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
;
144 target
, closest
, display
: TSDL_DisplayMode
;
146 (* Display 0 = Primary display *)
147 SDL_GetDesktopDisplayMode(0, @display
);
148 {$IF DEFINED(ANDROID)}
149 gScreenWidth
:= display
.w
;
150 gScreenHeight
:= display
.h
;
151 //gBPP := SDL_BITSPERPIXEL(dispaly.format);
153 gFullScreen
:= True; (* rotation not allowed? *)
155 (* Window must be smaller than display *)
156 target
.w
:= display
.w
* 75 div 100;
157 target
.h
:= display
.h
* 75 div 100;
158 target
.format
:= 0; (* didn't care *)
159 target
.refresh_rate
:= 0; (* didn't care *)
160 target
.driverdata
:= nil; (* init *)
161 SDL_GetClosestDisplayMode(0, @target
, @closest
);
162 gScreenWidth
:= closest
.w
;
163 gScreenHeight
:= closest
.h
;
164 //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
166 gFullScreen
:= False;
168 (* Must be positioned on primary display *)
169 gWinRealPosX
:= SDL_WINDOWPOS_CENTERED
;
170 gWinRealPosY
:= SDL_WINDOWPOS_CENTERED
;
171 gWinMaximized
:= False;
173 gTextureFilter
:= True;
174 glLegacyNPOT
:= False;
175 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gScreenWidth
) + ' h = ' + IntToStr(gScreenHeight
));
178 procedure g_Options_SetDefault();
187 gMuteWhenInactive
:= False;
188 gAnnouncer
:= ANNOUNCE_MEPLUS
;
189 gSoundEffectsDF
:= True;
190 gUseChatSounds
:= True;
191 gsSDLSampleRate
:= 44100;
192 gsSDLBufferSize
:= 2048;
194 g_Sound_SetupAllVolumes(gSoundLevel
, gMusicLevel
);
196 (* section GameControls *)
197 with gGameControls
.GameControls
do
199 TakeScreenshot
:= SDL_SCANCODE_F12
;
200 Stat
:= SDL_SCANCODE_TAB
;
201 Chat
:= SDL_SCANCODE_T
;
202 TeamChat
:= SDL_SCANCODE_Y
;
205 (* section Player1 *)
206 with gGameControls
.P1Control
do
208 KeyRight
:= SDL_SCANCODE_KP_6
;
209 KeyLeft
:= SDL_SCANCODE_KP_4
;
210 KeyUp
:= SDL_SCANCODE_KP_8
;
211 KeyDown
:= SDL_SCANCODE_KP_5
;
212 KeyFire
:= SDL_SCANCODE_SLASH
;
213 KeyJump
:= SDL_SCANCODE_RCTRL
;
214 KeyNextWeapon
:= SDL_SCANCODE_KP_9
;
215 KeyPrevWeapon
:= SDL_SCANCODE_KP_7
;
216 KeyOpen
:= SDL_SCANCODE_RSHIFT
;
217 KeyStrafe
:= SDL_SCANCODE_PERIOD
;
221 KeyWeapon
[i
] := SDL_SCANCODE_1
+ i (* 1, ..., 9, 0 *)
223 KeyWeapon
[10] := SDL_SCANCODE_MINUS
;
224 for i
:= 11 to High(KeyWeapon
) do
229 KeyRight2
:= VK_RIGHT
;
235 KeyNextWeapon2
:= VK_NEXT
;
236 KeyPrevWeapon2
:= VK_PREV
;
238 KeyStrafe2
:= VK_STRAFE
;
240 for i
:= 0 to High(KeyWeapon2
) do
242 KeyWeapon2
[i
] := VK_0
+ i
246 with gPlayer1Settings
do
249 Model
:= STD_PLAYER_MODEL
;
250 Color
.R
:= PLAYER1_DEF_COLOR
.R
;
251 Color
.G
:= PLAYER1_DEF_COLOR
.G
;
252 Color
.B
:= PLAYER1_DEF_COLOR
.B
;
256 (* section Player2 *)
257 with gGameControls
.P2Control
do
259 KeyRight
:= SDL_SCANCODE_D
;
260 KeyLeft
:= SDL_SCANCODE_A
;
261 KeyUp
:= SDL_SCANCODE_W
;
262 KeyDown
:= SDL_SCANCODE_S
;
263 KeyFire
:= SDL_SCANCODE_G
;
264 KeyJump
:= SDL_SCANCODE_SPACE
;
265 KeyNextWeapon
:= SDL_SCANCODE_E
;
266 KeyPrevWeapon
:= SDL_SCANCODE_Q
;
267 KeyOpen
:= SDL_SCANCODE_F
;
268 KeyStrafe
:= SDL_SCANCODE_LSHIFT
;
269 for i
:= 0 to High(KeyWeapon
) do
285 for i
:= 0 to High(KeyWeapon2
) do
291 with gPlayer2Settings
do
294 Model
:= STD_PLAYER_MODEL
;
295 Color
.R
:= PLAYER2_DEF_COLOR
.R
;
296 Color
.G
:= PLAYER2_DEF_COLOR
.G
;
297 Color
.B
:= PLAYER2_DEF_COLOR
.B
;
301 (* section Joysticks *)
302 for i
:= 0 to e_MaxJoys
- 1 do
304 e_JoystickDeadzones
[i
] := 8192
309 g_touch_fire
:= True;
310 g_touch_offset
:= 50;
311 g_touch_alt
:= False;
315 g_Shells_SetMax(300);
317 g_Corpses_SetMax(20);
319 ITEM_RESPAWNTIME
:= 60 * 36;
325 gDrawBackGround
:= True;
326 gShowMessages
:= True;
327 gRevertPlayers
:= False;
330 gSFSFastMode
:= False;
331 e_FastScreenshots
:= True;
332 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
333 gBerserkAutoswitch
:= True;
336 gAskLanguage
:= True;
337 gLanguage
:= LANGUAGE_ENGLISH
;
339 (* section GameplayCustom *)
341 gcGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
346 gcTeamDamage
:= False;
348 gcWeaponStay
:= False;
350 gcBotsVS
:= 'Everybody';
352 (* section GameplayNetwork *)
354 gnGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
359 gnTeamDamage
:= False;
361 gnWeaponStay
:= False;
363 gnBotsVS
:= 'Everybody';
365 (* section MasterServer *)
366 NetSlistIP
:= 'mpms.doom2d.org';
367 NetSlistPort
:= 25665;
368 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
371 NetServerName
:= 'Unnamed Server';
375 NetAllowRCON
:= False;
376 NetRCONPassword
:= 'default';
377 NetUseMaster
:= True;
380 NetMasterRate
:= 60000;
381 NetForwardPorts
:= False;
385 NetForcePlayerUpdate
:= False;
386 NetPredictSelf
:= True;
387 NetClientIP
:= '127.0.0.1';
388 NetClientPort
:= NetPort
;
391 procedure g_Options_Read(FileName
: String);
397 procedure ReadInteger (VAR v
: Integer; param
: String; minv
: Integer = Low(Integer); maxv
: Integer = High(Integer));
399 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
402 procedure ReadInteger (VAR v
: LongWord; param
: String; minv
: LongWord = Low(LongWord); maxv
: LongWord = High(LongWord)); overload
;
404 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
407 procedure ReadInteger (VAR v
: Word; param
: String; minv
: Word = Low(Word); maxv
: Word = High(Word)); overload
;
409 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
412 procedure ReadInteger (VAR v
: Byte; param
: String; minv
: Byte = Low(Byte); maxv
: Byte = High(Byte)); overload
;
414 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
417 procedure ReadBoolean (VAR v
: Boolean; param
: String);
419 v
:= config
.ReadBool(section
, param
, v
)
422 procedure ReadString (VAR v
: String; param
: String);
424 v
:= config
.ReadStr(section
, param
, v
)
428 gAskLanguage
:= True;
429 e_WriteLog('Reading config', TMsgType
.Notify
);
430 g_Options_SetDefault
;
432 if FileExists(FileName
) = False then
434 e_WriteLog('Config file '+FileName
+' not found', TMsgType
.Warning
);
435 g_Options_SetDefaultVideo
;
439 config
:= TConfig
.CreateFile(FileName
);
442 ReadInteger(gScreenWidth
, 'ScreenWidth', 0);
443 ReadInteger(gScreenHeight
, 'ScreenHeight', 0);
444 ReadInteger(gWinRealPosX
, 'WinPosX', 60);
445 ReadInteger(gWinRealPosY
, 'WinPosY', 60);
446 ReadBoolean(gFullScreen
, 'Fullscreen');
447 ReadBoolean(gWinMaximized
, 'Maximized');
448 ReadInteger(gBPP
, 'BPP', 0);
449 ReadInteger(gFreq
, 'Freq', 0);
450 ReadBoolean(gVSync
, 'VSync');
451 ReadBoolean(gTextureFilter
, 'TextureFilter');
452 ReadBoolean(glLegacyNPOT
, 'LegacyCompatible');
455 ReadBoolean(gNoSound
, 'NoSound');
456 ReadInteger(gSoundLevel
, 'SoundLevel', 0, 255);
457 ReadInteger(gMusicLevel
, 'MusicLevel', 0, 255);
458 ReadInteger(gMaxSimSounds
, 'MaxSimSounds', 2, 66);
459 ReadBoolean(gMuteWhenInactive
, 'MuteInactive');
460 ReadInteger(gAnnouncer
, 'Announcer', ANNOUNCE_NONE
, ANNOUNCE_ALL
);
461 ReadBoolean(gSoundEffectsDF
, 'SoundEffectsDF');
462 ReadBoolean(gUseChatSounds
, 'ChatSounds');
463 ReadInteger(gsSDLSampleRate
, 'SDLSampleRate', 11025, 96000);
464 ReadInteger(gsSDLBufferSize
, 'SDLBufferSize', 64, 16384);
466 section
:= 'GameControls';
467 with gGameControls
.GameControls
do
469 ReadInteger(TakeScreenshot
, 'TakeScreenshot');
470 ReadInteger(Stat
, 'Stat');
471 ReadInteger(Chat
, 'Chat');
472 ReadInteger(TeamChat
, 'TeamChat');
475 section
:= 'Player1';
476 with gGameControls
.P1Control
do
478 ReadInteger(KeyRight
, 'KeyRight');
479 ReadInteger(KeyLeft
, 'KeyLeft');
480 ReadInteger(KeyUp
, 'KeyUp');
481 ReadInteger(KeyDown
, 'KeyDown');
482 ReadInteger(KeyFire
, 'KeyFire');
483 ReadInteger(KeyJump
, 'KeyJump');
484 ReadInteger(KeyNextWeapon
, 'KeyNextWeapon');
485 ReadInteger(KeyPrevWeapon
, 'KeyPrevWeapon');
486 ReadInteger(KeyOpen
, 'KeyOpen');
487 ReadInteger(KeyStrafe
, 'KeyStrafe');
489 for i
:= 0 to High(KeyWeapon
) do
491 ReadInteger(KeyWeapon
[i
], 'KeyWeapon' + IntToStr(i
))
494 ReadInteger(KeyRight2
, 'KeyRight2');
495 ReadInteger(KeyLeft2
, 'KeyLeft2');
496 ReadInteger(KeyUp2
, 'KeyUp2');
497 ReadInteger(KeyDown2
, 'KeyDown2');
498 ReadInteger(KeyFire2
, 'KeyFire2');
499 ReadInteger(KeyJump2
, 'KeyJump2');
500 ReadInteger(KeyNextWeapon2
, 'KeyNextWeapon2');
501 ReadInteger(KeyPrevWeapon2
, 'KeyPrevWeapon2');
502 ReadInteger(KeyOpen2
, 'KeyOpen2');
503 ReadInteger(KeyStrafe2
, 'KeyStrafe2');
505 for i
:= 0 to High(KeyWeapon2
) do
507 ReadInteger(KeyWeapon2
[i
], 'KeyWeapon2' + IntToStr(i
))
511 section
:= 'Player1';
512 with gPlayer1Settings
do
514 ReadString(Name
, 'name');
515 ReadString(Model
, 'model');
516 ReadInteger(Color
.R
, 'red', 0, 255);
517 ReadInteger(Color
.G
, 'green', 0, 255);
518 ReadInteger(Color
.B
, 'blue', 0, 255);
519 ReadInteger(Team
, 'team');
520 if (Team
< TEAM_RED
) or (Team
> TEAM_BLUE
) then
524 section
:= 'Player2';
525 with gGameControls
.P2Control
do
527 ReadInteger(KeyRight
, 'KeyRight');
528 ReadInteger(KeyLeft
, 'KeyLeft');
529 ReadInteger(KeyUp
, 'KeyUp');
530 ReadInteger(KeyDown
, 'KeyDown');
531 ReadInteger(KeyFire
, 'KeyFire');
532 ReadInteger(KeyJump
, 'KeyJump');
533 ReadInteger(KeyNextWeapon
, 'KeyNextWeapon');
534 ReadInteger(KeyPrevWeapon
, 'KeyPrevWeapon');
535 ReadInteger(KeyOpen
, 'KeyOpen');
536 ReadInteger(KeyStrafe
, 'KeyStrafe');
538 for i
:= 0 to High(KeyWeapon
) do
540 ReadInteger(KeyWeapon
[i
], 'KeyWeapon' + IntToStr(i
))
543 ReadInteger(KeyRight2
, 'KeyRight2');
544 ReadInteger(KeyLeft2
, 'KeyLeft2');
545 ReadInteger(KeyUp2
, 'KeyUp2');
546 ReadInteger(KeyDown2
, 'KeyDown2');
547 ReadInteger(KeyFire2
, 'KeyFire2');
548 ReadInteger(KeyJump2
, 'KeyJump2');
549 ReadInteger(KeyNextWeapon2
, 'KeyNextWeapon2');
550 ReadInteger(KeyPrevWeapon2
, 'KeyPrevWeapon2');
551 ReadInteger(KeyOpen2
, 'KeyOpen2');
552 ReadInteger(KeyStrafe2
, 'KeyStrafe2');
554 for i
:= 0 to High(KeyWeapon2
) do
556 ReadInteger(KeyWeapon2
[i
], 'KeyWeapon2' + IntToStr(i
))
560 section
:= 'Player2';
561 with gPlayer2Settings
do
563 ReadString(Name
, 'name');
564 ReadString(Model
, 'model');
565 ReadInteger(Color
.R
, 'red', 0, 255);
566 ReadInteger(Color
.G
, 'green', 0, 255);
567 ReadInteger(Color
.B
, 'blue', 0, 255);
568 ReadInteger(Team
, 'team');
569 if (Team
< TEAM_RED
) or (Team
> TEAM_BLUE
) then
573 section
:= 'Joysticks';
574 for i
:= 0 to e_MaxJoys
- 1 do
576 ReadInteger(e_JoystickDeadzones
[i
], 'Deadzone' + IntToStr(i
))
580 i
:= Trunc(g_touch_size
* 10); ReadInteger(i
, 'Size', 0); g_touch_size
:= i
/ 10;
581 ReadBoolean(g_touch_fire
, 'Fire');
582 i
:= Round(g_touch_offset
); ReadInteger(i
, 'Offset', 0, 100); g_touch_offset
:= i
;
583 ReadBoolean(g_touch_alt
, 'Alt');
586 ReadInteger(i
, 'MaxParticles', 1000, 50000); g_GFX_SetMax(i
);
587 ReadInteger(i
, 'MaxShells', 300, 600); g_Shells_SetMax(i
);
588 ReadInteger(i
, 'MaxGibs', 150, 500); g_Gibs_SetMax(i
);
589 ReadInteger(i
, 'MaxCorpses', 20, 100); g_Corpses_SetMax(i
);
590 ReadInteger(i
, 'GibsCount');
596 else gGibsCount
:= 48;
598 i
:= ITEM_RESPAWNTIME
div 36; ReadInteger(i
, 'ItemRespawnTime', 0); ITEM_RESPAWNTIME
:= i
* 36;
599 ReadInteger(gBloodCount
, 'BloodCount', 0, 4);
600 ReadBoolean(gAdvBlood
, 'AdvancesBlood');
601 ReadBoolean(gAdvCorpses
, 'AdvancesCorpses');
602 ReadBoolean(gAdvGibs
, 'AdvancesGibs');
603 ReadInteger(gFlash
, 'Flash', 0, 2);
604 ReadBoolean(gDrawBackGround
, 'BackGround');
605 ReadBoolean(gShowMessages
, 'Messages');
606 ReadBoolean(gRevertPlayers
, 'RevertPlayers');
607 ReadInteger(gChatBubble
, 'ChatBubble', 0, 4);
608 ReadBoolean(gSFSDebug
, 'SFSDebug'); wadoptDebug
:= gSFSDebug
;
609 ReadBoolean(gSFSFastMode
, 'SFSFastMode'); wadoptFast
:= gSFSFastMode
;
610 ReadBoolean(e_FastScreenshots
, 'FastScreenshots');
611 ReadString(gDefaultMegawadStart
, 'DefaultMegawadStart');
612 ReadBoolean(gBerserkAutoswitch
, 'BerserkAutoswitching');
613 i
:= Trunc(g_dbg_scale
* 100); ReadInteger(i
, 'Scale', 100); g_dbg_scale
:= i
/ 100;
614 ReadString(gLanguage
, 'Language');
615 if (gLanguage
= LANGUAGE_RUSSIAN
) or (gLanguage
= LANGUAGE_ENGLISH
) then
616 gAskLanguage
:= False
618 gLanguage
:= LANGUAGE_ENGLISH
;
620 section
:= 'GameplayCustom';
621 ReadString(gcMap
, 'Map');
622 ReadString(gcGameMode
, 'GameMode');
623 ReadInteger(gcTimeLimit
, 'TimeLimit', 0, 65535);
624 ReadInteger(gcGoalLimit
, 'GoalLimit', 0, 65535);
625 ReadInteger(gcMaxLives
, 'MaxLives', 0, 255);
626 ReadInteger(gcPlayers
, 'Players', 0, 2);
627 ReadBoolean(gcTeamDamage
, 'TeamDamage');
628 ReadBoolean(gcAllowExit
, 'AllowExit');
629 ReadBoolean(gcWeaponStay
, 'WeaponStay');
630 ReadBoolean(gcMonsters
, 'Monsters');
631 ReadString(gcBotsVS
, 'BotsVS');
633 with gGameSettings
do
635 GameMode
:= g_Game_TextToMode(gcGameMode
);
636 if GameMode
= GM_NONE
then
638 if GameMode
= GM_SINGLE
then
640 TimeLimit
:= gcTimeLimit
;
641 GoalLimit
:= gcGoalLimit
;
642 MaxLives
:= gcMaxLives
;
646 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
;
648 Options
:= Options
or GAME_OPTION_ALLOWEXIT
;
650 Options
:= Options
or GAME_OPTION_WEAPONSTAY
;
652 Options
:= Options
or GAME_OPTION_MONSTERS
;
653 if gcBotsVS
= 'Everybody' then
654 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
655 if gcBotsVS
= 'Players' then
656 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
;
657 if gcBotsVS
= 'Monsters' then
658 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
;
661 section
:= 'GameplayNetwork';
662 ReadString(gnMap
, 'Map');
663 ReadString(gnGameMode
, 'GameMode');
664 ReadInteger(gnTimeLimit
, 'TimeLimit', 0, 65535);
665 ReadInteger(gnGoalLimit
, 'GoalLimit', 0, 65535);
666 ReadInteger(gnMaxLives
, 'MaxLives', 0, 255);
667 ReadInteger(gnPlayers
, 'Players', 0, 2);
668 ReadBoolean(gnTeamDamage
, 'TeamDamage');
669 ReadBoolean(gnAllowExit
, 'AllowExit');
670 ReadBoolean(gnWeaponStay
, 'WeaponStay');
671 ReadBoolean(gnMonsters
, 'Monsters');
672 ReadString(gnBotsVS
, 'BotsVS');
674 section
:= 'MasterServer';
675 ReadString(NetSlistIP
, 'IP');
676 ReadInteger(NetSlistPort
, 'Port', 0, 65535);
677 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
680 ReadString(NetServerName
, 'Name');
681 ReadString(NetPassword
, 'Password');
682 ReadInteger(NetPort
, 'Port', 0, 65535);
683 ReadInteger(NetMaxClients
, 'MaxClients', 0, NET_MAXCLIENTS
);
684 ReadBoolean(NetAllowRCON
, 'RCON');
685 ReadString(NetRCONPassword
, 'RCONPassword');
686 ReadBoolean(NetUseMaster
, 'SyncWithMaster');
687 ReadInteger(NetUpdateRate
, 'UpdateInterval', 0);
688 ReadInteger(NetRelupdRate
, 'ReliableUpdateInterval', 0);
689 ReadInteger(NetMasterRate
, 'MasterSyncInterval', 1);
690 ReadBoolean(NetForwardPorts
, 'ForwardPorts');
693 ReadInteger(NetInterpLevel
, 'InterpolationSteps', 0);
694 ReadBoolean(NetForcePlayerUpdate
, 'ForcePlayerUpdate');
695 ReadBoolean(NetPredictSelf
, 'PredictSelf');
696 ReadString(NetClientIP
, 'LastIP');
697 ReadInteger(NetClientPort
, 'LastPort', 0, 65535);
701 //if gTextureFilter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
704 procedure g_Options_Write(FileName
: String);
709 e_WriteLog('Writing config', TMsgType
.Notify
);
711 config
:= TConfig
.CreateFile(FileName
);
713 config
.WriteInt('Video', 'ScreenWidth', gScreenWidth
);
714 config
.WriteInt('Video', 'ScreenHeight', gScreenHeight
);
715 config
.WriteInt('Video', 'WinPosX', gWinRealPosX
);
716 config
.WriteInt('Video', 'WinPosY', gWinRealPosY
);
717 config
.WriteBool('Video', 'Fullscreen', gFullScreen
);
718 config
.WriteBool('Video', 'Maximized', gWinMaximized
);
719 config
.WriteInt('Video', 'BPP', gBPP
);
720 config
.WriteBool('Video', 'VSync', gVSync
);
721 config
.WriteBool('Video', 'TextureFilter', gTextureFilter
);
722 config
.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT
);
724 config
.WriteBool('Sound', 'NoSound', gNoSound
);
725 config
.WriteInt('Sound', 'SoundLevel', gSoundLevel
);
726 config
.WriteInt('Sound', 'MusicLevel', gMusicLevel
);
727 config
.WriteInt('Sound', 'MaxSimSounds', gMaxSimSounds
);
728 config
.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive
);
729 config
.WriteInt('Sound', 'Announcer', gAnnouncer
);
730 config
.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF
);
731 config
.WriteBool('Sound', 'ChatSounds', gUseChatSounds
);
732 config
.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate
);
733 config
.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize
);
735 with config
, gGameControls
.GameControls
do
737 WriteInt('GameControls', 'TakeScreenshot', TakeScreenshot
);
738 WriteInt('GameControls', 'Stat', Stat
);
739 WriteInt('GameControls', 'Chat', Chat
);
740 WriteInt('GameControls', 'TeamChat', TeamChat
);
743 with config
, gGameControls
.P1Control
, gPlayer1Settings
do
745 WriteInt('Player1', 'KeyRight', KeyRight
);
746 WriteInt('Player1', 'KeyLeft', KeyLeft
);
747 WriteInt('Player1', 'KeyUp', KeyUp
);
748 WriteInt('Player1', 'KeyDown', KeyDown
);
749 WriteInt('Player1', 'KeyFire', KeyFire
);
750 WriteInt('Player1', 'KeyJump', KeyJump
);
751 WriteInt('Player1', 'KeyNextWeapon', KeyNextWeapon
);
752 WriteInt('Player1', 'KeyPrevWeapon', KeyPrevWeapon
);
753 WriteInt('Player1', 'KeyOpen', KeyOpen
);
754 WriteInt('Player1', 'KeyStrafe', KeyStrafe
);
755 for i
:= 0 to High(KeyWeapon
) do
756 WriteInt('Player1', 'KeyWeapon' + IntToStr(i
), KeyWeapon
[i
]);
758 WriteInt('Player1', 'KeyRight2', KeyRight2
);
759 WriteInt('Player1', 'KeyLeft2', KeyLeft2
);
760 WriteInt('Player1', 'KeyUp2', KeyUp2
);
761 WriteInt('Player1', 'KeyDown2', KeyDown2
);
762 WriteInt('Player1', 'KeyFire2', KeyFire2
);
763 WriteInt('Player1', 'KeyJump2', KeyJump2
);
764 WriteInt('Player1', 'KeyNextWeapon2', KeyNextWeapon2
);
765 WriteInt('Player1', 'KeyPrevWeapon2', KeyPrevWeapon2
);
766 WriteInt('Player1', 'KeyOpen2', KeyOpen2
);
767 WriteInt('Player1', 'KeyStrafe2', KeyStrafe2
);
768 for i
:= 0 to High(KeyWeapon2
) do
769 WriteInt('Player1', 'KeyWeapon2' + IntToStr(i
), KeyWeapon2
[i
]);
771 WriteStr('Player1', 'Name', Name
);
772 WriteStr('Player1', 'model', Model
);
773 WriteInt('Player1', 'red', Color
.R
);
774 WriteInt('Player1', 'green', Color
.G
);
775 WriteInt('Player1', 'blue', Color
.B
);
776 WriteInt('Player1', 'team', Team
);
779 with config
, gGameControls
.P2Control
, gPlayer2Settings
do
781 WriteInt('Player2', 'KeyRight', KeyRight
);
782 WriteInt('Player2', 'KeyLeft', KeyLeft
);
783 WriteInt('Player2', 'KeyUp', KeyUp
);
784 WriteInt('Player2', 'KeyDown', KeyDown
);
785 WriteInt('Player2', 'KeyFire', KeyFire
);
786 WriteInt('Player2', 'KeyJump', KeyJump
);
787 WriteInt('Player2', 'KeyNextWeapon', KeyNextWeapon
);
788 WriteInt('Player2', 'KeyPrevWeapon', KeyPrevWeapon
);
789 WriteInt('Player2', 'KeyOpen', KeyOpen
);
790 WriteInt('Player2', 'KeyStrafe', KeyStrafe
);
791 for i
:= 0 to High(KeyWeapon
) do
792 WriteInt('Player2', 'KeyWeapon' + IntToStr(i
), KeyWeapon
[i
]);
794 WriteInt('Player2', 'KeyRight2', KeyRight2
);
795 WriteInt('Player2', 'KeyLeft2', KeyLeft2
);
796 WriteInt('Player2', 'KeyUp2', KeyUp2
);
797 WriteInt('Player2', 'KeyDown2', KeyDown2
);
798 WriteInt('Player2', 'KeyFire2', KeyFire2
);
799 WriteInt('Player2', 'KeyJump2', KeyJump2
);
800 WriteInt('Player2', 'KeyNextWeapon2', KeyNextWeapon2
);
801 WriteInt('Player2', 'KeyPrevWeapon2', KeyPrevWeapon2
);
802 WriteInt('Player2', 'KeyOpen2', KeyOpen2
);
803 WriteInt('Player2', 'KeyStrafe2', KeyStrafe2
);
804 for i
:= 0 to High(KeyWeapon2
) do
805 WriteInt('Player2', 'KeyWeapon2' + IntToStr(i
), KeyWeapon2
[i
]);
807 WriteStr('Player2', 'Name', Name
);
808 WriteStr('Player2', 'model', Model
);
809 WriteInt('Player2', 'red', Color
.R
);
810 WriteInt('Player2', 'green', Color
.G
);
811 WriteInt('Player2', 'blue', Color
.B
);
812 WriteInt('Player2', 'team', Team
);
815 for i
:= 0 to e_MaxJoys
-1 do
816 config
.WriteInt('Joysticks', 'Deadzone' + IntToStr(i
), e_JoystickDeadzones
[i
]);
818 config
.WriteInt('Touch', 'Size', Round(g_touch_size
* 10));
819 config
.WriteBool('Touch', 'Fire', g_touch_fire
);
820 config
.WriteInt('Touch', 'Offset', Round(g_touch_offset
));
821 config
.WriteBool('Touch', 'Alt', g_touch_alt
);
825 0: config
.WriteInt('Game', 'GibsCount', 0);
826 8: config
.WriteInt('Game', 'GibsCount', 1);
827 16: config
.WriteInt('Game', 'GibsCount', 2);
828 32: config
.WriteInt('Game', 'GibsCount', 3);
829 else config
.WriteInt('Game', 'GibsCount', 4);
832 config
.WriteInt('Game', 'ItemRespawnTime', ITEM_RESPAWNTIME
div 36);
833 config
.WriteInt('Game', 'MaxParticles', g_GFX_GetMax());
834 config
.WriteInt('Game', 'MaxShells', g_Shells_GetMax());
835 config
.WriteInt('Game', 'MaxGibs', g_Gibs_GetMax());
836 config
.WriteInt('Game', 'MaxCorpses', g_Corpses_GetMax());
837 config
.WriteInt('Game', 'BloodCount', gBloodCount
);
838 config
.WriteBool('Game', 'AdvancesBlood', gAdvBlood
);
839 config
.WriteBool('Game', 'AdvancesCorpses', gAdvCorpses
);
840 config
.WriteBool('Game', 'AdvancesGibs', gAdvGibs
);
841 config
.WriteInt('Game', 'Flash', gFlash
);
842 config
.WriteBool('Game', 'BackGround', gDrawBackGround
);
843 config
.WriteBool('Game', 'Messages', gShowMessages
);
844 config
.WriteBool('Game', 'RevertPlayers', gRevertPlayers
);
845 config
.WriteInt('Game', 'ChatBubble', gChatBubble
);
846 config
.WriteBool('Game', 'SFSDebug', gSFSDebug
);
847 config
.WriteBool('Game', 'SFSFastMode', gSFSFastMode
);
848 config
.WriteBool('Game', 'FastScreenshots', e_FastScreenshots
);
849 config
.WriteStr('Game', 'DefaultMegawadStart', gDefaultMegawadStart
);
850 config
.WriteBool('Game', 'BerserkAutoswitching', gBerserkAutoswitch
);
851 config
.WriteInt('Game', 'Scale', Round(g_dbg_scale
* 100));
853 config
.WriteStr ('GameplayCustom', 'Map', gcMap
);
854 config
.WriteStr ('GameplayCustom', 'GameMode', gcGameMode
);
855 config
.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit
);
856 config
.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit
);
857 config
.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives
);
858 config
.WriteInt ('GameplayCustom', 'Players', gcPlayers
);
859 config
.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage
);
860 config
.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit
);
861 config
.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay
);
862 config
.WriteBool('GameplayCustom', 'Monsters', gcMonsters
);
863 config
.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS
);
865 config
.WriteStr ('GameplayNetwork', 'Map', gnMap
);
866 config
.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode
);
867 config
.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit
);
868 config
.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit
);
869 config
.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives
);
870 config
.WriteInt ('GameplayNetwork', 'Players', gnPlayers
);
871 config
.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage
);
872 config
.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit
);
873 config
.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay
);
874 config
.WriteBool('GameplayNetwork', 'Monsters', gnMonsters
);
875 config
.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS
);
877 config
.WriteStr('MasterServer', 'IP', NetSlistIP
);
878 config
.WriteInt('MasterServer', 'Port', NetSlistPort
);
880 config
.WriteStr ('Server', 'Name', NetServerName
);
881 config
.WriteStr ('Server', 'Password', NetPassword
);
882 config
.WriteInt ('Server', 'Port', NetPort
);
883 config
.WriteInt ('Server', 'MaxClients', NetMaxClients
);
884 config
.WriteBool('Server', 'RCON', NetAllowRCON
);
885 config
.WriteStr ('Server', 'RCONPassword', NetRCONPassword
);
886 config
.WriteBool('Server', 'SyncWithMaster', NetUseMaster
);
887 config
.WriteBool('Server', 'ForwardPorts', NetForwardPorts
);
888 config
.WriteInt ('Server', 'UpdateInterval', NetUpdateRate
);
889 config
.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate
);
890 config
.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate
);
892 config
.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel
);
893 config
.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate
);
894 config
.WriteBool ('Client', 'PredictSelf', NetPredictSelf
);
895 config
.WriteStr ('Client', 'LastIP', NetClientIP
);
896 config
.WriteInt ('Client', 'LastPort', NetClientPort
);
898 config
.SaveFile(FileName
);
902 procedure g_Options_Write_Language(FileName
: String);
906 e_WriteLog('Writing language config', TMsgType
.Notify
);
908 config
:= TConfig
.CreateFile(FileName
);
909 config
.WriteStr('Game', 'Language', gLanguage
);
910 config
.SaveFile(FileName
);
914 procedure g_Options_Write_Video(FileName
: String);
919 e_WriteLog('Writing resolution to config', TMsgType
.Notify
);
921 config
:= TConfig
.CreateFile(FileName
);
923 if gWinMaximized
and (not gFullscreen
) then
933 e_LogWritefln(' (ws=%dx%d) (ss=%dx%d)', [gWinSizeX
, gWinSizeY
, gScreenWidth
, gScreenHeight
]);
935 config
.WriteInt('Video', 'ScreenWidth', sW
);
936 config
.WriteInt('Video', 'ScreenHeight', sH
);
937 config
.WriteInt('Video', 'WinPosX', gWinRealPosX
);
938 config
.WriteInt('Video', 'WinPosY', gWinRealPosY
);
939 config
.WriteBool('Video', 'Fullscreen', gFullscreen
);
940 config
.WriteBool('Video', 'Maximized', gWinMaximized
);
942 config
.SaveFile(FileName
);
946 procedure g_Options_Write_Gameplay_Custom(FileName
: String);
950 e_WriteLog('Writing custom gameplay config', TMsgType
.Notify
);
952 config
:= TConfig
.CreateFile(FileName
);
954 config
.WriteStr ('GameplayCustom', 'Map', gcMap
);
955 config
.WriteStr ('GameplayCustom', 'GameMode', gcGameMode
);
956 config
.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit
);
957 config
.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit
);
958 config
.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives
);
959 config
.WriteInt ('GameplayCustom', 'Players', gcPlayers
);
960 config
.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage
);
961 config
.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit
);
962 config
.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay
);
963 config
.WriteBool('GameplayCustom', 'Monsters', gcMonsters
);
964 config
.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS
);
966 config
.SaveFile(FileName
);
970 procedure g_Options_Write_Gameplay_Net(FileName
: String);
974 e_WriteLog('Writing network gameplay config', TMsgType
.Notify
);
976 config
:= TConfig
.CreateFile(FileName
);
978 config
.WriteStr ('GameplayNetwork', 'Map', gnMap
);
979 config
.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode
);
980 config
.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit
);
981 config
.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit
);
982 config
.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives
);
983 config
.WriteInt ('GameplayNetwork', 'Players', gnPlayers
);
984 config
.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage
);
985 config
.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit
);
986 config
.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay
);
987 config
.WriteBool('GameplayNetwork', 'Monsters', gnMonsters
);
988 config
.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS
);
990 config
.SaveFile(FileName
);
994 procedure g_Options_Write_Net_Server(FileName
: String);
998 e_WriteLog('Writing server config', TMsgType
.Notify
);
1000 config
:= TConfig
.CreateFile(FileName
);
1002 config
.WriteStr ('Server', 'Name', NetServerName
);
1003 config
.WriteStr ('Server', 'Password', NetPassword
);
1004 config
.WriteInt ('Server', 'Port', NetPort
);
1005 config
.WriteInt ('Server', 'MaxClients', NetMaxClients
);
1006 config
.WriteBool('Server', 'SyncWithMaster', NetUseMaster
);
1007 config
.WriteBool('Server', 'ForwardPorts', NetForwardPorts
);
1009 config
.SaveFile(FileName
);
1013 procedure g_Options_Write_Net_Client(FileName
: String);
1017 e_WriteLog('Writing client config', TMsgType
.Notify
);
1019 config
:= TConfig
.CreateFile(FileName
);
1021 config
.WriteStr('Client', 'LastIP', NetClientIP
);
1022 config
.WriteInt('Client', 'LastPort', NetClientPort
);
1024 config
.SaveFile(FileName
);