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
: TSDL_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;
174 e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gScreenWidth
) + ' h = ' + IntToStr(gScreenHeight
));
177 procedure g_Options_SetDefault();
186 gMuteWhenInactive
:= False;
187 gAnnouncer
:= ANNOUNCE_MEPLUS
;
188 gSoundEffectsDF
:= True;
189 gUseChatSounds
:= True;
190 gsSDLSampleRate
:= 44100;
191 gsSDLBufferSize
:= 2048;
193 g_Sound_SetupAllVolumes(gSoundLevel
, gMusicLevel
);
195 (* section GameControls *)
196 with gGameControls
.GameControls
do
198 TakeScreenshot
:= SDL_SCANCODE_F12
;
199 Stat
:= SDL_SCANCODE_TAB
;
200 Chat
:= SDL_SCANCODE_T
;
201 TeamChat
:= SDL_SCANCODE_Y
;
204 (* section Player1 *)
205 with gGameControls
.P1Control
do
207 KeyRight
:= SDL_SCANCODE_KP_6
;
208 KeyLeft
:= SDL_SCANCODE_KP_4
;
209 KeyUp
:= SDL_SCANCODE_KP_8
;
210 KeyDown
:= SDL_SCANCODE_KP_5
;
211 KeyFire
:= SDL_SCANCODE_SLASH
;
212 KeyJump
:= SDL_SCANCODE_RCTRL
;
213 KeyNextWeapon
:= SDL_SCANCODE_KP_9
;
214 KeyPrevWeapon
:= SDL_SCANCODE_KP_7
;
215 KeyOpen
:= SDL_SCANCODE_RSHIFT
;
216 KeyStrafe
:= SDL_SCANCODE_PERIOD
;
220 KeyWeapon
[i
] := SDL_SCANCODE_1
+ i (* 1, ..., 9, 0 *)
222 KeyWeapon
[10] := SDL_SCANCODE_MINUS
;
223 for i
:= 11 to High(KeyWeapon
) do
228 KeyRight2
:= VK_RIGHT
;
234 KeyNextWeapon2
:= VK_NEXT
;
235 KeyPrevWeapon2
:= VK_PREV
;
237 KeyStrafe2
:= VK_STRAFE
;
239 for i
:= 0 to High(KeyWeapon2
) do
241 KeyWeapon2
[i
] := VK_0
+ i
245 with gPlayer1Settings
do
248 Model
:= STD_PLAYER_MODEL
;
249 Color
.R
:= PLAYER1_DEF_COLOR
.R
;
250 Color
.G
:= PLAYER1_DEF_COLOR
.G
;
251 Color
.B
:= PLAYER1_DEF_COLOR
.B
;
255 (* section Player2 *)
256 with gGameControls
.P2Control
do
258 KeyRight
:= SDL_SCANCODE_D
;
259 KeyLeft
:= SDL_SCANCODE_A
;
260 KeyUp
:= SDL_SCANCODE_W
;
261 KeyDown
:= SDL_SCANCODE_S
;
262 KeyFire
:= SDL_SCANCODE_G
;
263 KeyJump
:= SDL_SCANCODE_SPACE
;
264 KeyNextWeapon
:= SDL_SCANCODE_E
;
265 KeyPrevWeapon
:= SDL_SCANCODE_Q
;
266 KeyOpen
:= SDL_SCANCODE_F
;
267 KeyStrafe
:= SDL_SCANCODE_LSHIFT
;
268 for i
:= 0 to High(KeyWeapon
) do
284 for i
:= 0 to High(KeyWeapon2
) do
290 with gPlayer2Settings
do
293 Model
:= STD_PLAYER_MODEL
;
294 Color
.R
:= PLAYER2_DEF_COLOR
.R
;
295 Color
.G
:= PLAYER2_DEF_COLOR
.G
;
296 Color
.B
:= PLAYER2_DEF_COLOR
.B
;
300 (* section Joysticks *)
301 for i
:= 0 to e_MaxJoys
- 1 do
303 e_JoystickDeadzones
[i
] := 8192
308 g_touch_fire
:= True;
309 g_touch_offset
:= 50;
310 g_touch_alt
:= False;
314 g_Shells_SetMax(300);
316 g_Corpses_SetMax(20);
318 ITEM_RESPAWNTIME
:= 60 * 36;
324 gDrawBackGround
:= True;
325 gShowMessages
:= True;
326 gRevertPlayers
:= False;
329 gSFSFastMode
:= False;
330 e_FastScreenshots
:= True;
331 gDefaultMegawadStart
:= DF_Default_Megawad_Start
;
332 gBerserkAutoswitch
:= True;
335 gAskLanguage
:= True;
336 gLanguage
:= LANGUAGE_ENGLISH
;
338 (* section GameplayCustom *)
340 gcGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
345 gcTeamDamage
:= False;
347 gcWeaponStay
:= False;
349 gcBotsVS
:= 'Everybody';
351 (* section GameplayNetwork *)
353 gnGameMode
:= _lc
[I_MENU_GAME_TYPE_DM
];
358 gnTeamDamage
:= False;
360 gnWeaponStay
:= False;
362 gnBotsVS
:= 'Everybody';
364 (* section MasterServer *)
365 NetSlistIP
:= 'mpms.doom2d.org';
366 NetSlistPort
:= 25665;
367 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
370 NetServerName
:= 'Unnamed Server';
374 NetAllowRCON
:= False;
375 NetRCONPassword
:= 'default';
376 NetUseMaster
:= True;
379 NetMasterRate
:= 60000;
380 NetForwardPorts
:= False;
384 NetForcePlayerUpdate
:= False;
385 NetPredictSelf
:= True;
386 NetClientIP
:= '127.0.0.1';
387 NetClientPort
:= NetPort
;
390 procedure g_Options_Read(FileName
: String);
396 procedure ReadInteger (VAR v
: Integer; param
: String; minv
: Integer = Low(Integer); maxv
: Integer = High(Integer));
398 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
401 procedure ReadInteger (VAR v
: LongWord; param
: String; minv
: LongWord = Low(LongWord); maxv
: LongWord = High(LongWord)); overload
;
403 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
406 procedure ReadInteger (VAR v
: Word; param
: String; minv
: Word = Low(Word); maxv
: Word = High(Word)); overload
;
408 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
411 procedure ReadInteger (VAR v
: Byte; param
: String; minv
: Byte = Low(Byte); maxv
: Byte = High(Byte)); overload
;
413 v
:= Max(Min(config
.ReadInt(section
, param
, v
), maxv
), minv
)
416 procedure ReadBoolean (VAR v
: Boolean; param
: String);
418 v
:= config
.ReadBool(section
, param
, v
)
421 procedure ReadString (VAR v
: String; param
: String);
423 v
:= config
.ReadStr(section
, param
, v
)
427 gAskLanguage
:= True;
428 e_WriteLog('Reading config', TMsgType
.Notify
);
429 g_Options_SetDefault
;
431 if FileExists(FileName
) = False then
433 e_WriteLog('Config file '+FileName
+' not found', TMsgType
.Warning
);
434 g_Options_SetDefaultVideo
;
438 config
:= TConfig
.CreateFile(FileName
);
441 ReadInteger(gScreenWidth
, 'ScreenWidth', 0);
442 ReadInteger(gScreenHeight
, 'ScreenHeight', 0);
443 ReadInteger(gWinRealPosX
, 'WinPosX', 60);
444 ReadInteger(gWinRealPosY
, 'WinPosY', 60);
445 ReadBoolean(gFullScreen
, 'Fullscreen');
446 ReadBoolean(gWinMaximized
, 'Maximized');
447 ReadInteger(gBPP
, 'BPP', 0);
448 ReadInteger(gFreq
, 'Freq', 0);
449 ReadBoolean(gVSync
, 'VSync');
450 ReadBoolean(gTextureFilter
, 'TextureFilter');
451 ReadBoolean(glLegacyNPOT
, 'LegacyCompatible');
454 ReadBoolean(gNoSound
, 'NoSound');
455 ReadInteger(gSoundLevel
, 'SoundLevel', 0, 255);
456 ReadInteger(gMusicLevel
, 'MusicLevel', 0, 255);
457 ReadInteger(gMaxSimSounds
, 'MaxSimSounds', 2, 66);
458 ReadBoolean(gMuteWhenInactive
, 'MuteInactive');
459 ReadInteger(gAnnouncer
, 'Announcer', ANNOUNCE_NONE
, ANNOUNCE_ALL
);
460 ReadBoolean(gSoundEffectsDF
, 'SoundEffectsDF');
461 ReadBoolean(gUseChatSounds
, 'ChatSounds');
462 ReadInteger(gsSDLSampleRate
, 'SDLSampleRate', 11025, 96000);
463 ReadInteger(gsSDLBufferSize
, 'SDLBufferSize', 64, 16384);
465 section
:= 'GameControls';
466 with gGameControls
.GameControls
do
468 ReadInteger(TakeScreenshot
, 'TakeScreenshot');
469 ReadInteger(Stat
, 'Stat');
470 ReadInteger(Chat
, 'Chat');
471 ReadInteger(TeamChat
, 'TeamChat');
474 section
:= 'Player1';
475 with gGameControls
.P1Control
do
477 ReadInteger(KeyRight
, 'KeyRight');
478 ReadInteger(KeyLeft
, 'KeyLeft');
479 ReadInteger(KeyUp
, 'KeyUp');
480 ReadInteger(KeyDown
, 'KeyDown');
481 ReadInteger(KeyFire
, 'KeyFire');
482 ReadInteger(KeyJump
, 'KeyJump');
483 ReadInteger(KeyNextWeapon
, 'KeyNextWeapon');
484 ReadInteger(KeyPrevWeapon
, 'KeyPrevWeapon');
485 ReadInteger(KeyOpen
, 'KeyOpen');
486 ReadInteger(KeyStrafe
, 'KeyStrafe');
488 for i
:= 0 to High(KeyWeapon
) do
490 ReadInteger(KeyWeapon
[i
], 'KeyWeapon' + IntToStr(i
))
493 ReadInteger(KeyRight2
, 'KeyRight2');
494 ReadInteger(KeyLeft2
, 'KeyLeft2');
495 ReadInteger(KeyUp2
, 'KeyUp2');
496 ReadInteger(KeyDown2
, 'KeyDown2');
497 ReadInteger(KeyFire2
, 'KeyFire2');
498 ReadInteger(KeyJump2
, 'KeyJump2');
499 ReadInteger(KeyNextWeapon2
, 'KeyNextWeapon2');
500 ReadInteger(KeyPrevWeapon2
, 'KeyPrevWeapon2');
501 ReadInteger(KeyOpen2
, 'KeyOpen2');
502 ReadInteger(KeyStrafe2
, 'KeyStrafe2');
504 for i
:= 0 to High(KeyWeapon2
) do
506 ReadInteger(KeyWeapon2
[i
], 'KeyWeapon2' + IntToStr(i
))
510 section
:= 'Player1';
511 with gPlayer1Settings
do
513 ReadString(Name
, 'name');
514 ReadString(Model
, 'model');
515 ReadInteger(Color
.R
, 'red', 0, 255);
516 ReadInteger(Color
.G
, 'green', 0, 255);
517 ReadInteger(Color
.B
, 'blue', 0, 255);
518 ReadInteger(Team
, 'team');
519 if (Team
< TEAM_RED
) or (Team
> TEAM_BLUE
) then
523 section
:= 'Player2';
524 with gGameControls
.P2Control
do
526 ReadInteger(KeyRight
, 'KeyRight');
527 ReadInteger(KeyLeft
, 'KeyLeft');
528 ReadInteger(KeyUp
, 'KeyUp');
529 ReadInteger(KeyDown
, 'KeyDown');
530 ReadInteger(KeyFire
, 'KeyFire');
531 ReadInteger(KeyJump
, 'KeyJump');
532 ReadInteger(KeyNextWeapon
, 'KeyNextWeapon');
533 ReadInteger(KeyPrevWeapon
, 'KeyPrevWeapon');
534 ReadInteger(KeyOpen
, 'KeyOpen');
535 ReadInteger(KeyStrafe
, 'KeyStrafe');
537 for i
:= 0 to High(KeyWeapon
) do
539 ReadInteger(KeyWeapon
[i
], 'KeyWeapon' + IntToStr(i
))
542 ReadInteger(KeyRight2
, 'KeyRight2');
543 ReadInteger(KeyLeft2
, 'KeyLeft2');
544 ReadInteger(KeyUp2
, 'KeyUp2');
545 ReadInteger(KeyDown2
, 'KeyDown2');
546 ReadInteger(KeyFire2
, 'KeyFire2');
547 ReadInteger(KeyJump2
, 'KeyJump2');
548 ReadInteger(KeyNextWeapon2
, 'KeyNextWeapon2');
549 ReadInteger(KeyPrevWeapon2
, 'KeyPrevWeapon2');
550 ReadInteger(KeyOpen2
, 'KeyOpen2');
551 ReadInteger(KeyStrafe2
, 'KeyStrafe2');
553 for i
:= 0 to High(KeyWeapon2
) do
555 ReadInteger(KeyWeapon2
[i
], 'KeyWeapon2' + IntToStr(i
))
559 section
:= 'Player2';
560 with gPlayer2Settings
do
562 ReadString(Name
, 'name');
563 ReadString(Model
, 'model');
564 ReadInteger(Color
.R
, 'red', 0, 255);
565 ReadInteger(Color
.G
, 'green', 0, 255);
566 ReadInteger(Color
.B
, 'blue', 0, 255);
567 ReadInteger(Team
, 'team');
568 if (Team
< TEAM_RED
) or (Team
> TEAM_BLUE
) then
572 section
:= 'Joysticks';
573 for i
:= 0 to e_MaxJoys
- 1 do
575 ReadInteger(e_JoystickDeadzones
[i
], 'Deadzone' + IntToStr(i
))
579 i
:= Trunc(g_touch_size
* 10); ReadInteger(i
, 'Size', 0); g_touch_size
:= i
/ 10;
580 ReadBoolean(g_touch_fire
, 'Fire');
581 i
:= Round(g_touch_offset
); ReadInteger(i
, 'Offset', 0, 100); g_touch_offset
:= i
;
582 ReadBoolean(g_touch_alt
, 'Alt');
585 ReadInteger(i
, 'MaxParticles', 1000, 50000); g_GFX_SetMax(i
);
586 ReadInteger(i
, 'MaxShells', 300, 600); g_Shells_SetMax(i
);
587 ReadInteger(i
, 'MaxGibs', 150, 500); g_Gibs_SetMax(i
);
588 ReadInteger(i
, 'MaxCorpses', 20, 100); g_Corpses_SetMax(i
);
589 ReadInteger(i
, 'GibsCount');
595 else gGibsCount
:= 48;
597 i
:= ITEM_RESPAWNTIME
div 36; ReadInteger(i
, 'ItemRespawnTime', 0); ITEM_RESPAWNTIME
:= i
* 36;
598 ReadInteger(gBloodCount
, 'BloodCount', 0, 4);
599 ReadBoolean(gAdvBlood
, 'AdvancesBlood');
600 ReadBoolean(gAdvCorpses
, 'AdvancesCorpses');
601 ReadBoolean(gAdvGibs
, 'AdvancesGibs');
602 ReadInteger(gFlash
, 'Flash', 0, 2);
603 ReadBoolean(gDrawBackGround
, 'BackGround');
604 ReadBoolean(gShowMessages
, 'Messages');
605 ReadBoolean(gRevertPlayers
, 'RevertPlayers');
606 ReadInteger(gChatBubble
, 'ChatBubble', 0, 4);
607 ReadBoolean(gSFSDebug
, 'SFSDebug'); wadoptDebug
:= gSFSDebug
;
608 ReadBoolean(gSFSFastMode
, 'SFSFastMode'); wadoptFast
:= gSFSFastMode
;
609 ReadBoolean(e_FastScreenshots
, 'FastScreenshots');
610 ReadString(gDefaultMegawadStart
, 'DefaultMegawadStart');
611 ReadBoolean(gBerserkAutoswitch
, 'BerserkAutoswitching');
612 i
:= Trunc(g_dbg_scale
* 100); ReadInteger(i
, 'Scale', 100); g_dbg_scale
:= i
/ 100;
613 ReadString(gLanguage
, 'Language');
614 if (gLanguage
= LANGUAGE_RUSSIAN
) or (gLanguage
= LANGUAGE_ENGLISH
) then
615 gAskLanguage
:= False
617 gLanguage
:= LANGUAGE_ENGLISH
;
619 section
:= 'GameplayCustom';
620 ReadString(gcMap
, 'Map');
621 ReadString(gcGameMode
, 'GameMode');
622 ReadInteger(gcTimeLimit
, 'TimeLimit', 0, 65535);
623 ReadInteger(gcGoalLimit
, 'GoalLimit', 0, 65535);
624 ReadInteger(gcMaxLives
, 'MaxLives', 0, 255);
625 ReadInteger(gcPlayers
, 'Players', 0, 2);
626 ReadBoolean(gcTeamDamage
, 'TeamDamage');
627 ReadBoolean(gcAllowExit
, 'AllowExit');
628 ReadBoolean(gcWeaponStay
, 'WeaponStay');
629 ReadBoolean(gcMonsters
, 'Monsters');
630 ReadString(gcBotsVS
, 'BotsVS');
632 with gGameSettings
do
634 GameMode
:= g_Game_TextToMode(gcGameMode
);
635 if GameMode
= GM_NONE
then
637 if GameMode
= GM_SINGLE
then
639 TimeLimit
:= gcTimeLimit
;
640 GoalLimit
:= gcGoalLimit
;
641 MaxLives
:= gcMaxLives
;
645 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
;
647 Options
:= Options
or GAME_OPTION_ALLOWEXIT
;
649 Options
:= Options
or GAME_OPTION_WEAPONSTAY
;
651 Options
:= Options
or GAME_OPTION_MONSTERS
;
652 if gcBotsVS
= 'Everybody' then
653 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
654 if gcBotsVS
= 'Players' then
655 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
;
656 if gcBotsVS
= 'Monsters' then
657 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
;
660 section
:= 'GameplayNetwork';
661 ReadString(gnMap
, 'Map');
662 ReadString(gnGameMode
, 'GameMode');
663 ReadInteger(gnTimeLimit
, 'TimeLimit', 0, 65535);
664 ReadInteger(gnGoalLimit
, 'GoalLimit', 0, 65535);
665 ReadInteger(gnMaxLives
, 'MaxLives', 0, 255);
666 ReadInteger(gnPlayers
, 'Players', 0, 2);
667 ReadBoolean(gnTeamDamage
, 'TeamDamage');
668 ReadBoolean(gnAllowExit
, 'AllowExit');
669 ReadBoolean(gnWeaponStay
, 'WeaponStay');
670 ReadBoolean(gnMonsters
, 'Monsters');
671 ReadString(gnBotsVS
, 'BotsVS');
673 section
:= 'MasterServer';
674 ReadString(NetSlistIP
, 'IP');
675 ReadInteger(NetSlistPort
, 'Port', 0, 65535);
676 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
679 ReadString(NetServerName
, 'Name');
680 ReadString(NetPassword
, 'Password');
681 ReadInteger(NetPort
, 'Port', 0, 65535);
682 ReadInteger(NetMaxClients
, 'MaxClients', 0, NET_MAXCLIENTS
);
683 ReadBoolean(NetAllowRCON
, 'RCON');
684 ReadString(NetRCONPassword
, 'RCONPassword');
685 ReadBoolean(NetUseMaster
, 'SyncWithMaster');
686 ReadInteger(NetUpdateRate
, 'UpdateInterval', 0);
687 ReadInteger(NetRelupdRate
, 'ReliableUpdateInterval', 0);
688 ReadInteger(NetMasterRate
, 'MasterSyncInterval', 1);
689 ReadBoolean(NetForwardPorts
, 'ForwardPorts');
692 ReadInteger(NetInterpLevel
, 'InterpolationSteps', 0);
693 ReadBoolean(NetForcePlayerUpdate
, 'ForcePlayerUpdate');
694 ReadBoolean(NetPredictSelf
, 'PredictSelf');
695 ReadString(NetClientIP
, 'LastIP');
696 ReadInteger(NetClientPort
, 'LastPort', 0, 65535);
700 //if gTextureFilter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
703 procedure g_Options_Write(FileName
: String);
708 e_WriteLog('Writing config', TMsgType
.Notify
);
710 config
:= TConfig
.CreateFile(FileName
);
712 config
.WriteInt('Video', 'ScreenWidth', gScreenWidth
);
713 config
.WriteInt('Video', 'ScreenHeight', gScreenHeight
);
714 config
.WriteInt('Video', 'WinPosX', gWinRealPosX
);
715 config
.WriteInt('Video', 'WinPosY', gWinRealPosY
);
716 config
.WriteBool('Video', 'Fullscreen', gFullScreen
);
717 config
.WriteBool('Video', 'Maximized', gWinMaximized
);
718 config
.WriteInt('Video', 'BPP', gBPP
);
719 config
.WriteBool('Video', 'VSync', gVSync
);
720 config
.WriteBool('Video', 'TextureFilter', gTextureFilter
);
721 config
.WriteBool('Video', 'LegacyCompatible', glLegacyNPOT
);
723 config
.WriteBool('Sound', 'NoSound', gNoSound
);
724 config
.WriteInt('Sound', 'SoundLevel', gSoundLevel
);
725 config
.WriteInt('Sound', 'MusicLevel', gMusicLevel
);
726 config
.WriteInt('Sound', 'MaxSimSounds', gMaxSimSounds
);
727 config
.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive
);
728 config
.WriteInt('Sound', 'Announcer', gAnnouncer
);
729 config
.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF
);
730 config
.WriteBool('Sound', 'ChatSounds', gUseChatSounds
);
731 config
.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate
);
732 config
.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize
);
734 with config
, gGameControls
.GameControls
do
736 WriteInt('GameControls', 'TakeScreenshot', TakeScreenshot
);
737 WriteInt('GameControls', 'Stat', Stat
);
738 WriteInt('GameControls', 'Chat', Chat
);
739 WriteInt('GameControls', 'TeamChat', TeamChat
);
742 with config
, gGameControls
.P1Control
, gPlayer1Settings
do
744 WriteInt('Player1', 'KeyRight', KeyRight
);
745 WriteInt('Player1', 'KeyLeft', KeyLeft
);
746 WriteInt('Player1', 'KeyUp', KeyUp
);
747 WriteInt('Player1', 'KeyDown', KeyDown
);
748 WriteInt('Player1', 'KeyFire', KeyFire
);
749 WriteInt('Player1', 'KeyJump', KeyJump
);
750 WriteInt('Player1', 'KeyNextWeapon', KeyNextWeapon
);
751 WriteInt('Player1', 'KeyPrevWeapon', KeyPrevWeapon
);
752 WriteInt('Player1', 'KeyOpen', KeyOpen
);
753 WriteInt('Player1', 'KeyStrafe', KeyStrafe
);
754 for i
:= 0 to High(KeyWeapon
) do
755 WriteInt('Player1', 'KeyWeapon' + IntToStr(i
), KeyWeapon
[i
]);
757 WriteInt('Player1', 'KeyRight2', KeyRight2
);
758 WriteInt('Player1', 'KeyLeft2', KeyLeft2
);
759 WriteInt('Player1', 'KeyUp2', KeyUp2
);
760 WriteInt('Player1', 'KeyDown2', KeyDown2
);
761 WriteInt('Player1', 'KeyFire2', KeyFire2
);
762 WriteInt('Player1', 'KeyJump2', KeyJump2
);
763 WriteInt('Player1', 'KeyNextWeapon2', KeyNextWeapon2
);
764 WriteInt('Player1', 'KeyPrevWeapon2', KeyPrevWeapon2
);
765 WriteInt('Player1', 'KeyOpen2', KeyOpen2
);
766 WriteInt('Player1', 'KeyStrafe2', KeyStrafe2
);
767 for i
:= 0 to High(KeyWeapon2
) do
768 WriteInt('Player1', 'KeyWeapon2' + IntToStr(i
), KeyWeapon2
[i
]);
770 WriteStr('Player1', 'Name', Name
);
771 WriteStr('Player1', 'model', Model
);
772 WriteInt('Player1', 'red', Color
.R
);
773 WriteInt('Player1', 'green', Color
.G
);
774 WriteInt('Player1', 'blue', Color
.B
);
775 WriteInt('Player1', 'team', Team
);
778 with config
, gGameControls
.P2Control
, gPlayer2Settings
do
780 WriteInt('Player2', 'KeyRight', KeyRight
);
781 WriteInt('Player2', 'KeyLeft', KeyLeft
);
782 WriteInt('Player2', 'KeyUp', KeyUp
);
783 WriteInt('Player2', 'KeyDown', KeyDown
);
784 WriteInt('Player2', 'KeyFire', KeyFire
);
785 WriteInt('Player2', 'KeyJump', KeyJump
);
786 WriteInt('Player2', 'KeyNextWeapon', KeyNextWeapon
);
787 WriteInt('Player2', 'KeyPrevWeapon', KeyPrevWeapon
);
788 WriteInt('Player2', 'KeyOpen', KeyOpen
);
789 WriteInt('Player2', 'KeyStrafe', KeyStrafe
);
790 for i
:= 0 to High(KeyWeapon
) do
791 WriteInt('Player2', 'KeyWeapon' + IntToStr(i
), KeyWeapon
[i
]);
793 WriteInt('Player2', 'KeyRight2', KeyRight2
);
794 WriteInt('Player2', 'KeyLeft2', KeyLeft2
);
795 WriteInt('Player2', 'KeyUp2', KeyUp2
);
796 WriteInt('Player2', 'KeyDown2', KeyDown2
);
797 WriteInt('Player2', 'KeyFire2', KeyFire2
);
798 WriteInt('Player2', 'KeyJump2', KeyJump2
);
799 WriteInt('Player2', 'KeyNextWeapon2', KeyNextWeapon2
);
800 WriteInt('Player2', 'KeyPrevWeapon2', KeyPrevWeapon2
);
801 WriteInt('Player2', 'KeyOpen2', KeyOpen2
);
802 WriteInt('Player2', 'KeyStrafe2', KeyStrafe2
);
803 for i
:= 0 to High(KeyWeapon2
) do
804 WriteInt('Player2', 'KeyWeapon2' + IntToStr(i
), KeyWeapon2
[i
]);
806 WriteStr('Player2', 'Name', Name
);
807 WriteStr('Player2', 'model', Model
);
808 WriteInt('Player2', 'red', Color
.R
);
809 WriteInt('Player2', 'green', Color
.G
);
810 WriteInt('Player2', 'blue', Color
.B
);
811 WriteInt('Player2', 'team', Team
);
814 for i
:= 0 to e_MaxJoys
-1 do
815 config
.WriteInt('Joysticks', 'Deadzone' + IntToStr(i
), e_JoystickDeadzones
[i
]);
817 config
.WriteInt('Touch', 'Size', Round(g_touch_size
* 10));
818 config
.WriteBool('Touch', 'Fire', g_touch_fire
);
819 config
.WriteInt('Touch', 'Offset', Round(g_touch_offset
));
820 config
.WriteBool('Touch', 'Alt', g_touch_alt
);
824 0: config
.WriteInt('Game', 'GibsCount', 0);
825 8: config
.WriteInt('Game', 'GibsCount', 1);
826 16: config
.WriteInt('Game', 'GibsCount', 2);
827 32: config
.WriteInt('Game', 'GibsCount', 3);
828 else config
.WriteInt('Game', 'GibsCount', 4);
831 config
.WriteInt('Game', 'ItemRespawnTime', ITEM_RESPAWNTIME
div 36);
832 config
.WriteInt('Game', 'MaxParticles', g_GFX_GetMax());
833 config
.WriteInt('Game', 'MaxShells', g_Shells_GetMax());
834 config
.WriteInt('Game', 'MaxGibs', g_Gibs_GetMax());
835 config
.WriteInt('Game', 'MaxCorpses', g_Corpses_GetMax());
836 config
.WriteInt('Game', 'BloodCount', gBloodCount
);
837 config
.WriteBool('Game', 'AdvancesBlood', gAdvBlood
);
838 config
.WriteBool('Game', 'AdvancesCorpses', gAdvCorpses
);
839 config
.WriteBool('Game', 'AdvancesGibs', gAdvGibs
);
840 config
.WriteInt('Game', 'Flash', gFlash
);
841 config
.WriteBool('Game', 'BackGround', gDrawBackGround
);
842 config
.WriteBool('Game', 'Messages', gShowMessages
);
843 config
.WriteBool('Game', 'RevertPlayers', gRevertPlayers
);
844 config
.WriteInt('Game', 'ChatBubble', gChatBubble
);
845 config
.WriteBool('Game', 'SFSDebug', gSFSDebug
);
846 config
.WriteBool('Game', 'SFSFastMode', gSFSFastMode
);
847 config
.WriteBool('Game', 'FastScreenshots', e_FastScreenshots
);
848 config
.WriteStr('Game', 'DefaultMegawadStart', gDefaultMegawadStart
);
849 config
.WriteBool('Game', 'BerserkAutoswitching', gBerserkAutoswitch
);
850 config
.WriteInt('Game', 'Scale', Round(g_dbg_scale
* 100));
852 config
.WriteStr ('GameplayCustom', 'Map', gcMap
);
853 config
.WriteStr ('GameplayCustom', 'GameMode', gcGameMode
);
854 config
.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit
);
855 config
.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit
);
856 config
.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives
);
857 config
.WriteInt ('GameplayCustom', 'Players', gcPlayers
);
858 config
.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage
);
859 config
.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit
);
860 config
.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay
);
861 config
.WriteBool('GameplayCustom', 'Monsters', gcMonsters
);
862 config
.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS
);
864 config
.WriteStr ('GameplayNetwork', 'Map', gnMap
);
865 config
.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode
);
866 config
.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit
);
867 config
.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit
);
868 config
.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives
);
869 config
.WriteInt ('GameplayNetwork', 'Players', gnPlayers
);
870 config
.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage
);
871 config
.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit
);
872 config
.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay
);
873 config
.WriteBool('GameplayNetwork', 'Monsters', gnMonsters
);
874 config
.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS
);
876 config
.WriteStr('MasterServer', 'IP', NetSlistIP
);
877 config
.WriteInt('MasterServer', 'Port', NetSlistPort
);
879 config
.WriteStr ('Server', 'Name', NetServerName
);
880 config
.WriteStr ('Server', 'Password', NetPassword
);
881 config
.WriteInt ('Server', 'Port', NetPort
);
882 config
.WriteInt ('Server', 'MaxClients', NetMaxClients
);
883 config
.WriteBool('Server', 'RCON', NetAllowRCON
);
884 config
.WriteStr ('Server', 'RCONPassword', NetRCONPassword
);
885 config
.WriteBool('Server', 'SyncWithMaster', NetUseMaster
);
886 config
.WriteBool('Server', 'ForwardPorts', NetForwardPorts
);
887 config
.WriteInt ('Server', 'UpdateInterval', NetUpdateRate
);
888 config
.WriteInt ('Server', 'ReliableUpdateInterval', NetRelupdRate
);
889 config
.WriteInt ('Server', 'MasterSyncInterval', NetMasterRate
);
891 config
.WriteInt ('Client', 'InterpolationSteps', NetInterpLevel
);
892 config
.WriteBool ('Client', 'ForcePlayerUpdate', NetForcePlayerUpdate
);
893 config
.WriteBool ('Client', 'PredictSelf', NetPredictSelf
);
894 config
.WriteStr ('Client', 'LastIP', NetClientIP
);
895 config
.WriteInt ('Client', 'LastPort', NetClientPort
);
897 config
.SaveFile(FileName
);
901 procedure g_Options_Write_Language(FileName
: String);
905 e_WriteLog('Writing language config', TMsgType
.Notify
);
907 config
:= TConfig
.CreateFile(FileName
);
908 config
.WriteStr('Game', 'Language', gLanguage
);
909 config
.SaveFile(FileName
);
913 procedure g_Options_Write_Video(FileName
: String);
918 e_WriteLog('Writing resolution to config', TMsgType
.Notify
);
920 config
:= TConfig
.CreateFile(FileName
);
922 if gWinMaximized
and (not gFullscreen
) then
932 e_LogWritefln(' (ws=%dx%d) (ss=%dx%d)', [gWinSizeX
, gWinSizeY
, gScreenWidth
, gScreenHeight
]);
934 config
.WriteInt('Video', 'ScreenWidth', sW
);
935 config
.WriteInt('Video', 'ScreenHeight', sH
);
936 config
.WriteInt('Video', 'WinPosX', gWinRealPosX
);
937 config
.WriteInt('Video', 'WinPosY', gWinRealPosY
);
938 config
.WriteBool('Video', 'Fullscreen', gFullscreen
);
939 config
.WriteBool('Video', 'Maximized', gWinMaximized
);
941 config
.SaveFile(FileName
);
945 procedure g_Options_Write_Gameplay_Custom(FileName
: String);
949 e_WriteLog('Writing custom gameplay config', TMsgType
.Notify
);
951 config
:= TConfig
.CreateFile(FileName
);
953 config
.WriteStr ('GameplayCustom', 'Map', gcMap
);
954 config
.WriteStr ('GameplayCustom', 'GameMode', gcGameMode
);
955 config
.WriteInt ('GameplayCustom', 'TimeLimit', gcTimeLimit
);
956 config
.WriteInt ('GameplayCustom', 'GoalLimit', gcGoalLimit
);
957 config
.WriteInt ('GameplayCustom', 'MaxLives', gcMaxLives
);
958 config
.WriteInt ('GameplayCustom', 'Players', gcPlayers
);
959 config
.WriteBool('GameplayCustom', 'TeamDamage', gcTeamDamage
);
960 config
.WriteBool('GameplayCustom', 'AllowExit', gcAllowExit
);
961 config
.WriteBool('GameplayCustom', 'WeaponStay', gcWeaponStay
);
962 config
.WriteBool('GameplayCustom', 'Monsters', gcMonsters
);
963 config
.WriteStr ('GameplayCustom', 'BotsVS', gcBotsVS
);
965 config
.SaveFile(FileName
);
969 procedure g_Options_Write_Gameplay_Net(FileName
: String);
973 e_WriteLog('Writing network gameplay config', TMsgType
.Notify
);
975 config
:= TConfig
.CreateFile(FileName
);
977 config
.WriteStr ('GameplayNetwork', 'Map', gnMap
);
978 config
.WriteStr ('GameplayNetwork', 'GameMode', gnGameMode
);
979 config
.WriteInt ('GameplayNetwork', 'TimeLimit', gnTimeLimit
);
980 config
.WriteInt ('GameplayNetwork', 'GoalLimit', gnGoalLimit
);
981 config
.WriteInt ('GameplayNetwork', 'MaxLives', gnMaxLives
);
982 config
.WriteInt ('GameplayNetwork', 'Players', gnPlayers
);
983 config
.WriteBool('GameplayNetwork', 'TeamDamage', gnTeamDamage
);
984 config
.WriteBool('GameplayNetwork', 'AllowExit', gnAllowExit
);
985 config
.WriteBool('GameplayNetwork', 'WeaponStay', gnWeaponStay
);
986 config
.WriteBool('GameplayNetwork', 'Monsters', gnMonsters
);
987 config
.WriteStr ('GameplayNetwork', 'BotsVS', gnBotsVS
);
989 config
.SaveFile(FileName
);
993 procedure g_Options_Write_Net_Server(FileName
: String);
997 e_WriteLog('Writing server config', TMsgType
.Notify
);
999 config
:= TConfig
.CreateFile(FileName
);
1001 config
.WriteStr ('Server', 'Name', NetServerName
);
1002 config
.WriteStr ('Server', 'Password', NetPassword
);
1003 config
.WriteInt ('Server', 'Port', NetPort
);
1004 config
.WriteInt ('Server', 'MaxClients', NetMaxClients
);
1005 config
.WriteBool('Server', 'SyncWithMaster', NetUseMaster
);
1006 config
.WriteBool('Server', 'ForwardPorts', NetForwardPorts
);
1008 config
.SaveFile(FileName
);
1012 procedure g_Options_Write_Net_Client(FileName
: String);
1016 e_WriteLog('Writing client config', TMsgType
.Notify
);
1018 config
:= TConfig
.CreateFile(FileName
);
1020 config
.WriteStr('Client', 'LastIP', NetClientIP
);
1021 config
.WriteInt('Client', 'LastPort', NetClientPort
);
1023 config
.SaveFile(FileName
);