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 g_dbg_scale
: Single = 1.0;
84 r_pixel_scale
: Single = 1.0;
86 gwin_has_stencil
: Boolean = false;
87 gwin_k8_enable_light_experiments
: Boolean = false;
88 g_dbg_aimline_on
: Boolean = false;
89 g_dbg_input
: Boolean = False;
92 g_touch_enabled
: Boolean = False;
93 g_touch_size
: Single = 1.0;
94 g_touch_offset
: Single = 50.0;
95 g_touch_fire
: Boolean = True;
96 g_touch_alt
: Boolean = False;
98 {--- Read-only dirs ---}
102 MegawadDirs
: SSArray
;
105 AllMapDirs
: SSArray
; // Maps + Megawads
107 {--- Read-Write dirs ---}
113 ScreenshotDirs
: SSArray
;
115 MapDownloadDirs
: SSArray
;
116 WadDownloadDirs
: SSArray
;
118 GameWADName
: string = 'GAME';
132 {$IFDEF ENABLE_SHELLS}
135 {$IFDEF ENABLE_CORPSES}
138 e_log
, e_input
, g_console
, g_sound
, g_player
, Math
,
139 g_map
, g_net
, g_netmaster
, SysUtils
, CONFIG
, g_game
,
140 g_items
, wadreader
, envvars
;
145 function GenPlayerName (n
: Integer): String;
148 Result
:= GetUserName
;
150 Result
:= 'Player' + IntToStr(machine
MOD 10000);
152 Result
:= Copy(Result
, 1, 12) + ' '
154 Result
:= Copy(Result
, 1, 10) + ' ' + IntToStr(n
)
158 procedure g_Options_SetDefaultVideo
;
159 var display
: TSDL_DisplayMode
;
161 var target
, closest
: TSDL_DisplayMode
; percentage
: Integer;
164 (* Display 0 = Primary display *)
166 gScreenHeight
:= 480;
169 //gBPP := SDL_BITSPERPIXEL(display.format);
172 gFullScreen
:= True; (* rotation not allowed? *)
174 gFullScreen
:= False;
176 if SDL_GetDesktopDisplayMode(0, @display
) = 0 then
179 gWinSizeX
:= display
.w
;
180 gWinSizeY
:= display
.h
;
182 (* Window must be smaller than display *)
183 closest
.w
:= display
.w
;
184 closest
.h
:= display
.h
;
186 while (display
.w
- closest
.w
< 48) or (display
.h
- closest
.h
< 48) do
188 if percentage
< 25 then
190 closest
.w
:= display
.w
* 75 div 100;
191 closest
.h
:= display
.h
* 75 div 100;
194 target
.w
:= display
.w
* percentage
div 100;
195 target
.h
:= display
.h
* percentage
div 100;
196 target
.format
:= 0; (* didn't care *)
197 target
.refresh_rate
:= 0; (* didn't care *)
198 target
.driverdata
:= nil; (* init *)
199 SDL_GetClosestDisplayMode(0, @target
, @closest
);
202 gWinSizeX
:= closest
.w
;
203 gWinSizeY
:= closest
.h
;
204 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
209 e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError
])
211 (* Must be positioned on primary display *)
212 gWinMaximized
:= False;
214 gTextureFilter
:= True;
215 glLegacyNPOT
:= False;
216 gRC_Width
:= gWinSizeX
;
217 gRC_Height
:= gWinSizeY
;
218 gRC_FullScreen
:= gFullScreen
;
219 gRC_Maximized
:= gWinMaximized
;
220 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
221 g_Console_ResetBinds
;
224 procedure g_Options_SetDefaultVideo
;
229 gFullScreen
:= False;
230 gWinMaximized
:= False;
232 gTextureFilter
:= True;
233 glLegacyNPOT
:= False;
234 gScreenWidth
:= gWinSizeX
;
235 gScreenHeight
:= gWinSizeY
;
236 gRC_Width
:= gWinSizeX
;
237 gRC_Height
:= gWinSizeY
;
238 gRC_FullScreen
:= gFullScreen
;
239 gRC_Maximized
:= gWinMaximized
;
240 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
241 g_Console_ResetBinds
;
245 procedure g_Options_SetDefault();
254 gMuteWhenInactive
:= False;
255 gAnnouncer
:= ANNOUNCE_MEPLUS
;
256 gSoundEffectsDF
:= True;
257 gUseChatSounds
:= True;
258 gsSDLSampleRate
:= 44100;
259 gsSDLBufferSize
:= 2048;
261 g_Sound_SetupAllVolumes(gSoundLevel
, gMusicLevel
);
263 with gPlayer1Settings
do
265 Name
:= GenPlayerName(1);
266 Model
:= STD_PLAYER_MODEL
;
267 Color
.R
:= PLAYER1_DEF_COLOR
.R
;
268 Color
.G
:= PLAYER1_DEF_COLOR
.G
;
269 Color
.B
:= PLAYER1_DEF_COLOR
.B
;
273 with gPlayer2Settings
do
275 Name
:= GenPlayerName(2);
276 Model
:= STD_PLAYER_MODEL
;
277 Color
.R
:= PLAYER2_DEF_COLOR
.R
;
278 Color
.G
:= PLAYER2_DEF_COLOR
.G
;
279 Color
.B
:= PLAYER2_DEF_COLOR
.B
;
283 (* section Joysticks *)
284 for i
:= 0 to e_MaxJoys
- 1 do
286 e_JoystickDeadzones
[i
] := 8192
293 {$IFDEF ENABLE_SHELLS}
294 g_Shells_SetMax(DefaultShellMax
);
296 {$IFDEF ENABLE_CORPSES}
297 g_Corpses_SetMax(DefaultCorpsesMax
);
300 g_Gibs_SetMax(DefaultGibsMax
);
301 gGibsCount
:= DefaultGibsCount
;
308 gDrawBackGround
:= True;
309 gShowMessages
:= True;
310 gRevertPlayers
:= False;
312 wadoptDebug
:= False;
314 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
318 gAskLanguage
:= True;
319 gLanguage
:= LANGUAGE_ENGLISH
;
322 gsGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
328 gsItemRespawnTime
:= 60;
329 gsGameFlags
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_DMKEYS
or
330 GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
or
331 GAME_OPTION_TEAMHITTRACE
or GAME_OPTION_TEAMHITPROJECTILE
or
332 GAME_OPTION_ALLOWDROPFLAG
;
336 g_Options_ApplyGameSettings
;
338 (* section MasterServer *)
339 NetMasterList
:= 'mpms.doom2d.org:25665, deadsoftware.ru:25665, terminalcorner.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 ScoreLimit
:= gsScoreLimit
;
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_default_megawad', @gDefaultMegawadStart
, '', '');
429 conRegVar('g_save_stats', @gSaveStats
, '', '');
430 conRegVar('g_screenshot_stats', @gScreenshotStats
, '', '');
431 conRegVar('g_lastmap', @gsMap
, '', '');
433 conRegVar('d_input', @g_dbg_input
, '', '');
436 conRegVar('touch_enable', @g_touch_enabled
, 'enable/disable virtual buttons', 'draw buttons');
437 conRegVar('touch_fire', @g_touch_fire
, 'enable/disable fire when press virtual up/down', 'fire when press up/down');
438 conRegVar('touch_size', @g_touch_size
, 0.1, 10, 'size of virtual buttons', 'button size');
439 conRegVar('touch_offset', @g_touch_offset
, 0, 100, '', '');
440 conRegVar('touch_alt', @g_touch_alt
, 'althernative virtual buttons layout', 'althernative layout');