DEADSOFTWARE

cosmetic: yet another fix, but for rus language
[d2df-sdl.git] / src / game / g_options.pas
1 (* Copyright (C) Doom 2D: Forever Developers
2 *
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.
6 *
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.
11 *
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/>.
14 *)
15 {$INCLUDE ../shared/a_modes.inc}
16 unit g_options;
18 interface
20 uses
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';
31 var
32 gBPP: Integer;
33 gFreq: Byte;
34 gFullscreen: Boolean;
35 gWinSizeX, gWinSizeY: Integer;
36 gWinMaximized: Boolean;
37 gVSync: Boolean;
38 glLegacyNPOT: Boolean;
39 glRenderToFBO: Boolean = True;
40 gTextureFilter: Boolean;
41 gLerpActors: Boolean = True;
42 gFrameTime: Integer = 5;
43 gMaxFPS: Integer = 200;
44 gNoSound: Boolean;
45 gSoundLevel: Integer;
46 gMusicLevel: Integer;
47 gMaxSimSounds: Integer;
48 gMuteWhenInactive: Boolean;
49 gAdvCorpses: Boolean;
50 gAdvBlood: Boolean;
51 gAdvGibs: Boolean;
52 gGibsCount: Integer;
53 gBloodCount: Integer;
54 gFlash: Integer;
55 gDrawBackGround: Boolean;
56 gShowMessages: Boolean;
57 gRevertPlayers: Boolean;
58 gLanguage: String;
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 *)
68 gsMap: String;
69 gsGameMode: String;
70 gsTimeLimit: Word;
71 gsScoreLimit: Word;
72 gsMaxLives: Byte;
73 gsPlayers: Byte;
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;
82 implementation
84 uses
85 {$INCLUDE ../nogl/noGLuses.inc}
86 {$IFDEF USE_SDL2}
87 SDL2,
88 {$ENDIF}
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;
93 var
94 machine: Integer;
96 function GenPlayerName (n: Integer): String;
97 begin
98 ASSERT(n >= 1);
99 Result := GetUserName;
100 if Result = '' then
101 Result := 'Player' + IntToStr(machine MOD 10000);
102 if n = 1 then
103 Result := Copy(Result, 1, 12) + ' '
104 else
105 Result := Copy(Result, 1, 10) + ' ' + IntToStr(n)
106 end;
108 {$IFDEF USE_SDL2}
109 procedure g_Options_SetDefaultVideo;
110 var display: TSDL_DisplayMode;
111 {$IFNDEF ANDROID}
112 var target, closest: TSDL_DisplayMode; percentage: Integer;
113 {$ENDIF}
114 begin
115 (* Display 0 = Primary display *)
116 gScreenWidth := 640;
117 gScreenHeight := 480;
118 gWinSizeX := 640;
119 gWinSizeY := 480;
120 //gBPP := SDL_BITSPERPIXEL(display.format);
121 gBPP := 32;
122 {$IFDEF ANDROID}
123 gFullScreen := True; (* rotation not allowed? *)
124 {$ELSE}
125 gFullScreen := False;
126 {$ENDIF}
127 if SDL_GetDesktopDisplayMode(0, @display) = 0 then
128 begin
129 {$IFDEF ANDROID}
130 gWinSizeX := display.w;
131 gWinSizeY := display.h;
132 {$ELSE}
133 (* Window must be smaller than display *)
134 closest.w := display.w;
135 closest.h := display.h;
136 percentage := 75;
137 while (display.w - closest.w < 48) or (display.h - closest.h < 48) do
138 begin
139 if percentage < 25 then
140 begin
141 closest.w := display.w * 75 div 100;
142 closest.h := display.h * 75 div 100;
143 break;
144 end;
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);
151 Dec(percentage);
152 end;
153 gWinSizeX := closest.w;
154 gWinSizeY := closest.h;
155 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
156 {$ENDIF}
157 end
158 else
159 begin
160 e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError])
161 end;
162 (* Must be positioned on primary display *)
163 gWinMaximized := False;
164 gVSync := True;
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;
173 end;
174 {$ELSE}
175 procedure g_Options_SetDefaultVideo;
176 begin
177 gWinSizeX := 640;
178 gWinSizeY := 480;
179 gBPP := 32;
180 gFullScreen := False;
181 gWinMaximized := False;
182 gVSync := True;
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;
193 end;
194 {$ENDIF}
196 procedure g_Options_SetDefault();
197 var
198 i: Integer;
199 begin
200 (* section Sound *)
201 gNoSound := False;
202 gSoundLevel := 75;
203 gMusicLevel := 65;
204 gMaxSimSounds := 8;
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
215 begin
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;
221 Team := TEAM_RED;
222 end;
224 with gPlayer2Settings do
225 begin
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;
231 Team := TEAM_BLUE;
232 end;
234 (* section Joysticks *)
235 for i := 0 to e_MaxJoys - 1 do
236 begin
237 e_JoystickDeadzones[i] := 8192
238 end;
240 (* section Game *)
241 g_GFX_SetMax(2000);
242 g_Shells_SetMax(300);
243 g_Gibs_SetMax(150);
244 g_Corpses_SetMax(20);
245 gGibsCount := 32;
246 gBloodCount := 4;
247 gAdvBlood := True;
248 gAdvCorpses := True;
249 gAdvGibs := True;
250 gFlash := 1;
251 gDrawBackGround := True;
252 gShowMessages := True;
253 gRevertPlayers := False;
254 gChatBubble := 4;
255 wadoptDebug := False;
256 wadoptFast := False;
257 e_FastScreenshots := True;
258 gDefaultMegawadStart := DF_Default_Megawad_Start;
259 g_dbg_scale := 1.0;
260 gSaveStats := False;
262 gAskLanguage := True;
263 gLanguage := LANGUAGE_ENGLISH;
265 gsMap := '';
266 gsGameMode := _lc[I_MENU_GAME_TYPE_DM];
267 gsTimeLimit := 0;
268 gsScoreLimit := 0;
269 gsMaxLives := 0;
270 gsPlayers := 1;
271 gsSpawnInvul := 0;
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;
280 gsPlayers := 1;
282 if not gGameOn then
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);
289 (* section Server *)
290 NetServerName := 'Unnamed Server';
291 NetPassword := '';
292 NetPort := 25666;
293 NetMaxClients := 16;
294 NetAllowRCON := False;
295 NetRCONPassword := 'default';
296 NetUseMaster := True;
297 NetUpdateRate := 0;
298 NetRelupdRate := 18;
299 NetMasterRate := 60000;
300 NetForwardPorts := False;
302 (* section Client *)
303 NetInterpLevel := 2;
304 NetForcePlayerUpdate := False;
305 NetPredictSelf := True;
306 NetClientIP := '127.0.0.1';
307 NetClientPort := NetPort;
308 end;
310 procedure g_Options_ApplyGameSettings;
311 begin
312 with gGameSettings do
313 begin
314 GameMode := g_Game_TextToMode(gsGameMode);
315 if GameMode = GM_NONE then
316 GameMode := GM_DM;
317 if GameMode = GM_SINGLE then
318 GameMode := GM_COOP;
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;
329 end;
330 end;
332 initialization
333 Randomize;
334 machine := Random(10000);
336 (* Video *)
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');
347 (* Sound *)
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, '', '');
359 {$ENDIF}
361 (* Game *)
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, '', '');
379 end.