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}
21 procedure g_Menu_Init();
22 procedure g_Menu_Free();
23 procedure g_Menu_Reset();
24 procedure LoadStdFont(cfgres
, texture
: string; var FontID
: DWORD
);
25 procedure LoadFont(txtres
, fntres
: string; var FontID
: DWORD
);
26 procedure g_Menu_AskLanguage();
28 procedure g_Menu_Show_SaveMenu();
29 procedure g_Menu_Show_LoadMenu(standalone
: Boolean=false);
30 procedure g_Menu_Show_GameSetGame();
31 procedure g_Menu_Show_OptionsVideo();
32 procedure g_Menu_Show_OptionsSound();
33 procedure g_Menu_Show_EndGameMenu();
34 procedure g_Menu_Show_QuitGameMenu();
38 gMenuSmallFont
: DWORD
;
50 g_gui
, g_textures
, e_graphics
, g_main
, g_window
, g_game
, g_map
,
51 g_basic
, g_console
, g_sound
, g_gfx
, g_player
, g_options
, g_weapons
,
52 e_log
, SysUtils
, CONFIG
, g_playermodel
, DateUtils
, sdl2
,
53 MAPDEF
, Math
, g_saveload
,
54 e_texture
, g_language
,
55 g_net
, g_netmsg
, g_netmaster
, g_items
, e_input
, g_touch
,
59 type TYNCallback
= procedure (yes
:Boolean);
61 procedure YNKeyDownProc (win
: TGUIWindow
; Key
: Byte);
63 if win
.UserData
= nil then exit
;
65 IK_Y
, IK_SPACE
: TYNCallback(win
.UserData
)(true);
66 IK_N
: TYNCallback(win
.UserData
)(false);
70 procedure YesButtonCB (ctl
: TGUITextButton
);
72 if ctl
.UserData
= nil then exit
;
73 TYNCallback(ctl
.UserData
)(true);
76 procedure NoButtonCB (ctl
: TGUITextButton
);
78 if ctl
.UserData
= nil then exit
;
79 TYNCallback(ctl
.UserData
)(false);
82 function CreateYNMenu (WinName
, Text: String; MaxLen
: Word; FontID
: DWORD
; ActionProc
: TYNCallback
): TGUIWindow
;
86 //if length(Text) = 0 then exit;
87 Result
:= TGUIWindow
.Create(WinName
);
90 //OnKeyDownEx := @YNKeyDownProc;
91 //UserData := @ActionProc;
92 menu
:= TGUIMenu(Result
.AddChild(TGUIMenu
.Create(gMenuSmallFont
, gMenuSmallFont
, '')));
95 Name
:= '__temp_yes_no_menu:'+WinName
;
97 AddText(Text, MaxLen
);
98 with AddButton(nil, _lc
[I_MENU_YES
]) do begin ProcEx
:= @YesButtonCB
; UserData
:= @ActionProc
; end;
99 with AddButton(nil, _lc
[I_MENU_NO
]) do begin ProcEx
:= @NoButtonCB
; UserData
:= @ActionProc
; end;
101 DefControl
:= '__temp_yes_no_menu:'+WinName
;
107 procedure ProcChangeColor(Sender
: TGUIControl
); forward;
108 procedure ProcSelectModel(Sender
: TGUIControl
); forward;
110 procedure ProcApplyOptions();
116 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
118 if TGUISwitch(menu
.GetControl('swBPP')).ItemIndex
= 0 then
124 gVSync
:= TGUISwitch(menu
.GetControl('swVSync')).ItemIndex
= 0;
125 if (ovs
<> gVSync
) then g_SetVSync(gVSync
);
127 gTextureFilter
:= TGUISwitch(menu
.GetControl('swTextureFilter')).ItemIndex
= 0;
128 glLegacyNPOT
:= not (TGUISwitch(menu
.GetControl('swLegacyNPOT')).ItemIndex
= 0);
130 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
132 g_Sound_SetupAllVolumes(
133 Min(TGUIScroll(menu
.GetControl('scSoundLevel')).Value
*16, 255),
134 Min(TGUIScroll(menu
.GetControl('scMusicLevel')).Value
*16, 255)
137 gMaxSimSounds
:= Max(Min(TGUIScroll(menu
.GetControl('scMaxSimSounds')).Value
*4+2, 66), 2);
138 gMuteWhenInactive
:= TGUISwitch(menu
.GetControl('swInactiveSounds')).ItemIndex
= 1;
139 gAnnouncer
:= TGUISwitch(menu
.GetControl('swAnnouncer')).ItemIndex
;
140 gSoundEffectsDF
:= TGUISwitch(menu
.GetControl('swSoundEffects')).ItemIndex
= 1;
141 gUseChatSounds
:= TGUISwitch(menu
.GetControl('swChatSpeech')).ItemIndex
= 0;
143 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
145 g_GFX_SetMax(TGUIScroll(menu
.GetControl('scParticlesCount')).Value
*1000);
146 g_Shells_SetMax(TGUIScroll(menu
.GetControl('scShellsMax')).Value
*30);
147 g_Gibs_SetMax(TGUIScroll(menu
.GetControl('scGibsMax')).Value
*25);
148 g_Corpses_SetMax(TGUIScroll(menu
.GetControl('scCorpsesMax')).Value
*5);
150 case TGUISwitch(menu
.GetControl('swGibsCount')).ItemIndex
of
155 else gGibsCount
:= 48;
158 gBloodCount
:= TGUISwitch(menu
.GetControl('swBloodCount')).ItemIndex
;
159 gFlash
:= TGUISwitch(menu
.GetControl('swScreenFlash')).ItemIndex
;
160 gAdvBlood
:= TGUISwitch(menu
.GetControl('swBloodType')).ItemIndex
= 1;
161 gAdvCorpses
:= TGUISwitch(menu
.GetControl('swCorpseType')).ItemIndex
= 1;
162 gAdvGibs
:= TGUISwitch(menu
.GetControl('swGibsType')).ItemIndex
= 1;
163 gDrawBackGround
:= TGUISwitch(menu
.GetControl('swBackGround')).ItemIndex
= 0;
164 gShowMessages
:= TGUISwitch(menu
.GetControl('swMessages')).ItemIndex
= 0;
165 gRevertPlayers
:= TGUISwitch(menu
.GetControl('swRevertPlayers')).ItemIndex
= 0;
166 gChatBubble
:= TGUISwitch(menu
.GetControl('swChatBubble')).ItemIndex
;
167 g_dbg_scale
:= TGUIScroll(menu
.GetControl('scScaleFactor')).Value
+ 1;
169 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
171 with menu
, gGameControls
.GameControls
do
173 TakeScreenshot
:= TGUIKeyRead(GetControl(_lc
[I_MENU_CONTROL_SCREENSHOT
])).Key
;
174 Stat
:= TGUIKeyRead(GetControl(_lc
[I_MENU_CONTROL_STAT
])).Key
;
175 Chat
:= TGUIKeyRead(GetControl(_lc
[I_MENU_CONTROL_CHAT
])).Key
;
176 TeamChat
:= TGUIKeyRead(GetControl(_lc
[I_MENU_CONTROL_TEAMCHAT
])).Key
;
179 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
180 with menu
, gGameControls
.P1Control
do
182 KeyRight
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_RIGHT
])).Key0
;
183 KeyLeft
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_LEFT
])).Key0
;
184 KeyUp
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_UP
])).Key0
;
185 KeyDown
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_DOWN
])).Key0
;
186 KeyFire
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_FIRE
])).Key0
;
187 KeyJump
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_JUMP
])).Key0
;
188 KeyNextWeapon
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_NEXT_WEAPON
])).Key0
;
189 KeyPrevWeapon
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_PREV_WEAPON
])).Key0
;
190 KeyOpen
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_USE
])).Key0
;
191 KeyStrafe
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_STRAFE
])).Key0
;
193 KeyRight2
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_RIGHT
])).Key1
;
194 KeyLeft2
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_LEFT
])).Key1
;
195 KeyUp2
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_UP
])).Key1
;
196 KeyDown2
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_DOWN
])).Key1
;
197 KeyFire2
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_FIRE
])).Key1
;
198 KeyJump2
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_JUMP
])).Key1
;
199 KeyNextWeapon2
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_NEXT_WEAPON
])).Key1
;
200 KeyPrevWeapon2
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_PREV_WEAPON
])).Key1
;
201 KeyOpen2
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_USE
])).Key1
;
202 KeyStrafe2
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_STRAFE
])).Key1
;
205 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
206 with menu
, gGameControls
.P1Control
do
208 for i
:= WP_FIRST
to WP_LAST
do
210 KeyWeapon
[i
] := TGUIKeyRead2(GetControl(_lc
[TStrings_Locale(Cardinal(I_GAME_WEAPON0
) + i
)])).Key0
;
211 KeyWeapon2
[i
] := TGUIKeyRead2(GetControl(_lc
[TStrings_Locale(Cardinal(I_GAME_WEAPON0
) + i
)])).Key1
;
215 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
216 with menu
, gGameControls
.P2Control
do
218 KeyRight
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_RIGHT
])).Key0
;
219 KeyLeft
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_LEFT
])).Key0
;
220 KeyUp
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_UP
])).Key0
;
221 KeyDown
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_DOWN
])).Key0
;
222 KeyFire
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_FIRE
])).Key0
;
223 KeyJump
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_JUMP
])).Key0
;
224 KeyNextWeapon
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_NEXT_WEAPON
])).Key0
;
225 KeyPrevWeapon
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_PREV_WEAPON
])).Key0
;
226 KeyOpen
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_USE
])).Key0
;
227 KeyStrafe
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_STRAFE
])).Key0
;
229 KeyRight2
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_RIGHT
])).Key1
;
230 KeyLeft2
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_LEFT
])).Key1
;
231 KeyUp2
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_UP
])).Key1
;
232 KeyDown2
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_DOWN
])).Key1
;
233 KeyFire2
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_FIRE
])).Key1
;
234 KeyJump2
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_JUMP
])).Key1
;
235 KeyNextWeapon2
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_NEXT_WEAPON
])).Key1
;
236 KeyPrevWeapon2
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_PREV_WEAPON
])).Key1
;
237 KeyOpen2
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_USE
])).Key1
;
238 KeyStrafe2
:= TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_STRAFE
])).Key1
;
241 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
242 with menu
, gGameControls
.P2Control
do
244 for i
:= WP_FIRST
to WP_LAST
do
246 KeyWeapon
[i
] := TGUIKeyRead2(GetControl(_lc
[TStrings_Locale(Cardinal(I_GAME_WEAPON0
) + i
)])).Key0
;
247 KeyWeapon2
[i
] := TGUIKeyRead2(GetControl(_lc
[TStrings_Locale(Cardinal(I_GAME_WEAPON0
) + i
)])).Key1
;
251 if e_JoysticksAvailable
> 0 then
253 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
256 for i
:= 0 to e_JoysticksAvailable
-1 do
257 e_JoystickDeadzones
[i
] := TGUIScroll(menu
.GetControl('scDeadzone' + IntToStr(i
))).Value
*(32767 div 20);
261 if SDL_GetNumTouchDevices() > 0 then
263 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
264 g_touch_size
:= TGUIScroll(menu
.GetControl('scTouchSize')).Value
/ 10 + 0.5;
265 g_touch_fire
:= TGUISwitch(menu
.GetControl('swTouchFire')).ItemIndex
= 1;
268 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
270 gPlayer1Settings
.Name
:= b_Text_Unformat(TGUIEdit(menu
.GetControl('edP1Name')).Text);
271 gPlayer1Settings
.Team
:= IfThen(TGUISwitch(menu
.GetControl('swP1Team')).ItemIndex
= 0,
272 TEAM_RED
, TEAM_BLUE
);
274 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mvP1Model')) do
276 gPlayer1Settings
.Model
:= Model
.Name
;
277 gPlayer1Settings
.Color
:= Model
.Color
;
280 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
282 gPlayer2Settings
.Name
:= b_Text_Unformat(TGUIEdit(menu
.GetControl('edP2Name')).Text);
283 gPlayer2Settings
.Team
:= IfThen(TGUISwitch(menu
.GetControl('swP2Team')).ItemIndex
= 0,
284 TEAM_RED
, TEAM_BLUE
);
285 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mvP2Model')) do
287 gPlayer2Settings
.Model
:= Model
.Name
;
288 gPlayer2Settings
.Color
:= Model
.Color
;
291 if gPlayer1Settings
.Name
= '' then gPlayer1Settings
.Name
:= 'Player1';
292 if gPlayer2Settings
.Name
= '' then gPlayer2Settings
.Name
:= 'Player2';
294 if g_Game_IsServer
then
296 if gPlayer1
<> nil then
298 gPlayer1
.SetModel(gPlayer1Settings
.Model
);
299 gPlayer1
.Name
:= gPlayer1Settings
.Name
;
300 if not (gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
]) then
301 gPlayer1
.SetColor(gPlayer1Settings
.Color
)
303 if gPlayer1
.Team
<> gPlayer1Settings
.Team
then
306 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
309 if gPlayer2
<> nil then
311 gPlayer2
.SetModel(gPlayer2Settings
.Model
);
312 gPlayer2
.Name
:= gPlayer2Settings
.Name
;
313 if (gGameSettings
.GameMode
<> GM_TDM
) and (gGameSettings
.GameMode
<> GM_CTF
) then
314 gPlayer2
.SetColor(gPlayer2Settings
.Color
)
316 if gPlayer2
.Team
<> gPlayer2Settings
.Team
then
321 if g_Game_IsClient
then MC_SEND_PlayerSettings
;
323 g_Options_Write(GameDir
+'/'+CONFIG_FILENAME
);
326 procedure ReadOptions();
331 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
333 with TGUISwitch(menu
.GetControl('swBPP')) do
339 with TGUISwitch(menu
.GetControl('swTextureFilter')) do
340 if gTextureFilter
then ItemIndex
:= 0 else ItemIndex
:= 1;
342 with TGUISwitch(menu
.GetControl('swVSync')) do
343 if gVSync
then ItemIndex
:= 0 else ItemIndex
:= 1;
345 with TGUISwitch(menu
.GetControl('swLegacyNPOT')) do
346 if not glLegacyNPOT
then ItemIndex
:= 0 else ItemIndex
:= 1;
348 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
350 TGUIScroll(menu
.GetControl('scSoundLevel')).Value
:= Round(gSoundLevel
/16);
351 TGUIScroll(menu
.GetControl('scMusicLevel')).Value
:= Round(gMusicLevel
/16);
352 TGUIScroll(menu
.GetControl('scMaxSimSounds')).Value
:= Round((gMaxSimSounds
-2)/4);
354 with TGUISwitch(menu
.GetControl('swInactiveSounds')) do
355 if gMuteWhenInactive
then
360 TGUISwitch(menu
.GetControl('swAnnouncer')).ItemIndex
:= gAnnouncer
;
362 with TGUISwitch(menu
.GetControl('swSoundEffects')) do
363 if gSoundEffectsDF
then
368 with TGUISwitch(menu
.GetControl('swChatSpeech')) do
369 if gUseChatSounds
then
374 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
375 with menu
, gGameControls
.P1Control
do
377 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_RIGHT
])).Key0
:= KeyRight
;
378 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_LEFT
])).Key0
:= KeyLeft
;
379 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_UP
])).Key0
:= KeyUp
;
380 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_DOWN
])).Key0
:= KeyDown
;
381 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_FIRE
])).Key0
:= KeyFire
;
382 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_JUMP
])).Key0
:= KeyJump
;
383 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_NEXT_WEAPON
])).Key0
:= KeyNextWeapon
;
384 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_PREV_WEAPON
])).Key0
:= KeyPrevWeapon
;
385 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_USE
])).Key0
:= KeyOpen
;
386 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_STRAFE
])).Key0
:= KeyStrafe
;
388 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_RIGHT
])).Key1
:= KeyRight2
;
389 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_LEFT
])).Key1
:= KeyLeft2
;
390 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_UP
])).Key1
:= KeyUp2
;
391 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_DOWN
])).Key1
:= KeyDown2
;
392 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_FIRE
])).Key1
:= KeyFire2
;
393 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_JUMP
])).Key1
:= KeyJump2
;
394 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_NEXT_WEAPON
])).Key1
:= KeyNextWeapon2
;
395 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_PREV_WEAPON
])).Key1
:= KeyPrevWeapon2
;
396 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_USE
])).Key1
:= KeyOpen2
;
397 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_STRAFE
])).Key1
:= KeyStrafe2
;
400 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
401 with menu
, gGameControls
.P1Control
do
403 for i
:= WP_FIRST
to WP_LAST
do
405 TGUIKeyRead2(GetControl(_lc
[TStrings_Locale(Cardinal(I_GAME_WEAPON0
) + i
)])).Key0
:= KeyWeapon
[i
];
406 TGUIKeyRead2(GetControl(_lc
[TStrings_Locale(Cardinal(I_GAME_WEAPON0
) + i
)])).Key1
:= KeyWeapon2
[i
];
410 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
411 with menu
, gGameControls
.P2Control
do
413 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_RIGHT
])).Key0
:= KeyRight
;
414 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_LEFT
])).Key0
:= KeyLeft
;
415 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_UP
])).Key0
:= KeyUp
;
416 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_DOWN
])).Key0
:= KeyDown
;
417 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_FIRE
])).Key0
:= KeyFire
;
418 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_JUMP
])).Key0
:= KeyJump
;
419 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_NEXT_WEAPON
])).Key0
:= KeyNextWeapon
;
420 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_PREV_WEAPON
])).Key0
:= KeyPrevWeapon
;
421 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_USE
])).Key0
:= KeyOpen
;
422 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_STRAFE
])).Key0
:= KeyStrafe
;
424 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_RIGHT
])).Key1
:= KeyRight2
;
425 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_LEFT
])).Key1
:= KeyLeft2
;
426 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_UP
])).Key1
:= KeyUp2
;
427 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_DOWN
])).Key1
:= KeyDown2
;
428 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_FIRE
])).Key1
:= KeyFire2
;
429 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_JUMP
])).Key1
:= KeyJump2
;
430 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_NEXT_WEAPON
])).Key1
:= KeyNextWeapon2
;
431 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_PREV_WEAPON
])).Key1
:= KeyPrevWeapon2
;
432 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_USE
])).Key1
:= KeyOpen2
;
433 TGUIKeyRead2(GetControl(_lc
[I_MENU_CONTROL_STRAFE
])).Key1
:= KeyStrafe2
;
436 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
437 with menu
, gGameControls
.P2Control
do
439 for i
:= WP_FIRST
to WP_LAST
do
441 TGUIKeyRead2(GetControl(_lc
[TStrings_Locale(Cardinal(I_GAME_WEAPON0
) + i
)])).Key0
:= KeyWeapon
[i
];
442 TGUIKeyRead2(GetControl(_lc
[TStrings_Locale(Cardinal(I_GAME_WEAPON0
) + i
)])).Key1
:= KeyWeapon2
[i
];
446 if e_JoysticksAvailable
> 0 then
448 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
451 for i
:= 0 to e_JoysticksAvailable
-1 do
452 TGUIScroll(menu
.GetControl('scDeadzone' + IntToStr(i
))).Value
:= e_JoystickDeadzones
[i
] div (32767 div 20);
456 if SDL_GetNumTouchDevices() > 0 then
458 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
459 TGUIScroll(menu
.GetControl('scTouchSize')).Value
:= Round((g_touch_size
- 0.5) * 10);
460 with TGUISwitch(menu
.GetControl('swTouchFire')) do
461 if g_touch_fire
then ItemIndex
:= 1 else ItemIndex
:= 0;
464 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
465 with menu
, gGameControls
.GameControls
do
467 TGUIKeyRead(GetControl(_lc
[I_MENU_CONTROL_SCREENSHOT
])).Key
:= TakeScreenshot
;
468 TGUIKeyRead(GetControl(_lc
[I_MENU_CONTROL_STAT
])).Key
:= Stat
;
469 TGUIKeyRead(GetControl(_lc
[I_MENU_CONTROL_CHAT
])).Key
:= Chat
;
470 TGUIKeyRead(GetControl(_lc
[I_MENU_CONTROL_TEAMCHAT
])).Key
:= TeamChat
;
473 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
475 TGUIScroll(menu
.GetControl('scParticlesCount')).Value
:= g_GFX_GetMax() div 1000;
476 TGUIScroll(menu
.GetControl('scShellsMax')).Value
:= g_Shells_GetMax() div 30;
477 TGUIScroll(menu
.GetControl('scGibsMax')).Value
:= g_Gibs_GetMax() div 25;
478 TGUIScroll(menu
.GetControl('scCorpsesMax')).Value
:= g_Corpses_GetMax() div 5;
479 TGUISwitch(menu
.GetControl('swBloodCount')).ItemIndex
:= gBloodCount
;
481 with TGUISwitch(menu
.GetControl('swScreenFlash')) do
484 with TGUISwitch(menu
.GetControl('swBloodType')) do
485 if gAdvBlood
then ItemIndex
:= 1 else ItemIndex
:= 0;
487 with TGUISwitch(menu
.GetControl('swCorpseType')) do
488 if gAdvCorpses
then ItemIndex
:= 1 else ItemIndex
:= 0;
490 with TGUISwitch(menu
.GetControl('swGibsType')) do
491 if gAdvGibs
then ItemIndex
:= 1 else ItemIndex
:= 0;
493 with TGUISwitch(menu
.GetControl('swGibsCount')) do
502 with TGUISwitch(menu
.GetControl('swBackGround')) do
503 if gDrawBackGround
then ItemIndex
:= 0 else ItemIndex
:= 1;
505 with TGUISwitch(menu
.GetControl('swMessages')) do
506 if gShowMessages
then ItemIndex
:= 0 else ItemIndex
:= 1;
508 with TGUISwitch(menu
.GetControl('swRevertPlayers')) do
509 if gRevertPlayers
then ItemIndex
:= 0 else ItemIndex
:= 1;
511 with TGUISwitch(menu
.GetControl('swChatBubble')) do
512 ItemIndex
:= gChatBubble
;
514 TGUIScroll(menu
.GetControl('scScaleFactor')).Value
:= Round(g_dbg_scale
- 1);
516 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
518 TGUIListBox(menu
.GetControl('lsP1Model')).SelectItem(gPlayer1Settings
.Model
);
519 TGUIEdit(menu
.GetControl('edP1Name')).Text := gPlayer1Settings
.Name
;
521 TGUISwitch(menu
.GetControl('swP1Team')).ItemIndex
:=
522 IfThen(gPlayer1Settings
.Team
= TEAM_BLUE
, 1, 0);
524 TGUIScroll(menu
.GetControl('scP1Red')).Value
:= Round(gPlayer1Settings
.Color
.R
/16);
525 TGUIScroll(menu
.GetControl('scP1Green')).Value
:= Round(gPlayer1Settings
.Color
.G
/16);
526 TGUIScroll(menu
.GetControl('scP1Blue')).Value
:= Round(gPlayer1Settings
.Color
.B
/16);
528 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
530 TGUIListBox(menu
.GetControl('lsP2Model')).SelectItem(gPlayer2Settings
.Model
);
531 TGUIEdit(menu
.GetControl('edP2Name')).Text := gPlayer2Settings
.Name
;
533 TGUISwitch(menu
.GetControl('swP2Team')).ItemIndex
:=
534 IfThen(gPlayer2Settings
.Team
= TEAM_BLUE
, 1, 0);
536 TGUIScroll(menu
.GetControl('scP2Red')).Value
:= Round(gPlayer2Settings
.Color
.R
/16);
537 TGUIScroll(menu
.GetControl('scP2Green')).Value
:= Round(gPlayer2Settings
.Color
.G
/16);
538 TGUIScroll(menu
.GetControl('scP2Blue')).Value
:= Round(gPlayer2Settings
.Color
.B
/16);
540 ProcSelectModel(nil);
543 procedure ProcSwitchMonstersCustom(Sender
: TGUIControl
);
545 // don't turn off monsters in DM
547 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
548 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
549 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
551 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
554 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
555 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
556 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
557 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
561 procedure ProcSwitchMonstersNet(Sender
: TGUIControl
);
563 // don't turn off monsters in DM
565 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
566 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
567 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
569 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
572 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
573 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
574 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
575 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
579 procedure ProcStartCustomGame();
585 with TGUIMenu(g_ActiveWindow
.GetControl('mCustomGameMenu')) do
587 Map
:= TGUILabel(GetControl('lbMap')).Text;
590 if not isWadPath(Map
) then
593 GameMode
:= TGUISwitch(GetControl('swGameMode')).ItemIndex
+1;
594 gcGameMode
:= TGUISwitch(GetControl('swGameMode')).GetText
;
595 gcTimeLimit
:= StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
596 gcGoalLimit
:= StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
597 gcMaxLives
:= StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
599 gcTeamDamage
:= TGUISwitch(GetControl('swTeamDamage')).ItemIndex
= 0;
600 gcAllowExit
:= TGUISwitch(GetControl('swEnableExits')).ItemIndex
= 0;
601 gcWeaponStay
:= TGUISwitch(GetControl('swWeaponStay')).ItemIndex
= 0;
602 gcMonsters
:= TGUISwitch(GetControl('swMonsters')).ItemIndex
= 0;
605 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
;
607 Options
:= Options
or GAME_OPTION_ALLOWEXIT
;
609 Options
:= Options
or GAME_OPTION_WEAPONSTAY
;
611 Options
:= Options
or GAME_OPTION_MONSTERS
;
612 gcPlayers
:= TGUISwitch(GetControl('swPlayers')).ItemIndex
;
614 case TGUISwitch(GetControl('swBotsVS')).ItemIndex
of
616 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
;
617 gcBotsVS
:= 'Monsters';
620 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
621 gcBotsVS
:= 'Everybody';
624 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
;
625 gcBotsVS
:= 'Players';
632 g_Options_Write_Gameplay_Custom(GameDir
+'/'+CONFIG_FILENAME
);
634 g_Game_StartCustom(Map
, GameMode
, gcTimeLimit
, gcGoalLimit
,
635 gcMaxLives
, Options
, gcPlayers
);
639 procedure ProcStartNetGame();
645 with TGUIMenu(g_ActiveWindow
.GetControl('mNetServerMenu')) do
647 Map
:= TGUILabel(GetControl('lbMap')).Text;
650 if not isWadPath(Map
) then
653 GameMode
:= TGUISwitch(GetControl('swGameMode')).ItemIndex
+1;
654 gnGameMode
:= TGUISwitch(GetControl('swGameMode')).GetText
;
655 gnTimeLimit
:= StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
656 gnGoalLimit
:= StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
657 gnMaxLives
:= StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
658 NetPort
:= StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
660 gnTeamDamage
:= TGUISwitch(GetControl('swTeamDamage')).ItemIndex
= 0;
661 gnAllowExit
:= TGUISwitch(GetControl('swEnableExits')).ItemIndex
= 0;
662 gnWeaponStay
:= TGUISwitch(GetControl('swWeaponStay')).ItemIndex
= 0;
663 gnMonsters
:= TGUISwitch(GetControl('swMonsters')).ItemIndex
= 0;
666 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
;
668 Options
:= Options
or GAME_OPTION_ALLOWEXIT
;
670 Options
:= Options
or GAME_OPTION_WEAPONSTAY
;
672 Options
:= Options
or GAME_OPTION_MONSTERS
;
673 gnPlayers
:= TGUISwitch(GetControl('swPlayers')).ItemIndex
;
675 case TGUISwitch(GetControl('swBotsVS')).ItemIndex
of
677 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
;
678 gnBotsVS
:= 'Monsters';
681 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
or GAME_OPTION_BOTVSMONSTER
;
682 gnBotsVS
:= 'Everybody';
685 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
;
686 gnBotsVS
:= 'Players';
691 NetServerName
:= TGUIEdit(GetControl('edSrvName')).Text;
692 NetMaxClients
:= Max(1, StrToIntDef(TGUIEdit(GetControl('edMaxPlayers')).Text, 1));
693 NetMaxClients
:= Min(NET_MAXCLIENTS
, NetMaxClients
);
694 NetPassword
:= TGUIEdit(GetControl('edSrvPassword')).Text;
695 NetUseMaster
:= TGUISwitch(GetControl('swUseMaster')).ItemIndex
= 0;
698 g_Options_Write_Net_Server(GameDir
+'/'+CONFIG_FILENAME
);
699 g_Options_Write_Gameplay_Net(GameDir
+'/'+CONFIG_FILENAME
);
701 g_Game_StartServer(Map
, GameMode
, gnTimeLimit
, gnGoalLimit
, gnMaxLives
,
702 Options
, gnPlayers
, 0, NetPort
);
705 procedure ProcConnectNetGame();
709 with TGUIMenu(g_ActiveWindow
.GetControl('mNetClientMenu')) do
711 NetClientIP
:= TGUIEdit(GetControl('edIP')).Text;
712 NetClientPort
:= StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
713 PW
:= TGUIEdit(GetControl('edPW')).Text;
716 g_Options_Write_Net_Client(GameDir
+'/'+CONFIG_FILENAME
);
717 g_Game_StartClient(NetClientIP
, NetClientPort
, PW
);
720 procedure ProcEnterPassword();
724 with TGUIMenu(g_ActiveWindow
.GetControl('mClientPasswordMenu')) do
726 NetClientIP
:= PromptIP
;
727 NetClientPort
:= PromptPort
;
728 PW
:= TGUIEdit(GetControl('edPW')).Text;
731 g_Options_Write_Net_Client(GameDir
+'/'+CONFIG_FILENAME
);
732 g_Game_StartClient(NetClientIP
, NetClientPort
, PW
);
735 procedure ProcServerlist();
737 if not NetInitDone
then
739 if (not g_Net_Init()) then
741 g_Console_Add('NET: ERROR: Failed to init ENet!');
748 g_Net_Slist_Set(NetSlistIP
, NetSlistPort
);
750 gState
:= STATE_SLIST
;
751 g_ActiveWindow
:= nil;
753 slWaitStr
:= _lc
[I_NET_SLIST_WAIT
];
758 slReturnPressed
:= True;
759 if g_Net_Slist_Fetch(slCurrent
) then
761 if slCurrent
= nil then
762 slWaitStr
:= _lc
[I_NET_SLIST_NOSERVERS
];
765 slWaitStr
:= _lc
[I_NET_SLIST_ERROR
];
768 procedure ProcStartCampaign();
774 with TGUIMenu(g_ActiveWindow
.GetControl('mCampaignMenu')) do
776 WAD
:= ExtractRelativePath(MapsDir
, TGUIFileListBox(GetControl('lsWAD')).SelectedItem());
777 TwoPlayers
:= TGUISwitch(GetControl('swPlayers')).ItemIndex
= 1;
784 g_Game_StartSingle(WAD
+ ':\MAP01', TwoPlayers
, n
);
787 procedure ProcSelectMap(Sender
: TGUIControl
);
791 wad
, map
, res
: String;
793 win
:= g_GUI_GetWindow('SelectMapMenu');
794 with TGUIMenu(win
.GetControl('mSelectMapMenu')) do
796 wad
:= TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
797 map
:= TGUIListBox(GetControl('lsMapRes')).SelectedItem();
799 if (wad
= '') or (map
= '') then
800 begin // Ýòî íå êàðòà
801 TGUILabel(GetControl('lbMapName')).Text := '';
802 TGUILabel(GetControl('lbMapAuthor')).Text := '';
803 TGUILabel(GetControl('lbMapSize')).Text := '';
804 TGUIMemo(GetControl('meMapDescription')).SetText('');
805 TGUIMapPreview(win
.GetControl('mpMapPreview')).ClearMap();
806 TGUILabel(win
.GetControl('lbMapScale')).Text := '';
812 a
:= g_Map_GetMapInfo(res
);
814 TGUILabel(GetControl('lbMapName')).Text := a
.Name
;
815 TGUILabel(GetControl('lbMapAuthor')).Text := a
.Author
;
816 TGUILabel(GetControl('lbMapSize')).Text := Format('%dx%d', [a
.Width
, a
.Height
]);
817 TGUIMemo(GetControl('meMapDescription')).SetText(a
.Description
);
818 TGUIMapPreview(win
.GetControl('mpMapPreview')).SetMap(res
);
819 TGUILabel(win
.GetControl('lbMapScale')).Text :=
820 TGUIMapPreview(win
.GetControl('mpMapPreview')).GetScaleStr
;
825 procedure ProcSelectWAD(Sender
: TGUIControl
);
830 with TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu')) do
832 wad
:= TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
834 with TGUIListBox(GetControl('lsMapRes')) do
840 list
:= g_Map_GetMapsList(wad
);
854 procedure ProcSelectCampaignWAD(Sender
: TGUIControl
);
860 win
:= g_GUI_GetWindow('CampaignMenu');
861 with TGUIMenu(win
.GetControl('mCampaignMenu')) do
863 wad
:= TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
867 TGUILabel(GetControl('lbWADName')).Text := '';
868 TGUILabel(GetControl('lbWADAuthor')).Text := '';
869 TGUIMemo(GetControl('meWADDescription')).SetText('');
872 a
:= g_Game_GetMegaWADInfo(wad
);
874 TGUILabel(GetControl('lbWADName')).Text := a
.Name
;
875 TGUILabel(GetControl('lbWADAuthor')).Text := a
.Author
;
876 TGUIMemo(GetControl('meWADDescription')).SetText(a
.Description
);
878 TGUIImage(win
.GetControl('mpWADImage')).ClearImage();
882 fn
:= g_ExtractWadName(a
.pic
);
884 TGUIImage(win
.GetControl('mpWADImage')).SetImage(wad
+a
.pic
)
886 TGUIImage(win
.GetControl('mpWADImage')).SetImage(a
.pic
);
891 procedure ProcChangeColor(Sender
: TGUIControl
);
895 window
:= g_GUI_GetWindow('OptionsPlayersP1Menu');
896 with TGUIMenu(window
.GetControl('mOptionsPlayersP1Menu')) do
897 TGUIModelView(window
.GetControl('mvP1Model')).SetColor(
898 Min(TGUIScroll(GetControl('scP1Red')).Value
*16, 255),
899 Min(TGUIScroll(GetControl('scP1Green')).Value
*16, 255),
900 Min(TGUIScroll(GetControl('scP1Blue')).Value
*16, 255));
902 window
:= g_GUI_GetWindow('OptionsPlayersP2Menu');
903 with TGUIMenu(window
.GetControl('mOptionsPlayersP2Menu')) do
904 TGUIModelView(window
.GetControl('mvP2Model')).SetColor(
905 Min(TGUIScroll(GetControl('scP2Red')).Value
*16, 255),
906 Min(TGUIScroll(GetControl('scP2Green')).Value
*16, 255),
907 Min(TGUIScroll(GetControl('scP2Blue')).Value
*16, 255));
910 procedure ProcSelectModel(Sender
: TGUIControl
);
915 window
:= g_GUI_GetWindow('OptionsPlayersP1Menu');
916 a
:= TGUIListBox(TGUIMenu(window
.GetControl('mOptionsPlayersP1Menu')).GetControl('lsP1Model')).SelectedItem
;
917 if a
<> '' then TGUIModelView(window
.GetControl('mvP1Model')).SetModel(a
);
919 window
:= g_GUI_GetWindow('OptionsPlayersP2Menu');
920 a
:= TGUIListBox(TGUIMenu(window
.GetControl('mOptionsPlayersP2Menu')).GetControl('lsP2Model')).SelectedItem
;
921 if a
<> '' then TGUIModelView(window
.GetControl('mvP2Model')).SetModel(a
);
923 ProcChangeColor(nil);
926 procedure LoadStdFont(cfgres
, texture
: string; var FontID
: DWORD
);
938 wad
:= TWADFile
.Create
;
939 if wad
.ReadFile(GameWAD
) then
940 wad
.GetResource('FONTS/'+cfgres
, cfgdata
, cfglen
);
945 g_Texture_CreateWADEx('FONT_STD', GameWAD
+':FONTS\'+texture
);
947 config
:= TConfig
.CreateMem(cfgdata
, cfglen
);
948 cwdt
:= Min(Max(config
.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
949 chgt
:= Min(Max(config
.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
950 spc
:= Min(Max(config
.ReadInt('FontMap', 'Kerning', 0), -128), 127);
952 if g_Texture_Get('FONT_STD', ID
) then
953 e_TextureFontBuild(ID
, FontID
, cwdt
, chgt
, spc
);
958 if cfglen
<> 0 then FreeMem(cfgdata
);
961 procedure LoadFont(txtres
, fntres
: string; var FontID
: DWORD
);
967 cfgdata
, fntdata
: Pointer;
968 cfglen
, fntlen
: Integer;
976 wad
:= TWADFile
.Create
;
977 if wad
.ReadFile(GameWAD
) then
979 wad
.GetResource('FONTS/'+txtres
, cfgdata
, cfglen
);
980 wad
.GetResource('FONTS/'+fntres
, fntdata
, fntlen
);
986 config
:= TConfig
.CreateMem(cfgdata
, cfglen
);
987 cwdt
:= Min(Max(config
.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
988 chgt
:= Min(Max(config
.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
990 spc
:= Min(Max(config
.ReadInt('FontMap', 'Kerning', 0), -128), 127);
991 FontID
:= e_CharFont_Create(spc
);
995 chrwidth
:= config
.ReadInt(IntToStr(a
), 'Width', 0);
996 if chrwidth
= 0 then Continue
;
998 if e_CreateTextureMemEx(fntdata
, fntlen
, CharID
, cwdt
*(a
mod 16), chgt
*(a
div 16),
1000 e_CharFont_AddChar(FontID
, CharID
, Chr(a
), chrwidth
);
1006 if cfglen
<> 0 then FreeMem(cfgdata
);
1007 if fntlen
<> 0 then FreeMem(fntdata
);
1010 procedure MenuLoadData();
1012 e_WriteLog('Loading menu data...', TMsgType
.Notify
);
1014 g_Texture_CreateWADEx('MAINMENU_MARKER1', GameWAD
+':TEXTURES\MARKER1');
1015 g_Texture_CreateWADEx('MAINMENU_MARKER2', GameWAD
+':TEXTURES\MARKER2');
1016 g_Texture_CreateWADEx('SCROLL_LEFT', GameWAD
+':TEXTURES\SLEFT');
1017 g_Texture_CreateWADEx('SCROLL_RIGHT', GameWAD
+':TEXTURES\SRIGHT');
1018 g_Texture_CreateWADEx('SCROLL_MIDDLE', GameWAD
+':TEXTURES\SMIDDLE');
1019 g_Texture_CreateWADEx('SCROLL_MARKER', GameWAD
+':TEXTURES\SMARKER');
1020 g_Texture_CreateWADEx('EDIT_LEFT', GameWAD
+':TEXTURES\ELEFT');
1021 g_Texture_CreateWADEx('EDIT_RIGHT', GameWAD
+':TEXTURES\ERIGHT');
1022 g_Texture_CreateWADEx('EDIT_MIDDLE', GameWAD
+':TEXTURES\EMIDDLE');
1023 g_Texture_CreateWADEx('BOX1', GameWAD
+':TEXTURES\BOX1');
1024 g_Texture_CreateWADEx('BOX2', GameWAD
+':TEXTURES\BOX2');
1025 g_Texture_CreateWADEx('BOX3', GameWAD
+':TEXTURES\BOX3');
1026 g_Texture_CreateWADEx('BOX4', GameWAD
+':TEXTURES\BOX4');
1027 g_Texture_CreateWADEx('BOX5', GameWAD
+':TEXTURES\BOX5');
1028 g_Texture_CreateWADEx('BOX6', GameWAD
+':TEXTURES\BOX6');
1029 g_Texture_CreateWADEx('BOX7', GameWAD
+':TEXTURES\BOX7');
1030 g_Texture_CreateWADEx('BOX8', GameWAD
+':TEXTURES\BOX8');
1031 g_Texture_CreateWADEx('BOX9', GameWAD
+':TEXTURES\BOX9');
1032 g_Texture_CreateWADEx('BSCROLL_UP_A', GameWAD
+':TEXTURES\SCROLLUPA');
1033 g_Texture_CreateWADEx('BSCROLL_UP_U', GameWAD
+':TEXTURES\SCROLLUPU');
1034 g_Texture_CreateWADEx('BSCROLL_DOWN_A', GameWAD
+':TEXTURES\SCROLLDOWNA');
1035 g_Texture_CreateWADEx('BSCROLL_DOWN_U', GameWAD
+':TEXTURES\SCROLLDOWNU');
1036 g_Texture_CreateWADEx('BSCROLL_MIDDLE', GameWAD
+':TEXTURES\SCROLLMIDDLE');
1037 g_Texture_CreateWADEx('NOPIC', GameWAD
+':TEXTURES\NOPIC');
1039 g_Sound_CreateWADEx('MENU_SELECT', GameWAD
+':SOUNDS\MENUSELECT');
1040 g_Sound_CreateWADEx('MENU_OPEN', GameWAD
+':SOUNDS\MENUOPEN');
1041 g_Sound_CreateWADEx('MENU_CLOSE', GameWAD
+':SOUNDS\MENUCLOSE');
1042 g_Sound_CreateWADEx('MENU_CHANGE', GameWAD
+':SOUNDS\MENUCHANGE');
1043 g_Sound_CreateWADEx('SCROLL_ADD', GameWAD
+':SOUNDS\SCROLLADD');
1044 g_Sound_CreateWADEx('SCROLL_SUB', GameWAD
+':SOUNDS\SCROLLSUB');
1045 g_Sound_CreateWADEx('SOUND_PLAYER_FALL', GameWAD
+':SOUNDS\FALL');
1048 procedure MenuFreeData();
1050 e_CharFont_Remove(gMenuFont
);
1051 e_CharFont_Remove(gMenuSmallFont
);
1053 g_Texture_Delete('MAINMENU_MARKER1');
1054 g_Texture_Delete('MAINMENU_MARKER2');
1055 g_Texture_Delete('SCROLL_LEFT');
1056 g_Texture_Delete('SCROLL_RIGHT');
1057 g_Texture_Delete('SCROLL_MIDDLE');
1058 g_Texture_Delete('SCROLL_MARKER');
1059 g_Texture_Delete('EDIT_LEFT');
1060 g_Texture_Delete('EDIT_RIGHT');
1061 g_Texture_Delete('EDIT_MIDDLE');
1062 g_Texture_Delete('BOX1');
1063 g_Texture_Delete('BOX2');
1064 g_Texture_Delete('BOX3');
1065 g_Texture_Delete('BOX4');
1066 g_Texture_Delete('BOX5');
1067 g_Texture_Delete('BOX6');
1068 g_Texture_Delete('BOX7');
1069 g_Texture_Delete('BOX8');
1070 g_Texture_Delete('BOX9');
1071 g_Texture_Delete('BSCROLL_UP_A');
1072 g_Texture_Delete('BSCROLL_UP_U');
1073 g_Texture_Delete('BSCROLL_DOWN_A');
1074 g_Texture_Delete('BSCROLL_DOWN_U');
1075 g_Texture_Delete('BSCROLL_MIDDLE');
1076 g_Texture_Delete('NOPIC');
1078 g_Sound_Delete('MENU_SELECT');
1079 g_Sound_Delete('MENU_OPEN');
1080 g_Sound_Delete('MENU_CLOSE');
1081 g_Sound_Delete('MENU_CHANGE');
1082 g_Sound_Delete('SCROLL_ADD');
1083 g_Sound_Delete('SCROLL_SUB');
1084 g_Sound_Delete('SOUND_PLAYER_FALL');
1087 procedure ProcAuthorsMenu();
1089 gMusic
.SetByName('MUSIC_INTERMUS');
1093 procedure ProcExitMenuKeyDown (yes
: Boolean);
1096 snd
: TPlayableSound
;
1101 g_Game_StopAllSounds(True);
1102 case (Random(18)) of
1103 0: s
:= 'SOUND_MONSTER_PAIN';
1104 1: s
:= 'SOUND_MONSTER_DIE_3';
1105 2: s
:= 'SOUND_MONSTER_SLOP';
1106 3: s
:= 'SOUND_MONSTER_DEMON_DIE';
1107 4: s
:= 'SOUND_MONSTER_IMP_DIE_2';
1108 5: s
:= 'SOUND_MONSTER_MAN_DIE';
1109 6: s
:= 'SOUND_MONSTER_BSP_DIE';
1110 7: s
:= 'SOUND_MONSTER_VILE_DIE';
1111 8: s
:= 'SOUND_MONSTER_SKEL_DIE';
1112 9: s
:= 'SOUND_MONSTER_MANCUB_ALERT';
1113 10: s
:= 'SOUND_MONSTER_PAIN_PAIN';
1114 11: s
:= 'SOUND_MONSTER_BARON_DIE';
1115 12: s
:= 'SOUND_MONSTER_CACO_DIE';
1116 13: s
:= 'SOUND_MONSTER_CYBER_DIE';
1117 14: s
:= 'SOUND_MONSTER_KNIGHT_ALERT';
1118 15: s
:= 'SOUND_MONSTER_SPIDER_ALERT';
1119 else s
:= 'SOUND_PLAYER_FALL';
1121 snd
:= TPlayableSound
.Create();
1122 res
:= snd
.SetByName(s
);
1123 if not res
then res
:= snd
.SetByName('SOUND_PLAYER_FALL');
1127 while snd
.IsPlaying() do begin end;
1135 procedure ProcLoadMenu();
1142 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a
))).Text := g_GetSaveName(a
, valid
);
1143 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a
))).Invalid
:= not valid
;
1144 //TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a)).Enabled := valid;
1148 procedure ProcSaveMenu();
1156 name
:= g_GetSaveName(a
, valid
);
1157 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a
))).Text := name
;
1158 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a
))).Invalid
:= (name
<> '') and (not valid
);
1162 procedure ProcSaveGame(Sender
: TGUIControl
);
1166 if g_Game_IsNet
then Exit
;
1167 if g_Game_IsTestMap
then Exit
;
1168 a
:= StrToInt(Copy(Sender
.Name
, Length(Sender
.Name
), 1));
1169 g_Game_PauseAllSounds(True);
1170 g_SaveGame(a
, TGUIEdit(Sender
).Text);
1172 g_ActiveWindow
:= nil;
1173 g_Game_Pause(False);
1176 procedure ProcLoadGame(Sender
: TGUIControl
);
1180 if g_Game_IsNet
then Exit
;
1181 a
:= StrToInt(Copy(Sender
.Name
, Length(Sender
.Name
), 1));
1182 if g_LoadGame(a
) then
1184 g_Game_PauseAllSounds(False)
1186 else // Íå çàãðóçèëîñü - âîçâðàò â ìåíþ
1188 g_Console_Add(_lc
[I_MSG_BAD_SAVE_VERSION
], true);
1189 g_GUI_GetWindow('LoadMenu').SetActive(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu'));
1190 //g_ActiveWindow := nil;
1194 procedure ProcSingle1Player();
1196 g_Game_StartSingle(gDefaultMegawadStart
, False, 1);
1199 procedure ProcSingle2Players();
1201 g_Game_StartSingle(gDefaultMegawadStart
, True, 2);
1204 procedure ProcSelectMapMenu();
1207 wad_lb
: TGUIFileListBox
;
1208 map_lb
: TGUIListBox
;
1211 menu
:= TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1212 wad_lb
:= TGUIFileListBox(menu
.GetControl('lsMapWAD'));
1213 map_lb
:= TGUIListBox(menu
.GetControl('lsMapRes'));
1215 if wad_lb
.SelectedItem() <> '' then
1216 map
:= map_lb
.SelectedItem()
1220 wad_lb
.UpdateFileList();
1223 if wad_lb
.SelectedItem() <> '' then
1226 map_lb
.SelectItem(map
);
1228 if map_lb
.SelectedItem() <> '' then
1232 g_GUI_ShowWindow('SelectMapMenu');
1235 procedure ProcSelectCampaignMenu();
1238 wad_lb
: TGUIFileListBox
;
1240 menu
:= TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1241 wad_lb
:= TGUIFileListBox(menu
.GetControl('lsWAD'));
1243 wad_lb
.UpdateFileList();
1245 if wad_lb
.SelectedItem() <> '' then
1246 ProcSelectCampaignWAD(nil);
1249 procedure ProcSetMap();
1251 wad
, map
, res
: String;
1253 with TGUIMenu(g_ActiveWindow
.GetControl('mSelectMapMenu')) do
1255 wad
:= ExtractRelativePath(MapsDir
, TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem());
1256 map
:= TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1259 if (wad
= '') or (map
= '') then
1262 res
:= wad
+':\'+map
;
1264 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res
;
1265 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res
;
1268 procedure ProcChangeSoundSettings(Sender
: TGUIControl
);
1272 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1274 g_Sound_SetupAllVolumes(
1275 Min(TGUIScroll(menu
.GetControl('scSoundLevel')).Value
*16, 255),
1276 Min(TGUIScroll(menu
.GetControl('scMusicLevel')).Value
*16, 255)
1280 procedure ProcChangeGameSettings(Sender
: TGUIControl
);
1284 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
1285 g_dbg_scale
:= TGUIScroll(menu
.GetControl('scScaleFactor')).Value
+ 1;
1288 procedure ProcChangeTouchSettings(Sender
: TGUIControl
);
1292 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
1293 g_touch_size
:= TGUIScroll(menu
.GetControl('scTouchSize')).Value
/ 10 + 0.5;
1296 procedure ProcOptionsPlayersMIMenu();
1301 if g_ActiveWindow
.Name
= 'OptionsPlayersP1Menu' then s
:= 'P1' else s
:= 'P2';
1303 a
:= TGUIListBox(TGUIMenu(g_ActiveWindow
.GetControl('mOptionsPlayers'+s
+'Menu')).GetControl('ls'+s
+'Model')).SelectedItem
;
1305 if a
= '' then Exit
;
1307 b
:= g_PlayerModel_GetInfo(a
);
1309 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1311 TGUILabel(GetControl('lbName')).Text := b
.Name
;
1312 TGUILabel(GetControl('lbAuthor')).Text := b
.Author
;
1313 TGUIMemo(GetControl('meComment')).SetText(b
.Description
);
1315 if b
.HaveWeapon
then
1316 TGUILabel(GetControl('lbWeapon')).Text := _lc
[I_MENU_YES
]
1318 TGUILabel(GetControl('lbWeapon')).Text := _lc
[I_MENU_NO
];
1321 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1324 procedure ProcOptionsPlayersAnim();
1328 if g_ActiveWindow
.Name
= 'OptionsPlayersP1Menu' then
1333 with TGUIModelView(g_ActiveWindow
.GetControl('mv'+s
+'Model')) do
1336 Model
.GetCurrentAnimation
.Loop
:= True;
1337 Model
.GetCurrentAnimationMask
.Loop
:= True;
1341 procedure ProcOptionsPlayersWeap();
1345 if g_ActiveWindow
.Name
= 'OptionsPlayersP1Menu' then
1350 with TGUIModelView(g_ActiveWindow
.GetControl('mv'+s
+'Model')) do
1354 procedure ProcOptionsPlayersRot();
1358 if g_ActiveWindow
.Name
= 'OptionsPlayersP1Menu' then s
:= 'P1' else s
:= 'P2';
1359 with TGUIModelView(g_ActiveWindow
.GetControl('mv'+s
+'Model')).Model
do
1361 if Direction
= TDirection
.D_LEFT
then Direction
:= TDirection
.D_RIGHT
else Direction
:= TDirection
.D_LEFT
;
1365 procedure ProcDefaultMenuKeyDown (yes
: Boolean);
1369 g_Options_SetDefault();
1375 procedure ProcSavedMenuKeyDown (yes
: Boolean);
1377 if yes
then ReadOptions();
1381 procedure ProcAuthorsClose();
1383 gMusic
.SetByName('MUSIC_MENU');
1385 gState
:= STATE_MENU
;
1388 procedure ProcGMClose();
1390 g_Game_InGameMenu(False);
1393 procedure ProcGMShow();
1398 if (gGameSettings
.GameType
= GT_SINGLE
) and
1399 ((gPlayer1
= nil) or (not gPlayer1
.alive
)) and
1400 ((gPlayer2
= nil) or (not gPlayer2
.alive
)) then
1401 Enabled
:= False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1403 Enabled
:= False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1404 if g_Game_IsTestMap
then
1405 Enabled
:= False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1406 TGUIMainMenu(g_ActiveWindow
.GetControl(
1407 g_ActiveWindow
.DefControl
)).EnableButton('save', Enabled
);
1410 procedure ProcChangePlayers();
1412 TeamGame
, Spectator
, AddTwo
: Boolean;
1413 P1Team
{, P2Team}: Byte;
1414 bP2
: TGUITextButton
;
1416 TeamGame
:= gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
];
1417 Spectator
:= (gPlayer1
= nil) and (gPlayer2
= nil);
1418 AddTwo
:= gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
];
1419 P1Team
:= TEAM_NONE
;
1420 if gPlayer1
<> nil then P1Team
:= gPlayer1
.Team
;
1422 //P2Team := TEAM_NONE;
1423 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1425 TGUIMainMenu(g_ActiveWindow
.GetControl(
1426 g_ActiveWindow
.DefControl
)).EnableButton('tmJoinRed', TeamGame
and (P1Team
<> TEAM_RED
));
1427 TGUIMainMenu(g_ActiveWindow
.GetControl(
1428 g_ActiveWindow
.DefControl
)).EnableButton('tmJoinBlue', TeamGame
and (P1Team
<> TEAM_BLUE
));
1429 TGUIMainMenu(g_ActiveWindow
.GetControl(
1430 g_ActiveWindow
.DefControl
)).EnableButton('tmJoinGame', Spectator
and not TeamGame
);
1432 bP2
:= TGUIMainMenu(g_ActiveWindow
.GetControl(
1433 g_ActiveWindow
.DefControl
)).GetButton('tmPlayer2');
1434 bP2
.Enabled
:= AddTwo
and not Spectator
;
1436 bP2
.Color
:= MAINMENU_ITEMS_COLOR
1438 bP2
.Color
:= MAINMENU_UNACTIVEITEMS_COLOR
;
1439 if gPlayer2
= nil then
1440 bP2
.Caption
:= _lc
[I_MENU_ADD_PLAYER_2
]
1442 bP2
.Caption
:= _lc
[I_MENU_REM_PLAYER_2
];
1444 TGUIMainMenu(g_ActiveWindow
.GetControl(
1445 g_ActiveWindow
.DefControl
)).EnableButton('tmSpectate', not Spectator
);
1448 procedure ProcJoinRed();
1450 if not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
]) then
1452 if g_Game_IsServer
then
1454 if gPlayer1
= nil then
1455 g_Game_AddPlayer(TEAM_RED
)
1458 if gPlayer1
.Team
<> TEAM_RED
then
1460 gPlayer1
.SwitchTeam
;
1461 gPlayer1Settings
.Team
:= gPlayer1
.Team
;
1464 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
1469 gPlayer1Settings
.Team
:= TEAM_RED
;
1470 MC_SEND_PlayerSettings
;
1471 if gPlayer1
= nil then
1472 g_Game_AddPlayer(TEAM_RED
);
1474 g_ActiveWindow
:= nil;
1475 g_Game_Pause(False);
1478 procedure ProcJoinBlue();
1480 if not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
]) then
1482 if g_Game_IsServer
then
1484 if gPlayer1
= nil then
1485 g_Game_AddPlayer(TEAM_BLUE
)
1488 if gPlayer1
.Team
<> TEAM_BLUE
then
1490 gPlayer1
.SwitchTeam
;
1491 gPlayer1Settings
.Team
:= gPlayer1
.Team
;
1494 if g_Game_IsNet
then MH_SEND_PlayerSettings(gPlayer1
.UID
);
1499 gPlayer1Settings
.Team
:= TEAM_BLUE
;
1500 MC_SEND_PlayerSettings
;
1501 if gPlayer1
= nil then
1502 g_Game_AddPlayer(TEAM_BLUE
);
1504 g_ActiveWindow
:= nil;
1505 g_Game_Pause(False);
1508 procedure ProcJoinGame();
1510 if not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
]) then
1512 if gPlayer1
= nil then
1514 g_ActiveWindow
:= nil;
1515 g_Game_Pause(False);
1518 procedure ProcSwitchP2();
1520 if not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
]) then
1522 if gPlayer1
= nil then
1524 if gPlayer2
= nil then
1527 g_Game_RemovePlayer();
1528 g_ActiveWindow
:= nil;
1529 g_Game_Pause(False);
1532 procedure ProcSpectate();
1534 if not (gGameSettings
.GameType
in [GT_CUSTOM
, GT_SERVER
, GT_CLIENT
]) then
1537 g_ActiveWindow
:= nil;
1538 g_Game_Pause(False);
1541 procedure ProcRestartMenuKeyDown (yes
: Boolean);
1543 if yes
then g_Game_Restart() else g_GUI_HideWindow
;
1546 procedure ProcEndMenuKeyDown (yes
: Boolean);
1548 if yes
then gExit
:= EXIT_SIMPLE
else g_GUI_HideWindow
;
1551 procedure ProcSetRussianLanguage();
1553 if gLanguage
<> LANGUAGE_RUSSIAN
then
1555 gLanguage
:= LANGUAGE_RUSSIAN
;
1556 gLanguageChange
:= True;
1557 gAskLanguage
:= False;
1559 g_Options_Write_Language(GameDir
+'/'+CONFIG_FILENAME
);
1561 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1566 procedure ProcSetEnglishLanguage();
1568 if gLanguage
<> LANGUAGE_ENGLISH
then
1570 gLanguage
:= LANGUAGE_ENGLISH
;
1571 gLanguageChange
:= True;
1572 gAskLanguage
:= False;
1574 g_Options_Write_Language(GameDir
+'/'+CONFIG_FILENAME
);
1576 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1581 procedure ReadGameSettings();
1585 menu
:= TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1587 with gGameSettings
do
1589 with TGUISwitch(menu
.GetControl('swTeamDamage')) do
1590 if LongBool(Options
and GAME_OPTION_TEAMDAMAGE
) then
1595 TGUIEdit(menu
.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit
);
1596 TGUIEdit(menu
.GetControl('edGoalLimit')).Text := IntToStr(GoalLimit
);
1597 TGUIEdit(menu
.GetControl('edMaxLives')).Text := IntToStr(MaxLives
);
1599 with TGUISwitch(menu
.GetControl('swBotsVS')) do
1600 if LongBool(Options
and GAME_OPTION_BOTVSPLAYER
) and
1601 LongBool(Options
and GAME_OPTION_BOTVSMONSTER
) then
1604 if LongBool(Options
and GAME_OPTION_BOTVSMONSTER
) then
1609 if GameType
in [GT_CUSTOM
, GT_SERVER
] then
1611 TGUISwitch(menu
.GetControl('swTeamDamage')).Enabled
:= True;
1612 TGUIEdit(menu
.GetControl('edTimeLimit')).Enabled
:= True;
1613 TGUILabel(menu
.GetControlsText('edTimeLimit')).Color
:= MENU_ITEMSTEXT_COLOR
;
1614 TGUIEdit(menu
.GetControl('edGoalLimit')).Enabled
:= True;
1615 TGUILabel(menu
.GetControlsText('edGoalLimit')).Color
:= MENU_ITEMSTEXT_COLOR
;
1616 TGUIEdit(menu
.GetControl('edMaxLives')).Enabled
:= True;
1617 TGUILabel(menu
.GetControlsText('edMaxLives')).Color
:= MENU_ITEMSTEXT_COLOR
;
1618 TGUISwitch(menu
.GetControl('swBotsVS')).Enabled
:= True;
1622 TGUISwitch(menu
.GetControl('swTeamDamage')).Enabled
:= True;
1623 with TGUIEdit(menu
.GetControl('edTimeLimit')) do
1628 TGUILabel(menu
.GetControlsText('edTimeLimit')).Color
:= MENU_UNACTIVEITEMS_COLOR
;
1629 with TGUIEdit(menu
.GetControl('edGoalLimit')) do
1634 TGUILabel(menu
.GetControlsText('edGoalLimit')).Color
:= MENU_UNACTIVEITEMS_COLOR
;
1635 with TGUIEdit(menu
.GetControl('edMaxLives')) do
1640 TGUILabel(menu
.GetControlsText('edMaxLives')).Color
:= MENU_UNACTIVEITEMS_COLOR
;
1641 TGUISwitch(menu
.GetControl('swBotsVS')).Enabled
:= True;
1646 procedure ProcApplyGameSet();
1650 stat
: TPlayerStatArray
;
1652 menu
:= TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1654 if not g_Game_IsServer
then Exit
;
1656 with gGameSettings
do
1658 if TGUISwitch(menu
.GetControl('swTeamDamage')).Enabled
then
1660 if TGUISwitch(menu
.GetControl('swTeamDamage')).ItemIndex
= 0 then
1661 Options
:= Options
or GAME_OPTION_TEAMDAMAGE
1663 Options
:= Options
and (not GAME_OPTION_TEAMDAMAGE
);
1666 if TGUIEdit(menu
.GetControl('edTimeLimit')).Enabled
then
1668 n
:= StrToIntDef(TGUIEdit(menu
.GetControl('edTimeLimit')).Text, TimeLimit
);
1674 b
:= (gTime
- gGameStartTime
) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1676 TimeLimit
:= Max(n
, b
);
1680 if TGUIEdit(menu
.GetControl('edGoalLimit')).Enabled
then
1682 n
:= StrToIntDef(TGUIEdit(menu
.GetControl('edGoalLimit')).Text, GoalLimit
);
1689 if GameMode
= GM_DM
then
1691 stat
:= g_Player_GetStats();
1693 for a
:= 0 to High(stat
) do
1694 if stat
[a
].Frags
> b
then
1698 b
:= Max(gTeamStat
[TEAM_RED
].Goals
, gTeamStat
[TEAM_BLUE
].Goals
);
1700 GoalLimit
:= Max(n
, b
);
1704 if TGUIEdit(menu
.GetControl('edMaxLives')).Enabled
then
1706 n
:= StrToIntDef(TGUIEdit(menu
.GetControl('edMaxLives')).Text, GoalLimit
);
1707 if n
< 0 then n
:= 0;
1708 if n
> 255 then n
:= 255;
1714 stat
:= g_Player_GetStats();
1716 for a
:= 0 to High(stat
) do
1717 if stat
[a
].Lives
> b
then
1720 MaxLives
:= Max(n
, b
);
1724 if TGUISwitch(menu
.GetControl('swBotsVS')).Enabled
then
1726 case TGUISwitch(menu
.GetControl('swBotsVS')).ItemIndex
of
1729 Options
:= Options
and (not GAME_OPTION_BOTVSPLAYER
);
1730 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
;
1734 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
;
1735 Options
:= Options
or GAME_OPTION_BOTVSMONSTER
;
1739 Options
:= Options
or GAME_OPTION_BOTVSPLAYER
;
1740 Options
:= Options
and (not GAME_OPTION_BOTVSMONSTER
);
1746 if g_Game_IsNet
then MH_SEND_GameSettings
;
1749 procedure ProcVideoOptionsRes();
1755 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1757 TGUILabel(menu
.GetControl('lbCurrentRes')).Text :=
1758 IntToStr(gScreenWidth
) +
1759 ' x ' + IntToStr(gScreenHeight
) +
1760 ', ' + IntToStr(gBPP
) + ' bpp';
1762 with TGUIListBox(menu
.GetControl('lsResolution')) do
1764 list
:= GetDisplayModes(gBPP
, SR
);
1775 with TGUISwitch(menu
.GetControl('swFullScreen')) do
1782 procedure ProcApplyVideoOptions();
1785 Fullscreen
: Boolean;
1786 SWidth
, SHeight
: Integer;
1789 menu
:= TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1791 str
:= TGUIListBox(menu
.GetControl('lsResolution')).SelectedItem
;
1792 SScanf(str
, '%dx%d', [@SWidth
, @SHeight
]);
1794 Fullscreen
:= TGUISwitch(menu
.GetControl('swFullScreen')).ItemIndex
= 0;
1796 if (SWidth
<> gScreenWidth
) or
1797 (SHeight
<> gScreenHeight
) or
1798 (Fullscreen
<> gFullscreen
) then
1800 gResolutionChange
:= True;
1801 gRC_Width
:= SWidth
;
1802 gRC_Height
:= SHeight
;
1803 gRC_FullScreen
:= Fullscreen
;
1804 gRC_Maximized
:= gWinMaximized
;
1807 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1811 procedure ProcSetFirstRussianLanguage();
1813 gLanguage
:= LANGUAGE_RUSSIAN
;
1814 gLanguageChange
:= True;
1815 gAskLanguage
:= False;
1817 g_Options_Write_Language(GameDir
+'/'+CONFIG_FILENAME
);
1820 procedure ProcSetFirstEnglishLanguage();
1822 gLanguage
:= LANGUAGE_ENGLISH
;
1823 gLanguageChange
:= True;
1824 gAskLanguage
:= False;
1826 g_Options_Write_Language(GameDir
+'/'+CONFIG_FILENAME
);
1829 procedure ProcRecallAddress();
1831 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1833 TGUIEdit(GetControl('edIP')).Text := NetClientIP
;
1834 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort
);
1838 procedure CreateFirstLanguageMenu();
1842 Menu
:= TGUIWindow
.Create('FirstLanguageMenu');
1844 with TGUIMainMenu(Menu
.AddChild(TGUIMainMenu
.Create(gMenuFont
, ' '))) do
1846 Name
:= 'mmFirstLanguageMenu';
1847 AddButton(@ProcSetFirstRussianLanguage
, 'Ðóññêèé', '');
1848 AddButton(@ProcSetFirstEnglishLanguage
, 'English', '');
1851 Menu
.DefControl
:= 'mmFirstLanguageMenu';
1852 Menu
.MainWindow
:= True;
1853 g_GUI_AddWindow(Menu
);
1856 procedure g_Menu_AskLanguage();
1858 CreateFirstLanguageMenu();
1859 g_GUI_ShowWindow('FirstLanguageMenu');
1862 procedure CreatePlayerOptionsMenu(s
: String);
1867 Menu
:= TGUIWindow
.Create('OptionsPlayers'+s
+'Menu');
1869 a
:= _lc
[I_MENU_PLAYER_1
]
1871 a
:= _lc
[I_MENU_PLAYER_2
];
1872 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, a
))) do
1874 Name
:= 'mOptionsPlayers'+s
+'Menu';
1875 with AddEdit(_lc
[I_MENU_PLAYER_NAME
]) do
1877 Name
:= 'ed'+s
+'Name';
1881 with AddSwitch(_lc
[I_MENU_PLAYER_TEAM
]) do
1883 Name
:= 'sw'+s
+'Team';
1884 AddItem(_lc
[I_MENU_PLAYER_TEAM_RED
]);
1885 AddItem(_lc
[I_MENU_PLAYER_TEAM_BLUE
]);
1887 with AddList(_lc
[I_MENU_PLAYER_MODEL
], 12, 6) do
1889 Name
:= 'ls'+s
+'Model';
1891 Items
:= g_PlayerModel_GetNames();
1892 OnChange
:= ProcSelectModel
;
1894 with AddScroll(_lc
[I_MENU_PLAYER_RED
]) do
1896 Name
:= 'sc'+s
+'Red';
1898 OnChange
:= ProcChangeColor
;
1900 with AddScroll(_lc
[I_MENU_PLAYER_GREEN
]) do
1902 Name
:= 'sc'+s
+'Green';
1904 OnChange
:= ProcChangeColor
;
1906 with AddScroll(_lc
[I_MENU_PLAYER_BLUE
]) do
1908 Name
:= 'sc'+s
+'Blue';
1910 OnChange
:= ProcChangeColor
;
1913 AddButton(@ProcOptionsPlayersMIMenu
, _lc
[I_MENU_MODEL_INFO
]);
1914 AddButton(@ProcOptionsPlayersAnim
, _lc
[I_MENU_MODEL_ANIMATION
]);
1915 AddButton(@ProcOptionsPlayersWeap
, _lc
[I_MENU_MODEL_CHANGE_WEAPON
]);
1916 AddButton(@ProcOptionsPlayersRot
, _lc
[I_MENU_MODEL_ROTATE
]);
1918 with TGUIModelView(Menu
.AddChild(TGUIModelView
.Create
)) do
1920 Name
:= 'mv'+s
+'Model';
1921 X
:= GetControl('ls'+s
+'Model').X
+TGUIListBox(GetControl('ls'+s
+'Model')).GetWidth
+16;
1922 Y
:= GetControl('ls'+s
+'Model').Y
;
1925 Menu
.DefControl
:= 'mOptionsPlayers'+s
+'Menu';
1926 g_GUI_AddWindow(Menu
);
1929 procedure CreateAllMenus();
1933 a
, cx
, _y
, i
: Integer;
1936 Menu
:= TGUIWindow
.Create('MainMenu');
1937 with TGUIMainMenu(Menu
.AddChild(TGUIMainMenu
.Create(gMenuFont
, _lc
[I_MENU_MAIN_MENU
]))) do
1939 Name
:= 'mmMainMenu';
1940 AddButton(nil, _lc
[I_MENU_NEW_GAME
], 'NewGameMenu');
1941 AddButton(nil, _lc
[I_MENU_MULTIPLAYER
], 'NetGameMenu');
1942 AddButton(nil, _lc
[I_MENU_LOAD_GAME
], 'LoadMenu');
1943 AddButton(@ReadOptions
, _lc
[I_MENU_OPTIONS
], 'OptionsMenu');
1944 AddButton(@ProcAuthorsMenu
, _lc
[I_MENU_AUTHORS
], 'AuthorsMenu');
1945 AddButton(nil, _lc
[I_MENU_EXIT
], 'ExitMenu');
1947 with TGUILabel(Menu
.AddChild(TGUILabel
.Create(Format(_lc
[I_VERSION
], [GAME_VERSION
]), gMenuSmallFont
))) do
1949 Color
:= _RGB(255, 255, 255);
1950 X
:= gScreenWidth
-GetWidth
-8;
1951 Y
:= gScreenHeight
-GetHeight
-8;
1953 Menu
.DefControl
:= 'mmMainMenu';
1954 Menu
.MainWindow
:= True;
1955 g_GUI_AddWindow(Menu
);
1957 Menu
:= TGUIWindow
.Create('NewGameMenu');
1958 with TGUIMainMenu(Menu
.AddChild(TGUIMainMenu
.Create(gMenuFont
, _lc
[I_MENU_NEW_GAME
]))) do
1960 Name
:= 'mmNewGameMenu';
1961 AddButton(@ProcSingle1Player
, _lc
[I_MENU_1_PLAYER
]);
1962 AddButton(@ProcSingle2Players
, _lc
[I_MENU_2_PLAYERS
]);
1963 AddButton(nil, _lc
[I_MENU_CUSTOM_GAME
], 'CustomGameMenu');
1964 AddButton(@ProcSelectCampaignMenu
, _lc
[I_MENU_CAMPAIGN
], 'CampaignMenu');
1966 Menu
.DefControl
:= 'mmNewGameMenu';
1967 g_GUI_AddWindow(Menu
);
1969 Menu
:= TGUIWindow
.Create('NetGameMenu');
1970 with TGUIMainMenu(Menu
.AddChild(TGUIMainMenu
.Create(gMenuFont
, _lc
[I_MENU_MULTIPLAYER
]))) do
1972 Name
:= 'mmNetGameMenu';
1973 AddButton(@ProcRecallAddress
, _lc
[I_MENU_START_CLIENT
], 'NetClientMenu');
1974 AddButton(nil, _lc
[I_MENU_START_SERVER
], 'NetServerMenu');
1976 Menu
.DefControl
:= 'mmNetGameMenu';
1977 g_GUI_AddWindow(Menu
);
1979 Menu
:= TGUIWindow
.Create('NetServerMenu');
1980 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_START_SERVER
]))) do
1982 Name
:= 'mNetServerMenu';
1983 with AddEdit(_lc
[I_NET_SERVER_NAME
]) do
1985 Name
:= 'edSrvName';
1986 OnlyDigits
:= False;
1989 Text := NetServerName
;
1991 with AddEdit(_lc
[I_NET_SERVER_PASSWORD
]) do
1993 Name
:= 'edSrvPassword';
1994 OnlyDigits
:= False;
1997 Text := NetPassword
;
1999 with AddEdit(_lc
[I_NET_PORT
]) do
2005 Text := IntToStr(NetPort
);
2007 with AddEdit(_lc
[I_NET_MAX_CLIENTS
]) do
2009 Name
:= 'edMaxPlayers';
2013 Text := IntToStr(NetMaxClients
);
2015 with AddSwitch(_lc
[I_NET_USE_MASTER
]) do
2017 Name
:= 'swUseMaster';
2018 AddItem(_lc
[I_MENU_YES
]);
2019 AddItem(_lc
[I_MENU_NO
]);
2020 if NetUseMaster
then
2026 with AddLabel(_lc
[I_MENU_MAP
]) do
2031 OnClick
:= @ProcSelectMapMenu
;
2033 with AddSwitch(_lc
[I_MENU_GAME_TYPE
]) do
2035 Name
:= 'swGameMode';
2036 AddItem(_lc
[I_MENU_GAME_TYPE_DM
]);
2037 AddItem(_lc
[I_MENU_GAME_TYPE_TDM
]);
2038 AddItem(_lc
[I_MENU_GAME_TYPE_CTF
]);
2039 AddItem(_lc
[I_MENU_GAME_TYPE_COOP
]);
2040 case g_Game_TextToMode(gnGameMode
) of
2042 GM_DM
: ItemIndex
:= 0;
2043 GM_TDM
: ItemIndex
:= 1;
2044 GM_CTF
: ItemIndex
:= 2;
2046 GM_COOP
: ItemIndex
:= 3;
2048 OnChange
:= ProcSwitchMonstersNet
;
2050 with AddEdit(_lc
[I_MENU_TIME_LIMIT
]) do
2052 Name
:= 'edTimeLimit';
2056 if gnTimeLimit
> 0 then
2057 Text := IntToStr(gnTimeLimit
);
2059 with AddEdit(_lc
[I_MENU_GOAL_LIMIT
]) do
2061 Name
:= 'edGoalLimit';
2065 if gnGoalLimit
> 0 then
2066 Text := IntToStr(gnGoalLimit
);
2068 with AddEdit(_lc
[I_MENU_MAX_LIVES
]) do
2070 Name
:= 'edMaxLives';
2074 if gnMaxLives
> 0 then
2075 Text := IntToStr(gnMaxLives
);
2077 with AddSwitch(_lc
[I_MENU_SERVER_PLAYERS
]) do
2079 Name
:= 'swPlayers';
2080 AddItem(_lc
[I_MENU_COUNT_NONE
]);
2081 AddItem(_lc
[I_MENU_PLAYERS_ONE
]);
2082 AddItem(_lc
[I_MENU_PLAYERS_TWO
]);
2083 ItemIndex
:= gnPlayers
;
2085 with AddSwitch(_lc
[I_MENU_TEAM_DAMAGE
]) do
2087 Name
:= 'swTeamDamage';
2088 AddItem(_lc
[I_MENU_YES
]);
2089 AddItem(_lc
[I_MENU_NO
]);
2090 if gnTeamDamage
then
2095 with AddSwitch(_lc
[I_MENU_ENABLE_EXITS
]) do
2097 Name
:= 'swEnableExits';
2098 AddItem(_lc
[I_MENU_YES
]);
2099 AddItem(_lc
[I_MENU_NO
]);
2105 with AddSwitch(_lc
[I_MENU_WEAPONS_STAY
]) do
2107 Name
:= 'swWeaponStay';
2108 AddItem(_lc
[I_MENU_YES
]);
2109 AddItem(_lc
[I_MENU_NO
]);
2110 if gnWeaponStay
then
2115 with AddSwitch(_lc
[I_MENU_ENABLE_MONSTERS
]) do
2117 Name
:= 'swMonsters';
2118 AddItem(_lc
[I_MENU_YES
]);
2119 AddItem(_lc
[I_MENU_NO
]);
2125 with AddSwitch(_lc
[I_MENU_BOTS_VS
]) do
2128 AddItem(_lc
[I_MENU_BOTS_VS_PLAYERS
]);
2129 AddItem(_lc
[I_MENU_BOTS_VS_MONSTERS
]);
2130 AddItem(_lc
[I_MENU_BOTS_VS_ALL
]);
2132 if gnBotsVS
= 'Players' then
2134 if gnBotsVS
= 'Monsters' then
2138 AddButton(@ProcStartNetGame
, _lc
[I_MENU_START_GAME
]);
2142 Menu
.DefControl
:= 'mNetServerMenu';
2143 g_GUI_AddWindow(Menu
);
2145 Menu
:= TGUIWindow
.Create('NetClientMenu');
2146 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_START_CLIENT
]))) do
2148 Name
:= 'mNetClientMenu';
2150 AddButton(@ProcServerlist
, _lc
[I_NET_SLIST
]);
2153 with AddEdit(_lc
[I_NET_ADDRESS
]) do
2159 Text := 'localhost';
2161 with AddEdit(_lc
[I_NET_PORT
]) do
2169 with AddEdit(_lc
[I_NET_SERVER_PASSWORD
]) do
2172 OnlyDigits
:= False;
2179 AddButton(@ProcConnectNetGame
, _lc
[I_MENU_CLIENT_CONNECT
]);
2183 Menu
.DefControl
:= 'mNetClientMenu';
2184 g_GUI_AddWindow(Menu
);
2186 Menu
:= TGUIWindow
.Create('LoadMenu');
2187 Menu
.OnShow
:= ProcLoadMenu
;
2188 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_LOAD_GAME
]))) do
2190 Name
:= 'mmLoadMenu';
2195 Name
:= 'edSlot'+IntToStr(a
);
2198 OnEnter
:= ProcLoadGame
;
2201 Menu
.DefControl
:= 'mmLoadMenu';
2202 g_GUI_AddWindow(Menu
);
2204 Menu
:= TGUIWindow
.Create('SaveMenu');
2205 Menu
.OnShow
:= ProcSaveMenu
;
2206 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_SAVE_GAME
]))) do
2208 Name
:= 'mmSaveMenu';
2213 Name
:= 'edSlot'+IntToStr(a
);
2216 OnChange
:= ProcSaveGame
;
2219 Menu
.DefControl
:= 'mmSaveMenu';
2220 g_GUI_AddWindow(Menu
);
2222 Menu
:= TGUIWindow
.Create('CustomGameMenu');
2223 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_CUSTOM_GAME
]))) do
2225 Name
:= 'mCustomGameMenu';
2226 with AddLabel(_lc
[I_MENU_MAP
]) do
2231 OnClick
:= @ProcSelectMapMenu
;
2233 with AddSwitch(_lc
[I_MENU_GAME_TYPE
]) do
2235 Name
:= 'swGameMode';
2236 AddItem(_lc
[I_MENU_GAME_TYPE_DM
]);
2237 AddItem(_lc
[I_MENU_GAME_TYPE_TDM
]);
2238 AddItem(_lc
[I_MENU_GAME_TYPE_CTF
]);
2239 AddItem(_lc
[I_MENU_GAME_TYPE_COOP
]);
2240 case g_Game_TextToMode(gcGameMode
) of
2242 GM_DM
: ItemIndex
:= 0;
2243 GM_TDM
: ItemIndex
:= 1;
2244 GM_CTF
: ItemIndex
:= 2;
2246 GM_COOP
: ItemIndex
:= 3;
2248 OnChange
:= ProcSwitchMonstersCustom
;
2250 with AddEdit(_lc
[I_MENU_TIME_LIMIT
]) do
2252 Name
:= 'edTimeLimit';
2256 if gcTimeLimit
> 0 then
2257 Text := IntToStr(gcTimeLimit
);
2259 with AddEdit(_lc
[I_MENU_GOAL_LIMIT
]) do
2261 Name
:= 'edGoalLimit';
2265 if gcGoalLimit
> 0 then
2266 Text := IntToStr(gcGoalLimit
);
2268 with AddEdit(_lc
[I_MENU_MAX_LIVES
]) do
2270 Name
:= 'edMaxLives';
2274 if gcMaxLives
> 0 then
2275 Text := IntToStr(gcMaxLives
);
2277 with AddSwitch(_lc
[I_MENU_PLAYERS
]) do
2279 Name
:= 'swPlayers';
2280 AddItem(_lc
[I_MENU_COUNT_NONE
]);
2281 AddItem(_lc
[I_MENU_PLAYERS_ONE
]);
2282 AddItem(_lc
[I_MENU_PLAYERS_TWO
]);
2283 ItemIndex
:= gcPlayers
;
2285 with AddSwitch(_lc
[I_MENU_TEAM_DAMAGE
]) do
2287 Name
:= 'swTeamDamage';
2288 AddItem(_lc
[I_MENU_YES
]);
2289 AddItem(_lc
[I_MENU_NO
]);
2290 if gcTeamDamage
then
2295 with AddSwitch(_lc
[I_MENU_ENABLE_EXITS
]) do
2297 Name
:= 'swEnableExits';
2298 AddItem(_lc
[I_MENU_YES
]);
2299 AddItem(_lc
[I_MENU_NO
]);
2305 with AddSwitch(_lc
[I_MENU_WEAPONS_STAY
]) do
2307 Name
:= 'swWeaponStay';
2308 AddItem(_lc
[I_MENU_YES
]);
2309 AddItem(_lc
[I_MENU_NO
]);
2310 if gcWeaponStay
then
2315 with AddSwitch(_lc
[I_MENU_ENABLE_MONSTERS
]) do
2317 Name
:= 'swMonsters';
2318 AddItem(_lc
[I_MENU_YES
]);
2319 AddItem(_lc
[I_MENU_NO
]);
2325 with AddSwitch(_lc
[I_MENU_BOTS_VS
]) do
2328 AddItem(_lc
[I_MENU_BOTS_VS_PLAYERS
]);
2329 AddItem(_lc
[I_MENU_BOTS_VS_MONSTERS
]);
2330 AddItem(_lc
[I_MENU_BOTS_VS_ALL
]);
2332 if gcBotsVS
= 'Players' then
2334 if gcBotsVS
= 'Monsters' then
2338 AddButton(@ProcStartCustomGame
, _lc
[I_MENU_START_GAME
]);
2342 Menu
.DefControl
:= 'mCustomGameMenu';
2343 g_GUI_AddWindow(Menu
);
2345 Menu
:= TGUIWindow
.Create('CampaignMenu');
2346 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_CAMPAIGN
]))) do
2348 Name
:= 'mCampaignMenu';
2357 with AddFileList('', 15, 4) do
2360 OnChange
:= ProcSelectCampaignWAD
;
2364 FileMask
:= '*.wad|*.pk3|*.zip';
2365 SetBase(MapsDir
+'megawads/');
2368 with AddLabel(_lc
[I_MENU_MAP_NAME
]) do
2370 Name
:= 'lbWADName';
2374 with AddLabel(_lc
[I_MENU_MAP_AUTHOR
]) do
2376 Name
:= 'lbWADAuthor';
2380 AddLine(_lc
[I_MENU_MAP_DESCRIPTION
]);
2381 with AddMemo('', 15, 3) do
2383 Name
:= 'meWADDescription';
2384 Color
:= MENU_ITEMSCTRL_COLOR
;
2386 with AddSwitch(_lc
[I_MENU_PLAYERS
]) do
2388 Name
:= 'swPlayers';
2389 AddItem(_lc
[I_MENU_PLAYERS_ONE
]);
2390 AddItem(_lc
[I_MENU_PLAYERS_TWO
]);
2393 AddButton(@ProcStartCampaign
, _lc
[I_MENU_START_GAME
]);
2397 with TGUIImage(Menu
.AddChild(TGUIImage
.Create
)) do
2399 Name
:= 'mpWADImage';
2400 DefaultRes
:= 'NOPIC';
2401 X
:= GetControl('lsWAD').X
+4;
2402 Y
:= GetControl('lsWAD').Y
-128-MENU_VSPACE
;
2405 Menu
.DefControl
:= 'mCampaignMenu';
2406 g_GUI_AddWindow(Menu
);
2408 Menu
:= TGUIWindow
.Create('SelectMapMenu');
2409 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_SELECT_MAP
]))) do
2411 Name
:= 'mSelectMapMenu';
2412 with AddFileList(_lc
[I_MENU_MAP_WAD
], 12, 4) do
2415 OnChange
:= ProcSelectWAD
;
2419 FileMask
:= '*.wad|*.pk3|*.zip';
2422 with AddList(_lc
[I_MENU_MAP_RESOURCE
], 12, 4) do
2426 OnChange
:= ProcSelectMap
;
2429 with AddLabel(_lc
[I_MENU_MAP_NAME
]) do
2431 Name
:= 'lbMapName';
2435 with AddLabel(_lc
[I_MENU_MAP_AUTHOR
]) do
2437 Name
:= 'lbMapAuthor';
2441 with AddLabel(_lc
[I_MENU_MAP_SIZE
]) do
2443 Name
:= 'lbMapSize';
2447 with AddMemo(_lc
[I_MENU_MAP_DESCRIPTION
], 12, 4) do
2449 Name
:= 'meMapDescription';
2454 with TGUIMapPreview(Menu
.AddChild(TGUIMapPreview
.Create
)) do
2456 Name
:= 'mpMapPreview';
2457 X
:= GetControl('lsMapWAD').X
+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2458 Y
:= GetControl('lsMapWAD').Y
;
2460 with TGUILabel(Menu
.AddChild(TGUILabel
.Create('', gMenuSmallFont
))) do
2462 Name
:= 'lbMapScale';
2465 Color
:= MENU_ITEMSCTRL_COLOR
;
2466 X
:= GetControl('lsMapWAD').X
+
2467 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2468 2 + MAPPREVIEW_WIDTH
*4;
2469 Y
:= GetControl('lsMapWAD').Y
+ MAPPREVIEW_HEIGHT
*16 + 16;
2472 Menu
.OnClose
:= ProcSetMap
;
2473 Menu
.DefControl
:= 'mSelectMapMenu';
2474 g_GUI_AddWindow(Menu
);
2476 Menu
:= TGUIWindow
.Create('OptionsMenu');
2477 with TGUIMainMenu(Menu
.AddChild(TGUIMainMenu
.Create(gMenuFont
, _lc
[I_MENU_OPTIONS
]))) do
2479 Name
:= 'mmOptionsMenu';
2480 AddButton(nil, _lc
[I_MENU_VIDEO_OPTIONS
], 'OptionsVideoMenu');
2481 AddButton(nil, _lc
[I_MENU_SOUND_OPTIONS
], 'OptionsSoundMenu');
2482 AddButton(nil, _lc
[I_MENU_GAME_OPTIONS
], 'OptionsGameMenu');
2483 AddButton(nil, _lc
[I_MENU_CONTROLS_OPTIONS
], 'OptionsControlsMenu');
2484 AddButton(nil, _lc
[I_MENU_PLAYER_OPTIONS
], 'OptionsPlayersMenu');
2485 AddButton(nil, _lc
[I_MENU_LANGUAGE_OPTIONS
], 'OptionsLanguageMenu');
2487 AddButton(nil, _lc
[I_MENU_SAVED_OPTIONS
], 'SavedOptionsMenu').Color
:= _RGB(255, 0, 0);
2488 AddButton(nil, _lc
[I_MENU_DEFAULT_OPTIONS
], 'DefaultOptionsMenu').Color
:= _RGB(255, 0, 0);
2490 Menu
.OnClose
:= ProcApplyOptions
;
2491 Menu
.DefControl
:= 'mmOptionsMenu';
2492 g_GUI_AddWindow(Menu
);
2494 Menu
:= CreateYNMenu('SavedOptionsMenu', _lc
[I_MENU_LOAD_SAVED_PROMT
], Round(gScreenWidth
*0.6),
2495 gMenuSmallFont
, @ProcSavedMenuKeyDown
);
2496 g_GUI_AddWindow(Menu
);
2498 Menu
:= TGUIWindow
.Create('OptionsVideoMenu');
2499 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_VIDEO_OPTIONS
]))) do
2501 Name
:= 'mOptionsVideoMenu';
2502 AddButton(@ProcVideoOptionsRes
, _lc
[I_MENU_VIDEO_RESOLUTION
], 'OptionsVideoResMenu');
2503 with AddSwitch(_lc
[I_MENU_VIDEO_BPP
]) do
2509 with AddSwitch(_lc
[I_MENU_VIDEO_VSYNC
]) do
2512 AddItem(_lc
[I_MENU_YES
]);
2513 AddItem(_lc
[I_MENU_NO
]);
2515 with AddSwitch(_lc
[I_MENU_VIDEO_FILTER_SKY
]) do
2517 Name
:= 'swTextureFilter';
2518 AddItem(_lc
[I_MENU_YES
]);
2519 AddItem(_lc
[I_MENU_NO
]);
2521 with AddSwitch(_lc
[I_MENU_VIDEO_LEGACY_COMPATIBLE
]) do
2523 Name
:= 'swLegacyNPOT';
2524 AddItem(_lc
[I_MENU_NO
]);
2525 AddItem(_lc
[I_MENU_YES
]);
2528 AddText(_lc
[I_MENU_VIDEO_NEED_RESTART
], Round(gScreenWidth
*0.6));
2531 Menu
.DefControl
:= 'mOptionsVideoMenu';
2532 g_GUI_AddWindow(Menu
);
2534 Menu
:= TGUIWindow
.Create('OptionsVideoResMenu');
2535 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_RESOLUTION_SELECT
]))) do
2537 Name
:= 'mOptionsVideoResMenu';
2538 with AddLabel(_lc
[I_MENU_RESOLUTION_CURRENT
]) do
2540 Name
:= 'lbCurrentRes';
2544 with AddList(_lc
[I_MENU_RESOLUTION_LIST
], 12, 6) do
2546 Name
:= 'lsResolution';
2549 with AddSwitch(_lc
[I_MENU_RESOLUTION_FULLSCREEN
]) do
2551 Name
:= 'swFullScreen';
2552 AddItem(_lc
[I_MENU_YES
]);
2553 AddItem(_lc
[I_MENU_NO
]);
2556 AddButton(@ProcApplyVideoOptions
, _lc
[I_MENU_RESOLUTION_APPLY
]);
2559 Menu
.DefControl
:= 'mOptionsVideoResMenu';
2560 g_GUI_AddWindow(Menu
);
2562 Menu
:= TGUIWindow
.Create('OptionsSoundMenu');
2563 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_SOUND_OPTIONS
]))) do
2565 Name
:= 'mOptionsSoundMenu';
2566 with AddScroll(_lc
[I_MENU_SOUND_MUSIC_LEVEL
]) do
2568 Name
:= 'scMusicLevel';
2570 OnChange
:= ProcChangeSoundSettings
;
2572 with AddScroll(_lc
[I_MENU_SOUND_SOUND_LEVEL
]) do
2574 Name
:= 'scSoundLevel';
2576 OnChange
:= ProcChangeSoundSettings
;
2578 with AddScroll(_lc
[I_MENU_SOUND_MAX_SIM_SOUNDS
]) do
2580 Name
:= 'scMaxSimSounds';
2583 with AddSwitch (_lc
[I_MENU_SOUND_ANNOUNCE
]) do
2585 Name
:= 'swAnnouncer';
2586 AddItem(_lc
[I_MENU_ANNOUNCE_NONE
]);
2587 AddItem(_lc
[I_MENU_ANNOUNCE_ME
]);
2588 AddItem(_lc
[I_MENU_ANNOUNCE_MEPLUS
]);
2589 AddItem(_lc
[I_MENU_ANNOUNCE_ALL
]);
2591 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2592 with AddSwitch (_lc
[I_MENU_SOUND_COMPAT
]) do
2594 Name
:= 'swSoundEffects';
2595 AddItem(_lc
[I_MENU_COMPAT_DOOM2
]);
2596 AddItem(_lc
[I_MENU_COMPAT_DF
]);
2598 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
2599 with AddSwitch (_lc
[I_MENU_SOUND_CHAT
]) do
2601 Name
:= 'swChatSpeech';
2602 AddItem(_lc
[I_MENU_YES
]);
2603 AddItem(_lc
[I_MENU_NO
]);
2605 with AddSwitch(_lc
[I_MENU_SOUND_INACTIVE_SOUNDS
]) do
2607 Name
:= 'swInactiveSounds';
2608 AddItem(_lc
[I_MENU_SOUND_INACTIVE_SOUNDS_ON
]);
2609 AddItem(_lc
[I_MENU_SOUND_INACTIVE_SOUNDS_OFF
]);
2613 Menu
.DefControl
:= 'mOptionsSoundMenu';
2614 g_GUI_AddWindow(Menu
);
2616 Menu
:= TGUIWindow
.Create('OptionsGameMenu');
2617 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_GAME_OPTIONS
]))) do
2619 Name
:= 'mOptionsGameMenu';
2620 with AddScroll(_lc
[I_MENU_GAME_PARTICLES_COUNT
]) do
2622 Name
:= 'scParticlesCount';
2625 with AddSwitch(_lc
[I_MENU_GAME_BLOOD_COUNT
]) do
2627 Name
:= 'swBloodCount';
2628 AddItem(_lc
[I_MENU_COUNT_NONE
]);
2629 AddItem(_lc
[I_MENU_COUNT_SMALL
]);
2630 AddItem(_lc
[I_MENU_COUNT_NORMAL
]);
2631 AddItem(_lc
[I_MENU_COUNT_BIG
]);
2632 AddItem(_lc
[I_MENU_COUNT_VERYBIG
]);
2634 with AddScroll(_lc
[I_MENU_GAME_MAX_SHELLS
]) do
2636 Name
:= 'scShellsMax';
2639 with AddScroll(_lc
[I_MENU_GAME_GIBS_COUNT
]) do
2641 Name
:= 'scGibsMax';
2644 with AddScroll(_lc
[I_MENU_GAME_MAX_CORPSES
]) do
2646 Name
:= 'scCorpsesMax';
2649 with AddSwitch(_lc
[I_MENU_GAME_MAX_GIBS
]) do
2651 Name
:= 'swGibsCount';
2652 AddItem(_lc
[I_MENU_COUNT_NONE
]);
2653 AddItem(_lc
[I_MENU_COUNT_SMALL
]);
2654 AddItem(_lc
[I_MENU_COUNT_NORMAL
]);
2655 AddItem(_lc
[I_MENU_COUNT_BIG
]);
2656 AddItem(_lc
[I_MENU_COUNT_VERYBIG
]);
2658 with AddSwitch(_lc
[I_MENU_GAME_CORPSE_TYPE
]) do
2660 Name
:= 'swCorpseType';
2661 AddItem(_lc
[I_MENU_GAME_CORPSE_TYPE_SIMPLE
]);
2662 AddItem(_lc
[I_MENU_GAME_CORPSE_TYPE_ADV
]);
2664 with AddSwitch(_lc
[I_MENU_GAME_GIBS_TYPE
]) do
2666 Name
:= 'swGibsType';
2667 AddItem(_lc
[I_MENU_GAME_GIBS_TYPE_SIMPLE
]);
2668 AddItem(_lc
[I_MENU_GAME_GIBS_TYPE_ADV
]);
2670 with AddSwitch(_lc
[I_MENU_GAME_BLOOD_TYPE
]) do
2672 Name
:= 'swBloodType';
2673 AddItem(_lc
[I_MENU_GAME_BLOOD_TYPE_SIMPLE
]);
2674 AddItem(_lc
[I_MENU_GAME_BLOOD_TYPE_ADV
]);
2676 with AddSwitch(_lc
[I_MENU_GAME_SCREEN_FLASH
]) do
2678 Name
:= 'swScreenFlash';
2679 AddItem(_lc
[I_MENU_NO
]);
2680 AddItem(_lc
[I_MENU_COMPAT_DF
]);
2681 AddItem(_lc
[I_MENU_COMPAT_DOOM2
]);
2683 with AddSwitch(_lc
[I_MENU_GAME_BACKGROUND
]) do
2685 Name
:= 'swBackground';
2686 AddItem(_lc
[I_MENU_YES
]);
2687 AddItem(_lc
[I_MENU_NO
]);
2689 with AddSwitch(_lc
[I_MENU_GAME_MESSAGES
]) do
2691 Name
:= 'swMessages';
2692 AddItem(_lc
[I_MENU_YES
]);
2693 AddItem(_lc
[I_MENU_NO
]);
2695 with AddSwitch(_lc
[I_MENU_GAME_REVERT_PLAYERS
]) do
2697 Name
:= 'swRevertPlayers';
2698 AddItem(_lc
[I_MENU_YES
]);
2699 AddItem(_lc
[I_MENU_NO
]);
2701 with AddSwitch(_lc
[I_MENU_GAME_CHAT_BUBBLE
]) do
2703 Name
:= 'swChatBubble';
2704 AddItem(_lc
[I_MENU_GAME_CHAT_TYPE_NONE
]);
2705 AddItem(_lc
[I_MENU_GAME_CHAT_TYPE_SIMPLE
]);
2706 AddItem(_lc
[I_MENU_GAME_CHAT_TYPE_ADV
]);
2707 AddItem(_lc
[I_MENU_GAME_CHAT_TYPE_COLOR
]);
2708 AddItem(_lc
[I_MENU_GAME_CHAT_TYPE_TEXTURE
]);
2710 with AddScroll(_lc
[I_MENU_GAME_SCALE_FACTOR
]) do
2712 Name
:= 'scScaleFactor';
2714 OnChange
:= ProcChangeGameSettings
;
2718 Menu
.DefControl
:= 'mOptionsGameMenu';
2719 g_GUI_AddWindow(Menu
);
2721 Menu
:= TGUIWindow
.Create('OptionsControlsMenu');
2722 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_CONTROLS_OPTIONS
]))) do
2724 Name
:= 'mOptionsControlsMenu';
2725 AddLine(_lc
[I_MENU_CONTROL_GLOBAL
]);
2726 AddKeyRead(_lc
[I_MENU_CONTROL_SCREENSHOT
]).Name
:= _lc
[I_MENU_CONTROL_SCREENSHOT
];
2727 AddKeyRead(_lc
[I_MENU_CONTROL_STAT
]).Name
:= _lc
[I_MENU_CONTROL_STAT
];
2728 AddKeyRead(_lc
[I_MENU_CONTROL_CHAT
]).Name
:= _lc
[I_MENU_CONTROL_CHAT
];
2729 AddKeyRead(_lc
[I_MENU_CONTROL_TEAMCHAT
]).Name
:= _lc
[I_MENU_CONTROL_TEAMCHAT
];
2731 AddButton(nil, _lc
[I_MENU_PLAYER_1_KBD
], 'OptionsControlsP1Menu');
2732 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
2733 AddButton(nil, _lc
[I_MENU_PLAYER_1_WEAPONS
], 'OptionsControlsP1MenuWeapons');
2734 AddButton(nil, _lc
[I_MENU_PLAYER_2_KBD
], 'OptionsControlsP2Menu');
2735 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
2736 AddButton(nil, _lc
[I_MENU_PLAYER_2_WEAPONS
], 'OptionsControlsP2MenuWeapons');
2737 if e_JoysticksAvailable
<> 0 then
2740 AddButton(nil, _lc
[I_MENU_CONTROL_JOYSTICKS
], 'OptionsControlsJoystickMenu');
2742 if SDL_GetNumTouchDevices() > 0 then
2745 AddButton(nil, _lc
[I_MENU_CONTROL_TOUCH
], 'OptionsControlsTouchMenu');
2748 Menu
.DefControl
:= 'mOptionsControlsMenu';
2749 g_GUI_AddWindow(Menu
);
2751 Menu
:= TGUIWindow
.Create('OptionsControlsP1Menu');
2752 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_PLAYER_1_KBD
]))) do
2754 Name
:= 'mOptionsControlsP1Menu';
2755 AddKeyRead2(_lc
[I_MENU_CONTROL_LEFT
]).Name
:= _lc
[I_MENU_CONTROL_LEFT
];
2756 AddKeyRead2(_lc
[I_MENU_CONTROL_RIGHT
]).Name
:= _lc
[I_MENU_CONTROL_RIGHT
];
2757 AddKeyRead2(_lc
[I_MENU_CONTROL_UP
]).Name
:= _lc
[I_MENU_CONTROL_UP
];
2758 AddKeyRead2(_lc
[I_MENU_CONTROL_DOWN
]).Name
:= _lc
[I_MENU_CONTROL_DOWN
];
2759 AddKeyRead2(_lc
[I_MENU_CONTROL_JUMP
]).Name
:= _lc
[I_MENU_CONTROL_JUMP
];
2760 AddKeyRead2(_lc
[I_MENU_CONTROL_FIRE
]).Name
:= _lc
[I_MENU_CONTROL_FIRE
];
2761 AddKeyRead2(_lc
[I_MENU_CONTROL_USE
]).Name
:= _lc
[I_MENU_CONTROL_USE
];
2762 AddKeyRead2(_lc
[I_MENU_CONTROL_NEXT_WEAPON
]).Name
:= _lc
[I_MENU_CONTROL_NEXT_WEAPON
];
2763 AddKeyRead2(_lc
[I_MENU_CONTROL_PREV_WEAPON
]).Name
:= _lc
[I_MENU_CONTROL_PREV_WEAPON
];
2764 AddKeyRead2(_lc
[I_MENU_CONTROL_STRAFE
]).Name
:= _lc
[I_MENU_CONTROL_STRAFE
];
2766 Menu
.DefControl
:= 'mOptionsControlsP1Menu';
2767 g_GUI_AddWindow(Menu
);
2769 Menu
:= TGUIWindow
.Create('OptionsControlsP1MenuWeapons');
2770 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_PLAYER_1_WEAPONS
]))) do
2772 Name
:= 'mOptionsControlsP1MenuWeapons';
2773 for i
:= WP_FIRST
to WP_LAST
do
2774 AddKeyRead2(_lc
[TStrings_Locale(Cardinal(I_GAME_WEAPON0
) + i
)]).Name
:=
2775 _lc
[TStrings_Locale(Cardinal(I_GAME_WEAPON0
) + i
)];
2777 Menu
.DefControl
:= 'mOptionsControlsP1MenuWeapons';
2778 g_GUI_AddWindow(Menu
);
2780 Menu
:= TGUIWindow
.Create('OptionsControlsP2Menu');
2781 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_PLAYER_2_KBD
]))) do
2783 Name
:= 'mOptionsControlsP2Menu';
2784 AddKeyRead2(_lc
[I_MENU_CONTROL_LEFT
]).Name
:= _lc
[I_MENU_CONTROL_LEFT
];
2785 AddKeyRead2(_lc
[I_MENU_CONTROL_RIGHT
]).Name
:= _lc
[I_MENU_CONTROL_RIGHT
];
2786 AddKeyRead2(_lc
[I_MENU_CONTROL_UP
]).Name
:= _lc
[I_MENU_CONTROL_UP
];
2787 AddKeyRead2(_lc
[I_MENU_CONTROL_DOWN
]).Name
:= _lc
[I_MENU_CONTROL_DOWN
];
2788 AddKeyRead2(_lc
[I_MENU_CONTROL_JUMP
]).Name
:= _lc
[I_MENU_CONTROL_JUMP
];
2789 AddKeyRead2(_lc
[I_MENU_CONTROL_FIRE
]).Name
:= _lc
[I_MENU_CONTROL_FIRE
];
2790 AddKeyRead2(_lc
[I_MENU_CONTROL_USE
]).Name
:= _lc
[I_MENU_CONTROL_USE
];
2791 AddKeyRead2(_lc
[I_MENU_CONTROL_NEXT_WEAPON
]).Name
:= _lc
[I_MENU_CONTROL_NEXT_WEAPON
];
2792 AddKeyRead2(_lc
[I_MENU_CONTROL_PREV_WEAPON
]).Name
:= _lc
[I_MENU_CONTROL_PREV_WEAPON
];
2793 AddKeyRead2(_lc
[I_MENU_CONTROL_STRAFE
]).Name
:= _lc
[I_MENU_CONTROL_STRAFE
];
2795 Menu
.DefControl
:= 'mOptionsControlsP2Menu';
2796 g_GUI_AddWindow(Menu
);
2798 Menu
:= TGUIWindow
.Create('OptionsControlsP2MenuWeapons');
2799 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_PLAYER_2_WEAPONS
]))) do
2801 Name
:= 'mOptionsControlsP2MenuWeapons';
2802 for i
:= WP_FIRST
to WP_LAST
do
2803 AddKeyRead2(_lc
[TStrings_Locale(Cardinal(I_GAME_WEAPON0
) + i
)]).Name
:=
2804 _lc
[TStrings_Locale(Cardinal(I_GAME_WEAPON0
) + i
)];
2806 Menu
.DefControl
:= 'mOptionsControlsP2MenuWeapons';
2807 g_GUI_AddWindow(Menu
);
2809 Menu
:= TGUIWindow
.Create('OptionsControlsJoystickMenu');
2810 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_CONTROL_JOYSTICKS
]))) do
2812 Name
:= 'mOptionsControlsJoystickMenu';
2813 for i
:= 0 to e_JoysticksAvailable
-1 do
2814 with AddScroll(Format(_lc
[I_MENU_CONTROL_DEADZONE
], [i
+ 1])) do
2816 Name
:= 'scDeadzone' + IntToStr(i
);
2820 Menu
.DefControl
:= 'mOptionsControlsJoystickMenu';
2821 g_GUI_AddWindow(Menu
);
2823 Menu
:= TGUIWindow
.Create('OptionsControlsTouchMenu');
2824 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_CONTROL_TOUCH
]))) do
2826 Name
:= 'mOptionsControlsTouchMenu';
2827 with AddScroll(_lc
[I_MENU_CONTROL_TOUCH_SIZE
]) do
2829 Name
:= 'scTouchSize';
2831 OnChange
:= ProcChangeTouchSettings
;
2833 with AddSwitch(_lc
[I_MENU_CONTROL_TOUCH_FIRE
]) do
2835 Name
:= 'swTouchFire';
2836 AddItem(_lc
[I_MENU_NO
]);
2837 AddItem(_lc
[I_MENU_YES
]);
2840 Menu
.DefControl
:= 'mOptionsControlsTouchMenu';
2841 g_GUI_AddWindow(Menu
);
2843 Menu
:= TGUIWindow
.Create('OptionsPlayersMenu');
2844 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_PLAYER_OPTIONS
]))) do
2846 Name
:= 'mOptionsPlayersMenu';
2847 AddButton(nil, _lc
[I_MENU_PLAYER_1
], 'OptionsPlayersP1Menu');
2848 AddButton(nil, _lc
[I_MENU_PLAYER_2
], 'OptionsPlayersP2Menu');
2850 Menu
.DefControl
:= 'mOptionsPlayersMenu';
2851 g_GUI_AddWindow(Menu
);
2853 CreatePlayerOptionsMenu('P1');
2854 CreatePlayerOptionsMenu('P2');
2856 Menu
:= TGUIWindow
.Create('OptionsPlayersMIMenu');
2857 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_MODEL_INFO
]))) do
2859 Name
:= 'mOptionsPlayersMIMenu';
2860 with AddLabel(_lc
[I_MENU_MODEL_NAME
]) do
2865 with AddLabel(_lc
[I_MENU_MODEL_AUTHOR
]) do
2870 with AddMemo(_lc
[I_MENU_MODEL_COMMENT
], 14, 6) do
2872 Name
:= 'meComment';
2875 AddLine(_lc
[I_MENU_MODEL_OPTIONS
]);
2876 with AddLabel(_lc
[I_MENU_MODEL_WEAPON
]) do
2879 FixedLength
:= Max(Length(_lc
[I_MENU_YES
]), Length(_lc
[I_MENU_NO
]));
2883 Menu
.DefControl
:= 'mOptionsPlayersMIMenu';
2884 g_GUI_AddWindow(Menu
);
2886 Menu
:= TGUIWindow
.Create('OptionsLanguageMenu');
2887 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_LANGUAGE_OPTIONS
]))) do
2889 Name
:= 'mOptionsLanguageMenu';
2890 AddButton(@ProcSetRussianLanguage
, _lc
[I_MENU_LANGUAGE_RUSSIAN
]);
2891 AddButton(@ProcSetEnglishLanguage
, _lc
[I_MENU_LANGUAGE_ENGLISH
]);
2894 Menu
.DefControl
:= 'mOptionsLanguageMenu';
2895 g_GUI_AddWindow(Menu
);
2897 Menu
:= CreateYNMenu('DefaultOptionsMenu', _lc
[I_MENU_SET_DEFAULT_PROMT
], Round(gScreenWidth
*0.6),
2898 gMenuSmallFont
, @ProcDefaultMenuKeyDown
);
2899 g_GUI_AddWindow(Menu
);
2901 Menu
:= TGUIWindow
.Create('AuthorsMenu');
2902 Menu
.BackTexture
:= 'INTER';
2903 Menu
.OnClose
:= ProcAuthorsClose
;
2907 with TGUILabel(Menu
.AddChild(TGUILabel
.Create(_lc
[I_CREDITS_CAP_1
], gMenuFont
))) do
2909 Color
:= _RGB(255, 0, 0);
2910 X
:= (gScreenWidth
div 2)-(GetWidth() div 2);
2912 _y
:= _y
+GetHeight();
2914 with TGUILabel(Menu
.AddChild(TGUILabel
.Create(Format(_lc
[I_CREDITS_CAP_2
], [GAME_VERSION
, NET_PROTOCOL_VER
]), gMenuSmallFont
))) do
2916 Color
:= _RGB(255, 0, 0);
2917 X
:= (gScreenWidth
div 2)-(GetWidth() div 2);
2919 _y
:= _y
+GetHeight()+32;
2921 // ×òî äåëàë: Êòî äåëàë
2922 cx
:= gScreenWidth
div 2 - 320 + 64;
2923 with TGUILabel(Menu
.AddChild(TGUILabel
.Create(_lc
[I_CREDITS_A_1
], gMenuSmallFont
))) do
2925 Color
:= _RGB(255, 0, 0);
2930 with TGUILabel(Menu
.AddChild(TGUILabel
.Create(_lc
[I_CREDITS_A_1_1
], gMenuSmallFont
))) do
2932 Color
:= _RGB(255, 255, 255);
2937 with TGUILabel(Menu
.AddChild(TGUILabel
.Create(_lc
[I_CREDITS_A_2
], gMenuSmallFont
))) do
2939 Color
:= _RGB(255, 0, 0);
2944 with TGUILabel(Menu
.AddChild(TGUILabel
.Create(_lc
[I_CREDITS_A_2_1
], gMenuSmallFont
))) do
2946 Color
:= _RGB(255, 255, 255);
2951 with TGUILabel(Menu
.AddChild(TGUILabel
.Create(_lc
[I_CREDITS_A_2_2
], gMenuSmallFont
))) do
2953 Color
:= _RGB(255, 255, 255);
2958 with TGUILabel(Menu
.AddChild(TGUILabel
.Create(_lc
[I_CREDITS_A_3
], gMenuSmallFont
))) do
2960 Color
:= _RGB(255, 0, 0);
2965 with TGUILabel(Menu
.AddChild(TGUILabel
.Create(_lc
[I_CREDITS_A_3_1
], gMenuSmallFont
))) do
2967 Color
:= _RGB(255, 255, 255);
2972 with TGUILabel(Menu
.AddChild(TGUILabel
.Create(_lc
[I_CREDITS_A_4
], gMenuSmallFont
))) do
2974 Color
:= _RGB(255, 0, 0);
2979 with TGUILabel(Menu
.AddChild(TGUILabel
.Create(_lc
[I_CREDITS_A_4_1
], gMenuSmallFont
))) do
2981 Color
:= _RGB(255, 255, 255);
2984 _y
:= gScreenHeight
- 128;
2987 with TGUILabel(Menu
.AddChild(TGUILabel
.Create(_lc
[I_CREDITS_CAP_3
], gMenuSmallFont
))) do
2989 Color
:= _RGB(255, 0, 0);
2994 with TGUILabel(Menu
.AddChild(TGUILabel
.Create(_lc
[I_CREDITS_CLO_1
], gMenuSmallFont
))) do
2996 Color
:= _RGB(255, 255, 255);
2999 _y
:= _y
+GetHeight();
3001 with TGUILabel(Menu
.AddChild(TGUILabel
.Create(_lc
[I_CREDITS_CLO_2
], gMenuSmallFont
))) do
3003 Color
:= _RGB(255, 255, 255);
3006 _y
:= _y
+GetHeight();
3008 with TGUILabel(Menu
.AddChild(TGUILabel
.Create(_lc
[I_CREDITS_CLO_3
], gMenuSmallFont
))) do
3010 Color
:= _RGB(255, 255, 255);
3013 _y
:= gScreenHeight
- 32;
3015 with TGUILabel(Menu
.AddChild(TGUILabel
.Create(_lc
[I_CREDITS_CLO_4
], gMenuSmallFont
))) do
3017 Color
:= _RGB(255, 0, 0);
3018 X
:= gScreenWidth
div 2 - GetWidth() div 2;
3021 g_GUI_AddWindow(Menu
);
3023 Menu
:= CreateYNMenu('ExitMenu', _lc
[I_MENU_EXIT_PROMT
], Round(gScreenWidth
*0.6),
3024 gMenuSmallFont
, @ProcExitMenuKeyDown
);
3025 g_GUI_AddWindow(Menu
);
3027 Menu
:= TGUIWindow
.Create('GameSingleMenu');
3028 with TGUIMainMenu(Menu
.AddChild(TGUIMainMenu
.Create(gMenuFont
, _lc
[I_MENU_MAIN_MENU
]))) do
3030 Name
:= 'mmGameSingleMenu';
3031 AddButton(nil, _lc
[I_MENU_LOAD_GAME
], 'LoadMenu');
3032 AddButton(nil, _lc
[I_MENU_SAVE_GAME
], 'SaveMenu').Name
:= 'save';
3033 AddButton(@ReadGameSettings
, _lc
[I_MENU_SET_GAME
], 'GameSetGameMenu');
3034 AddButton(@ReadOptions
, _lc
[I_MENU_OPTIONS
], 'OptionsMenu');
3035 AddButton(nil, _lc
[I_MENU_RESTART
], 'RestartGameMenu');
3036 AddButton(nil, _lc
[I_MENU_END_GAME
], 'EndGameMenu');
3038 Menu
.DefControl
:= 'mmGameSingleMenu';
3039 Menu
.MainWindow
:= True;
3040 Menu
.OnClose
:= ProcGMClose
;
3041 Menu
.OnShow
:= ProcGMShow
;
3042 g_GUI_AddWindow(Menu
);
3044 Menu
:= CreateYNMenu('EndGameMenu', _lc
[I_MENU_END_GAME_PROMT
], Round(gScreenWidth
*0.6),
3045 gMenuSmallFont
, @ProcEndMenuKeyDown
);
3046 g_GUI_AddWindow(Menu
);
3048 Menu
:= CreateYNMenu('RestartGameMenu', _lc
[I_MENU_RESTART_GAME_PROMT
], Round(gScreenWidth
*0.6),
3049 gMenuSmallFont
, @ProcRestartMenuKeyDown
);
3050 g_GUI_AddWindow(Menu
);
3052 Menu
:= TGUIWindow
.Create('GameCustomMenu');
3053 with TGUIMainMenu(Menu
.AddChild(TGUIMainMenu
.Create(gMenuFont
, _lc
[I_MENU_MAIN_MENU
]))) do
3055 Name
:= 'mmGameCustomMenu';
3056 AddButton(nil, _lc
[I_MENU_CHANGE_PLAYERS
], 'TeamMenu');
3057 AddButton(nil, _lc
[I_MENU_LOAD_GAME
], 'LoadMenu');
3058 AddButton(nil, _lc
[I_MENU_SAVE_GAME
], 'SaveMenu').Name
:= 'save';
3059 AddButton(@ReadGameSettings
, _lc
[I_MENU_SET_GAME
], 'GameSetGameMenu');
3060 AddButton(@ReadOptions
, _lc
[I_MENU_OPTIONS
], 'OptionsMenu');
3061 AddButton(nil, _lc
[I_MENU_RESTART
], 'RestartGameMenu');
3062 AddButton(nil, _lc
[I_MENU_END_GAME
], 'EndGameMenu');
3064 Menu
.DefControl
:= 'mmGameCustomMenu';
3065 Menu
.MainWindow
:= True;
3066 Menu
.OnClose
:= ProcGMClose
;
3067 Menu
.OnShow
:= ProcGMShow
;
3068 g_GUI_AddWindow(Menu
);
3070 Menu
:= TGUIWindow
.Create('GameServerMenu');
3071 with TGUIMainMenu(Menu
.AddChild(TGUIMainMenu
.Create(gMenuFont
, _lc
[I_MENU_MAIN_MENU
]))) do
3073 Name
:= 'mmGameServerMenu';
3074 AddButton(nil, _lc
[I_MENU_CHANGE_PLAYERS
], 'TeamMenu');
3075 AddButton(@ReadGameSettings
, _lc
[I_MENU_SET_GAME
], 'GameSetGameMenu');
3076 AddButton(@ReadOptions
, _lc
[I_MENU_OPTIONS
], 'OptionsMenu');
3077 AddButton(nil, _lc
[I_MENU_RESTART
], 'RestartGameMenu');
3078 AddButton(nil, _lc
[I_MENU_END_GAME
], 'EndGameMenu');
3080 Menu
.DefControl
:= 'mmGameServerMenu';
3081 Menu
.MainWindow
:= True;
3082 Menu
.OnClose
:= ProcGMClose
;
3083 Menu
.OnShow
:= ProcGMShow
;
3084 g_GUI_AddWindow(Menu
);
3086 Menu
:= TGUIWindow
.Create('GameClientMenu');
3087 with TGUIMainMenu(Menu
.AddChild(TGUIMainMenu
.Create(gMenuFont
, _lc
[I_MENU_MAIN_MENU
]))) do
3089 Name
:= 'mmGameClientMenu';
3090 AddButton(nil, _lc
[I_MENU_CHANGE_PLAYERS
], 'TeamMenu');
3091 AddButton(@ReadOptions
, _lc
[I_MENU_OPTIONS
], 'OptionsMenu');
3092 AddButton(nil, _lc
[I_MENU_END_GAME
], 'EndGameMenu');
3094 Menu
.DefControl
:= 'mmGameClientMenu';
3095 Menu
.MainWindow
:= True;
3096 Menu
.OnClose
:= ProcGMClose
;
3097 Menu
.OnShow
:= ProcGMShow
;
3098 g_GUI_AddWindow(Menu
);
3100 Menu
:= TGUIWindow
.Create('ClientPasswordMenu');
3101 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuSmallFont
, gMenuSmallFont
, _lc
[I_MENU_ENTERPASSWORD
]))) do
3103 Name
:= 'mClientPasswordMenu';
3104 with AddEdit(_lc
[I_NET_SERVER_PASSWORD
]) do
3112 AddButton(@ProcEnterPassword
, _lc
[I_MENU_START_GAME
]);
3115 Menu
.DefControl
:= 'mClientPasswordMenu';
3116 g_GUI_AddWindow(Menu
);
3118 Menu
:= TGUIWindow
.Create('GameSetGameMenu');
3119 with TGUIMenu(Menu
.AddChild(TGUIMenu
.Create(gMenuFont
, gMenuSmallFont
, _lc
[I_MENU_SET_GAME
]))) do
3121 Name
:= 'mGameSetGameMenu';
3122 with AddSwitch(_lc
[I_MENU_TEAM_DAMAGE
]) do
3124 Name
:= 'swTeamDamage';
3125 AddItem(_lc
[I_MENU_YES
]);
3126 AddItem(_lc
[I_MENU_NO
]);
3129 with AddEdit(_lc
[I_MENU_TIME_LIMIT
]) do
3131 Name
:= 'edTimeLimit';
3136 with AddEdit(_lc
[I_MENU_GOAL_LIMIT
]) do
3138 Name
:= 'edGoalLimit';
3143 with AddEdit(_lc
[I_MENU_MAX_LIVES
]) do
3145 Name
:= 'edMaxLives';
3150 with AddSwitch(_lc
[I_MENU_BOTS_VS
]) do
3153 AddItem(_lc
[I_MENU_BOTS_VS_PLAYERS
]);
3154 AddItem(_lc
[I_MENU_BOTS_VS_MONSTERS
]);
3155 AddItem(_lc
[I_MENU_BOTS_VS_ALL
]);
3161 Menu
.DefControl
:= 'mGameSetGameMenu';
3162 Menu
.OnClose
:= ProcApplyGameSet
;
3163 g_GUI_AddWindow(Menu
);
3165 Menu
:= TGUIWindow
.Create('TeamMenu');
3166 with TGUIMainMenu(Menu
.AddChild(TGUIMainMenu
.Create(gMenuFont
, _lc
[I_MENU_CHANGE_PLAYERS
]))) do
3168 Name
:= 'mmTeamMenu';
3169 AddButton(@ProcJoinRed
, _lc
[I_MENU_JOIN_RED
], '').Name
:= 'tmJoinRed';
3170 AddButton(@ProcJoinBlue
, _lc
[I_MENU_JOIN_BLUE
], '').Name
:= 'tmJoinBlue';
3171 AddButton(@ProcJoinGame
, _lc
[I_MENU_JOIN_GAME
], '').Name
:= 'tmJoinGame';
3172 AddButton(@ProcSwitchP2
, _lc
[I_MENU_ADD_PLAYER_2
], '').Name
:= 'tmPlayer2';
3173 AddButton(@ProcSpectate
, _lc
[I_MENU_SPECTATE
], '').Name
:= 'tmSpectate';
3175 Menu
.DefControl
:= 'mmTeamMenu';
3176 Menu
.OnShow
:= ProcChangePlayers
;
3177 g_GUI_AddWindow(Menu
);
3180 procedure g_Menu_Show_SaveMenu();
3182 if g_Game_IsTestMap
then
3184 if gGameSettings
.GameType
= GT_SINGLE
then
3185 g_GUI_ShowWindow('GameSingleMenu')
3188 if g_Game_IsClient
then
3191 if g_Game_IsNet
then
3194 g_GUI_ShowWindow('GameCustomMenu');
3196 g_GUI_ShowWindow('SaveMenu');
3197 g_Sound_PlayEx('MENU_OPEN');
3200 procedure g_Menu_Show_LoadMenu (standalone
: Boolean=false);
3202 if (g_ActiveWindow
<> nil) and (g_ActiveWindow
.name
= 'LoadMenu') then exit
; // nothing to do
3203 if gGameSettings
.GameType
= GT_SINGLE
then
3205 if not standalone
then g_GUI_ShowWindow('GameSingleMenu')
3209 if g_Game_IsClient
then exit
;
3210 if g_Game_IsNet
then exit
;
3211 if not standalone
then g_GUI_ShowWindow('GameCustomMenu');
3213 g_GUI_ShowWindow('LoadMenu');
3214 g_Sound_PlayEx('MENU_OPEN');
3217 procedure g_Menu_Show_GameSetGame();
3219 if gGameSettings
.GameType
= GT_SINGLE
then
3220 g_GUI_ShowWindow('GameSingleMenu')
3223 if g_Game_IsClient
then
3226 if g_Game_IsNet
then
3227 g_GUI_ShowWindow('GameServerMenu')
3229 g_GUI_ShowWindow('GameCustomMenu');
3232 g_GUI_ShowWindow('GameSetGameMenu');
3233 g_Sound_PlayEx('MENU_OPEN');
3236 procedure g_Menu_Show_OptionsVideo();
3238 if gGameSettings
.GameType
= GT_SINGLE
then
3239 g_GUI_ShowWindow('GameSingleMenu')
3242 if g_Game_IsClient
then
3243 g_GUI_ShowWindow('GameClientMenu')
3245 if g_Game_IsNet
then
3246 g_GUI_ShowWindow('GameServerMenu')
3248 g_GUI_ShowWindow('GameCustomMenu');
3251 g_GUI_ShowWindow('OptionsMenu');
3252 g_GUI_ShowWindow('OptionsVideoMenu');
3253 g_Sound_PlayEx('MENU_OPEN');
3256 procedure g_Menu_Show_OptionsSound();
3258 if gGameSettings
.GameType
= GT_SINGLE
then
3259 g_GUI_ShowWindow('GameSingleMenu')
3262 if g_Game_IsClient
then
3263 g_GUI_ShowWindow('GameClientMenu')
3265 if g_Game_IsNet
then
3266 g_GUI_ShowWindow('GameServerMenu')
3268 g_GUI_ShowWindow('GameCustomMenu');
3271 g_GUI_ShowWindow('OptionsMenu');
3272 g_GUI_ShowWindow('OptionsSoundMenu');
3273 g_Sound_PlayEx('MENU_OPEN');
3276 procedure g_Menu_Show_EndGameMenu();
3278 g_GUI_ShowWindow('EndGameMenu');
3279 g_Sound_PlayEx('MENU_OPEN');
3282 procedure g_Menu_Show_QuitGameMenu();
3284 g_GUI_ShowWindow('ExitMenu');
3285 g_Sound_PlayEx('MENU_OPEN');
3288 procedure g_Menu_Init();
3295 procedure g_Menu_Free();
3299 e_WriteLog('Releasing menu data...', TMsgType
.Notify
);
3304 procedure g_Menu_Reset();
3308 g_GUI_SaveMenuPos();
3309 ex
:= g_GUI_Destroy();
3313 e_WriteLog('Recreating menu...', TMsgType
.Notify
);
3318 g_Game_SetDebugMode();
3320 g_GUI_LoadMenuPos();