DEADSOFTWARE

Fix some default values that not present in config
[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;
79 gScreenHeight: Word;
80 gWinRealPosX: Integer;
81 gWinRealPosY: Integer;
82 gBPP: Byte;
83 gFreq: Byte;
84 gFullscreen: Boolean;
85 gWinMaximized: Boolean;
86 gVSync: Boolean;
87 glLegacyNPOT: Boolean;
88 gTextureFilter: Boolean;
89 gNoSound: Boolean;
90 gSoundLevel: Byte;
91 gMusicLevel: Byte;
92 gMaxSimSounds: Byte;
93 gMuteWhenInactive: Boolean;
94 gAdvCorpses: Boolean;
95 gAdvBlood: Boolean;
96 gAdvGibs: Boolean;
97 gGibsCount: Integer;
98 gBloodCount: Byte;
99 gFlash: Byte;
100 gDrawBackGround: Boolean;
101 gShowMessages: Boolean;
102 gRevertPlayers: Boolean;
103 gLanguage: String;
104 gAskLanguage: Boolean;
105 gcMap: String;
106 gcGameMode: String;
107 gcTimeLimit: Word;
108 gcGoalLimit: Word;
109 gcMaxLives: Byte;
110 gcPlayers: Byte;
111 gcTeamDamage: Boolean;
112 gcAllowExit: Boolean;
113 gcWeaponStay: Boolean;
114 gcMonsters: Boolean;
115 gcBotsVS: String;
116 gnMap: String;
117 gnGameMode: String;
118 gnTimeLimit: Word;
119 gnGoalLimit: Word;
120 gnMaxLives: Byte;
121 gnPlayers: Byte;
122 gnTeamDamage: Boolean;
123 gnAllowExit: Boolean;
124 gnWeaponStay: Boolean;
125 gnMonsters: Boolean;
126 gnBotsVS: String;
127 gsSDLSampleRate: Integer;
128 gsSDLBufferSize: Integer;
129 gSFSDebug: Boolean;
130 gSFSFastMode: Boolean;
131 gDefaultMegawadStart: AnsiString;
132 gBerserkAutoswitch: Boolean;
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, SDL2;
146 procedure g_Options_SetDefaultVideo;
147 {$IF DEFINED(ANDROID)}
148 var
149 display: PSDL_DisplayMode;
150 {$ENDIF}
151 begin
152 {$IF DEFINED(ANDROID)}
153 (* On android set max screen size *)
154 SDL_GetCurrentDisplayMode(0, display);
155 gScreenWidth := display.w;
156 gScreenHeight := display.h;
157 gWinRealPosX := 0;
158 gWinRealPosY := 0;
159 gWinMaximized := False;
160 gFullScreen := False; (* if True then rotation not allowed *)
161 gBPP := 32;
162 gVSync := True;
163 gTextureFilter := True;
164 glLegacyNPOT := False;
165 {$ELSE}
166 (* On other systems use default 800x600 *)
167 gScreenWidth := 800;
168 gScreenHeight := 600;
169 gWinRealPosX := 0;
170 gWinRealPosY := 0;
171 gWinMaximized := False;
172 gFullScreen := False;
173 gBPP := 32;
174 gVSync := True;
175 gTextureFilter := True;
176 glLegacyNPOT := False;
177 {$ENDIF}
178 end;
180 procedure g_Options_SetDefault();
181 var
182 i: Integer;
183 begin
184 (* section Sound *)
185 gNoSound := False;
186 gSoundLevel := 75;
187 gMusicLevel := 65;
188 gMaxSimSounds := 8;
189 gMuteWhenInactive := False;
190 gAnnouncer := ANNOUNCE_MEPLUS;
191 gSoundEffectsDF := True;
192 gUseChatSounds := True;
193 gsSDLSampleRate := 44100;
194 gsSDLBufferSize := 2048;
196 g_Sound_SetupAllVolumes(gSoundLevel, gMusicLevel);
198 (* section GameControls *)
199 with gGameControls.GameControls do
200 begin
201 TakeScreenshot := SDL_SCANCODE_F12;
202 Stat := SDL_SCANCODE_TAB;
203 Chat := SDL_SCANCODE_T;
204 TeamChat := SDL_SCANCODE_Y;
205 end;
207 (* section Player1 *)
208 with gGameControls.P1Control do
209 begin
210 KeyRight := SDL_SCANCODE_KP_6;
211 KeyLeft := SDL_SCANCODE_KP_4;
212 KeyUp := SDL_SCANCODE_KP_8;
213 KeyDown := SDL_SCANCODE_KP_5;
214 KeyFire := SDL_SCANCODE_SLASH;
215 KeyJump := SDL_SCANCODE_RCTRL;
216 KeyNextWeapon := SDL_SCANCODE_KP_9;
217 KeyPrevWeapon := SDL_SCANCODE_KP_7;
218 KeyOpen := SDL_SCANCODE_RSHIFT;
219 KeyStrafe := SDL_SCANCODE_PERIOD;
221 for i := 0 to 9 do
222 begin
223 KeyWeapon[i] := SDL_SCANCODE_1 + i (* 1, ..., 9, 0 *)
224 end;
225 KeyWeapon[10] := SDL_SCANCODE_MINUS;
226 for i := 11 to High(KeyWeapon) do
227 begin
228 KeyWeapon[i] := 0
229 end;
231 KeyRight2 := VK_RIGHT;
232 KeyLeft2 := VK_LEFT;
233 KeyUp2 := VK_UP;
234 KeyDown2 := VK_DOWN;
235 KeyFire2 := VK_FIRE;
236 KeyJump2 := VK_JUMP;
237 KeyNextWeapon2 := VK_NEXT;
238 KeyPrevWeapon2 := VK_PREV;
239 KeyOpen2 := VK_OPEN;
240 KeyStrafe2 := VK_STRAFE;
242 for i := 0 to High(KeyWeapon2) do
243 begin
244 KeyWeapon2[i] := VK_0 + i
245 end;
246 end;
248 with gPlayer1Settings do
249 begin
250 Name := 'Player1';
251 Model := STD_PLAYER_MODEL;
252 Color.R := PLAYER1_DEF_COLOR.R;
253 Color.G := PLAYER1_DEF_COLOR.G;
254 Color.B := PLAYER1_DEF_COLOR.B;
255 Team := TEAM_RED;
256 end;
258 (* section Player2 *)
259 with gGameControls.P2Control do
260 begin
261 KeyRight := SDL_SCANCODE_D;
262 KeyLeft := SDL_SCANCODE_A;
263 KeyUp := SDL_SCANCODE_W;
264 KeyDown := SDL_SCANCODE_S;
265 KeyFire := SDL_SCANCODE_G;
266 KeyJump := SDL_SCANCODE_SPACE;
267 KeyNextWeapon := SDL_SCANCODE_E;
268 KeyPrevWeapon := SDL_SCANCODE_Q;
269 KeyOpen := SDL_SCANCODE_F;
270 KeyStrafe := SDL_SCANCODE_LSHIFT;
271 for i := 0 to High(KeyWeapon) do
272 begin
273 KeyWeapon[i] := 0
274 end;
276 KeyRight2 := 0;
277 KeyLeft2 := 0;
278 KeyUp2 := 0;
279 KeyDown2 := 0;
280 KeyFire2 := 0;
281 KeyJump2 := 0;
282 KeyNextWeapon2 := 0;
283 KeyPrevWeapon2 := 0;
284 KeyOpen2 := 0;
285 KeyStrafe2 := 0;
287 for i := 0 to High(KeyWeapon2) do
288 begin
289 KeyWeapon2[i] := 0;
290 end
291 end;
293 with gPlayer2Settings do
294 begin
295 Name := 'Player2';
296 Model := STD_PLAYER_MODEL;
297 Color.R := PLAYER2_DEF_COLOR.R;
298 Color.G := PLAYER2_DEF_COLOR.G;
299 Color.B := PLAYER2_DEF_COLOR.B;
300 Team := TEAM_BLUE;
301 end;
303 (* section Joysticks *)
304 for i := 0 to e_MaxJoys - 1 do
305 begin
306 e_JoystickDeadzones[i] := 8192
307 end;
309 (* section Touch *)
310 g_touch_size := 1.0;
311 g_touch_fire := True;
312 g_touch_offset := 50;
313 g_touch_alt := False;
315 (* section Game *)
316 g_GFX_SetMax(2000);
317 g_Shells_SetMax(300);
318 g_Gibs_SetMax(150);
319 g_Corpses_SetMax(20);
320 gGibsCount := 32;
321 ITEM_RESPAWNTIME := 60 * 36;
322 gBloodCount := 4;
323 gAdvBlood := True;
324 gAdvCorpses := True;
325 gAdvGibs := True;
326 gFlash := 1;
327 gDrawBackGround := True;
328 gShowMessages := True;
329 gRevertPlayers := False;
330 gChatBubble := 4;
331 gSFSDebug := False;
332 gSFSFastMode := False;
333 e_FastScreenshots := True;
334 gDefaultMegawadStart := DF_Default_Megawad_Start;
335 gBerserkAutoswitch := True;
336 g_dbg_scale := 1.0;
338 gAskLanguage := True;
339 gLanguage := LANGUAGE_ENGLISH;
341 (* section GameplayCustom *)
342 gcMap := '';
343 gcGameMode := _lc[I_MENU_GAME_TYPE_DM];
344 gcTimeLimit := 0;
345 gcGoalLimit := 0;
346 gcMaxLives := 0;
347 gcPlayers := 1;
348 gcTeamDamage := False;
349 gcAllowExit := True;
350 gcWeaponStay := False;
351 gcMonsters := False;
352 gcBotsVS := 'Everybody';
354 (* section GameplayNetwork *)
355 gnMap := '';
356 gnGameMode := _lc[I_MENU_GAME_TYPE_DM];
357 gnTimeLimit := 0;
358 gnGoalLimit := 0;
359 gnMaxLives := 0;
360 gnPlayers := 1;
361 gnTeamDamage := False;
362 gnAllowExit := True;
363 gnWeaponStay := False;
364 gnMonsters := False;
365 gnBotsVS := 'Everybody';
367 (* section MasterServer *)
368 NetSlistIP := 'mpms.doom2d.org';
369 NetSlistPort := 25665;
370 g_Net_Slist_Set(NetSlistIP, NetSlistPort);
372 (* section Server *)
373 NetServerName := 'Unnamed Server';
374 NetPassword := '';
375 NetPort := 25666;
376 NetMaxClients := 16;
377 NetAllowRCON := False;
378 NetRCONPassword := 'default';
379 NetUseMaster := True;
380 NetUpdateRate := 0;
381 NetRelupdRate := 18;
382 NetMasterRate := 60000;
383 NetForwardPorts := False;
385 (* section Client *)
386 NetInterpLevel := 2;
387 NetForcePlayerUpdate := False;
388 NetPredictSelf := True;
389 NetClientIP := '127.0.0.1';
390 NetClientPort := NetPort;
391 end;
393 procedure g_Options_Read(FileName: String);
394 var
395 i: Integer;
396 config: TConfig;
397 section: String;
399 procedure ReadInteger (VAR v: Integer; param: String; minv: Integer = Low(Integer); maxv: Integer = High(Integer));
400 begin
401 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
402 end;
404 procedure ReadInteger (VAR v: LongWord; param: String; minv: LongWord = Low(LongWord); maxv: LongWord = High(LongWord)); overload;
405 begin
406 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
407 end;
409 procedure ReadInteger (VAR v: Word; param: String; minv: Word = Low(Word); maxv: Word = High(Word)); overload;
410 begin
411 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
412 end;
414 procedure ReadInteger (VAR v: Byte; param: String; minv: Byte = Low(Byte); maxv: Byte = High(Byte)); overload;
415 begin
416 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
417 end;
419 procedure ReadBoolean (VAR v: Boolean; param: String);
420 begin
421 v := config.ReadBool(section, param, v)
422 end;
424 procedure ReadString (VAR v: String; param: String);
425 begin
426 v := config.ReadStr(section, param, v)
427 end;
429 begin
430 gAskLanguage := True;
431 e_WriteLog('Reading config', TMsgType.Notify);
432 g_Options_SetDefault;
434 if FileExists(FileName) = False then
435 begin
436 e_WriteLog('Config file '+FileName+' not found', TMsgType.Warning);
437 g_Options_SetDefaultVideo;
438 Exit
439 end;
441 config := TConfig.CreateFile(FileName);
443 section := 'Video';
444 ReadInteger(gScreenWidth, 'ScreenWidth', 0);
445 ReadInteger(gScreenHeight, 'ScreenHeight', 0);
446 ReadInteger(gWinRealPosX, 'WinPosX', 60);
447 ReadInteger(gWinRealPosY, 'WinPosY', 60);
448 ReadBoolean(gFullScreen, 'Fullscreen');
449 ReadBoolean(gWinMaximized, 'Maximized');
450 ReadInteger(gBPP, 'BPP', 0);
451 ReadInteger(gFreq, 'Freq', 0);
452 ReadBoolean(gVSync, 'VSync');
453 ReadBoolean(gTextureFilter, 'TextureFilter');
454 ReadBoolean(glLegacyNPOT, 'LegacyCompatible');
456 section := 'Sound';
457 ReadBoolean(gNoSound, 'NoSound');
458 ReadInteger(gSoundLevel, 'SoundLevel', 0, 255);
459 ReadInteger(gMusicLevel, 'MusicLevel', 0, 255);
460 ReadInteger(gMaxSimSounds, 'MaxSimSounds', 2, 66);
461 ReadBoolean(gMuteWhenInactive, 'MuteInactive');
462 ReadInteger(gAnnouncer, 'Announcer', ANNOUNCE_NONE, ANNOUNCE_ALL);
463 ReadBoolean(gSoundEffectsDF, 'SoundEffectsDF');
464 ReadBoolean(gUseChatSounds, 'ChatSounds');
465 ReadInteger(gsSDLSampleRate, 'SDLSampleRate', 11025, 96000);
466 ReadInteger(gsSDLBufferSize, 'SDLBufferSize', 64, 16384);
468 section := 'GameControls';
469 with gGameControls.GameControls do
470 begin
471 ReadInteger(TakeScreenshot, 'TakeScreenshot');
472 ReadInteger(Stat, 'Stat');
473 ReadInteger(Chat, 'Chat');
474 ReadInteger(TeamChat, 'TeamChat');
475 end;
477 section := 'Player1';
478 with gGameControls.P1Control do
479 begin
480 ReadInteger(KeyRight, 'KeyRight');
481 ReadInteger(KeyLeft, 'KeyLeft');
482 ReadInteger(KeyUp, 'KeyUp');
483 ReadInteger(KeyDown, 'KeyDown');
484 ReadInteger(KeyFire, 'KeyFire');
485 ReadInteger(KeyJump, 'KeyJump');
486 ReadInteger(KeyNextWeapon, 'KeyNextWeapon');
487 ReadInteger(KeyPrevWeapon, 'KeyPrevWeapon');
488 ReadInteger(KeyOpen, 'KeyOpen');
489 ReadInteger(KeyStrafe, 'KeyStrafe');
491 for i := 0 to High(KeyWeapon) do
492 begin
493 ReadInteger(KeyWeapon[i], 'KeyWeapon' + IntToStr(i))
494 end;
496 ReadInteger(KeyRight2, 'KeyRight2');
497 ReadInteger(KeyLeft2, 'KeyLeft2');
498 ReadInteger(KeyUp2, 'KeyUp2');
499 ReadInteger(KeyDown2, 'KeyDown2');
500 ReadInteger(KeyFire2, 'KeyFire2');
501 ReadInteger(KeyJump2, 'KeyJump2');
502 ReadInteger(KeyNextWeapon2, 'KeyNextWeapon2');
503 ReadInteger(KeyPrevWeapon2, 'KeyPrevWeapon2');
504 ReadInteger(KeyOpen2, 'KeyOpen2');
505 ReadInteger(KeyStrafe2, 'KeyStrafe2');
507 for i := 0 to High(KeyWeapon2) do
508 begin
509 ReadInteger(KeyWeapon2[i], 'KeyWeapon2' + IntToStr(i))
510 end;
511 end;
513 section := 'Player1';
514 with gPlayer1Settings do
515 begin
516 ReadString(Name, 'name');
517 ReadString(Model, 'model');
518 ReadInteger(Color.R, 'red', 0, 255);
519 ReadInteger(Color.G, 'green', 0, 255);
520 ReadInteger(Color.B, 'blue', 0, 255);
521 ReadInteger(Team, 'team');
522 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
523 Team := TEAM_RED;
524 end;
526 section := 'Player2';
527 with gGameControls.P2Control do
528 begin
529 ReadInteger(KeyRight, 'KeyRight');
530 ReadInteger(KeyLeft, 'KeyLeft');
531 ReadInteger(KeyUp, 'KeyUp');
532 ReadInteger(KeyDown, 'KeyDown');
533 ReadInteger(KeyFire, 'KeyFire');
534 ReadInteger(KeyJump, 'KeyJump');
535 ReadInteger(KeyNextWeapon, 'KeyNextWeapon');
536 ReadInteger(KeyPrevWeapon, 'KeyPrevWeapon');
537 ReadInteger(KeyOpen, 'KeyOpen');
538 ReadInteger(KeyStrafe, 'KeyStrafe');
540 for i := 0 to High(KeyWeapon) do
541 begin
542 ReadInteger(KeyWeapon[i], 'KeyWeapon' + IntToStr(i))
543 end;
545 ReadInteger(KeyRight2, 'KeyRight2');
546 ReadInteger(KeyLeft2, 'KeyLeft2');
547 ReadInteger(KeyUp2, 'KeyUp2');
548 ReadInteger(KeyDown2, 'KeyDown2');
549 ReadInteger(KeyFire2, 'KeyFire2');
550 ReadInteger(KeyJump2, 'KeyJump2');
551 ReadInteger(KeyNextWeapon2, 'KeyNextWeapon2');
552 ReadInteger(KeyPrevWeapon2, 'KeyPrevWeapon2');
553 ReadInteger(KeyOpen2, 'KeyOpen2');
554 ReadInteger(KeyStrafe2, 'KeyStrafe2');
556 for i := 0 to High(KeyWeapon2) do
557 begin
558 ReadInteger(KeyWeapon2[i], 'KeyWeapon2' + IntToStr(i))
559 end;
560 end;
562 section := 'Player2';
563 with gPlayer2Settings do
564 begin
565 ReadString(Name, 'name');
566 ReadString(Model, 'model');
567 ReadInteger(Color.R, 'red', 0, 255);
568 ReadInteger(Color.G, 'green', 0, 255);
569 ReadInteger(Color.B, 'blue', 0, 255);
570 ReadInteger(Team, 'team');
571 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
572 Team := TEAM_RED;
573 end;
575 section := 'Joysticks';
576 for i := 0 to e_MaxJoys - 1 do
577 begin
578 ReadInteger(e_JoystickDeadzones[i], 'Deadzone' + IntToStr(i))
579 end;
581 section := 'Touch';
582 i := Trunc(g_touch_size * 10); ReadInteger(i, 'Size', 0); g_touch_size := i / 10;
583 ReadBoolean(g_touch_fire, 'Fire');
584 i := Round(g_touch_offset); ReadInteger(i, 'Offset', 0, 100); g_touch_offset := i;
585 ReadBoolean(g_touch_alt, 'Alt');
587 section := 'Game';
588 ReadInteger(i, 'MaxParticles', 1000, 50000); g_GFX_SetMax(i);
589 ReadInteger(i, 'MaxShells', 300, 600); g_Shells_SetMax(i);
590 ReadInteger(i, 'MaxGibs', 150, 500); g_Gibs_SetMax(i);
591 ReadInteger(i, 'MaxCorpses', 20, 100); g_Corpses_SetMax(i);
592 ReadInteger(i, 'GibsCount');
593 case i of
594 0: gGibsCount := 0;
595 1: gGibsCount := 8;
596 2: gGibsCount := 16;
597 3: gGibsCount := 32;
598 else gGibsCount := 48;
599 end;
600 i := ITEM_RESPAWNTIME div 36; ReadInteger(i, 'ItemRespawnTime', 0); ITEM_RESPAWNTIME := i * 36;
601 ReadInteger(gBloodCount, 'BloodCount', 0, 4);
602 ReadBoolean(gAdvBlood, 'AdvancesBlood');
603 ReadBoolean(gAdvCorpses, 'AdvancesCorpses');
604 ReadBoolean(gAdvGibs, 'AdvancesGibs');
605 ReadInteger(gFlash, 'Flash', 0, 2);
606 ReadBoolean(gDrawBackGround, 'BackGround');
607 ReadBoolean(gShowMessages, 'Messages');
608 ReadBoolean(gRevertPlayers, 'RevertPlayers');
609 ReadInteger(gChatBubble, 'ChatBubble', 0, 4);
610 ReadBoolean(gSFSDebug, 'SFSDebug'); wadoptDebug := gSFSDebug;
611 ReadBoolean(gSFSFastMode, 'SFSFastMode'); wadoptFast := gSFSFastMode;
612 ReadBoolean(e_FastScreenshots, 'FastScreenshots');
613 ReadString(gDefaultMegawadStart, 'DefaultMegawadStart');
614 ReadBoolean(gBerserkAutoswitch, 'BerserkAutoswitching');
615 i := Trunc(g_dbg_scale * 100); ReadInteger(i, 'Scale', 100); g_dbg_scale := i / 100;
616 ReadString(gLanguage, 'Language');
617 if (gLanguage = LANGUAGE_RUSSIAN) or (gLanguage = LANGUAGE_ENGLISH) then
618 gAskLanguage := False
619 else
620 gLanguage := LANGUAGE_ENGLISH;
622 section := 'GameplayCustom';
623 ReadString(gcMap, 'Map');
624 ReadString(gcGameMode, 'GameMode');
625 ReadInteger(gcTimeLimit, 'TimeLimit', 0, 65535);
626 ReadInteger(gcGoalLimit, 'GoalLimit', 0, 65535);
627 ReadInteger(gcMaxLives, 'MaxLives', 0, 255);
628 ReadInteger(gcPlayers, 'Players', 0, 2);
629 ReadBoolean(gcTeamDamage, 'TeamDamage');
630 ReadBoolean(gcAllowExit, 'AllowExit');
631 ReadBoolean(gcWeaponStay, 'WeaponStay');
632 ReadBoolean(gcMonsters, 'Monsters');
633 ReadString(gcBotsVS, 'BotsVS');
635 with gGameSettings do
636 begin
637 GameMode := g_Game_TextToMode(gcGameMode);
638 if GameMode = GM_NONE then
639 GameMode := GM_DM;
640 if GameMode = GM_SINGLE then
641 GameMode := GM_COOP;
642 TimeLimit := gcTimeLimit;
643 GoalLimit := gcGoalLimit;
644 MaxLives := gcMaxLives;
646 Options := 0;
647 if gcTeamDamage then
648 Options := Options or GAME_OPTION_TEAMDAMAGE;
649 if gcAllowExit then
650 Options := Options or GAME_OPTION_ALLOWEXIT;
651 if gcWeaponStay then
652 Options := Options or GAME_OPTION_WEAPONSTAY;
653 if gcMonsters then
654 Options := Options or GAME_OPTION_MONSTERS;
655 if gcBotsVS = 'Everybody' then
656 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
657 if gcBotsVS = 'Players' then
658 Options := Options or GAME_OPTION_BOTVSPLAYER;
659 if gcBotsVS = 'Monsters' then
660 Options := Options or GAME_OPTION_BOTVSMONSTER;
661 end;
663 section := 'GameplayNetwork';
664 ReadString(gnMap, 'Map');
665 ReadString(gnGameMode, 'GameMode');
666 ReadInteger(gnTimeLimit, 'TimeLimit', 0, 65535);
667 ReadInteger(gnGoalLimit, 'GoalLimit', 0, 65535);
668 ReadInteger(gnMaxLives, 'MaxLives', 0, 255);
669 ReadInteger(gnPlayers, 'Players', 0, 2);
670 ReadBoolean(gnTeamDamage, 'TeamDamage');
671 ReadBoolean(gnAllowExit, 'AllowExit');
672 ReadBoolean(gnWeaponStay, 'WeaponStay');
673 ReadBoolean(gnMonsters, 'Monsters');
674 ReadString(gnBotsVS, 'BotsVS');
676 section := 'MasterServer';
677 ReadString(NetSlistIP, 'IP');
678 ReadInteger(NetSlistPort, 'Port', 0, 65535);
679 g_Net_Slist_Set(NetSlistIP, NetSlistPort);
681 section := 'Server';
682 ReadString(NetServerName, 'Name');
683 ReadString(NetPassword, 'Password');
684 ReadInteger(NetPort, 'Port', 0, 65535);
685 ReadInteger(NetMaxClients, 'MaxClients', 0, NET_MAXCLIENTS);
686 ReadBoolean(NetAllowRCON, 'RCON');
687 ReadString(NetRCONPassword, 'RCONPassword');
688 ReadBoolean(NetUseMaster, 'SyncWithMaster');
689 ReadInteger(NetUpdateRate, 'UpdateInterval', 0);
690 ReadInteger(NetRelupdRate, 'ReliableUpdateInterval', 0);
691 ReadInteger(NetMasterRate, 'MasterSyncInterval', 1);
692 ReadBoolean(NetForwardPorts, 'ForwardPorts');
694 section := 'Client';
695 ReadInteger(NetInterpLevel, 'InterpolationSteps', 0);
696 ReadBoolean(NetForcePlayerUpdate, 'ForcePlayerUpdate');
697 ReadBoolean(NetPredictSelf, 'PredictSelf');
698 ReadString(NetClientIP, 'LastIP');
699 ReadInteger(NetClientPort, 'LastPort', 0, 65535);
701 config.Free();
703 //if gTextureFilter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
704 end;
706 procedure g_Options_Write(FileName: String);
707 var
708 config: TConfig;
709 i: Integer;
710 begin
711 e_WriteLog('Writing config', TMsgType.Notify);
713 config := TConfig.CreateFile(FileName);
715 config.WriteInt('Video', 'ScreenWidth', gScreenWidth);
716 config.WriteInt('Video', 'ScreenHeight', gScreenHeight);
717 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
718 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
719 config.WriteBool('Video', 'Fullscreen', gFullScreen);
720 config.WriteBool('Video', 'Maximized', gWinMaximized);
721 config.WriteInt('Video', 'BPP', gBPP);
722 config.WriteBool('Video', 'VSync', gVSync);
723 config.WriteBool('Video', 'TextureFilter', gTextureFilter);
724 config.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT);
726 config.WriteBool('Sound', 'NoSound', gNoSound);
727 config.WriteInt('Sound', 'SoundLevel', gSoundLevel);
728 config.WriteInt('Sound', 'MusicLevel', gMusicLevel);
729 config.WriteInt('Sound', 'MaxSimSounds', gMaxSimSounds);
730 config.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive);
731 config.WriteInt('Sound', 'Announcer', gAnnouncer);
732 config.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF);
733 config.WriteBool('Sound', 'ChatSounds', gUseChatSounds);
734 config.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate);
735 config.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize);
737 with config, gGameControls.GameControls do
738 begin
739 WriteInt('GameControls', 'TakeScreenshot', TakeScreenshot);
740 WriteInt('GameControls', 'Stat', Stat);
741 WriteInt('GameControls', 'Chat', Chat);
742 WriteInt('GameControls', 'TeamChat', TeamChat);
743 end;
745 with config, gGameControls.P1Control, gPlayer1Settings do
746 begin
747 WriteInt('Player1', 'KeyRight', KeyRight);
748 WriteInt('Player1', 'KeyLeft', KeyLeft);
749 WriteInt('Player1', 'KeyUp', KeyUp);
750 WriteInt('Player1', 'KeyDown', KeyDown);
751 WriteInt('Player1', 'KeyFire', KeyFire);
752 WriteInt('Player1', 'KeyJump', KeyJump);
753 WriteInt('Player1', 'KeyNextWeapon', KeyNextWeapon);
754 WriteInt('Player1', 'KeyPrevWeapon', KeyPrevWeapon);
755 WriteInt('Player1', 'KeyOpen', KeyOpen);
756 WriteInt('Player1', 'KeyStrafe', KeyStrafe);
757 for i := 0 to High(KeyWeapon) do
758 WriteInt('Player1', 'KeyWeapon' + IntToStr(i), KeyWeapon[i]);
760 WriteInt('Player1', 'KeyRight2', KeyRight2);
761 WriteInt('Player1', 'KeyLeft2', KeyLeft2);
762 WriteInt('Player1', 'KeyUp2', KeyUp2);
763 WriteInt('Player1', 'KeyDown2', KeyDown2);
764 WriteInt('Player1', 'KeyFire2', KeyFire2);
765 WriteInt('Player1', 'KeyJump2', KeyJump2);
766 WriteInt('Player1', 'KeyNextWeapon2', KeyNextWeapon2);
767 WriteInt('Player1', 'KeyPrevWeapon2', KeyPrevWeapon2);
768 WriteInt('Player1', 'KeyOpen2', KeyOpen2);
769 WriteInt('Player1', 'KeyStrafe2', KeyStrafe2);
770 for i := 0 to High(KeyWeapon2) do
771 WriteInt('Player1', 'KeyWeapon2' + IntToStr(i), KeyWeapon2[i]);
773 WriteStr('Player1', 'Name', Name);
774 WriteStr('Player1', 'model', Model);
775 WriteInt('Player1', 'red', Color.R);
776 WriteInt('Player1', 'green', Color.G);
777 WriteInt('Player1', 'blue', Color.B);
778 WriteInt('Player1', 'team', Team);
779 end;
781 with config, gGameControls.P2Control, gPlayer2Settings do
782 begin
783 WriteInt('Player2', 'KeyRight', KeyRight);
784 WriteInt('Player2', 'KeyLeft', KeyLeft);
785 WriteInt('Player2', 'KeyUp', KeyUp);
786 WriteInt('Player2', 'KeyDown', KeyDown);
787 WriteInt('Player2', 'KeyFire', KeyFire);
788 WriteInt('Player2', 'KeyJump', KeyJump);
789 WriteInt('Player2', 'KeyNextWeapon', KeyNextWeapon);
790 WriteInt('Player2', 'KeyPrevWeapon', KeyPrevWeapon);
791 WriteInt('Player2', 'KeyOpen', KeyOpen);
792 WriteInt('Player2', 'KeyStrafe', KeyStrafe);
793 for i := 0 to High(KeyWeapon) do
794 WriteInt('Player2', 'KeyWeapon' + IntToStr(i), KeyWeapon[i]);
796 WriteInt('Player2', 'KeyRight2', KeyRight2);
797 WriteInt('Player2', 'KeyLeft2', KeyLeft2);
798 WriteInt('Player2', 'KeyUp2', KeyUp2);
799 WriteInt('Player2', 'KeyDown2', KeyDown2);
800 WriteInt('Player2', 'KeyFire2', KeyFire2);
801 WriteInt('Player2', 'KeyJump2', KeyJump2);
802 WriteInt('Player2', 'KeyNextWeapon2', KeyNextWeapon2);
803 WriteInt('Player2', 'KeyPrevWeapon2', KeyPrevWeapon2);
804 WriteInt('Player2', 'KeyOpen2', KeyOpen2);
805 WriteInt('Player2', 'KeyStrafe2', KeyStrafe2);
806 for i := 0 to High(KeyWeapon2) do
807 WriteInt('Player2', 'KeyWeapon2' + IntToStr(i), KeyWeapon2[i]);
809 WriteStr('Player2', 'Name', Name);
810 WriteStr('Player2', 'model', Model);
811 WriteInt('Player2', 'red', Color.R);
812 WriteInt('Player2', 'green', Color.G);
813 WriteInt('Player2', 'blue', Color.B);
814 WriteInt('Player2', 'team', Team);
815 end;
817 for i := 0 to e_MaxJoys-1 do
818 config.WriteInt('Joysticks', 'Deadzone' + IntToStr(i), e_JoystickDeadzones[i]);
820 config.WriteInt('Touch', 'Size', Round(g_touch_size * 10));
821 config.WriteBool('Touch', 'Fire', g_touch_fire);
822 config.WriteInt('Touch', 'Offset', Round(g_touch_offset));
823 config.WriteBool('Touch', 'Alt', g_touch_alt);
825 with config do
826 case gGibsCount of
827 0: config.WriteInt('Game', 'GibsCount', 0);
828 8: config.WriteInt('Game', 'GibsCount', 1);
829 16: config.WriteInt('Game', 'GibsCount', 2);
830 32: config.WriteInt('Game', 'GibsCount', 3);
831 else config.WriteInt('Game', 'GibsCount', 4);
832 end;
834 config.WriteInt('Game', 'ItemRespawnTime', ITEM_RESPAWNTIME div 36);
835 config.WriteInt('Game', 'MaxParticles', g_GFX_GetMax());
836 config.WriteInt('Game', 'MaxShells', g_Shells_GetMax());
837 config.WriteInt('Game', 'MaxGibs', g_Gibs_GetMax());
838 config.WriteInt('Game', 'MaxCorpses', g_Corpses_GetMax());
839 config.WriteInt('Game', 'BloodCount', gBloodCount);
840 config.WriteBool('Game', 'AdvancesBlood', gAdvBlood);
841 config.WriteBool('Game', 'AdvancesCorpses', gAdvCorpses);
842 config.WriteBool('Game', 'AdvancesGibs', gAdvGibs);
843 config.WriteInt('Game', 'Flash', gFlash);
844 config.WriteBool('Game', 'BackGround', gDrawBackGround);
845 config.WriteBool('Game', 'Messages', gShowMessages);
846 config.WriteBool('Game', 'RevertPlayers', gRevertPlayers);
847 config.WriteInt('Game', 'ChatBubble', gChatBubble);
848 config.WriteBool('Game', 'SFSDebug', gSFSDebug);
849 config.WriteBool('Game', 'SFSFastMode', gSFSFastMode);
850 config.WriteBool('Game', 'FastScreenshots', e_FastScreenshots);
851 config.WriteStr('Game', 'DefaultMegawadStart', gDefaultMegawadStart);
852 config.WriteBool('Game', 'BerserkAutoswitching', gBerserkAutoswitch);
853 config.WriteInt('Game', 'Scale', Round(g_dbg_scale * 100));
855 config.WriteStr ('GameplayCustom', 'Map', gcMap);
856 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
857 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
858 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
859 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
860 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
861 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
862 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
863 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
864 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
865 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
867 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
868 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
869 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
870 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
871 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
872 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
873 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
874 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
875 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
876 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
877 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
879 config.WriteStr('MasterServer', 'IP', NetSlistIP);
880 config.WriteInt('MasterServer', 'Port', NetSlistPort);
882 config.WriteStr ('Server', 'Name', NetServerName);
883 config.WriteStr ('Server', 'Password', NetPassword);
884 config.WriteInt ('Server', 'Port', NetPort);
885 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
886 config.WriteBool('Server', 'RCON', NetAllowRCON);
887 config.WriteStr ('Server', 'RCONPassword', NetRCONPassword);
888 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
889 config.WriteBool('Server', 'ForwardPorts', NetForwardPorts);
890 config.WriteInt ('Server', 'UpdateInterval', NetUpdateRate);
891 config.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate);
892 config.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate);
894 config.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel);
895 config.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate);
896 config.WriteBool ('Client', 'PredictSelf', NetPredictSelf);
897 config.WriteStr ('Client', 'LastIP', NetClientIP);
898 config.WriteInt ('Client', 'LastPort', NetClientPort);
900 config.SaveFile(FileName);
901 config.Free();
902 end;
904 procedure g_Options_Write_Language(FileName: String);
905 var
906 config: TConfig;
907 begin
908 e_WriteLog('Writing language config', TMsgType.Notify);
910 config := TConfig.CreateFile(FileName);
911 config.WriteStr('Game', 'Language', gLanguage);
912 config.SaveFile(FileName);
913 config.Free();
914 end;
916 procedure g_Options_Write_Video(FileName: String);
917 var
918 config: TConfig;
919 sW, sH: Integer;
920 begin
921 e_WriteLog('Writing resolution to config', TMsgType.Notify);
923 config := TConfig.CreateFile(FileName);
925 if gWinMaximized and (not gFullscreen) then
926 begin
927 sW := gWinSizeX;
928 sH := gWinSizeY;
929 end
930 else
931 begin
932 sW := gScreenWidth;
933 sH := gScreenHeight;
934 end;
935 e_LogWritefln(' (ws=%dx%d) (ss=%dx%d)', [gWinSizeX, gWinSizeY, gScreenWidth, gScreenHeight]);
937 config.WriteInt('Video', 'ScreenWidth', sW);
938 config.WriteInt('Video', 'ScreenHeight', sH);
939 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
940 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
941 config.WriteBool('Video', 'Fullscreen', gFullscreen);
942 config.WriteBool('Video', 'Maximized', gWinMaximized);
944 config.SaveFile(FileName);
945 config.Free();
946 end;
948 procedure g_Options_Write_Gameplay_Custom(FileName: String);
949 var
950 config: TConfig;
951 begin
952 e_WriteLog('Writing custom gameplay config', TMsgType.Notify);
954 config := TConfig.CreateFile(FileName);
956 config.WriteStr ('GameplayCustom', 'Map', gcMap);
957 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
958 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
959 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
960 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
961 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
962 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
963 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
964 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
965 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
966 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
968 config.SaveFile(FileName);
969 config.Free();
970 end;
972 procedure g_Options_Write_Gameplay_Net(FileName: String);
973 var
974 config: TConfig;
975 begin
976 e_WriteLog('Writing network gameplay config', TMsgType.Notify);
978 config := TConfig.CreateFile(FileName);
980 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
981 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
982 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
983 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
984 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
985 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
986 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
987 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
988 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
989 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
990 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
992 config.SaveFile(FileName);
993 config.Free();
994 end;
996 procedure g_Options_Write_Net_Server(FileName: String);
997 var
998 config: TConfig;
999 begin
1000 e_WriteLog('Writing server config', TMsgType.Notify);
1002 config := TConfig.CreateFile(FileName);
1004 config.WriteStr ('Server', 'Name', NetServerName);
1005 config.WriteStr ('Server', 'Password', NetPassword);
1006 config.WriteInt ('Server', 'Port', NetPort);
1007 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
1008 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
1009 config.WriteBool('Server', 'ForwardPorts', NetForwardPorts);
1011 config.SaveFile(FileName);
1012 config.Free();
1013 end;
1015 procedure g_Options_Write_Net_Client(FileName: String);
1016 var
1017 config: TConfig;
1018 begin
1019 e_WriteLog('Writing client config', TMsgType.Notify);
1021 config := TConfig.CreateFile(FileName);
1023 config.WriteStr('Client', 'LastIP', NetClientIP);
1024 config.WriteInt('Client', 'LastPort', NetClientPort);
1026 config.SaveFile(FileName);
1027 config.Free();
1028 end;
1030 end.