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;
44 gMaxSimSounds
: Integer;
45 gMuteWhenInactive
: Boolean;
52 gDrawBackGround
: Boolean;
53 gShowMessages
: Boolean;
54 gRevertPlayers
: Boolean;
56 gAskLanguage
: Boolean;
57 gSaveStats
: Boolean = False;
58 gScreenshotStats
: Boolean = False;
59 gsSDLSampleRate
: Integer;
60 gsSDLBufferSize
: Integer;
61 gDefaultMegawadStart
: AnsiString;
62 gBerserkAutoswitch
: Boolean;
63 glNPOTOverride
: Boolean = false;
65 (* Latched game settings *)
72 gsGameFlags
: LongWord;
73 gsSpawnInvul
: Integer = 0;
74 gsItemRespawnTime
: Word = 60;
75 gsWarmupTime
: Word = 30;
80 {$INCLUDE ../nogl/noGLuses.inc}
84 e_log
, e_input
, g_console
, g_window
, g_sound
, g_gfx
, g_player
, Math
,
85 g_map
, g_net
, g_netmaster
, SysUtils
, CONFIG
, g_game
, g_main
, e_texture
,
86 g_items
, wadreader
, e_graphics
, g_touch
, envvars
, g_system
;
91 function GenPlayerName (n
: Integer): String;
94 Result
:= GetUserName
;
96 Result
:= 'Player' + IntToStr(machine
MOD 10000);
98 Result
:= Copy(Result
, 1, 12) + ' '
100 Result
:= Copy(Result
, 1, 10) + ' ' + IntToStr(n
)
104 procedure g_Options_SetDefaultVideo
;
105 var display
: TSDL_DisplayMode
;
107 var target
, closest
: TSDL_DisplayMode
; percentage
: Integer;
110 (* Display 0 = Primary display *)
112 gScreenHeight
:= 480;
115 //gBPP := SDL_BITSPERPIXEL(dispaly.format);
118 gFullScreen
:= True; (* rotation not allowed? *)
120 gFullScreen
:= False;
122 if SDL_GetDesktopDisplayMode(0, @display
) = 0 then
125 gWinSizeX
:= display
.w
;
126 gWinSizeY
:= display
.h
;
128 (* Window must be smaller than display *)
129 closest
.w
:= display
.w
;
130 closest
.h
:= display
.h
;
132 while (display
.w
- closest
.w
< 48) or (display
.h
- closest
.h
< 48) do
134 if percentage
< 25 then
136 closest
.w
:= display
.w
* 75 div 100;
137 closest
.h
:= display
.h
* 75 div 100;
140 target
.w
:= display
.w
* percentage
div 100;
141 target
.h
:= display
.h
* percentage
div 100;
142 target
.format
:= 0; (* didn't care *)
143 target
.refresh_rate
:= 0; (* didn't care *)
144 target
.driverdata
:= nil; (* init *)
145 SDL_GetClosestDisplayMode(0, @target
, @closest
);
148 gWinSizeX
:= closest
.w
;
149 gWinSizeY
:= closest
.h
;
150 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
155 e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError
])
157 (* Must be positioned on primary display *)
158 gWinMaximized
:= False;
160 gTextureFilter
:= True;
161 glLegacyNPOT
:= False;
162 gRC_Width
:= gWinSizeX
;
163 gRC_Height
:= gWinSizeY
;
164 gRC_FullScreen
:= gFullScreen
;
165 gRC_Maximized
:= gWinMaximized
;
166 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
167 g_Console_ResetBinds
;
170 procedure g_Options_SetDefaultVideo
;
175 gFullScreen
:= False;
176 gWinMaximized
:= False;
178 gTextureFilter
:= True;
179 glLegacyNPOT
:= False;
180 gScreenWidth
:= gWinSizeX
;
181 gScreenHeight
:= gWinSizeY
;
182 gRC_Width
:= gWinSizeX
;
183 gRC_Height
:= gWinSizeY
;
184 gRC_FullScreen
:= gFullScreen
;
185 gRC_Maximized
:= gWinMaximized
;
186 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
187 g_Console_ResetBinds
;
191 procedure g_Options_SetDefault();
200 gMuteWhenInactive
:= False;
201 gAnnouncer
:= ANNOUNCE_MEPLUS
;
202 gSoundEffectsDF
:= True;
203 gUseChatSounds
:= True;
204 gsSDLSampleRate
:= 44100;
205 gsSDLBufferSize
:= 2048;
207 g_Sound_SetupAllVolumes(gSoundLevel
, gMusicLevel
);
209 with gPlayer1Settings
do
211 Name
:= GenPlayerName(1);
212 Model
:= STD_PLAYER_MODEL
;
213 Color
.R
:= PLAYER1_DEF_COLOR
.R
;
214 Color
.G
:= PLAYER1_DEF_COLOR
.G
;
215 Color
.B
:= PLAYER1_DEF_COLOR
.B
;
219 with gPlayer2Settings
do
221 Name
:= GenPlayerName(2);
222 Model
:= STD_PLAYER_MODEL
;
223 Color
.R
:= PLAYER2_DEF_COLOR
.R
;
224 Color
.G
:= PLAYER2_DEF_COLOR
.G
;
225 Color
.B
:= PLAYER2_DEF_COLOR
.B
;
229 (* section Joysticks *)
230 for i
:= 0 to e_MaxJoys
- 1 do
232 e_JoystickDeadzones
[i
] := 8192
237 g_Shells_SetMax(300);
239 g_Corpses_SetMax(20);
246 gDrawBackGround
:= True;
247 gShowMessages
:= True;
248 gRevertPlayers
:= False;
250 wadoptDebug
:= False;
252 e_FastScreenshots
:= True;
253 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
254 gBerserkAutoswitch
:= True;
258 gAskLanguage
:= True;
259 gLanguage
:= LANGUAGE_ENGLISH
;
262 gsGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
268 gsItemRespawnTime
:= 60;
269 gsGameFlags
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_DMKEYS
or
270 GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
273 (* section MasterServer *)
274 NetMasterList
:= 'mpms.doom2d.org:25665,deadsoftware.ru:25665';
275 g_Net_Slist_Set(NetMasterList
);
278 NetServerName
:= 'Unnamed Server';
282 NetAllowRCON
:= False;
283 NetRCONPassword
:= 'default';
284 NetUseMaster
:= True;
287 NetMasterRate
:= 60000;
288 NetForwardPorts
:= False;
292 NetForcePlayerUpdate
:= False;
293 NetPredictSelf
:= True;
294 NetClientIP
:= '127.0.0.1';
295 NetClientPort
:= NetPort
;
298 procedure g_Options_ApplyGameSettings
;
300 with gGameSettings
do
302 GameMode
:= g_Game_TextToMode(gsGameMode
);
303 if GameMode
= GM_NONE
then
305 if GameMode
= GM_SINGLE
then
307 TimeLimit
:= gsTimeLimit
;
308 GoalLimit
:= gsGoalLimit
;
309 MaxLives
:= gsMaxLives
;
310 SpawnInvul
:= gsSpawnInvul
;
311 ItemRespawnTime
:= gsItemRespawnTime
;
312 WarmupTime
:= gsWarmupTime
;
313 Options
:= gsGameFlags
;
319 machine
:= Random(10000);
322 conRegVar('r_width', @gRC_Width
, '', '');
323 conRegVar('r_height', @gRC_Height
, '', '');
324 conRegVar('r_fullscreen', @gRC_FullScreen
, '', '');
325 conRegVar('r_maximized', @gRC_Maximized
, '', '');
326 conRegVar('r_bpp', @gBPP
, '', '');
327 conRegVar('r_vsync', @gVSync
, '', '');
328 conRegVar('r_texfilter', @gTextureFilter
, '', '');
329 conRegVar('r_npot', @glNPOTOverride
, '', '');
332 conRegVar('s_nosound', @gNoSound
, '', '');
333 conRegVar('s_soundvolume', @gSoundLevel
, '', '');
334 conRegVar('s_musicvolume', @gMusicLevel
, '', '');
335 conRegVar('s_maxsim', @gMaxSimSounds
, '', ''); // e_sound_fmod/sdl?
336 conRegVar('s_muteinactive', @gMuteWhenInactive
, '', '');
337 conRegVar('s_announcer', @gAnnouncer
, '', '');
338 conRegVar('s_sfx', @gSoundEffectsDF
, '', '');
339 conRegVar('s_chatsounds', @gUseChatSounds
, '', '');
340 {$IFDEF USE_SDLMIXER}
341 conRegVar('sdl_mixer_samplerate', @gsSDLSampleRate
, '', '');
342 conRegVar('sdl_mixer_buffersize', @gsSDLBufferSize
, '', '');
346 conRegVar('g_gibs_count', @gGibsCount
, '', '');
347 conRegVar('g_blood_count', @gBloodCount
, '', '');
348 conRegVar('g_adv_blood', @gAdvBlood
, '', '');
349 conRegVar('g_adv_corpses', @gAdvCorpses
, '', '');
350 conRegVar('g_adv_gibs', @gAdvGibs
, '', '');
351 conRegVar('r_flash', @gFlash
, '', '');
352 conRegVar('r_background', @gDrawBackGround
, '', '');
353 conRegVar('g_show_messages', @gShowMessages
, '', '');
354 conRegVar('r_revert_players', @gRevertPlayers
, '', '');
355 conRegVar('r_chat_bubble', @gChatBubble
, '', '');
356 conRegVar('sfs_debug', @wadoptDebug
, '', '');
357 conRegVar('sfs_fastmode', @wadoptFast
, '', '');
358 conRegVar('g_fast_screenshots', @e_FastScreenshots
, '', '');
359 conRegVar('g_default_megawad', @gDefaultMegawadStart
, '', '');
360 conRegVar('g_save_stats', @gSaveStats
, '', '');
361 conRegVar('g_screenshot_stats', @gScreenshotStats
, '', '');
362 conRegVar('g_lastmap', @gsMap
, '', '');