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;
83 {$INCLUDE ../nogl/noGLuses.inc}
87 e_log
, e_input
, g_console
, g_window
, g_sound
, g_gfx
, g_player
, Math
,
88 g_map
, g_net
, g_netmaster
, SysUtils
, CONFIG
, g_game
, g_main
, e_texture
,
89 g_items
, wadreader
, e_graphics
, g_touch
, envvars
, g_system
;
94 function GenPlayerName (n
: Integer): String;
97 Result
:= GetUserName
;
99 Result
:= 'Player' + IntToStr(machine
MOD 10000);
101 Result
:= Copy(Result
, 1, 12) + ' '
103 Result
:= Copy(Result
, 1, 10) + ' ' + IntToStr(n
)
107 procedure g_Options_SetDefaultVideo
;
108 var display
: TSDL_DisplayMode
;
110 var target
, closest
: TSDL_DisplayMode
; percentage
: Integer;
113 (* Display 0 = Primary display *)
115 gScreenHeight
:= 480;
118 //gBPP := SDL_BITSPERPIXEL(dispaly.format);
121 gFullScreen
:= True; (* rotation not allowed? *)
123 gFullScreen
:= False;
125 if SDL_GetDesktopDisplayMode(0, @display
) = 0 then
128 gWinSizeX
:= display
.w
;
129 gWinSizeY
:= display
.h
;
131 (* Window must be smaller than display *)
132 closest
.w
:= display
.w
;
133 closest
.h
:= display
.h
;
135 while (display
.w
- closest
.w
< 48) or (display
.h
- closest
.h
< 48) do
137 if percentage
< 25 then
139 closest
.w
:= display
.w
* 75 div 100;
140 closest
.h
:= display
.h
* 75 div 100;
143 target
.w
:= display
.w
* percentage
div 100;
144 target
.h
:= display
.h
* percentage
div 100;
145 target
.format
:= 0; (* didn't care *)
146 target
.refresh_rate
:= 0; (* didn't care *)
147 target
.driverdata
:= nil; (* init *)
148 SDL_GetClosestDisplayMode(0, @target
, @closest
);
151 gWinSizeX
:= closest
.w
;
152 gWinSizeY
:= closest
.h
;
153 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
158 e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError
])
160 (* Must be positioned on primary display *)
161 gWinMaximized
:= False;
163 gTextureFilter
:= True;
164 glLegacyNPOT
:= False;
165 gRC_Width
:= gWinSizeX
;
166 gRC_Height
:= gWinSizeY
;
167 gRC_FullScreen
:= gFullScreen
;
168 gRC_Maximized
:= gWinMaximized
;
169 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
170 g_Console_ResetBinds
;
173 procedure g_Options_SetDefaultVideo
;
178 gFullScreen
:= False;
179 gWinMaximized
:= False;
181 gTextureFilter
:= True;
182 glLegacyNPOT
:= False;
183 gScreenWidth
:= gWinSizeX
;
184 gScreenHeight
:= gWinSizeY
;
185 gRC_Width
:= gWinSizeX
;
186 gRC_Height
:= gWinSizeY
;
187 gRC_FullScreen
:= gFullScreen
;
188 gRC_Maximized
:= gWinMaximized
;
189 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gWinSizeX
) + ' h = ' + IntToStr(gWinSizeY
));
190 g_Console_ResetBinds
;
194 procedure g_Options_SetDefault();
203 gMuteWhenInactive
:= False;
204 gAnnouncer
:= ANNOUNCE_MEPLUS
;
205 gSoundEffectsDF
:= True;
206 gUseChatSounds
:= True;
207 gsSDLSampleRate
:= 44100;
208 gsSDLBufferSize
:= 2048;
210 g_Sound_SetupAllVolumes(gSoundLevel
, gMusicLevel
);
212 with gPlayer1Settings
do
214 Name
:= GenPlayerName(1);
215 Model
:= STD_PLAYER_MODEL
;
216 Color
.R
:= PLAYER1_DEF_COLOR
.R
;
217 Color
.G
:= PLAYER1_DEF_COLOR
.G
;
218 Color
.B
:= PLAYER1_DEF_COLOR
.B
;
222 with gPlayer2Settings
do
224 Name
:= GenPlayerName(2);
225 Model
:= STD_PLAYER_MODEL
;
226 Color
.R
:= PLAYER2_DEF_COLOR
.R
;
227 Color
.G
:= PLAYER2_DEF_COLOR
.G
;
228 Color
.B
:= PLAYER2_DEF_COLOR
.B
;
232 (* section Joysticks *)
233 for i
:= 0 to e_MaxJoys
- 1 do
235 e_JoystickDeadzones
[i
] := 8192
240 g_Shells_SetMax(300);
242 g_Corpses_SetMax(20);
249 gDrawBackGround
:= True;
250 gShowMessages
:= True;
251 gRevertPlayers
:= False;
253 wadoptDebug
:= False;
255 e_FastScreenshots
:= True;
256 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
257 gBerserkAutoswitch
:= True;
261 gAskLanguage
:= True;
262 gLanguage
:= LANGUAGE_ENGLISH
;
265 gsGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
271 gsItemRespawnTime
:= 60;
272 gsGameFlags
:= GAME_OPTION_ALLOWEXIT
or GAME_OPTION_DMKEYS
or
273 GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
276 (* section MasterServer *)
277 NetMasterList
:= 'mpms.doom2d.org:25665, deadsoftware.ru:25665';
278 g_Net_Slist_Set(NetMasterList
);
281 NetServerName
:= 'Unnamed Server';
285 NetAllowRCON
:= False;
286 NetRCONPassword
:= 'default';
287 NetUseMaster
:= True;
290 NetMasterRate
:= 60000;
291 NetForwardPorts
:= False;
295 NetForcePlayerUpdate
:= False;
296 NetPredictSelf
:= True;
297 NetClientIP
:= '127.0.0.1';
298 NetClientPort
:= NetPort
;
301 procedure g_Options_ApplyGameSettings
;
303 with gGameSettings
do
305 GameMode
:= g_Game_TextToMode(gsGameMode
);
306 if GameMode
= GM_NONE
then
308 if GameMode
= GM_SINGLE
then
310 TimeLimit
:= gsTimeLimit
;
311 GoalLimit
:= gsGoalLimit
;
312 MaxLives
:= gsMaxLives
;
313 SpawnInvul
:= gsSpawnInvul
;
314 ItemRespawnTime
:= gsItemRespawnTime
;
315 WarmupTime
:= gsWarmupTime
;
316 Options
:= gsGameFlags
;
322 machine
:= Random(10000);
325 conRegVar('r_width', @gRC_Width
, '', '');
326 conRegVar('r_height', @gRC_Height
, '', '');
327 conRegVar('r_fullscreen', @gRC_FullScreen
, '', '');
328 conRegVar('r_maximized', @gRC_Maximized
, '', '');
329 conRegVar('r_bpp', @gBPP
, '', '');
330 conRegVar('r_vsync', @gVSync
, '', '');
331 conRegVar('r_texfilter', @gTextureFilter
, '', '');
332 conRegVar('r_npot', @glNPOTOverride
, '', '');
333 conRegVar('r_interp', @gLerpActors
, '', 'interpolate actors');
336 conRegVar('s_nosound', @gNoSound
, '', '');
337 conRegVar('s_soundvolume', @gSoundLevel
, '', '');
338 conRegVar('s_musicvolume', @gMusicLevel
, '', '');
339 conRegVar('s_maxsim', @gMaxSimSounds
, '', ''); // e_sound_fmod/sdl?
340 conRegVar('s_muteinactive', @gMuteWhenInactive
, '', '');
341 conRegVar('s_announcer', @gAnnouncer
, '', '');
342 conRegVar('s_sfx', @gSoundEffectsDF
, '', '');
343 conRegVar('s_chatsounds', @gUseChatSounds
, '', '');
344 {$IFDEF USE_SDLMIXER}
345 conRegVar('sdl_mixer_samplerate', @gsSDLSampleRate
, '', '');
346 conRegVar('sdl_mixer_buffersize', @gsSDLBufferSize
, '', '');
350 conRegVar('g_gibs_count', @gGibsCount
, '', '');
351 conRegVar('g_blood_count', @gBloodCount
, '', '');
352 conRegVar('g_adv_blood', @gAdvBlood
, '', '');
353 conRegVar('g_adv_corpses', @gAdvCorpses
, '', '');
354 conRegVar('g_adv_gibs', @gAdvGibs
, '', '');
355 conRegVar('r_flash', @gFlash
, '', '');
356 conRegVar('r_background', @gDrawBackGround
, '', '');
357 conRegVar('g_show_messages', @gShowMessages
, '', '');
358 conRegVar('r_revert_players', @gRevertPlayers
, '', '');
359 conRegVar('r_chat_bubble', @gChatBubble
, '', '');
360 conRegVar('sfs_debug', @wadoptDebug
, '', '');
361 conRegVar('sfs_fastmode', @wadoptFast
, '', '');
362 conRegVar('g_fast_screenshots', @e_FastScreenshots
, '', '');
363 conRegVar('g_default_megawad', @gDefaultMegawadStart
, '', '');
364 conRegVar('g_save_stats', @gSaveStats
, '', '');
365 conRegVar('g_screenshot_stats', @gScreenshotStats
, '', '');
366 conRegVar('g_lastmap', @gsMap
, '', '');