DEADSOFTWARE

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