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 gWeaponAutoswitch
: Boolean;
67 glNPOTOverride
: Boolean = false;
69 (* Latched game settings *)
76 gsGameFlags
: LongWord;
77 gsSpawnInvul
: Integer = 0;
78 gsItemRespawnTime
: Word = 60;
79 gsWarmupTime
: Word = 30;
84 {$INCLUDE ../nogl/noGLuses.inc}
88 e_log
, e_input
, g_console
, g_window
, g_sound
, g_gfx
, g_player
, Math
,
89 g_map
, g_net
, g_netmaster
, SysUtils
, CONFIG
, g_game
, g_main
, e_texture
,
90 g_items
, wadreader
, e_graphics
, g_touch
, envvars
, g_system
;
95 function GenPlayerName (n
: Integer): String;
98 Result
:= GetUserName
;
100 Result
:= 'Player' + IntToStr(machine
MOD 10000);
102 Result
:= Copy(Result
, 1, 12) + ' '
104 Result
:= Copy(Result
, 1, 10) + ' ' + IntToStr(n
)
108 procedure g_Options_SetDefaultVideo
;
109 var display
: TSDL_DisplayMode
;
111 var target
, closest
: TSDL_DisplayMode
; percentage
: Integer;
114 (* Display 0 = Primary display *)
116 gScreenHeight
:= 480;
119 //gBPP := SDL_BITSPERPIXEL(dispaly.format);
122 gFullScreen
:= True; (* rotation not allowed? *)
124 gFullScreen
:= False;
126 if SDL_GetDesktopDisplayMode(0, @display
) = 0 then
129 gWinSizeX
:= display
.w
;
130 gWinSizeY
:= display
.h
;
132 (* Window must be smaller than display *)
133 closest
.w
:= display
.w
;
134 closest
.h
:= display
.h
;
136 while (display
.w
- closest
.w
< 48) or (display
.h
- closest
.h
< 48) do
138 if percentage
< 25 then
140 closest
.w
:= display
.w
* 75 div 100;
141 closest
.h
:= display
.h
* 75 div 100;
144 target
.w
:= display
.w
* percentage
div 100;
145 target
.h
:= display
.h
* percentage
div 100;
146 target
.format
:= 0; (* didn't care *)
147 target
.refresh_rate
:= 0; (* didn't care *)
148 target
.driverdata
:= nil; (* init *)
149 SDL_GetClosestDisplayMode(0, @target
, @closest
);
152 gWinSizeX
:= closest
.w
;
153 gWinSizeY
:= closest
.h
;
154 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
159 e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError
])
161 (* Must be positioned on primary display *)
162 gWinMaximized
:= False;
164 gTextureFilter
:= True;
165 glLegacyNPOT
:= False;
166 gRC_Width
:= gWinSizeX
;
167 gRC_Height
:= gWinSizeY
;
168 gRC_FullScreen
:= gFullScreen
;
169 gRC_Maximized
:= gWinMaximized
;
170 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
171 g_Console_ResetBinds
;
174 procedure g_Options_SetDefaultVideo
;
179 gFullScreen
:= False;
180 gWinMaximized
:= False;
182 gTextureFilter
:= True;
183 glLegacyNPOT
:= False;
184 gScreenWidth
:= gWinSizeX
;
185 gScreenHeight
:= gWinSizeY
;
186 gRC_Width
:= gWinSizeX
;
187 gRC_Height
:= gWinSizeY
;
188 gRC_FullScreen
:= gFullScreen
;
189 gRC_Maximized
:= gWinMaximized
;
190 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
191 g_Console_ResetBinds
;
195 procedure g_Options_SetDefault();
204 gMuteWhenInactive
:= False;
205 gAnnouncer
:= ANNOUNCE_MEPLUS
;
206 gSoundEffectsDF
:= True;
207 gUseChatSounds
:= True;
208 gsSDLSampleRate
:= 44100;
209 gsSDLBufferSize
:= 2048;
211 g_Sound_SetupAllVolumes(gSoundLevel
, gMusicLevel
);
213 with gPlayer1Settings
do
215 Name
:= GenPlayerName(1);
216 Model
:= STD_PLAYER_MODEL
;
217 Color
.R
:= PLAYER1_DEF_COLOR
.R
;
218 Color
.G
:= PLAYER1_DEF_COLOR
.G
;
219 Color
.B
:= PLAYER1_DEF_COLOR
.B
;
223 with gPlayer2Settings
do
225 Name
:= GenPlayerName(2);
226 Model
:= STD_PLAYER_MODEL
;
227 Color
.R
:= PLAYER2_DEF_COLOR
.R
;
228 Color
.G
:= PLAYER2_DEF_COLOR
.G
;
229 Color
.B
:= PLAYER2_DEF_COLOR
.B
;
233 (* section Joysticks *)
234 for i
:= 0 to e_MaxJoys
- 1 do
236 e_JoystickDeadzones
[i
] := 8192
241 g_Shells_SetMax(300);
243 g_Corpses_SetMax(20);
250 gDrawBackGround
:= True;
251 gShowMessages
:= True;
252 gRevertPlayers
:= False;
254 wadoptDebug
:= False;
256 e_FastScreenshots
:= True;
257 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
258 gBerserkAutoswitch
:= True;
259 gWeaponAutoswitch
:= True;
263 gAskLanguage
:= True;
264 gLanguage
:= LANGUAGE_ENGLISH
;
267 gsGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
273 gsItemRespawnTime
:= 60;
274 gsGameFlags
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_DMKEYS
or
275 GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
or
276 GAME_OPTION_TEAMHITTRACE
or GAME_OPTION_TEAMHITPROJECTILE
or
277 GAME_OPTION_ALLOWDROPFLAG
;
281 g_Options_ApplyGameSettings
;
283 (* section MasterServer *)
284 NetMasterList
:= 'mpms.doom2d.org:25665, deadsoftware.ru:25665';
285 g_Net_Slist_Set(NetMasterList
);
288 NetServerName
:= 'Unnamed Server';
292 NetAllowRCON
:= False;
293 NetRCONPassword
:= 'default';
294 NetUseMaster
:= True;
297 NetMasterRate
:= 60000;
298 NetForwardPorts
:= False;
302 NetForcePlayerUpdate
:= False;
303 NetPredictSelf
:= True;
304 NetClientIP
:= '127.0.0.1';
305 NetClientPort
:= NetPort
;
308 procedure g_Options_ApplyGameSettings
;
310 with gGameSettings
do
312 GameMode
:= g_Game_TextToMode(gsGameMode
);
313 if GameMode
= GM_NONE
then
315 if GameMode
= GM_SINGLE
then
317 TimeLimit
:= gsTimeLimit
;
318 GoalLimit
:= gsGoalLimit
;
319 MaxLives
:= gsMaxLives
;
320 SpawnInvul
:= gsSpawnInvul
;
321 ItemRespawnTime
:= gsItemRespawnTime
;
322 WarmupTime
:= gsWarmupTime
;
323 Options
:= gsGameFlags
;
329 machine
:= Random(10000);
332 conRegVar('r_width', @gRC_Width
, '', '');
333 conRegVar('r_height', @gRC_Height
, '', '');
334 conRegVar('r_fullscreen', @gRC_FullScreen
, '', '');
335 conRegVar('r_maximized', @gRC_Maximized
, '', '');
336 conRegVar('r_bpp', @gBPP
, '', '');
337 conRegVar('r_vsync', @gVSync
, '', '');
338 conRegVar('r_texfilter', @gTextureFilter
, '', '');
339 conRegVar('r_npot', @glNPOTOverride
, '', '');
340 conRegVar('r_interp', @gLerpActors
, '', 'interpolate actors');
343 conRegVar('s_nosound', @gNoSound
, '', '');
344 conRegVar('s_soundvolume', @gSoundLevel
, '', '');
345 conRegVar('s_musicvolume', @gMusicLevel
, '', '');
346 conRegVar('s_maxsim', @gMaxSimSounds
, '', ''); // e_sound_fmod/sdl?
347 conRegVar('s_muteinactive', @gMuteWhenInactive
, '', '');
348 conRegVar('s_announcer', @gAnnouncer
, '', '');
349 conRegVar('s_sfx', @gSoundEffectsDF
, '', '');
350 conRegVar('s_chatsounds', @gUseChatSounds
, '', '');
351 {$IFDEF USE_SDLMIXER}
352 conRegVar('sdl_mixer_samplerate', @gsSDLSampleRate
, '', '');
353 conRegVar('sdl_mixer_buffersize', @gsSDLBufferSize
, '', '');
357 conRegVar('g_gibs_count', @gGibsCount
, '', '');
358 conRegVar('g_blood_count', @gBloodCount
, '', '');
359 conRegVar('g_adv_blood', @gAdvBlood
, '', '');
360 conRegVar('g_adv_corpses', @gAdvCorpses
, '', '');
361 conRegVar('g_adv_gibs', @gAdvGibs
, '', '');
362 conRegVar('r_flash', @gFlash
, '', '');
363 conRegVar('r_background', @gDrawBackGround
, '', '');
364 conRegVar('g_show_messages', @gShowMessages
, '', '');
365 conRegVar('r_revert_players', @gRevertPlayers
, '', '');
366 conRegVar('r_chat_bubble', @gChatBubble
, '', '');
367 conRegVar('sfs_debug', @wadoptDebug
, '', '');
368 conRegVar('sfs_fastmode', @wadoptFast
, '', '');
369 conRegVar('g_fast_screenshots', @e_FastScreenshots
, '', '');
370 conRegVar('g_default_megawad', @gDefaultMegawadStart
, '', '');
371 conRegVar('g_save_stats', @gSaveStats
, '', '');
372 conRegVar('g_screenshot_stats', @gScreenshotStats
, '', '');
373 conRegVar('g_lastmap', @gsMap
, '', '');