54acb699e1be8cecfc7e402a00589f8895e1d97b
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;
142 e_log
, e_input
, g_window
, g_sound
, g_gfx
, g_player
, Math
,
143 g_map
, g_net
, g_netmaster
, SysUtils
, CONFIG
, g_game
, g_main
, e_texture
,
144 g_items
, wadreader
, e_graphics
, g_touch
, SDL2
;
146 procedure g_Options_SetDefaultVideo
;
147 {$IF DEFINED(ANDROID)}
149 display
: PSDL_DisplayMode
;
152 {$IF DEFINED(ANDROID)}
153 (* On android set max screen size *)
154 SDL_GetCurrentDisplayMode(0, display
);
155 gScreenWidth
:= display
.w
;
156 gScreenHeight
:= display
.h
;
159 gWinMaximized
:= False;
160 gFullScreen
:= False; (* if True then rotation not allowed *)
163 gTextureFilter
:= True;
164 glLegacyNPOT
:= False;
166 (* On other systems use default 800x600 *)
168 gScreenHeight
:= 600;
171 gWinMaximized
:= False;
172 gFullScreen
:= False;
175 gTextureFilter
:= True;
176 glLegacyNPOT
:= False;
180 procedure g_Options_SetDefault();
189 gMuteWhenInactive
:= False;
190 gAnnouncer
:= ANNOUNCE_MEPLUS
;
191 gSoundEffectsDF
:= True;
192 gUseChatSounds
:= True;
193 gsSDLSampleRate
:= 44100;
194 gsSDLBufferSize
:= 2048;
196 g_Sound_SetupAllVolumes(gSoundLevel
, gMusicLevel
);
198 (* section GameControls *)
199 with gGameControls
.GameControls
do
201 TakeScreenshot
:= SDL_SCANCODE_F12
;
202 Stat
:= SDL_SCANCODE_TAB
;
203 Chat
:= SDL_SCANCODE_T
;
204 TeamChat
:= SDL_SCANCODE_Y
;
207 (* section Player1 *)
208 with gGameControls
.P1Control
do
210 KeyRight
:= SDL_SCANCODE_KP_6
;
211 KeyLeft
:= SDL_SCANCODE_KP_4
;
212 KeyUp
:= SDL_SCANCODE_KP_8
;
213 KeyDown
:= SDL_SCANCODE_KP_5
;
214 KeyFire
:= SDL_SCANCODE_SLASH
;
215 KeyJump
:= SDL_SCANCODE_RCTRL
;
216 KeyNextWeapon
:= SDL_SCANCODE_KP_9
;
217 KeyPrevWeapon
:= SDL_SCANCODE_KP_7
;
218 KeyOpen
:= SDL_SCANCODE_RSHIFT
;
219 KeyStrafe
:= SDL_SCANCODE_PERIOD
;
223 KeyWeapon
[i
] := SDL_SCANCODE_1
+ i (* 1, ..., 9, 0 *)
225 KeyWeapon
[10] := SDL_SCANCODE_MINUS
;
226 for i
:= 11 to High(KeyWeapon
) do
231 KeyRight2
:= VK_RIGHT
;
237 KeyNextWeapon2
:= VK_NEXT
;
238 KeyPrevWeapon2
:= VK_PREV
;
240 KeyStrafe2
:= VK_STRAFE
;
242 for i
:= 0 to High(KeyWeapon2
) do
244 KeyWeapon2
[i
] := VK_0
+ i
248 with gPlayer1Settings
do
251 Model
:= STD_PLAYER_MODEL
;
252 Color
.R
:= PLAYER1_DEF_COLOR
.R
;
253 Color
.G
:= PLAYER1_DEF_COLOR
.G
;
254 Color
.B
:= PLAYER1_DEF_COLOR
.B
;
258 (* section Player2 *)
259 with gGameControls
.P2Control
do
261 KeyRight
:= SDL_SCANCODE_D
;
262 KeyLeft
:= SDL_SCANCODE_A
;
263 KeyUp
:= SDL_SCANCODE_W
;
264 KeyDown
:= SDL_SCANCODE_S
;
265 KeyFire
:= SDL_SCANCODE_G
;
266 KeyJump
:= SDL_SCANCODE_SPACE
;
267 KeyNextWeapon
:= SDL_SCANCODE_E
;
268 KeyPrevWeapon
:= SDL_SCANCODE_Q
;
269 KeyOpen
:= SDL_SCANCODE_F
;
270 KeyStrafe
:= SDL_SCANCODE_LSHIFT
;
271 for i
:= 0 to High(KeyWeapon
) do
287 for i
:= 0 to High(KeyWeapon2
) do
293 with gPlayer2Settings
do
296 Model
:= STD_PLAYER_MODEL
;
297 Color
.R
:= PLAYER2_DEF_COLOR
.R
;
298 Color
.G
:= PLAYER2_DEF_COLOR
.G
;
299 Color
.B
:= PLAYER2_DEF_COLOR
.B
;
303 (* section Joysticks *)
304 for i
:= 0 to e_MaxJoys
- 1 do
306 e_JoystickDeadzones
[i
] := 8192
311 g_touch_fire
:= True;
312 g_touch_offset
:= 50;
313 g_touch_alt
:= False;
317 g_Shells_SetMax(300);
319 g_Corpses_SetMax(20);
321 ITEM_RESPAWNTIME
:= 60 * 36;
327 gDrawBackGround
:= True;
328 gShowMessages
:= True;
329 gRevertPlayers
:= False;
332 gSFSFastMode
:= False;
333 e_FastScreenshots
:= True;
334 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
335 gBerserkAutoswitch
:= True;
338 gAskLanguage
:= True;
339 gLanguage
:= LANGUAGE_ENGLISH
;
341 (* section GameplayCustom *)
343 gcGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
348 gcTeamDamage
:= False;
350 gcWeaponStay
:= False;
352 gcBotsVS
:= 'Everybody';
354 (* section GameplayNetwork *)
356 gnGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
361 gnTeamDamage
:= False;
363 gnWeaponStay
:= False;
365 gnBotsVS
:= 'Everybody';
367 (* section MasterServer *)
368 NetSlistIP
:= 'mpms.doom2d.org';
369 NetSlistPort
:= 25665;
370 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
373 NetServerName
:= 'Unnamed Server';
377 NetAllowRCON
:= False;
378 NetRCONPassword
:= 'default';
379 NetUseMaster
:= True;
382 NetMasterRate
:= 60000;
383 NetForwardPorts
:= False;
387 NetForcePlayerUpdate
:= False;
388 NetPredictSelf
:= True;
389 NetClientIP
:= '127.0.0.1';
390 NetClientPort
:= NetPort
;
393 procedure g_Options_Read(FileName
: String);
399 procedure ReadInteger (VAR v
: Integer; param
: String; minv
: Integer = Low(Integer); maxv
: Integer = High(Integer));
401 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
404 procedure ReadInteger (VAR v
: LongWord; param
: String; minv
: LongWord = Low(LongWord); maxv
: LongWord = High(LongWord)); overload
;
406 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
409 procedure ReadInteger (VAR v
: Word; param
: String; minv
: Word = Low(Word); maxv
: Word = High(Word)); overload
;
411 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
414 procedure ReadInteger (VAR v
: Byte; param
: String; minv
: Byte = Low(Byte); maxv
: Byte = High(Byte)); overload
;
416 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
419 procedure ReadBoolean (VAR v
: Boolean; param
: String);
421 v
:= config
.ReadBool(section
, param
, v
)
424 procedure ReadString (VAR v
: String; param
: String);
426 v
:= config
.ReadStr(section
, param
, v
)
430 gAskLanguage
:= True;
431 e_WriteLog('Reading config', TMsgType
.Notify
);
432 g_Options_SetDefault
;
434 if FileExists(FileName
) = False then
436 e_WriteLog('Config file '+FileName
+' not found', TMsgType
.Warning
);
437 g_Options_SetDefaultVideo
;
441 config
:= TConfig
.CreateFile(FileName
);
444 ReadInteger(gScreenWidth
, 'ScreenWidth', 0);
445 ReadInteger(gScreenHeight
, 'ScreenHeight', 0);
446 ReadInteger(gWinRealPosX
, 'WinPosX', 60);
447 ReadInteger(gWinRealPosY
, 'WinPosY', 60);
448 ReadBoolean(gFullScreen
, 'Fullscreen');
449 ReadBoolean(gWinMaximized
, 'Maximized');
450 ReadInteger(gBPP
, 'BPP', 0);
451 ReadInteger(gFreq
, 'Freq', 0);
452 ReadBoolean(gVSync
, 'VSync');
453 ReadBoolean(gTextureFilter
, 'TextureFilter');
454 ReadBoolean(glLegacyNPOT
, 'LegacyCompatible');
457 ReadBoolean(gNoSound
, 'NoSound');
458 ReadInteger(gSoundLevel
, 'SoundLevel', 0, 255);
459 ReadInteger(gMusicLevel
, 'MusicLevel', 0, 255);
460 ReadInteger(gMaxSimSounds
, 'MaxSimSounds', 2, 66);
461 ReadBoolean(gMuteWhenInactive
, 'MuteInactive');
462 ReadInteger(gAnnouncer
, 'Announcer', ANNOUNCE_NONE
, ANNOUNCE_ALL
);
463 ReadBoolean(gSoundEffectsDF
, 'SoundEffectsDF');
464 ReadBoolean(gUseChatSounds
, 'ChatSounds');
465 ReadInteger(gsSDLSampleRate
, 'SDLSampleRate', 11025, 96000);
466 ReadInteger(gsSDLBufferSize
, 'SDLBufferSize', 64, 16384);
468 section
:= 'GameControls';
469 with gGameControls
.GameControls
do
471 ReadInteger(TakeScreenshot
, 'TakeScreenshot');
472 ReadInteger(Stat
, 'Stat');
473 ReadInteger(Chat
, 'Chat');
474 ReadInteger(TeamChat
, 'TeamChat');
477 section
:= 'Player1';
478 with gGameControls
.P1Control
do
480 ReadInteger(KeyRight
, 'KeyRight');
481 ReadInteger(KeyLeft
, 'KeyLeft');
482 ReadInteger(KeyUp
, 'KeyUp');
483 ReadInteger(KeyDown
, 'KeyDown');
484 ReadInteger(KeyFire
, 'KeyFire');
485 ReadInteger(KeyJump
, 'KeyJump');
486 ReadInteger(KeyNextWeapon
, 'KeyNextWeapon');
487 ReadInteger(KeyPrevWeapon
, 'KeyPrevWeapon');
488 ReadInteger(KeyOpen
, 'KeyOpen');
489 ReadInteger(KeyStrafe
, 'KeyStrafe');
491 for i
:= 0 to High(KeyWeapon
) do
493 ReadInteger(KeyWeapon
[i
], 'KeyWeapon' + IntToStr(i
))
496 ReadInteger(KeyRight2
, 'KeyRight2');
497 ReadInteger(KeyLeft2
, 'KeyLeft2');
498 ReadInteger(KeyUp2
, 'KeyUp2');
499 ReadInteger(KeyDown2
, 'KeyDown2');
500 ReadInteger(KeyFire2
, 'KeyFire2');
501 ReadInteger(KeyJump2
, 'KeyJump2');
502 ReadInteger(KeyNextWeapon2
, 'KeyNextWeapon2');
503 ReadInteger(KeyPrevWeapon2
, 'KeyPrevWeapon2');
504 ReadInteger(KeyOpen2
, 'KeyOpen2');
505 ReadInteger(KeyStrafe2
, 'KeyStrafe2');
507 for i
:= 0 to High(KeyWeapon2
) do
509 ReadInteger(KeyWeapon2
[i
], 'KeyWeapon2' + IntToStr(i
))
513 section
:= 'Player1';
514 with gPlayer1Settings
do
516 ReadString(Name
, 'name');
517 ReadString(Model
, 'model');
518 ReadInteger(Color
.R
, 'red', 0, 255);
519 ReadInteger(Color
.G
, 'green', 0, 255);
520 ReadInteger(Color
.B
, 'blue', 0, 255);
521 ReadInteger(Team
, 'team');
522 if (Team
< TEAM_RED
) or (Team
> TEAM_BLUE
) then
526 section
:= 'Player2';
527 with gGameControls
.P2Control
do
529 ReadInteger(KeyRight
, 'KeyRight');
530 ReadInteger(KeyLeft
, 'KeyLeft');
531 ReadInteger(KeyUp
, 'KeyUp');
532 ReadInteger(KeyDown
, 'KeyDown');
533 ReadInteger(KeyFire
, 'KeyFire');
534 ReadInteger(KeyJump
, 'KeyJump');
535 ReadInteger(KeyNextWeapon
, 'KeyNextWeapon');
536 ReadInteger(KeyPrevWeapon
, 'KeyPrevWeapon');
537 ReadInteger(KeyOpen
, 'KeyOpen');
538 ReadInteger(KeyStrafe
, 'KeyStrafe');
540 for i
:= 0 to High(KeyWeapon
) do
542 ReadInteger(KeyWeapon
[i
], 'KeyWeapon' + IntToStr(i
))
545 ReadInteger(KeyRight2
, 'KeyRight2');
546 ReadInteger(KeyLeft2
, 'KeyLeft2');
547 ReadInteger(KeyUp2
, 'KeyUp2');
548 ReadInteger(KeyDown2
, 'KeyDown2');
549 ReadInteger(KeyFire2
, 'KeyFire2');
550 ReadInteger(KeyJump2
, 'KeyJump2');
551 ReadInteger(KeyNextWeapon2
, 'KeyNextWeapon2');
552 ReadInteger(KeyPrevWeapon2
, 'KeyPrevWeapon2');
553 ReadInteger(KeyOpen2
, 'KeyOpen2');
554 ReadInteger(KeyStrafe2
, 'KeyStrafe2');
556 for i
:= 0 to High(KeyWeapon2
) do
558 ReadInteger(KeyWeapon2
[i
], 'KeyWeapon2' + IntToStr(i
))
562 section
:= 'Player2';
563 with gPlayer2Settings
do
565 ReadString(Name
, 'name');
566 ReadString(Model
, 'model');
567 ReadInteger(Color
.R
, 'red', 0, 255);
568 ReadInteger(Color
.G
, 'green', 0, 255);
569 ReadInteger(Color
.B
, 'blue', 0, 255);
570 ReadInteger(Team
, 'team');
571 if (Team
< TEAM_RED
) or (Team
> TEAM_BLUE
) then
575 section
:= 'Joysticks';
576 for i
:= 0 to e_MaxJoys
- 1 do
578 ReadInteger(e_JoystickDeadzones
[i
], 'Deadzone' + IntToStr(i
))
582 i
:= Trunc(g_touch_size
* 10); ReadInteger(i
, 'Size', 0); g_touch_size
:= i
/ 10;
583 ReadBoolean(g_touch_fire
, 'Fire');
584 i
:= Round(g_touch_offset
); ReadInteger(i
, 'Offset', 0, 100); g_touch_offset
:= i
;
585 ReadBoolean(g_touch_alt
, 'Alt');
588 ReadInteger(i
, 'MaxParticles', 1000, 50000); g_GFX_SetMax(i
);
589 ReadInteger(i
, 'MaxShells', 300, 600); g_Shells_SetMax(i
);
590 ReadInteger(i
, 'MaxGibs', 150, 500); g_Gibs_SetMax(i
);
591 ReadInteger(i
, 'MaxCorpses', 20, 100); g_Corpses_SetMax(i
);
592 ReadInteger(i
, 'GibsCount');
598 else gGibsCount
:= 48;
600 i
:= ITEM_RESPAWNTIME
div 36; ReadInteger(i
, 'ItemRespawnTime', 0); ITEM_RESPAWNTIME
:= i
* 36;
601 ReadInteger(gBloodCount
, 'BloodCount', 0, 4);
602 ReadBoolean(gAdvBlood
, 'AdvancesBlood');
603 ReadBoolean(gAdvCorpses
, 'AdvancesCorpses');
604 ReadBoolean(gAdvGibs
, 'AdvancesGibs');
605 ReadInteger(gFlash
, 'Flash', 0, 2);
606 ReadBoolean(gDrawBackGround
, 'BackGround');
607 ReadBoolean(gShowMessages
, 'Messages');
608 ReadBoolean(gRevertPlayers
, 'RevertPlayers');
609 ReadInteger(gChatBubble
, 'ChatBubble', 0, 4);
610 ReadBoolean(gSFSDebug
, 'SFSDebug'); wadoptDebug
:= gSFSDebug
;
611 ReadBoolean(gSFSFastMode
, 'SFSFastMode'); wadoptFast
:= gSFSFastMode
;
612 ReadBoolean(e_FastScreenshots
, 'FastScreenshots');
613 ReadString(gDefaultMegawadStart
, 'DefaultMegawadStart');
614 ReadBoolean(gBerserkAutoswitch
, 'BerserkAutoswitching');
615 i
:= Trunc(g_dbg_scale
* 100); ReadInteger(i
, 'Scale', 100); g_dbg_scale
:= i
/ 100;
616 ReadString(gLanguage
, 'Language');
617 if (gLanguage
= LANGUAGE_RUSSIAN
) or (gLanguage
= LANGUAGE_ENGLISH
) then
618 gAskLanguage
:= False
620 gLanguage
:= LANGUAGE_ENGLISH
;
622 section
:= 'GameplayCustom';
623 ReadString(gcMap
, 'Map');
624 ReadString(gcGameMode
, 'GameMode');
625 ReadInteger(gcTimeLimit
, 'TimeLimit', 0, 65535);
626 ReadInteger(gcGoalLimit
, 'GoalLimit', 0, 65535);
627 ReadInteger(gcMaxLives
, 'MaxLives', 0, 255);
628 ReadInteger(gcPlayers
, 'Players', 0, 2);
629 ReadBoolean(gcTeamDamage
, 'TeamDamage');
630 ReadBoolean(gcAllowExit
, 'AllowExit');
631 ReadBoolean(gcWeaponStay
, 'WeaponStay');
632 ReadBoolean(gcMonsters
, 'Monsters');
633 ReadString(gcBotsVS
, 'BotsVS');
635 with gGameSettings
do
637 GameMode
:= g_Game_TextToMode(gcGameMode
);
638 if GameMode
= GM_NONE
then
640 if GameMode
= GM_SINGLE
then
642 TimeLimit
:= gcTimeLimit
;
643 GoalLimit
:= gcGoalLimit
;
644 MaxLives
:= gcMaxLives
;
648 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
;
650 Options
:= Options
or GAME_OPTION_ALLOWEXIT
;
652 Options
:= Options
or GAME_OPTION_WEAPONSTAY
;
654 Options
:= Options
or GAME_OPTION_MONSTERS
;
655 if gcBotsVS
= 'Everybody' then
656 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
657 if gcBotsVS
= 'Players' then
658 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
;
659 if gcBotsVS
= 'Monsters' then
660 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
;
663 section
:= 'GameplayNetwork';
664 ReadString(gnMap
, 'Map');
665 ReadString(gnGameMode
, 'GameMode');
666 ReadInteger(gnTimeLimit
, 'TimeLimit', 0, 65535);
667 ReadInteger(gnGoalLimit
, 'GoalLimit', 0, 65535);
668 ReadInteger(gnMaxLives
, 'MaxLives', 0, 255);
669 ReadInteger(gnPlayers
, 'Players', 0, 2);
670 ReadBoolean(gnTeamDamage
, 'TeamDamage');
671 ReadBoolean(gnAllowExit
, 'AllowExit');
672 ReadBoolean(gnWeaponStay
, 'WeaponStay');
673 ReadBoolean(gnMonsters
, 'Monsters');
674 ReadString(gnBotsVS
, 'BotsVS');
676 section
:= 'MasterServer';
677 ReadString(NetSlistIP
, 'IP');
678 ReadInteger(NetSlistPort
, 'Port', 0, 65535);
679 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
682 ReadString(NetServerName
, 'Name');
683 ReadString(NetPassword
, 'Password');
684 ReadInteger(NetPort
, 'Port', 0, 65535);
685 ReadInteger(NetMaxClients
, 'MaxClients', 0, NET_MAXCLIENTS
);
686 ReadBoolean(NetAllowRCON
, 'RCON');
687 ReadString(NetRCONPassword
, 'RCONPassword');
688 ReadBoolean(NetUseMaster
, 'SyncWithMaster');
689 ReadInteger(NetUpdateRate
, 'UpdateInterval', 0);
690 ReadInteger(NetRelupdRate
, 'ReliableUpdateInterval', 0);
691 ReadInteger(NetMasterRate
, 'MasterSyncInterval', 1);
692 ReadBoolean(NetForwardPorts
, 'ForwardPorts');
695 ReadInteger(NetInterpLevel
, 'InterpolationSteps', 0);
696 ReadBoolean(NetForcePlayerUpdate
, 'ForcePlayerUpdate');
697 ReadBoolean(NetPredictSelf
, 'PredictSelf');
698 ReadString(NetClientIP
, 'LastIP');
699 ReadInteger(NetClientPort
, 'LastPort', 0, 65535);
703 //if gTextureFilter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
706 procedure g_Options_Write(FileName
: String);
711 e_WriteLog('Writing config', TMsgType
.Notify
);
713 config
:= TConfig
.CreateFile(FileName
);
715 config
.WriteInt('Video', 'ScreenWidth', gScreenWidth
);
716 config
.WriteInt('Video', 'ScreenHeight', gScreenHeight
);
717 config
.WriteInt('Video', 'WinPosX', gWinRealPosX
);
718 config
.WriteInt('Video', 'WinPosY', gWinRealPosY
);
719 config
.WriteBool('Video', 'Fullscreen', gFullScreen
);
720 config
.WriteBool('Video', 'Maximized', gWinMaximized
);
721 config
.WriteInt('Video', 'BPP', gBPP
);
722 config
.WriteBool('Video', 'VSync', gVSync
);
723 config
.WriteBool('Video', 'TextureFilter', gTextureFilter
);
724 config
.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT
);
726 config
.WriteBool('Sound', 'NoSound', gNoSound
);
727 config
.WriteInt('Sound', 'SoundLevel', gSoundLevel
);
728 config
.WriteInt('Sound', 'MusicLevel', gMusicLevel
);
729 config
.WriteInt('Sound', 'MaxSimSounds', gMaxSimSounds
);
730 config
.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive
);
731 config
.WriteInt('Sound', 'Announcer', gAnnouncer
);
732 config
.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF
);
733 config
.WriteBool('Sound', 'ChatSounds', gUseChatSounds
);
734 config
.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate
);
735 config
.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize
);
737 with config
, gGameControls
.GameControls
do
739 WriteInt('GameControls', 'TakeScreenshot', TakeScreenshot
);
740 WriteInt('GameControls', 'Stat', Stat
);
741 WriteInt('GameControls', 'Chat', Chat
);
742 WriteInt('GameControls', 'TeamChat', TeamChat
);
745 with config
, gGameControls
.P1Control
, gPlayer1Settings
do
747 WriteInt('Player1', 'KeyRight', KeyRight
);
748 WriteInt('Player1', 'KeyLeft', KeyLeft
);
749 WriteInt('Player1', 'KeyUp', KeyUp
);
750 WriteInt('Player1', 'KeyDown', KeyDown
);
751 WriteInt('Player1', 'KeyFire', KeyFire
);
752 WriteInt('Player1', 'KeyJump', KeyJump
);
753 WriteInt('Player1', 'KeyNextWeapon', KeyNextWeapon
);
754 WriteInt('Player1', 'KeyPrevWeapon', KeyPrevWeapon
);
755 WriteInt('Player1', 'KeyOpen', KeyOpen
);
756 WriteInt('Player1', 'KeyStrafe', KeyStrafe
);
757 for i
:= 0 to High(KeyWeapon
) do
758 WriteInt('Player1', 'KeyWeapon' + IntToStr(i
), KeyWeapon
[i
]);
760 WriteInt('Player1', 'KeyRight2', KeyRight2
);
761 WriteInt('Player1', 'KeyLeft2', KeyLeft2
);
762 WriteInt('Player1', 'KeyUp2', KeyUp2
);
763 WriteInt('Player1', 'KeyDown2', KeyDown2
);
764 WriteInt('Player1', 'KeyFire2', KeyFire2
);
765 WriteInt('Player1', 'KeyJump2', KeyJump2
);
766 WriteInt('Player1', 'KeyNextWeapon2', KeyNextWeapon2
);
767 WriteInt('Player1', 'KeyPrevWeapon2', KeyPrevWeapon2
);
768 WriteInt('Player1', 'KeyOpen2', KeyOpen2
);
769 WriteInt('Player1', 'KeyStrafe2', KeyStrafe2
);
770 for i
:= 0 to High(KeyWeapon2
) do
771 WriteInt('Player1', 'KeyWeapon2' + IntToStr(i
), KeyWeapon2
[i
]);
773 WriteStr('Player1', 'Name', Name
);
774 WriteStr('Player1', 'model', Model
);
775 WriteInt('Player1', 'red', Color
.R
);
776 WriteInt('Player1', 'green', Color
.G
);
777 WriteInt('Player1', 'blue', Color
.B
);
778 WriteInt('Player1', 'team', Team
);
781 with config
, gGameControls
.P2Control
, gPlayer2Settings
do
783 WriteInt('Player2', 'KeyRight', KeyRight
);
784 WriteInt('Player2', 'KeyLeft', KeyLeft
);
785 WriteInt('Player2', 'KeyUp', KeyUp
);
786 WriteInt('Player2', 'KeyDown', KeyDown
);
787 WriteInt('Player2', 'KeyFire', KeyFire
);
788 WriteInt('Player2', 'KeyJump', KeyJump
);
789 WriteInt('Player2', 'KeyNextWeapon', KeyNextWeapon
);
790 WriteInt('Player2', 'KeyPrevWeapon', KeyPrevWeapon
);
791 WriteInt('Player2', 'KeyOpen', KeyOpen
);
792 WriteInt('Player2', 'KeyStrafe', KeyStrafe
);
793 for i
:= 0 to High(KeyWeapon
) do
794 WriteInt('Player2', 'KeyWeapon' + IntToStr(i
), KeyWeapon
[i
]);
796 WriteInt('Player2', 'KeyRight2', KeyRight2
);
797 WriteInt('Player2', 'KeyLeft2', KeyLeft2
);
798 WriteInt('Player2', 'KeyUp2', KeyUp2
);
799 WriteInt('Player2', 'KeyDown2', KeyDown2
);
800 WriteInt('Player2', 'KeyFire2', KeyFire2
);
801 WriteInt('Player2', 'KeyJump2', KeyJump2
);
802 WriteInt('Player2', 'KeyNextWeapon2', KeyNextWeapon2
);
803 WriteInt('Player2', 'KeyPrevWeapon2', KeyPrevWeapon2
);
804 WriteInt('Player2', 'KeyOpen2', KeyOpen2
);
805 WriteInt('Player2', 'KeyStrafe2', KeyStrafe2
);
806 for i
:= 0 to High(KeyWeapon2
) do
807 WriteInt('Player2', 'KeyWeapon2' + IntToStr(i
), KeyWeapon2
[i
]);
809 WriteStr('Player2', 'Name', Name
);
810 WriteStr('Player2', 'model', Model
);
811 WriteInt('Player2', 'red', Color
.R
);
812 WriteInt('Player2', 'green', Color
.G
);
813 WriteInt('Player2', 'blue', Color
.B
);
814 WriteInt('Player2', 'team', Team
);
817 for i
:= 0 to e_MaxJoys
-1 do
818 config
.WriteInt('Joysticks', 'Deadzone' + IntToStr(i
), e_JoystickDeadzones
[i
]);
820 config
.WriteInt('Touch', 'Size', Round(g_touch_size
* 10));
821 config
.WriteBool('Touch', 'Fire', g_touch_fire
);
822 config
.WriteInt('Touch', 'Offset', Round(g_touch_offset
));
823 config
.WriteBool('Touch', 'Alt', g_touch_alt
);
827 0: config
.WriteInt('Game', 'GibsCount', 0);
828 8: config
.WriteInt('Game', 'GibsCount', 1);
829 16: config
.WriteInt('Game', 'GibsCount', 2);
830 32: config
.WriteInt('Game', 'GibsCount', 3);
831 else config
.WriteInt('Game', 'GibsCount', 4);
834 config
.WriteInt('Game', 'ItemRespawnTime', ITEM_RESPAWNTIME
div 36);
835 config
.WriteInt('Game', 'MaxParticles', g_GFX_GetMax());
836 config
.WriteInt('Game', 'MaxShells', g_Shells_GetMax());
837 config
.WriteInt('Game', 'MaxGibs', g_Gibs_GetMax());
838 config
.WriteInt('Game', 'MaxCorpses', g_Corpses_GetMax());
839 config
.WriteInt('Game', 'BloodCount', gBloodCount
);
840 config
.WriteBool('Game', 'AdvancesBlood', gAdvBlood
);
841 config
.WriteBool('Game', 'AdvancesCorpses', gAdvCorpses
);
842 config
.WriteBool('Game', 'AdvancesGibs', gAdvGibs
);
843 config
.WriteInt('Game', 'Flash', gFlash
);
844 config
.WriteBool('Game', 'BackGround', gDrawBackGround
);
845 config
.WriteBool('Game', 'Messages', gShowMessages
);
846 config
.WriteBool('Game', 'RevertPlayers', gRevertPlayers
);
847 config
.WriteInt('Game', 'ChatBubble', gChatBubble
);
848 config
.WriteBool('Game', 'SFSDebug', gSFSDebug
);
849 config
.WriteBool('Game', 'SFSFastMode', gSFSFastMode
);
850 config
.WriteBool('Game', 'FastScreenshots', e_FastScreenshots
);
851 config
.WriteStr('Game', 'DefaultMegawadStart', gDefaultMegawadStart
);
852 config
.WriteBool('Game', 'BerserkAutoswitching', gBerserkAutoswitch
);
853 config
.WriteInt('Game', 'Scale', Round(g_dbg_scale
* 100));
855 config
.WriteStr ('GameplayCustom', 'Map', gcMap
);
856 config
.WriteStr ('GameplayCustom', 'GameMode', gcGameMode
);
857 config
.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit
);
858 config
.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit
);
859 config
.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives
);
860 config
.WriteInt ('GameplayCustom', 'Players', gcPlayers
);
861 config
.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage
);
862 config
.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit
);
863 config
.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay
);
864 config
.WriteBool('GameplayCustom', 'Monsters', gcMonsters
);
865 config
.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS
);
867 config
.WriteStr ('GameplayNetwork', 'Map', gnMap
);
868 config
.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode
);
869 config
.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit
);
870 config
.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit
);
871 config
.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives
);
872 config
.WriteInt ('GameplayNetwork', 'Players', gnPlayers
);
873 config
.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage
);
874 config
.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit
);
875 config
.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay
);
876 config
.WriteBool('GameplayNetwork', 'Monsters', gnMonsters
);
877 config
.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS
);
879 config
.WriteStr('MasterServer', 'IP', NetSlistIP
);
880 config
.WriteInt('MasterServer', 'Port', NetSlistPort
);
882 config
.WriteStr ('Server', 'Name', NetServerName
);
883 config
.WriteStr ('Server', 'Password', NetPassword
);
884 config
.WriteInt ('Server', 'Port', NetPort
);
885 config
.WriteInt ('Server', 'MaxClients', NetMaxClients
);
886 config
.WriteBool('Server', 'RCON', NetAllowRCON
);
887 config
.WriteStr ('Server', 'RCONPassword', NetRCONPassword
);
888 config
.WriteBool('Server', 'SyncWithMaster', NetUseMaster
);
889 config
.WriteBool('Server', 'ForwardPorts', NetForwardPorts
);
890 config
.WriteInt ('Server', 'UpdateInterval', NetUpdateRate
);
891 config
.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate
);
892 config
.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate
);
894 config
.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel
);
895 config
.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate
);
896 config
.WriteBool ('Client', 'PredictSelf', NetPredictSelf
);
897 config
.WriteStr ('Client', 'LastIP', NetClientIP
);
898 config
.WriteInt ('Client', 'LastPort', NetClientPort
);
900 config
.SaveFile(FileName
);
904 procedure g_Options_Write_Language(FileName
: String);
908 e_WriteLog('Writing language config', TMsgType
.Notify
);
910 config
:= TConfig
.CreateFile(FileName
);
911 config
.WriteStr('Game', 'Language', gLanguage
);
912 config
.SaveFile(FileName
);
916 procedure g_Options_Write_Video(FileName
: String);
921 e_WriteLog('Writing resolution to config', TMsgType
.Notify
);
923 config
:= TConfig
.CreateFile(FileName
);
925 if gWinMaximized
and (not gFullscreen
) then
935 e_LogWritefln(' (ws=%dx%d) (ss=%dx%d)', [gWinSizeX
, gWinSizeY
, gScreenWidth
, gScreenHeight
]);
937 config
.WriteInt('Video', 'ScreenWidth', sW
);
938 config
.WriteInt('Video', 'ScreenHeight', sH
);
939 config
.WriteInt('Video', 'WinPosX', gWinRealPosX
);
940 config
.WriteInt('Video', 'WinPosY', gWinRealPosY
);
941 config
.WriteBool('Video', 'Fullscreen', gFullscreen
);
942 config
.WriteBool('Video', 'Maximized', gWinMaximized
);
944 config
.SaveFile(FileName
);
948 procedure g_Options_Write_Gameplay_Custom(FileName
: String);
952 e_WriteLog('Writing custom gameplay config', TMsgType
.Notify
);
954 config
:= TConfig
.CreateFile(FileName
);
956 config
.WriteStr ('GameplayCustom', 'Map', gcMap
);
957 config
.WriteStr ('GameplayCustom', 'GameMode', gcGameMode
);
958 config
.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit
);
959 config
.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit
);
960 config
.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives
);
961 config
.WriteInt ('GameplayCustom', 'Players', gcPlayers
);
962 config
.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage
);
963 config
.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit
);
964 config
.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay
);
965 config
.WriteBool('GameplayCustom', 'Monsters', gcMonsters
);
966 config
.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS
);
968 config
.SaveFile(FileName
);
972 procedure g_Options_Write_Gameplay_Net(FileName
: String);
976 e_WriteLog('Writing network gameplay config', TMsgType
.Notify
);
978 config
:= TConfig
.CreateFile(FileName
);
980 config
.WriteStr ('GameplayNetwork', 'Map', gnMap
);
981 config
.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode
);
982 config
.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit
);
983 config
.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit
);
984 config
.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives
);
985 config
.WriteInt ('GameplayNetwork', 'Players', gnPlayers
);
986 config
.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage
);
987 config
.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit
);
988 config
.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay
);
989 config
.WriteBool('GameplayNetwork', 'Monsters', gnMonsters
);
990 config
.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS
);
992 config
.SaveFile(FileName
);
996 procedure g_Options_Write_Net_Server(FileName
: String);
1000 e_WriteLog('Writing server config', TMsgType
.Notify
);
1002 config
:= TConfig
.CreateFile(FileName
);
1004 config
.WriteStr ('Server', 'Name', NetServerName
);
1005 config
.WriteStr ('Server', 'Password', NetPassword
);
1006 config
.WriteInt ('Server', 'Port', NetPort
);
1007 config
.WriteInt ('Server', 'MaxClients', NetMaxClients
);
1008 config
.WriteBool('Server', 'SyncWithMaster', NetUseMaster
);
1009 config
.WriteBool('Server', 'ForwardPorts', NetForwardPorts
);
1011 config
.SaveFile(FileName
);
1015 procedure g_Options_Write_Net_Client(FileName
: String);
1019 e_WriteLog('Writing client config', TMsgType
.Notify
);
1021 config
:= TConfig
.CreateFile(FileName
);
1023 config
.WriteStr('Client', 'LastIP', NetClientIP
);
1024 config
.WriteInt('Client', 'LastPort', NetClientPort
);
1026 config
.SaveFile(FileName
);