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 {$IFDEF ENABLE_CORPSES}
140 e_log
, e_input
, g_console
, g_sound
, g_player
, Math
,
141 g_map
, g_net
, g_netmaster
, SysUtils
, CONFIG
, g_game
,
142 g_items
, wadreader
, envvars
;
147 function GenPlayerName (n
: Integer): String;
150 Result
:= GetUserName
;
152 Result
:= 'Player' + IntToStr(machine
MOD 10000);
154 Result
:= Copy(Result
, 1, 12) + ' '
156 Result
:= Copy(Result
, 1, 10) + ' ' + IntToStr(n
)
160 procedure g_Options_SetDefaultVideo
;
161 var display
: TSDL_DisplayMode
;
163 var target
, closest
: TSDL_DisplayMode
; percentage
: Integer;
166 (* Display 0 = Primary display *)
168 gScreenHeight
:= 480;
171 //gBPP := SDL_BITSPERPIXEL(dispaly.format);
174 gFullScreen
:= True; (* rotation not allowed? *)
176 gFullScreen
:= False;
178 if SDL_GetDesktopDisplayMode(0, @display
) = 0 then
181 gWinSizeX
:= display
.w
;
182 gWinSizeY
:= display
.h
;
184 (* Window must be smaller than display *)
185 closest
.w
:= display
.w
;
186 closest
.h
:= display
.h
;
188 while (display
.w
- closest
.w
< 48) or (display
.h
- closest
.h
< 48) do
190 if percentage
< 25 then
192 closest
.w
:= display
.w
* 75 div 100;
193 closest
.h
:= display
.h
* 75 div 100;
196 target
.w
:= display
.w
* percentage
div 100;
197 target
.h
:= display
.h
* percentage
div 100;
198 target
.format
:= 0; (* didn't care *)
199 target
.refresh_rate
:= 0; (* didn't care *)
200 target
.driverdata
:= nil; (* init *)
201 SDL_GetClosestDisplayMode(0, @target
, @closest
);
204 gWinSizeX
:= closest
.w
;
205 gWinSizeY
:= closest
.h
;
206 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
211 e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError
])
213 (* Must be positioned on primary display *)
214 gWinMaximized
:= False;
216 gTextureFilter
:= True;
217 glLegacyNPOT
:= False;
218 gRC_Width
:= gWinSizeX
;
219 gRC_Height
:= gWinSizeY
;
220 gRC_FullScreen
:= gFullScreen
;
221 gRC_Maximized
:= gWinMaximized
;
222 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
223 g_Console_ResetBinds
;
226 procedure g_Options_SetDefaultVideo
;
231 gFullScreen
:= False;
232 gWinMaximized
:= False;
234 gTextureFilter
:= True;
235 glLegacyNPOT
:= False;
236 gScreenWidth
:= gWinSizeX
;
237 gScreenHeight
:= gWinSizeY
;
238 gRC_Width
:= gWinSizeX
;
239 gRC_Height
:= gWinSizeY
;
240 gRC_FullScreen
:= gFullScreen
;
241 gRC_Maximized
:= gWinMaximized
;
242 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
243 g_Console_ResetBinds
;
247 procedure g_Options_SetDefault();
256 gMuteWhenInactive
:= False;
257 gAnnouncer
:= ANNOUNCE_MEPLUS
;
258 gSoundEffectsDF
:= True;
259 gUseChatSounds
:= True;
260 gsSDLSampleRate
:= 44100;
261 gsSDLBufferSize
:= 2048;
263 g_Sound_SetupAllVolumes(gSoundLevel
, gMusicLevel
);
265 with gPlayer1Settings
do
267 Name
:= GenPlayerName(1);
268 Model
:= STD_PLAYER_MODEL
;
269 Color
.R
:= PLAYER1_DEF_COLOR
.R
;
270 Color
.G
:= PLAYER1_DEF_COLOR
.G
;
271 Color
.B
:= PLAYER1_DEF_COLOR
.B
;
275 with gPlayer2Settings
do
277 Name
:= GenPlayerName(2);
278 Model
:= STD_PLAYER_MODEL
;
279 Color
.R
:= PLAYER2_DEF_COLOR
.R
;
280 Color
.G
:= PLAYER2_DEF_COLOR
.G
;
281 Color
.B
:= PLAYER2_DEF_COLOR
.B
;
285 (* section Joysticks *)
286 for i
:= 0 to e_MaxJoys
- 1 do
288 e_JoystickDeadzones
[i
] := 8192
295 {$IFDEF ENABLE_SHELLS}
296 g_Shells_SetMax(DefaultShellMax
);
298 {$IFDEF ENABLE_CORPSES}
299 g_Corpses_SetMax(DefaultCorpsesMax
);
302 g_Gibs_SetMax(DefaultGibsMax
);
303 gGibsCount
:= DefaultGibsCount
;
310 gDrawBackGround
:= True;
311 gShowMessages
:= True;
312 gRevertPlayers
:= False;
314 wadoptDebug
:= False;
316 e_FastScreenshots
:= True;
317 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
318 gBerserkAutoswitch
:= True;
322 gAskLanguage
:= True;
323 gLanguage
:= LANGUAGE_ENGLISH
;
326 gsGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
332 gsItemRespawnTime
:= 60;
333 gsGameFlags
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_DMKEYS
or
334 GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
or
335 GAME_OPTION_TEAMHITTRACE
or GAME_OPTION_TEAMHITPROJECTILE
;
338 (* section MasterServer *)
339 NetMasterList
:= 'mpms.doom2d.org:25665, deadsoftware.ru:25665';
340 g_Net_Slist_Set(NetMasterList
);
343 NetServerName
:= 'Unnamed Server';
347 NetAllowRCON
:= False;
348 NetRCONPassword
:= 'default';
349 NetUseMaster
:= True;
352 NetMasterRate
:= 60000;
353 NetForwardPorts
:= False;
357 NetForcePlayerUpdate
:= False;
358 NetPredictSelf
:= True;
359 NetClientIP
:= '127.0.0.1';
360 NetClientPort
:= NetPort
;
363 procedure g_Options_ApplyGameSettings
;
365 with gGameSettings
do
367 GameMode
:= g_Game_TextToMode(gsGameMode
);
368 if GameMode
= GM_NONE
then
370 if GameMode
= GM_SINGLE
then
372 TimeLimit
:= gsTimeLimit
;
373 GoalLimit
:= gsGoalLimit
;
374 MaxLives
:= gsMaxLives
;
375 SpawnInvul
:= gsSpawnInvul
;
376 ItemRespawnTime
:= gsItemRespawnTime
;
377 WarmupTime
:= gsWarmupTime
;
378 Options
:= gsGameFlags
;
384 machine
:= Random(10000);
387 conRegVar('r_width', @gRC_Width
, '', '');
388 conRegVar('r_height', @gRC_Height
, '', '');
389 conRegVar('r_fullscreen', @gRC_FullScreen
, '', '');
390 conRegVar('r_maximized', @gRC_Maximized
, '', '');
391 conRegVar('r_bpp', @gBPP
, '', '');
392 conRegVar('r_vsync', @gVSync
, '', '');
393 conRegVar('r_texfilter', @gTextureFilter
, '', '');
394 conRegVar('r_npot', @glNPOTOverride
, '', '');
395 conRegVar('r_interp', @gLerpActors
, '', 'interpolate actors');
396 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
397 conRegVar('r_resolution_scale', @r_pixel_scale
, 0.01, 100.0, 'upscale factor', '', false);
400 conRegVar('s_nosound', @gNoSound
, '', '');
401 conRegVar('s_soundvolume', @gSoundLevel
, '', '');
402 conRegVar('s_musicvolume', @gMusicLevel
, '', '');
403 conRegVar('s_maxsim', @gMaxSimSounds
, '', ''); // e_sound_fmod/sdl?
404 conRegVar('s_muteinactive', @gMuteWhenInactive
, '', '');
405 conRegVar('s_announcer', @gAnnouncer
, '', '');
406 conRegVar('s_sfx', @gSoundEffectsDF
, '', '');
407 conRegVar('s_chatsounds', @gUseChatSounds
, '', '');
408 {$IFDEF USE_SDLMIXER}
409 conRegVar('sdl_mixer_samplerate', @gsSDLSampleRate
, '', '');
410 conRegVar('sdl_mixer_buffersize', @gsSDLBufferSize
, '', '');
415 conRegVar('g_gibs_count', @gGibsCount
, '', '');
417 conRegVar('g_blood_count', @gBloodCount
, '', '');
418 conRegVar('g_adv_blood', @gAdvBlood
, '', '');
419 conRegVar('g_adv_corpses', @gAdvCorpses
, '', '');
420 conRegVar('g_adv_gibs', @gAdvGibs
, '', '');
421 conRegVar('r_flash', @gFlash
, '', '');
422 conRegVar('r_background', @gDrawBackGround
, '', '');
423 conRegVar('g_show_messages', @gShowMessages
, '', '');
424 conRegVar('r_revert_players', @gRevertPlayers
, '', '');
425 conRegVar('r_chat_bubble', @gChatBubble
, '', '');
426 conRegVar('sfs_debug', @wadoptDebug
, '', '');
427 conRegVar('sfs_fastmode', @wadoptFast
, '', '');
428 conRegVar('g_fast_screenshots', @e_FastScreenshots
, '', '');
429 conRegVar('g_default_megawad', @gDefaultMegawadStart
, '', '');
430 conRegVar('g_save_stats', @gSaveStats
, '', '');
431 conRegVar('g_screenshot_stats', @gScreenshotStats
, '', '');
432 conRegVar('g_lastmap', @gsMap
, '', '');
434 conRegVar('d_input', @g_dbg_input
, '', '');
437 conRegVar('touch_enable', @g_touch_enabled
, 'enable/disable virtual buttons', 'draw buttons');
438 conRegVar('touch_fire', @g_touch_fire
, 'enable/disable fire when press virtual up/down', 'fire when press up/down');
439 conRegVar('touch_size', @g_touch_size
, 0.1, 10, 'size of virtual buttons', 'button size');
440 conRegVar('touch_offset', @g_touch_offset
, 0, 100, '', '');
441 conRegVar('touch_alt', @g_touch_alt
, 'althernative virtual buttons layout', 'althernative layout');