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 gBerserkAutoswitch
: Boolean;
66 glNPOTOverride
: Boolean = false;
68 (* Latched game settings *)
75 gsGameFlags
: LongWord;
76 gsSpawnInvul
: Integer = 0;
77 gsItemRespawnTime
: Word = 60;
78 gsWarmupTime
: Word = 30;
81 e_NoGraphics
: Boolean = True;
83 e_NoGraphics
: Boolean = False;
85 e_FastScreenshots
: Boolean = true; // it's REALLY SLOW with `false`
86 g_dbg_scale
: Single = 1.0;
87 r_pixel_scale
: Single = 1.0;
89 gwin_has_stencil
: Boolean = false;
90 gwin_k8_enable_light_experiments
: Boolean = false;
91 g_dbg_aimline_on
: Boolean = false;
92 g_dbg_input
: Boolean = False;
95 g_touch_enabled
: Boolean = False;
96 g_touch_size
: Single = 1.0;
97 g_touch_offset
: Single = 50.0;
98 g_touch_fire
: Boolean = True;
99 g_touch_alt
: Boolean = False;
101 {--- Read-only dirs ---}
105 MegawadDirs
: SSArray
;
108 AllMapDirs
: SSArray
; // Maps + Megawads
110 {--- Read-Write dirs ---}
116 ScreenshotDirs
: SSArray
;
118 MapDownloadDirs
: SSArray
;
119 WadDownloadDirs
: SSArray
;
121 GameWADName
: string = 'GAME';
132 e_log
, e_input
, g_console
, g_sound
, g_player
, Math
,
133 g_map
, g_net
, g_netmaster
, SysUtils
, CONFIG
, g_game
,
134 g_items
, wadreader
, envvars
;
139 function GenPlayerName (n
: Integer): String;
142 Result
:= GetUserName
;
144 Result
:= 'Player' + IntToStr(machine
MOD 10000);
146 Result
:= Copy(Result
, 1, 12) + ' '
148 Result
:= Copy(Result
, 1, 10) + ' ' + IntToStr(n
)
152 procedure g_Options_SetDefaultVideo
;
153 var display
: TSDL_DisplayMode
;
155 var target
, closest
: TSDL_DisplayMode
; percentage
: Integer;
158 (* Display 0 = Primary display *)
160 gScreenHeight
:= 480;
163 //gBPP := SDL_BITSPERPIXEL(dispaly.format);
166 gFullScreen
:= True; (* rotation not allowed? *)
168 gFullScreen
:= False;
170 if SDL_GetDesktopDisplayMode(0, @display
) = 0 then
173 gWinSizeX
:= display
.w
;
174 gWinSizeY
:= display
.h
;
176 (* Window must be smaller than display *)
177 closest
.w
:= display
.w
;
178 closest
.h
:= display
.h
;
180 while (display
.w
- closest
.w
< 48) or (display
.h
- closest
.h
< 48) do
182 if percentage
< 25 then
184 closest
.w
:= display
.w
* 75 div 100;
185 closest
.h
:= display
.h
* 75 div 100;
188 target
.w
:= display
.w
* percentage
div 100;
189 target
.h
:= display
.h
* percentage
div 100;
190 target
.format
:= 0; (* didn't care *)
191 target
.refresh_rate
:= 0; (* didn't care *)
192 target
.driverdata
:= nil; (* init *)
193 SDL_GetClosestDisplayMode(0, @target
, @closest
);
196 gWinSizeX
:= closest
.w
;
197 gWinSizeY
:= closest
.h
;
198 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
203 e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError
])
205 (* Must be positioned on primary display *)
206 gWinMaximized
:= False;
208 gTextureFilter
:= True;
209 glLegacyNPOT
:= False;
210 gRC_Width
:= gWinSizeX
;
211 gRC_Height
:= gWinSizeY
;
212 gRC_FullScreen
:= gFullScreen
;
213 gRC_Maximized
:= gWinMaximized
;
214 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
215 g_Console_ResetBinds
;
218 procedure g_Options_SetDefaultVideo
;
223 gFullScreen
:= False;
224 gWinMaximized
:= False;
226 gTextureFilter
:= True;
227 glLegacyNPOT
:= False;
228 gScreenWidth
:= gWinSizeX
;
229 gScreenHeight
:= gWinSizeY
;
230 gRC_Width
:= gWinSizeX
;
231 gRC_Height
:= gWinSizeY
;
232 gRC_FullScreen
:= gFullScreen
;
233 gRC_Maximized
:= gWinMaximized
;
234 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
235 g_Console_ResetBinds
;
239 procedure g_Options_SetDefault();
248 gMuteWhenInactive
:= False;
249 gAnnouncer
:= ANNOUNCE_MEPLUS
;
250 gSoundEffectsDF
:= True;
251 gUseChatSounds
:= True;
252 gsSDLSampleRate
:= 44100;
253 gsSDLBufferSize
:= 2048;
255 g_Sound_SetupAllVolumes(gSoundLevel
, gMusicLevel
);
257 with gPlayer1Settings
do
259 Name
:= GenPlayerName(1);
260 Model
:= STD_PLAYER_MODEL
;
261 Color
.R
:= PLAYER1_DEF_COLOR
.R
;
262 Color
.G
:= PLAYER1_DEF_COLOR
.G
;
263 Color
.B
:= PLAYER1_DEF_COLOR
.B
;
267 with gPlayer2Settings
do
269 Name
:= GenPlayerName(2);
270 Model
:= STD_PLAYER_MODEL
;
271 Color
.R
:= PLAYER2_DEF_COLOR
.R
;
272 Color
.G
:= PLAYER2_DEF_COLOR
.G
;
273 Color
.B
:= PLAYER2_DEF_COLOR
.B
;
277 (* section Joysticks *)
278 for i
:= 0 to e_MaxJoys
- 1 do
280 e_JoystickDeadzones
[i
] := 8192
287 g_Shells_SetMax(300);
289 g_Corpses_SetMax(20);
296 gDrawBackGround
:= True;
297 gShowMessages
:= True;
298 gRevertPlayers
:= False;
300 wadoptDebug
:= False;
302 e_FastScreenshots
:= True;
303 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
304 gBerserkAutoswitch
:= True;
308 gAskLanguage
:= True;
309 gLanguage
:= LANGUAGE_ENGLISH
;
312 gsGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
318 gsItemRespawnTime
:= 60;
319 gsGameFlags
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_DMKEYS
or
320 GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
or
321 GAME_OPTION_TEAMHITTRACE
or GAME_OPTION_TEAMHITPROJECTILE
;
324 (* section MasterServer *)
325 NetMasterList
:= 'mpms.doom2d.org:25665, deadsoftware.ru:25665';
326 g_Net_Slist_Set(NetMasterList
);
329 NetServerName
:= 'Unnamed Server';
333 NetAllowRCON
:= False;
334 NetRCONPassword
:= 'default';
335 NetUseMaster
:= True;
338 NetMasterRate
:= 60000;
339 NetForwardPorts
:= False;
343 NetForcePlayerUpdate
:= False;
344 NetPredictSelf
:= True;
345 NetClientIP
:= '127.0.0.1';
346 NetClientPort
:= NetPort
;
349 procedure g_Options_ApplyGameSettings
;
351 with gGameSettings
do
353 GameMode
:= g_Game_TextToMode(gsGameMode
);
354 if GameMode
= GM_NONE
then
356 if GameMode
= GM_SINGLE
then
358 TimeLimit
:= gsTimeLimit
;
359 GoalLimit
:= gsGoalLimit
;
360 MaxLives
:= gsMaxLives
;
361 SpawnInvul
:= gsSpawnInvul
;
362 ItemRespawnTime
:= gsItemRespawnTime
;
363 WarmupTime
:= gsWarmupTime
;
364 Options
:= gsGameFlags
;
370 machine
:= Random(10000);
373 conRegVar('r_width', @gRC_Width
, '', '');
374 conRegVar('r_height', @gRC_Height
, '', '');
375 conRegVar('r_fullscreen', @gRC_FullScreen
, '', '');
376 conRegVar('r_maximized', @gRC_Maximized
, '', '');
377 conRegVar('r_bpp', @gBPP
, '', '');
378 conRegVar('r_vsync', @gVSync
, '', '');
379 conRegVar('r_texfilter', @gTextureFilter
, '', '');
380 conRegVar('r_npot', @glNPOTOverride
, '', '');
381 conRegVar('r_interp', @gLerpActors
, '', 'interpolate actors');
382 conRegVar('r_scale', @g_dbg_scale
, 0.01, 100.0, 'render scale', '', false);
383 conRegVar('r_resolution_scale', @r_pixel_scale
, 0.01, 100.0, 'upscale factor', '', false);
386 conRegVar('s_nosound', @gNoSound
, '', '');
387 conRegVar('s_soundvolume', @gSoundLevel
, '', '');
388 conRegVar('s_musicvolume', @gMusicLevel
, '', '');
389 conRegVar('s_maxsim', @gMaxSimSounds
, '', ''); // e_sound_fmod/sdl?
390 conRegVar('s_muteinactive', @gMuteWhenInactive
, '', '');
391 conRegVar('s_announcer', @gAnnouncer
, '', '');
392 conRegVar('s_sfx', @gSoundEffectsDF
, '', '');
393 conRegVar('s_chatsounds', @gUseChatSounds
, '', '');
394 {$IFDEF USE_SDLMIXER}
395 conRegVar('sdl_mixer_samplerate', @gsSDLSampleRate
, '', '');
396 conRegVar('sdl_mixer_buffersize', @gsSDLBufferSize
, '', '');
400 conRegVar('g_gibs_count', @gGibsCount
, '', '');
401 conRegVar('g_blood_count', @gBloodCount
, '', '');
402 conRegVar('g_adv_blood', @gAdvBlood
, '', '');
403 conRegVar('g_adv_corpses', @gAdvCorpses
, '', '');
404 conRegVar('g_adv_gibs', @gAdvGibs
, '', '');
405 conRegVar('r_flash', @gFlash
, '', '');
406 conRegVar('r_background', @gDrawBackGround
, '', '');
407 conRegVar('g_show_messages', @gShowMessages
, '', '');
408 conRegVar('r_revert_players', @gRevertPlayers
, '', '');
409 conRegVar('r_chat_bubble', @gChatBubble
, '', '');
410 conRegVar('sfs_debug', @wadoptDebug
, '', '');
411 conRegVar('sfs_fastmode', @wadoptFast
, '', '');
412 conRegVar('g_fast_screenshots', @e_FastScreenshots
, '', '');
413 conRegVar('g_default_megawad', @gDefaultMegawadStart
, '', '');
414 conRegVar('g_save_stats', @gSaveStats
, '', '');
415 conRegVar('g_screenshot_stats', @gScreenshotStats
, '', '');
416 conRegVar('g_lastmap', @gsMap
, '', '');
418 conRegVar('d_input', @g_dbg_input
, '', '');
421 conRegVar('touch_enable', @g_touch_enabled
, 'enable/disable virtual buttons', 'draw buttons');
422 conRegVar('touch_fire', @g_touch_fire
, 'enable/disable fire when press virtual up/down', 'fire when press up/down');
423 conRegVar('touch_size', @g_touch_size
, 0.1, 10, 'size of virtual buttons', 'button size');
424 conRegVar('touch_offset', @g_touch_offset
, 0, 100, '', '');
425 conRegVar('touch_alt', @g_touch_alt
, 'althernative virtual buttons layout', 'althernative layout');