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
or
274 GAME_OPTION_TEAMHITTRACE
or GAME_OPTION_TEAMHITPROJECTILE
;
277 (* section MasterServer *)
278 NetMasterList
:= 'mpms.doom2d.org:25665, deadsoftware.ru:25665';
279 g_Net_Slist_Set(NetMasterList
);
282 NetServerName
:= 'Unnamed Server';
286 NetAllowRCON
:= False;
287 NetRCONPassword
:= 'default';
288 NetUseMaster
:= True;
291 NetMasterRate
:= 60000;
292 NetForwardPorts
:= False;
296 NetForcePlayerUpdate
:= False;
297 NetPredictSelf
:= True;
298 NetClientIP
:= '127.0.0.1';
299 NetClientPort
:= NetPort
;
302 procedure g_Options_ApplyGameSettings
;
304 with gGameSettings
do
306 GameMode
:= g_Game_TextToMode(gsGameMode
);
307 if GameMode
= GM_NONE
then
309 if GameMode
= GM_SINGLE
then
311 TimeLimit
:= gsTimeLimit
;
312 GoalLimit
:= gsGoalLimit
;
313 MaxLives
:= gsMaxLives
;
314 SpawnInvul
:= gsSpawnInvul
;
315 ItemRespawnTime
:= gsItemRespawnTime
;
316 WarmupTime
:= gsWarmupTime
;
317 Options
:= gsGameFlags
;
323 machine
:= Random(10000);
326 conRegVar('r_width', @gRC_Width
, '', '');
327 conRegVar('r_height', @gRC_Height
, '', '');
328 conRegVar('r_fullscreen', @gRC_FullScreen
, '', '');
329 conRegVar('r_maximized', @gRC_Maximized
, '', '');
330 conRegVar('r_bpp', @gBPP
, '', '');
331 conRegVar('r_vsync', @gVSync
, '', '');
332 conRegVar('r_texfilter', @gTextureFilter
, '', '');
333 conRegVar('r_npot', @glNPOTOverride
, '', '');
334 conRegVar('r_interp', @gLerpActors
, '', 'interpolate actors');
337 conRegVar('s_nosound', @gNoSound
, '', '');
338 conRegVar('s_soundvolume', @gSoundLevel
, '', '');
339 conRegVar('s_musicvolume', @gMusicLevel
, '', '');
340 conRegVar('s_maxsim', @gMaxSimSounds
, '', ''); // e_sound_fmod/sdl?
341 conRegVar('s_muteinactive', @gMuteWhenInactive
, '', '');
342 conRegVar('s_announcer', @gAnnouncer
, '', '');
343 conRegVar('s_sfx', @gSoundEffectsDF
, '', '');
344 conRegVar('s_chatsounds', @gUseChatSounds
, '', '');
345 {$IFDEF USE_SDLMIXER}
346 conRegVar('sdl_mixer_samplerate', @gsSDLSampleRate
, '', '');
347 conRegVar('sdl_mixer_buffersize', @gsSDLBufferSize
, '', '');
351 conRegVar('g_gibs_count', @gGibsCount
, '', '');
352 conRegVar('g_blood_count', @gBloodCount
, '', '');
353 conRegVar('g_adv_blood', @gAdvBlood
, '', '');
354 conRegVar('g_adv_corpses', @gAdvCorpses
, '', '');
355 conRegVar('g_adv_gibs', @gAdvGibs
, '', '');
356 conRegVar('r_flash', @gFlash
, '', '');
357 conRegVar('r_background', @gDrawBackGround
, '', '');
358 conRegVar('g_show_messages', @gShowMessages
, '', '');
359 conRegVar('r_revert_players', @gRevertPlayers
, '', '');
360 conRegVar('r_chat_bubble', @gChatBubble
, '', '');
361 conRegVar('sfs_debug', @wadoptDebug
, '', '');
362 conRegVar('sfs_fastmode', @wadoptFast
, '', '');
363 conRegVar('g_fast_screenshots', @e_FastScreenshots
, '', '');
364 conRegVar('g_default_megawad', @gDefaultMegawadStart
, '', '');
365 conRegVar('g_save_stats', @gSaveStats
, '', '');
366 conRegVar('g_screenshot_stats', @gScreenshotStats
, '', '');
367 conRegVar('g_lastmap', @gsMap
, '', '');