DEADSOFTWARE

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