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 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;
93 {--- Read-only dirs ---}
100 AllMapDirs
: SSArray
; // Maps + Megawads
102 {--- Read-Write dirs ---}
108 ScreenshotDirs
: SSArray
;
110 MapDownloadDirs
: SSArray
;
111 WadDownloadDirs
: SSArray
;
113 GameWADName
: string = 'GAME';
121 e_log
, e_input
, g_console
, g_sound
, g_gfx
, g_player
, Math
,
122 g_map
, g_net
, g_netmaster
, SysUtils
, CONFIG
, g_game
,
123 g_items
, wadreader
, envvars
;
128 function GenPlayerName (n
: Integer): String;
131 Result
:= GetUserName
;
133 Result
:= 'Player' + IntToStr(machine
MOD 10000);
135 Result
:= Copy(Result
, 1, 12) + ' '
137 Result
:= Copy(Result
, 1, 10) + ' ' + IntToStr(n
)
141 procedure g_Options_SetDefaultVideo
;
142 var display
: TSDL_DisplayMode
;
144 var target
, closest
: TSDL_DisplayMode
; percentage
: Integer;
147 (* Display 0 = Primary display *)
149 gScreenHeight
:= 480;
152 //gBPP := SDL_BITSPERPIXEL(display.format);
155 gFullScreen
:= True; (* rotation not allowed? *)
157 gFullScreen
:= False;
159 if SDL_GetDesktopDisplayMode(0, @display
) = 0 then
162 gWinSizeX
:= display
.w
;
163 gWinSizeY
:= display
.h
;
165 (* Window must be smaller than display *)
166 closest
.w
:= display
.w
;
167 closest
.h
:= display
.h
;
169 while (display
.w
- closest
.w
< 48) or (display
.h
- closest
.h
< 48) do
171 if percentage
< 25 then
173 closest
.w
:= display
.w
* 75 div 100;
174 closest
.h
:= display
.h
* 75 div 100;
177 target
.w
:= display
.w
* percentage
div 100;
178 target
.h
:= display
.h
* percentage
div 100;
179 target
.format
:= 0; (* didn't care *)
180 target
.refresh_rate
:= 0; (* didn't care *)
181 target
.driverdata
:= nil; (* init *)
182 SDL_GetClosestDisplayMode(0, @target
, @closest
);
185 gWinSizeX
:= closest
.w
;
186 gWinSizeY
:= closest
.h
;
187 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
192 e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError
])
194 (* Must be positioned on primary display *)
195 gWinMaximized
:= False;
197 gTextureFilter
:= True;
198 glLegacyNPOT
:= False;
199 gRC_Width
:= gWinSizeX
;
200 gRC_Height
:= gWinSizeY
;
201 gRC_FullScreen
:= gFullScreen
;
202 gRC_Maximized
:= gWinMaximized
;
203 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
204 g_Console_ResetBinds
;
207 procedure g_Options_SetDefaultVideo
;
212 gFullScreen
:= False;
213 gWinMaximized
:= False;
215 gTextureFilter
:= True;
216 glLegacyNPOT
:= False;
217 gScreenWidth
:= gWinSizeX
;
218 gScreenHeight
:= gWinSizeY
;
219 gRC_Width
:= gWinSizeX
;
220 gRC_Height
:= gWinSizeY
;
221 gRC_FullScreen
:= gFullScreen
;
222 gRC_Maximized
:= gWinMaximized
;
223 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
224 g_Console_ResetBinds
;
228 procedure g_Options_SetDefault();
237 gMuteWhenInactive
:= False;
238 gAnnouncer
:= ANNOUNCE_MEPLUS
;
239 gSoundEffectsDF
:= True;
240 gUseChatSounds
:= True;
241 gsSDLSampleRate
:= 44100;
242 gsSDLBufferSize
:= 2048;
244 g_Sound_SetupAllVolumes(gSoundLevel
, gMusicLevel
);
246 with gPlayer1Settings
do
248 Name
:= GenPlayerName(1);
249 Model
:= STD_PLAYER_MODEL
;
250 Color
.R
:= PLAYER1_DEF_COLOR
.R
;
251 Color
.G
:= PLAYER1_DEF_COLOR
.G
;
252 Color
.B
:= PLAYER1_DEF_COLOR
.B
;
256 with gPlayer2Settings
do
258 Name
:= GenPlayerName(2);
259 Model
:= STD_PLAYER_MODEL
;
260 Color
.R
:= PLAYER2_DEF_COLOR
.R
;
261 Color
.G
:= PLAYER2_DEF_COLOR
.G
;
262 Color
.B
:= PLAYER2_DEF_COLOR
.B
;
266 (* section Joysticks *)
267 for i
:= 0 to e_MaxJoys
- 1 do
269 e_JoystickDeadzones
[i
] := 8192
274 g_Shells_SetMax(300);
276 g_Corpses_SetMax(20);
283 gDrawBackGround
:= True;
284 gShowMessages
:= True;
285 gRevertPlayers
:= False;
287 wadoptDebug
:= False;
289 e_FastScreenshots
:= True;
290 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
294 gAskLanguage
:= True;
295 gLanguage
:= LANGUAGE_ENGLISH
;
298 gsGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
304 gsItemRespawnTime
:= 60;
305 gsGameFlags
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_DMKEYS
or
306 GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
or
307 GAME_OPTION_TEAMHITTRACE
or GAME_OPTION_TEAMHITPROJECTILE
or
308 GAME_OPTION_ALLOWDROPFLAG
;
312 g_Options_ApplyGameSettings
;
314 (* section MasterServer *)
315 NetMasterList
:= 'mpms.doom2d.org:25665, deadsoftware.ru:25665, terminalcorner.ru:25665';
316 g_Net_Slist_Set(NetMasterList
);
319 NetServerName
:= 'Unnamed Server';
323 NetAllowRCON
:= False;
324 NetRCONPassword
:= 'default';
325 NetUseMaster
:= True;
328 NetMasterRate
:= 60000;
329 NetForwardPorts
:= False;
333 NetForcePlayerUpdate
:= False;
334 NetPredictSelf
:= True;
335 NetClientIP
:= '127.0.0.1';
336 NetClientPort
:= NetPort
;
339 procedure g_Options_ApplyGameSettings
;
341 with gGameSettings
do
343 GameMode
:= g_Game_TextToMode(gsGameMode
);
344 if GameMode
= GM_NONE
then
346 if GameMode
= GM_SINGLE
then
348 TimeLimit
:= gsTimeLimit
;
349 ScoreLimit
:= gsScoreLimit
;
350 MaxLives
:= gsMaxLives
;
351 SpawnInvul
:= gsSpawnInvul
;
352 ItemRespawnTime
:= gsItemRespawnTime
;
353 WarmupTime
:= gsWarmupTime
;
354 Options
:= gsGameFlags
;
360 machine
:= Random(10000);
363 conRegVar('r_width', @gRC_Width
, '', '');
364 conRegVar('r_height', @gRC_Height
, '', '');
365 conRegVar('r_fullscreen', @gRC_FullScreen
, '', '');
366 conRegVar('r_maximized', @gRC_Maximized
, '', '');
367 conRegVar('r_bpp', @gBPP
, '', '');
368 conRegVar('r_vsync', @gVSync
, '', '');
369 conRegVar('r_texfilter', @gTextureFilter
, '', '');
370 conRegVar('r_npot', @glNPOTOverride
, '', '');
371 conRegVar('r_interp', @gLerpActors
, '', 'interpolate actors');
372 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
373 conRegVar('r_resolution_scale', @r_pixel_scale
, 0.01, 100.0, 'upscale factor', '', false);
376 conRegVar('s_nosound', @gNoSound
, '', '');
377 conRegVar('s_soundvolume', @gSoundLevel
, '', '');
378 conRegVar('s_musicvolume', @gMusicLevel
, '', '');
379 conRegVar('s_maxsim', @gMaxSimSounds
, '', ''); // e_sound_fmod/sdl?
380 conRegVar('s_muteinactive', @gMuteWhenInactive
, '', '');
381 conRegVar('s_announcer', @gAnnouncer
, '', '');
382 conRegVar('s_sfx', @gSoundEffectsDF
, '', '');
383 conRegVar('s_chatsounds', @gUseChatSounds
, '', '');
384 {$IFDEF USE_SDLMIXER}
385 conRegVar('sdl_mixer_samplerate', @gsSDLSampleRate
, '', '');
386 conRegVar('sdl_mixer_buffersize', @gsSDLBufferSize
, '', '');
390 conRegVar('g_gibs_count', @gGibsCount
, '', '');
391 conRegVar('g_blood_count', @gBloodCount
, '', '');
392 conRegVar('g_adv_blood', @gAdvBlood
, '', '');
393 conRegVar('g_adv_corpses', @gAdvCorpses
, '', '');
394 conRegVar('g_adv_gibs', @gAdvGibs
, '', '');
395 conRegVar('r_flash', @gFlash
, '', '');
396 conRegVar('r_background', @gDrawBackGround
, '', '');
397 conRegVar('g_show_messages', @gShowMessages
, '', '');
398 conRegVar('r_revert_players', @gRevertPlayers
, '', '');
399 conRegVar('r_chat_bubble', @gChatBubble
, '', '');
400 conRegVar('sfs_debug', @wadoptDebug
, '', '');
401 conRegVar('sfs_fastmode', @wadoptFast
, '', '');
402 conRegVar('g_fast_screenshots', @e_FastScreenshots
, '', '');
403 conRegVar('g_default_megawad', @gDefaultMegawadStart
, '', '');
404 conRegVar('g_save_stats', @gSaveStats
, '', '');
405 conRegVar('g_screenshot_stats', @gScreenshotStats
, '', '');
406 conRegVar('g_lastmap', @gsMap
, '', '');
408 conRegVar('d_input', @g_dbg_input
, '', '')