DEADSOFTWARE

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