DEADSOFTWARE

Added vertical offset for virtual keyboard
[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, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *)
16 {$INCLUDE ../shared/a_modes.inc}
17 unit g_options;
19 interface
21 uses
22 g_language, g_weapons;
24 type
25 TPlayerControl = record
26 KeyRight: Word;
27 KeyLeft: Word;
28 KeyUp: Word;
29 KeyDown: Word;
30 KeyFire: Word;
31 KeyJump: Word;
32 KeyNextWeapon: Word;
33 KeyPrevWeapon: Word;
34 KeyOpen: Word;
35 KeyStrafe: Word;
36 KeyWeapon: array [WP_FIRST..WP_LAST] of Word;
38 KeyRight2: Word;
39 KeyLeft2: Word;
40 KeyUp2: Word;
41 KeyDown2: Word;
42 KeyFire2: Word;
43 KeyJump2: Word;
44 KeyNextWeapon2: Word;
45 KeyPrevWeapon2: Word;
46 KeyOpen2: Word;
47 KeyStrafe2: Word;
48 KeyWeapon2: array [WP_FIRST..WP_LAST] of Word;
49 end;
51 TGameControls = record
52 TakeScreenshot: Word;
53 Stat: Word;
54 Chat: Word;
55 TeamChat: Word;
56 end;
58 TControls = record
59 GameControls: TGameControls;
60 P1Control: TPlayerControl;
61 P2Control: TPlayerControl;
62 end;
64 procedure g_Options_SetDefault();
65 procedure g_Options_Read(FileName: String);
66 procedure g_Options_Write(FileName: String);
67 procedure g_Options_Write_Language(FileName: String);
68 procedure g_Options_Write_Video(FileName: String);
69 procedure g_Options_Write_Gameplay_Custom(FileName: String);
70 procedure g_Options_Write_Gameplay_Net(FileName: String);
71 procedure g_Options_Write_Net_Server(FileName: String);
72 procedure g_Options_Write_Net_Client(FileName: String);
74 const DF_Default_Megawad_Start = 'megawads/DOOM2D.WAD:\MAP01';
76 var
77 gGameControls: TControls;
78 gScreenWidth: Word = 800;
79 gScreenHeight: Word = 600;
80 gWinRealPosX: Integer = 0;
81 gWinRealPosY: Integer = 0;
82 gBPP: Byte = 32;
83 gFreq: Byte = 0;
84 gFullscreen: Boolean = False;
85 gWinMaximized: Boolean = False;
86 gVSync: Boolean = False;
87 glLegacyNPOT: Boolean = False;
88 gTextureFilter: Boolean = True;
89 gNoSound: Boolean = False;
90 gSoundLevel: Byte = 75;
91 gMusicLevel: Byte = 65;
92 gMaxSimSounds: Byte = 8;
93 gMuteWhenInactive: Boolean = False;
94 gAdvCorpses: Boolean = True;
95 gAdvBlood: Boolean = True;
96 gAdvGibs: Boolean = True;
97 gGibsCount: Integer = 32;
98 gBloodCount: Byte = 3;
99 gFlash: Byte = 1;
100 gDrawBackGround: Boolean = True;
101 gShowMessages: Boolean = True;
102 gRevertPlayers: Boolean = False;
103 gLanguage: String = LANGUAGE_ENGLISH;
104 gAskLanguage: Boolean = True;
105 gcMap: String = '';
106 gcGameMode: String = '';
107 gcTimeLimit: Word = 0;
108 gcGoalLimit: Word = 0;
109 gcMaxLives: Byte = 0;
110 gcPlayers: Byte = 1;
111 gcTeamDamage: Boolean = False;
112 gcAllowExit: Boolean = True;
113 gcWeaponStay: Boolean = False;
114 gcMonsters: Boolean = False;
115 gcBotsVS: String = 'Everybody';
116 gnMap: String = '';
117 gnGameMode: String = '';
118 gnTimeLimit: Word = 0;
119 gnGoalLimit: Word = 0;
120 gnMaxLives: Byte = 0;
121 gnPlayers: Byte = 1;
122 gnTeamDamage: Boolean = False;
123 gnAllowExit: Boolean = True;
124 gnWeaponStay: Boolean = False;
125 gnMonsters: Boolean = False;
126 gnBotsVS: String = 'Everybody';
127 gsSDLSampleRate: Integer = 44100;
128 gsSDLBufferSize: Integer = 2048;
129 gSFSDebug: Boolean = False;
130 gSFSFastMode: Boolean = False;
131 gDefaultMegawadStart: AnsiString = DF_Default_Megawad_Start;
132 gBerserkAutoswitch: Boolean = True;
134 implementation
136 uses
137 {$IFDEF USE_NANOGL}
138 nanoGL,
139 {$ELSE}
140 GL, GLExt,
141 {$ENDIF}
142 e_log, e_input, g_window, g_sound, g_gfx, g_player, Math,
143 g_map, g_net, g_netmaster, SysUtils, CONFIG, g_game, g_main, e_texture,
144 g_items, wadreader, e_graphics, g_touch;
146 procedure g_Options_SetDefault();
147 var
148 i: Integer;
149 begin
150 g_Sound_SetupAllVolumes(75, 65);
151 gMaxSimSounds := 8;
152 gMuteWhenInactive := False;
153 gAnnouncer := ANNOUNCE_MEPLUS;
154 gSoundEffectsDF := True;
155 gUseChatSounds := True;
156 g_GFX_SetMax(2000);
157 g_Gibs_SetMax(150);
158 g_Corpses_SetMax(20);
159 g_Shells_SetMax(300);
160 gGibsCount := 32;
161 gBloodCount := 3;
162 gAdvBlood := True;
163 gAdvCorpses := True;
164 gAdvGibs := True;
165 gFlash := 1;
166 gDrawBackGround := True;
167 gShowMessages := True;
168 gRevertPlayers := False;
169 g_dbg_scale := 1.0;
170 g_touch_size := 1.0;
171 g_touch_fire := True;
172 g_touch_offset := 50;
174 for i := 0 to e_MaxJoys-1 do
175 e_JoystickDeadzones[i] := 8192;
177 with gGameControls.GameControls do
178 begin
179 TakeScreenshot := 183;
180 Stat := 15;
181 Chat := 20; // [T]
182 TeamChat := 21; // [Y]
183 end;
185 with gGameControls.P1Control do
186 begin
187 KeyRight := 77;
188 KeyLeft := 75;
189 KeyUp := 72;
190 KeyDown := 76;
191 KeyFire := 184;
192 KeyJump := 157;
193 KeyNextWeapon := 73;
194 KeyPrevWeapon := 71;
195 KeyOpen := 54;
196 KeyStrafe := 0;
197 for i := 0 to 9 do
198 KeyWeapon[i] := 30 + i;
199 KeyWeapon[10] := 45;
200 for i := 10 to High(KeyWeapon) do
201 KeyWeapon[i] := 0;
203 KeyRight2 := VK_RIGHT;
204 KeyLeft2 := VK_LEFT;
205 KeyUp2 := VK_UP;
206 KeyDown2 := VK_DOWN;
207 KeyFire2 := VK_FIRE;
208 KeyJump2 := VK_JUMP;
209 KeyNextWeapon2 := VK_NEXT;
210 KeyPrevWeapon2 := VK_PREV;
211 KeyOpen2 := VK_OPEN;
212 KeyStrafe2 := VK_STRAFE;
213 for i := 0 to High(KeyWeapon2) do
214 KeyWeapon2[i] := VK_0 + i;
215 end;
217 with gGameControls.P2Control do
218 begin
219 KeyRight := 33;
220 KeyLeft := 31;
221 KeyUp := 18;
222 KeyDown := 32;
223 KeyFire := 30;
224 KeyJump := 16;
225 KeyNextWeapon := 19;
226 KeyPrevWeapon := 17;
227 KeyOpen := 58;
228 KeyStrafe := 0;
229 for i := 0 to High(KeyWeapon) do
230 KeyWeapon[i] := 0;
232 KeyRight2 := 0;
233 KeyLeft2 := 0;
234 KeyUp2 := 0;
235 KeyDown2 := 0;
236 KeyFire2 := 0;
237 KeyJump2 := 0;
238 KeyNextWeapon2 := 0;
239 KeyPrevWeapon2 := 0;
240 KeyOpen2 := 0;
241 KeyStrafe2 := 0;
242 for i := 0 to High(KeyWeapon2) do
243 KeyWeapon2[i] := 0;
244 end;
246 with gPlayer1Settings do
247 begin
248 Name := 'Player1';
249 Model := STD_PLAYER_MODEL;
250 Color.R := PLAYER1_DEF_COLOR.R;
251 Color.G := PLAYER1_DEF_COLOR.G;
252 Color.B := PLAYER1_DEF_COLOR.B;
253 Team := TEAM_RED;
254 end;
256 with gPlayer2Settings do
257 begin
258 Name := 'Player2';
259 Model := STD_PLAYER_MODEL;
260 Color.R := PLAYER2_DEF_COLOR.R;
261 Color.G := PLAYER2_DEF_COLOR.G;
262 Color.B := PLAYER2_DEF_COLOR.B;
263 Team := TEAM_BLUE;
264 end;
266 NetUseMaster := True;
267 NetForwardPorts := False;
268 g_Net_Slist_Set('mpms.doom2d.org', 25665);
269 end;
271 procedure g_Options_Read(FileName: String);
272 var
273 config: TConfig;
274 str: String;
275 i: Integer;
276 begin
277 gAskLanguage := True;
278 e_WriteLog('Reading config', TMsgType.Notify);
280 if not FileExists(FileName) then
281 begin
282 e_WriteLog('Config file '+FileName+' not found', TMsgType.Warning);
283 g_Options_SetDefault();
285 // Default video options:
286 gScreenWidth := 800;
287 gScreenHeight := 600;
288 gWinRealPosX := 0;
289 gWinRealPosY := 0;
290 gWinMaximized := False;
291 gFullScreen := False;
292 gBPP := 32;
293 gVSync := False;
294 gTextureFilter := True;
295 glLegacyNPOT := False;
297 Exit;
298 end;
300 config := TConfig.CreateFile(FileName);
302 gScreenWidth := config.ReadInt('Video', 'ScreenWidth', 800);
303 if gScreenWidth < 640 then
304 gScreenWidth := 640;
305 gScreenHeight := config.ReadInt('Video', 'ScreenHeight', 600);
306 if gScreenHeight < 480 then
307 gScreenHeight := 480;
308 gWinRealPosX := config.ReadInt('Video', 'WinPosX', 60);
309 if gWinRealPosX < 0 then
310 gWinRealPosX := 60;
311 gWinRealPosY := config.ReadInt('Video', 'WinPosY', 60);
312 if gWinRealPosY < 0 then
313 gWinRealPosY := 60;
314 gFullScreen := config.ReadBool('Video', 'Fullscreen', False);
315 gWinMaximized := config.ReadBool('Video', 'Maximized', False);
316 gBPP := config.ReadInt('Video', 'BPP', 32);
317 gFreq := config.ReadInt('Video', 'Freq', 0);
318 gVSync := config.ReadBool('Video', 'VSync', True);
319 gTextureFilter := config.ReadBool('Video', 'TextureFilter', True);
320 glLegacyNPOT := config.ReadBool('Video', 'LegacyCompatible', False);
322 gNoSound := config.ReadBool('Sound', 'NoSound', False);
323 gSoundLevel := Min(config.ReadInt('Sound', 'SoundLevel', 75), 255);
324 gMusicLevel := Min(config.ReadInt('Sound', 'MusicLevel', 65), 255);
325 gMaxSimSounds := Max(Min(config.ReadInt('Sound', 'MaxSimSounds', 8), 66), 2);
326 gMuteWhenInactive := config.ReadBool('Sound', 'MuteInactive', False);
327 gAnnouncer := Min(Max(config.ReadInt('Sound', 'Announcer', ANNOUNCE_MEPLUS), ANNOUNCE_NONE), ANNOUNCE_ALL);
328 gSoundEffectsDF := config.ReadBool('Sound', 'SoundEffectsDF', True);
329 gUseChatSounds := config.ReadBool('Sound', 'ChatSounds', True);
330 gsSDLSampleRate := Min(Max(config.ReadInt('Sound', 'SDLSampleRate', 44100), 11025), 96000);
331 gsSDLBufferSize := Min(Max(config.ReadInt('Sound', 'SDLBufferSize', 2048), 64), 16384);
333 with gGameControls.GameControls do
334 begin
335 TakeScreenshot := config.ReadInt('GameControls', 'TakeScreenshot', 183);
336 Stat := config.ReadInt('GameControls', 'Stat', 15);
337 Chat := config.ReadInt('GameControls', 'Chat', 20);
338 TeamChat := config.ReadInt('GameControls', 'TeamChat', 21);
339 end;
341 with gGameControls.P1Control, config do
342 begin
343 KeyRight := ReadInt('Player1', 'KeyRight', 33);
344 KeyLeft := ReadInt('Player1', 'KeyLeft', 31);
345 KeyUp := ReadInt('Player1', 'KeyUp', 18);
346 KeyDown := ReadInt('Player1', 'KeyDown', 32);
347 KeyFire := ReadInt('Player1', 'KeyFire', 30);
348 KeyJump := ReadInt('Player1', 'KeyJump', 16);
349 KeyNextWeapon := ReadInt('Player1', 'KeyNextWeapon', 19);
350 KeyPrevWeapon := ReadInt('Player1', 'KeyPrevWeapon', 17);
351 KeyOpen := ReadInt('Player1', 'KeyOpen', 58);
352 KeyStrafe := ReadInt('Player1', 'KeyStrafe', 0);
353 for i := 0 to High(KeyWeapon) do
354 KeyWeapon[i] := ReadInt('Player1', 'KeyWeapon' + IntToStr(i), 0);
356 KeyRight2 := ReadInt('Player1', 'KeyRight2', 0);
357 KeyLeft2 := ReadInt('Player1', 'KeyLeft2', 0);
358 KeyUp2 := ReadInt('Player1', 'KeyUp2', 0);
359 KeyDown2 := ReadInt('Player1', 'KeyDown2', 0);
360 KeyFire2 := ReadInt('Player1', 'KeyFire2', 0);
361 KeyJump2 := ReadInt('Player1', 'KeyJump2', 0);
362 KeyNextWeapon2 := ReadInt('Player1', 'KeyNextWeapon2', 0);
363 KeyPrevWeapon2 := ReadInt('Player1', 'KeyPrevWeapon2', 0);
364 KeyOpen2 := ReadInt('Player1', 'KeyOpen2', 0);
365 KeyStrafe2 := ReadInt('Player1', 'KeyStrafe2', 0);
366 for i := 0 to High(KeyWeapon2) do
367 KeyWeapon2[i] := ReadInt('Player1', 'KeyWeapon2' + IntToStr(i), 0);
368 end;
370 with gPlayer1Settings, config do
371 begin
372 Name := ReadStr('Player1', 'name', 'Player1');
373 Model := ReadStr('Player1', 'model', STD_PLAYER_MODEL);
374 Color.R := Min(Abs(ReadInt('Player1', 'red', PLAYER1_DEF_COLOR.R)), 255);
375 Color.G := Min(Abs(ReadInt('Player1', 'green', PLAYER1_DEF_COLOR.G)), 255);
376 Color.B := Min(Abs(ReadInt('Player1', 'blue', PLAYER1_DEF_COLOR.B)), 255);
377 Team := ReadInt('Player1', 'team', TEAM_RED);
378 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
379 Team := TEAM_RED;
380 end;
382 with gGameControls.P2Control, config do
383 begin
384 KeyRight := ReadInt('Player2', 'KeyRight', 205);
385 KeyLeft := ReadInt('Player2', 'KeyLeft', 203);
386 KeyUp := ReadInt('Player2', 'KeyUp', 200);
387 KeyDown := ReadInt('Player2', 'KeyDown', 208);
388 KeyFire := ReadInt('Player2', 'KeyFire', 184);
389 KeyJump := ReadInt('Player2', 'KeyJump', 157);
390 KeyNextWeapon := ReadInt('Player2', 'KeyNextWeapon', 73);
391 KeyPrevWeapon := ReadInt('Player2', 'KeyPrevWeapon', 71);
392 KeyOpen := ReadInt('Player2', 'KeyOpen', 54);
393 KeyStrafe := ReadInt('Player2', 'KeyStrafe', 0);
394 for i := 0 to High(KeyWeapon) do
395 KeyWeapon[i] := ReadInt('Player2', 'KeyWeapon' + IntToStr(i), 0);
397 KeyRight2 := ReadInt('Player2', 'KeyRight2', 0);
398 KeyLeft2 := ReadInt('Player2', 'KeyLeft2', 0);
399 KeyUp2 := ReadInt('Player2', 'KeyUp2', 0);
400 KeyDown2 := ReadInt('Player2', 'KeyDown2', 0);
401 KeyFire2 := ReadInt('Player2', 'KeyFire2', 0);
402 KeyJump2 := ReadInt('Player2', 'KeyJump2', 0);
403 KeyNextWeapon2 := ReadInt('Player2', 'KeyNextWeapon2', 0);
404 KeyPrevWeapon2 := ReadInt('Player2', 'KeyPrevWeapon2', 0);
405 KeyOpen2 := ReadInt('Player2', 'KeyOpen2', 0);
406 KeyStrafe2 := ReadInt('Player2', 'KeyStrafe2', 0);
407 for i := 0 to High(KeyWeapon2) do
408 KeyWeapon2[i] := ReadInt('Player2', 'KeyWeapon2' + IntToStr(i), 0);
409 end;
411 with gPlayer2Settings, config do
412 begin
413 Name := ReadStr('Player2', 'name', 'Player2');
414 Model := ReadStr('Player2', 'model', STD_PLAYER_MODEL);
415 Color.R := Min(Abs(ReadInt('Player2', 'red', PLAYER2_DEF_COLOR.R)), 255);
416 Color.G := Min(Abs(ReadInt('Player2', 'green', PLAYER2_DEF_COLOR.G)), 255);
417 Color.B := Min(Abs(ReadInt('Player2', 'blue', PLAYER2_DEF_COLOR.B)), 255);
418 Team := ReadInt('Player2', 'team', TEAM_BLUE);
419 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
420 Team := TEAM_RED;
421 end;
423 for i := 0 to e_MaxJoys-1 do
424 e_JoystickDeadzones[i] := config.ReadInt('Joysticks', 'Deadzone' + IntToStr(i), 8192);
426 g_touch_size := Max(config.ReadInt('Touch', 'Size', 10) / 10, 0.1);
427 g_touch_fire := config.ReadBool('Touch', 'Fire', True);
428 g_touch_offset := Max(Min(config.ReadInt('Touch', 'Offset', 50), 100), 0);
430 g_GFX_SetMax(Min(config.ReadInt('Game', 'MaxParticles', 1000), 50000));
431 g_Shells_SetMax(Min(config.ReadInt('Game', 'MaxShells', 300), 600));
432 g_Gibs_SetMax(Min(config.ReadInt('Game', 'MaxGibs', 150), 500));
433 g_Corpses_SetMax(Min(config.ReadInt('Game', 'MaxCorpses', 20), 100));
435 case config.ReadInt('Game', 'GibsCount', 3) of
436 0: gGibsCount := 0;
437 1: gGibsCount := 8;
438 2: gGibsCount := 16;
439 3: gGibsCount := 32;
440 else gGibsCount := 48;
441 end;
443 ITEM_RESPAWNTIME := 36*Max(config.ReadInt('Game', 'ItemRespawnTime', 60), 0);
444 gBloodCount := Min(config.ReadInt('Game', 'BloodCount', 4), 4);
445 gAdvBlood := config.ReadBool('Game', 'AdvancesBlood', True);
446 gAdvCorpses := config.ReadBool('Game', 'AdvancesCorpses', True);
447 gAdvGibs := config.ReadBool('Game', 'AdvancesGibs', True);
448 gFlash := Min(Max(config.ReadInt('Game', 'Flash', 1), 0), 2);
449 gDrawBackGround := config.ReadBool('Game', 'BackGround', True);
450 gShowMessages := config.ReadBool('Game', 'Messages', True);
451 gRevertPlayers := config.ReadBool('Game', 'RevertPlayers', False);
452 gChatBubble := Min(Max(config.ReadInt('Game', 'ChatBubble', 4), 0), 4);
453 gSFSDebug := config.ReadBool('Game', 'SFSDebug', False);
454 wadoptDebug := gSFSDebug;
455 gSFSFastMode := config.ReadBool('Game', 'SFSFastMode', False);
456 wadoptFast := gSFSFastMode;
457 e_FastScreenshots := config.ReadBool('Game', 'FastScreenshots', True);
458 gDefaultMegawadStart := config.ReadStr('Game', 'DefaultMegawadStart', DF_Default_Megawad_Start);
459 gBerserkAutoswitch := config.ReadBool('Game', 'BerserkAutoswitching', True);
460 g_dbg_scale := Max(config.ReadInt('Game', 'Scale', 100) / 100, 1.0);
462 // Ãåéìïëåé â ñâîåé èãðå
463 gcMap := config.ReadStr('GameplayCustom', 'Map', '');
464 gcGameMode := config.ReadStr('GameplayCustom', 'GameMode', _lc[I_MENU_GAME_TYPE_DM]);
465 gcTimeLimit := Min(Max(config.ReadInt('GameplayCustom', 'TimeLimit', 0), 0), 65535);
466 gcGoalLimit := Min(Max(config.ReadInt('GameplayCustom', 'GoalLimit', 0), 0), 65535);
467 gcMaxLives := Min(Max(config.ReadInt('GameplayCustom', 'MaxLives', 0), 0), 255);
468 gcPlayers := Min(Max(config.ReadInt('GameplayCustom', 'Players', 1), 0), 2);
469 gcTeamDamage := config.ReadBool('GameplayCustom', 'TeamDamage', False);
470 gcAllowExit := config.ReadBool('GameplayCustom', 'AllowExit', True);
471 gcWeaponStay := config.ReadBool('GameplayCustom', 'WeaponStay', False);
472 gcMonsters := config.ReadBool('GameplayCustom', 'Monsters', False);
473 gcBotsVS := config.ReadStr('GameplayCustom', 'BotsVS', 'Everybody');
475 with gGameSettings do
476 begin
477 GameMode := g_Game_TextToMode(gcGameMode);
478 if GameMode = GM_NONE then
479 GameMode := GM_DM;
480 if GameMode = GM_SINGLE then
481 GameMode := GM_COOP;
482 TimeLimit := gcTimeLimit;
483 GoalLimit := gcGoalLimit;
484 MaxLives := gcMaxLives;
486 Options := 0;
487 if gcTeamDamage then
488 Options := Options or GAME_OPTION_TEAMDAMAGE;
489 if gcAllowExit then
490 Options := Options or GAME_OPTION_ALLOWEXIT;
491 if gcWeaponStay then
492 Options := Options or GAME_OPTION_WEAPONSTAY;
493 if gcMonsters then
494 Options := Options or GAME_OPTION_MONSTERS;
495 if gcBotsVS = 'Everybody' then
496 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
497 if gcBotsVS = 'Players' then
498 Options := Options or GAME_OPTION_BOTVSPLAYER;
499 if gcBotsVS = 'Monsters' then
500 Options := Options or GAME_OPTION_BOTVSMONSTER;
501 end;
503 // Ãåéìïëåé â ñåòåâîé èãðå
504 gnMap := config.ReadStr('GameplayNetwork', 'Map', '');
505 gnGameMode := config.ReadStr('GameplayNetwork', 'GameMode', _lc[I_MENU_GAME_TYPE_DM]);
506 gnTimeLimit := Min(Max(config.ReadInt('GameplayNetwork', 'TimeLimit', 0), 0), 65535);
507 gnGoalLimit := Min(Max(config.ReadInt('GameplayNetwork', 'GoalLimit', 0), 0), 65535);
508 gnMaxLives := Min(Max(config.ReadInt('GameplayNetwork', 'MaxLives', 0), 0), 255);
509 gnPlayers := Min(Max(config.ReadInt('GameplayNetwork', 'Players', 1), 0), 2);
510 gnTeamDamage := config.ReadBool('GameplayNetwork', 'TeamDamage', False);
511 gnAllowExit := config.ReadBool('GameplayNetwork', 'AllowExit', True);
512 gnWeaponStay := config.ReadBool('GameplayNetwork', 'WeaponStay', False);
513 gnMonsters := config.ReadBool('GameplayNetwork', 'Monsters', False);
514 gnBotsVS := config.ReadStr('GameplayNetwork', 'BotsVS', 'Everybody');
516 // Îáùèå ñåòåâûå
517 NetSlistIP := config.ReadStr('MasterServer', 'IP', 'mpms.doom2d.org');
518 NetSlistPort := config.ReadInt('MasterServer', 'Port', 25665);
520 // Ñåðâåð
521 NetServerName := config.ReadStr('Server', 'Name', 'Unnamed Server');
522 NetPassword := config.ReadStr('Server', 'Password', '');
523 NetPort := Min(Max(0, config.ReadInt('Server', 'Port', 25666)), 65535);
524 NetMaxClients := Min(Max(0, config.ReadInt('Server', 'MaxClients', 16)), NET_MAXCLIENTS);
525 NetAllowRCON := config.ReadBool('Server', 'RCON', False);
526 NetRCONPassword := config.ReadStr('Server', 'RCONPassword', 'default');
527 NetUseMaster := config.ReadBool('Server', 'SyncWithMaster', True);
528 NetUpdateRate := Max(0, config.ReadInt('Server', 'UpdateInterval', 0));
529 NetRelupdRate := Max(0, config.ReadInt('Server', 'ReliableUpdateInterval', 18));
530 NetMasterRate := Max(1, config.ReadInt('Server', 'MasterSyncInterval', 60000));
531 NetForwardPorts := config.ReadBool('Server', 'ForwardPorts', False);
533 // Êëèåíò
534 NetInterpLevel := Max(0, config.ReadInt('Client', 'InterpolationSteps', 2));
535 NetForcePlayerUpdate := config.ReadBool('Client', 'ForcePlayerUpdate', False);
536 NetPredictSelf := config.ReadBool('Client', 'PredictSelf', True);
537 NetClientIP := config.ReadStr('Client', 'LastIP', '127.0.0.1');
538 NetClientPort := Max(0, config.ReadInt('Client', 'LastPort', 25666));
540 // ßçûê:
541 str := config.ReadStr('Game', 'Language', '');
542 if (str = LANGUAGE_RUSSIAN) or
543 (str = LANGUAGE_ENGLISH) then
544 begin
545 gLanguage := str;
546 gAskLanguage := False;
547 end
548 else
549 gLanguage := LANGUAGE_ENGLISH;
551 config.Free();
553 //if gTextureFilter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
554 end;
556 procedure g_Options_Write(FileName: String);
557 var
558 config: TConfig;
559 i: Integer;
560 begin
561 e_WriteLog('Writing config', TMsgType.Notify);
563 config := TConfig.CreateFile(FileName);
565 config.WriteInt('Video', 'ScreenWidth', gScreenWidth);
566 config.WriteInt('Video', 'ScreenHeight', gScreenHeight);
567 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
568 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
569 config.WriteBool('Video', 'Fullscreen', gFullScreen);
570 config.WriteBool('Video', 'Maximized', gWinMaximized);
571 config.WriteInt('Video', 'BPP', gBPP);
572 config.WriteBool('Video', 'VSync', gVSync);
573 config.WriteBool('Video', 'TextureFilter', gTextureFilter);
574 config.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT);
576 config.WriteBool('Sound', 'NoSound', gNoSound);
577 config.WriteInt('Sound', 'SoundLevel', gSoundLevel);
578 config.WriteInt('Sound', 'MusicLevel', gMusicLevel);
579 config.WriteInt('Sound', 'MaxSimSounds', gMaxSimSounds);
580 config.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive);
581 config.WriteInt('Sound', 'Announcer', gAnnouncer);
582 config.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF);
583 config.WriteBool('Sound', 'ChatSounds', gUseChatSounds);
584 config.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate);
585 config.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize);
587 with config, gGameControls.GameControls do
588 begin
589 WriteInt('GameControls', 'TakeScreenshot', TakeScreenshot);
590 WriteInt('GameControls', 'Stat', Stat);
591 WriteInt('GameControls', 'Chat', Chat);
592 WriteInt('GameControls', 'TeamChat', TeamChat);
593 end;
595 with config, gGameControls.P1Control, gPlayer1Settings do
596 begin
597 WriteInt('Player1', 'KeyRight', KeyRight);
598 WriteInt('Player1', 'KeyLeft', KeyLeft);
599 WriteInt('Player1', 'KeyUp', KeyUp);
600 WriteInt('Player1', 'KeyDown', KeyDown);
601 WriteInt('Player1', 'KeyFire', KeyFire);
602 WriteInt('Player1', 'KeyJump', KeyJump);
603 WriteInt('Player1', 'KeyNextWeapon', KeyNextWeapon);
604 WriteInt('Player1', 'KeyPrevWeapon', KeyPrevWeapon);
605 WriteInt('Player1', 'KeyOpen', KeyOpen);
606 WriteInt('Player1', 'KeyStrafe', KeyStrafe);
607 for i := 0 to High(KeyWeapon) do
608 WriteInt('Player1', 'KeyWeapon' + IntToStr(i), KeyWeapon[i]);
610 WriteInt('Player1', 'KeyRight2', KeyRight2);
611 WriteInt('Player1', 'KeyLeft2', KeyLeft2);
612 WriteInt('Player1', 'KeyUp2', KeyUp2);
613 WriteInt('Player1', 'KeyDown2', KeyDown2);
614 WriteInt('Player1', 'KeyFire2', KeyFire2);
615 WriteInt('Player1', 'KeyJump2', KeyJump2);
616 WriteInt('Player1', 'KeyNextWeapon2', KeyNextWeapon2);
617 WriteInt('Player1', 'KeyPrevWeapon2', KeyPrevWeapon2);
618 WriteInt('Player1', 'KeyOpen2', KeyOpen2);
619 WriteInt('Player1', 'KeyStrafe2', KeyStrafe2);
620 for i := 0 to High(KeyWeapon2) do
621 WriteInt('Player1', 'KeyWeapon2' + IntToStr(i), KeyWeapon2[i]);
623 WriteStr('Player1', 'Name', Name);
624 WriteStr('Player1', 'model', Model);
625 WriteInt('Player1', 'red', Color.R);
626 WriteInt('Player1', 'green', Color.G);
627 WriteInt('Player1', 'blue', Color.B);
628 WriteInt('Player1', 'team', Team);
629 end;
631 with config, gGameControls.P2Control, gPlayer2Settings do
632 begin
633 WriteInt('Player2', 'KeyRight', KeyRight);
634 WriteInt('Player2', 'KeyLeft', KeyLeft);
635 WriteInt('Player2', 'KeyUp', KeyUp);
636 WriteInt('Player2', 'KeyDown', KeyDown);
637 WriteInt('Player2', 'KeyFire', KeyFire);
638 WriteInt('Player2', 'KeyJump', KeyJump);
639 WriteInt('Player2', 'KeyNextWeapon', KeyNextWeapon);
640 WriteInt('Player2', 'KeyPrevWeapon', KeyPrevWeapon);
641 WriteInt('Player2', 'KeyOpen', KeyOpen);
642 WriteInt('Player2', 'KeyStrafe', KeyStrafe);
643 for i := 0 to High(KeyWeapon) do
644 WriteInt('Player2', 'KeyWeapon' + IntToStr(i), KeyWeapon[i]);
646 WriteInt('Player2', 'KeyRight2', KeyRight2);
647 WriteInt('Player2', 'KeyLeft2', KeyLeft2);
648 WriteInt('Player2', 'KeyUp2', KeyUp2);
649 WriteInt('Player2', 'KeyDown2', KeyDown2);
650 WriteInt('Player2', 'KeyFire2', KeyFire2);
651 WriteInt('Player2', 'KeyJump2', KeyJump2);
652 WriteInt('Player2', 'KeyNextWeapon2', KeyNextWeapon2);
653 WriteInt('Player2', 'KeyPrevWeapon2', KeyPrevWeapon2);
654 WriteInt('Player2', 'KeyOpen2', KeyOpen2);
655 WriteInt('Player2', 'KeyStrafe2', KeyStrafe2);
656 for i := 0 to High(KeyWeapon2) do
657 WriteInt('Player2', 'KeyWeapon2' + IntToStr(i), KeyWeapon2[i]);
659 WriteStr('Player2', 'Name', Name);
660 WriteStr('Player2', 'model', Model);
661 WriteInt('Player2', 'red', Color.R);
662 WriteInt('Player2', 'green', Color.G);
663 WriteInt('Player2', 'blue', Color.B);
664 WriteInt('Player2', 'team', Team);
665 end;
667 for i := 0 to e_MaxJoys-1 do
668 config.WriteInt('Joysticks', 'Deadzone' + IntToStr(i), e_JoystickDeadzones[i]);
670 config.WriteInt('Touch', 'Size', Round(g_touch_size * 10));
671 config.WriteBool('Touch', 'Fire', g_touch_fire);
672 config.WriteInt('Touch', 'Offset', Round(g_touch_offset));
674 with config do
675 case gGibsCount of
676 0: config.WriteInt('Game', 'GibsCount', 0);
677 8: config.WriteInt('Game', 'GibsCount', 1);
678 16: config.WriteInt('Game', 'GibsCount', 2);
679 32: config.WriteInt('Game', 'GibsCount', 3);
680 else config.WriteInt('Game', 'GibsCount', 4);
681 end;
683 config.WriteInt('Game', 'ItemRespawnTime', ITEM_RESPAWNTIME div 36);
684 config.WriteInt('Game', 'MaxParticles', g_GFX_GetMax());
685 config.WriteInt('Game', 'MaxShells', g_Shells_GetMax());
686 config.WriteInt('Game', 'MaxGibs', g_Gibs_GetMax());
687 config.WriteInt('Game', 'MaxCorpses', g_Corpses_GetMax());
688 config.WriteInt('Game', 'BloodCount', gBloodCount);
689 config.WriteBool('Game', 'AdvancesBlood', gAdvBlood);
690 config.WriteBool('Game', 'AdvancesCorpses', gAdvCorpses);
691 config.WriteBool('Game', 'AdvancesGibs', gAdvGibs);
692 config.WriteInt('Game', 'Flash', gFlash);
693 config.WriteBool('Game', 'BackGround', gDrawBackGround);
694 config.WriteBool('Game', 'Messages', gShowMessages);
695 config.WriteBool('Game', 'RevertPlayers', gRevertPlayers);
696 config.WriteInt('Game', 'ChatBubble', gChatBubble);
697 config.WriteBool('Game', 'SFSDebug', gSFSDebug);
698 config.WriteBool('Game', 'SFSFastMode', gSFSFastMode);
699 config.WriteBool('Game', 'FastScreenshots', e_FastScreenshots);
700 config.WriteStr('Game', 'DefaultMegawadStart', gDefaultMegawadStart);
701 config.WriteBool('Game', 'BerserkAutoswitching', gBerserkAutoswitch);
702 config.WriteInt('Game', 'Scale', Round(g_dbg_scale * 100));
704 config.WriteStr ('GameplayCustom', 'Map', gcMap);
705 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
706 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
707 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
708 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
709 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
710 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
711 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
712 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
713 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
714 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
716 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
717 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
718 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
719 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
720 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
721 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
722 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
723 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
724 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
725 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
726 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
728 config.WriteStr('MasterServer', 'IP', NetSlistIP);
729 config.WriteInt('MasterServer', 'Port', NetSlistPort);
731 config.WriteStr ('Server', 'Name', NetServerName);
732 config.WriteStr ('Server', 'Password', NetPassword);
733 config.WriteInt ('Server', 'Port', NetPort);
734 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
735 config.WriteBool('Server', 'RCON', NetAllowRCON);
736 config.WriteStr ('Server', 'RCONPassword', NetRCONPassword);
737 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
738 config.WriteBool('Server', 'ForwardPorts', NetForwardPorts);
739 config.WriteInt ('Server', 'UpdateInterval', NetUpdateRate);
740 config.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate);
741 config.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate);
743 config.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel);
744 config.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate);
745 config.WriteBool ('Client', 'PredictSelf', NetPredictSelf);
746 config.WriteStr ('Client', 'LastIP', NetClientIP);
747 config.WriteInt ('Client', 'LastPort', NetClientPort);
749 config.SaveFile(FileName);
750 config.Free();
751 end;
753 procedure g_Options_Write_Language(FileName: String);
754 var
755 config: TConfig;
756 begin
757 e_WriteLog('Writing language config', TMsgType.Notify);
759 config := TConfig.CreateFile(FileName);
760 config.WriteStr('Game', 'Language', gLanguage);
761 config.SaveFile(FileName);
762 config.Free();
763 end;
765 procedure g_Options_Write_Video(FileName: String);
766 var
767 config: TConfig;
768 sW, sH: Integer;
769 begin
770 e_WriteLog('Writing resolution to config', TMsgType.Notify);
772 config := TConfig.CreateFile(FileName);
774 if gWinMaximized and (not gFullscreen) then
775 begin
776 sW := gWinSizeX;
777 sH := gWinSizeY;
778 end
779 else
780 begin
781 sW := gScreenWidth;
782 sH := gScreenHeight;
783 end;
784 e_LogWritefln(' (ws=%dx%d) (ss=%dx%d)', [gWinSizeX, gWinSizeY, gScreenWidth, gScreenHeight]);
786 config.WriteInt('Video', 'ScreenWidth', sW);
787 config.WriteInt('Video', 'ScreenHeight', sH);
788 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
789 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
790 config.WriteBool('Video', 'Fullscreen', gFullscreen);
791 config.WriteBool('Video', 'Maximized', gWinMaximized);
793 config.SaveFile(FileName);
794 config.Free();
795 end;
797 procedure g_Options_Write_Gameplay_Custom(FileName: String);
798 var
799 config: TConfig;
800 begin
801 e_WriteLog('Writing custom gameplay config', TMsgType.Notify);
803 config := TConfig.CreateFile(FileName);
805 config.WriteStr ('GameplayCustom', 'Map', gcMap);
806 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
807 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
808 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
809 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
810 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
811 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
812 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
813 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
814 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
815 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
817 config.SaveFile(FileName);
818 config.Free();
819 end;
821 procedure g_Options_Write_Gameplay_Net(FileName: String);
822 var
823 config: TConfig;
824 begin
825 e_WriteLog('Writing network gameplay config', TMsgType.Notify);
827 config := TConfig.CreateFile(FileName);
829 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
830 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
831 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
832 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
833 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
834 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
835 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
836 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
837 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
838 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
839 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
841 config.SaveFile(FileName);
842 config.Free();
843 end;
845 procedure g_Options_Write_Net_Server(FileName: String);
846 var
847 config: TConfig;
848 begin
849 e_WriteLog('Writing server config', TMsgType.Notify);
851 config := TConfig.CreateFile(FileName);
853 config.WriteStr ('Server', 'Name', NetServerName);
854 config.WriteStr ('Server', 'Password', NetPassword);
855 config.WriteInt ('Server', 'Port', NetPort);
856 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
857 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
858 config.WriteBool('Server', 'ForwardPorts', NetForwardPorts);
860 config.SaveFile(FileName);
861 config.Free();
862 end;
864 procedure g_Options_Write_Net_Client(FileName: String);
865 var
866 config: TConfig;
867 begin
868 e_WriteLog('Writing client config', TMsgType.Notify);
870 config := TConfig.CreateFile(FileName);
872 config.WriteStr('Client', 'LastIP', NetClientIP);
873 config.WriteInt('Client', 'LastPort', NetClientPort);
875 config.SaveFile(FileName);
876 config.Free();
877 end;
879 end.