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 glNPOTOverride
: Boolean = false;
66 (* Latched game settings *)
73 gsGameFlags
: LongWord;
74 gsSpawnInvul
: Integer = 0;
75 gsItemRespawnTime
: Word = 60;
76 gsWarmupTime
: Word = 30;
79 e_NoGraphics
: Boolean = True;
81 e_NoGraphics
: Boolean = False;
83 e_FastScreenshots
: Boolean = true; // it's REALLY SLOW with `false`
84 g_dbg_scale
: Single = 1.0;
85 r_pixel_scale
: Single = 1.0;
87 gwin_has_stencil
: Boolean = false;
88 gwin_k8_enable_light_experiments
: Boolean = false;
89 g_dbg_aimline_on
: Boolean = false;
90 g_dbg_input
: Boolean = False;
93 g_touch_enabled
: Boolean = False;
94 g_touch_size
: Single = 1.0;
95 g_touch_offset
: Single = 50.0;
96 g_touch_fire
: Boolean = True;
97 g_touch_alt
: Boolean = False;
99 {--- Read-only dirs ---}
103 MegawadDirs
: SSArray
;
106 AllMapDirs
: SSArray
; // Maps + Megawads
108 {--- Read-Write dirs ---}
114 ScreenshotDirs
: SSArray
;
116 MapDownloadDirs
: SSArray
;
117 WadDownloadDirs
: SSArray
;
119 GameWADName
: string = 'GAME';
133 e_log
, e_input
, g_console
, g_sound
, g_player
, Math
,
134 g_map
, g_net
, g_netmaster
, SysUtils
, CONFIG
, g_game
,
135 g_items
, wadreader
, envvars
;
140 function GenPlayerName (n
: Integer): String;
143 Result
:= GetUserName
;
145 Result
:= 'Player' + IntToStr(machine
MOD 10000);
147 Result
:= Copy(Result
, 1, 12) + ' '
149 Result
:= Copy(Result
, 1, 10) + ' ' + IntToStr(n
)
153 procedure g_Options_SetDefaultVideo
;
154 var display
: TSDL_DisplayMode
;
156 var target
, closest
: TSDL_DisplayMode
; percentage
: Integer;
159 (* Display 0 = Primary display *)
161 gScreenHeight
:= 480;
164 //gBPP := SDL_BITSPERPIXEL(display.format);
167 gFullScreen
:= True; (* rotation not allowed? *)
169 gFullScreen
:= False;
171 if SDL_GetDesktopDisplayMode(0, @display
) = 0 then
174 gWinSizeX
:= display
.w
;
175 gWinSizeY
:= display
.h
;
177 (* Window must be smaller than display *)
178 closest
.w
:= display
.w
;
179 closest
.h
:= display
.h
;
181 while (display
.w
- closest
.w
< 48) or (display
.h
- closest
.h
< 48) do
183 if percentage
< 25 then
185 closest
.w
:= display
.w
* 75 div 100;
186 closest
.h
:= display
.h
* 75 div 100;
189 target
.w
:= display
.w
* percentage
div 100;
190 target
.h
:= display
.h
* percentage
div 100;
191 target
.format
:= 0; (* didn't care *)
192 target
.refresh_rate
:= 0; (* didn't care *)
193 target
.driverdata
:= nil; (* init *)
194 SDL_GetClosestDisplayMode(0, @target
, @closest
);
197 gWinSizeX
:= closest
.w
;
198 gWinSizeY
:= closest
.h
;
199 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
204 e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError
])
206 (* Must be positioned on primary display *)
207 gWinMaximized
:= False;
209 gTextureFilter
:= True;
210 glLegacyNPOT
:= False;
211 gRC_Width
:= gWinSizeX
;
212 gRC_Height
:= gWinSizeY
;
213 gRC_FullScreen
:= gFullScreen
;
214 gRC_Maximized
:= gWinMaximized
;
215 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
216 g_Console_ResetBinds
;
219 procedure g_Options_SetDefaultVideo
;
224 gFullScreen
:= False;
225 gWinMaximized
:= False;
227 gTextureFilter
:= True;
228 glLegacyNPOT
:= False;
229 gScreenWidth
:= gWinSizeX
;
230 gScreenHeight
:= gWinSizeY
;
231 gRC_Width
:= gWinSizeX
;
232 gRC_Height
:= gWinSizeY
;
233 gRC_FullScreen
:= gFullScreen
;
234 gRC_Maximized
:= gWinMaximized
;
235 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
236 g_Console_ResetBinds
;
240 procedure g_Options_SetDefault();
249 gMuteWhenInactive
:= False;
250 gAnnouncer
:= ANNOUNCE_MEPLUS
;
251 gSoundEffectsDF
:= True;
252 gUseChatSounds
:= True;
253 gsSDLSampleRate
:= 44100;
254 gsSDLBufferSize
:= 2048;
256 g_Sound_SetupAllVolumes(gSoundLevel
, gMusicLevel
);
258 with gPlayer1Settings
do
260 Name
:= GenPlayerName(1);
261 Model
:= STD_PLAYER_MODEL
;
262 Color
.R
:= PLAYER1_DEF_COLOR
.R
;
263 Color
.G
:= PLAYER1_DEF_COLOR
.G
;
264 Color
.B
:= PLAYER1_DEF_COLOR
.B
;
268 with gPlayer2Settings
do
270 Name
:= GenPlayerName(2);
271 Model
:= STD_PLAYER_MODEL
;
272 Color
.R
:= PLAYER2_DEF_COLOR
.R
;
273 Color
.G
:= PLAYER2_DEF_COLOR
.G
;
274 Color
.B
:= PLAYER2_DEF_COLOR
.B
;
278 (* section Joysticks *)
279 for i
:= 0 to e_MaxJoys
- 1 do
281 e_JoystickDeadzones
[i
] := 8192
288 g_Shells_SetMax(300);
289 g_Corpses_SetMax(20);
291 g_Gibs_SetMax(DefaultGibsMax
);
292 gGibsCount
:= DefaultGibsCount
;
299 gDrawBackGround
:= True;
300 gShowMessages
:= True;
301 gRevertPlayers
:= False;
303 wadoptDebug
:= False;
305 e_FastScreenshots
:= True;
306 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
310 gAskLanguage
:= True;
311 gLanguage
:= LANGUAGE_ENGLISH
;
314 gsGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
320 gsItemRespawnTime
:= 60;
321 gsGameFlags
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_DMKEYS
or
322 GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
or
323 GAME_OPTION_TEAMHITTRACE
or GAME_OPTION_TEAMHITPROJECTILE
or
324 GAME_OPTION_ALLOWDROPFLAG
;
328 g_Options_ApplyGameSettings
;
330 (* section MasterServer *)
331 NetMasterList
:= 'mpms.doom2d.org:25665, deadsoftware.ru:25665, terminalcorner.ru:25665';
332 g_Net_Slist_Set(NetMasterList
);
335 NetServerName
:= 'Unnamed Server';
339 NetAllowRCON
:= False;
340 NetRCONPassword
:= 'default';
341 NetUseMaster
:= True;
344 NetMasterRate
:= 60000;
345 NetForwardPorts
:= False;
349 NetForcePlayerUpdate
:= False;
350 NetPredictSelf
:= True;
351 NetClientIP
:= '127.0.0.1';
352 NetClientPort
:= NetPort
;
355 procedure g_Options_ApplyGameSettings
;
357 with gGameSettings
do
359 GameMode
:= g_Game_TextToMode(gsGameMode
);
360 if GameMode
= GM_NONE
then
362 if GameMode
= GM_SINGLE
then
364 TimeLimit
:= gsTimeLimit
;
365 ScoreLimit
:= gsScoreLimit
;
366 MaxLives
:= gsMaxLives
;
367 SpawnInvul
:= gsSpawnInvul
;
368 ItemRespawnTime
:= gsItemRespawnTime
;
369 WarmupTime
:= gsWarmupTime
;
370 Options
:= gsGameFlags
;
376 machine
:= Random(10000);
379 conRegVar('r_width', @gRC_Width
, '', '');
380 conRegVar('r_height', @gRC_Height
, '', '');
381 conRegVar('r_fullscreen', @gRC_FullScreen
, '', '');
382 conRegVar('r_maximized', @gRC_Maximized
, '', '');
383 conRegVar('r_bpp', @gBPP
, '', '');
384 conRegVar('r_vsync', @gVSync
, '', '');
385 conRegVar('r_texfilter', @gTextureFilter
, '', '');
386 conRegVar('r_npot', @glNPOTOverride
, '', '');
387 conRegVar('r_interp', @gLerpActors
, '', 'interpolate actors');
388 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
389 conRegVar('r_resolution_scale', @r_pixel_scale
, 0.01, 100.0, 'upscale factor', '', false);
392 conRegVar('s_nosound', @gNoSound
, '', '');
393 conRegVar('s_soundvolume', @gSoundLevel
, '', '');
394 conRegVar('s_musicvolume', @gMusicLevel
, '', '');
395 conRegVar('s_maxsim', @gMaxSimSounds
, '', ''); // e_sound_fmod/sdl?
396 conRegVar('s_muteinactive', @gMuteWhenInactive
, '', '');
397 conRegVar('s_announcer', @gAnnouncer
, '', '');
398 conRegVar('s_sfx', @gSoundEffectsDF
, '', '');
399 conRegVar('s_chatsounds', @gUseChatSounds
, '', '');
400 {$IFDEF USE_SDLMIXER}
401 conRegVar('sdl_mixer_samplerate', @gsSDLSampleRate
, '', '');
402 conRegVar('sdl_mixer_buffersize', @gsSDLBufferSize
, '', '');
407 conRegVar('g_gibs_count', @gGibsCount
, '', '');
409 conRegVar('g_blood_count', @gBloodCount
, '', '');
410 conRegVar('g_adv_blood', @gAdvBlood
, '', '');
411 conRegVar('g_adv_corpses', @gAdvCorpses
, '', '');
412 conRegVar('g_adv_gibs', @gAdvGibs
, '', '');
413 conRegVar('r_flash', @gFlash
, '', '');
414 conRegVar('r_background', @gDrawBackGround
, '', '');
415 conRegVar('g_show_messages', @gShowMessages
, '', '');
416 conRegVar('r_revert_players', @gRevertPlayers
, '', '');
417 conRegVar('r_chat_bubble', @gChatBubble
, '', '');
418 conRegVar('sfs_debug', @wadoptDebug
, '', '');
419 conRegVar('sfs_fastmode', @wadoptFast
, '', '');
420 conRegVar('g_fast_screenshots', @e_FastScreenshots
, '', '');
421 conRegVar('g_default_megawad', @gDefaultMegawadStart
, '', '');
422 conRegVar('g_save_stats', @gSaveStats
, '', '');
423 conRegVar('g_screenshot_stats', @gScreenshotStats
, '', '');
424 conRegVar('g_lastmap', @gsMap
, '', '');
426 conRegVar('d_input', @g_dbg_input
, '', '');
429 conRegVar('touch_enable', @g_touch_enabled
, 'enable/disable virtual buttons', 'draw buttons');
430 conRegVar('touch_fire', @g_touch_fire
, 'enable/disable fire when press virtual up/down', 'fire when press up/down');
431 conRegVar('touch_size', @g_touch_size
, 0.1, 10, 'size of virtual buttons', 'button size');
432 conRegVar('touch_offset', @g_touch_offset
, 0, 100, '', '');
433 conRegVar('touch_alt', @g_touch_alt
, 'althernative virtual buttons layout', 'althernative layout');