1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../shared/a_modes.inc}
21 g_language
, g_weapons
, utils
;
23 function GenPlayerName (n
: Integer): String;
25 procedure g_Options_SetDefault
;
26 procedure g_Options_SetDefaultVideo
;
27 procedure g_Options_ApplyGameSettings
;
29 const DF_Default_Megawad_Start
= 'megawads/DOOM2D.WAD:\MAP01';
35 gWinSizeX
, gWinSizeY
: Integer;
36 gWinMaximized
: Boolean;
38 glLegacyNPOT
: Boolean;
39 glRenderToFBO
: Boolean = True;
40 gTextureFilter
: Boolean;
41 gLerpActors
: Boolean = True;
42 gFrameTime
: Integer = 5;
43 gMaxFPS
: Integer = 200;
47 gMaxSimSounds
: Integer;
48 gMuteWhenInactive
: Boolean;
54 gDrawBackGround
: Boolean;
55 gShowMessages
: Boolean;
56 gRevertPlayers
: Boolean;
58 gAskLanguage
: Boolean;
59 gSaveStats
: Boolean = False;
60 gScreenshotStats
: Boolean = False;
61 gsSDLSampleRate
: Integer;
62 gsSDLBufferSize
: Integer;
63 gDefaultMegawadStart
: AnsiString;
64 gBerserkAutoswitch
: Boolean;
65 glNPOTOverride
: Boolean = false;
67 (* Latched game settings *)
74 gsGameFlags
: LongWord;
75 gsSpawnInvul
: Integer = 0;
76 gsItemRespawnTime
: Word = 60;
77 gsWarmupTime
: Word = 30;
80 e_NoGraphics
: Boolean = True;
82 e_NoGraphics
: Boolean = False;
84 e_FastScreenshots
: Boolean = true; // it's REALLY SLOW with `false`
85 g_dbg_scale
: Single = 1.0;
86 r_pixel_scale
: Single = 1.0;
88 gwin_has_stencil
: Boolean = false;
89 gwin_k8_enable_light_experiments
: Boolean = false;
90 g_dbg_aimline_on
: Boolean = false;
91 g_dbg_input
: Boolean = False;
94 g_touch_enabled
: Boolean = False;
95 g_touch_size
: Single = 1.0;
96 g_touch_offset
: Single = 50.0;
97 g_touch_fire
: Boolean = True;
98 g_touch_alt
: Boolean = False;
100 {--- Read-only dirs ---}
104 MegawadDirs
: SSArray
;
107 AllMapDirs
: SSArray
; // Maps + Megawads
109 {--- Read-Write dirs ---}
115 ScreenshotDirs
: SSArray
;
117 MapDownloadDirs
: SSArray
;
118 WadDownloadDirs
: SSArray
;
120 GameWADName
: string = 'GAME';
134 {$IFDEF ENABLE_SHELLS}
137 e_log
, e_input
, g_console
, g_sound
, g_player
, Math
,
138 g_map
, g_net
, g_netmaster
, SysUtils
, CONFIG
, g_game
,
139 g_items
, wadreader
, envvars
;
144 function GenPlayerName (n
: Integer): String;
147 Result
:= GetUserName
;
149 Result
:= 'Player' + IntToStr(machine
MOD 10000);
151 Result
:= Copy(Result
, 1, 12) + ' '
153 Result
:= Copy(Result
, 1, 10) + ' ' + IntToStr(n
)
157 procedure g_Options_SetDefaultVideo
;
158 var display
: TSDL_DisplayMode
;
160 var target
, closest
: TSDL_DisplayMode
; percentage
: Integer;
163 (* Display 0 = Primary display *)
165 gScreenHeight
:= 480;
168 //gBPP := SDL_BITSPERPIXEL(dispaly.format);
171 gFullScreen
:= True; (* rotation not allowed? *)
173 gFullScreen
:= False;
175 if SDL_GetDesktopDisplayMode(0, @display
) = 0 then
178 gWinSizeX
:= display
.w
;
179 gWinSizeY
:= display
.h
;
181 (* Window must be smaller than display *)
182 closest
.w
:= display
.w
;
183 closest
.h
:= display
.h
;
185 while (display
.w
- closest
.w
< 48) or (display
.h
- closest
.h
< 48) do
187 if percentage
< 25 then
189 closest
.w
:= display
.w
* 75 div 100;
190 closest
.h
:= display
.h
* 75 div 100;
193 target
.w
:= display
.w
* percentage
div 100;
194 target
.h
:= display
.h
* percentage
div 100;
195 target
.format
:= 0; (* didn't care *)
196 target
.refresh_rate
:= 0; (* didn't care *)
197 target
.driverdata
:= nil; (* init *)
198 SDL_GetClosestDisplayMode(0, @target
, @closest
);
201 gWinSizeX
:= closest
.w
;
202 gWinSizeY
:= closest
.h
;
203 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
208 e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError
])
210 (* Must be positioned on primary display *)
211 gWinMaximized
:= False;
213 gTextureFilter
:= True;
214 glLegacyNPOT
:= False;
215 gRC_Width
:= gWinSizeX
;
216 gRC_Height
:= gWinSizeY
;
217 gRC_FullScreen
:= gFullScreen
;
218 gRC_Maximized
:= gWinMaximized
;
219 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
220 g_Console_ResetBinds
;
223 procedure g_Options_SetDefaultVideo
;
228 gFullScreen
:= False;
229 gWinMaximized
:= False;
231 gTextureFilter
:= True;
232 glLegacyNPOT
:= False;
233 gScreenWidth
:= gWinSizeX
;
234 gScreenHeight
:= gWinSizeY
;
235 gRC_Width
:= gWinSizeX
;
236 gRC_Height
:= gWinSizeY
;
237 gRC_FullScreen
:= gFullScreen
;
238 gRC_Maximized
:= gWinMaximized
;
239 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
240 g_Console_ResetBinds
;
244 procedure g_Options_SetDefault();
253 gMuteWhenInactive
:= False;
254 gAnnouncer
:= ANNOUNCE_MEPLUS
;
255 gSoundEffectsDF
:= True;
256 gUseChatSounds
:= True;
257 gsSDLSampleRate
:= 44100;
258 gsSDLBufferSize
:= 2048;
260 g_Sound_SetupAllVolumes(gSoundLevel
, gMusicLevel
);
262 with gPlayer1Settings
do
264 Name
:= GenPlayerName(1);
265 Model
:= STD_PLAYER_MODEL
;
266 Color
.R
:= PLAYER1_DEF_COLOR
.R
;
267 Color
.G
:= PLAYER1_DEF_COLOR
.G
;
268 Color
.B
:= PLAYER1_DEF_COLOR
.B
;
272 with gPlayer2Settings
do
274 Name
:= GenPlayerName(2);
275 Model
:= STD_PLAYER_MODEL
;
276 Color
.R
:= PLAYER2_DEF_COLOR
.R
;
277 Color
.G
:= PLAYER2_DEF_COLOR
.G
;
278 Color
.B
:= PLAYER2_DEF_COLOR
.B
;
282 (* section Joysticks *)
283 for i
:= 0 to e_MaxJoys
- 1 do
285 e_JoystickDeadzones
[i
] := 8192
292 {$IFDEF ENABLE_SHELLS}
293 g_Shells_SetMax(DefaultShellMax
);
295 g_Corpses_SetMax(20);
297 g_Gibs_SetMax(DefaultGibsMax
);
298 gGibsCount
:= DefaultGibsCount
;
305 gDrawBackGround
:= True;
306 gShowMessages
:= True;
307 gRevertPlayers
:= False;
309 wadoptDebug
:= False;
311 e_FastScreenshots
:= True;
312 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
313 gBerserkAutoswitch
:= True;
317 gAskLanguage
:= True;
318 gLanguage
:= LANGUAGE_ENGLISH
;
321 gsGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
327 gsItemRespawnTime
:= 60;
328 gsGameFlags
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_DMKEYS
or
329 GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
or
330 GAME_OPTION_TEAMHITTRACE
or GAME_OPTION_TEAMHITPROJECTILE
;
333 (* section MasterServer *)
334 NetMasterList
:= 'mpms.doom2d.org:25665, deadsoftware.ru:25665';
335 g_Net_Slist_Set(NetMasterList
);
338 NetServerName
:= 'Unnamed Server';
342 NetAllowRCON
:= False;
343 NetRCONPassword
:= 'default';
344 NetUseMaster
:= True;
347 NetMasterRate
:= 60000;
348 NetForwardPorts
:= False;
352 NetForcePlayerUpdate
:= False;
353 NetPredictSelf
:= True;
354 NetClientIP
:= '127.0.0.1';
355 NetClientPort
:= NetPort
;
358 procedure g_Options_ApplyGameSettings
;
360 with gGameSettings
do
362 GameMode
:= g_Game_TextToMode(gsGameMode
);
363 if GameMode
= GM_NONE
then
365 if GameMode
= GM_SINGLE
then
367 TimeLimit
:= gsTimeLimit
;
368 GoalLimit
:= gsGoalLimit
;
369 MaxLives
:= gsMaxLives
;
370 SpawnInvul
:= gsSpawnInvul
;
371 ItemRespawnTime
:= gsItemRespawnTime
;
372 WarmupTime
:= gsWarmupTime
;
373 Options
:= gsGameFlags
;
379 machine
:= Random(10000);
382 conRegVar('r_width', @gRC_Width
, '', '');
383 conRegVar('r_height', @gRC_Height
, '', '');
384 conRegVar('r_fullscreen', @gRC_FullScreen
, '', '');
385 conRegVar('r_maximized', @gRC_Maximized
, '', '');
386 conRegVar('r_bpp', @gBPP
, '', '');
387 conRegVar('r_vsync', @gVSync
, '', '');
388 conRegVar('r_texfilter', @gTextureFilter
, '', '');
389 conRegVar('r_npot', @glNPOTOverride
, '', '');
390 conRegVar('r_interp', @gLerpActors
, '', 'interpolate actors');
391 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
392 conRegVar('r_resolution_scale', @r_pixel_scale
, 0.01, 100.0, 'upscale factor', '', false);
395 conRegVar('s_nosound', @gNoSound
, '', '');
396 conRegVar('s_soundvolume', @gSoundLevel
, '', '');
397 conRegVar('s_musicvolume', @gMusicLevel
, '', '');
398 conRegVar('s_maxsim', @gMaxSimSounds
, '', ''); // e_sound_fmod/sdl?
399 conRegVar('s_muteinactive', @gMuteWhenInactive
, '', '');
400 conRegVar('s_announcer', @gAnnouncer
, '', '');
401 conRegVar('s_sfx', @gSoundEffectsDF
, '', '');
402 conRegVar('s_chatsounds', @gUseChatSounds
, '', '');
403 {$IFDEF USE_SDLMIXER}
404 conRegVar('sdl_mixer_samplerate', @gsSDLSampleRate
, '', '');
405 conRegVar('sdl_mixer_buffersize', @gsSDLBufferSize
, '', '');
410 conRegVar('g_gibs_count', @gGibsCount
, '', '');
412 conRegVar('g_blood_count', @gBloodCount
, '', '');
413 conRegVar('g_adv_blood', @gAdvBlood
, '', '');
414 conRegVar('g_adv_corpses', @gAdvCorpses
, '', '');
415 conRegVar('g_adv_gibs', @gAdvGibs
, '', '');
416 conRegVar('r_flash', @gFlash
, '', '');
417 conRegVar('r_background', @gDrawBackGround
, '', '');
418 conRegVar('g_show_messages', @gShowMessages
, '', '');
419 conRegVar('r_revert_players', @gRevertPlayers
, '', '');
420 conRegVar('r_chat_bubble', @gChatBubble
, '', '');
421 conRegVar('sfs_debug', @wadoptDebug
, '', '');
422 conRegVar('sfs_fastmode', @wadoptFast
, '', '');
423 conRegVar('g_fast_screenshots', @e_FastScreenshots
, '', '');
424 conRegVar('g_default_megawad', @gDefaultMegawadStart
, '', '');
425 conRegVar('g_save_stats', @gSaveStats
, '', '');
426 conRegVar('g_screenshot_stats', @gScreenshotStats
, '', '');
427 conRegVar('g_lastmap', @gsMap
, '', '');
429 conRegVar('d_input', @g_dbg_input
, '', '');
432 conRegVar('touch_enable', @g_touch_enabled
, 'enable/disable virtual buttons', 'draw buttons');
433 conRegVar('touch_fire', @g_touch_fire
, 'enable/disable fire when press virtual up/down', 'fire when press up/down');
434 conRegVar('touch_size', @g_touch_size
, 0.1, 10, 'size of virtual buttons', 'button size');
435 conRegVar('touch_offset', @g_touch_offset
, 0, 100, '', '');
436 conRegVar('touch_alt', @g_touch_alt
, 'althernative virtual buttons layout', 'althernative layout');