DEADSOFTWARE

Chat sounds: Add config and menu option
[d2df-sdl.git] / src / game / g_options.pas
1 (* Copyright (C) Doom 2D: Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *)
16 {$INCLUDE ../shared/a_modes.inc}
17 unit g_options;
19 interface
21 uses
22 g_language, g_weapons;
24 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;
36 KeyWeapon: array [WP_FIRST..WP_LAST] of Word;
38 KeyRight2: Word;
39 KeyLeft2: Word;
40 KeyUp2: Word;
41 KeyDown2: Word;
42 KeyFire2: Word;
43 KeyJump2: Word;
44 KeyNextWeapon2: Word;
45 KeyPrevWeapon2: Word;
46 KeyOpen2: Word;
47 KeyStrafe2: Word;
48 KeyWeapon2: array [WP_FIRST..WP_LAST] of Word;
49 end;
51 TGameControls = record
52 TakeScreenshot: Word;
53 Stat: Word;
54 Chat: Word;
55 TeamChat: Word;
56 end;
58 TControls = record
59 GameControls: TGameControls;
60 P1Control: TPlayerControl;
61 P2Control: TPlayerControl;
62 end;
64 procedure g_Options_SetDefault();
65 procedure g_Options_Read(FileName: String);
66 procedure g_Options_Write(FileName: String);
67 procedure g_Options_Write_Language(FileName: String);
68 procedure g_Options_Write_Video(FileName: String);
69 procedure g_Options_Write_Gameplay_Custom(FileName: String);
70 procedure g_Options_Write_Gameplay_Net(FileName: String);
71 procedure g_Options_Write_Net_Server(FileName: String);
72 procedure g_Options_Write_Net_Client(FileName: String);
74 const DF_Default_Megawad_Start = 'megawads/DOOM2D.WAD:\MAP01';
76 var
77 gGameControls: TControls;
78 gScreenWidth: Word = 800;
79 gScreenHeight: Word = 600;
80 gWinRealPosX: Integer = 0;
81 gWinRealPosY: Integer = 0;
82 gBPP: Byte = 32;
83 gFreq: Byte = 0;
84 gFullscreen: Boolean = False;
85 gWinMaximized: Boolean = False;
86 gVSync: Boolean = False;
87 glLegacyNPOT: Boolean = False;
88 gTextureFilter: Boolean = True;
89 gNoSound: Boolean = False;
90 gSoundLevel: Byte = 75;
91 gMusicLevel: Byte = 65;
92 gMaxSimSounds: Byte = 8;
93 gMuteWhenInactive: Boolean = False;
94 gAdvCorpses: Boolean = True;
95 gAdvBlood: Boolean = True;
96 gAdvGibs: Boolean = True;
97 gGibsCount: Integer = 32;
98 gBloodCount: Byte = 3;
99 gFlash: Byte = 1;
100 gDrawBackGround: Boolean = True;
101 gShowMessages: Boolean = True;
102 gRevertPlayers: Boolean = False;
103 gLanguage: String = LANGUAGE_ENGLISH;
104 gAskLanguage: Boolean = True;
105 gcMap: String = '';
106 gcGameMode: String = '';
107 gcTimeLimit: Word = 0;
108 gcGoalLimit: Word = 0;
109 gcMaxLives: Byte = 0;
110 gcPlayers: Byte = 1;
111 gcTeamDamage: Boolean = False;
112 gcAllowExit: Boolean = True;
113 gcWeaponStay: Boolean = False;
114 gcMonsters: Boolean = False;
115 gcBotsVS: String = 'Everybody';
116 gnMap: String = '';
117 gnGameMode: String = '';
118 gnTimeLimit: Word = 0;
119 gnGoalLimit: Word = 0;
120 gnMaxLives: Byte = 0;
121 gnPlayers: Byte = 1;
122 gnTeamDamage: Boolean = False;
123 gnAllowExit: Boolean = True;
124 gnWeaponStay: Boolean = False;
125 gnMonsters: Boolean = False;
126 gnBotsVS: String = 'Everybody';
127 gsSDLSampleRate: Integer = 44100;
128 gsSDLBufferSize: Integer = 2048;
129 gSFSDebug: Boolean = False;
130 gSFSFastMode: Boolean = False;
131 gDefaultMegawadStart: AnsiString = DF_Default_Megawad_Start;
132 gBerserkAutoswitch: Boolean = True;
134 implementation
136 uses
137 e_log, e_input, g_window, g_sound, g_gfx, g_player, Math,
138 g_map, g_net, g_netmaster, SysUtils, CONFIG, g_game, g_main, e_texture,
139 g_items, GL, GLExt, wadreader, e_graphics;
141 procedure g_Options_SetDefault();
142 var
143 i: Integer;
144 begin
145 g_Sound_SetupAllVolumes(75, 65);
146 gMaxSimSounds := 8;
147 gMuteWhenInactive := False;
148 gAnnouncer := ANNOUNCE_MEPLUS;
149 gSoundEffectsDF := True;
150 gUseChatSounds := True;
151 g_GFX_SetMax(2000);
152 g_Gibs_SetMax(150);
153 g_Corpses_SetMax(20);
154 g_Shells_SetMax(300);
155 gGibsCount := 32;
156 gBloodCount := 3;
157 gAdvBlood := True;
158 gAdvCorpses := True;
159 gAdvGibs := True;
160 gFlash := 1;
161 gDrawBackGround := True;
162 gShowMessages := True;
163 gRevertPlayers := False;
165 for i := 0 to e_MaxJoys-1 do
166 e_JoystickDeadzones[i] := 8192;
168 with gGameControls.GameControls do
169 begin
170 TakeScreenshot := 183;
171 Stat := 15;
172 Chat := 20; // [T]
173 TeamChat := 21; // [Y]
174 end;
176 with gGameControls.P1Control do
177 begin
178 KeyRight := 77;
179 KeyLeft := 75;
180 KeyUp := 72;
181 KeyDown := 76;
182 KeyFire := 184;
183 KeyJump := 157;
184 KeyNextWeapon := 73;
185 KeyPrevWeapon := 71;
186 KeyOpen := 54;
187 KeyStrafe := 0;
188 for i := 0 to High(KeyWeapon) do
189 KeyWeapon[i] := 0;
191 KeyRight2 := 0;
192 KeyLeft2 := 0;
193 KeyUp2 := 0;
194 KeyDown2 := 0;
195 KeyFire2 := 0;
196 KeyJump2 := 0;
197 KeyNextWeapon2 := 0;
198 KeyPrevWeapon2 := 0;
199 KeyOpen2 := 0;
200 KeyStrafe2 := 0;
201 for i := 0 to High(KeyWeapon2) do
202 KeyWeapon2[i] := 0;
203 end;
205 with gGameControls.P2Control do
206 begin
207 KeyRight := 33;
208 KeyLeft := 31;
209 KeyUp := 18;
210 KeyDown := 32;
211 KeyFire := 30;
212 KeyJump := 16;
213 KeyNextWeapon := 19;
214 KeyPrevWeapon := 17;
215 KeyOpen := 58;
216 KeyStrafe := 0;
217 for i := 0 to High(KeyWeapon) do
218 KeyWeapon[i] := 0;
220 KeyRight2 := 0;
221 KeyLeft2 := 0;
222 KeyUp2 := 0;
223 KeyDown2 := 0;
224 KeyFire2 := 0;
225 KeyJump2 := 0;
226 KeyNextWeapon2 := 0;
227 KeyPrevWeapon2 := 0;
228 KeyOpen2 := 0;
229 KeyStrafe2 := 0;
230 for i := 0 to High(KeyWeapon2) do
231 KeyWeapon2[i] := 0;
232 end;
234 with gPlayer1Settings do
235 begin
236 Name := 'Player1';
237 Model := STD_PLAYER_MODEL;
238 Color.R := PLAYER1_DEF_COLOR.R;
239 Color.G := PLAYER1_DEF_COLOR.G;
240 Color.B := PLAYER1_DEF_COLOR.B;
241 Team := TEAM_RED;
242 end;
244 with gPlayer2Settings do
245 begin
246 Name := 'Player2';
247 Model := STD_PLAYER_MODEL;
248 Color.R := PLAYER2_DEF_COLOR.R;
249 Color.G := PLAYER2_DEF_COLOR.G;
250 Color.B := PLAYER2_DEF_COLOR.B;
251 Team := TEAM_BLUE;
252 end;
254 NetUseMaster := True;
255 g_Net_Slist_Set('mpms.doom2d.org', 25665);
256 end;
258 procedure g_Options_Read(FileName: String);
259 var
260 config: TConfig;
261 str: String;
262 i: Integer;
263 begin
264 gAskLanguage := True;
265 e_WriteLog('Reading config', TMsgType.Notify);
267 if not FileExists(FileName) then
268 begin
269 e_WriteLog('Config file '+FileName+' not found', TMsgType.Warning);
270 g_Options_SetDefault();
272 // Default video options:
273 gScreenWidth := 800;
274 gScreenHeight := 600;
275 gWinRealPosX := 0;
276 gWinRealPosY := 0;
277 gWinMaximized := False;
278 gFullScreen := False;
279 gBPP := 32;
280 gVSync := False;
281 gTextureFilter := True;
282 glLegacyNPOT := False;
284 Exit;
285 end;
287 config := TConfig.CreateFile(FileName);
289 gScreenWidth := config.ReadInt('Video', 'ScreenWidth', 800);
290 if gScreenWidth < 640 then
291 gScreenWidth := 640;
292 gScreenHeight := config.ReadInt('Video', 'ScreenHeight', 600);
293 if gScreenHeight < 480 then
294 gScreenHeight := 480;
295 gWinRealPosX := config.ReadInt('Video', 'WinPosX', 0);
296 if gWinRealPosX < 0 then
297 gWinRealPosX := 0;
298 gWinRealPosY := config.ReadInt('Video', 'WinPosY', 0);
299 if gWinRealPosY < 0 then
300 gWinRealPosY := 0;
301 gFullScreen := config.ReadBool('Video', 'Fullscreen', False);
302 gWinMaximized := config.ReadBool('Video', 'Maximized', False);
303 gBPP := config.ReadInt('Video', 'BPP', 32);
304 gFreq := config.ReadInt('Video', 'Freq', 0);
305 gVSync := config.ReadBool('Video', 'VSync', True);
306 gTextureFilter := config.ReadBool('Video', 'TextureFilter', True);
307 glLegacyNPOT := config.ReadBool('Video', 'LegacyCompatible', False);
309 gNoSound := config.ReadBool('Sound', 'NoSound', False);
310 gSoundLevel := Min(config.ReadInt('Sound', 'SoundLevel', 75), 255);
311 gMusicLevel := Min(config.ReadInt('Sound', 'MusicLevel', 65), 255);
312 gMaxSimSounds := Max(Min(config.ReadInt('Sound', 'MaxSimSounds', 8), 66), 2);
313 gMuteWhenInactive := config.ReadBool('Sound', 'MuteInactive', False);
314 gAnnouncer := Min(Max(config.ReadInt('Sound', 'Announcer', ANNOUNCE_MEPLUS), ANNOUNCE_NONE), ANNOUNCE_ALL);
315 gSoundEffectsDF := config.ReadBool('Sound', 'SoundEffectsDF', True);
316 gUseChatSounds := config.ReadBool('Sound', 'ChatSounds', True);
317 gsSDLSampleRate := Min(Max(config.ReadInt('Sound', 'SDLSampleRate', 44100), 11025), 96000);
318 gsSDLBufferSize := Min(Max(config.ReadInt('Sound', 'SDLBufferSize', 2048), 64), 16384);
320 with gGameControls.GameControls do
321 begin
322 TakeScreenshot := config.ReadInt('GameControls', 'TakeScreenshot', 183);
323 Stat := config.ReadInt('GameControls', 'Stat', 15);
324 Chat := config.ReadInt('GameControls', 'Chat', 20);
325 TeamChat := config.ReadInt('GameControls', 'TeamChat', 21);
326 end;
328 with gGameControls.P1Control, config do
329 begin
330 KeyRight := ReadInt('Player1', 'KeyRight', 33);
331 KeyLeft := ReadInt('Player1', 'KeyLeft', 31);
332 KeyUp := ReadInt('Player1', 'KeyUp', 18);
333 KeyDown := ReadInt('Player1', 'KeyDown', 32);
334 KeyFire := ReadInt('Player1', 'KeyFire', 30);
335 KeyJump := ReadInt('Player1', 'KeyJump', 16);
336 KeyNextWeapon := ReadInt('Player1', 'KeyNextWeapon', 19);
337 KeyPrevWeapon := ReadInt('Player1', 'KeyPrevWeapon', 17);
338 KeyOpen := ReadInt('Player1', 'KeyOpen', 58);
339 KeyStrafe := ReadInt('Player1', 'KeyStrafe', 0);
340 for i := 0 to High(KeyWeapon) do
341 KeyWeapon[i] := ReadInt('Player1', 'KeyWeapon' + IntToStr(i), 0);
343 KeyRight2 := ReadInt('Player1', 'KeyRight2', 0);
344 KeyLeft2 := ReadInt('Player1', 'KeyLeft2', 0);
345 KeyUp2 := ReadInt('Player1', 'KeyUp2', 0);
346 KeyDown2 := ReadInt('Player1', 'KeyDown2', 0);
347 KeyFire2 := ReadInt('Player1', 'KeyFire2', 0);
348 KeyJump2 := ReadInt('Player1', 'KeyJump2', 0);
349 KeyNextWeapon2 := ReadInt('Player1', 'KeyNextWeapon2', 0);
350 KeyPrevWeapon2 := ReadInt('Player1', 'KeyPrevWeapon2', 0);
351 KeyOpen2 := ReadInt('Player1', 'KeyOpen2', 0);
352 KeyStrafe2 := ReadInt('Player1', 'KeyStrafe2', 0);
353 for i := 0 to High(KeyWeapon2) do
354 KeyWeapon2[i] := ReadInt('Player1', 'KeyWeapon2' + IntToStr(i), 0);
355 end;
357 with gPlayer1Settings, config do
358 begin
359 Name := ReadStr('Player1', 'name', 'Player1');
360 Model := ReadStr('Player1', 'model', STD_PLAYER_MODEL);
361 Color.R := Min(Abs(ReadInt('Player1', 'red', PLAYER1_DEF_COLOR.R)), 255);
362 Color.G := Min(Abs(ReadInt('Player1', 'green', PLAYER1_DEF_COLOR.G)), 255);
363 Color.B := Min(Abs(ReadInt('Player1', 'blue', PLAYER1_DEF_COLOR.B)), 255);
364 Team := ReadInt('Player1', 'team', TEAM_RED);
365 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
366 Team := TEAM_RED;
367 end;
369 with gGameControls.P2Control, config do
370 begin
371 KeyRight := ReadInt('Player2', 'KeyRight', 205);
372 KeyLeft := ReadInt('Player2', 'KeyLeft', 203);
373 KeyUp := ReadInt('Player2', 'KeyUp', 200);
374 KeyDown := ReadInt('Player2', 'KeyDown', 208);
375 KeyFire := ReadInt('Player2', 'KeyFire', 184);
376 KeyJump := ReadInt('Player2', 'KeyJump', 157);
377 KeyNextWeapon := ReadInt('Player2', 'KeyNextWeapon', 73);
378 KeyPrevWeapon := ReadInt('Player2', 'KeyPrevWeapon', 71);
379 KeyOpen := ReadInt('Player2', 'KeyOpen', 54);
380 KeyStrafe := ReadInt('Player2', 'KeyStrafe', 0);
381 for i := 0 to High(KeyWeapon) do
382 KeyWeapon[i] := ReadInt('Player2', 'KeyWeapon' + IntToStr(i), 0);
384 KeyRight2 := ReadInt('Player2', 'KeyRight2', 0);
385 KeyLeft2 := ReadInt('Player2', 'KeyLeft2', 0);
386 KeyUp2 := ReadInt('Player2', 'KeyUp2', 0);
387 KeyDown2 := ReadInt('Player2', 'KeyDown2', 0);
388 KeyFire2 := ReadInt('Player2', 'KeyFire2', 0);
389 KeyJump2 := ReadInt('Player2', 'KeyJump2', 0);
390 KeyNextWeapon2 := ReadInt('Player2', 'KeyNextWeapon2', 0);
391 KeyPrevWeapon2 := ReadInt('Player2', 'KeyPrevWeapon2', 0);
392 KeyOpen2 := ReadInt('Player2', 'KeyOpen2', 0);
393 KeyStrafe2 := ReadInt('Player2', 'KeyStrafe2', 0);
394 for i := 0 to High(KeyWeapon2) do
395 KeyWeapon2[i] := ReadInt('Player2', 'KeyWeapon2' + IntToStr(i), 0);
396 end;
398 with gPlayer2Settings, config do
399 begin
400 Name := ReadStr('Player2', 'name', 'Player2');
401 Model := ReadStr('Player2', 'model', STD_PLAYER_MODEL);
402 Color.R := Min(Abs(ReadInt('Player2', 'red', PLAYER2_DEF_COLOR.R)), 255);
403 Color.G := Min(Abs(ReadInt('Player2', 'green', PLAYER2_DEF_COLOR.G)), 255);
404 Color.B := Min(Abs(ReadInt('Player2', 'blue', PLAYER2_DEF_COLOR.B)), 255);
405 Team := ReadInt('Player2', 'team', TEAM_BLUE);
406 if (Team < TEAM_RED) or (Team > TEAM_BLUE) then
407 Team := TEAM_RED;
408 end;
410 for i := 0 to e_MaxJoys-1 do
411 e_JoystickDeadzones[i] := config.ReadInt('Joysticks', 'Deadzone' + IntToStr(i), 8192);
413 g_GFX_SetMax(Min(config.ReadInt('Game', 'MaxParticles', 1000), 50000));
414 g_Shells_SetMax(Min(config.ReadInt('Game', 'MaxShells', 300), 600));
415 g_Gibs_SetMax(Min(config.ReadInt('Game', 'MaxGibs', 150), 500));
416 g_Corpses_SetMax(Min(config.ReadInt('Game', 'MaxCorpses', 20), 100));
418 case config.ReadInt('Game', 'GibsCount', 3) of
419 0: gGibsCount := 0;
420 1: gGibsCount := 8;
421 2: gGibsCount := 16;
422 3: gGibsCount := 32;
423 else gGibsCount := 48;
424 end;
426 ITEM_RESPAWNTIME := 36*Max(config.ReadInt('Game', 'ItemRespawnTime', 60), 0);
427 gBloodCount := Min(config.ReadInt('Game', 'BloodCount', 4), 4);
428 gAdvBlood := config.ReadBool('Game', 'AdvancesBlood', True);
429 gAdvCorpses := config.ReadBool('Game', 'AdvancesCorpses', True);
430 gAdvGibs := config.ReadBool('Game', 'AdvancesGibs', True);
431 gFlash := Min(Max(config.ReadInt('Game', 'Flash', 1), 0), 2);
432 gDrawBackGround := config.ReadBool('Game', 'BackGround', True);
433 gShowMessages := config.ReadBool('Game', 'Messages', True);
434 gRevertPlayers := config.ReadBool('Game', 'RevertPlayers', False);
435 gChatBubble := Min(Max(config.ReadInt('Game', 'ChatBubble', 4), 0), 4);
436 gSFSDebug := config.ReadBool('Game', 'SFSDebug', False);
437 wadoptDebug := gSFSDebug;
438 gSFSFastMode := config.ReadBool('Game', 'SFSFastMode', False);
439 wadoptFast := gSFSFastMode;
440 e_FastScreenshots := config.ReadBool('Game', 'FastScreenshots', True);
441 gDefaultMegawadStart := config.ReadStr('Game', 'DefaultMegawadStart', DF_Default_Megawad_Start);
442 gBerserkAutoswitch := config.ReadBool('Game', 'BerserkAutoswitching', True);
444 // Ãåéìïëåé â ñâîåé èãðå
445 gcMap := config.ReadStr('GameplayCustom', 'Map', '');
446 gcGameMode := config.ReadStr('GameplayCustom', 'GameMode', _lc[I_MENU_GAME_TYPE_DM]);
447 gcTimeLimit := Min(Max(config.ReadInt('GameplayCustom', 'TimeLimit', 0), 0), 65535);
448 gcGoalLimit := Min(Max(config.ReadInt('GameplayCustom', 'GoalLimit', 0), 0), 65535);
449 gcMaxLives := Min(Max(config.ReadInt('GameplayCustom', 'MaxLives', 0), 0), 255);
450 gcPlayers := Min(Max(config.ReadInt('GameplayCustom', 'Players', 1), 0), 2);
451 gcTeamDamage := config.ReadBool('GameplayCustom', 'TeamDamage', False);
452 gcAllowExit := config.ReadBool('GameplayCustom', 'AllowExit', True);
453 gcWeaponStay := config.ReadBool('GameplayCustom', 'WeaponStay', False);
454 gcMonsters := config.ReadBool('GameplayCustom', 'Monsters', False);
455 gcBotsVS := config.ReadStr('GameplayCustom', 'BotsVS', 'Everybody');
457 with gGameSettings do
458 begin
459 GameMode := g_Game_TextToMode(gcGameMode);
460 if GameMode = GM_NONE then
461 GameMode := GM_DM;
462 if GameMode = GM_SINGLE then
463 GameMode := GM_COOP;
464 TimeLimit := gcTimeLimit;
465 GoalLimit := gcGoalLimit;
466 MaxLives := gcMaxLives;
468 Options := 0;
469 if gcTeamDamage then
470 Options := Options or GAME_OPTION_TEAMDAMAGE;
471 if gcAllowExit then
472 Options := Options or GAME_OPTION_ALLOWEXIT;
473 if gcWeaponStay then
474 Options := Options or GAME_OPTION_WEAPONSTAY;
475 if gcMonsters then
476 Options := Options or GAME_OPTION_MONSTERS;
477 if gcBotsVS = 'Everybody' then
478 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
479 if gcBotsVS = 'Players' then
480 Options := Options or GAME_OPTION_BOTVSPLAYER;
481 if gcBotsVS = 'Monsters' then
482 Options := Options or GAME_OPTION_BOTVSMONSTER;
483 end;
485 // Ãåéìïëåé â ñåòåâîé èãðå
486 gnMap := config.ReadStr('GameplayNetwork', 'Map', '');
487 gnGameMode := config.ReadStr('GameplayNetwork', 'GameMode', _lc[I_MENU_GAME_TYPE_DM]);
488 gnTimeLimit := Min(Max(config.ReadInt('GameplayNetwork', 'TimeLimit', 0), 0), 65535);
489 gnGoalLimit := Min(Max(config.ReadInt('GameplayNetwork', 'GoalLimit', 0), 0), 65535);
490 gnMaxLives := Min(Max(config.ReadInt('GameplayNetwork', 'MaxLives', 0), 0), 255);
491 gnPlayers := Min(Max(config.ReadInt('GameplayNetwork', 'Players', 1), 0), 2);
492 gnTeamDamage := config.ReadBool('GameplayNetwork', 'TeamDamage', False);
493 gnAllowExit := config.ReadBool('GameplayNetwork', 'AllowExit', True);
494 gnWeaponStay := config.ReadBool('GameplayNetwork', 'WeaponStay', False);
495 gnMonsters := config.ReadBool('GameplayNetwork', 'Monsters', False);
496 gnBotsVS := config.ReadStr('GameplayNetwork', 'BotsVS', 'Everybody');
498 // Îáùèå ñåòåâûå
499 NetSlistIP := config.ReadStr('MasterServer', 'IP', 'mpms.doom2d.org');
500 NetSlistPort := config.ReadInt('MasterServer', 'Port', 25665);
502 // Ñåðâåð
503 NetServerName := config.ReadStr('Server', 'Name', 'Unnamed Server');
504 NetPassword := config.ReadStr('Server', 'Password', '');
505 NetPort := Min(Max(0, config.ReadInt('Server', 'Port', 25666)), 65535);
506 NetMaxClients := Min(Max(0, config.ReadInt('Server', 'MaxClients', 16)), NET_MAXCLIENTS);
507 NetAllowRCON := config.ReadBool('Server', 'RCON', False);
508 NetRCONPassword := config.ReadStr('Server', 'RCONPassword', 'default');
509 NetUseMaster := config.ReadBool('Server', 'SyncWithMaster', True);
510 NetUpdateRate := Max(0, config.ReadInt('Server', 'UpdateInterval', 0));
511 NetRelupdRate := Max(0, config.ReadInt('Server', 'ReliableUpdateInterval', 18));
512 NetMasterRate := Max(1, config.ReadInt('Server', 'MasterSyncInterval', 60000));
514 // Êëèåíò
515 NetInterpLevel := Max(0, config.ReadInt('Client', 'InterpolationSteps', 2));
516 NetForcePlayerUpdate := config.ReadBool('Client', 'ForcePlayerUpdate', False);
517 NetPredictSelf := config.ReadBool('Client', 'PredictSelf', True);
518 NetClientIP := config.ReadStr('Client', 'LastIP', '127.0.0.1');
519 NetClientPort := Max(0, config.ReadInt('Client', 'LastPort', 25666));
521 // ßçûê:
522 str := config.ReadStr('Game', 'Language', '');
523 if (str = LANGUAGE_RUSSIAN) or
524 (str = LANGUAGE_ENGLISH) then
525 begin
526 gLanguage := str;
527 gAskLanguage := False;
528 end
529 else
530 gLanguage := LANGUAGE_ENGLISH;
532 config.Free();
534 //if gTextureFilter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
535 end;
537 procedure g_Options_Write(FileName: String);
538 var
539 config: TConfig;
540 i: Integer;
541 begin
542 e_WriteLog('Writing config', TMsgType.Notify);
544 config := TConfig.CreateFile(FileName);
546 config.WriteInt('Video', 'ScreenWidth', gScreenWidth);
547 config.WriteInt('Video', 'ScreenHeight', gScreenHeight);
548 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
549 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
550 config.WriteBool('Video', 'Fullscreen', gFullScreen);
551 config.WriteBool('Video', 'Maximized', gWinMaximized);
552 config.WriteInt('Video', 'BPP', gBPP);
553 config.WriteBool('Video', 'VSync', gVSync);
554 config.WriteBool('Video', 'TextureFilter', gTextureFilter);
555 config.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT);
557 config.WriteBool('Sound', 'NoSound', gNoSound);
558 config.WriteInt('Sound', 'SoundLevel', gSoundLevel);
559 config.WriteInt('Sound', 'MusicLevel', gMusicLevel);
560 config.WriteInt('Sound', 'MaxSimSounds', gMaxSimSounds);
561 config.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive);
562 config.WriteInt('Sound', 'Announcer', gAnnouncer);
563 config.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF);
564 config.WriteBool('Sound', 'ChatSounds', gUseChatSounds);
565 config.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate);
566 config.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize);
568 with config, gGameControls.GameControls do
569 begin
570 WriteInt('GameControls', 'TakeScreenshot', TakeScreenshot);
571 WriteInt('GameControls', 'Stat', Stat);
572 WriteInt('GameControls', 'Chat', Chat);
573 WriteInt('GameControls', 'TeamChat', TeamChat);
574 end;
576 with config, gGameControls.P1Control, gPlayer1Settings do
577 begin
578 WriteInt('Player1', 'KeyRight', KeyRight);
579 WriteInt('Player1', 'KeyLeft', KeyLeft);
580 WriteInt('Player1', 'KeyUp', KeyUp);
581 WriteInt('Player1', 'KeyDown', KeyDown);
582 WriteInt('Player1', 'KeyFire', KeyFire);
583 WriteInt('Player1', 'KeyJump', KeyJump);
584 WriteInt('Player1', 'KeyNextWeapon', KeyNextWeapon);
585 WriteInt('Player1', 'KeyPrevWeapon', KeyPrevWeapon);
586 WriteInt('Player1', 'KeyOpen', KeyOpen);
587 WriteInt('Player1', 'KeyStrafe', KeyStrafe);
588 for i := 0 to High(KeyWeapon) do
589 WriteInt('Player1', 'KeyWeapon' + IntToStr(i), KeyWeapon[i]);
591 WriteInt('Player1', 'KeyRight2', KeyRight2);
592 WriteInt('Player1', 'KeyLeft2', KeyLeft2);
593 WriteInt('Player1', 'KeyUp2', KeyUp2);
594 WriteInt('Player1', 'KeyDown2', KeyDown2);
595 WriteInt('Player1', 'KeyFire2', KeyFire2);
596 WriteInt('Player1', 'KeyJump2', KeyJump2);
597 WriteInt('Player1', 'KeyNextWeapon2', KeyNextWeapon2);
598 WriteInt('Player1', 'KeyPrevWeapon2', KeyPrevWeapon2);
599 WriteInt('Player1', 'KeyOpen2', KeyOpen2);
600 WriteInt('Player1', 'KeyStrafe2', KeyStrafe2);
601 for i := 0 to High(KeyWeapon2) do
602 WriteInt('Player1', 'KeyWeapon2' + IntToStr(i), KeyWeapon2[i]);
604 WriteStr('Player1', 'Name', Name);
605 WriteStr('Player1', 'model', Model);
606 WriteInt('Player1', 'red', Color.R);
607 WriteInt('Player1', 'green', Color.G);
608 WriteInt('Player1', 'blue', Color.B);
609 WriteInt('Player1', 'team', Team);
610 end;
612 with config, gGameControls.P2Control, gPlayer2Settings do
613 begin
614 WriteInt('Player2', 'KeyRight', KeyRight);
615 WriteInt('Player2', 'KeyLeft', KeyLeft);
616 WriteInt('Player2', 'KeyUp', KeyUp);
617 WriteInt('Player2', 'KeyDown', KeyDown);
618 WriteInt('Player2', 'KeyFire', KeyFire);
619 WriteInt('Player2', 'KeyJump', KeyJump);
620 WriteInt('Player2', 'KeyNextWeapon', KeyNextWeapon);
621 WriteInt('Player2', 'KeyPrevWeapon', KeyPrevWeapon);
622 WriteInt('Player2', 'KeyOpen', KeyOpen);
623 WriteInt('Player2', 'KeyStrafe', KeyStrafe);
624 for i := 0 to High(KeyWeapon) do
625 WriteInt('Player2', 'KeyWeapon' + IntToStr(i), KeyWeapon[i]);
627 WriteInt('Player2', 'KeyRight2', KeyRight2);
628 WriteInt('Player2', 'KeyLeft2', KeyLeft2);
629 WriteInt('Player2', 'KeyUp2', KeyUp2);
630 WriteInt('Player2', 'KeyDown2', KeyDown2);
631 WriteInt('Player2', 'KeyFire2', KeyFire2);
632 WriteInt('Player2', 'KeyJump2', KeyJump2);
633 WriteInt('Player2', 'KeyNextWeapon2', KeyNextWeapon2);
634 WriteInt('Player2', 'KeyPrevWeapon2', KeyPrevWeapon2);
635 WriteInt('Player2', 'KeyOpen2', KeyOpen2);
636 WriteInt('Player2', 'KeyStrafe2', KeyStrafe2);
637 for i := 0 to High(KeyWeapon2) do
638 WriteInt('Player2', 'KeyWeapon2' + IntToStr(i), KeyWeapon2[i]);
640 WriteStr('Player2', 'Name', Name);
641 WriteStr('Player2', 'model', Model);
642 WriteInt('Player2', 'red', Color.R);
643 WriteInt('Player2', 'green', Color.G);
644 WriteInt('Player2', 'blue', Color.B);
645 WriteInt('Player2', 'team', Team);
646 end;
648 for i := 0 to e_MaxJoys-1 do
649 config.WriteInt('Joysticks', 'Deadzone' + IntToStr(i), e_JoystickDeadzones[i]);
651 with config do
652 case gGibsCount of
653 0: config.WriteInt('Game', 'GibsCount', 0);
654 8: config.WriteInt('Game', 'GibsCount', 1);
655 16: config.WriteInt('Game', 'GibsCount', 2);
656 32: config.WriteInt('Game', 'GibsCount', 3);
657 else config.WriteInt('Game', 'GibsCount', 4);
658 end;
660 config.WriteInt('Game', 'ItemRespawnTime', ITEM_RESPAWNTIME div 36);
661 config.WriteInt('Game', 'MaxParticles', g_GFX_GetMax());
662 config.WriteInt('Game', 'MaxShells', g_Shells_GetMax());
663 config.WriteInt('Game', 'MaxGibs', g_Gibs_GetMax());
664 config.WriteInt('Game', 'MaxCorpses', g_Corpses_GetMax());
665 config.WriteInt('Game', 'BloodCount', gBloodCount);
666 config.WriteBool('Game', 'AdvancesBlood', gAdvBlood);
667 config.WriteBool('Game', 'AdvancesCorpses', gAdvCorpses);
668 config.WriteBool('Game', 'AdvancesGibs', gAdvGibs);
669 config.WriteInt('Game', 'Flash', gFlash);
670 config.WriteBool('Game', 'BackGround', gDrawBackGround);
671 config.WriteBool('Game', 'Messages', gShowMessages);
672 config.WriteBool('Game', 'RevertPlayers', gRevertPlayers);
673 config.WriteInt('Game', 'ChatBubble', gChatBubble);
674 config.WriteBool('Game', 'SFSDebug', gSFSDebug);
675 config.WriteBool('Game', 'SFSFastMode', gSFSFastMode);
676 config.WriteBool('Game', 'FastScreenshots', e_FastScreenshots);
677 config.WriteStr('Game', 'DefaultMegawadStart', gDefaultMegawadStart);
678 config.WriteBool('Game', 'BerserkAutoswitching', gBerserkAutoswitch);
680 config.WriteStr ('GameplayCustom', 'Map', gcMap);
681 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
682 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
683 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
684 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
685 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
686 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
687 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
688 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
689 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
690 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
692 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
693 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
694 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
695 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
696 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
697 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
698 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
699 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
700 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
701 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
702 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
704 config.WriteStr('MasterServer', 'IP', NetSlistIP);
705 config.WriteInt('MasterServer', 'Port', NetSlistPort);
707 config.WriteStr ('Server', 'Name', NetServerName);
708 config.WriteStr ('Server', 'Password', NetPassword);
709 config.WriteInt ('Server', 'Port', NetPort);
710 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
711 config.WriteBool('Server', 'RCON', NetAllowRCON);
712 config.WriteStr ('Server', 'RCONPassword', NetRCONPassword);
713 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
714 config.WriteInt ('Server', 'UpdateInterval', NetUpdateRate);
715 config.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate);
716 config.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate);
718 config.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel);
719 config.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate);
720 config.WriteBool ('Client', 'PredictSelf', NetPredictSelf);
721 config.WriteStr ('Client', 'LastIP', NetClientIP);
722 config.WriteInt ('Client', 'LastPort', NetClientPort);
724 config.SaveFile(FileName);
725 config.Free();
726 end;
728 procedure g_Options_Write_Language(FileName: String);
729 var
730 config: TConfig;
731 begin
732 e_WriteLog('Writing language config', TMsgType.Notify);
734 config := TConfig.CreateFile(FileName);
735 config.WriteStr('Game', 'Language', gLanguage);
736 config.SaveFile(FileName);
737 config.Free();
738 end;
740 procedure g_Options_Write_Video(FileName: String);
741 var
742 config: TConfig;
743 sW, sH: Integer;
744 begin
745 e_WriteLog('Writing resolution to config', TMsgType.Notify);
747 config := TConfig.CreateFile(FileName);
749 if gWinMaximized and (not gFullscreen) then
750 begin
751 sW := gWinSizeX;
752 sH := gWinSizeY;
753 end
754 else
755 begin
756 sW := gScreenWidth;
757 sH := gScreenHeight;
758 end;
760 config.WriteInt('Video', 'ScreenWidth', sW);
761 config.WriteInt('Video', 'ScreenHeight', sH);
762 config.WriteInt('Video', 'WinPosX', gWinRealPosX);
763 config.WriteInt('Video', 'WinPosY', gWinRealPosY);
764 config.WriteBool('Video', 'Fullscreen', gFullscreen);
765 config.WriteBool('Video', 'Maximized', gWinMaximized);
767 config.SaveFile(FileName);
768 config.Free();
769 end;
771 procedure g_Options_Write_Gameplay_Custom(FileName: String);
772 var
773 config: TConfig;
774 begin
775 e_WriteLog('Writing custom gameplay config', TMsgType.Notify);
777 config := TConfig.CreateFile(FileName);
779 config.WriteStr ('GameplayCustom', 'Map', gcMap);
780 config.WriteStr ('GameplayCustom', 'GameMode', gcGameMode);
781 config.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit);
782 config.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit);
783 config.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives);
784 config.WriteInt ('GameplayCustom', 'Players', gcPlayers);
785 config.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage);
786 config.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit);
787 config.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay);
788 config.WriteBool('GameplayCustom', 'Monsters', gcMonsters);
789 config.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS);
791 config.SaveFile(FileName);
792 config.Free();
793 end;
795 procedure g_Options_Write_Gameplay_Net(FileName: String);
796 var
797 config: TConfig;
798 begin
799 e_WriteLog('Writing network gameplay config', TMsgType.Notify);
801 config := TConfig.CreateFile(FileName);
803 config.WriteStr ('GameplayNetwork', 'Map', gnMap);
804 config.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode);
805 config.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit);
806 config.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit);
807 config.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives);
808 config.WriteInt ('GameplayNetwork', 'Players', gnPlayers);
809 config.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage);
810 config.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit);
811 config.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay);
812 config.WriteBool('GameplayNetwork', 'Monsters', gnMonsters);
813 config.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS);
815 config.SaveFile(FileName);
816 config.Free();
817 end;
819 procedure g_Options_Write_Net_Server(FileName: String);
820 var
821 config: TConfig;
822 begin
823 e_WriteLog('Writing server config', TMsgType.Notify);
825 config := TConfig.CreateFile(FileName);
827 config.WriteStr ('Server', 'Name', NetServerName);
828 config.WriteStr ('Server', 'Password', NetPassword);
829 config.WriteInt ('Server', 'Port', NetPort);
830 config.WriteInt ('Server', 'MaxClients', NetMaxClients);
831 config.WriteBool('Server', 'SyncWithMaster', NetUseMaster);
833 config.SaveFile(FileName);
834 config.Free();
835 end;
837 procedure g_Options_Write_Net_Client(FileName: String);
838 var
839 config: TConfig;
840 begin
841 e_WriteLog('Writing client config', TMsgType.Notify);
843 config := TConfig.CreateFile(FileName);
845 config.WriteStr('Client', 'LastIP', NetClientIP);
846 config.WriteInt('Client', 'LastPort', NetClientPort);
848 config.SaveFile(FileName);
849 config.Free();
850 end;
852 end.