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;
55 gDrawBackGround
: Boolean;
56 gShowMessages
: Boolean;
57 gRevertPlayers
: Boolean;
59 gAskLanguage
: Boolean;
60 gSaveStats
: Boolean = False;
61 gScreenshotStats
: Boolean = False;
62 gsSDLSampleRate
: Integer;
63 gsSDLBufferSize
: Integer;
64 gDefaultMegawadStart
: AnsiString;
65 gBerserkAutoswitch
: Boolean;
66 glNPOTOverride
: Boolean = false;
68 (* Latched game settings *)
75 gsGameFlags
: LongWord;
76 gsSpawnInvul
: Integer = 0;
77 gsItemRespawnTime
: Word = 60;
78 gsWarmupTime
: Word = 30;
81 e_NoGraphics
: Boolean = True;
83 e_NoGraphics
: Boolean = False;
85 e_FastScreenshots
: Boolean = true; // it's REALLY SLOW with `false`
86 g_dbg_scale
: Single = 1.0;
87 r_pixel_scale
: Single = 1.0;
89 {--- Read-only dirs ---}
96 AllMapDirs
: SSArray
; // Maps + Megawads
98 {--- Read-Write dirs ---}
104 ScreenshotDirs
: SSArray
;
106 MapDownloadDirs
: SSArray
;
107 WadDownloadDirs
: SSArray
;
109 GameWADName
: string = 'GAME';
117 e_log
, e_input
, g_console
, g_window
, g_sound
, g_gfx
, g_player
, Math
,
118 g_map
, g_net
, g_netmaster
, SysUtils
, CONFIG
, g_game
,
119 g_items
, wadreader
, g_touch
, envvars
, g_system
;
124 function GenPlayerName (n
: Integer): String;
127 Result
:= GetUserName
;
129 Result
:= 'Player' + IntToStr(machine
MOD 10000);
131 Result
:= Copy(Result
, 1, 12) + ' '
133 Result
:= Copy(Result
, 1, 10) + ' ' + IntToStr(n
)
137 procedure g_Options_SetDefaultVideo
;
138 var display
: TSDL_DisplayMode
;
140 var target
, closest
: TSDL_DisplayMode
; percentage
: Integer;
143 (* Display 0 = Primary display *)
145 gScreenHeight
:= 480;
148 //gBPP := SDL_BITSPERPIXEL(dispaly.format);
151 gFullScreen
:= True; (* rotation not allowed? *)
153 gFullScreen
:= False;
155 if SDL_GetDesktopDisplayMode(0, @display
) = 0 then
158 gWinSizeX
:= display
.w
;
159 gWinSizeY
:= display
.h
;
161 (* Window must be smaller than display *)
162 closest
.w
:= display
.w
;
163 closest
.h
:= display
.h
;
165 while (display
.w
- closest
.w
< 48) or (display
.h
- closest
.h
< 48) do
167 if percentage
< 25 then
169 closest
.w
:= display
.w
* 75 div 100;
170 closest
.h
:= display
.h
* 75 div 100;
173 target
.w
:= display
.w
* percentage
div 100;
174 target
.h
:= display
.h
* percentage
div 100;
175 target
.format
:= 0; (* didn't care *)
176 target
.refresh_rate
:= 0; (* didn't care *)
177 target
.driverdata
:= nil; (* init *)
178 SDL_GetClosestDisplayMode(0, @target
, @closest
);
181 gWinSizeX
:= closest
.w
;
182 gWinSizeY
:= closest
.h
;
183 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
188 e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError
])
190 (* Must be positioned on primary display *)
191 gWinMaximized
:= False;
193 gTextureFilter
:= True;
194 glLegacyNPOT
:= False;
195 gRC_Width
:= gWinSizeX
;
196 gRC_Height
:= gWinSizeY
;
197 gRC_FullScreen
:= gFullScreen
;
198 gRC_Maximized
:= gWinMaximized
;
199 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
200 g_Console_ResetBinds
;
203 procedure g_Options_SetDefaultVideo
;
208 gFullScreen
:= False;
209 gWinMaximized
:= False;
211 gTextureFilter
:= True;
212 glLegacyNPOT
:= False;
213 gScreenWidth
:= gWinSizeX
;
214 gScreenHeight
:= gWinSizeY
;
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
;
224 procedure g_Options_SetDefault();
233 gMuteWhenInactive
:= False;
234 gAnnouncer
:= ANNOUNCE_MEPLUS
;
235 gSoundEffectsDF
:= True;
236 gUseChatSounds
:= True;
237 gsSDLSampleRate
:= 44100;
238 gsSDLBufferSize
:= 2048;
240 g_Sound_SetupAllVolumes(gSoundLevel
, gMusicLevel
);
242 with gPlayer1Settings
do
244 Name
:= GenPlayerName(1);
245 Model
:= STD_PLAYER_MODEL
;
246 Color
.R
:= PLAYER1_DEF_COLOR
.R
;
247 Color
.G
:= PLAYER1_DEF_COLOR
.G
;
248 Color
.B
:= PLAYER1_DEF_COLOR
.B
;
252 with gPlayer2Settings
do
254 Name
:= GenPlayerName(2);
255 Model
:= STD_PLAYER_MODEL
;
256 Color
.R
:= PLAYER2_DEF_COLOR
.R
;
257 Color
.G
:= PLAYER2_DEF_COLOR
.G
;
258 Color
.B
:= PLAYER2_DEF_COLOR
.B
;
262 (* section Joysticks *)
263 for i
:= 0 to e_MaxJoys
- 1 do
265 e_JoystickDeadzones
[i
] := 8192
270 g_Shells_SetMax(300);
272 g_Corpses_SetMax(20);
279 gDrawBackGround
:= True;
280 gShowMessages
:= True;
281 gRevertPlayers
:= False;
283 wadoptDebug
:= False;
285 e_FastScreenshots
:= True;
286 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
287 gBerserkAutoswitch
:= True;
291 gAskLanguage
:= True;
292 gLanguage
:= LANGUAGE_ENGLISH
;
295 gsGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
301 gsItemRespawnTime
:= 60;
302 gsGameFlags
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_DMKEYS
or
303 GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
or
304 GAME_OPTION_TEAMHITTRACE
or GAME_OPTION_TEAMHITPROJECTILE
;
307 (* section MasterServer *)
308 NetMasterList
:= 'mpms.doom2d.org:25665, deadsoftware.ru:25665';
309 g_Net_Slist_Set(NetMasterList
);
312 NetServerName
:= 'Unnamed Server';
316 NetAllowRCON
:= False;
317 NetRCONPassword
:= 'default';
318 NetUseMaster
:= True;
321 NetMasterRate
:= 60000;
322 NetForwardPorts
:= False;
326 NetForcePlayerUpdate
:= False;
327 NetPredictSelf
:= True;
328 NetClientIP
:= '127.0.0.1';
329 NetClientPort
:= NetPort
;
332 procedure g_Options_ApplyGameSettings
;
334 with gGameSettings
do
336 GameMode
:= g_Game_TextToMode(gsGameMode
);
337 if GameMode
= GM_NONE
then
339 if GameMode
= GM_SINGLE
then
341 TimeLimit
:= gsTimeLimit
;
342 GoalLimit
:= gsGoalLimit
;
343 MaxLives
:= gsMaxLives
;
344 SpawnInvul
:= gsSpawnInvul
;
345 ItemRespawnTime
:= gsItemRespawnTime
;
346 WarmupTime
:= gsWarmupTime
;
347 Options
:= gsGameFlags
;
353 machine
:= Random(10000);
356 conRegVar('r_width', @gRC_Width
, '', '');
357 conRegVar('r_height', @gRC_Height
, '', '');
358 conRegVar('r_fullscreen', @gRC_FullScreen
, '', '');
359 conRegVar('r_maximized', @gRC_Maximized
, '', '');
360 conRegVar('r_bpp', @gBPP
, '', '');
361 conRegVar('r_vsync', @gVSync
, '', '');
362 conRegVar('r_texfilter', @gTextureFilter
, '', '');
363 conRegVar('r_npot', @glNPOTOverride
, '', '');
364 conRegVar('r_interp', @gLerpActors
, '', 'interpolate actors');
365 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
366 conRegVar('r_resolution_scale', @r_pixel_scale
, 0.01, 100.0, 'upscale factor', '', false);
369 conRegVar('s_nosound', @gNoSound
, '', '');
370 conRegVar('s_soundvolume', @gSoundLevel
, '', '');
371 conRegVar('s_musicvolume', @gMusicLevel
, '', '');
372 conRegVar('s_maxsim', @gMaxSimSounds
, '', ''); // e_sound_fmod/sdl?
373 conRegVar('s_muteinactive', @gMuteWhenInactive
, '', '');
374 conRegVar('s_announcer', @gAnnouncer
, '', '');
375 conRegVar('s_sfx', @gSoundEffectsDF
, '', '');
376 conRegVar('s_chatsounds', @gUseChatSounds
, '', '');
377 {$IFDEF USE_SDLMIXER}
378 conRegVar('sdl_mixer_samplerate', @gsSDLSampleRate
, '', '');
379 conRegVar('sdl_mixer_buffersize', @gsSDLBufferSize
, '', '');
383 conRegVar('g_gibs_count', @gGibsCount
, '', '');
384 conRegVar('g_blood_count', @gBloodCount
, '', '');
385 conRegVar('g_adv_blood', @gAdvBlood
, '', '');
386 conRegVar('g_adv_corpses', @gAdvCorpses
, '', '');
387 conRegVar('g_adv_gibs', @gAdvGibs
, '', '');
388 conRegVar('r_flash', @gFlash
, '', '');
389 conRegVar('r_background', @gDrawBackGround
, '', '');
390 conRegVar('g_show_messages', @gShowMessages
, '', '');
391 conRegVar('r_revert_players', @gRevertPlayers
, '', '');
392 conRegVar('r_chat_bubble', @gChatBubble
, '', '');
393 conRegVar('sfs_debug', @wadoptDebug
, '', '');
394 conRegVar('sfs_fastmode', @wadoptFast
, '', '');
395 conRegVar('g_fast_screenshots', @e_FastScreenshots
, '', '');
396 conRegVar('g_default_megawad', @gDefaultMegawadStart
, '', '');
397 conRegVar('g_save_stats', @gSaveStats
, '', '');
398 conRegVar('g_screenshot_stats', @gScreenshotStats
, '', '');
399 conRegVar('g_lastmap', @gsMap
, '', '');