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 gsItemRespawnRandom
: Word = 0;
78 gsRulezRespawnTime
: Word = 60;
79 gsRulezRespawnRandom
: Word = 0;
80 gsWarmupTime
: Word = 30;
85 {$INCLUDE ../nogl/noGLuses.inc}
89 e_log
, e_input
, g_console
, g_window
, g_sound
, g_gfx
, g_player
, Math
,
90 g_map
, g_net
, g_netmaster
, SysUtils
, CONFIG
, g_game
, g_main
, e_texture
,
91 g_items
, wadreader
, e_graphics
, g_touch
, envvars
, g_system
;
96 function GenPlayerName (n
: Integer): String;
99 Result
:= GetUserName
;
101 Result
:= 'Player' + IntToStr(machine
MOD 10000);
103 Result
:= Copy(Result
, 1, 12) + ' '
105 Result
:= Copy(Result
, 1, 10) + ' ' + IntToStr(n
)
109 procedure g_Options_SetDefaultVideo
;
110 var display
: TSDL_DisplayMode
;
112 var target
, closest
: TSDL_DisplayMode
; percentage
: Integer;
115 (* Display 0 = Primary display *)
117 gScreenHeight
:= 480;
120 //gBPP := SDL_BITSPERPIXEL(display.format);
123 gFullScreen
:= True; (* rotation not allowed? *)
125 gFullScreen
:= False;
127 if SDL_GetDesktopDisplayMode(0, @display
) = 0 then
130 gWinSizeX
:= display
.w
;
131 gWinSizeY
:= display
.h
;
133 (* Window must be smaller than display *)
134 closest
.w
:= display
.w
;
135 closest
.h
:= display
.h
;
137 while (display
.w
- closest
.w
< 48) or (display
.h
- closest
.h
< 48) do
139 if percentage
< 25 then
141 closest
.w
:= display
.w
* 75 div 100;
142 closest
.h
:= display
.h
* 75 div 100;
145 target
.w
:= display
.w
* percentage
div 100;
146 target
.h
:= display
.h
* percentage
div 100;
147 target
.format
:= 0; (* didn't care *)
148 target
.refresh_rate
:= 0; (* didn't care *)
149 target
.driverdata
:= nil; (* init *)
150 SDL_GetClosestDisplayMode(0, @target
, @closest
);
153 gWinSizeX
:= closest
.w
;
154 gWinSizeY
:= closest
.h
;
155 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
160 e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError
])
162 (* Must be positioned on primary display *)
163 gWinMaximized
:= False;
165 gTextureFilter
:= True;
166 glLegacyNPOT
:= False;
167 gRC_Width
:= gWinSizeX
;
168 gRC_Height
:= gWinSizeY
;
169 gRC_FullScreen
:= gFullScreen
;
170 gRC_Maximized
:= gWinMaximized
;
171 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
172 g_Console_ResetBinds
;
175 procedure g_Options_SetDefaultVideo
;
180 gFullScreen
:= False;
181 gWinMaximized
:= False;
183 gTextureFilter
:= True;
184 glLegacyNPOT
:= False;
185 gScreenWidth
:= gWinSizeX
;
186 gScreenHeight
:= gWinSizeY
;
187 gRC_Width
:= gWinSizeX
;
188 gRC_Height
:= gWinSizeY
;
189 gRC_FullScreen
:= gFullScreen
;
190 gRC_Maximized
:= gWinMaximized
;
191 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
192 g_Console_ResetBinds
;
196 procedure g_Options_SetDefault();
205 gMuteWhenInactive
:= False;
206 gAnnouncer
:= ANNOUNCE_MEPLUS
;
207 gSoundEffectsDF
:= True;
208 gUseChatSounds
:= True;
209 gsSDLSampleRate
:= 44100;
210 gsSDLBufferSize
:= 2048;
212 g_Sound_SetupAllVolumes(gSoundLevel
, gMusicLevel
);
214 with gPlayer1Settings
do
216 Name
:= GenPlayerName(1);
217 Model
:= STD_PLAYER_MODEL
;
218 Color
.R
:= PLAYER1_DEF_COLOR
.R
;
219 Color
.G
:= PLAYER1_DEF_COLOR
.G
;
220 Color
.B
:= PLAYER1_DEF_COLOR
.B
;
224 with gPlayer2Settings
do
226 Name
:= GenPlayerName(2);
227 Model
:= STD_PLAYER_MODEL
;
228 Color
.R
:= PLAYER2_DEF_COLOR
.R
;
229 Color
.G
:= PLAYER2_DEF_COLOR
.G
;
230 Color
.B
:= PLAYER2_DEF_COLOR
.B
;
234 (* section Joysticks *)
235 for i
:= 0 to e_MaxJoys
- 1 do
237 e_JoystickDeadzones
[i
] := 8192
242 g_Shells_SetMax(300);
244 g_Corpses_SetMax(20);
251 gDrawBackGround
:= True;
252 gShowMessages
:= True;
253 gRevertPlayers
:= False;
255 wadoptDebug
:= False;
257 e_FastScreenshots
:= True;
258 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
262 gAskLanguage
:= True;
263 gLanguage
:= LANGUAGE_ENGLISH
;
266 gsGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
272 gsItemRespawnTime
:= 60;
273 gsItemRespawnRandom
:= 0;
274 gsRulezRespawnTime
:= 60;
275 gsRulezRespawnRandom
:= 0;
276 gsGameFlags
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_DMKEYS
or
277 GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
or
278 GAME_OPTION_TEAMHITTRACE
or GAME_OPTION_TEAMHITPROJECTILE
or
279 GAME_OPTION_ALLOWDROPFLAG
or GAME_OPTION_RULEZRANDOM
;
283 g_Options_ApplyGameSettings
;
285 (* section MasterServer *)
286 NetMasterList
:= 'mpms.doom2d.org:25665, deadsoftware.ru:25665, terminalcorner.ru:25665';
287 g_Net_Slist_Set(NetMasterList
);
290 NetServerName
:= 'Unnamed Server';
294 NetAllowRCON
:= False;
295 NetRCONPassword
:= 'default';
296 NetUseMaster
:= True;
299 NetMasterRate
:= 60000;
300 NetForwardPorts
:= False;
304 NetForcePlayerUpdate
:= False;
305 NetPredictSelf
:= True;
306 NetClientIP
:= '127.0.0.1';
307 NetClientPort
:= NetPort
;
310 procedure g_Options_ApplyGameSettings
;
312 with gGameSettings
do
314 GameMode
:= g_Game_TextToMode(gsGameMode
);
315 if GameMode
= GM_NONE
then
317 if GameMode
= GM_SINGLE
then
319 TimeLimit
:= gsTimeLimit
;
320 ScoreLimit
:= gsScoreLimit
;
321 MaxLives
:= gsMaxLives
;
322 SpawnInvul
:= gsSpawnInvul
;
323 ItemRespawnTime
:= gsItemRespawnTime
;
324 ItemRespawnRandom
:= gsItemRespawnRandom
;
325 RulezRespawnTime
:= gsRulezRespawnTime
;
326 RulezRespawnRandom
:= gsRulezRespawnRandom
;
327 WarmupTime
:= gsWarmupTime
;
328 Options
:= gsGameFlags
;
334 machine
:= Random(10000);
337 conRegVar('r_width', @gRC_Width
, '', '');
338 conRegVar('r_height', @gRC_Height
, '', '');
339 conRegVar('r_fullscreen', @gRC_FullScreen
, '', '');
340 conRegVar('r_maximized', @gRC_Maximized
, '', '');
341 conRegVar('r_bpp', @gBPP
, '', '');
342 conRegVar('r_vsync', @gVSync
, '', '');
343 conRegVar('r_texfilter', @gTextureFilter
, '', '');
344 conRegVar('r_npot', @glNPOTOverride
, '', '');
345 conRegVar('r_interp', @gLerpActors
, '', 'interpolate actors');
348 conRegVar('s_nosound', @gNoSound
, '', '');
349 conRegVar('s_soundvolume', @gSoundLevel
, '', '');
350 conRegVar('s_musicvolume', @gMusicLevel
, '', '');
351 conRegVar('s_maxsim', @gMaxSimSounds
, '', ''); // e_sound_fmod/sdl?
352 conRegVar('s_muteinactive', @gMuteWhenInactive
, '', '');
353 conRegVar('s_announcer', @gAnnouncer
, '', '');
354 conRegVar('s_sfx', @gSoundEffectsDF
, '', '');
355 conRegVar('s_chatsounds', @gUseChatSounds
, '', '');
356 {$IFDEF USE_SDLMIXER}
357 conRegVar('sdl_mixer_samplerate', @gsSDLSampleRate
, '', '');
358 conRegVar('sdl_mixer_buffersize', @gsSDLBufferSize
, '', '');
362 conRegVar('g_gibs_count', @gGibsCount
, '', '');
363 conRegVar('g_blood_count', @gBloodCount
, '', '');
364 conRegVar('g_adv_blood', @gAdvBlood
, '', '');
365 conRegVar('g_adv_corpses', @gAdvCorpses
, '', '');
366 conRegVar('g_adv_gibs', @gAdvGibs
, '', '');
367 conRegVar('r_flash', @gFlash
, '', '');
368 conRegVar('r_background', @gDrawBackGround
, '', '');
369 conRegVar('g_show_messages', @gShowMessages
, '', '');
370 conRegVar('r_revert_players', @gRevertPlayers
, '', '');
371 conRegVar('r_chat_bubble', @gChatBubble
, '', '');
372 conRegVar('sfs_debug', @wadoptDebug
, '', '');
373 conRegVar('sfs_fastmode', @wadoptFast
, '', '');
374 conRegVar('g_fast_screenshots', @e_FastScreenshots
, '', '');
375 conRegVar('g_default_megawad', @gDefaultMegawadStart
, '', '');
376 conRegVar('g_save_stats', @gSaveStats
, '', '');
377 conRegVar('g_screenshot_stats', @gScreenshotStats
, '', '');
378 conRegVar('g_lastmap', @gsMap
, '', '');