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 glNPOTOverride
: Boolean = false;
67 (* Latched game settings *)
74 gsGameFlags
: LongWord;
75 gsSpawnInvul
: Integer = 0;
76 gsItemRespawnTime
: Word = 60;
77 gsWarmupTime
: Word = 30;
82 {$INCLUDE ../nogl/noGLuses.inc}
86 e_log
, e_input
, g_console
, g_window
, g_sound
, g_gfx
, g_player
, Math
,
87 g_map
, g_net
, g_netmaster
, SysUtils
, CONFIG
, g_game
, g_main
, e_texture
,
88 g_items
, wadreader
, e_graphics
, g_touch
, envvars
, g_system
;
93 function GenPlayerName (n
: Integer): String;
96 Result
:= GetUserName
;
98 Result
:= 'Player' + IntToStr(machine
MOD 10000);
100 Result
:= Copy(Result
, 1, 12) + ' '
102 Result
:= Copy(Result
, 1, 10) + ' ' + IntToStr(n
)
106 procedure g_Options_SetDefaultVideo
;
107 var display
: TSDL_DisplayMode
;
109 var target
, closest
: TSDL_DisplayMode
; percentage
: Integer;
112 (* Display 0 = Primary display *)
114 gScreenHeight
:= 480;
117 //gBPP := SDL_BITSPERPIXEL(display.format);
120 gFullScreen
:= True; (* rotation not allowed? *)
122 gFullScreen
:= False;
124 if SDL_GetDesktopDisplayMode(0, @display
) = 0 then
127 gWinSizeX
:= display
.w
;
128 gWinSizeY
:= display
.h
;
130 (* Window must be smaller than display *)
131 closest
.w
:= display
.w
;
132 closest
.h
:= display
.h
;
134 while (display
.w
- closest
.w
< 48) or (display
.h
- closest
.h
< 48) do
136 if percentage
< 25 then
138 closest
.w
:= display
.w
* 75 div 100;
139 closest
.h
:= display
.h
* 75 div 100;
142 target
.w
:= display
.w
* percentage
div 100;
143 target
.h
:= display
.h
* percentage
div 100;
144 target
.format
:= 0; (* didn't care *)
145 target
.refresh_rate
:= 0; (* didn't care *)
146 target
.driverdata
:= nil; (* init *)
147 SDL_GetClosestDisplayMode(0, @target
, @closest
);
150 gWinSizeX
:= closest
.w
;
151 gWinSizeY
:= closest
.h
;
152 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
157 e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError
])
159 (* Must be positioned on primary display *)
160 gWinMaximized
:= False;
162 gTextureFilter
:= True;
163 glLegacyNPOT
:= False;
164 gRC_Width
:= gWinSizeX
;
165 gRC_Height
:= gWinSizeY
;
166 gRC_FullScreen
:= gFullScreen
;
167 gRC_Maximized
:= gWinMaximized
;
168 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
169 g_Console_ResetBinds
;
172 procedure g_Options_SetDefaultVideo
;
177 gFullScreen
:= False;
178 gWinMaximized
:= False;
180 gTextureFilter
:= True;
181 glLegacyNPOT
:= False;
182 gScreenWidth
:= gWinSizeX
;
183 gScreenHeight
:= gWinSizeY
;
184 gRC_Width
:= gWinSizeX
;
185 gRC_Height
:= gWinSizeY
;
186 gRC_FullScreen
:= gFullScreen
;
187 gRC_Maximized
:= gWinMaximized
;
188 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
189 g_Console_ResetBinds
;
193 procedure g_Options_SetDefault();
202 gMuteWhenInactive
:= False;
203 gAnnouncer
:= ANNOUNCE_MEPLUS
;
204 gSoundEffectsDF
:= True;
205 gUseChatSounds
:= True;
206 gsSDLSampleRate
:= 44100;
207 gsSDLBufferSize
:= 2048;
209 g_Sound_SetupAllVolumes(gSoundLevel
, gMusicLevel
);
211 with gPlayer1Settings
do
213 Name
:= GenPlayerName(1);
214 Model
:= STD_PLAYER_MODEL
;
215 Color
.R
:= PLAYER1_DEF_COLOR
.R
;
216 Color
.G
:= PLAYER1_DEF_COLOR
.G
;
217 Color
.B
:= PLAYER1_DEF_COLOR
.B
;
221 with gPlayer2Settings
do
223 Name
:= GenPlayerName(2);
224 Model
:= STD_PLAYER_MODEL
;
225 Color
.R
:= PLAYER2_DEF_COLOR
.R
;
226 Color
.G
:= PLAYER2_DEF_COLOR
.G
;
227 Color
.B
:= PLAYER2_DEF_COLOR
.B
;
231 (* section Joysticks *)
232 for i
:= 0 to e_MaxJoys
- 1 do
234 e_JoystickDeadzones
[i
] := 8192
239 g_Shells_SetMax(300);
241 g_Corpses_SetMax(20);
248 gDrawBackGround
:= True;
249 gShowMessages
:= True;
250 gRevertPlayers
:= False;
252 wadoptDebug
:= False;
254 e_FastScreenshots
:= True;
255 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
259 gAskLanguage
:= True;
260 gLanguage
:= LANGUAGE_ENGLISH
;
263 gsGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
269 gsItemRespawnTime
:= 60;
270 gsGameFlags
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_DMKEYS
or
271 GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
or
272 GAME_OPTION_TEAMHITTRACE
or GAME_OPTION_TEAMHITPROJECTILE
or
273 GAME_OPTION_ALLOWDROPFLAG
;
277 g_Options_ApplyGameSettings
;
279 (* section MasterServer *)
280 NetMasterList
:= 'mpms.doom2d.org:25665, deadsoftware.ru:25665, terminalcorner.ru:25665';
281 g_Net_Slist_Set(NetMasterList
);
284 NetServerName
:= 'Unnamed Server';
288 NetAllowRCON
:= False;
289 NetRCONPassword
:= 'default';
290 NetUseMaster
:= True;
293 NetMasterRate
:= 60000;
294 NetForwardPorts
:= False;
298 NetForcePlayerUpdate
:= False;
299 NetPredictSelf
:= True;
300 NetClientIP
:= '127.0.0.1';
301 NetClientPort
:= NetPort
;
304 procedure g_Options_ApplyGameSettings
;
306 with gGameSettings
do
308 GameMode
:= g_Game_TextToMode(gsGameMode
);
309 if GameMode
= GM_NONE
then
311 if GameMode
= GM_SINGLE
then
313 TimeLimit
:= gsTimeLimit
;
314 ScoreLimit
:= gsScoreLimit
;
315 MaxLives
:= gsMaxLives
;
316 SpawnInvul
:= gsSpawnInvul
;
317 ItemRespawnTime
:= gsItemRespawnTime
;
318 WarmupTime
:= gsWarmupTime
;
319 Options
:= gsGameFlags
;
325 machine
:= Random(10000);
328 conRegVar('r_width', @gRC_Width
, '', '');
329 conRegVar('r_height', @gRC_Height
, '', '');
330 conRegVar('r_fullscreen', @gRC_FullScreen
, '', '');
331 conRegVar('r_maximized', @gRC_Maximized
, '', '');
332 conRegVar('r_bpp', @gBPP
, '', '');
333 conRegVar('r_vsync', @gVSync
, '', '');
334 conRegVar('r_texfilter', @gTextureFilter
, '', '');
335 conRegVar('r_npot', @glNPOTOverride
, '', '');
336 conRegVar('r_interp', @gLerpActors
, '', 'interpolate actors');
339 conRegVar('s_nosound', @gNoSound
, '', '');
340 conRegVar('s_soundvolume', @gSoundLevel
, '', '');
341 conRegVar('s_musicvolume', @gMusicLevel
, '', '');
342 conRegVar('s_maxsim', @gMaxSimSounds
, '', ''); // e_sound_fmod/sdl?
343 conRegVar('s_muteinactive', @gMuteWhenInactive
, '', '');
344 conRegVar('s_announcer', @gAnnouncer
, '', '');
345 conRegVar('s_sfx', @gSoundEffectsDF
, '', '');
346 conRegVar('s_chatsounds', @gUseChatSounds
, '', '');
347 {$IFDEF USE_SDLMIXER}
348 conRegVar('sdl_mixer_samplerate', @gsSDLSampleRate
, '', '');
349 conRegVar('sdl_mixer_buffersize', @gsSDLBufferSize
, '', '');
353 conRegVar('g_gibs_count', @gGibsCount
, '', '');
354 conRegVar('g_blood_count', @gBloodCount
, '', '');
355 conRegVar('g_adv_blood', @gAdvBlood
, '', '');
356 conRegVar('g_adv_corpses', @gAdvCorpses
, '', '');
357 conRegVar('g_adv_gibs', @gAdvGibs
, '', '');
358 conRegVar('r_flash', @gFlash
, '', '');
359 conRegVar('r_background', @gDrawBackGround
, '', '');
360 conRegVar('g_show_messages', @gShowMessages
, '', '');
361 conRegVar('r_revert_players', @gRevertPlayers
, '', '');
362 conRegVar('r_chat_bubble', @gChatBubble
, '', '');
363 conRegVar('sfs_debug', @wadoptDebug
, '', '');
364 conRegVar('sfs_fastmode', @wadoptFast
, '', '');
365 conRegVar('g_fast_screenshots', @e_FastScreenshots
, '', '');
366 conRegVar('g_default_megawad', @gDefaultMegawadStart
, '', '');
367 conRegVar('g_save_stats', @gSaveStats
, '', '');
368 conRegVar('g_screenshot_stats', @gScreenshotStats
, '', '');
369 conRegVar('g_lastmap', @gsMap
, '', '');