DEADSOFTWARE

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