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 gBerserkAutoswitch
: Boolean;
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';
134 e_log
, e_input
, g_console
, g_sound
, g_player
, Math
,
135 g_map
, g_net
, g_netmaster
, SysUtils
, CONFIG
, g_game
,
136 g_items
, wadreader
, envvars
;
141 function GenPlayerName (n
: Integer): String;
144 Result
:= GetUserName
;
146 Result
:= 'Player' + IntToStr(machine
MOD 10000);
148 Result
:= Copy(Result
, 1, 12) + ' '
150 Result
:= Copy(Result
, 1, 10) + ' ' + IntToStr(n
)
154 procedure g_Options_SetDefaultVideo
;
155 var display
: TSDL_DisplayMode
;
157 var target
, closest
: TSDL_DisplayMode
; percentage
: Integer;
160 (* Display 0 = Primary display *)
162 gScreenHeight
:= 480;
165 //gBPP := SDL_BITSPERPIXEL(dispaly.format);
168 gFullScreen
:= True; (* rotation not allowed? *)
170 gFullScreen
:= False;
172 if SDL_GetDesktopDisplayMode(0, @display
) = 0 then
175 gWinSizeX
:= display
.w
;
176 gWinSizeY
:= display
.h
;
178 (* Window must be smaller than display *)
179 closest
.w
:= display
.w
;
180 closest
.h
:= display
.h
;
182 while (display
.w
- closest
.w
< 48) or (display
.h
- closest
.h
< 48) do
184 if percentage
< 25 then
186 closest
.w
:= display
.w
* 75 div 100;
187 closest
.h
:= display
.h
* 75 div 100;
190 target
.w
:= display
.w
* percentage
div 100;
191 target
.h
:= display
.h
* percentage
div 100;
192 target
.format
:= 0; (* didn't care *)
193 target
.refresh_rate
:= 0; (* didn't care *)
194 target
.driverdata
:= nil; (* init *)
195 SDL_GetClosestDisplayMode(0, @target
, @closest
);
198 gWinSizeX
:= closest
.w
;
199 gWinSizeY
:= closest
.h
;
200 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
205 e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError
])
207 (* Must be positioned on primary display *)
208 gWinMaximized
:= False;
210 gTextureFilter
:= True;
211 glLegacyNPOT
:= False;
212 gRC_Width
:= gWinSizeX
;
213 gRC_Height
:= gWinSizeY
;
214 gRC_FullScreen
:= gFullScreen
;
215 gRC_Maximized
:= gWinMaximized
;
216 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
217 g_Console_ResetBinds
;
220 procedure g_Options_SetDefaultVideo
;
225 gFullScreen
:= False;
226 gWinMaximized
:= False;
228 gTextureFilter
:= True;
229 glLegacyNPOT
:= False;
230 gScreenWidth
:= gWinSizeX
;
231 gScreenHeight
:= gWinSizeY
;
232 gRC_Width
:= gWinSizeX
;
233 gRC_Height
:= gWinSizeY
;
234 gRC_FullScreen
:= gFullScreen
;
235 gRC_Maximized
:= gWinMaximized
;
236 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
237 g_Console_ResetBinds
;
241 procedure g_Options_SetDefault();
250 gMuteWhenInactive
:= False;
251 gAnnouncer
:= ANNOUNCE_MEPLUS
;
252 gSoundEffectsDF
:= True;
253 gUseChatSounds
:= True;
254 gsSDLSampleRate
:= 44100;
255 gsSDLBufferSize
:= 2048;
257 g_Sound_SetupAllVolumes(gSoundLevel
, gMusicLevel
);
259 with gPlayer1Settings
do
261 Name
:= GenPlayerName(1);
262 Model
:= STD_PLAYER_MODEL
;
263 Color
.R
:= PLAYER1_DEF_COLOR
.R
;
264 Color
.G
:= PLAYER1_DEF_COLOR
.G
;
265 Color
.B
:= PLAYER1_DEF_COLOR
.B
;
269 with gPlayer2Settings
do
271 Name
:= GenPlayerName(2);
272 Model
:= STD_PLAYER_MODEL
;
273 Color
.R
:= PLAYER2_DEF_COLOR
.R
;
274 Color
.G
:= PLAYER2_DEF_COLOR
.G
;
275 Color
.B
:= PLAYER2_DEF_COLOR
.B
;
279 (* section Joysticks *)
280 for i
:= 0 to e_MaxJoys
- 1 do
282 e_JoystickDeadzones
[i
] := 8192
289 g_Shells_SetMax(300);
290 g_Corpses_SetMax(20);
292 g_Gibs_SetMax(DefaultGibsMax
);
293 gGibsCount
:= DefaultGibsCount
;
300 gDrawBackGround
:= True;
301 gShowMessages
:= True;
302 gRevertPlayers
:= False;
304 wadoptDebug
:= False;
306 e_FastScreenshots
:= True;
307 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
308 gBerserkAutoswitch
:= True;
312 gAskLanguage
:= True;
313 gLanguage
:= LANGUAGE_ENGLISH
;
316 gsGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
322 gsItemRespawnTime
:= 60;
323 gsGameFlags
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_DMKEYS
or
324 GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
or
325 GAME_OPTION_TEAMHITTRACE
or GAME_OPTION_TEAMHITPROJECTILE
;
328 (* section MasterServer *)
329 NetMasterList
:= 'mpms.doom2d.org:25665, deadsoftware.ru:25665';
330 g_Net_Slist_Set(NetMasterList
);
333 NetServerName
:= 'Unnamed Server';
337 NetAllowRCON
:= False;
338 NetRCONPassword
:= 'default';
339 NetUseMaster
:= True;
342 NetMasterRate
:= 60000;
343 NetForwardPorts
:= False;
347 NetForcePlayerUpdate
:= False;
348 NetPredictSelf
:= True;
349 NetClientIP
:= '127.0.0.1';
350 NetClientPort
:= NetPort
;
353 procedure g_Options_ApplyGameSettings
;
355 with gGameSettings
do
357 GameMode
:= g_Game_TextToMode(gsGameMode
);
358 if GameMode
= GM_NONE
then
360 if GameMode
= GM_SINGLE
then
362 TimeLimit
:= gsTimeLimit
;
363 GoalLimit
:= gsGoalLimit
;
364 MaxLives
:= gsMaxLives
;
365 SpawnInvul
:= gsSpawnInvul
;
366 ItemRespawnTime
:= gsItemRespawnTime
;
367 WarmupTime
:= gsWarmupTime
;
368 Options
:= gsGameFlags
;
374 machine
:= Random(10000);
377 conRegVar('r_width', @gRC_Width
, '', '');
378 conRegVar('r_height', @gRC_Height
, '', '');
379 conRegVar('r_fullscreen', @gRC_FullScreen
, '', '');
380 conRegVar('r_maximized', @gRC_Maximized
, '', '');
381 conRegVar('r_bpp', @gBPP
, '', '');
382 conRegVar('r_vsync', @gVSync
, '', '');
383 conRegVar('r_texfilter', @gTextureFilter
, '', '');
384 conRegVar('r_npot', @glNPOTOverride
, '', '');
385 conRegVar('r_interp', @gLerpActors
, '', 'interpolate actors');
386 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
387 conRegVar('r_resolution_scale', @r_pixel_scale
, 0.01, 100.0, 'upscale factor', '', false);
390 conRegVar('s_nosound', @gNoSound
, '', '');
391 conRegVar('s_soundvolume', @gSoundLevel
, '', '');
392 conRegVar('s_musicvolume', @gMusicLevel
, '', '');
393 conRegVar('s_maxsim', @gMaxSimSounds
, '', ''); // e_sound_fmod/sdl?
394 conRegVar('s_muteinactive', @gMuteWhenInactive
, '', '');
395 conRegVar('s_announcer', @gAnnouncer
, '', '');
396 conRegVar('s_sfx', @gSoundEffectsDF
, '', '');
397 conRegVar('s_chatsounds', @gUseChatSounds
, '', '');
398 {$IFDEF USE_SDLMIXER}
399 conRegVar('sdl_mixer_samplerate', @gsSDLSampleRate
, '', '');
400 conRegVar('sdl_mixer_buffersize', @gsSDLBufferSize
, '', '');
405 conRegVar('g_gibs_count', @gGibsCount
, '', '');
407 conRegVar('g_blood_count', @gBloodCount
, '', '');
408 conRegVar('g_adv_blood', @gAdvBlood
, '', '');
409 conRegVar('g_adv_corpses', @gAdvCorpses
, '', '');
410 conRegVar('g_adv_gibs', @gAdvGibs
, '', '');
411 conRegVar('r_flash', @gFlash
, '', '');
412 conRegVar('r_background', @gDrawBackGround
, '', '');
413 conRegVar('g_show_messages', @gShowMessages
, '', '');
414 conRegVar('r_revert_players', @gRevertPlayers
, '', '');
415 conRegVar('r_chat_bubble', @gChatBubble
, '', '');
416 conRegVar('sfs_debug', @wadoptDebug
, '', '');
417 conRegVar('sfs_fastmode', @wadoptFast
, '', '');
418 conRegVar('g_fast_screenshots', @e_FastScreenshots
, '', '');
419 conRegVar('g_default_megawad', @gDefaultMegawadStart
, '', '');
420 conRegVar('g_save_stats', @gSaveStats
, '', '');
421 conRegVar('g_screenshot_stats', @gScreenshotStats
, '', '');
422 conRegVar('g_lastmap', @gsMap
, '', '');
424 conRegVar('d_input', @g_dbg_input
, '', '');
427 conRegVar('touch_enable', @g_touch_enabled
, 'enable/disable virtual buttons', 'draw buttons');
428 conRegVar('touch_fire', @g_touch_fire
, 'enable/disable fire when press virtual up/down', 'fire when press up/down');
429 conRegVar('touch_size', @g_touch_size
, 0.1, 10, 'size of virtual buttons', 'button size');
430 conRegVar('touch_offset', @g_touch_offset
, 0, 100, '', '');
431 conRegVar('touch_alt', @g_touch_alt
, 'althernative virtual buttons layout', 'althernative layout');