DEADSOFTWARE

key binds and vars are stored in dfconfig.cfg
[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 function GenPlayerName (n: Integer): String;
26 procedure g_Options_SetDefault();
27 procedure g_Options_Read(FileName: String);
28 procedure g_Options_Write(FileName: String);
29 procedure g_Options_Write_Language(FileName: String);
30 procedure g_Options_Write_Video(FileName: String);
31 procedure g_Options_Write_Gameplay_Custom(FileName: String);
32 procedure g_Options_Write_Gameplay_Net(FileName: String);
33 procedure g_Options_Write_Net_Server(FileName: String);
34 procedure g_Options_Write_Net_Client(FileName: String);
36 const DF_Default_Megawad_Start = 'megawads/DOOM2D.WAD:\MAP01';
38 var
39 // gGameControls: TControls;
40 gScreenWidth: Word;
41 gScreenHeight: Word;
42 gWinRealPosX: Integer;
43 gWinRealPosY: Integer;
44 gBPP: Byte;
45 gFreq: Byte;
46 gFullscreen: Boolean;
47 gWinMaximized: Boolean;
48 gVSync: Boolean;
49 glLegacyNPOT: Boolean;
50 gTextureFilter: Boolean;
51 gNoSound: Boolean;
52 gSoundLevel: Byte;
53 gMusicLevel: Byte;
54 gMaxSimSounds: Byte;
55 gMuteWhenInactive: Boolean;
56 gAdvCorpses: Boolean;
57 gAdvBlood: Boolean;
58 gAdvGibs: Boolean;
59 gGibsCount: Integer;
60 gBloodCount: Byte;
61 gFlash: Byte;
62 gDrawBackGround: Boolean;
63 gShowMessages: Boolean;
64 gRevertPlayers: Boolean;
65 gLanguage: String;
66 gAskLanguage: Boolean;
67 gcMap: String;
68 gcGameMode: String;
69 gcTimeLimit: Word;
70 gcGoalLimit: Word;
71 gcMaxLives: Byte;
72 gcPlayers: Byte;
73 gcTeamDamage: Boolean;
74 gcAllowExit: Boolean;
75 gcWeaponStay: Boolean;
76 gcMonsters: Boolean;
77 gcBotsVS: String;
78 gnMap: String;
79 gnGameMode: String;
80 gnTimeLimit: Word;
81 gnGoalLimit: Word;
82 gnMaxLives: Byte;
83 gnPlayers: Byte;
84 gnTeamDamage: Boolean;
85 gnAllowExit: Boolean;
86 gnWeaponStay: Boolean;
87 gnMonsters: Boolean;
88 gnBotsVS: String;
89 gsSDLSampleRate: Integer;
90 gsSDLBufferSize: Integer;
91 gSFSDebug: Boolean;
92 gSFSFastMode: Boolean;
93 gDefaultMegawadStart: AnsiString;
94 gBerserkAutoswitch: Boolean;
96 implementation
98 uses
99 {$INCLUDE ../nogl/noGLuses.inc}
100 e_log, e_input, g_console, g_window, g_sound, g_gfx, g_player, Math,
101 g_map, g_net, g_netmaster, SysUtils, CONFIG, g_game, g_main, e_texture,
102 g_items, wadreader, e_graphics, g_touch, SDL2, envvars;
104 var
105 machine: Integer;
107 function GenPlayerName (n: Integer): String;
108 begin
109 ASSERT(n >= 1);
110 Result := GetUserName;
111 if Result = '' then
112 Result := 'Player' + IntToStr(machine MOD 10000);
113 if n = 1 then
114 Result := Copy(Result, 1, 12) + ' '
115 else
116 Result := Copy(Result, 1, 10) + ' ' + IntToStr(n)
117 end;
119 procedure g_Options_SetDefaultVideo;
120 var
121 target, closest, display: TSDL_DisplayMode;
122 percentage: Integer;
123 begin
124 (* Display 0 = Primary display *)
125 SDL_GetDesktopDisplayMode(0, @display);
126 {$IF DEFINED(ANDROID)}
127 gScreenWidth := display.w;
128 gScreenHeight := display.h;
129 //gBPP := SDL_BITSPERPIXEL(dispaly.format);
130 gBPP := 32;
131 gFullScreen := True; (* rotation not allowed? *)
132 {$ELSE}
133 (* Window must be smaller than display *)
134 closest.w := display.w;
135 closest.h := display.h;
136 percentage := 75;
137 while (display.w - closest.w < 48) or (display.h - closest.h < 48) do
138 begin
139 if percentage < 25 then
140 begin
141 closest.w := display.w * 75 div 100;
142 closest.h := display.h * 75 div 100;
143 break;
144 end;
145 target.w := display.w * percentage div 100;
146 target.h := display.h * percentage div 100;
147 target.format := 0; (* didn't care *)
148 target.refresh_rate := 0; (* didn't care *)
149 target.driverdata := nil; (* init *)
150 SDL_GetClosestDisplayMode(0, @target, @closest);
151 Dec(percentage);
152 end;
153 gScreenWidth := closest.w;
154 gScreenHeight := closest.h;
155 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
156 gBPP := 32;
157 gFullScreen := False;
158 {$ENDIF}
159 (* Must be positioned on primary display *)
160 gWinRealPosX := SDL_WINDOWPOS_CENTERED;
161 gWinRealPosY := SDL_WINDOWPOS_CENTERED;
162 gWinMaximized := False;
163 gVSync := True;
164 gTextureFilter := True;
165 glLegacyNPOT := False;
166 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gScreenWidth) + ' h = ' + IntToStr(gScreenHeight));
167 g_Console_ResetBinds
168 end;
170 procedure g_Options_SetDefault();
171 var
172 i: Integer;
173 begin
174 (* section Sound *)
175 gNoSound := False;
176 gSoundLevel := 75;
177 gMusicLevel := 65;
178 gMaxSimSounds := 8;
179 gMuteWhenInactive := False;
180 gAnnouncer := ANNOUNCE_MEPLUS;
181 gSoundEffectsDF := True;
182 gUseChatSounds := True;
183 gsSDLSampleRate := 44100;
184 gsSDLBufferSize := 2048;
186 g_Sound_SetupAllVolumes(gSoundLevel, gMusicLevel);
188 with gPlayer1Settings do
189 begin
190 Name := GenPlayerName(1);
191 Model := STD_PLAYER_MODEL;
192 Color.R := PLAYER1_DEF_COLOR.R;
193 Color.G := PLAYER1_DEF_COLOR.G;
194 Color.B := PLAYER1_DEF_COLOR.B;
195 Team := TEAM_RED;
196 end;
198 with gPlayer2Settings do
199 begin
200 Name := GenPlayerName(2);
201 Model := STD_PLAYER_MODEL;
202 Color.R := PLAYER2_DEF_COLOR.R;
203 Color.G := PLAYER2_DEF_COLOR.G;
204 Color.B := PLAYER2_DEF_COLOR.B;
205 Team := TEAM_BLUE;
206 end;
208 (* section Joysticks *)
209 for i := 0 to e_MaxJoys - 1 do
210 begin
211 e_JoystickDeadzones[i] := 8192
212 end;
214 (* section Game *)
215 g_GFX_SetMax(2000);
216 g_Shells_SetMax(300);
217 g_Gibs_SetMax(150);
218 g_Corpses_SetMax(20);
219 gGibsCount := 32;
220 ITEM_RESPAWNTIME := 60 * 36;
221 gBloodCount := 4;
222 gAdvBlood := True;
223 gAdvCorpses := True;
224 gAdvGibs := True;
225 gFlash := 1;
226 gDrawBackGround := True;
227 gShowMessages := True;
228 gRevertPlayers := False;
229 gChatBubble := 4;
230 gPlayerIndicator := True;
231 gSFSDebug := False;
232 gSFSFastMode := False;
233 e_FastScreenshots := True;
234 gDefaultMegawadStart := DF_Default_Megawad_Start;
235 gBerserkAutoswitch := True;
236 g_dbg_scale := 1.0;
238 gAskLanguage := True;
239 gLanguage := LANGUAGE_ENGLISH;
241 (* section GameplayCustom *)
242 gcMap := '';
243 gcGameMode := _lc[I_MENU_GAME_TYPE_DM];
244 gcTimeLimit := 0;
245 gcGoalLimit := 0;
246 gcMaxLives := 0;
247 gcPlayers := 1;
248 gcTeamDamage := False;
249 gcAllowExit := True;
250 gcWeaponStay := False;
251 gcMonsters := False;
252 gcBotsVS := 'Everybody';
254 (* section GameplayNetwork *)
255 gnMap := '';
256 gnGameMode := _lc[I_MENU_GAME_TYPE_DM];
257 gnTimeLimit := 0;
258 gnGoalLimit := 0;
259 gnMaxLives := 0;
260 gnPlayers := 1;
261 gnTeamDamage := False;
262 gnAllowExit := True;
263 gnWeaponStay := False;
264 gnMonsters := False;
265 gnBotsVS := 'Everybody';
267 (* section MasterServer *)
268 NetSlistIP := 'mpms.doom2d.org';
269 NetSlistPort := 25665;
270 g_Net_Slist_Set(NetSlistIP, NetSlistPort);
272 (* section Server *)
273 NetServerName := 'Unnamed Server';
274 NetPassword := '';
275 NetPort := 25666;
276 NetMaxClients := 16;
277 NetAllowRCON := False;
278 NetRCONPassword := 'default';
279 NetUseMaster := True;
280 NetUpdateRate := 0;
281 NetRelupdRate := 18;
282 NetMasterRate := 60000;
283 NetForwardPorts := False;
285 (* section Client *)
286 NetInterpLevel := 2;
287 NetForcePlayerUpdate := False;
288 NetPredictSelf := True;
289 NetClientIP := '127.0.0.1';
290 NetClientPort := NetPort;
291 end;
293 procedure g_Options_Read(FileName: String);
294 var
295 i: Integer;
296 config: TConfig;
297 section: String;
299 procedure ReadInteger (VAR v: Integer; param: String; minv: Integer = Low(Integer); maxv: Integer = High(Integer));
300 begin
301 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
302 end;
304 procedure ReadInteger (VAR v: LongWord; param: String; minv: LongWord = Low(LongWord); maxv: LongWord = High(LongWord)); overload;
305 begin
306 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
307 end;
309 procedure ReadInteger (VAR v: Word; param: String; minv: Word = Low(Word); maxv: Word = High(Word)); overload;
310 begin
311 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
312 end;
314 procedure ReadInteger (VAR v: Byte; param: String; minv: Byte = Low(Byte); maxv: Byte = High(Byte)); overload;
315 begin
316 v := Max(Min(config.ReadInt(section, param, v), maxv), minv)
317 end;
319 procedure ReadBoolean (VAR v: Boolean; param: String);
320 begin
321 v := config.ReadBool(section, param, v)
322 end;
324 procedure ReadString (VAR v: String; param: String);
325 begin
326 v := config.ReadStr(section, param, v)
327 end;
329 begin
330 gAskLanguage := True;
331 e_WriteLog('Reading config', TMsgType.Notify);
332 g_Options_SetDefault;
334 if FileExists(FileName) = False then
335 begin
336 e_WriteLog('Config file '+FileName+' not found', TMsgType.Warning);
337 g_Options_SetDefaultVideo;
338 Exit
339 end;
341 config := TConfig.CreateFile(FileName);
343 section := 'Video';
344 ReadInteger(gScreenWidth, 'ScreenWidth', 0);
345 ReadInteger(gScreenHeight, 'ScreenHeight', 0);
346 ReadInteger(gWinRealPosX, 'WinPosX', 60);
347 ReadInteger(gWinRealPosY, 'WinPosY', 60);
348 ReadBoolean(gFullScreen, 'Fullscreen');
349 ReadBoolean(gWinMaximized, 'Maximized');
350 ReadInteger(gBPP, 'BPP', 0);
351 ReadInteger(gFreq, 'Freq', 0);
352 ReadBoolean(gVSync, 'VSync');
353 ReadBoolean(gTextureFilter, 'TextureFilter');
354 ReadBoolean(glLegacyNPOT, 'LegacyCompatible');
356 section := 'Sound';
357 ReadBoolean(gNoSound, 'NoSound');
358 ReadInteger(gSoundLevel, 'SoundLevel', 0, 255);
359 ReadInteger(gMusicLevel, 'MusicLevel', 0, 255);
360 ReadInteger(gMaxSimSounds, 'MaxSimSounds', 2, 66);
361 ReadBoolean(gMuteWhenInactive, 'MuteInactive');
362 ReadInteger(gAnnouncer, 'Announcer', ANNOUNCE_NONE, ANNOUNCE_ALL);
363 ReadBoolean(gSoundEffectsDF, 'SoundEffectsDF');
364 ReadBoolean(gUseChatSounds, 'ChatSounds');
365 ReadInteger(gsSDLSampleRate, 'SDLSampleRate', 11025, 96000);
366 ReadInteger(gsSDLBufferSize, 'SDLBufferSize', 64, 16384);
368 section := 'Player1';
369 with gPlayer1Settings do
370 begin
371 ReadString(Name, 'name');
372 ReadString(Model, 'model');
373 ReadInteger(Color.R, 'red', 0, 255);
374 ReadInteger(Color.G, 'green', 0, 255);
375 ReadInteger(Color.B, 'blue', 0, 255);
376 ReadInteger(Team, 'team');
377 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
378 Team := TEAM_RED;
379 end;
381 section := 'Player2';
382 with gPlayer2Settings do
383 begin
384 ReadString(Name, 'name');
385 ReadString(Model, 'model');
386 ReadInteger(Color.R, 'red', 0, 255);
387 ReadInteger(Color.G, 'green', 0, 255);
388 ReadInteger(Color.B, 'blue', 0, 255);
389 ReadInteger(Team, 'team');
390 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
391 Team := TEAM_RED;
392 end;
394 section := 'Joysticks';
395 for i := 0 to e_MaxJoys - 1 do
396 begin
397 ReadInteger(e_JoystickDeadzones[i], 'Deadzone' + IntToStr(i))
398 end;
400 section := 'Game';
401 ReadInteger(i, 'MaxParticles', 0, 50000); g_GFX_SetMax(i);
402 ReadInteger(i, 'MaxShells', 0, 600); g_Shells_SetMax(i);
403 ReadInteger(i, 'MaxGibs', 0, 500); g_Gibs_SetMax(i);
404 ReadInteger(i, 'MaxCorpses', 0, 100); g_Corpses_SetMax(i);
405 ReadInteger(i, 'GibsCount');
406 case i of
407 0: gGibsCount := 0;
408 1: gGibsCount := 8;
409 2: gGibsCount := 16;
410 3: gGibsCount := 32;
411 else gGibsCount := 48;
412 end;
413 i := ITEM_RESPAWNTIME div 36; ReadInteger(i, 'ItemRespawnTime', 0); ITEM_RESPAWNTIME := i * 36;
414 ReadInteger(gBloodCount, 'BloodCount', 0, 4);
415 ReadBoolean(gAdvBlood, 'AdvancesBlood');
416 ReadBoolean(gAdvCorpses, 'AdvancesCorpses');
417 ReadBoolean(gAdvGibs, 'AdvancesGibs');
418 ReadInteger(gFlash, 'Flash', 0, 2);
419 ReadBoolean(gDrawBackGround, 'BackGround');
420 ReadBoolean(gShowMessages, 'Messages');
421 ReadBoolean(gRevertPlayers, 'RevertPlayers');
422 ReadInteger(gChatBubble, 'ChatBubble', 0, 4);
423 ReadBoolean(gPlayerIndicator, 'PlayerIndicator');
424 ReadBoolean(gSFSDebug, 'SFSDebug'); wadoptDebug := gSFSDebug;
425 ReadBoolean(gSFSFastMode, 'SFSFastMode'); wadoptFast := gSFSFastMode;
426 ReadBoolean(e_FastScreenshots, 'FastScreenshots');
427 ReadString(gDefaultMegawadStart, 'DefaultMegawadStart');
428 ReadBoolean(gBerserkAutoswitch, 'BerserkAutoswitching');
429 i := Trunc(g_dbg_scale * 100); ReadInteger(i, 'Scale', 100); g_dbg_scale := i / 100;
430 ReadString(gLanguage, 'Language');
431 if (gLanguage = LANGUAGE_RUSSIAN) or (gLanguage = LANGUAGE_ENGLISH) then
432 gAskLanguage := False
433 else
434 gLanguage := LANGUAGE_ENGLISH;
436 section := 'GameplayCustom';
437 ReadString(gcMap, 'Map');
438 ReadString(gcGameMode, 'GameMode');
439 ReadInteger(gcTimeLimit, 'TimeLimit', 0, 65535);
440 ReadInteger(gcGoalLimit, 'GoalLimit', 0, 65535);
441 ReadInteger(gcMaxLives, 'MaxLives', 0, 255);
442 ReadInteger(gcPlayers, 'Players', 0, 2);
443 ReadBoolean(gcTeamDamage, 'TeamDamage');
444 ReadBoolean(gcAllowExit, 'AllowExit');
445 ReadBoolean(gcWeaponStay, 'WeaponStay');
446 ReadBoolean(gcMonsters, 'Monsters');
447 ReadString(gcBotsVS, 'BotsVS');
449 with gGameSettings do
450 begin
451 GameMode := g_Game_TextToMode(gcGameMode);
452 if GameMode = GM_NONE then
453 GameMode := GM_DM;
454 if GameMode = GM_SINGLE then
455 GameMode := GM_COOP;
456 TimeLimit := gcTimeLimit;
457 GoalLimit := gcGoalLimit;
458 MaxLives := gcMaxLives;
460 Options := 0;
461 if gcTeamDamage then
462 Options := Options or GAME_OPTION_TEAMDAMAGE;
463 if gcAllowExit then
464 Options := Options or GAME_OPTION_ALLOWEXIT;
465 if gcWeaponStay then
466 Options := Options or GAME_OPTION_WEAPONSTAY;
467 if gcMonsters then
468 Options := Options or GAME_OPTION_MONSTERS;
469 if gcBotsVS = 'Everybody' then
470 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
471 if gcBotsVS = 'Players' then
472 Options := Options or GAME_OPTION_BOTVSPLAYER;
473 if gcBotsVS = 'Monsters' then
474 Options := Options or GAME_OPTION_BOTVSMONSTER;
475 end;
477 section := 'GameplayNetwork';
478 ReadString(gnMap, 'Map');
479 ReadString(gnGameMode, 'GameMode');
480 ReadInteger(gnTimeLimit, 'TimeLimit', 0, 65535);
481 ReadInteger(gnGoalLimit, 'GoalLimit', 0, 65535);
482 ReadInteger(gnMaxLives, 'MaxLives', 0, 255);
483 ReadInteger(gnPlayers, 'Players', 0, 2);
484 ReadBoolean(gnTeamDamage, 'TeamDamage');
485 ReadBoolean(gnAllowExit, 'AllowExit');
486 ReadBoolean(gnWeaponStay, 'WeaponStay');
487 ReadBoolean(gnMonsters, 'Monsters');
488 ReadString(gnBotsVS, 'BotsVS');
490 section := 'MasterServer';
491 ReadString(NetSlistIP, 'IP');
492 ReadInteger(NetSlistPort, 'Port', 0, 65535);
493 g_Net_Slist_Set(NetSlistIP, NetSlistPort);
495 section := 'Server';
496 ReadString(NetServerName, 'Name');
497 ReadString(NetPassword, 'Password');
498 ReadInteger(NetPort, 'Port', 0, 65535);
499 ReadInteger(NetMaxClients, 'MaxClients', 0, NET_MAXCLIENTS);
500 ReadBoolean(NetAllowRCON, 'RCON');
501 ReadString(NetRCONPassword, 'RCONPassword');
502 ReadBoolean(NetUseMaster, 'SyncWithMaster');
503 ReadInteger(NetUpdateRate, 'UpdateInterval', 0);
504 ReadInteger(NetRelupdRate, 'ReliableUpdateInterval', 0);
505 ReadInteger(NetMasterRate, 'MasterSyncInterval', 1);
506 ReadBoolean(NetForwardPorts, 'ForwardPorts');
508 section := 'Client';
509 ReadInteger(NetInterpLevel, 'InterpolationSteps', 0);
510 ReadBoolean(NetForcePlayerUpdate, 'ForcePlayerUpdate');
511 ReadBoolean(NetPredictSelf, 'PredictSelf');
512 ReadString(NetClientIP, 'LastIP');
513 ReadInteger(NetClientPort, 'LastPort', 0, 65535);
515 config.Free();
517 //if gTextureFilter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
518 end;
520 procedure g_Options_Write(FileName: String);
521 var
522 config: TConfig;
523 i: Integer;
524 begin
525 e_WriteLog('Writing config', TMsgType.Notify);
527 config := TConfig.CreateFile(FileName);
529 config.WriteInt('Video', 'ScreenWidth', gScreenWidth);
530 config.WriteInt('Video', 'ScreenHeight', gScreenHeight);
531 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
532 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
533 config.WriteBool('Video', 'Fullscreen', gFullScreen);
534 config.WriteBool('Video', 'Maximized', gWinMaximized);
535 config.WriteInt('Video', 'BPP', gBPP);
536 config.WriteBool('Video', 'VSync', gVSync);
537 config.WriteBool('Video', 'TextureFilter', gTextureFilter);
538 config.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT);
540 config.WriteBool('Sound', 'NoSound', gNoSound);
541 config.WriteInt('Sound', 'SoundLevel', gSoundLevel);
542 config.WriteInt('Sound', 'MusicLevel', gMusicLevel);
543 config.WriteInt('Sound', 'MaxSimSounds', gMaxSimSounds);
544 config.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive);
545 config.WriteInt('Sound', 'Announcer', gAnnouncer);
546 config.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF);
547 config.WriteBool('Sound', 'ChatSounds', gUseChatSounds);
548 config.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate);
549 config.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize);
551 with config, gPlayer1Settings do
552 begin
553 WriteStr('Player1', 'Name', Name);
554 WriteStr('Player1', 'model', Model);
555 WriteInt('Player1', 'red', Color.R);
556 WriteInt('Player1', 'green', Color.G);
557 WriteInt('Player1', 'blue', Color.B);
558 WriteInt('Player1', 'team', Team);
559 end;
561 with config, gPlayer2Settings do
562 begin
563 WriteStr('Player2', 'Name', Name);
564 WriteStr('Player2', 'model', Model);
565 WriteInt('Player2', 'red', Color.R);
566 WriteInt('Player2', 'green', Color.G);
567 WriteInt('Player2', 'blue', Color.B);
568 WriteInt('Player2', 'team', Team);
569 end;
571 for i := 0 to e_MaxJoys-1 do
572 config.WriteInt('Joysticks', 'Deadzone' + IntToStr(i), e_JoystickDeadzones[i]);
574 with config do
575 case gGibsCount of
576 0: config.WriteInt('Game', 'GibsCount', 0);
577 8: config.WriteInt('Game', 'GibsCount', 1);
578 16: config.WriteInt('Game', 'GibsCount', 2);
579 32: config.WriteInt('Game', 'GibsCount', 3);
580 else config.WriteInt('Game', 'GibsCount', 4);
581 end;
583 config.WriteInt('Game', 'ItemRespawnTime', ITEM_RESPAWNTIME div 36);
584 config.WriteInt('Game', 'MaxParticles', g_GFX_GetMax());
585 config.WriteInt('Game', 'MaxShells', g_Shells_GetMax());
586 config.WriteInt('Game', 'MaxGibs', g_Gibs_GetMax());
587 config.WriteInt('Game', 'MaxCorpses', g_Corpses_GetMax());
588 config.WriteInt('Game', 'BloodCount', gBloodCount);
589 config.WriteBool('Game', 'AdvancesBlood', gAdvBlood);
590 config.WriteBool('Game', 'AdvancesCorpses', gAdvCorpses);
591 config.WriteBool('Game', 'AdvancesGibs', gAdvGibs);
592 config.WriteInt('Game', 'Flash', gFlash);
593 config.WriteBool('Game', 'BackGround', gDrawBackGround);
594 config.WriteBool('Game', 'Messages', gShowMessages);
595 config.WriteBool('Game', 'RevertPlayers', gRevertPlayers);
596 config.WriteInt('Game', 'ChatBubble', gChatBubble);
597 config.WriteBool('Game', 'PlayerIndicator', gPlayerIndicator);
598 config.WriteBool('Game', 'SFSDebug', gSFSDebug);
599 config.WriteBool('Game', 'SFSFastMode', gSFSFastMode);
600 config.WriteBool('Game', 'FastScreenshots', e_FastScreenshots);
601 config.WriteStr('Game', 'DefaultMegawadStart', gDefaultMegawadStart);
602 config.WriteBool('Game', 'BerserkAutoswitching', gBerserkAutoswitch);
603 config.WriteInt('Game', 'Scale', Round(g_dbg_scale * 100));
605 config.WriteStr ('GameplayCustom', 'Map', gcMap);
606 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
607 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
608 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
609 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
610 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
611 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
612 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
613 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
614 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
615 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
617 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
618 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
619 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
620 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
621 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
622 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
623 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
624 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
625 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
626 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
627 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
629 config.WriteStr('MasterServer', 'IP', NetSlistIP);
630 config.WriteInt('MasterServer', 'Port', NetSlistPort);
632 config.WriteStr ('Server', 'Name', NetServerName);
633 config.WriteStr ('Server', 'Password', NetPassword);
634 config.WriteInt ('Server', 'Port', NetPort);
635 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
636 config.WriteBool('Server', 'RCON', NetAllowRCON);
637 config.WriteStr ('Server', 'RCONPassword', NetRCONPassword);
638 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
639 config.WriteBool('Server', 'ForwardPorts', NetForwardPorts);
640 config.WriteInt ('Server', 'UpdateInterval', NetUpdateRate);
641 config.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate);
642 config.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate);
644 config.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel);
645 config.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate);
646 config.WriteBool ('Client', 'PredictSelf', NetPredictSelf);
647 config.WriteStr ('Client', 'LastIP', NetClientIP);
648 config.WriteInt ('Client', 'LastPort', NetClientPort);
650 config.SaveFile(FileName);
651 config.Free();
652 end;
654 procedure g_Options_Write_Language(FileName: String);
655 var
656 config: TConfig;
657 begin
658 e_WriteLog('Writing language config', TMsgType.Notify);
660 config := TConfig.CreateFile(FileName);
661 config.WriteStr('Game', 'Language', gLanguage);
662 config.SaveFile(FileName);
663 config.Free();
664 end;
666 procedure g_Options_Write_Video(FileName: String);
667 var
668 config: TConfig;
669 sW, sH: Integer;
670 begin
671 e_WriteLog('Writing resolution to config', TMsgType.Notify);
673 config := TConfig.CreateFile(FileName);
675 if gWinMaximized and (not gFullscreen) then
676 begin
677 sW := gWinSizeX;
678 sH := gWinSizeY;
679 end
680 else
681 begin
682 sW := gScreenWidth;
683 sH := gScreenHeight;
684 end;
685 e_LogWritefln(' (ws=%dx%d) (ss=%dx%d)', [gWinSizeX, gWinSizeY, gScreenWidth, gScreenHeight]);
687 config.WriteInt('Video', 'ScreenWidth', sW);
688 config.WriteInt('Video', 'ScreenHeight', sH);
689 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
690 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
691 config.WriteBool('Video', 'Fullscreen', gFullscreen);
692 config.WriteBool('Video', 'Maximized', gWinMaximized);
694 config.WriteStr('Player1', 'Name', gPlayer1Settings.Name);
695 config.WriteStr('Player2', 'Name', gPlayer2Settings.Name);
697 config.SaveFile(FileName);
698 config.Free();
699 end;
701 procedure g_Options_Write_Gameplay_Custom(FileName: String);
702 var
703 config: TConfig;
704 begin
705 e_WriteLog('Writing custom gameplay config', TMsgType.Notify);
707 config := TConfig.CreateFile(FileName);
709 config.WriteStr ('GameplayCustom', 'Map', gcMap);
710 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
711 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
712 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
713 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
714 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
715 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
716 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
717 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
718 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
719 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
721 config.SaveFile(FileName);
722 config.Free();
723 end;
725 procedure g_Options_Write_Gameplay_Net(FileName: String);
726 var
727 config: TConfig;
728 begin
729 e_WriteLog('Writing network gameplay config', TMsgType.Notify);
731 config := TConfig.CreateFile(FileName);
733 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
734 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
735 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
736 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
737 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
738 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
739 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
740 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
741 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
742 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
743 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
745 config.SaveFile(FileName);
746 config.Free();
747 end;
749 procedure g_Options_Write_Net_Server(FileName: String);
750 var
751 config: TConfig;
752 begin
753 e_WriteLog('Writing server config', TMsgType.Notify);
755 config := TConfig.CreateFile(FileName);
757 config.WriteStr ('Server', 'Name', NetServerName);
758 config.WriteStr ('Server', 'Password', NetPassword);
759 config.WriteInt ('Server', 'Port', NetPort);
760 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
761 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
762 config.WriteBool('Server', 'ForwardPorts', NetForwardPorts);
764 config.SaveFile(FileName);
765 config.Free();
766 end;
768 procedure g_Options_Write_Net_Client(FileName: String);
769 var
770 config: TConfig;
771 begin
772 e_WriteLog('Writing client config', TMsgType.Notify);
774 config := TConfig.CreateFile(FileName);
776 config.WriteStr('Client', 'LastIP', NetClientIP);
777 config.WriteInt('Client', 'LastPort', NetClientPort);
779 config.SaveFile(FileName);
780 config.Free();
781 end;
783 initialization
784 Randomize;
785 machine := Random(10000)
786 end.