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;
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';
128 e_log
, e_input
, g_console
, g_sound
, g_gfx
, g_player
, Math
,
129 g_map
, g_net
, g_netmaster
, SysUtils
, CONFIG
, g_game
,
130 g_items
, wadreader
, envvars
;
135 function GenPlayerName (n
: Integer): String;
138 Result
:= GetUserName
;
140 Result
:= 'Player' + IntToStr(machine
MOD 10000);
142 Result
:= Copy(Result
, 1, 12) + ' '
144 Result
:= Copy(Result
, 1, 10) + ' ' + IntToStr(n
)
148 procedure g_Options_SetDefaultVideo
;
149 var display
: TSDL_DisplayMode
;
151 var target
, closest
: TSDL_DisplayMode
; percentage
: Integer;
154 (* Display 0 = Primary display *)
156 gScreenHeight
:= 480;
159 //gBPP := SDL_BITSPERPIXEL(display.format);
162 gFullScreen
:= True; (* rotation not allowed? *)
164 gFullScreen
:= False;
166 if SDL_GetDesktopDisplayMode(0, @display
) = 0 then
169 gWinSizeX
:= display
.w
;
170 gWinSizeY
:= display
.h
;
172 (* Window must be smaller than display *)
173 closest
.w
:= display
.w
;
174 closest
.h
:= display
.h
;
176 while (display
.w
- closest
.w
< 48) or (display
.h
- closest
.h
< 48) do
178 if percentage
< 25 then
180 closest
.w
:= display
.w
* 75 div 100;
181 closest
.h
:= display
.h
* 75 div 100;
184 target
.w
:= display
.w
* percentage
div 100;
185 target
.h
:= display
.h
* percentage
div 100;
186 target
.format
:= 0; (* didn't care *)
187 target
.refresh_rate
:= 0; (* didn't care *)
188 target
.driverdata
:= nil; (* init *)
189 SDL_GetClosestDisplayMode(0, @target
, @closest
);
192 gWinSizeX
:= closest
.w
;
193 gWinSizeY
:= closest
.h
;
194 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
199 e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError
])
201 (* Must be positioned on primary display *)
202 gWinMaximized
:= False;
204 gTextureFilter
:= True;
205 glLegacyNPOT
:= False;
206 gRC_Width
:= gWinSizeX
;
207 gRC_Height
:= gWinSizeY
;
208 gRC_FullScreen
:= gFullScreen
;
209 gRC_Maximized
:= gWinMaximized
;
210 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
211 g_Console_ResetBinds
;
214 procedure g_Options_SetDefaultVideo
;
219 gFullScreen
:= False;
220 gWinMaximized
:= False;
222 gTextureFilter
:= True;
223 glLegacyNPOT
:= False;
224 gScreenWidth
:= gWinSizeX
;
225 gScreenHeight
:= gWinSizeY
;
226 gRC_Width
:= gWinSizeX
;
227 gRC_Height
:= gWinSizeY
;
228 gRC_FullScreen
:= gFullScreen
;
229 gRC_Maximized
:= gWinMaximized
;
230 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
231 g_Console_ResetBinds
;
235 procedure g_Options_SetDefault();
244 gMuteWhenInactive
:= False;
245 gAnnouncer
:= ANNOUNCE_MEPLUS
;
246 gSoundEffectsDF
:= True;
247 gUseChatSounds
:= True;
248 gsSDLSampleRate
:= 44100;
249 gsSDLBufferSize
:= 2048;
251 g_Sound_SetupAllVolumes(gSoundLevel
, gMusicLevel
);
253 with gPlayer1Settings
do
255 Name
:= GenPlayerName(1);
256 Model
:= STD_PLAYER_MODEL
;
257 Color
.R
:= PLAYER1_DEF_COLOR
.R
;
258 Color
.G
:= PLAYER1_DEF_COLOR
.G
;
259 Color
.B
:= PLAYER1_DEF_COLOR
.B
;
263 with gPlayer2Settings
do
265 Name
:= GenPlayerName(2);
266 Model
:= STD_PLAYER_MODEL
;
267 Color
.R
:= PLAYER2_DEF_COLOR
.R
;
268 Color
.G
:= PLAYER2_DEF_COLOR
.G
;
269 Color
.B
:= PLAYER2_DEF_COLOR
.B
;
273 (* section Joysticks *)
274 for i
:= 0 to e_MaxJoys
- 1 do
276 e_JoystickDeadzones
[i
] := 8192
281 g_Shells_SetMax(300);
283 g_Corpses_SetMax(20);
290 gDrawBackGround
:= True;
291 gShowMessages
:= True;
292 gRevertPlayers
:= False;
294 wadoptDebug
:= False;
296 e_FastScreenshots
:= True;
297 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
301 gAskLanguage
:= True;
302 gLanguage
:= LANGUAGE_ENGLISH
;
305 gsGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
311 gsItemRespawnTime
:= 60;
312 gsGameFlags
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_DMKEYS
or
313 GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
or
314 GAME_OPTION_TEAMHITTRACE
or GAME_OPTION_TEAMHITPROJECTILE
or
315 GAME_OPTION_ALLOWDROPFLAG
;
319 g_Options_ApplyGameSettings
;
321 (* section MasterServer *)
322 NetMasterList
:= 'mpms.doom2d.org:25665, deadsoftware.ru:25665, terminalcorner.ru:25665';
323 g_Net_Slist_Set(NetMasterList
);
326 NetServerName
:= 'Unnamed Server';
330 NetAllowRCON
:= False;
331 NetRCONPassword
:= 'default';
332 NetUseMaster
:= True;
335 NetMasterRate
:= 60000;
336 NetForwardPorts
:= False;
340 NetForcePlayerUpdate
:= False;
341 NetPredictSelf
:= True;
342 NetClientIP
:= '127.0.0.1';
343 NetClientPort
:= NetPort
;
346 procedure g_Options_ApplyGameSettings
;
348 with gGameSettings
do
350 GameMode
:= g_Game_TextToMode(gsGameMode
);
351 if GameMode
= GM_NONE
then
353 if GameMode
= GM_SINGLE
then
355 TimeLimit
:= gsTimeLimit
;
356 ScoreLimit
:= gsScoreLimit
;
357 MaxLives
:= gsMaxLives
;
358 SpawnInvul
:= gsSpawnInvul
;
359 ItemRespawnTime
:= gsItemRespawnTime
;
360 WarmupTime
:= gsWarmupTime
;
361 Options
:= gsGameFlags
;
367 machine
:= Random(10000);
370 conRegVar('r_width', @gRC_Width
, '', '');
371 conRegVar('r_height', @gRC_Height
, '', '');
372 conRegVar('r_fullscreen', @gRC_FullScreen
, '', '');
373 conRegVar('r_maximized', @gRC_Maximized
, '', '');
374 conRegVar('r_bpp', @gBPP
, '', '');
375 conRegVar('r_vsync', @gVSync
, '', '');
376 conRegVar('r_texfilter', @gTextureFilter
, '', '');
377 conRegVar('r_npot', @glNPOTOverride
, '', '');
378 conRegVar('r_interp', @gLerpActors
, '', 'interpolate actors');
379 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
380 conRegVar('r_resolution_scale', @r_pixel_scale
, 0.01, 100.0, 'upscale factor', '', false);
383 conRegVar('s_nosound', @gNoSound
, '', '');
384 conRegVar('s_soundvolume', @gSoundLevel
, '', '');
385 conRegVar('s_musicvolume', @gMusicLevel
, '', '');
386 conRegVar('s_maxsim', @gMaxSimSounds
, '', ''); // e_sound_fmod/sdl?
387 conRegVar('s_muteinactive', @gMuteWhenInactive
, '', '');
388 conRegVar('s_announcer', @gAnnouncer
, '', '');
389 conRegVar('s_sfx', @gSoundEffectsDF
, '', '');
390 conRegVar('s_chatsounds', @gUseChatSounds
, '', '');
391 {$IFDEF USE_SDLMIXER}
392 conRegVar('sdl_mixer_samplerate', @gsSDLSampleRate
, '', '');
393 conRegVar('sdl_mixer_buffersize', @gsSDLBufferSize
, '', '');
397 conRegVar('g_gibs_count', @gGibsCount
, '', '');
398 conRegVar('g_blood_count', @gBloodCount
, '', '');
399 conRegVar('g_adv_blood', @gAdvBlood
, '', '');
400 conRegVar('g_adv_corpses', @gAdvCorpses
, '', '');
401 conRegVar('g_adv_gibs', @gAdvGibs
, '', '');
402 conRegVar('r_flash', @gFlash
, '', '');
403 conRegVar('r_background', @gDrawBackGround
, '', '');
404 conRegVar('g_show_messages', @gShowMessages
, '', '');
405 conRegVar('r_revert_players', @gRevertPlayers
, '', '');
406 conRegVar('r_chat_bubble', @gChatBubble
, '', '');
407 conRegVar('sfs_debug', @wadoptDebug
, '', '');
408 conRegVar('sfs_fastmode', @wadoptFast
, '', '');
409 conRegVar('g_fast_screenshots', @e_FastScreenshots
, '', '');
410 conRegVar('g_default_megawad', @gDefaultMegawadStart
, '', '');
411 conRegVar('g_save_stats', @gSaveStats
, '', '');
412 conRegVar('g_screenshot_stats', @gScreenshotStats
, '', '');
413 conRegVar('g_lastmap', @gsMap
, '', '');
415 conRegVar('d_input', @g_dbg_input
, '', '');
418 conRegVar('touch_enable', @g_touch_enabled
, 'enable/disable virtual buttons', 'draw buttons');
419 conRegVar('touch_fire', @g_touch_fire
, 'enable/disable fire when press virtual up/down', 'fire when press up/down');
420 conRegVar('touch_size', @g_touch_size
, 0.1, 10, 'size of virtual buttons', 'button size');
421 conRegVar('touch_offset', @g_touch_offset
, 0, 100, '', '');
422 conRegVar('touch_alt', @g_touch_alt
, 'althernative virtual buttons layout', 'althernative layout');