DEADSOFTWARE

fd68a7af5a2bf4996b5036de065ef597bedff1fc
[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 {$MODE DELPHI}
17 unit g_options;
19 interface
21 uses
22 g_language;
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 end;
37 TGameControls = record
38 TakeScreenshot: Word;
39 Stat: Word;
40 Chat: Word;
41 TeamChat: Word;
42 end;
44 TControls = record
45 GameControls: TGameControls;
46 P1Control: TPlayerControl;
47 P2Control: TPlayerControl;
48 end;
50 procedure g_Options_SetDefault();
51 procedure g_Options_Read(FileName: String);
52 procedure g_Options_Write(FileName: String);
53 procedure g_Options_Write_Language(FileName: String);
54 procedure g_Options_Write_Video(FileName: String);
55 procedure g_Options_Write_Gameplay_Custom(FileName: String);
56 procedure g_Options_Write_Gameplay_Net(FileName: String);
57 procedure g_Options_Write_Net_Server(FileName: String);
58 procedure g_Options_Write_Net_Client(FileName: String);
60 var
61 gGameControls: TControls;
62 gScreenWidth: Word = 800;
63 gScreenHeight: Word = 600;
64 gWinRealPosX: Integer = 0;
65 gWinRealPosY: Integer = 0;
66 gBPP: Byte = 32;
67 gFreq: Byte = 0;
68 gFullscreen: Boolean = False;
69 gWinMaximized: Boolean = False;
70 gVSync: Boolean = False;
71 glLegacyNPOT: Boolean = False;
72 gTextureFilter: Boolean = True;
73 gNoSound: Boolean = False;
74 gSoundLevel: Byte = 75;
75 gMusicLevel: Byte = 65;
76 gMaxSimSounds: Byte = 8;
77 gMuteWhenInactive: Boolean = False;
78 gAdvCorpses: Boolean = True;
79 gAdvBlood: Boolean = True;
80 gAdvGibs: Boolean = True;
81 gGibsCount: Integer = 32;
82 gBloodCount: Byte = 3;
83 gFlash: Byte = 1;
84 gDrawBackGround: Boolean = True;
85 gShowMessages: Boolean = True;
86 gRevertPlayers: Boolean = False;
87 gLanguage: String = LANGUAGE_ENGLISH;
88 gAskLanguage: Boolean = True;
89 gcMap: String = '';
90 gcGameMode: String = '';
91 gcTimeLimit: Word = 0;
92 gcGoalLimit: Word = 0;
93 gcMaxLives: Byte = 0;
94 gcPlayers: Byte = 1;
95 gcTeamDamage: Boolean = False;
96 gcAllowExit: Boolean = True;
97 gcWeaponStay: Boolean = False;
98 gcMonsters: Boolean = False;
99 gcBotsVS: String = 'Everybody';
100 gnMap: String = '';
101 gnGameMode: String = '';
102 gnTimeLimit: Word = 0;
103 gnGoalLimit: Word = 0;
104 gnMaxLives: Byte = 0;
105 gnPlayers: Byte = 1;
106 gnTeamDamage: Boolean = False;
107 gnAllowExit: Boolean = True;
108 gnWeaponStay: Boolean = False;
109 gnMonsters: Boolean = False;
110 gnBotsVS: String = 'Everybody';
111 gsSDLSampleRate: Integer = 44100;
112 gsSDLBufferSize: Integer = 2048;
113 gSFSDebug: Boolean = False;
114 gSFSFastMode: Boolean = False;
116 implementation
118 uses
119 e_log, e_input, g_window, g_sound, g_gfx, g_player, Math,
120 g_map, g_net, g_netmaster, SysUtils, CONFIG, g_game, g_main, e_textures,
121 g_items, GL, GLExt, wadreader, e_graphics;
123 procedure g_Options_SetDefault();
124 var
125 i: Integer;
126 begin
127 g_Sound_SetupAllVolumes(75, 65);
128 gMaxSimSounds := 8;
129 gMuteWhenInactive := False;
130 gAnnouncer := ANNOUNCE_MEPLUS;
131 gSoundEffectsDF := True;
132 g_GFX_SetMax(2000);
133 g_Gibs_SetMax(150);
134 g_Corpses_SetMax(20);
135 g_Shells_SetMax(300);
136 gGibsCount := 32;
137 gBloodCount := 3;
138 gAdvBlood := True;
139 gAdvCorpses := True;
140 gAdvGibs := True;
141 gFlash := 1;
142 gDrawBackGround := True;
143 gShowMessages := True;
144 gRevertPlayers := False;
146 for i := 0 to e_MaxJoys-1 do
147 e_JoystickDeadzones[i] := 8192;
149 with gGameControls.GameControls do
150 begin
151 TakeScreenshot := 183;
152 Stat := 15;
153 Chat := 20; // [T]
154 TeamChat := 21; // [Y]
155 end;
157 with gGameControls.P1Control do
158 begin
159 KeyRight := 77;
160 KeyLeft := 75;
161 KeyUp := 72;
162 KeyDown := 76;
163 KeyFire := 184;
164 KeyJump := 157;
165 KeyNextWeapon := 73;
166 KeyPrevWeapon := 71;
167 KeyOpen := 54;
168 end;
170 with gGameControls.P2Control do
171 begin
172 KeyRight := 33;
173 KeyLeft := 31;
174 KeyUp := 18;
175 KeyDown := 32;
176 KeyFire := 30;
177 KeyJump := 16;
178 KeyNextWeapon := 19;
179 KeyPrevWeapon := 17;
180 KeyOpen := 58;
181 end;
183 with gPlayer1Settings do
184 begin
185 Name := 'Player1';
186 Model := STD_PLAYER_MODEL;
187 Color.R := PLAYER1_DEF_COLOR.R;
188 Color.G := PLAYER1_DEF_COLOR.G;
189 Color.B := PLAYER1_DEF_COLOR.B;
190 Team := TEAM_RED;
191 end;
193 with gPlayer2Settings do
194 begin
195 Name := 'Player2';
196 Model := STD_PLAYER_MODEL;
197 Color.R := PLAYER2_DEF_COLOR.R;
198 Color.G := PLAYER2_DEF_COLOR.G;
199 Color.B := PLAYER2_DEF_COLOR.B;
200 Team := TEAM_BLUE;
201 end;
203 NetUseMaster := True;
204 g_Net_Slist_Set('mpms.doom2d.org', 25665);
205 end;
207 procedure g_Options_Read(FileName: String);
208 var
209 config: TConfig;
210 str: String;
211 i: Integer;
212 begin
213 gAskLanguage := True;
214 e_WriteLog('Reading config', MSG_NOTIFY);
216 if not FileExists(FileName) then
217 begin
218 e_WriteLog('Config file '+FileName+' not found', MSG_WARNING);
219 g_Options_SetDefault();
221 // Default video options:
222 gScreenWidth := 800;
223 gScreenHeight := 600;
224 gWinRealPosX := 0;
225 gWinRealPosY := 0;
226 gWinMaximized := False;
227 gFullScreen := False;
228 gBPP := 32;
229 gVSync := False;
230 gTextureFilter := True;
231 glLegacyNPOT := False;
233 Exit;
234 end;
236 config := TConfig.CreateFile(FileName);
238 gScreenWidth := config.ReadInt('Video', 'ScreenWidth', 800);
239 if gScreenWidth < 640 then
240 gScreenWidth := 640;
241 gScreenHeight := config.ReadInt('Video', 'ScreenHeight', 600);
242 if gScreenHeight < 480 then
243 gScreenHeight := 480;
244 gWinRealPosX := config.ReadInt('Video', 'WinPosX', 0);
245 if gWinRealPosX < 0 then
246 gWinRealPosX := 0;
247 gWinRealPosY := config.ReadInt('Video', 'WinPosY', 0);
248 if gWinRealPosY < 0 then
249 gWinRealPosY := 0;
250 gFullScreen := config.ReadBool('Video', 'Fullscreen', False);
251 gWinMaximized := config.ReadBool('Video', 'Maximized', False);
252 gBPP := config.ReadInt('Video', 'BPP', 32);
253 gFreq := config.ReadInt('Video', 'Freq', 0);
254 gVSync := config.ReadBool('Video', 'VSync', True);
255 gTextureFilter := config.ReadBool('Video', 'TextureFilter', True);
256 glLegacyNPOT := config.ReadBool('Video', 'LegacyCompatible', False);
258 gNoSound := config.ReadBool('Sound', 'NoSound', False);
259 gSoundLevel := Min(config.ReadInt('Sound', 'SoundLevel', 75), 255);
260 gMusicLevel := Min(config.ReadInt('Sound', 'MusicLevel', 65), 255);
261 gMaxSimSounds := Max(Min(config.ReadInt('Sound', 'MaxSimSounds', 8), 66), 2);
262 gMuteWhenInactive := config.ReadBool('Sound', 'MuteInactive', False);
263 gAnnouncer := Min(Max(config.ReadInt('Sound', 'Announcer', ANNOUNCE_MEPLUS), ANNOUNCE_NONE), ANNOUNCE_ALL);
264 gSoundEffectsDF := config.ReadBool('Sound', 'SoundEffectsDF', True);
265 gsSDLSampleRate := Min(Max(config.ReadInt('Sound', 'SDLSampleRate', 44100), 11025), 96000);
266 gsSDLBufferSize := Min(Max(config.ReadInt('Sound', 'SDLBufferSize', 2048), 64), 16384);
268 with gGameControls.GameControls do
269 begin
270 TakeScreenshot := config.ReadInt('GameControls', 'TakeScreenshot', 183);
271 Stat := config.ReadInt('GameControls', 'Stat', 15);
272 Chat := config.ReadInt('GameControls', 'Chat', 20);
273 TeamChat := config.ReadInt('GameControls', 'TeamChat', 21);
274 end;
276 with gGameControls.P1Control, config do
277 begin
278 KeyRight := ReadInt('Player1', 'KeyRight', 33);
279 KeyLeft := ReadInt('Player1', 'KeyLeft', 31);
280 KeyUp := ReadInt('Player1', 'KeyUp', 18);
281 KeyDown := ReadInt('Player1', 'KeyDown', 32);
282 KeyFire := ReadInt('Player1', 'KeyFire', 30);
283 KeyJump := ReadInt('Player1', 'KeyJump', 16);
284 KeyNextWeapon := ReadInt('Player1', 'KeyNextWeapon', 19);
285 KeyPrevWeapon := ReadInt('Player1', 'KeyPrevWeapon', 17);
286 KeyOpen := ReadInt('Player1', 'KeyOpen', 58);
287 end;
289 with gPlayer1Settings, config do
290 begin
291 Name := ReadStr('Player1', 'name', 'Player1');
292 Model := ReadStr('Player1', 'model', STD_PLAYER_MODEL);
293 Color.R := Min(Abs(ReadInt('Player1', 'red', PLAYER1_DEF_COLOR.R)), 255);
294 Color.G := Min(Abs(ReadInt('Player1', 'green', PLAYER1_DEF_COLOR.G)), 255);
295 Color.B := Min(Abs(ReadInt('Player1', 'blue', PLAYER1_DEF_COLOR.B)), 255);
296 Team := ReadInt('Player1', 'team', TEAM_RED);
297 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
298 Team := TEAM_RED;
299 end;
301 with gGameControls.P2Control, config do
302 begin
303 KeyRight := ReadInt('Player2', 'KeyRight', 205);
304 KeyLeft := ReadInt('Player2', 'KeyLeft', 203);
305 KeyUp := ReadInt('Player2', 'KeyUp', 200);
306 KeyDown := ReadInt('Player2', 'KeyDown', 208);
307 KeyFire := ReadInt('Player2', 'KeyFire', 184);
308 KeyJump := ReadInt('Player2', 'KeyJump', 157);
309 KeyNextWeapon := ReadInt('Player2', 'KeyNextWeapon', 73);
310 KeyPrevWeapon := ReadInt('Player2', 'KeyPrevWeapon', 71);
311 KeyOpen := ReadInt('Player2', 'KeyOpen', 54);
312 end;
314 with gPlayer2Settings, config do
315 begin
316 Name := ReadStr('Player2', 'name', 'Player2');
317 Model := ReadStr('Player2', 'model', STD_PLAYER_MODEL);
318 Color.R := Min(Abs(ReadInt('Player2', 'red', PLAYER2_DEF_COLOR.R)), 255);
319 Color.G := Min(Abs(ReadInt('Player2', 'green', PLAYER2_DEF_COLOR.G)), 255);
320 Color.B := Min(Abs(ReadInt('Player2', 'blue', PLAYER2_DEF_COLOR.B)), 255);
321 Team := ReadInt('Player2', 'team', TEAM_BLUE);
322 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
323 Team := TEAM_RED;
324 end;
326 for i := 0 to e_MaxJoys-1 do
327 e_JoystickDeadzones[i] := config.ReadInt('Joysticks', 'Deadzone' + IntToStr(i), 8192);
329 g_GFX_SetMax(Min(config.ReadInt('Game', 'MaxParticles', 1000), 50000));
330 g_Shells_SetMax(Min(config.ReadInt('Game', 'MaxShells', 300), 600));
331 g_Gibs_SetMax(Min(config.ReadInt('Game', 'MaxGibs', 150), 500));
332 g_Corpses_SetMax(Min(config.ReadInt('Game', 'MaxCorpses', 20), 100));
334 case config.ReadInt('Game', 'GibsCount', 3) of
335 0: gGibsCount := 0;
336 1: gGibsCount := 8;
337 2: gGibsCount := 16;
338 3: gGibsCount := 32;
339 else gGibsCount := 48;
340 end;
342 ITEM_RESPAWNTIME := 36*Max(config.ReadInt('Game', 'ItemRespawnTime', 60), 0);
343 gBloodCount := Min(config.ReadInt('Game', 'BloodCount', 4), 4);
344 gAdvBlood := config.ReadBool('Game', 'AdvancesBlood', True);
345 gAdvCorpses := config.ReadBool('Game', 'AdvancesCorpses', True);
346 gAdvGibs := config.ReadBool('Game', 'AdvancesGibs', True);
347 gFlash := Min(Max(config.ReadInt('Game', 'Flash', 1), 0), 2);
348 gDrawBackGround := config.ReadBool('Game', 'BackGround', True);
349 gShowMessages := config.ReadBool('Game', 'Messages', True);
350 gRevertPlayers := config.ReadBool('Game', 'RevertPlayers', False);
351 gChatBubble := Min(Max(config.ReadInt('Game', 'ChatBubble', 4), 0), 4);
352 gSFSDebug := config.ReadBool('Game', 'SFSDebug', False);
353 wadoptDebug := gSFSDebug;
354 gSFSFastMode := config.ReadBool('Game', 'SFSFastMode', False);
355 wadoptFast := gSFSFastMode;
356 e_FastScreenshots := config.ReadBool('Game', 'FastScreenshots', True);
358 // Ãåéìïëåé â ñâîåé èãðå
359 gcMap := config.ReadStr('GameplayCustom', 'Map', '');
360 gcGameMode := config.ReadStr('GameplayCustom', 'GameMode', _lc[I_MENU_GAME_TYPE_DM]);
361 gcTimeLimit := Min(Max(config.ReadInt('GameplayCustom', 'TimeLimit', 0), 0), 65535);
362 gcGoalLimit := Min(Max(config.ReadInt('GameplayCustom', 'GoalLimit', 0), 0), 65535);
363 gcMaxLives := Min(Max(config.ReadInt('GameplayCustom', 'MaxLives', 0), 0), 255);
364 gcPlayers := Min(Max(config.ReadInt('GameplayCustom', 'Players', 1), 0), 2);
365 gcTeamDamage := config.ReadBool('GameplayCustom', 'TeamDamage', False);
366 gcAllowExit := config.ReadBool('GameplayCustom', 'AllowExit', True);
367 gcWeaponStay := config.ReadBool('GameplayCustom', 'WeaponStay', False);
368 gcMonsters := config.ReadBool('GameplayCustom', 'Monsters', False);
369 gcBotsVS := config.ReadStr('GameplayCustom', 'BotsVS', 'Everybody');
371 with gGameSettings do
372 begin
373 GameMode := g_Game_TextToMode(gcGameMode);
374 if GameMode = GM_NONE then
375 GameMode := GM_DM;
376 if GameMode = GM_SINGLE then
377 GameMode := GM_COOP;
378 TimeLimit := gcTimeLimit;
379 GoalLimit := gcGoalLimit;
380 MaxLives := gcMaxLives;
382 Options := 0;
383 if gcTeamDamage then
384 Options := Options or GAME_OPTION_TEAMDAMAGE;
385 if gcAllowExit then
386 Options := Options or GAME_OPTION_ALLOWEXIT;
387 if gcWeaponStay then
388 Options := Options or GAME_OPTION_WEAPONSTAY;
389 if gcMonsters then
390 Options := Options or GAME_OPTION_MONSTERS;
391 if gcBotsVS = 'Everybody' then
392 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
393 if gcBotsVS = 'Players' then
394 Options := Options or GAME_OPTION_BOTVSPLAYER;
395 if gcBotsVS = 'Monsters' then
396 Options := Options or GAME_OPTION_BOTVSMONSTER;
397 end;
399 // Ãåéìïëåé â ñåòåâîé èãðå
400 gnMap := config.ReadStr('GameplayNetwork', 'Map', '');
401 gnGameMode := config.ReadStr('GameplayNetwork', 'GameMode', _lc[I_MENU_GAME_TYPE_DM]);
402 gnTimeLimit := Min(Max(config.ReadInt('GameplayNetwork', 'TimeLimit', 0), 0), 65535);
403 gnGoalLimit := Min(Max(config.ReadInt('GameplayNetwork', 'GoalLimit', 0), 0), 65535);
404 gnMaxLives := Min(Max(config.ReadInt('GameplayNetwork', 'MaxLives', 0), 0), 255);
405 gnPlayers := Min(Max(config.ReadInt('GameplayNetwork', 'Players', 1), 0), 2);
406 gnTeamDamage := config.ReadBool('GameplayNetwork', 'TeamDamage', False);
407 gnAllowExit := config.ReadBool('GameplayNetwork', 'AllowExit', True);
408 gnWeaponStay := config.ReadBool('GameplayNetwork', 'WeaponStay', False);
409 gnMonsters := config.ReadBool('GameplayNetwork', 'Monsters', False);
410 gnBotsVS := config.ReadStr('GameplayNetwork', 'BotsVS', 'Everybody');
412 // Îáùèå ñåòåâûå
413 NetSlistIP := config.ReadStr('MasterServer', 'IP', 'mpms.doom2d.org');
414 NetSlistPort := config.ReadInt('MasterServer', 'Port', 25665);
416 // Ñåðâåð
417 NetServerName := config.ReadStr('Server', 'Name', 'Unnamed Server');
418 NetPassword := config.ReadStr('Server', 'Password', '');
419 NetPort := Min(Max(0, config.ReadInt('Server', 'Port', 25666)), 65535);
420 NetMaxClients := Min(Max(0, config.ReadInt('Server', 'MaxClients', 16)), NET_MAXCLIENTS);
421 NetAllowRCON := config.ReadBool('Server', 'RCON', False);
422 NetRCONPassword := config.ReadStr('Server', 'RCONPassword', 'default');
423 NetUseMaster := config.ReadBool('Server', 'SyncWithMaster', True);
424 NetUpdateRate := Max(0, config.ReadInt('Server', 'UpdateInterval', 0));
425 NetRelupdRate := Max(0, config.ReadInt('Server', 'ReliableUpdateInterval', 18));
426 NetMasterRate := Max(1, config.ReadInt('Server', 'MasterSyncInterval', 60000));
428 // Êëèåíò
429 NetInterpLevel := Max(0, config.ReadInt('Client', 'InterpolationSteps', 2));
430 NetForcePlayerUpdate := config.ReadBool('Client', 'ForcePlayerUpdate', False);
431 NetPredictSelf := config.ReadBool('Client', 'PredictSelf', True);
432 NetClientIP := config.ReadStr('Client', 'LastIP', '127.0.0.1');
433 NetClientPort := Max(0, config.ReadInt('Client', 'LastPort', 25666));
435 // ßçûê:
436 str := config.ReadStr('Game', 'Language', '');
437 if (str = LANGUAGE_RUSSIAN) or
438 (str = LANGUAGE_ENGLISH) then
439 begin
440 gLanguage := str;
441 gAskLanguage := False;
442 end
443 else
444 gLanguage := LANGUAGE_ENGLISH;
446 config.Free();
448 if gTextureFilter then
449 TEXTUREFILTER := GL_LINEAR
450 else
451 TEXTUREFILTER := GL_NEAREST;
452 end;
454 procedure g_Options_Write(FileName: String);
455 var
456 config: TConfig;
457 i: Integer;
458 begin
459 e_WriteLog('Writing config', MSG_NOTIFY);
461 config := TConfig.CreateFile(FileName);
463 config.WriteInt('Video', 'ScreenWidth', gScreenWidth);
464 config.WriteInt('Video', 'ScreenHeight', gScreenHeight);
465 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
466 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
467 config.WriteBool('Video', 'Fullscreen', gFullScreen);
468 config.WriteBool('Video', 'Maximized', gWinMaximized);
469 config.WriteInt('Video', 'BPP', gBPP);
470 config.WriteBool('Video', 'VSync', gVSync);
471 config.WriteBool('Video', 'TextureFilter', gTextureFilter);
472 config.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT);
474 config.WriteBool('Sound', 'NoSound', gNoSound);
475 config.WriteInt('Sound', 'SoundLevel', gSoundLevel);
476 config.WriteInt('Sound', 'MusicLevel', gMusicLevel);
477 config.WriteInt('Sound', 'MaxSimSounds', gMaxSimSounds);
478 config.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive);
479 config.WriteInt('Sound', 'Announcer', gAnnouncer);
480 config.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF);
481 config.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate);
482 config.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize);
484 with config, gGameControls.GameControls do
485 begin
486 WriteInt('GameControls', 'TakeScreenshot', TakeScreenshot);
487 WriteInt('GameControls', 'Stat', Stat);
488 WriteInt('GameControls', 'Chat', Chat);
489 WriteInt('GameControls', 'TeamChat', TeamChat);
490 end;
492 with config, gGameControls.P1Control, gPlayer1Settings do
493 begin
494 WriteInt('Player1', 'KeyRight', KeyRight);
495 WriteInt('Player1', 'KeyLeft', KeyLeft);
496 WriteInt('Player1', 'KeyUp', KeyUp);
497 WriteInt('Player1', 'KeyDown', KeyDown);
498 WriteInt('Player1', 'KeyFire', KeyFire);
499 WriteInt('Player1', 'KeyJump', KeyJump);
500 WriteInt('Player1', 'KeyNextWeapon', KeyNextWeapon);
501 WriteInt('Player1', 'KeyPrevWeapon', KeyPrevWeapon);
502 WriteInt('Player1', 'KeyOpen', KeyOpen);
504 WriteStr('Player1', 'Name', Name);
505 WriteStr('Player1', 'model', Model);
506 WriteInt('Player1', 'red', Color.R);
507 WriteInt('Player1', 'green', Color.G);
508 WriteInt('Player1', 'blue', Color.B);
509 WriteInt('Player1', 'team', Team);
510 end;
512 with config, gGameControls.P2Control, gPlayer2Settings do
513 begin
514 WriteInt('Player2', 'KeyRight', KeyRight);
515 WriteInt('Player2', 'KeyLeft', KeyLeft);
516 WriteInt('Player2', 'KeyUp', KeyUp);
517 WriteInt('Player2', 'KeyDown', KeyDown);
518 WriteInt('Player2', 'KeyFire', KeyFire);
519 WriteInt('Player2', 'KeyJump', KeyJump);
520 WriteInt('Player2', 'KeyNextWeapon', KeyNextWeapon);
521 WriteInt('Player2', 'KeyPrevWeapon', KeyPrevWeapon);
522 WriteInt('Player2', 'KeyOpen', KeyOpen);
524 WriteStr('Player2', 'Name', Name);
525 WriteStr('Player2', 'model', Model);
526 WriteInt('Player2', 'red', Color.R);
527 WriteInt('Player2', 'green', Color.G);
528 WriteInt('Player2', 'blue', Color.B);
529 WriteInt('Player2', 'team', Team);
530 end;
532 for i := 0 to e_MaxJoys-1 do
533 config.WriteInt('Joysticks', 'Deadzone' + IntToStr(i), e_JoystickDeadzones[i]);
535 with config do
536 case gGibsCount of
537 0: config.WriteInt('Game', 'GibsCount', 0);
538 8: config.WriteInt('Game', 'GibsCount', 1);
539 16: config.WriteInt('Game', 'GibsCount', 2);
540 32: config.WriteInt('Game', 'GibsCount', 3);
541 else config.WriteInt('Game', 'GibsCount', 4);
542 end;
544 config.WriteInt('Game', 'ItemRespawnTime', ITEM_RESPAWNTIME div 36);
545 config.WriteInt('Game', 'MaxParticles', g_GFX_GetMax());
546 config.WriteInt('Game', 'MaxShells', g_Shells_GetMax());
547 config.WriteInt('Game', 'MaxGibs', g_Gibs_GetMax());
548 config.WriteInt('Game', 'MaxCorpses', g_Corpses_GetMax());
549 config.WriteInt('Game', 'BloodCount', gBloodCount);
550 config.WriteBool('Game', 'AdvancesBlood', gAdvBlood);
551 config.WriteBool('Game', 'AdvancesCorpses', gAdvCorpses);
552 config.WriteBool('Game', 'AdvancesGibs', gAdvGibs);
553 config.WriteInt('Game', 'Flash', gFlash);
554 config.WriteBool('Game', 'BackGround', gDrawBackGround);
555 config.WriteBool('Game', 'Messages', gShowMessages);
556 config.WriteBool('Game', 'RevertPlayers', gRevertPlayers);
557 config.WriteInt('Game', 'ChatBubble', gChatBubble);
558 config.WriteBool('Game', 'SFSDebug', gSFSDebug);
559 config.WriteBool('Game', 'SFSFastMode', gSFSFastMode);
560 config.WriteBool('Game', 'FastScreenshots', e_FastScreenshots);
562 config.WriteStr ('GameplayCustom', 'Map', gcMap);
563 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
564 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
565 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
566 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
567 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
568 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
569 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
570 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
571 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
572 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
574 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
575 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
576 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
577 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
578 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
579 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
580 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
581 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
582 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
583 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
584 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
586 config.WriteStr('MasterServer', 'IP', NetSlistIP);
587 config.WriteInt('MasterServer', 'Port', NetSlistPort);
589 config.WriteStr ('Server', 'Name', NetServerName);
590 config.WriteStr ('Server', 'Password', NetPassword);
591 config.WriteInt ('Server', 'Port', NetPort);
592 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
593 config.WriteBool('Server', 'RCON', NetAllowRCON);
594 config.WriteStr ('Server', 'RCONPassword', NetRCONPassword);
595 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
596 config.WriteInt ('Server', 'UpdateInterval', NetUpdateRate);
597 config.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate);
598 config.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate);
600 config.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel);
601 config.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate);
602 config.WriteBool ('Client', 'PredictSelf', NetPredictSelf);
603 config.WriteStr ('Client', 'LastIP', NetClientIP);
604 config.WriteInt ('Client', 'LastPort', NetClientPort);
606 config.SaveFile(FileName);
607 config.Free();
608 end;
610 procedure g_Options_Write_Language(FileName: String);
611 var
612 config: TConfig;
613 begin
614 e_WriteLog('Writing language config', MSG_NOTIFY);
616 config := TConfig.CreateFile(FileName);
617 config.WriteStr('Game', 'Language', gLanguage);
618 config.SaveFile(FileName);
619 config.Free();
620 end;
622 procedure g_Options_Write_Video(FileName: String);
623 var
624 config: TConfig;
625 sW, sH: Integer;
626 begin
627 e_WriteLog('Writing resolution to config', MSG_NOTIFY);
629 config := TConfig.CreateFile(FileName);
631 if gWinMaximized and (not gFullscreen) then
632 begin
633 sW := gWinSizeX;
634 sH := gWinSizeY;
635 end
636 else
637 begin
638 sW := gScreenWidth;
639 sH := gScreenHeight;
640 end;
642 config.WriteInt('Video', 'ScreenWidth', sW);
643 config.WriteInt('Video', 'ScreenHeight', sH);
644 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
645 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
646 config.WriteBool('Video', 'Fullscreen', gFullscreen);
647 config.WriteBool('Video', 'Maximized', gWinMaximized);
649 config.SaveFile(FileName);
650 config.Free();
651 end;
653 procedure g_Options_Write_Gameplay_Custom(FileName: String);
654 var
655 config: TConfig;
656 begin
657 e_WriteLog('Writing custom gameplay config', MSG_NOTIFY);
659 config := TConfig.CreateFile(FileName);
661 config.WriteStr ('GameplayCustom', 'Map', gcMap);
662 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
663 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
664 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
665 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
666 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
667 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
668 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
669 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
670 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
671 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
673 config.SaveFile(FileName);
674 config.Free();
675 end;
677 procedure g_Options_Write_Gameplay_Net(FileName: String);
678 var
679 config: TConfig;
680 begin
681 e_WriteLog('Writing network gameplay config', MSG_NOTIFY);
683 config := TConfig.CreateFile(FileName);
685 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
686 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
687 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
688 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
689 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
690 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
691 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
692 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
693 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
694 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
695 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
697 config.SaveFile(FileName);
698 config.Free();
699 end;
701 procedure g_Options_Write_Net_Server(FileName: String);
702 var
703 config: TConfig;
704 begin
705 e_WriteLog('Writing server config', MSG_NOTIFY);
707 config := TConfig.CreateFile(FileName);
709 config.WriteStr ('Server', 'Name', NetServerName);
710 config.WriteStr ('Server', 'Password', NetPassword);
711 config.WriteInt ('Server', 'Port', NetPort);
712 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
713 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
715 config.SaveFile(FileName);
716 config.Free();
717 end;
719 procedure g_Options_Write_Net_Client(FileName: String);
720 var
721 config: TConfig;
722 begin
723 e_WriteLog('Writing client config', MSG_NOTIFY);
725 config := TConfig.CreateFile(FileName);
727 config.WriteStr('Client', 'LastIP', NetClientIP);
728 config.WriteInt('Client', 'LastPort', NetClientPort);
730 config.SaveFile(FileName);
731 config.Free();
732 end;
734 end.