1 (* Copyright (C) Doom 2D: Forever Developers
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.
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.
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/>.
16 {$INCLUDE ../shared/a_modes.inc}
22 g_language
, g_weapons
;
25 TPlayerControl
= record
36 KeyWeapon
: array [WP_FIRST
..WP_LAST
] of Word;
48 KeyWeapon2
: array [WP_FIRST
..WP_LAST
] of Word;
51 TGameControls
= record
59 GameControls
: TGameControls
;
60 P1Control
: TPlayerControl
;
61 P2Control
: TPlayerControl
;
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';
77 gGameControls
: TControls
;
80 gWinRealPosX
: Integer;
81 gWinRealPosY
: Integer;
85 gWinMaximized
: Boolean;
87 glLegacyNPOT
: Boolean;
88 gTextureFilter
: Boolean;
93 gMuteWhenInactive
: Boolean;
100 gDrawBackGround
: Boolean;
101 gShowMessages
: Boolean;
102 gRevertPlayers
: Boolean;
104 gAskLanguage
: Boolean;
111 gcTeamDamage
: Boolean;
112 gcAllowExit
: Boolean;
113 gcWeaponStay
: Boolean;
122 gnTeamDamage
: Boolean;
123 gnAllowExit
: Boolean;
124 gnWeaponStay
: Boolean;
127 gsSDLSampleRate
: Integer;
128 gsSDLBufferSize
: Integer;
130 gSFSFastMode
: Boolean;
131 gDefaultMegawadStart
: AnsiString;
132 gBerserkAutoswitch
: Boolean;
137 {$INCLUDE ../nogl/noGLuses.inc}
138 e_log
, e_input
, g_window
, g_sound
, g_gfx
, g_player
, Math
,
139 g_map
, g_net
, g_netmaster
, SysUtils
, CONFIG
, g_game
, g_main
, e_texture
,
140 g_items
, wadreader
, e_graphics
, g_touch
, SDL2
;
142 procedure g_Options_SetDefaultVideo
;
143 {$IF DEFINED(ANDROID)}
145 display
: PSDL_DisplayMode
;
148 {$IF DEFINED(ANDROID)}
149 (* On android set max screen size *)
150 SDL_GetCurrentDisplayMode(0, display
);
151 gScreenWidth
:= display
.w
;
152 gScreenHeight
:= display
.h
;
155 gWinMaximized
:= False;
156 gFullScreen
:= False; (* if True then rotation not allowed *)
159 gTextureFilter
:= True;
160 glLegacyNPOT
:= False;
162 (* On other systems use default 800x600 *)
164 gScreenHeight
:= 600;
167 gWinMaximized
:= False;
168 gFullScreen
:= False;
171 gTextureFilter
:= True;
172 glLegacyNPOT
:= False;
176 procedure g_Options_SetDefault();
185 gMuteWhenInactive
:= False;
186 gAnnouncer
:= ANNOUNCE_MEPLUS
;
187 gSoundEffectsDF
:= True;
188 gUseChatSounds
:= True;
189 gsSDLSampleRate
:= 44100;
190 gsSDLBufferSize
:= 2048;
192 g_Sound_SetupAllVolumes(gSoundLevel
, gMusicLevel
);
194 (* section GameControls *)
195 with gGameControls
.GameControls
do
197 TakeScreenshot
:= SDL_SCANCODE_F12
;
198 Stat
:= SDL_SCANCODE_TAB
;
199 Chat
:= SDL_SCANCODE_T
;
200 TeamChat
:= SDL_SCANCODE_Y
;
203 (* section Player1 *)
204 with gGameControls
.P1Control
do
206 KeyRight
:= SDL_SCANCODE_KP_6
;
207 KeyLeft
:= SDL_SCANCODE_KP_4
;
208 KeyUp
:= SDL_SCANCODE_KP_8
;
209 KeyDown
:= SDL_SCANCODE_KP_5
;
210 KeyFire
:= SDL_SCANCODE_SLASH
;
211 KeyJump
:= SDL_SCANCODE_RCTRL
;
212 KeyNextWeapon
:= SDL_SCANCODE_KP_9
;
213 KeyPrevWeapon
:= SDL_SCANCODE_KP_7
;
214 KeyOpen
:= SDL_SCANCODE_RSHIFT
;
215 KeyStrafe
:= SDL_SCANCODE_PERIOD
;
219 KeyWeapon
[i
] := SDL_SCANCODE_1
+ i (* 1, ..., 9, 0 *)
221 KeyWeapon
[10] := SDL_SCANCODE_MINUS
;
222 for i
:= 11 to High(KeyWeapon
) do
227 KeyRight2
:= VK_RIGHT
;
233 KeyNextWeapon2
:= VK_NEXT
;
234 KeyPrevWeapon2
:= VK_PREV
;
236 KeyStrafe2
:= VK_STRAFE
;
238 for i
:= 0 to High(KeyWeapon2
) do
240 KeyWeapon2
[i
] := VK_0
+ i
244 with gPlayer1Settings
do
247 Model
:= STD_PLAYER_MODEL
;
248 Color
.R
:= PLAYER1_DEF_COLOR
.R
;
249 Color
.G
:= PLAYER1_DEF_COLOR
.G
;
250 Color
.B
:= PLAYER1_DEF_COLOR
.B
;
254 (* section Player2 *)
255 with gGameControls
.P2Control
do
257 KeyRight
:= SDL_SCANCODE_D
;
258 KeyLeft
:= SDL_SCANCODE_A
;
259 KeyUp
:= SDL_SCANCODE_W
;
260 KeyDown
:= SDL_SCANCODE_S
;
261 KeyFire
:= SDL_SCANCODE_G
;
262 KeyJump
:= SDL_SCANCODE_SPACE
;
263 KeyNextWeapon
:= SDL_SCANCODE_E
;
264 KeyPrevWeapon
:= SDL_SCANCODE_Q
;
265 KeyOpen
:= SDL_SCANCODE_F
;
266 KeyStrafe
:= SDL_SCANCODE_LSHIFT
;
267 for i
:= 0 to High(KeyWeapon
) do
283 for i
:= 0 to High(KeyWeapon2
) do
289 with gPlayer2Settings
do
292 Model
:= STD_PLAYER_MODEL
;
293 Color
.R
:= PLAYER2_DEF_COLOR
.R
;
294 Color
.G
:= PLAYER2_DEF_COLOR
.G
;
295 Color
.B
:= PLAYER2_DEF_COLOR
.B
;
299 (* section Joysticks *)
300 for i
:= 0 to e_MaxJoys
- 1 do
302 e_JoystickDeadzones
[i
] := 8192
307 g_touch_fire
:= True;
308 g_touch_offset
:= 50;
309 g_touch_alt
:= False;
313 g_Shells_SetMax(300);
315 g_Corpses_SetMax(20);
317 ITEM_RESPAWNTIME
:= 60 * 36;
323 gDrawBackGround
:= True;
324 gShowMessages
:= True;
325 gRevertPlayers
:= False;
328 gSFSFastMode
:= False;
329 e_FastScreenshots
:= True;
330 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
331 gBerserkAutoswitch
:= True;
334 gAskLanguage
:= True;
335 gLanguage
:= LANGUAGE_ENGLISH
;
337 (* section GameplayCustom *)
339 gcGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
344 gcTeamDamage
:= False;
346 gcWeaponStay
:= False;
348 gcBotsVS
:= 'Everybody';
350 (* section GameplayNetwork *)
352 gnGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
357 gnTeamDamage
:= False;
359 gnWeaponStay
:= False;
361 gnBotsVS
:= 'Everybody';
363 (* section MasterServer *)
364 NetSlistIP
:= 'mpms.doom2d.org';
365 NetSlistPort
:= 25665;
366 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
369 NetServerName
:= 'Unnamed Server';
373 NetAllowRCON
:= False;
374 NetRCONPassword
:= 'default';
375 NetUseMaster
:= True;
378 NetMasterRate
:= 60000;
379 NetForwardPorts
:= False;
383 NetForcePlayerUpdate
:= False;
384 NetPredictSelf
:= True;
385 NetClientIP
:= '127.0.0.1';
386 NetClientPort
:= NetPort
;
389 procedure g_Options_Read(FileName
: String);
395 procedure ReadInteger (VAR v
: Integer; param
: String; minv
: Integer = Low(Integer); maxv
: Integer = High(Integer));
397 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
400 procedure ReadInteger (VAR v
: LongWord; param
: String; minv
: LongWord = Low(LongWord); maxv
: LongWord = High(LongWord)); overload
;
402 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
405 procedure ReadInteger (VAR v
: Word; param
: String; minv
: Word = Low(Word); maxv
: Word = High(Word)); overload
;
407 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
410 procedure ReadInteger (VAR v
: Byte; param
: String; minv
: Byte = Low(Byte); maxv
: Byte = High(Byte)); overload
;
412 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
415 procedure ReadBoolean (VAR v
: Boolean; param
: String);
417 v
:= config
.ReadBool(section
, param
, v
)
420 procedure ReadString (VAR v
: String; param
: String);
422 v
:= config
.ReadStr(section
, param
, v
)
426 gAskLanguage
:= True;
427 e_WriteLog('Reading config', TMsgType
.Notify
);
428 g_Options_SetDefault
;
430 if FileExists(FileName
) = False then
432 e_WriteLog('Config file '+FileName
+' not found', TMsgType
.Warning
);
433 g_Options_SetDefaultVideo
;
437 config
:= TConfig
.CreateFile(FileName
);
440 ReadInteger(gScreenWidth
, 'ScreenWidth', 0);
441 ReadInteger(gScreenHeight
, 'ScreenHeight', 0);
442 ReadInteger(gWinRealPosX
, 'WinPosX', 60);
443 ReadInteger(gWinRealPosY
, 'WinPosY', 60);
444 ReadBoolean(gFullScreen
, 'Fullscreen');
445 ReadBoolean(gWinMaximized
, 'Maximized');
446 ReadInteger(gBPP
, 'BPP', 0);
447 ReadInteger(gFreq
, 'Freq', 0);
448 ReadBoolean(gVSync
, 'VSync');
449 ReadBoolean(gTextureFilter
, 'TextureFilter');
450 ReadBoolean(glLegacyNPOT
, 'LegacyCompatible');
453 ReadBoolean(gNoSound
, 'NoSound');
454 ReadInteger(gSoundLevel
, 'SoundLevel', 0, 255);
455 ReadInteger(gMusicLevel
, 'MusicLevel', 0, 255);
456 ReadInteger(gMaxSimSounds
, 'MaxSimSounds', 2, 66);
457 ReadBoolean(gMuteWhenInactive
, 'MuteInactive');
458 ReadInteger(gAnnouncer
, 'Announcer', ANNOUNCE_NONE
, ANNOUNCE_ALL
);
459 ReadBoolean(gSoundEffectsDF
, 'SoundEffectsDF');
460 ReadBoolean(gUseChatSounds
, 'ChatSounds');
461 ReadInteger(gsSDLSampleRate
, 'SDLSampleRate', 11025, 96000);
462 ReadInteger(gsSDLBufferSize
, 'SDLBufferSize', 64, 16384);
464 section
:= 'GameControls';
465 with gGameControls
.GameControls
do
467 ReadInteger(TakeScreenshot
, 'TakeScreenshot');
468 ReadInteger(Stat
, 'Stat');
469 ReadInteger(Chat
, 'Chat');
470 ReadInteger(TeamChat
, 'TeamChat');
473 section
:= 'Player1';
474 with gGameControls
.P1Control
do
476 ReadInteger(KeyRight
, 'KeyRight');
477 ReadInteger(KeyLeft
, 'KeyLeft');
478 ReadInteger(KeyUp
, 'KeyUp');
479 ReadInteger(KeyDown
, 'KeyDown');
480 ReadInteger(KeyFire
, 'KeyFire');
481 ReadInteger(KeyJump
, 'KeyJump');
482 ReadInteger(KeyNextWeapon
, 'KeyNextWeapon');
483 ReadInteger(KeyPrevWeapon
, 'KeyPrevWeapon');
484 ReadInteger(KeyOpen
, 'KeyOpen');
485 ReadInteger(KeyStrafe
, 'KeyStrafe');
487 for i
:= 0 to High(KeyWeapon
) do
489 ReadInteger(KeyWeapon
[i
], 'KeyWeapon' + IntToStr(i
))
492 ReadInteger(KeyRight2
, 'KeyRight2');
493 ReadInteger(KeyLeft2
, 'KeyLeft2');
494 ReadInteger(KeyUp2
, 'KeyUp2');
495 ReadInteger(KeyDown2
, 'KeyDown2');
496 ReadInteger(KeyFire2
, 'KeyFire2');
497 ReadInteger(KeyJump2
, 'KeyJump2');
498 ReadInteger(KeyNextWeapon2
, 'KeyNextWeapon2');
499 ReadInteger(KeyPrevWeapon2
, 'KeyPrevWeapon2');
500 ReadInteger(KeyOpen2
, 'KeyOpen2');
501 ReadInteger(KeyStrafe2
, 'KeyStrafe2');
503 for i
:= 0 to High(KeyWeapon2
) do
505 ReadInteger(KeyWeapon2
[i
], 'KeyWeapon2' + IntToStr(i
))
509 section
:= 'Player1';
510 with gPlayer1Settings
do
512 ReadString(Name
, 'name');
513 ReadString(Model
, 'model');
514 ReadInteger(Color
.R
, 'red', 0, 255);
515 ReadInteger(Color
.G
, 'green', 0, 255);
516 ReadInteger(Color
.B
, 'blue', 0, 255);
517 ReadInteger(Team
, 'team');
518 if (Team
< TEAM_RED
) or (Team
> TEAM_BLUE
) then
522 section
:= 'Player2';
523 with gGameControls
.P2Control
do
525 ReadInteger(KeyRight
, 'KeyRight');
526 ReadInteger(KeyLeft
, 'KeyLeft');
527 ReadInteger(KeyUp
, 'KeyUp');
528 ReadInteger(KeyDown
, 'KeyDown');
529 ReadInteger(KeyFire
, 'KeyFire');
530 ReadInteger(KeyJump
, 'KeyJump');
531 ReadInteger(KeyNextWeapon
, 'KeyNextWeapon');
532 ReadInteger(KeyPrevWeapon
, 'KeyPrevWeapon');
533 ReadInteger(KeyOpen
, 'KeyOpen');
534 ReadInteger(KeyStrafe
, 'KeyStrafe');
536 for i
:= 0 to High(KeyWeapon
) do
538 ReadInteger(KeyWeapon
[i
], 'KeyWeapon' + IntToStr(i
))
541 ReadInteger(KeyRight2
, 'KeyRight2');
542 ReadInteger(KeyLeft2
, 'KeyLeft2');
543 ReadInteger(KeyUp2
, 'KeyUp2');
544 ReadInteger(KeyDown2
, 'KeyDown2');
545 ReadInteger(KeyFire2
, 'KeyFire2');
546 ReadInteger(KeyJump2
, 'KeyJump2');
547 ReadInteger(KeyNextWeapon2
, 'KeyNextWeapon2');
548 ReadInteger(KeyPrevWeapon2
, 'KeyPrevWeapon2');
549 ReadInteger(KeyOpen2
, 'KeyOpen2');
550 ReadInteger(KeyStrafe2
, 'KeyStrafe2');
552 for i
:= 0 to High(KeyWeapon2
) do
554 ReadInteger(KeyWeapon2
[i
], 'KeyWeapon2' + IntToStr(i
))
558 section
:= 'Player2';
559 with gPlayer2Settings
do
561 ReadString(Name
, 'name');
562 ReadString(Model
, 'model');
563 ReadInteger(Color
.R
, 'red', 0, 255);
564 ReadInteger(Color
.G
, 'green', 0, 255);
565 ReadInteger(Color
.B
, 'blue', 0, 255);
566 ReadInteger(Team
, 'team');
567 if (Team
< TEAM_RED
) or (Team
> TEAM_BLUE
) then
571 section
:= 'Joysticks';
572 for i
:= 0 to e_MaxJoys
- 1 do
574 ReadInteger(e_JoystickDeadzones
[i
], 'Deadzone' + IntToStr(i
))
578 i
:= Trunc(g_touch_size
* 10); ReadInteger(i
, 'Size', 0); g_touch_size
:= i
/ 10;
579 ReadBoolean(g_touch_fire
, 'Fire');
580 i
:= Round(g_touch_offset
); ReadInteger(i
, 'Offset', 0, 100); g_touch_offset
:= i
;
581 ReadBoolean(g_touch_alt
, 'Alt');
584 ReadInteger(i
, 'MaxParticles', 1000, 50000); g_GFX_SetMax(i
);
585 ReadInteger(i
, 'MaxShells', 300, 600); g_Shells_SetMax(i
);
586 ReadInteger(i
, 'MaxGibs', 150, 500); g_Gibs_SetMax(i
);
587 ReadInteger(i
, 'MaxCorpses', 20, 100); g_Corpses_SetMax(i
);
588 ReadInteger(i
, 'GibsCount');
594 else gGibsCount
:= 48;
596 i
:= ITEM_RESPAWNTIME
div 36; ReadInteger(i
, 'ItemRespawnTime', 0); ITEM_RESPAWNTIME
:= i
* 36;
597 ReadInteger(gBloodCount
, 'BloodCount', 0, 4);
598 ReadBoolean(gAdvBlood
, 'AdvancesBlood');
599 ReadBoolean(gAdvCorpses
, 'AdvancesCorpses');
600 ReadBoolean(gAdvGibs
, 'AdvancesGibs');
601 ReadInteger(gFlash
, 'Flash', 0, 2);
602 ReadBoolean(gDrawBackGround
, 'BackGround');
603 ReadBoolean(gShowMessages
, 'Messages');
604 ReadBoolean(gRevertPlayers
, 'RevertPlayers');
605 ReadInteger(gChatBubble
, 'ChatBubble', 0, 4);
606 ReadBoolean(gSFSDebug
, 'SFSDebug'); wadoptDebug
:= gSFSDebug
;
607 ReadBoolean(gSFSFastMode
, 'SFSFastMode'); wadoptFast
:= gSFSFastMode
;
608 ReadBoolean(e_FastScreenshots
, 'FastScreenshots');
609 ReadString(gDefaultMegawadStart
, 'DefaultMegawadStart');
610 ReadBoolean(gBerserkAutoswitch
, 'BerserkAutoswitching');
611 i
:= Trunc(g_dbg_scale
* 100); ReadInteger(i
, 'Scale', 100); g_dbg_scale
:= i
/ 100;
612 ReadString(gLanguage
, 'Language');
613 if (gLanguage
= LANGUAGE_RUSSIAN
) or (gLanguage
= LANGUAGE_ENGLISH
) then
614 gAskLanguage
:= False
616 gLanguage
:= LANGUAGE_ENGLISH
;
618 section
:= 'GameplayCustom';
619 ReadString(gcMap
, 'Map');
620 ReadString(gcGameMode
, 'GameMode');
621 ReadInteger(gcTimeLimit
, 'TimeLimit', 0, 65535);
622 ReadInteger(gcGoalLimit
, 'GoalLimit', 0, 65535);
623 ReadInteger(gcMaxLives
, 'MaxLives', 0, 255);
624 ReadInteger(gcPlayers
, 'Players', 0, 2);
625 ReadBoolean(gcTeamDamage
, 'TeamDamage');
626 ReadBoolean(gcAllowExit
, 'AllowExit');
627 ReadBoolean(gcWeaponStay
, 'WeaponStay');
628 ReadBoolean(gcMonsters
, 'Monsters');
629 ReadString(gcBotsVS
, 'BotsVS');
631 with gGameSettings
do
633 GameMode
:= g_Game_TextToMode(gcGameMode
);
634 if GameMode
= GM_NONE
then
636 if GameMode
= GM_SINGLE
then
638 TimeLimit
:= gcTimeLimit
;
639 GoalLimit
:= gcGoalLimit
;
640 MaxLives
:= gcMaxLives
;
644 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
;
646 Options
:= Options
or GAME_OPTION_ALLOWEXIT
;
648 Options
:= Options
or GAME_OPTION_WEAPONSTAY
;
650 Options
:= Options
or GAME_OPTION_MONSTERS
;
651 if gcBotsVS
= 'Everybody' then
652 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
653 if gcBotsVS
= 'Players' then
654 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
;
655 if gcBotsVS
= 'Monsters' then
656 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
;
659 section
:= 'GameplayNetwork';
660 ReadString(gnMap
, 'Map');
661 ReadString(gnGameMode
, 'GameMode');
662 ReadInteger(gnTimeLimit
, 'TimeLimit', 0, 65535);
663 ReadInteger(gnGoalLimit
, 'GoalLimit', 0, 65535);
664 ReadInteger(gnMaxLives
, 'MaxLives', 0, 255);
665 ReadInteger(gnPlayers
, 'Players', 0, 2);
666 ReadBoolean(gnTeamDamage
, 'TeamDamage');
667 ReadBoolean(gnAllowExit
, 'AllowExit');
668 ReadBoolean(gnWeaponStay
, 'WeaponStay');
669 ReadBoolean(gnMonsters
, 'Monsters');
670 ReadString(gnBotsVS
, 'BotsVS');
672 section
:= 'MasterServer';
673 ReadString(NetSlistIP
, 'IP');
674 ReadInteger(NetSlistPort
, 'Port', 0, 65535);
675 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
678 ReadString(NetServerName
, 'Name');
679 ReadString(NetPassword
, 'Password');
680 ReadInteger(NetPort
, 'Port', 0, 65535);
681 ReadInteger(NetMaxClients
, 'MaxClients', 0, NET_MAXCLIENTS
);
682 ReadBoolean(NetAllowRCON
, 'RCON');
683 ReadString(NetRCONPassword
, 'RCONPassword');
684 ReadBoolean(NetUseMaster
, 'SyncWithMaster');
685 ReadInteger(NetUpdateRate
, 'UpdateInterval', 0);
686 ReadInteger(NetRelupdRate
, 'ReliableUpdateInterval', 0);
687 ReadInteger(NetMasterRate
, 'MasterSyncInterval', 1);
688 ReadBoolean(NetForwardPorts
, 'ForwardPorts');
691 ReadInteger(NetInterpLevel
, 'InterpolationSteps', 0);
692 ReadBoolean(NetForcePlayerUpdate
, 'ForcePlayerUpdate');
693 ReadBoolean(NetPredictSelf
, 'PredictSelf');
694 ReadString(NetClientIP
, 'LastIP');
695 ReadInteger(NetClientPort
, 'LastPort', 0, 65535);
699 //if gTextureFilter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
702 procedure g_Options_Write(FileName
: String);
707 e_WriteLog('Writing config', TMsgType
.Notify
);
709 config
:= TConfig
.CreateFile(FileName
);
711 config
.WriteInt('Video', 'ScreenWidth', gScreenWidth
);
712 config
.WriteInt('Video', 'ScreenHeight', gScreenHeight
);
713 config
.WriteInt('Video', 'WinPosX', gWinRealPosX
);
714 config
.WriteInt('Video', 'WinPosY', gWinRealPosY
);
715 config
.WriteBool('Video', 'Fullscreen', gFullScreen
);
716 config
.WriteBool('Video', 'Maximized', gWinMaximized
);
717 config
.WriteInt('Video', 'BPP', gBPP
);
718 config
.WriteBool('Video', 'VSync', gVSync
);
719 config
.WriteBool('Video', 'TextureFilter', gTextureFilter
);
720 config
.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT
);
722 config
.WriteBool('Sound', 'NoSound', gNoSound
);
723 config
.WriteInt('Sound', 'SoundLevel', gSoundLevel
);
724 config
.WriteInt('Sound', 'MusicLevel', gMusicLevel
);
725 config
.WriteInt('Sound', 'MaxSimSounds', gMaxSimSounds
);
726 config
.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive
);
727 config
.WriteInt('Sound', 'Announcer', gAnnouncer
);
728 config
.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF
);
729 config
.WriteBool('Sound', 'ChatSounds', gUseChatSounds
);
730 config
.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate
);
731 config
.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize
);
733 with config
, gGameControls
.GameControls
do
735 WriteInt('GameControls', 'TakeScreenshot', TakeScreenshot
);
736 WriteInt('GameControls', 'Stat', Stat
);
737 WriteInt('GameControls', 'Chat', Chat
);
738 WriteInt('GameControls', 'TeamChat', TeamChat
);
741 with config
, gGameControls
.P1Control
, gPlayer1Settings
do
743 WriteInt('Player1', 'KeyRight', KeyRight
);
744 WriteInt('Player1', 'KeyLeft', KeyLeft
);
745 WriteInt('Player1', 'KeyUp', KeyUp
);
746 WriteInt('Player1', 'KeyDown', KeyDown
);
747 WriteInt('Player1', 'KeyFire', KeyFire
);
748 WriteInt('Player1', 'KeyJump', KeyJump
);
749 WriteInt('Player1', 'KeyNextWeapon', KeyNextWeapon
);
750 WriteInt('Player1', 'KeyPrevWeapon', KeyPrevWeapon
);
751 WriteInt('Player1', 'KeyOpen', KeyOpen
);
752 WriteInt('Player1', 'KeyStrafe', KeyStrafe
);
753 for i
:= 0 to High(KeyWeapon
) do
754 WriteInt('Player1', 'KeyWeapon' + IntToStr(i
), KeyWeapon
[i
]);
756 WriteInt('Player1', 'KeyRight2', KeyRight2
);
757 WriteInt('Player1', 'KeyLeft2', KeyLeft2
);
758 WriteInt('Player1', 'KeyUp2', KeyUp2
);
759 WriteInt('Player1', 'KeyDown2', KeyDown2
);
760 WriteInt('Player1', 'KeyFire2', KeyFire2
);
761 WriteInt('Player1', 'KeyJump2', KeyJump2
);
762 WriteInt('Player1', 'KeyNextWeapon2', KeyNextWeapon2
);
763 WriteInt('Player1', 'KeyPrevWeapon2', KeyPrevWeapon2
);
764 WriteInt('Player1', 'KeyOpen2', KeyOpen2
);
765 WriteInt('Player1', 'KeyStrafe2', KeyStrafe2
);
766 for i
:= 0 to High(KeyWeapon2
) do
767 WriteInt('Player1', 'KeyWeapon2' + IntToStr(i
), KeyWeapon2
[i
]);
769 WriteStr('Player1', 'Name', Name
);
770 WriteStr('Player1', 'model', Model
);
771 WriteInt('Player1', 'red', Color
.R
);
772 WriteInt('Player1', 'green', Color
.G
);
773 WriteInt('Player1', 'blue', Color
.B
);
774 WriteInt('Player1', 'team', Team
);
777 with config
, gGameControls
.P2Control
, gPlayer2Settings
do
779 WriteInt('Player2', 'KeyRight', KeyRight
);
780 WriteInt('Player2', 'KeyLeft', KeyLeft
);
781 WriteInt('Player2', 'KeyUp', KeyUp
);
782 WriteInt('Player2', 'KeyDown', KeyDown
);
783 WriteInt('Player2', 'KeyFire', KeyFire
);
784 WriteInt('Player2', 'KeyJump', KeyJump
);
785 WriteInt('Player2', 'KeyNextWeapon', KeyNextWeapon
);
786 WriteInt('Player2', 'KeyPrevWeapon', KeyPrevWeapon
);
787 WriteInt('Player2', 'KeyOpen', KeyOpen
);
788 WriteInt('Player2', 'KeyStrafe', KeyStrafe
);
789 for i
:= 0 to High(KeyWeapon
) do
790 WriteInt('Player2', 'KeyWeapon' + IntToStr(i
), KeyWeapon
[i
]);
792 WriteInt('Player2', 'KeyRight2', KeyRight2
);
793 WriteInt('Player2', 'KeyLeft2', KeyLeft2
);
794 WriteInt('Player2', 'KeyUp2', KeyUp2
);
795 WriteInt('Player2', 'KeyDown2', KeyDown2
);
796 WriteInt('Player2', 'KeyFire2', KeyFire2
);
797 WriteInt('Player2', 'KeyJump2', KeyJump2
);
798 WriteInt('Player2', 'KeyNextWeapon2', KeyNextWeapon2
);
799 WriteInt('Player2', 'KeyPrevWeapon2', KeyPrevWeapon2
);
800 WriteInt('Player2', 'KeyOpen2', KeyOpen2
);
801 WriteInt('Player2', 'KeyStrafe2', KeyStrafe2
);
802 for i
:= 0 to High(KeyWeapon2
) do
803 WriteInt('Player2', 'KeyWeapon2' + IntToStr(i
), KeyWeapon2
[i
]);
805 WriteStr('Player2', 'Name', Name
);
806 WriteStr('Player2', 'model', Model
);
807 WriteInt('Player2', 'red', Color
.R
);
808 WriteInt('Player2', 'green', Color
.G
);
809 WriteInt('Player2', 'blue', Color
.B
);
810 WriteInt('Player2', 'team', Team
);
813 for i
:= 0 to e_MaxJoys
-1 do
814 config
.WriteInt('Joysticks', 'Deadzone' + IntToStr(i
), e_JoystickDeadzones
[i
]);
816 config
.WriteInt('Touch', 'Size', Round(g_touch_size
* 10));
817 config
.WriteBool('Touch', 'Fire', g_touch_fire
);
818 config
.WriteInt('Touch', 'Offset', Round(g_touch_offset
));
819 config
.WriteBool('Touch', 'Alt', g_touch_alt
);
823 0: config
.WriteInt('Game', 'GibsCount', 0);
824 8: config
.WriteInt('Game', 'GibsCount', 1);
825 16: config
.WriteInt('Game', 'GibsCount', 2);
826 32: config
.WriteInt('Game', 'GibsCount', 3);
827 else config
.WriteInt('Game', 'GibsCount', 4);
830 config
.WriteInt('Game', 'ItemRespawnTime', ITEM_RESPAWNTIME
div 36);
831 config
.WriteInt('Game', 'MaxParticles', g_GFX_GetMax());
832 config
.WriteInt('Game', 'MaxShells', g_Shells_GetMax());
833 config
.WriteInt('Game', 'MaxGibs', g_Gibs_GetMax());
834 config
.WriteInt('Game', 'MaxCorpses', g_Corpses_GetMax());
835 config
.WriteInt('Game', 'BloodCount', gBloodCount
);
836 config
.WriteBool('Game', 'AdvancesBlood', gAdvBlood
);
837 config
.WriteBool('Game', 'AdvancesCorpses', gAdvCorpses
);
838 config
.WriteBool('Game', 'AdvancesGibs', gAdvGibs
);
839 config
.WriteInt('Game', 'Flash', gFlash
);
840 config
.WriteBool('Game', 'BackGround', gDrawBackGround
);
841 config
.WriteBool('Game', 'Messages', gShowMessages
);
842 config
.WriteBool('Game', 'RevertPlayers', gRevertPlayers
);
843 config
.WriteInt('Game', 'ChatBubble', gChatBubble
);
844 config
.WriteBool('Game', 'SFSDebug', gSFSDebug
);
845 config
.WriteBool('Game', 'SFSFastMode', gSFSFastMode
);
846 config
.WriteBool('Game', 'FastScreenshots', e_FastScreenshots
);
847 config
.WriteStr('Game', 'DefaultMegawadStart', gDefaultMegawadStart
);
848 config
.WriteBool('Game', 'BerserkAutoswitching', gBerserkAutoswitch
);
849 config
.WriteInt('Game', 'Scale', Round(g_dbg_scale
* 100));
851 config
.WriteStr ('GameplayCustom', 'Map', gcMap
);
852 config
.WriteStr ('GameplayCustom', 'GameMode', gcGameMode
);
853 config
.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit
);
854 config
.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit
);
855 config
.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives
);
856 config
.WriteInt ('GameplayCustom', 'Players', gcPlayers
);
857 config
.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage
);
858 config
.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit
);
859 config
.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay
);
860 config
.WriteBool('GameplayCustom', 'Monsters', gcMonsters
);
861 config
.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS
);
863 config
.WriteStr ('GameplayNetwork', 'Map', gnMap
);
864 config
.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode
);
865 config
.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit
);
866 config
.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit
);
867 config
.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives
);
868 config
.WriteInt ('GameplayNetwork', 'Players', gnPlayers
);
869 config
.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage
);
870 config
.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit
);
871 config
.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay
);
872 config
.WriteBool('GameplayNetwork', 'Monsters', gnMonsters
);
873 config
.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS
);
875 config
.WriteStr('MasterServer', 'IP', NetSlistIP
);
876 config
.WriteInt('MasterServer', 'Port', NetSlistPort
);
878 config
.WriteStr ('Server', 'Name', NetServerName
);
879 config
.WriteStr ('Server', 'Password', NetPassword
);
880 config
.WriteInt ('Server', 'Port', NetPort
);
881 config
.WriteInt ('Server', 'MaxClients', NetMaxClients
);
882 config
.WriteBool('Server', 'RCON', NetAllowRCON
);
883 config
.WriteStr ('Server', 'RCONPassword', NetRCONPassword
);
884 config
.WriteBool('Server', 'SyncWithMaster', NetUseMaster
);
885 config
.WriteBool('Server', 'ForwardPorts', NetForwardPorts
);
886 config
.WriteInt ('Server', 'UpdateInterval', NetUpdateRate
);
887 config
.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate
);
888 config
.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate
);
890 config
.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel
);
891 config
.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate
);
892 config
.WriteBool ('Client', 'PredictSelf', NetPredictSelf
);
893 config
.WriteStr ('Client', 'LastIP', NetClientIP
);
894 config
.WriteInt ('Client', 'LastPort', NetClientPort
);
896 config
.SaveFile(FileName
);
900 procedure g_Options_Write_Language(FileName
: String);
904 e_WriteLog('Writing language config', TMsgType
.Notify
);
906 config
:= TConfig
.CreateFile(FileName
);
907 config
.WriteStr('Game', 'Language', gLanguage
);
908 config
.SaveFile(FileName
);
912 procedure g_Options_Write_Video(FileName
: String);
917 e_WriteLog('Writing resolution to config', TMsgType
.Notify
);
919 config
:= TConfig
.CreateFile(FileName
);
921 if gWinMaximized
and (not gFullscreen
) then
931 e_LogWritefln(' (ws=%dx%d) (ss=%dx%d)', [gWinSizeX
, gWinSizeY
, gScreenWidth
, gScreenHeight
]);
933 config
.WriteInt('Video', 'ScreenWidth', sW
);
934 config
.WriteInt('Video', 'ScreenHeight', sH
);
935 config
.WriteInt('Video', 'WinPosX', gWinRealPosX
);
936 config
.WriteInt('Video', 'WinPosY', gWinRealPosY
);
937 config
.WriteBool('Video', 'Fullscreen', gFullscreen
);
938 config
.WriteBool('Video', 'Maximized', gWinMaximized
);
940 config
.SaveFile(FileName
);
944 procedure g_Options_Write_Gameplay_Custom(FileName
: String);
948 e_WriteLog('Writing custom gameplay config', TMsgType
.Notify
);
950 config
:= TConfig
.CreateFile(FileName
);
952 config
.WriteStr ('GameplayCustom', 'Map', gcMap
);
953 config
.WriteStr ('GameplayCustom', 'GameMode', gcGameMode
);
954 config
.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit
);
955 config
.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit
);
956 config
.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives
);
957 config
.WriteInt ('GameplayCustom', 'Players', gcPlayers
);
958 config
.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage
);
959 config
.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit
);
960 config
.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay
);
961 config
.WriteBool('GameplayCustom', 'Monsters', gcMonsters
);
962 config
.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS
);
964 config
.SaveFile(FileName
);
968 procedure g_Options_Write_Gameplay_Net(FileName
: String);
972 e_WriteLog('Writing network gameplay config', TMsgType
.Notify
);
974 config
:= TConfig
.CreateFile(FileName
);
976 config
.WriteStr ('GameplayNetwork', 'Map', gnMap
);
977 config
.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode
);
978 config
.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit
);
979 config
.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit
);
980 config
.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives
);
981 config
.WriteInt ('GameplayNetwork', 'Players', gnPlayers
);
982 config
.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage
);
983 config
.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit
);
984 config
.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay
);
985 config
.WriteBool('GameplayNetwork', 'Monsters', gnMonsters
);
986 config
.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS
);
988 config
.SaveFile(FileName
);
992 procedure g_Options_Write_Net_Server(FileName
: String);
996 e_WriteLog('Writing server config', TMsgType
.Notify
);
998 config
:= TConfig
.CreateFile(FileName
);
1000 config
.WriteStr ('Server', 'Name', NetServerName
);
1001 config
.WriteStr ('Server', 'Password', NetPassword
);
1002 config
.WriteInt ('Server', 'Port', NetPort
);
1003 config
.WriteInt ('Server', 'MaxClients', NetMaxClients
);
1004 config
.WriteBool('Server', 'SyncWithMaster', NetUseMaster
);
1005 config
.WriteBool('Server', 'ForwardPorts', NetForwardPorts
);
1007 config
.SaveFile(FileName
);
1011 procedure g_Options_Write_Net_Client(FileName
: String);
1015 e_WriteLog('Writing client config', TMsgType
.Notify
);
1017 config
:= TConfig
.CreateFile(FileName
);
1019 config
.WriteStr('Client', 'LastIP', NetClientIP
);
1020 config
.WriteInt('Client', 'LastPort', NetClientPort
);
1022 config
.SaveFile(FileName
);