DEADSOFTWARE

5c4f23285f7741d9bd374f675c5bbee486d805ae
[d2df-sdl.git] / src / game / g_menu.pas
1 (* Copyright (C) Doom 2D: Forever Developers
2 *
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, version 3 of the License ONLY.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *)
15 {$INCLUDE ../shared/a_modes.inc}
16 unit g_menu;
18 interface
20 procedure g_Menu_Init();
21 procedure g_Menu_Free();
22 procedure g_Menu_Reset();
23 procedure g_Menu_AskLanguage();
25 procedure g_Menu_Show_SaveMenu();
26 procedure g_Menu_Show_LoadMenu(standalone: Boolean=false);
27 procedure g_Menu_Show_GameSetGame();
28 procedure g_Menu_Show_OptionsVideo();
29 procedure g_Menu_Show_OptionsSound();
30 procedure g_Menu_Show_EndGameMenu();
31 procedure g_Menu_Show_QuitGameMenu();
33 var
34 PromptIP: string;
35 PromptPort: Word;
36 TempScale: Integer = -1;
37 TempResScale: Integer = -1;
39 implementation
41 uses
42 {$IFDEF ENABLE_GFX}
43 g_gfx,
44 {$ENDIF}
45 {$IFDEF ENABLE_GIBS}
46 g_gibs,
47 {$ENDIF}
48 g_gui, r_textures, r_graphics, g_game, g_map,
49 g_base, g_basic, g_console, g_sound, g_player, g_options, g_weapons,
50 e_log, SysUtils, CONFIG, g_playermodel, DateUtils,
51 MAPDEF, Math, g_saveload,
52 g_language, e_res,
53 g_net, g_netmsg, g_netmaster, g_items, e_input,
54 utils, wadreader, g_system, r_render, r_game;
57 type TYNCallback = procedure (yes:Boolean);
59 procedure YNKeyDownProc (win: TGUIWindow; Key: Byte);
60 begin
61 if win.UserData = nil then exit;
62 case Key of
63 IK_Y, IK_SPACE: TYNCallback(win.UserData)(true);
64 IK_N: TYNCallback(win.UserData)(false);
65 end;
66 end;
68 procedure YesButtonCB (ctl: TGUITextButton);
69 begin
70 if ctl.UserData = nil then exit;
71 TYNCallback(ctl.UserData)(true);
72 end;
74 procedure NoButtonCB (ctl: TGUITextButton);
75 begin
76 if ctl.UserData = nil then exit;
77 TYNCallback(ctl.UserData)(false);
78 end;
80 function CreateYNMenu (WinName, Text: String; MaxLen: Word; FontID: DWORD; ActionProc: TYNCallback): TGUIWindow;
81 var
82 menu: TGUIMenu;
83 begin
84 //if length(Text) = 0 then exit;
85 Result := TGUIWindow.Create(WinName);
86 with Result do
87 begin
88 //OnKeyDownEx := @YNKeyDownProc;
89 //UserData := @ActionProc;
90 menu := TGUIMenu(Result.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, '')));
91 with menu do
92 begin
93 Name := '__temp_yes_no_menu:'+WinName;
94 YesNo := true;
95 AddText(Text, MaxLen);
96 with AddButton(nil, _lc[I_MENU_YES]) do begin ProcEx := @YesButtonCB; UserData := @ActionProc; end;
97 with AddButton(nil, _lc[I_MENU_NO]) do begin ProcEx := @NoButtonCB; UserData := @ActionProc; end;
98 end;
99 DefControl := '__temp_yes_no_menu:'+WinName;
100 SetActive(nil);
101 end;
102 end;
105 procedure ProcChangeColor(Sender: TGUIControl); forward;
106 procedure ProcSelectModel(Sender: TGUIControl); forward;
108 procedure ProcApplyOptions();
109 var
110 menu: TGUIMenu;
111 i: Integer;
112 begin
113 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
115 if TGUISwitch(menu.GetControl('swBPP')).ItemIndex = 0 then
116 gBPP := 16
117 else
118 gBPP := 32;
120 gVSync := TGUISwitch(menu.GetControl('swVSync')).ItemIndex = 0;
122 gTextureFilter := TGUISwitch(menu.GetControl('swTextureFilter')).ItemIndex = 0;
123 glNPOTOverride := not (TGUISwitch(menu.GetControl('swLegacyNPOT')).ItemIndex = 0);
124 gLerpActors := TGUISwitch(menu.GetControl('swInterp')).ItemIndex = 0;
126 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
128 g_Sound_SetupAllVolumes(
129 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
130 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
131 );
133 gMaxSimSounds := Max(Min(TGUIScroll(menu.GetControl('scMaxSimSounds')).Value*4+2, 66), 2);
134 gMuteWhenInactive := TGUISwitch(menu.GetControl('swInactiveSounds')).ItemIndex = 1;
135 gAnnouncer := TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex;
136 gSoundEffectsDF := TGUISwitch(menu.GetControl('swSoundEffects')).ItemIndex = 1;
137 gUseChatSounds := TGUISwitch(menu.GetControl('swChatSpeech')).ItemIndex = 0;
139 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
141 {$IFDEF ENABLE_GFX}
142 g_GFX_SetMax(TGUIScroll(menu.GetControl('scParticlesCount')).Value*1000);
143 {$ENDIF}
144 g_Shells_SetMax(TGUIScroll(menu.GetControl('scShellsMax')).Value*30);
145 {$IFDEF ENABLE_GIBS}
146 g_Gibs_SetMax(TGUIScroll(menu.GetControl('scGibsMax')).Value*25);
147 {$ENDIF}
148 g_Corpses_SetMax(TGUIScroll(menu.GetControl('scCorpsesMax')).Value*5);
150 {$IFDEF ENABLE_GIBS}
151 case TGUISwitch(menu.GetControl('swGibsCount')).ItemIndex of
152 0: gGibsCount := 0;
153 1: gGibsCount := 8;
154 2: gGibsCount := 16;
155 3: gGibsCount := 32;
156 else gGibsCount := 48;
157 end;
158 {$ENDIF}
160 gBloodCount := TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex;
161 gFlash := TGUISwitch(menu.GetControl('swScreenFlash')).ItemIndex;
162 gAdvBlood := TGUISwitch(menu.GetControl('swBloodType')).ItemIndex = 1;
163 gAdvCorpses := TGUISwitch(menu.GetControl('swCorpseType')).ItemIndex = 1;
164 gAdvGibs := TGUISwitch(menu.GetControl('swGibsType')).ItemIndex = 1;
165 gDrawBackGround := TGUISwitch(menu.GetControl('swBackGround')).ItemIndex = 0;
166 gShowMessages := TGUISwitch(menu.GetControl('swMessages')).ItemIndex = 0;
167 gRevertPlayers := TGUISwitch(menu.GetControl('swRevertPlayers')).ItemIndex = 0;
168 gChatBubble := TGUISwitch(menu.GetControl('swChatBubble')).ItemIndex;
169 gPlayerIndicator := TGUISwitch(menu.GetControl('swPlayerIndicator')).ItemIndex;
170 gPlayerIndicatorStyle := TGUISwitch(menu.GetControl('swPlayerIndicatorStyle')).ItemIndex;
171 if TGUIScroll(menu.GetControl('scScaleFactor')).Value <> TempScale then
172 begin
173 TempScale := TGUIScroll(menu.GetControl('scScaleFactor')).Value;
174 g_dbg_scale := TempScale + 1;
175 end;
178 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
180 with menu do
181 begin
182 g_Console_BindKey(g_Console_FindBind(1, 'screenshot'), '');
183 g_Console_BindKey(g_Console_FindBind(1, '+scores', '-scores'), '');
184 g_Console_BindKey(g_Console_FindBind(1, 'togglechat'), '');
185 g_Console_BindKey(g_Console_FindBind(1, 'toggleteamchat'), '');
186 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_SCREENSHOT])).Key, 'screenshot');
187 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STAT])).Key, '+scores', '-scores');
188 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_CHAT])).Key, 'togglechat');
189 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_TEAMCHAT])).Key, 'toggleteamchat');
190 end;
192 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
193 with menu do
194 begin
195 g_Console_BindKey(g_Console_FindBind(1, '+p1_moveright', '-p1_moveright'), '');
196 g_Console_BindKey(g_Console_FindBind(1, '+p1_moveleft', '-p1_moveleft'), '');
197 g_Console_BindKey(g_Console_FindBind(1, '+p1_lookup', '-p1_lookup'), '');
198 g_Console_BindKey(g_Console_FindBind(1, '+p1_lookdown', '-p1_lookdown'), '');
199 g_Console_BindKey(g_Console_FindBind(1, '+p1_attack', '-p1_attack'), '');
200 g_Console_BindKey(g_Console_FindBind(1, '+p1_jump', '-p1_jump'), '');
201 g_Console_BindKey(g_Console_FindBind(1, '+p1_activate', '-p1_activate'), '');
202 g_Console_BindKey(g_Console_FindBind(1, '+p1_strafe', '-p1_strafe'), '');
203 g_Console_BindKey(g_Console_FindBind(1, 'p1_dropflag', ''), '');
204 g_Console_BindKey(g_Console_FindBind(1, 'p1_weapnext', ''), '');
205 g_Console_BindKey(g_Console_FindBind(1, 'p1_weapprev', ''), '');
206 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0, '+p1_moveright', '-p1_moveright');
207 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0, '+p1_moveleft', '-p1_moveleft');
208 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0, '+p1_lookup', '-p1_lookup');
209 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0, '+p1_lookdown', '-p1_lookdown');
210 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0, '+p1_attack', '-p1_attack');
211 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0, '+p1_jump', '-p1_jump');
212 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0, '+p1_activate', '-p1_activate');
213 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0, '+p1_strafe', '-p1_strafe');
214 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DROPFLAG])).Key0, 'p1_dropflag', '');
215 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0, 'p1_weapnext', '', True);
216 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0, 'p1_weapprev', '', True);
217 // second set
218 g_Console_BindKey(g_Console_FindBind(2, '+p1_moveright', '-p1_moveright'), '');
219 g_Console_BindKey(g_Console_FindBind(2, '+p1_moveleft', '-p1_moveleft'), '');
220 g_Console_BindKey(g_Console_FindBind(2, '+p1_lookup', '-p1_lookup'), '');
221 g_Console_BindKey(g_Console_FindBind(2, '+p1_lookdown', '-p1_lookdown'), '');
222 g_Console_BindKey(g_Console_FindBind(2, '+p1_attack', '-p1_attack'), '');
223 g_Console_BindKey(g_Console_FindBind(2, '+p1_jump', '-p1_jump'), '');
224 g_Console_BindKey(g_Console_FindBind(2, '+p1_activate', '-p1_activate'), '');
225 g_Console_BindKey(g_Console_FindBind(2, '+p1_strafe', '-p1_strafe'), '');
226 g_Console_BindKey(g_Console_FindBind(2, 'p1_dropflag', ''), '');
227 g_Console_BindKey(g_Console_FindBind(2, 'p1_weapnext', ''), '');
228 g_Console_BindKey(g_Console_FindBind(2, 'p1_weapprev', ''), '');
229 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1, '+p1_moveright', '-p1_moveright');
230 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1, '+p1_moveleft', '-p1_moveleft');
231 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1, '+p1_lookup', '-p1_lookup');
232 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1, '+p1_lookdown', '-p1_lookdown');
233 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1, '+p1_attack', '-p1_attack');
234 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1, '+p1_jump', '-p1_jump');
235 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1, '+p1_activate', '-p1_activate');
236 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1, '+p1_strafe', '-p1_strafe');
237 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DROPFLAG])).Key1, 'p1_dropflag', '');
238 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1, 'p1_weapnext', '', True);
239 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1, 'p1_weapprev', '', True);
240 end;
242 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
243 with menu do
244 begin
245 for i := WP_FIRST to WP_LAST do
246 begin
247 g_Console_BindKey(g_Console_FindBind(1, 'p1_weapon ' + IntToStr(i + 1)), '');
248 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0, 'p1_weapon ' + IntToStr(i + 1));
249 g_Console_BindKey(g_Console_FindBind(2, 'p1_weapon ' + IntToStr(i + 1)), '');
250 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1, 'p1_weapon ' + IntToStr(i + 1));
251 end;
252 end;
254 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
255 with menu do
256 begin
257 g_Console_BindKey(g_Console_FindBind(1, '+p2_moveright', '-p2_moveright'), '');
258 g_Console_BindKey(g_Console_FindBind(1, '+p2_moveleft', '-p2_moveleft'), '');
259 g_Console_BindKey(g_Console_FindBind(1, '+p2_lookup', '-p2_lookup'), '');
260 g_Console_BindKey(g_Console_FindBind(1, '+p2_lookdown', '-p2_lookdown'), '');
261 g_Console_BindKey(g_Console_FindBind(1, '+p2_attack', '-p2_attack'), '');
262 g_Console_BindKey(g_Console_FindBind(1, '+p2_jump', '-p2_jump'), '');
263 g_Console_BindKey(g_Console_FindBind(1, '+p2_activate', '-p2_activate'), '');
264 g_Console_BindKey(g_Console_FindBind(1, '+p2_strafe', '-p2_strafe'), '');
265 g_Console_BindKey(g_Console_FindBind(1, 'p2_dropflag', ''), '');
266 g_Console_BindKey(g_Console_FindBind(1, 'p2_weapnext', ''), '');
267 g_Console_BindKey(g_Console_FindBind(1, 'p2_weapprev', ''), '');
268 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0, '+p2_moveright', '-p2_moveright');
269 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0, '+p2_moveleft', '-p2_moveleft');
270 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0, '+p2_lookup', '-p2_lookup');
271 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0, '+p2_lookdown', '-p2_lookdown');
272 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0, '+p2_attack', '-p2_attack');
273 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0, '+p2_jump', '-p2_jump');
274 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0, '+p2_activate', '-p2_activate');
275 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0, '+p2_strafe', '-p2_strafe');
276 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DROPFLAG])).Key0, 'p2_dropflag', '');
277 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0, 'p2_weapnext', '', True);
278 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0, 'p2_weapprev', '', True);
279 // second set
280 g_Console_BindKey(g_Console_FindBind(2, '+p2_moveright', '-p2_moveright'), '');
281 g_Console_BindKey(g_Console_FindBind(2, '+p2_moveleft', '-p2_moveleft'), '');
282 g_Console_BindKey(g_Console_FindBind(2, '+p2_lookup', '-p2_lookup'), '');
283 g_Console_BindKey(g_Console_FindBind(2, '+p2_lookdown', '-p2_lookdown'), '');
284 g_Console_BindKey(g_Console_FindBind(2, '+p2_attack', '-p2_attack'), '');
285 g_Console_BindKey(g_Console_FindBind(2, '+p2_jump', '-p2_jump'), '');
286 g_Console_BindKey(g_Console_FindBind(2, '+p2_activate', '-p2_activate'), '');
287 g_Console_BindKey(g_Console_FindBind(2, '+p2_strafe', '-p2_strafe'), '');
288 g_Console_BindKey(g_Console_FindBind(2, 'p2_dropflag', ''), '');
289 g_Console_BindKey(g_Console_FindBind(2, 'p2_weapnext', ''), '');
290 g_Console_BindKey(g_Console_FindBind(2, 'p2_weapprev', ''), '');
291 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1, '+p2_moveright', '-p2_moveright');
292 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1, '+p2_moveleft', '-p2_moveleft');
293 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1, '+p2_lookup', '-p2_lookup');
294 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1, '+p2_lookdown', '-p2_lookdown');
295 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1, '+p2_attack', '-p2_attack');
296 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1, '+p2_jump', '-p2_jump');
297 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1, '+p2_activate', '-p2_activate');
298 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1, '+p2_strafe', '-p2_strafe');
299 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DROPFLAG])).Key1, 'p2_dropflag', '');
300 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1, 'p2_weapnext', '', True);
301 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1, 'p2_weapprev', '', True);
302 end;
304 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
305 with menu do
306 begin
307 for i := WP_FIRST to WP_LAST do
308 begin
309 g_Console_BindKey(g_Console_FindBind(1, 'p2_weapon ' + IntToStr(i + 1)), '');
310 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0, 'p2_weapon ' + IntToStr(i + 1));
311 g_Console_BindKey(g_Console_FindBind(2, 'p2_weapon ' + IntToStr(i + 1)), '');
312 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1, 'p2_weapon ' + IntToStr(i + 1));
313 end;
314 end;
316 if e_HasJoysticks then
317 begin
318 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
319 with menu do
320 begin
321 for i := 0 to e_MaxJoys - 1 do
322 if e_JoystickAvailable[i] then
323 e_JoystickDeadzones[i] := TGUIScroll(menu.GetControl('scDeadzone' + IntToStr(i))).Value*(32767 div 20)
324 end
325 end;
327 if g_touch_enabled then
328 begin
329 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
330 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
331 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
332 g_touch_fire := TGUISwitch(menu.GetControl('swTouchFire')).ItemIndex = 1;
333 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
334 end;
336 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
337 gPlayer1Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP1Name')).Text);
338 gPlayer1Settings.Team := IfThen(TGUISwitch(menu.GetControl('swP1Team')).ItemIndex = 0,
339 TEAM_RED, TEAM_BLUE);
340 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mvP1Model')) do
341 begin
342 gPlayer1Settings.Model := Model.GetName();
343 gPlayer1Settings.Color := Model.Color;
344 end;
346 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
347 gPlayer2Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP2Name')).Text);
348 gPlayer2Settings.Team := IfThen(TGUISwitch(menu.GetControl('swP2Team')).ItemIndex = 0,
349 TEAM_RED, TEAM_BLUE);
350 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mvP2Model')) do
351 begin
352 gPlayer2Settings.Model := Model.GetName();
353 gPlayer2Settings.Color := Model.Color;
354 end;
356 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1WeaponMenu').GetControl('mOptionsPlayersP1WeaponMenu'));
357 gPlayer1Settings.WeaponSwitch := TGUISwitch(menu.GetControl('swWeaponAutoswitch')).ItemIndex;
358 gPlayer1Settings.SwitchToEmpty := TGUISwitch(menu.GetControl('swWeaponAllowEmpty')).ItemIndex;
359 gPlayer1Settings.SkipFist := TGUISwitch(menu.GetControl('swWeaponAllowFist')).ItemIndex;
360 menu := TGUIMenu(g_GUI_GetWindow('OptionsPreferencesP1WeaponMenu').GetControl('mOptionsPreferencesP1WeaponMenu'));
361 with menu do
362 begin
363 for i := WP_FIRST to WP_LAST+1 do
364 begin
365 gPlayer1Settings.WeaponPreferences[i] := TGUISwitch(menu.GetControl(IntToStr(i))).ItemIndex;
366 end;
367 end;
369 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2WeaponMenu').GetControl('mOptionsPlayersP2WeaponMenu'));
370 gPlayer2Settings.WeaponSwitch := TGUISwitch(menu.GetControl('swWeaponAutoswitch')).ItemIndex;
371 gPlayer2Settings.SwitchToEmpty := TGUISwitch(menu.GetControl('swWeaponAllowEmpty')).ItemIndex;
372 gPlayer2Settings.SkipFist := TGUISwitch(menu.GetControl('swWeaponAllowFist')).ItemIndex;
373 menu := TGUIMenu(g_GUI_GetWindow('OptionsPreferencesP2WeaponMenu').GetControl('mOptionsPreferencesP2WeaponMenu'));
374 with menu do
375 begin
376 for i := WP_FIRST to WP_LAST+1 do
377 begin
378 gPlayer2Settings.WeaponPreferences[i] := TGUISwitch(menu.GetControl(IntToStr(i))).ItemIndex;
379 end;
380 end;
382 if gPlayer1Settings.Name = '' then gPlayer1Settings.Name := GenPlayerName(1);
383 if gPlayer2Settings.Name = '' then gPlayer2Settings.Name := GenPlayerName(2);
385 if g_Game_IsServer then
386 begin
387 if gPlayer1 <> nil then
388 begin
389 gPlayer1.SetModel(gPlayer1Settings.Model);
390 gPlayer1.Name := gPlayer1Settings.Name;
391 if not (gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
392 gPlayer1.SetColor(gPlayer1Settings.Color)
393 else
394 if gPlayer1.Team <> gPlayer1Settings.Team then
395 gPlayer1.SwitchTeam;
396 gPlayer1.WeapSwitchMode := gPlayer1Settings.WeaponSwitch;
397 gPlayer1.setWeaponPrefs(gPlayer1Settings.WeaponPreferences);
398 gPlayer1.SwitchToEmpty := gPlayer1Settings.SwitchToEmpty;
399 gPlayer1.SkipFist := gPlayer1Settings.SkipFist;
400 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
401 end;
403 if gPlayer2 <> nil then
404 begin
405 gPlayer2.SetModel(gPlayer2Settings.Model);
406 gPlayer2.Name := gPlayer2Settings.Name;
407 if not (gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
408 gPlayer2.SetColor(gPlayer2Settings.Color)
409 else
410 if gPlayer2.Team <> gPlayer2Settings.Team then
411 gPlayer2.SwitchTeam;
412 gPlayer2.WeapSwitchMode := gPlayer2Settings.WeaponSwitch;
413 gPlayer2.setWeaponPrefs(gPlayer2Settings.WeaponPreferences);
414 gPlayer2.SwitchToEmpty := gPlayer2Settings.SwitchToEmpty;
415 gPlayer2.SkipFist := gPlayer2Settings.SkipFist;
416 //if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer2.UID);
417 end;
418 end;
420 if g_Game_IsClient then
421 begin
422 MC_SEND_PlayerSettings;
423 gPlayer1.setWeaponPrefs(gPlayer1Settings.WeaponPreferences);
424 end;
426 g_Console_WriteGameConfig;
427 end;
429 procedure ReadOptions();
430 var
431 menu: TGUIMenu;
432 i: Integer;
433 begin
434 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
436 with TGUISwitch(menu.GetControl('swBPP')) do
437 if gBPP = 16 then
438 ItemIndex := 0
439 else
440 ItemIndex := 1;
442 with TGUISwitch(menu.GetControl('swTextureFilter')) do
443 if gTextureFilter then ItemIndex := 0 else ItemIndex := 1;
445 with TGUISwitch(menu.GetControl('swVSync')) do
446 if gVSync then ItemIndex := 0 else ItemIndex := 1;
448 with TGUISwitch(menu.GetControl('swLegacyNPOT')) do
449 if not glNPOTOverride then ItemIndex := 0 else ItemIndex := 1;
451 with TGUISwitch(menu.GetControl('swInterp')) do
452 if gLerpActors then ItemIndex := 0 else ItemIndex := 1;
454 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
456 TGUIScroll(menu.GetControl('scSoundLevel')).Value := Round(gSoundLevel/16);
457 TGUIScroll(menu.GetControl('scMusicLevel')).Value := Round(gMusicLevel/16);
458 TGUIScroll(menu.GetControl('scMaxSimSounds')).Value := Round((gMaxSimSounds-2)/4);
460 with TGUISwitch(menu.GetControl('swInactiveSounds')) do
461 if gMuteWhenInactive then
462 ItemIndex := 1
463 else
464 ItemIndex := 0;
466 TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex := gAnnouncer;
468 with TGUISwitch(menu.GetControl('swSoundEffects')) do
469 if gSoundEffectsDF then
470 ItemIndex := 1
471 else
472 ItemIndex := 0;
474 with TGUISwitch(menu.GetControl('swChatSpeech')) do
475 if gUseChatSounds then
476 ItemIndex := 0
477 else
478 ItemIndex := 1;
480 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
481 with menu do
482 begin
483 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0 := g_Console_FindBind(1, '+p1_moveright', '-p1_moveright');
484 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0 := g_Console_FindBind(1, '+p1_moveleft', '-p1_moveleft');
485 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0 := g_Console_FindBind(1, '+p1_lookup', '-p1_lookup');
486 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := g_Console_FindBind(1, '+p1_lookdown', '-p1_lookdown');
487 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := g_Console_FindBind(1, '+p1_attack', '-p1_attack');
488 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := g_Console_FindBind(1, '+p1_jump', '-p1_jump');
489 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := g_Console_FindBind(1, '+p1_activate', '-p1_activate');
490 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := g_Console_FindBind(1, '+p1_strafe', '-p1_strafe');
491 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DROPFLAG])).Key0 := g_Console_FindBind(1, 'p1_dropflag', '');
492 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := g_Console_FindBind(1, 'p1_weapnext', '');
493 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := g_Console_FindBind(1, 'p1_weapprev', '');
494 // second set
495 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := g_Console_FindBind(2, '+p1_moveright', '-p1_moveright');
496 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := g_Console_FindBind(2, '+p1_moveleft', '-p1_moveleft');
497 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1 := g_Console_FindBind(2, '+p1_lookup', '-p1_lookup');
498 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := g_Console_FindBind(2, '+p1_lookdown', '-p1_lookdown');
499 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := g_Console_FindBind(2, '+p1_attack', '-p1_attack');
500 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := g_Console_FindBind(2, '+p1_jump', '-p1_jump');
501 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := g_Console_FindBind(2, '+p1_activate', '-p1_activate');
502 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := g_Console_FindBind(2, '+p1_strafe', '-p1_strafe');
503 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DROPFLAG])).Key1 := g_Console_FindBind(2, 'p1_dropflag', '');
504 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := g_Console_FindBind(2, 'p1_weapnext', '');
505 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := g_Console_FindBind(2, 'p1_weapprev', '');
506 end;
508 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
509 with menu do
510 begin
511 for i := WP_FIRST to WP_LAST do
512 begin
513 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0 := g_Console_FindBind(1, 'p1_weapon ' + IntToStr(i + 1));
514 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1 := g_Console_FindBind(2, 'p1_weapon ' + IntToStr(i + 1));
515 end;
516 end;
518 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
519 with menu do
520 begin
521 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0 := g_Console_FindBind(1, '+p2_moveright', '-p2_moveright');
522 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0 := g_Console_FindBind(1, '+p2_moveleft', '-p2_moveleft');
523 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0 := g_Console_FindBind(1, '+p2_lookup', '-p2_lookup');
524 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := g_Console_FindBind(1, '+p2_lookdown', '-p2_lookdown');
525 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := g_Console_FindBind(1, '+p2_attack', '-p2_attack');
526 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := g_Console_FindBind(1, '+p2_jump', '-p2_jump');
527 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := g_Console_FindBind(1, '+p2_activate', '-p2_activate');
528 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := g_Console_FindBind(1, '+p2_strafe', '-p2_strafe');
529 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DROPFLAG])).Key0 := g_Console_FindBind(1, 'p2_dropflag', '');
530 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := g_Console_FindBind(1, 'p2_weapnext', '');
531 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := g_Console_FindBind(1, 'p2_weapprev', '');
532 // second set
533 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := g_Console_FindBind(2, '+p2_moveright', '-p2_moveright');
534 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := g_Console_FindBind(2, '+p2_moveleft', '-p2_moveleft');
535 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1 := g_Console_FindBind(2, '+p2_lookup', '-p2_lookup');
536 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := g_Console_FindBind(2, '+p2_lookdown', '-p2_lookdown');
537 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := g_Console_FindBind(2, '+p2_attack', '-p2_attack');
538 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := g_Console_FindBind(2, '+p2_jump', '-p2_jump');
539 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := g_Console_FindBind(2, '+p2_activate', '-p2_activate');
540 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := g_Console_FindBind(2, '+p2_strafe', '-p2_strafe');
541 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DROPFLAG])).Key1 := g_Console_FindBind(2, 'p2_dropflag', '');
542 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := g_Console_FindBind(2, 'p2_weapnext', '');
543 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := g_Console_FindBind(2, 'p2_weapprev', '');
544 end;
546 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
547 with menu do
548 begin
549 for i := WP_FIRST to WP_LAST do
550 begin
551 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0 := g_Console_FindBind(1, 'p2_weapon ' + IntToStr(i + 1));
552 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1 := g_Console_FindBind(2, 'p2_weapon ' + IntToStr(i + 1));
553 end;
554 end;
556 if e_HasJoysticks then
557 begin
558 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
559 with menu do
560 begin
561 for i := 0 to e_MaxJoys - 1 do
562 if e_JoystickAvailable[i] then
563 TGUIScroll(menu.GetControl('scDeadzone' + IntToStr(i))).Value := e_JoystickDeadzones[i] div (32767 div 20)
564 end
565 end;
567 if g_touch_enabled then
568 begin
569 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
570 with TGUISwitch(menu.GetControl('swTouchAlt')) do
571 if g_touch_alt then ItemIndex := 1 else ItemIndex := 0;
572 TGUIScroll(menu.GetControl('scTouchSize')).Value := Round((g_touch_size - 0.5) * 10);
573 with TGUISwitch(menu.GetControl('swTouchFire')) do
574 if g_touch_fire then ItemIndex := 1 else ItemIndex := 0;
575 TGUIScroll(menu.GetControl('scTouchOffset')).Value := Round(g_touch_offset / 5);
576 end;
578 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
579 with menu do
580 begin
581 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_SCREENSHOT])).Key := g_Console_FindBind(1, 'screenshot');
582 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STAT])).Key := g_Console_FindBind(1, '+scores', '-scores');
583 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_CHAT])).Key := g_Console_FindBind(1, 'togglechat');
584 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_TEAMCHAT])).Key := g_Console_FindBind(1, 'toggleteamchat');
585 end;
587 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
589 {$IFDEF ENABLE_GFX}
590 TGUIScroll(menu.GetControl('scParticlesCount')).Value := g_GFX_GetMax() div 1000;
591 {$ENDIF}
592 TGUIScroll(menu.GetControl('scShellsMax')).Value := g_Shells_GetMax() div 30;
593 {$IFDEF ENABLE_GIBS}
594 TGUIScroll(menu.GetControl('scGibsMax')).Value := g_Gibs_GetMax() div 25;
595 {$ENDIF}
596 TGUIScroll(menu.GetControl('scCorpsesMax')).Value := g_Corpses_GetMax() div 5;
597 TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex := gBloodCount;
599 with TGUISwitch(menu.GetControl('swScreenFlash')) do
600 ItemIndex := gFlash;
602 with TGUISwitch(menu.GetControl('swBloodType')) do
603 if gAdvBlood then ItemIndex := 1 else ItemIndex := 0;
605 with TGUISwitch(menu.GetControl('swCorpseType')) do
606 if gAdvCorpses then ItemIndex := 1 else ItemIndex := 0;
608 with TGUISwitch(menu.GetControl('swGibsType')) do
609 if gAdvGibs then ItemIndex := 1 else ItemIndex := 0;
611 {$IFDEF ENABLE_GIBS}
612 with TGUISwitch(menu.GetControl('swGibsCount')) do
613 begin
614 case gGibsCount of
615 0: ItemIndex := 0;
616 8: ItemIndex := 1;
617 16: ItemIndex := 2;
618 32: ItemIndex := 3;
619 else ItemIndex := 4;
620 end;
621 end;
622 {$ENDIF}
624 with TGUISwitch(menu.GetControl('swBackGround')) do
625 if gDrawBackGround then ItemIndex := 0 else ItemIndex := 1;
627 with TGUISwitch(menu.GetControl('swMessages')) do
628 if gShowMessages then ItemIndex := 0 else ItemIndex := 1;
630 with TGUISwitch(menu.GetControl('swRevertPlayers')) do
631 if gRevertPlayers then ItemIndex := 0 else ItemIndex := 1;
633 with TGUISwitch(menu.GetControl('swChatBubble')) do
634 ItemIndex := gChatBubble;
636 with TGUISwitch(menu.GetControl('swPlayerIndicator')) do
637 ItemIndex := gPlayerIndicator;
639 with TGUISwitch(menu.GetControl('swPlayerIndicatorStyle')) do
640 ItemIndex := gPlayerIndicatorStyle;
642 TempScale := Round(g_dbg_scale - 1);
643 TGUIScroll(menu.GetControl('scScaleFactor')).Value := TempScale;
645 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
647 TGUIListBox(menu.GetControl('lsP1Model')).SelectItem(gPlayer1Settings.Model);
648 TGUIEdit(menu.GetControl('edP1Name')).Text := gPlayer1Settings.Name;
650 TGUISwitch(menu.GetControl('swP1Team')).ItemIndex :=
651 IfThen(gPlayer1Settings.Team = TEAM_BLUE, 1, 0);
653 TGUIScroll(menu.GetControl('scP1Red')).Value := Round(gPlayer1Settings.Color.R/16);
654 TGUIScroll(menu.GetControl('scP1Green')).Value := Round(gPlayer1Settings.Color.G/16);
655 TGUIScroll(menu.GetControl('scP1Blue')).Value := Round(gPlayer1Settings.Color.B/16);
657 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1WeaponMenu').GetControl('mOptionsPlayersP1WeaponMenu'));
658 TGUISwitch(menu.GetControl('swWeaponAutoswitch')).ItemIndex := gPlayer1Settings.WeaponSwitch;
659 TGUISwitch(menu.GetControl('swWeaponAllowEmpty')).ItemIndex := gPlayer1Settings.SwitchToEmpty;
660 TGUISwitch(menu.GetControl('swWeaponAllowFist')).ItemIndex := gPlayer1Settings.SkipFist;
661 menu := TGUIMenu(g_GUI_GetWindow('OptionsPreferencesP1WeaponMenu').GetControl('mOptionsPreferencesP1WeaponMenu'));
662 for i := WP_FIRST to WP_LAST+1 do
663 begin
664 if (gPlayer1Settings.WeaponPreferences[i] > 0) and (gPlayer1Settings.WeaponPreferences[i] <= WP_LAST+1) then TGUISwitch(menu.GetControl(IntToStr(i))).ItemIndex := gPlayer1Settings.WeaponPreferences[i]
665 else TGUISwitch(menu.GetControl(IntToStr(i))).ItemIndex := 0;
666 end;
668 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2WeaponMenu').GetControl('mOptionsPlayersP2WeaponMenu'));
669 TGUISwitch(menu.GetControl('swWeaponAutoswitch')).ItemIndex := gPlayer2Settings.WeaponSwitch;
670 TGUISwitch(menu.GetControl('swWeaponAllowEmpty')).ItemIndex := gPlayer2Settings.SwitchToEmpty;
671 TGUISwitch(menu.GetControl('swWeaponAllowFist')).ItemIndex := gPlayer2Settings.SkipFist;
672 menu := TGUIMenu(g_GUI_GetWindow('OptionsPreferencesP2WeaponMenu').GetControl('mOptionsPreferencesP2WeaponMenu'));
673 for i := WP_FIRST to WP_LAST+1 do
674 begin
675 if (gPlayer2Settings.WeaponPreferences[i] > 0) and (gPlayer2Settings.WeaponPreferences[i] <= WP_LAST+1) then TGUISwitch(menu.GetControl(IntToStr(i))).ItemIndex := gPlayer2Settings.WeaponPreferences[i]
676 else TGUISwitch(menu.GetControl(IntToStr(i))).ItemIndex := 0;
677 end;
679 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
681 TGUIListBox(menu.GetControl('lsP2Model')).SelectItem(gPlayer2Settings.Model);
682 TGUIEdit(menu.GetControl('edP2Name')).Text := gPlayer2Settings.Name;
684 TGUISwitch(menu.GetControl('swP2Team')).ItemIndex :=
685 IfThen(gPlayer2Settings.Team = TEAM_BLUE, 1, 0);
687 TGUIScroll(menu.GetControl('scP2Red')).Value := Round(gPlayer2Settings.Color.R/16);
688 TGUIScroll(menu.GetControl('scP2Green')).Value := Round(gPlayer2Settings.Color.G/16);
689 TGUIScroll(menu.GetControl('scP2Blue')).Value := Round(gPlayer2Settings.Color.B/16);
691 ProcSelectModel(nil);
692 end;
694 procedure ProcSwitchMonstersCustom(Sender: TGUIControl);
695 begin
696 // don't turn off monsters in DM
698 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
699 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
700 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
701 else
702 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
705 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
706 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
707 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
708 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
710 end;
712 procedure ProcSwitchMonstersNet(Sender: TGUIControl);
713 begin
714 // don't turn off monsters in DM
716 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
717 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
718 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
719 else
720 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
723 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
724 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
725 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
726 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
728 end;
730 function LatchGameOptions(const MenuName: string): Byte;
731 var
732 Map: string;
733 begin
734 Result := GM_NONE;
736 with TGUIMenu(g_ActiveWindow.GetControl(MenuName)) do
737 begin
738 Map := TGUILabel(GetControl('lbMap')).Text;
739 if Map = '' then
740 Exit;
741 if not isWadPath(Map) then
742 Exit;
744 Result := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
745 gsGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
746 gsTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
747 gsScoreLimit := StrToIntDef(TGUIEdit(GetControl('edScoreLimit')).Text, 0);
748 gsMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
749 gsItemRespawnTime := StrToIntDef(TGUIEdit(GetControl('edItemRespawnTime')).Text, 0);
750 gsPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
751 gsMap := Map;
753 gsGameFlags := 0;
754 if TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0 then
755 gsGameFlags := gsGameFlags or GAME_OPTION_TEAMDAMAGE;
756 if TGUISwitch(GetControl('swDeathmatchKeys')).ItemIndex = 0 then
757 gsGameFlags := gsGameFlags or GAME_OPTION_DMKEYS;
758 if TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0 then
759 gsGameFlags := gsGameFlags or GAME_OPTION_ALLOWEXIT;
760 if TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0 then
761 gsGameFlags := gsGameFlags or GAME_OPTION_WEAPONSTAY;
762 if TGUISwitch(GetControl('swMonsters')).ItemIndex = 0 then
763 gsGameFlags := gsGameFlags or GAME_OPTION_MONSTERS;
765 case TGUISwitch(GetControl('swTeamHit')).ItemIndex of
766 1: gsGameFlags := gsGameFlags or GAME_OPTION_TEAMHITTRACE;
767 2: gsGameFlags := gsGameFlags or GAME_OPTION_TEAMHITPROJECTILE;
768 0: gsGameFlags := gsGameFlags or GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE;
769 end;
771 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
772 1: gsGameFlags := gsGameFlags or GAME_OPTION_BOTVSMONSTER;
773 2: gsGameFlags := gsGameFlags or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
774 else gsGameFlags := gsGameFlags or GAME_OPTION_BOTVSPLAYER;
775 end;
777 case TGUISwitch(GetControl('swFlagDrop')).ItemIndex of
778 0: gsGameFlags := gsGameFlags or GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG;
779 1: gsGameFlags := gsGameFlags or GAME_OPTION_ALLOWDROPFLAG;
780 else gsGameFlags := gsGameFlags and not (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG);
781 end;
783 // TODO: get this crap out of here
784 gGameSettings.ItemRespawnTime := gsItemRespawnTime;
785 gGameSettings.WarmupTime := gsWarmupTime;
786 gGameSettings.SpawnInvul := gsSpawnInvul;
787 end;
788 end;
790 procedure ProcStartCustomGame();
791 var
792 GameMode: Byte;
793 begin
794 GameMode := LatchGameOptions('mCustomGameMenu');
795 if GameMode = GM_NONE then Exit;
797 g_Console_WriteGameConfig;
798 g_Game_StartCustom(gsMap, GameMode, gsTimeLimit, gsScoreLimit,
799 gsMaxLives, gsGameFlags, gsPlayers);
800 end;
803 procedure ProcStartNetGame();
804 var
805 GameMode: Byte;
806 begin
807 GameMode := LatchGameOptions('mNetServerMenu');
808 if GameMode = GM_NONE then Exit;
810 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
811 begin
812 NetPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
813 NetServerName := TGUIEdit(GetControl('edSrvName')).Text;
814 NetMaxClients := Max(1, StrToIntDef(TGUIEdit(GetControl('edMaxPlayers')).Text, 1));
815 NetMaxClients := Min(NET_MAXCLIENTS, NetMaxClients);
816 NetPassword := TGUIEdit(GetControl('edSrvPassword')).Text;
817 NetUseMaster := TGUISwitch(GetControl('swUseMaster')).ItemIndex = 0;
818 end;
820 g_Console_WriteGameConfig;
821 g_Game_StartServer(gsMap, GameMode, gsTimeLimit, gsScoreLimit, gsMaxLives,
822 gsGameFlags, gsPlayers, 0, NetPort);
823 end;
825 procedure ProcConnectNetGame();
826 var
827 PW: String;
828 begin
829 with TGUIMenu(g_ActiveWindow.GetControl('mNetClientMenu')) do
830 begin
831 NetClientIP := TGUIEdit(GetControl('edIP')).Text;
832 NetClientPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
833 PW := TGUIEdit(GetControl('edPW')).Text;
834 end;
836 g_Console_WriteGameConfig;
837 g_Game_StartClient(NetClientIP, NetClientPort, PW);
838 end;
840 procedure ProcEnterPassword();
841 var
842 PW: string;
843 begin
844 with TGUIMenu(g_ActiveWindow.GetControl('mClientPasswordMenu')) do
845 begin
846 NetClientIP := PromptIP;
847 NetClientPort := PromptPort;
848 PW := TGUIEdit(GetControl('edPW')).Text;
849 end;
851 g_Console_WriteGameConfig;
852 g_Game_StartClient(NetClientIP, NetClientPort, PW);
853 end;
855 procedure ProcServerlist();
856 begin
857 if not NetInitDone then
858 begin
859 if (not g_Net_Init()) then
860 begin
861 g_Console_Add('NET: ERROR: Failed to init ENet!');
862 Exit;
863 end
864 else
865 NetInitDone := True;
866 end;
868 g_Net_Slist_Set(NetMasterList);
870 gState := STATE_SLIST;
871 g_ActiveWindow := nil;
873 slWaitStr := _lc[I_NET_SLIST_WAIT];
875 r_Render_Draw;
876 sys_Repaint;
878 slReturnPressed := True;
879 if g_Net_Slist_Fetch(slCurrent) then
880 begin
881 if slCurrent = nil then
882 slWaitStr := _lc[I_NET_SLIST_NOSERVERS];
883 end
884 else
885 slWaitStr := _lc[I_NET_SLIST_ERROR];
886 g_Serverlist_GenerateTable(slCurrent, slTable);
887 end;
889 procedure ProcStartCampaign();
890 var
891 WAD: String;
892 TwoPlayers: Boolean;
893 n: Byte;
894 begin
895 with TGUIMenu(g_ActiveWindow.GetControl('mCampaignMenu')) do
896 begin
897 WAD := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
898 TwoPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex = 1;
899 end;
900 WAD := e_FindWadRel(MegawadDirs, WAD);
902 if TwoPlayers then
903 n := 2
904 else
905 n := 1;
906 g_Game_StartSingle(WAD + ':\MAP01', TwoPlayers, n);
907 end;
909 procedure ProcSelectMap(Sender: TGUIControl);
910 var
911 win: TGUIWindow;
912 a: TMapInfo;
913 wad, map, res: String;
914 begin
915 win := g_GUI_GetWindow('SelectMapMenu');
916 with TGUIMenu(win.GetControl('mSelectMapMenu')) do
917 begin
918 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
919 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
921 if (wad = '') or (map = '') then
922 begin // Ýòî íå êàðòà
923 TGUILabel(GetControl('lbMapName')).Text := '';
924 TGUILabel(GetControl('lbMapAuthor')).Text := '';
925 TGUILabel(GetControl('lbMapSize')).Text := '';
926 TGUIMemo(GetControl('meMapDescription')).SetText('');
927 TGUIMapPreview(win.GetControl('mpMapPreview')).ClearMap();
928 TGUILabel(win.GetControl('lbMapScale')).Text := '';
929 end
930 else // Ýòî êàðòà
931 begin
932 res := wad+':\'+map;
934 a := g_Map_GetMapInfo(res);
936 TGUILabel(GetControl('lbMapName')).Text := a.Name;
937 TGUILabel(GetControl('lbMapAuthor')).Text := a.Author;
938 TGUILabel(GetControl('lbMapSize')).Text := Format('%dx%d', [a.Width, a.Height]);
939 TGUIMemo(GetControl('meMapDescription')).SetText(a.Description);
940 TGUIMapPreview(win.GetControl('mpMapPreview')).SetMap(res);
941 TGUILabel(win.GetControl('lbMapScale')).Text :=
942 TGUIMapPreview(win.GetControl('mpMapPreview')).GetScaleStr;
943 end;
944 end;
945 end;
947 procedure ProcSelectWAD(Sender: TGUIControl);
948 var
949 wad: String;
950 list: SSArray;
951 begin
952 with TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu')) do
953 begin
954 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
956 with TGUIListBox(GetControl('lsMapRes')) do
957 begin
958 Clear();
960 if wad <> '' then
961 begin
962 list := g_Map_GetMapsList(wad);
964 if list <> nil then
965 begin
966 Items := list;
967 ItemIndex := 0;
968 end
969 end;
970 end;
971 end;
973 ProcSelectMap(nil);
974 end;
976 procedure ProcSelectCampaignWAD(Sender: TGUIControl);
977 var
978 win: TGUIWindow;
979 a: TMegaWADInfo;
980 wad, fn: String;
981 begin
982 win := g_GUI_GetWindow('CampaignMenu');
983 with TGUIMenu(win.GetControl('mCampaignMenu')) do
984 begin
985 wad := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
987 if wad = '' then
988 begin
989 TGUILabel(GetControl('lbWADName')).Text := '';
990 TGUILabel(GetControl('lbWADAuthor')).Text := '';
991 TGUIMemo(GetControl('meWADDescription')).SetText('');
992 end;
994 a := g_Game_GetMegaWADInfo(wad);
996 TGUILabel(GetControl('lbWADName')).Text := a.Name;
997 TGUILabel(GetControl('lbWADAuthor')).Text := a.Author;
998 TGUIMemo(GetControl('meWADDescription')).SetText(a.Description);
1000 TGUIImage(win.GetControl('mpWADImage')).ClearImage();
1002 if a.pic <> '' then
1003 begin
1004 fn := g_ExtractWadName(a.pic);
1005 if fn = '' then
1006 TGUIImage(win.GetControl('mpWADImage')).SetImage(wad+a.pic)
1007 else
1008 TGUIImage(win.GetControl('mpWADImage')).SetImage(a.pic);
1009 end;
1010 end;
1011 end;
1013 procedure ProcChangeColor(Sender: TGUIControl);
1014 var
1015 window: TGUIWindow;
1016 begin
1017 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
1018 with TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')) do
1019 TGUIModelView(window.GetControl('mvP1Model')).SetColor(
1020 Min(TGUIScroll(GetControl('scP1Red')).Value*16, 255),
1021 Min(TGUIScroll(GetControl('scP1Green')).Value*16, 255),
1022 Min(TGUIScroll(GetControl('scP1Blue')).Value*16, 255));
1024 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
1025 with TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')) do
1026 TGUIModelView(window.GetControl('mvP2Model')).SetColor(
1027 Min(TGUIScroll(GetControl('scP2Red')).Value*16, 255),
1028 Min(TGUIScroll(GetControl('scP2Green')).Value*16, 255),
1029 Min(TGUIScroll(GetControl('scP2Blue')).Value*16, 255));
1030 end;
1032 procedure ProcSelectModel(Sender: TGUIControl);
1033 var
1034 a: string;
1035 window: TGUIWindow;
1036 begin
1037 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
1038 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')).GetControl('lsP1Model')).SelectedItem;
1039 if a <> '' then TGUIModelView(window.GetControl('mvP1Model')).SetModel(a);
1041 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
1042 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')).GetControl('lsP2Model')).SelectedItem;
1043 if a <> '' then TGUIModelView(window.GetControl('mvP2Model')).SetModel(a);
1045 ProcChangeColor(nil);
1046 end;
1048 procedure MenuLoadData();
1049 begin
1050 e_WriteLog('Loading menu data...', TMsgType.Notify);
1052 g_Texture_CreateWADEx('MAINMENU_LOGO', GameWAD+':TEXTURES\MAINLOGO');
1053 g_Texture_CreateWADEx('MAINMENU_MARKER1', GameWAD+':TEXTURES\MARKER1');
1054 g_Texture_CreateWADEx('MAINMENU_MARKER2', GameWAD+':TEXTURES\MARKER2');
1055 g_Texture_CreateWADEx('SCROLL_LEFT', GameWAD+':TEXTURES\SLEFT');
1056 g_Texture_CreateWADEx('SCROLL_RIGHT', GameWAD+':TEXTURES\SRIGHT');
1057 g_Texture_CreateWADEx('SCROLL_MIDDLE', GameWAD+':TEXTURES\SMIDDLE');
1058 g_Texture_CreateWADEx('SCROLL_MARKER', GameWAD+':TEXTURES\SMARKER');
1059 g_Texture_CreateWADEx('EDIT_LEFT', GameWAD+':TEXTURES\ELEFT');
1060 g_Texture_CreateWADEx('EDIT_RIGHT', GameWAD+':TEXTURES\ERIGHT');
1061 g_Texture_CreateWADEx('EDIT_MIDDLE', GameWAD+':TEXTURES\EMIDDLE');
1062 g_Texture_CreateWADEx('BOX1', GameWAD+':TEXTURES\BOX1');
1063 g_Texture_CreateWADEx('BOX2', GameWAD+':TEXTURES\BOX2');
1064 g_Texture_CreateWADEx('BOX3', GameWAD+':TEXTURES\BOX3');
1065 g_Texture_CreateWADEx('BOX4', GameWAD+':TEXTURES\BOX4');
1066 g_Texture_CreateWADEx('BOX5', GameWAD+':TEXTURES\BOX5');
1067 g_Texture_CreateWADEx('BOX6', GameWAD+':TEXTURES\BOX6');
1068 g_Texture_CreateWADEx('BOX7', GameWAD+':TEXTURES\BOX7');
1069 g_Texture_CreateWADEx('BOX8', GameWAD+':TEXTURES\BOX8');
1070 g_Texture_CreateWADEx('BOX9', GameWAD+':TEXTURES\BOX9');
1071 g_Texture_CreateWADEx('BSCROLL_UP_A', GameWAD+':TEXTURES\SCROLLUPA');
1072 g_Texture_CreateWADEx('BSCROLL_UP_U', GameWAD+':TEXTURES\SCROLLUPU');
1073 g_Texture_CreateWADEx('BSCROLL_DOWN_A', GameWAD+':TEXTURES\SCROLLDOWNA');
1074 g_Texture_CreateWADEx('BSCROLL_DOWN_U', GameWAD+':TEXTURES\SCROLLDOWNU');
1075 g_Texture_CreateWADEx('BSCROLL_MIDDLE', GameWAD+':TEXTURES\SCROLLMIDDLE');
1076 g_Texture_CreateWADEx('NOPIC', GameWAD+':TEXTURES\NOPIC');
1078 g_Sound_CreateWADEx('MENU_SELECT', GameWAD+':SOUNDS\MENUSELECT');
1079 g_Sound_CreateWADEx('MENU_OPEN', GameWAD+':SOUNDS\MENUOPEN');
1080 g_Sound_CreateWADEx('MENU_CLOSE', GameWAD+':SOUNDS\MENUCLOSE');
1081 g_Sound_CreateWADEx('MENU_CHANGE', GameWAD+':SOUNDS\MENUCHANGE');
1082 g_Sound_CreateWADEx('SCROLL_ADD', GameWAD+':SOUNDS\SCROLLADD');
1083 g_Sound_CreateWADEx('SCROLL_SUB', GameWAD+':SOUNDS\SCROLLSUB');
1084 g_Sound_CreateWADEx('SOUND_PLAYER_FALL', GameWAD+':SOUNDS\FALL');
1085 end;
1087 procedure MenuFreeData();
1088 begin
1089 e_CharFont_Remove(gMenuFont);
1090 e_CharFont_Remove(gMenuSmallFont);
1092 g_Texture_Delete('MAINMENU_LOGO');
1093 g_Texture_Delete('MAINMENU_MARKER1');
1094 g_Texture_Delete('MAINMENU_MARKER2');
1095 g_Texture_Delete('SCROLL_LEFT');
1096 g_Texture_Delete('SCROLL_RIGHT');
1097 g_Texture_Delete('SCROLL_MIDDLE');
1098 g_Texture_Delete('SCROLL_MARKER');
1099 g_Texture_Delete('EDIT_LEFT');
1100 g_Texture_Delete('EDIT_RIGHT');
1101 g_Texture_Delete('EDIT_MIDDLE');
1102 g_Texture_Delete('BOX1');
1103 g_Texture_Delete('BOX2');
1104 g_Texture_Delete('BOX3');
1105 g_Texture_Delete('BOX4');
1106 g_Texture_Delete('BOX5');
1107 g_Texture_Delete('BOX6');
1108 g_Texture_Delete('BOX7');
1109 g_Texture_Delete('BOX8');
1110 g_Texture_Delete('BOX9');
1111 g_Texture_Delete('BSCROLL_UP_A');
1112 g_Texture_Delete('BSCROLL_UP_U');
1113 g_Texture_Delete('BSCROLL_DOWN_A');
1114 g_Texture_Delete('BSCROLL_DOWN_U');
1115 g_Texture_Delete('BSCROLL_MIDDLE');
1116 g_Texture_Delete('NOPIC');
1118 g_Sound_Delete('MENU_SELECT');
1119 g_Sound_Delete('MENU_OPEN');
1120 g_Sound_Delete('MENU_CLOSE');
1121 g_Sound_Delete('MENU_CHANGE');
1122 g_Sound_Delete('SCROLL_ADD');
1123 g_Sound_Delete('SCROLL_SUB');
1124 g_Sound_Delete('SOUND_PLAYER_FALL');
1125 end;
1127 procedure ProcAuthorsMenu();
1128 begin
1129 gMusic.SetByName('MUSIC_INTERMUS');
1130 gMusic.Play();
1131 end;
1133 procedure ProcExitMenuKeyDown (yes: Boolean);
1134 var
1135 s: ShortString;
1136 snd: TPlayableSound;
1137 res: Boolean;
1138 begin
1139 if yes then
1140 begin
1141 g_Game_StopAllSounds(True);
1142 case (Random(18)) of
1143 0: s := 'SOUND_MONSTER_PAIN';
1144 1: s := 'SOUND_MONSTER_DIE_3';
1145 2: s := 'SOUND_MONSTER_SLOP';
1146 3: s := 'SOUND_MONSTER_DEMON_DIE';
1147 4: s := 'SOUND_MONSTER_IMP_DIE_2';
1148 5: s := 'SOUND_MONSTER_MAN_DIE';
1149 6: s := 'SOUND_MONSTER_BSP_DIE';
1150 7: s := 'SOUND_MONSTER_VILE_DIE';
1151 8: s := 'SOUND_MONSTER_SKEL_DIE';
1152 9: s := 'SOUND_MONSTER_MANCUB_ALERT';
1153 10: s := 'SOUND_MONSTER_PAIN_PAIN';
1154 11: s := 'SOUND_MONSTER_BARON_DIE';
1155 12: s := 'SOUND_MONSTER_CACO_DIE';
1156 13: s := 'SOUND_MONSTER_CYBER_DIE';
1157 14: s := 'SOUND_MONSTER_KNIGHT_ALERT';
1158 15: s := 'SOUND_MONSTER_SPIDER_ALERT';
1159 else s := 'SOUND_PLAYER_FALL';
1160 end;
1161 snd := TPlayableSound.Create();
1162 res := snd.SetByName(s);
1163 if not res then res := snd.SetByName('SOUND_PLAYER_FALL');
1164 if res then
1165 begin
1166 snd.Play(True);
1167 while snd.IsPlaying() do begin end;
1168 end;
1169 g_Game_Quit();
1170 exit;
1171 end;
1172 g_GUI_HideWindow();
1173 end;
1175 procedure ProcLoadMenu();
1176 var
1177 a: Integer;
1178 valid: Boolean;
1179 begin
1180 for a := 1 to 8 do
1181 begin
1182 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Text := g_GetSaveName(a, valid);
1183 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := not valid;
1184 //TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a)).Enabled := valid;
1185 end;
1186 end;
1188 procedure ProcSaveMenu();
1189 var
1190 a: Integer;
1191 valid: Boolean;
1192 name: AnsiString;
1193 begin
1194 for a := 1 to 8 do
1195 begin
1196 name := g_GetSaveName(a, valid);
1197 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Text := name;
1198 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := (name <> '') and (not valid);
1199 end;
1200 end;
1202 procedure ProcSaveGame(Sender: TGUIControl);
1203 var
1204 a: Integer;
1205 begin
1206 if g_Game_IsNet then Exit;
1207 if g_Game_IsTestMap then Exit;
1208 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1209 g_Game_PauseAllSounds(True);
1210 g_SaveGame(a, TGUIEdit(Sender).Text);
1212 g_ActiveWindow := nil;
1213 g_Game_Pause(False);
1214 end;
1216 procedure ProcLoadGame(Sender: TGUIControl);
1217 var
1218 a: Integer;
1219 begin
1220 if g_Game_IsNet then Exit;
1221 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1222 if g_LoadGame(a) then
1223 begin
1224 g_Game_PauseAllSounds(False)
1225 end
1226 else // Íå çàãðóçèëîñü - âîçâðàò â ìåíþ
1227 begin
1228 g_Console_Add(_lc[I_MSG_BAD_SAVE_VERSION], true);
1229 g_GUI_GetWindow('LoadMenu').SetActive(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu'));
1230 //g_ActiveWindow := nil;
1231 end;
1232 end;
1234 procedure ProcSinglePlayer (n: Integer);
1235 var wad, map: AnsiString;
1236 begin
1237 assert(n >= 1);
1238 wad := g_ExtractWadName(gDefaultMegawadStart);
1239 map := g_ExtractFilePathName(gDefaultMegawadStart);
1240 if e_FindResource(AllMapDirs, wad) then
1241 begin
1242 wad := ExpandFileName(wad);
1243 g_Game_StartSingle(wad + ':\' + map, n > 1, n)
1244 end
1245 end;
1247 procedure ProcSingle1Player;
1248 begin
1249 ProcSinglePlayer(1)
1250 end;
1252 procedure ProcSingle2Players;
1253 begin
1254 ProcSinglePlayer(2)
1255 end;
1257 procedure ProcSelectMapMenu();
1258 var
1259 menu: TGUIMenu;
1260 wad_lb: TGUIFileListBox;
1261 map_lb: TGUIListBox;
1262 map: String;
1263 begin
1264 menu := TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1265 wad_lb := TGUIFileListBox(menu.GetControl('lsMapWAD'));
1266 map_lb := TGUIListBox(menu.GetControl('lsMapRes'));
1268 if wad_lb.SelectedItem() <> '' then
1269 map := map_lb.SelectedItem()
1270 else
1271 map := '';
1273 wad_lb.UpdateFileList();
1274 map_lb.Clear();
1276 if wad_lb.SelectedItem() <> '' then
1277 begin
1278 ProcSelectWAD(nil);
1279 map_lb.SelectItem(map);
1281 if map_lb.SelectedItem() <> '' then
1282 ProcSelectMap(nil);
1283 end;
1285 g_GUI_ShowWindow('SelectMapMenu');
1286 end;
1288 procedure ProcSelectCampaignMenu();
1289 var
1290 menu: TGUIMenu;
1291 wad_lb: TGUIFileListBox;
1292 begin
1293 menu := TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1294 wad_lb := TGUIFileListBox(menu.GetControl('lsWAD'));
1296 wad_lb.UpdateFileList();
1298 if wad_lb.SelectedItem() <> '' then
1299 ProcSelectCampaignWAD(nil);
1300 end;
1302 procedure ProcSetMap();
1303 var
1304 wad, map, res: String;
1305 begin
1306 with TGUIMenu(g_ActiveWindow.GetControl('mSelectMapMenu')) do
1307 begin
1308 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
1309 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1310 end;
1312 if (wad = '') or (map = '') then
1313 Exit;
1315 wad := e_FindWadRel(MapDirs, WAD);
1317 res := wad+':\'+map;
1319 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
1320 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res;
1321 end;
1323 procedure ProcChangeSoundSettings(Sender: TGUIControl);
1324 var
1325 menu: TGUIMenu;
1326 begin
1327 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1329 g_Sound_SetupAllVolumes(
1330 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
1331 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
1332 );
1333 end;
1335 procedure ProcChangeGameSettings(Sender: TGUIControl);
1336 var
1337 menu: TGUIMenu;
1338 begin
1339 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
1340 if TGUIScroll(menu.GetControl('scScaleFactor')).Value <> TempScale then
1341 begin
1342 TempScale := TGUIScroll(menu.GetControl('scScaleFactor')).Value;
1343 g_dbg_scale := TempScale + 1;
1344 end;
1345 end;
1347 procedure ProcChangeTouchSettings(Sender: TGUIControl);
1348 var
1349 menu: TGUIMenu;
1350 begin
1351 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
1352 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
1353 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
1354 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
1355 end;
1357 procedure ProcOptionsPlayersMIMenu();
1358 var
1359 s, a: string;
1360 i: Integer;
1361 begin
1362 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1364 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+s+'Menu')).GetControl('ls'+s+'Model')).SelectedItem;
1366 if a = '' then Exit;
1368 i := g_PlayerModel_GetIndex(a);
1369 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1370 begin
1371 TGUILabel(GetControl('lbName')).Text := PlayerModelsArray[i].Name;
1372 TGUILabel(GetControl('lbAuthor')).Text := PlayerModelsArray[i].Author;
1373 TGUIMemo(GetControl('meComment')).SetText(PlayerModelsArray[i].Description);
1375 if PlayerModelsArray[i].HaveWeapon then
1376 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1377 else
1378 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1379 end;
1381 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1382 end;
1384 procedure ProcOptionsPlayerP1WeaponMenu();
1385 var
1386 a: string;
1387 begin
1388 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+'P1'+'Menu')).GetControl('ls'+'P1'+'Model')).SelectedItem;
1389 if a = '' then Exit;
1390 g_GUI_ShowWindow('OptionsPlayersP1WeaponMenu');
1391 end;
1393 procedure ProcOptionsPlayerP1WeaponPreferencesMenu();
1394 begin
1395 g_GUI_ShowWindow('OptionsPreferencesP1WeaponMenu');
1396 end;
1398 procedure ProcOptionsPlayerP2WeaponMenu();
1399 var
1400 a: string;
1401 begin
1402 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+'P2'+'Menu')).GetControl('ls'+'P2'+'Model')).SelectedItem;
1403 if a = '' then Exit;
1404 g_GUI_ShowWindow('OptionsPlayersP2WeaponMenu');
1405 end;
1407 procedure ProcOptionsPlayerP2WeaponPreferencesMenu();
1408 begin
1409 g_GUI_ShowWindow('OptionsPreferencesP2WeaponMenu');
1410 end;
1412 procedure ProcOptionsPlayersAnim();
1413 var
1414 s: String;
1415 begin
1416 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1417 s := 'P1'
1418 else
1419 s := 'P2';
1421 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1422 begin
1423 NextAnim();
1424 Model.AnimState.Loop := True;
1425 end;
1426 end;
1428 procedure ProcOptionsPlayersWeap();
1429 var
1430 s: String;
1431 begin
1432 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1433 s := 'P1'
1434 else
1435 s := 'P2';
1437 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1438 NextWeapon();
1439 end;
1441 procedure ProcOptionsPlayersRot();
1442 var
1443 s: string;
1444 begin
1445 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1446 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1447 begin
1448 if Direction = TDirection.D_LEFT then Direction := TDirection.D_RIGHT else Direction := TDirection.D_LEFT;
1449 end;
1450 end;
1452 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1453 begin
1454 if yes then
1455 begin
1456 g_Options_SetDefault();
1457 ReadOptions();
1458 end;
1459 g_GUI_HideWindow();
1460 end;
1462 procedure ProcSavedMenuKeyDown (yes: Boolean);
1463 begin
1464 if yes then ReadOptions();
1465 g_GUI_HideWindow();
1466 end;
1468 procedure ProcAuthorsClose();
1469 begin
1470 gMusic.SetByName('MUSIC_MENU');
1471 gMusic.Play();
1472 gState := STATE_MENU;
1473 end;
1475 procedure ProcGMClose();
1476 begin
1477 g_Game_InGameMenu(False);
1478 end;
1480 procedure ProcGMShow();
1481 var
1482 Enabled: Boolean;
1483 begin
1484 Enabled := True;
1485 if (gGameSettings.GameType = GT_SINGLE) and
1486 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1487 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1488 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1489 if not gGameOn then
1490 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1491 if g_Game_IsTestMap then
1492 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1493 TGUIMainMenu(g_ActiveWindow.GetControl(
1494 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1495 end;
1497 procedure ProcChangePlayers();
1498 var
1499 TeamGame, Spectator, AddTwo: Boolean;
1500 P1Team{, P2Team}: Byte;
1501 bP2: TGUITextButton;
1502 begin
1503 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1504 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1505 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1506 P1Team := TEAM_NONE;
1507 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1508 // TODO
1509 //P2Team := TEAM_NONE;
1510 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1512 TGUIMainMenu(g_ActiveWindow.GetControl(
1513 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1514 TGUIMainMenu(g_ActiveWindow.GetControl(
1515 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1516 TGUIMainMenu(g_ActiveWindow.GetControl(
1517 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1519 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1520 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1521 bP2.Enabled := AddTwo and not Spectator;
1522 if bP2.Enabled then
1523 bP2.Color := MAINMENU_ITEMS_COLOR
1524 else
1525 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1526 if gPlayer2 = nil then
1527 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1528 else
1529 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1531 TGUIMainMenu(g_ActiveWindow.GetControl(
1532 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1533 end;
1535 procedure ProcJoinRed();
1536 begin
1537 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1538 Exit;
1539 if g_Game_IsServer then
1540 begin
1541 if gPlayer1 = nil then
1542 g_Game_AddPlayer(TEAM_RED)
1543 else
1544 begin
1545 if gPlayer1.Team <> TEAM_RED then
1546 begin
1547 gPlayer1.SwitchTeam;
1548 gPlayer1Settings.Team := gPlayer1.Team;
1549 end;
1551 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1552 end;
1553 end
1554 else
1555 begin
1556 gPlayer1Settings.Team := TEAM_RED;
1557 MC_SEND_PlayerSettings;
1558 if gPlayer1 = nil then
1559 g_Game_AddPlayer(TEAM_RED);
1560 end;
1561 g_ActiveWindow := nil;
1562 g_Game_Pause(False);
1563 end;
1565 procedure ProcJoinBlue();
1566 begin
1567 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1568 Exit;
1569 if g_Game_IsServer then
1570 begin
1571 if gPlayer1 = nil then
1572 g_Game_AddPlayer(TEAM_BLUE)
1573 else
1574 begin
1575 if gPlayer1.Team <> TEAM_BLUE then
1576 begin
1577 gPlayer1.SwitchTeam;
1578 gPlayer1Settings.Team := gPlayer1.Team;
1579 end;
1581 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1582 end;
1583 end
1584 else
1585 begin
1586 gPlayer1Settings.Team := TEAM_BLUE;
1587 MC_SEND_PlayerSettings;
1588 if gPlayer1 = nil then
1589 g_Game_AddPlayer(TEAM_BLUE);
1590 end;
1591 g_ActiveWindow := nil;
1592 g_Game_Pause(False);
1593 end;
1595 procedure ProcJoinGame();
1596 begin
1597 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1598 Exit;
1599 if gPlayer1 = nil then
1600 g_Game_AddPlayer();
1601 g_ActiveWindow := nil;
1602 g_Game_Pause(False);
1603 end;
1605 procedure ProcSwitchP2();
1606 begin
1607 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1608 Exit;
1609 if gPlayer1 = nil then
1610 Exit;
1611 if gPlayer2 = nil then
1612 g_Game_AddPlayer()
1613 else
1614 g_Game_RemovePlayer();
1615 g_ActiveWindow := nil;
1616 g_Game_Pause(False);
1617 end;
1619 procedure ProcSpectate();
1620 begin
1621 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1622 Exit;
1623 g_Game_Spectate();
1624 g_ActiveWindow := nil;
1625 g_Game_Pause(False);
1626 end;
1628 procedure ProcRestartMenuKeyDown (yes: Boolean);
1629 begin
1630 if yes then g_Game_Restart() else g_GUI_HideWindow;
1631 end;
1633 procedure ProcEndMenuKeyDown (yes: Boolean);
1634 begin
1635 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1636 end;
1638 procedure ProcSetRussianLanguage;
1639 begin
1640 if gLanguage <> LANGUAGE_RUSSIAN then
1641 begin
1642 gLanguage := LANGUAGE_RUSSIAN;
1643 gLanguageChange := True;
1644 gAskLanguage := False;
1645 ProcApplyOptions();
1646 end;
1647 end;
1649 procedure ProcSetEnglishLanguage;
1650 begin
1651 if gLanguage <> LANGUAGE_ENGLISH then
1652 begin
1653 gLanguage := LANGUAGE_ENGLISH;
1654 gLanguageChange := True;
1655 gAskLanguage := False;
1656 ProcApplyOptions();
1657 end;
1658 end;
1660 procedure ReadGameSettings();
1661 var
1662 menu: TGUIMenu;
1663 begin
1664 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1666 with gGameSettings do
1667 begin
1668 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1669 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1670 ItemIndex := 0
1671 else
1672 ItemIndex := 1;
1673 with TGUISwitch(menu.GetControl('swTeamHit')) do
1674 if (Options and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
1675 ItemIndex := 0
1676 else if LongBool(Options and GAME_OPTION_TEAMHITTRACE) then
1677 ItemIndex := 1
1678 else if LongBool(Options and GAME_OPTION_TEAMHITPROJECTILE) then
1679 ItemIndex := 2
1680 else
1681 ItemIndex := 3;
1682 with TGUISwitch(menu.GetControl('swDeathmatchKeys')) do
1683 if LongBool(Options and GAME_OPTION_DMKEYS) then
1684 ItemIndex := 0
1685 else
1686 ItemIndex := 1;
1687 with TGUISwitch(menu.GetControl('swFlagDrop')) do
1688 if LongBool(Options and GAME_OPTION_ALLOWDROPFLAG) and LongBool(Options and GAME_OPTION_THROWFLAG) then
1689 ItemIndex := 0
1690 else if LongBool(Options and GAME_OPTION_ALLOWDROPFLAG) then
1691 ItemIndex := 1
1692 else
1693 ItemIndex := 2;
1695 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1696 TGUIEdit(menu.GetControl('edScoreLimit')).Text := IntToStr(ScoreLimit);
1697 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1699 with TGUISwitch(menu.GetControl('swBotsVS')) do
1700 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1701 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1702 ItemIndex := 2
1703 else
1704 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1705 ItemIndex := 1
1706 else
1707 ItemIndex := 0;
1709 if GameType in [GT_CUSTOM, GT_SERVER] then
1710 begin
1711 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1712 TGUISwitch(menu.GetControl('swTeamHit')).Enabled := True;
1713 if (GameMode in [GM_DM, GM_TDM, GM_CTF]) then
1714 begin
1715 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := True;
1716 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_ITEMSTEXT_COLOR;
1717 end
1718 else
1719 begin
1720 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1721 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1722 end;
1723 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1724 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1725 TGUIEdit(menu.GetControl('edScoreLimit')).Enabled := True;
1726 TGUILabel(menu.GetControlsText('edScoreLimit')).Color := MENU_ITEMSTEXT_COLOR;
1727 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1728 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1729 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1730 TGUISwitch(menu.GetControl('swFlagDrop')).Enabled := True;
1731 end
1732 else
1733 begin
1734 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1735 TGUISwitch(menu.GetControl('swTeamHit')).Enabled := True;
1736 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1737 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1738 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1739 begin
1740 Enabled := False;
1741 Text := '';
1742 end;
1743 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1744 with TGUIEdit(menu.GetControl('edScoreLimit')) do
1745 begin
1746 Enabled := False;
1747 Text := '';
1748 end;
1749 TGUILabel(menu.GetControlsText('edScoreLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1750 with TGUIEdit(menu.GetControl('edMaxLives')) do
1751 begin
1752 Enabled := False;
1753 Text := '';
1754 end;
1755 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1756 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1757 TGUISwitch(menu.GetControl('swFlagDrop')).Enabled := False;
1758 end;
1759 end;
1760 end;
1762 procedure ProcApplyGameSet();
1763 var
1764 menu: TGUIMenu;
1765 a, b, n: Integer;
1766 stat: TPlayerStatArray;
1767 begin
1768 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1770 if not g_Game_IsServer then Exit;
1772 with gGameSettings do
1773 begin
1774 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1775 begin
1776 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1777 Options := Options or GAME_OPTION_TEAMDAMAGE
1778 else
1779 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1780 end;
1782 if TGUISwitch(menu.GetControl('swTeamHit')).Enabled then
1783 begin
1784 Options := Options and not (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE);
1785 case TGUISwitch(menu.GetControl('swTeamHit')).ItemIndex of
1786 1: Options := Options or GAME_OPTION_TEAMHITTRACE;
1787 2: Options := Options or GAME_OPTION_TEAMHITPROJECTILE;
1788 0: Options := Options or GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE;
1789 end;
1790 end;
1792 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled then
1793 begin
1794 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).ItemIndex = 0 then
1795 Options := Options or GAME_OPTION_DMKEYS
1796 else
1797 Options := Options and (not GAME_OPTION_DMKEYS);
1798 end;
1800 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1801 begin
1802 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1804 if n = 0 then
1805 TimeLimit := 0
1806 else
1807 begin
1808 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1810 TimeLimit := Max(n, b);
1811 end;
1812 end;
1814 if TGUIEdit(menu.GetControl('edScoreLimit')).Enabled then
1815 begin
1816 n := StrToIntDef(TGUIEdit(menu.GetControl('edScoreLimit')).Text, ScoreLimit);
1818 if n = 0 then
1819 ScoreLimit := 0
1820 else
1821 begin
1822 b := 0;
1823 if GameMode = GM_DM then
1824 begin // DM
1825 stat := g_Player_GetStats();
1826 if stat <> nil then
1827 for a := 0 to High(stat) do
1828 if stat[a].Frags > b then
1829 b := stat[a].Frags;
1830 end
1831 else // CTF
1832 b := Max(gTeamStat[TEAM_RED].Score, gTeamStat[TEAM_BLUE].Score);
1834 ScoreLimit := Max(n, b);
1835 end;
1836 end;
1838 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1839 begin
1840 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, MaxLives);
1841 if n < 0 then n := 0;
1842 if n > 255 then n := 255;
1843 if n = 0 then
1844 MaxLives := 0
1845 else
1846 begin
1847 b := 0;
1848 stat := g_Player_GetStats();
1849 if stat <> nil then
1850 for a := 0 to High(stat) do
1851 if stat[a].Lives > b then
1852 b := stat[a].Lives;
1854 MaxLives := Max(n, b);
1855 end;
1856 end;
1858 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1859 begin
1860 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1861 1:
1862 begin
1863 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1864 Options := Options or GAME_OPTION_BOTVSMONSTER;
1865 end;
1866 2:
1867 begin
1868 Options := Options or GAME_OPTION_BOTVSPLAYER;
1869 Options := Options or GAME_OPTION_BOTVSMONSTER;
1870 end;
1871 else
1872 begin
1873 Options := Options or GAME_OPTION_BOTVSPLAYER;
1874 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1875 end;
1876 end;
1877 end;
1879 if TGUISwitch(menu.GetControl('swFlagDrop')).Enabled then
1880 begin
1881 case TGUISwitch(menu.GetControl('swFlagDrop')).ItemIndex of
1882 0: Options := Options or GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG;
1883 1: Options := Options or GAME_OPTION_ALLOWDROPFLAG;
1884 else Options := Options and not (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG);
1885 end;
1886 end;
1888 // don't forget to latch this shit
1889 gsGameFlags := Options;
1890 gsMaxLives := MaxLives;
1891 gsScoreLimit := ScoreLimit;
1892 gsTimeLimit := TimeLimit;
1893 end;
1895 if g_Game_IsNet then MH_SEND_GameSettings;
1896 end;
1898 procedure ProcVideoOptionsRes();
1899 var
1900 menu: TGUIMenu;
1901 list: SSArray;
1902 begin
1903 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1905 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1906 IntToStr(gWinSizeX) +
1907 ' x ' + IntToStr(gWinSizeY) +
1908 ', ' + IntToStr(gBPP) + ' bpp';
1910 with TGUIListBox(menu.GetControl('lsResolution')) do
1911 begin
1912 list := sys_GetDisplayModes(gBPP);
1913 if list <> nil then
1914 begin
1915 Items := list;
1916 ItemIndex := Length(list)
1917 end
1918 else
1919 begin
1920 Clear
1921 end
1922 end;
1924 with TGUISwitch(menu.GetControl('swFullScreen')) do
1925 if gFullscreen then
1926 ItemIndex := 0
1927 else
1928 ItemIndex := 1;
1930 TempResScale := Round(r_pixel_scale - 1);
1931 with TGUISwitch(menu.GetControl('swResFactor')) do
1932 ItemIndex := Min(TempResScale, gRC_Width div 640 - 1);
1933 end;
1935 procedure ProcApplyVideoOptions();
1936 var
1937 menu: TGUIMenu;
1938 Fullscreen: Boolean;
1939 SWidth, SHeight: Integer;
1940 ScaleChanged: Boolean;
1941 str: String;
1942 begin
1943 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1945 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1946 if str <> '' then
1947 SScanf(str, '%dx%d', [@SWidth, @SHeight])
1948 else
1949 begin
1950 SWidth := gWinSizeX;
1951 SHeight := gWinSizeY;
1952 TempResScale := Min(TempResScale, SWidth div 640 - 1);
1953 end;
1955 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1957 ScaleChanged := False;
1958 if TGUISwitch(menu.GetControl('swResFactor')).ItemIndex <> TempResScale then
1959 begin
1960 TempResScale := Min(TGUISwitch(menu.GetControl('swResFactor')).ItemIndex, SWidth div 640 - 1);
1961 r_pixel_scale := TempResScale + 1;
1962 ScaleChanged := True;
1963 end;
1965 if (SWidth <> gWinSizeX) or
1966 (SHeight <> gWinSizeY) or
1967 (Fullscreen <> gFullscreen) or
1968 ScaleChanged then
1969 begin
1970 gResolutionChange := True;
1971 gRC_Width := SWidth;
1972 gRC_Height := SHeight;
1973 gRC_FullScreen := Fullscreen;
1974 gRC_Maximized := gWinMaximized;
1975 end;
1977 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1978 ProcApplyOptions();
1979 end;
1981 procedure ProcSetFirstRussianLanguage;
1982 begin
1983 gLanguage := LANGUAGE_RUSSIAN;
1984 gLanguageChange := True;
1985 gAskLanguage := False;
1986 end;
1988 procedure ProcSetFirstEnglishLanguage;
1989 begin
1990 gLanguage := LANGUAGE_ENGLISH;
1991 gLanguageChange := True;
1992 gAskLanguage := False;
1993 end;
1995 procedure ProcRecallAddress();
1996 begin
1997 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1998 begin
1999 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
2000 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
2001 end;
2002 end;
2004 procedure CreateFirstLanguageMenu();
2005 var
2006 Menu: TGUIWindow;
2007 begin
2008 Menu := TGUIWindow.Create('FirstLanguageMenu');
2010 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', ' '))) do
2011 begin
2012 Name := 'mmFirstLanguageMenu';
2013 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
2014 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
2015 end;
2017 Menu.DefControl := 'mmFirstLanguageMenu';
2018 Menu.MainWindow := True;
2019 g_GUI_AddWindow(Menu);
2020 end;
2022 procedure g_Menu_AskLanguage();
2023 begin
2024 CreateFirstLanguageMenu();
2025 g_GUI_ShowWindow('FirstLanguageMenu');
2026 end;
2028 procedure CreatePlayerOptionsMenu(s: String);
2029 var
2030 Menu: TGUIWindow;
2031 a: String;
2032 begin
2033 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
2034 if s = 'P1' then
2035 a := _lc[I_MENU_PLAYER_1]
2036 else
2037 a := _lc[I_MENU_PLAYER_2];
2038 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
2039 begin
2040 Name := 'mOptionsPlayers'+s+'Menu';
2041 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
2042 begin
2043 Name := 'ed'+s+'Name';
2044 MaxLength := 12;
2045 Width := 12;
2046 end;
2047 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
2048 begin
2049 Name := 'sw'+s+'Team';
2050 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
2051 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
2052 end ;
2053 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
2054 begin
2055 Name := 'ls'+s+'Model';
2056 Sort := True;
2057 Items := g_PlayerModel_GetNames();
2058 OnChange := ProcSelectModel;
2059 end;
2060 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
2061 begin
2062 Name := 'sc'+s+'Red';
2063 Max := 16;
2064 OnChange := ProcChangeColor;
2065 end;
2066 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
2067 begin
2068 Name := 'sc'+s+'Green';
2069 Max := 16;
2070 OnChange := ProcChangeColor;
2071 end;
2072 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
2073 begin
2074 Name := 'sc'+s+'Blue';
2075 Max := 16;
2076 OnChange := ProcChangeColor;
2077 end;
2078 AddSpace();
2079 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
2080 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
2081 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
2082 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
2083 if s = 'P1' then AddButton(@ProcOptionsPlayerP1WeaponMenu, _lc[I_MENU_WEAPON])
2084 else AddButton(@ProcOptionsPlayerP2WeaponMenu, _lc[I_MENU_WEAPON]);
2085 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
2086 begin
2087 Name := 'mv'+s+'Model';
2088 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
2089 Y := GetControl('ls'+s+'Model').Y;
2090 end;
2091 end;
2092 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
2093 g_GUI_AddWindow(Menu);
2094 end;
2096 procedure CreateAllMenus();
2097 var
2098 Menu: TGUIWindow;
2099 //SR: TSearchRec;
2100 a, cx, _y, i: Integer;
2101 //list: SSArray;
2102 begin
2103 Menu := TGUIWindow.Create('MainMenu');
2104 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, 'MAINMENU_LOGO', _lc[I_MENU_MAIN_MENU]))) do
2105 begin
2106 Name := 'mmMainMenu';
2107 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
2108 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
2109 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2110 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2111 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
2112 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
2113 end;
2114 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
2115 begin
2116 Color := _RGB(255, 255, 255);
2117 X := gScreenWidth-GetWidth-8;
2118 Y := gScreenHeight-GetHeight-8;
2119 end;
2120 Menu.DefControl := 'mmMainMenu';
2121 Menu.MainWindow := True;
2122 g_GUI_AddWindow(Menu);
2124 Menu := TGUIWindow.Create('NewGameMenu');
2125 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_NEW_GAME]))) do
2126 begin
2127 Name := 'mmNewGameMenu';
2128 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
2129 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
2130 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
2131 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
2132 end;
2133 Menu.DefControl := 'mmNewGameMenu';
2134 g_GUI_AddWindow(Menu);
2136 Menu := TGUIWindow.Create('NetGameMenu');
2137 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MULTIPLAYER]))) do
2138 begin
2139 Name := 'mmNetGameMenu';
2140 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
2141 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
2142 end;
2143 Menu.DefControl := 'mmNetGameMenu';
2144 g_GUI_AddWindow(Menu);
2146 Menu := TGUIWindow.Create('NetServerMenu');
2147 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
2148 begin
2149 Name := 'mNetServerMenu';
2150 with AddEdit(_lc[I_NET_SERVER_NAME]) do
2151 begin
2152 Name := 'edSrvName';
2153 OnlyDigits := False;
2154 Width := 16;
2155 MaxLength := 64;
2156 Text := NetServerName;
2157 end;
2158 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2159 begin
2160 Name := 'edSrvPassword';
2161 OnlyDigits := False;
2162 Width := 16;
2163 MaxLength := 24;
2164 Text := NetPassword;
2165 end;
2166 with AddEdit(_lc[I_NET_PORT]) do
2167 begin
2168 Name := 'edPort';
2169 OnlyDigits := True;
2170 Width := 4;
2171 MaxLength := 5;
2172 Text := IntToStr(NetPort);
2173 end;
2174 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2175 begin
2176 Name := 'edMaxPlayers';
2177 OnlyDigits := True;
2178 Width := 4;
2179 MaxLength := 2;
2180 Text := IntToStr(NetMaxClients);
2181 end;
2182 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2183 begin
2184 Name := 'swUseMaster';
2185 AddItem(_lc[I_MENU_YES]);
2186 AddItem(_lc[I_MENU_NO]);
2187 if NetUseMaster then
2188 ItemIndex := 0
2189 else
2190 ItemIndex := 1;
2191 end;
2192 AddSpace();
2193 with AddLabel(_lc[I_MENU_MAP]) do
2194 begin
2195 Name := 'lbMap';
2196 FixedLength := 16;
2197 Text := gsMap;
2198 OnClick := @ProcSelectMapMenu;
2199 end;
2200 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2201 begin
2202 Name := 'swGameMode';
2203 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2204 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2205 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2206 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2207 case g_Game_TextToMode(gsGameMode) of
2208 GM_NONE,
2209 GM_DM: ItemIndex := 0;
2210 GM_TDM: ItemIndex := 1;
2211 GM_CTF: ItemIndex := 2;
2212 GM_SINGLE,
2213 GM_COOP: ItemIndex := 3;
2214 end;
2215 OnChange := ProcSwitchMonstersCustom;
2216 end;
2217 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2218 begin
2219 Name := 'edTimeLimit';
2220 OnlyDigits := True;
2221 Width := 4;
2222 MaxLength := 5;
2223 if gsTimeLimit > 0 then
2224 Text := IntToStr(gsTimeLimit);
2225 end;
2226 with AddEdit(_lc[I_MENU_SCORE_LIMIT]) do
2227 begin
2228 Name := 'edScoreLimit';
2229 OnlyDigits := True;
2230 Width := 4;
2231 MaxLength := 5;
2232 if gsScoreLimit > 0 then
2233 Text := IntToStr(gsScoreLimit);
2234 end;
2235 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2236 begin
2237 Name := 'edMaxLives';
2238 OnlyDigits := True;
2239 Width := 4;
2240 MaxLength := 5;
2241 if gsMaxLives > 0 then
2242 Text := IntToStr(gsMaxLives);
2243 end;
2244 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2245 begin
2246 Name := 'edItemRespawnTime';
2247 OnlyDigits := True;
2248 Width := 4;
2249 MaxLength := 5;
2250 if gsItemRespawnTime > 0 then
2251 Text := IntToStr(gsItemRespawnTime);
2252 end;
2253 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2254 begin
2255 Name := 'swPlayers';
2256 AddItem(_lc[I_MENU_COUNT_NONE]);
2257 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2258 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2259 ItemIndex := gsPlayers;
2260 end;
2261 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2262 begin
2263 Name := 'swTeamDamage';
2264 AddItem(_lc[I_MENU_YES]);
2265 AddItem(_lc[I_MENU_NO]);
2266 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2267 ItemIndex := 0
2268 else
2269 ItemIndex := 1;
2270 end;
2271 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
2272 begin
2273 Name := 'swTeamHit';
2274 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
2275 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
2276 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
2277 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
2278 if (gsGameFlags and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
2279 ItemIndex := 0
2280 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITTRACE) then
2281 ItemIndex := 1
2282 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITPROJECTILE) then
2283 ItemIndex := 2
2284 else
2285 ItemIndex := 3;
2286 end;
2287 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2288 begin
2289 Name := 'swDeathmatchKeys';
2290 AddItem(_lc[I_MENU_YES]);
2291 AddItem(_lc[I_MENU_NO]);
2292 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2293 ItemIndex := 0
2294 else
2295 ItemIndex := 1;
2296 end;
2297 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2298 begin
2299 Name := 'swEnableExits';
2300 AddItem(_lc[I_MENU_YES]);
2301 AddItem(_lc[I_MENU_NO]);
2302 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2303 ItemIndex := 0
2304 else
2305 ItemIndex := 1;
2306 end;
2307 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2308 begin
2309 Name := 'swWeaponStay';
2310 AddItem(_lc[I_MENU_YES]);
2311 AddItem(_lc[I_MENU_NO]);
2312 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2313 ItemIndex := 0
2314 else
2315 ItemIndex := 1;
2316 end;
2317 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2318 begin
2319 Name := 'swMonsters';
2320 AddItem(_lc[I_MENU_YES]);
2321 AddItem(_lc[I_MENU_NO]);
2322 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2323 ItemIndex := 0
2324 else
2325 ItemIndex := 1;
2326 end;
2327 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2328 begin
2329 Name := 'swBotsVS';
2330 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2331 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2332 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2333 ItemIndex := 2;
2334 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2335 ItemIndex := 0;
2336 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2337 ItemIndex := 1;
2338 end;
2339 with AddSwitch(_lc[I_MENU_FLAG_DROP]) do
2340 begin
2341 Name := 'swFlagDrop';
2342 AddItem(_lc[I_MENU_FLAG_THROW]);
2343 AddItem(_lc[I_MENU_YES]);
2344 AddItem(_lc[I_MENU_NO]);
2345 if (gsGameFlags and (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG)) = (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG) then
2346 ItemIndex := 0
2347 else if LongBool(gsGameFlags and GAME_OPTION_ALLOWDROPFLAG) then
2348 ItemIndex := 1
2349 else
2350 ItemIndex := 2;
2351 end;
2352 AddSpace();
2353 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2355 ReAlign();
2356 end;
2357 Menu.DefControl := 'mNetServerMenu';
2358 g_GUI_AddWindow(Menu);
2360 Menu := TGUIWindow.Create('NetClientMenu');
2361 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2362 begin
2363 Name := 'mNetClientMenu';
2365 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2366 AddSpace();
2368 with AddEdit(_lc[I_NET_ADDRESS]) do
2369 begin
2370 Name := 'edIP';
2371 OnlyDigits :=False;
2372 Width := 12;
2373 MaxLength := 64;
2374 Text := 'localhost';
2375 end;
2376 with AddEdit(_lc[I_NET_PORT]) do
2377 begin
2378 Name := 'edPort';
2379 OnlyDigits := True;
2380 Width := 4;
2381 MaxLength := 5;
2382 Text := '25666';
2383 end;
2384 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2385 begin
2386 Name := 'edPW';
2387 OnlyDigits := False;
2388 Width := 12;
2389 MaxLength := 32;
2390 Text := '';
2391 end;
2393 AddSpace();
2394 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2396 ReAlign();
2397 end;
2398 Menu.DefControl := 'mNetClientMenu';
2399 g_GUI_AddWindow(Menu);
2401 Menu := TGUIWindow.Create('LoadMenu');
2402 Menu.OnShow := ProcLoadMenu;
2403 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2404 begin
2405 Name := 'mmLoadMenu';
2407 for a := 1 to 8 do
2408 with AddEdit('') do
2409 begin
2410 Name := 'edSlot'+IntToStr(a);
2411 Width := 16;
2412 MaxLength := 16;
2413 OnEnter := ProcLoadGame;
2414 end;
2415 end;
2416 Menu.DefControl := 'mmLoadMenu';
2417 g_GUI_AddWindow(Menu);
2419 Menu := TGUIWindow.Create('SaveMenu');
2420 Menu.OnShow := ProcSaveMenu;
2421 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2422 begin
2423 Name := 'mmSaveMenu';
2425 for a := 1 to 8 do
2426 with AddEdit('') do
2427 begin
2428 Name := 'edSlot'+IntToStr(a);
2429 Width := 16;
2430 MaxLength := 16;
2431 OnChange := ProcSaveGame;
2432 end;
2433 end;
2434 Menu.DefControl := 'mmSaveMenu';
2435 g_GUI_AddWindow(Menu);
2437 Menu := TGUIWindow.Create('CustomGameMenu');
2438 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2439 begin
2440 Name := 'mCustomGameMenu';
2441 with AddLabel(_lc[I_MENU_MAP]) do
2442 begin
2443 Name := 'lbMap';
2444 FixedLength := 16;
2445 Text := gsMap;
2446 OnClick := @ProcSelectMapMenu;
2447 end;
2448 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2449 begin
2450 Name := 'swGameMode';
2451 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2452 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2453 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2454 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2455 case g_Game_TextToMode(gsGameMode) of
2456 GM_NONE,
2457 GM_DM: ItemIndex := 0;
2458 GM_TDM: ItemIndex := 1;
2459 GM_CTF: ItemIndex := 2;
2460 GM_SINGLE,
2461 GM_COOP: ItemIndex := 3;
2462 end;
2463 OnChange := ProcSwitchMonstersCustom;
2464 end;
2465 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2466 begin
2467 Name := 'edTimeLimit';
2468 OnlyDigits := True;
2469 Width := 4;
2470 MaxLength := 5;
2471 if gsTimeLimit > 0 then
2472 Text := IntToStr(gsTimeLimit);
2473 end;
2474 with AddEdit(_lc[I_MENU_SCORE_LIMIT]) do
2475 begin
2476 Name := 'edScoreLimit';
2477 OnlyDigits := True;
2478 Width := 4;
2479 MaxLength := 5;
2480 if gsScoreLimit > 0 then
2481 Text := IntToStr(gsScoreLimit);
2482 end;
2483 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2484 begin
2485 Name := 'edMaxLives';
2486 OnlyDigits := True;
2487 Width := 4;
2488 MaxLength := 5;
2489 if gsMaxLives > 0 then
2490 Text := IntToStr(gsMaxLives);
2491 end;
2492 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2493 begin
2494 Name := 'edItemRespawnTime';
2495 OnlyDigits := True;
2496 Width := 4;
2497 MaxLength := 5;
2498 if gsItemRespawnTime > 0 then
2499 Text := IntToStr(gsItemRespawnTime);
2500 end;
2501 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2502 begin
2503 Name := 'swPlayers';
2504 AddItem(_lc[I_MENU_COUNT_NONE]);
2505 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2506 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2507 ItemIndex := gsPlayers;
2508 end;
2509 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2510 begin
2511 Name := 'swTeamDamage';
2512 AddItem(_lc[I_MENU_YES]);
2513 AddItem(_lc[I_MENU_NO]);
2514 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2515 ItemIndex := 0
2516 else
2517 ItemIndex := 1;
2518 end;
2519 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
2520 begin
2521 Name := 'swTeamHit';
2522 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
2523 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
2524 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
2525 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
2526 if (gsGameFlags and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
2527 ItemIndex := 0
2528 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITTRACE) then
2529 ItemIndex := 1
2530 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITPROJECTILE) then
2531 ItemIndex := 2
2532 else
2533 ItemIndex := 3;
2534 end;
2535 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2536 begin
2537 Name := 'swDeathmatchKeys';
2538 AddItem(_lc[I_MENU_YES]);
2539 AddItem(_lc[I_MENU_NO]);
2540 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2541 ItemIndex := 0
2542 else
2543 ItemIndex := 1;
2544 end;
2545 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2546 begin
2547 Name := 'swEnableExits';
2548 AddItem(_lc[I_MENU_YES]);
2549 AddItem(_lc[I_MENU_NO]);
2550 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2551 ItemIndex := 0
2552 else
2553 ItemIndex := 1;
2554 end;
2555 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2556 begin
2557 Name := 'swWeaponStay';
2558 AddItem(_lc[I_MENU_YES]);
2559 AddItem(_lc[I_MENU_NO]);
2560 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2561 ItemIndex := 0
2562 else
2563 ItemIndex := 1;
2564 end;
2565 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2566 begin
2567 Name := 'swMonsters';
2568 AddItem(_lc[I_MENU_YES]);
2569 AddItem(_lc[I_MENU_NO]);
2570 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2571 ItemIndex := 0
2572 else
2573 ItemIndex := 1;
2574 end;
2575 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2576 begin
2577 Name := 'swBotsVS';
2578 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2579 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2580 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2581 ItemIndex := 2;
2582 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2583 ItemIndex := 0;
2584 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2585 ItemIndex := 1;
2586 end;
2587 with AddSwitch(_lc[I_MENU_FLAG_DROP]) do
2588 begin
2589 Name := 'swFlagDrop';
2590 AddItem(_lc[I_MENU_FLAG_THROW]);
2591 AddItem(_lc[I_MENU_YES]);
2592 AddItem(_lc[I_MENU_NO]);
2593 if (gsGameFlags and (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG)) = (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG) then
2594 ItemIndex := 0
2595 else if LongBool(gsGameFlags and GAME_OPTION_ALLOWDROPFLAG) then
2596 ItemIndex := 1
2597 else
2598 ItemIndex := 2;
2599 end;
2600 AddSpace();
2601 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2603 ReAlign();
2604 end;
2605 Menu.DefControl := 'mCustomGameMenu';
2606 g_GUI_AddWindow(Menu);
2608 Menu := TGUIWindow.Create('CampaignMenu');
2609 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2610 begin
2611 Name := 'mCampaignMenu';
2613 AddSpace();
2614 AddSpace();
2615 AddSpace();
2616 AddSpace();
2617 AddSpace();
2618 AddSpace();
2620 with AddFileList('', 15, 4) do
2621 begin
2622 Name := 'lsWAD';
2623 OnChange := ProcSelectCampaignWAD;
2625 Sort := True;
2626 Dirs := True;
2627 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2628 SetBase(MegawadDirs);
2629 end;
2631 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2632 begin
2633 Name := 'lbWADName';
2634 FixedLength := 8;
2635 Enabled := False;
2636 end;
2637 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2638 begin
2639 Name := 'lbWADAuthor';
2640 FixedLength := 8;
2641 Enabled := False;
2642 end;
2643 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2644 with AddMemo('', 15, 3) do
2645 begin
2646 Name := 'meWADDescription';
2647 Color := MENU_ITEMSCTRL_COLOR;
2648 end;
2649 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2650 begin
2651 Name := 'swPlayers';
2652 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2653 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2654 end;
2655 AddSpace();
2656 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2658 ReAlign();
2660 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2661 begin
2662 Name := 'mpWADImage';
2663 DefaultRes := 'NOPIC';
2664 X := GetControl('lsWAD').X+4;
2665 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2666 end;
2667 end;
2668 Menu.DefControl := 'mCampaignMenu';
2669 g_GUI_AddWindow(Menu);
2671 Menu := TGUIWindow.Create('SelectMapMenu');
2672 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2673 begin
2674 Name := 'mSelectMapMenu';
2675 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2676 begin
2677 Name := 'lsMapWAD';
2678 OnChange := ProcSelectWAD;
2680 Sort := True;
2681 Dirs := True;
2682 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2683 SetBase(MapDirs);
2684 end;
2685 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2686 begin
2687 Name := 'lsMapRes';
2688 Sort := True;
2689 OnChange := ProcSelectMap;
2690 end;
2691 AddSpace();
2692 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2693 begin
2694 Name := 'lbMapName';
2695 FixedLength := 24;
2696 Enabled := False;
2697 end;
2698 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2699 begin
2700 Name := 'lbMapAuthor';
2701 FixedLength := 16;
2702 Enabled := False;
2703 end;
2704 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2705 begin
2706 Name := 'lbMapSize';
2707 FixedLength := 10;
2708 Enabled := False;
2709 end;
2710 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 20, 4) do
2711 begin
2712 Name := 'meMapDescription';
2713 end;
2715 ReAlign();
2717 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2718 begin
2719 Name := 'mpMapPreview';
2720 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2721 Y := GetControl('lsMapWAD').Y;
2722 end;
2723 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2724 begin
2725 Name := 'lbMapScale';
2726 FixedLength := 8;
2727 Enabled := False;
2728 Color := MENU_ITEMSCTRL_COLOR;
2729 X := GetControl('lsMapWAD').X +
2730 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2731 2 + MAPPREVIEW_WIDTH*4;
2732 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2733 end;
2734 end;
2735 Menu.OnClose := ProcSetMap;
2736 Menu.DefControl := 'mSelectMapMenu';
2737 g_GUI_AddWindow(Menu);
2739 Menu := TGUIWindow.Create('OptionsMenu');
2740 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_OPTIONS]))) do
2741 begin
2742 Name := 'mmOptionsMenu';
2743 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2744 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2745 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2746 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2747 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2748 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2749 AddSpace();
2750 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2751 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2752 end;
2753 Menu.OnClose := ProcApplyOptions;
2754 Menu.DefControl := 'mmOptionsMenu';
2755 g_GUI_AddWindow(Menu);
2757 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2758 gMenuSmallFont, @ProcSavedMenuKeyDown);
2759 g_GUI_AddWindow(Menu);
2761 Menu := TGUIWindow.Create('OptionsVideoMenu');
2762 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2763 begin
2764 Name := 'mOptionsVideoMenu';
2765 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2766 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2767 begin
2768 Name := 'swBPP';
2769 AddItem('16');
2770 AddItem('32');
2771 end;
2772 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2773 begin
2774 Name := 'swVSync';
2775 AddItem(_lc[I_MENU_YES]);
2776 AddItem(_lc[I_MENU_NO]);
2777 end;
2778 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2779 begin
2780 Name := 'swTextureFilter';
2781 AddItem(_lc[I_MENU_YES]);
2782 AddItem(_lc[I_MENU_NO]);
2783 end;
2784 with AddSwitch(_lc[I_MENU_VIDEO_INTERPOLATION]) do
2785 begin
2786 Name := 'swInterp';
2787 AddItem(_lc[I_MENU_YES]);
2788 AddItem(_lc[I_MENU_NO]);
2789 end;
2790 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2791 begin
2792 Name := 'swLegacyNPOT';
2793 AddItem(_lc[I_MENU_NO]);
2794 AddItem(_lc[I_MENU_YES]);
2795 end;
2796 AddSpace();
2797 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2798 ReAlign();
2799 end;
2800 Menu.DefControl := 'mOptionsVideoMenu';
2801 g_GUI_AddWindow(Menu);
2803 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2804 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2805 begin
2806 Name := 'mOptionsVideoResMenu';
2807 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2808 begin
2809 Name := 'lbCurrentRes';
2810 FixedLength := 24;
2811 Enabled := False;
2812 end;
2813 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2814 begin
2815 Name := 'lsResolution';
2816 Sort := False;
2817 end;
2818 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2819 begin
2820 Name := 'swFullScreen';
2821 AddItem(_lc[I_MENU_YES]);
2822 AddItem(_lc[I_MENU_NO]);
2823 end;
2824 with AddSwitch(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2825 begin
2826 Name := 'swResFactor';
2827 AddItem('1x');
2828 for i := 2 to gRC_Width div 640 do
2829 AddItem(IntToStr(i) + 'x');
2830 end;
2831 AddSpace();
2832 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2833 UpdateIndex();
2834 end;
2835 Menu.DefControl := 'mOptionsVideoResMenu';
2836 g_GUI_AddWindow(Menu);
2838 Menu := TGUIWindow.Create('OptionsSoundMenu');
2839 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
2840 begin
2841 Name := 'mOptionsSoundMenu';
2842 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2843 begin
2844 Name := 'scMusicLevel';
2845 Max := 16;
2846 OnChange := ProcChangeSoundSettings;
2847 end;
2848 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2849 begin
2850 Name := 'scSoundLevel';
2851 Max := 16;
2852 OnChange := ProcChangeSoundSettings;
2853 end;
2854 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2855 begin
2856 Name := 'scMaxSimSounds';
2857 Max := 16;
2858 end;
2859 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2860 begin;
2861 Name := 'swAnnouncer';
2862 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2863 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2864 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2865 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2866 end;
2867 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2868 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2869 begin;
2870 Name := 'swSoundEffects';
2871 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2872 AddItem(_lc[I_MENU_COMPAT_DF]);
2873 end;
2874 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
2875 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
2876 begin;
2877 Name := 'swChatSpeech';
2878 AddItem(_lc[I_MENU_YES]);
2879 AddItem(_lc[I_MENU_NO]);
2880 end;
2881 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2882 begin
2883 Name := 'swInactiveSounds';
2884 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2885 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2886 end;
2887 ReAlign();
2888 end;
2889 Menu.DefControl := 'mOptionsSoundMenu';
2890 g_GUI_AddWindow(Menu);
2892 Menu := TGUIWindow.Create('OptionsGameMenu');
2893 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
2894 begin
2895 Name := 'mOptionsGameMenu';
2896 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2897 begin
2898 Name := 'scParticlesCount';
2899 Max := 20;
2900 end;
2901 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2902 begin
2903 Name := 'swBloodCount';
2904 AddItem(_lc[I_MENU_COUNT_NONE]);
2905 AddItem(_lc[I_MENU_COUNT_SMALL]);
2906 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2907 AddItem(_lc[I_MENU_COUNT_BIG]);
2908 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2909 end;
2910 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2911 begin
2912 Name := 'scShellsMax';
2913 Max := 20;
2914 end;
2915 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2916 begin
2917 Name := 'scGibsMax';
2918 Max := 20;
2919 end;
2920 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2921 begin
2922 Name := 'scCorpsesMax';
2923 Max := 20;
2924 end;
2925 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2926 begin
2927 Name := 'swGibsCount';
2928 AddItem(_lc[I_MENU_COUNT_NONE]);
2929 AddItem(_lc[I_MENU_COUNT_SMALL]);
2930 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2931 AddItem(_lc[I_MENU_COUNT_BIG]);
2932 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2933 end;
2934 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2935 begin
2936 Name := 'swCorpseType';
2937 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2938 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2939 end;
2940 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2941 begin
2942 Name := 'swGibsType';
2943 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2944 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2945 end;
2946 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2947 begin
2948 Name := 'swBloodType';
2949 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2950 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2951 end;
2952 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2953 begin
2954 Name := 'swScreenFlash';
2955 AddItem(_lc[I_MENU_NO]);
2956 AddItem(_lc[I_MENU_COMPAT_DF]);
2957 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2958 end;
2959 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2960 begin
2961 Name := 'swBackground';
2962 AddItem(_lc[I_MENU_YES]);
2963 AddItem(_lc[I_MENU_NO]);
2964 end;
2965 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2966 begin
2967 Name := 'swMessages';
2968 AddItem(_lc[I_MENU_YES]);
2969 AddItem(_lc[I_MENU_NO]);
2970 end;
2971 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2972 begin
2973 Name := 'swRevertPlayers';
2974 AddItem(_lc[I_MENU_YES]);
2975 AddItem(_lc[I_MENU_NO]);
2976 end;
2977 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2978 begin
2979 Name := 'swChatBubble';
2980 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2981 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2982 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2983 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2984 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2985 end;
2986 with AddSwitch(_lc[I_MENU_GAME_PLAYER_INDICATOR]) do
2987 begin
2988 Name := 'swPlayerIndicator';
2989 AddItem(_lc[I_MENU_GAME_INDICATOR_NONE]);
2990 AddItem(_lc[I_MENU_GAME_INDICATOR_OWN]);
2991 AddItem(_lc[I_MENU_GAME_INDICATOR_ALL]);
2992 end;
2993 with AddSwitch(_lc[I_MENU_GAME_INDICATOR_STYLE]) do
2994 begin
2995 Name := 'swPlayerIndicatorStyle';
2996 AddItem(_lc[I_MENU_GAME_INDICATOR_ARROW]);
2997 AddItem(_lc[I_MENU_GAME_INDICATOR_NAME]);
2998 end;
2999 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
3000 begin
3001 Name := 'scScaleFactor';
3002 Max := 10;
3003 OnChange := ProcChangeGameSettings;
3004 end;
3005 ReAlign();
3006 end;
3007 Menu.DefControl := 'mOptionsGameMenu';
3008 g_GUI_AddWindow(Menu);
3010 Menu := TGUIWindow.Create('OptionsControlsMenu');
3011 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
3012 begin
3013 Name := 'mOptionsControlsMenu';
3014 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
3015 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
3016 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
3017 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
3018 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
3019 AddSpace();
3020 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
3021 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
3022 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
3023 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
3024 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
3025 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
3026 if e_HasJoysticks then
3027 begin
3028 AddSpace();
3029 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
3030 end;
3031 if g_touch_enabled then
3032 begin
3033 AddSpace();
3034 AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
3035 end;
3036 end;
3037 Menu.DefControl := 'mOptionsControlsMenu';
3038 g_GUI_AddWindow(Menu);
3040 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
3041 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
3042 begin
3043 Name := 'mOptionsControlsP1Menu';
3044 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
3045 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
3046 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
3047 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
3048 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
3049 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
3050 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
3051 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
3052 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
3053 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
3054 AddKeyRead2(_lc[I_MENU_CONTROL_DROPFLAG]).Name := _lc[I_MENU_CONTROL_DROPFLAG];
3055 end;
3056 Menu.DefControl := 'mOptionsControlsP1Menu';
3057 g_GUI_AddWindow(Menu);
3059 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
3060 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
3061 begin
3062 Name := 'mOptionsControlsP1MenuWeapons';
3063 for i := WP_FIRST to WP_LAST do
3064 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
3065 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
3066 end;
3067 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
3068 g_GUI_AddWindow(Menu);
3070 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
3071 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
3072 begin
3073 Name := 'mOptionsControlsP2Menu';
3074 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
3075 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
3076 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
3077 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
3078 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
3079 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
3080 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
3081 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
3082 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
3083 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
3084 AddKeyRead2(_lc[I_MENU_CONTROL_DROPFLAG]).Name := _lc[I_MENU_CONTROL_DROPFLAG];
3085 end;
3086 Menu.DefControl := 'mOptionsControlsP2Menu';
3087 g_GUI_AddWindow(Menu);
3089 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
3090 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
3091 begin
3092 Name := 'mOptionsControlsP2MenuWeapons';
3093 for i := WP_FIRST to WP_LAST do
3094 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
3095 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
3096 end;
3097 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
3098 g_GUI_AddWindow(Menu);
3100 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
3101 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
3102 begin
3103 Name := 'mOptionsControlsJoystickMenu';
3104 for i := 0 to e_MaxJoys - 1 do
3105 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
3106 begin
3107 Name := 'scDeadzone' + IntToStr(i);
3108 Max := 20
3109 end
3110 end;
3111 Menu.DefControl := 'mOptionsControlsJoystickMenu';
3112 g_GUI_AddWindow(Menu);
3114 Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
3115 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do
3116 begin
3117 Name := 'mOptionsControlsTouchMenu';
3118 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
3119 begin
3120 Name := 'swTouchAlt';
3121 AddItem(_lc[I_MENU_NO]);
3122 AddItem(_lc[I_MENU_YES]);
3123 OnChange := ProcChangeTouchSettings;
3124 end;
3125 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
3126 begin
3127 Name := 'scTouchSize';
3128 Max := 20;
3129 OnChange := ProcChangeTouchSettings;
3130 end;
3131 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
3132 begin
3133 Name := 'swTouchFire';
3134 AddItem(_lc[I_MENU_NO]);
3135 AddItem(_lc[I_MENU_YES]);
3136 end;
3137 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do
3138 begin
3139 Name := 'scTouchOffset';
3140 Max := 20;
3141 OnChange := ProcChangeTouchSettings;
3142 end;
3143 end;
3144 Menu.DefControl := 'mOptionsControlsTouchMenu';
3145 g_GUI_AddWindow(Menu);
3147 Menu := TGUIWindow.Create('OptionsPlayersMenu');
3148 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
3149 begin
3150 Name := 'mOptionsPlayersMenu';
3151 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
3152 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
3153 end;
3154 Menu.DefControl := 'mOptionsPlayersMenu';
3155 g_GUI_AddWindow(Menu);
3157 CreatePlayerOptionsMenu('P1');
3158 CreatePlayerOptionsMenu('P2');
3160 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
3161 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
3162 begin
3163 Name := 'mOptionsPlayersMIMenu';
3164 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
3165 begin
3166 Name := 'lbName';
3167 FixedLength := 16;
3168 end;
3169 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
3170 begin
3171 Name := 'lbAuthor';
3172 FixedLength := 16;
3173 end;
3174 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
3175 begin
3176 Name := 'meComment';
3177 end;
3178 AddSpace();
3179 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
3180 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
3181 begin
3182 Name := 'lbWeapon';
3183 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
3184 end;
3185 ReAlign();
3186 end;
3187 Menu.DefControl := 'mOptionsPlayersMIMenu';
3188 g_GUI_AddWindow(Menu);
3190 Menu := TGUIWindow.Create('OptionsPlayersP1WeaponMenu');
3191 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_WEAPON]))) do
3192 begin
3193 Name := 'mOptionsPlayersP1WeaponMenu';
3194 with AddSwitch(_lc[I_MENU_WEAPON_SWITCH]) do
3195 begin
3196 Name := 'swWeaponAutoswitch';
3197 AddItem(_lc[I_MENU_NO]);
3198 AddItem(_lc[I_MENU_WEAPON_SWITCH_LINEAR]);
3199 AddItem(_lc[I_MENU_WEAPON_SWITCH_PREFERENCE]);
3200 end;
3201 with AddSwitch(_lc[I_MENU_WEAPON_ALLOW_EMPTY]) do
3202 begin
3203 Name := 'swWeaponAllowEmpty';
3204 AddItem(_lc[I_MENU_YES]);
3205 AddItem(_lc[I_MENU_NO]);
3206 end;
3207 with AddSwitch(_lc[I_MENU_KASTET_ALLOW]) do
3208 begin
3209 Name := 'swWeaponAllowFist';
3210 AddItem(_lc[I_MENU_KASTET_ALLOW_ALWAYS]);
3211 AddItem(_lc[I_MENU_KASTET_ALLOW_BERSERK]);
3212 end;
3213 AddButton(@ProcOptionsPlayerP1WeaponPreferencesMenu, _lc[I_MENU_WEAPON_SWITCH_PRIORITY]);
3214 ReAlign();
3215 end;
3216 Menu.DefControl := 'mOptionsPlayersP1WeaponMenu';
3217 g_GUI_AddWindow(Menu);
3219 Menu := TGUIWindow.Create('OptionsPreferencesP1WeaponMenu');
3220 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_WEAPON_PRIORITY_PLAYER_1]))) do
3221 begin
3222 Name := 'mOptionsPreferencesP1WeaponMenu';
3223 for i := WP_FIRST to WP_LAST do
3224 begin
3225 with AddSwitch(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]) do
3226 begin
3227 Name := IntToStr(i);
3228 for a := WP_FIRST to WP_LAST+1 do
3229 begin
3230 AddItem(IntToStr(a));
3231 end;
3232 ItemIndex := i
3233 end;
3234 end;
3235 with AddSwitch(_lc[I_GAME_WEAPON_BERSERK]) do
3236 begin
3237 Name := IntToStr(WP_LAST+1);
3238 for a := WP_FIRST to WP_LAST+1 do
3239 begin
3240 AddItem(IntToStr(a));
3241 end;
3242 ItemIndex := WP_LAST + 1;
3243 end;
3244 end;
3245 Menu.DefControl := 'mOptionsPreferencesP1WeaponMenu';
3246 g_GUI_AddWindow(Menu);
3249 Menu := TGUIWindow.Create('OptionsPlayersP2WeaponMenu');
3250 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_WEAPON]))) do
3251 begin
3252 Name := 'mOptionsPlayersP2WeaponMenu';
3253 with AddSwitch(_lc[I_MENU_WEAPON_SWITCH]) do
3254 begin
3255 Name := 'swWeaponAutoswitch';
3256 AddItem(_lc[I_MENU_NO]);
3257 AddItem(_lc[I_MENU_WEAPON_SWITCH_LINEAR]);
3258 AddItem(_lc[I_MENU_WEAPON_SWITCH_PREFERENCE]);
3259 end;
3260 with AddSwitch(_lc[I_MENU_WEAPON_ALLOW_EMPTY]) do
3261 begin
3262 Name := 'swWeaponAllowEmpty';
3263 AddItem(_lc[I_MENU_YES]);
3264 AddItem(_lc[I_MENU_NO]);
3265 end;
3266 with AddSwitch(_lc[I_MENU_KASTET_ALLOW]) do
3267 begin
3268 Name := 'swWeaponAllowFist';
3269 AddItem(_lc[I_MENU_KASTET_ALLOW_ALWAYS]);
3270 AddItem(_lc[I_MENU_KASTET_ALLOW_BERSERK]);
3271 end;
3272 AddButton(@ProcOptionsPlayerP2WeaponPreferencesMenu, _lc[I_MENU_WEAPON_SWITCH_PRIORITY]);
3273 ReAlign();
3274 end;
3275 Menu.DefControl := 'mOptionsPlayersP2WeaponMenu';
3276 g_GUI_AddWindow(Menu);
3278 Menu := TGUIWindow.Create('OptionsPreferencesP2WeaponMenu');
3279 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_WEAPON_PRIORITY_PLAYER_2]))) do
3280 begin
3281 Name := 'mOptionsPreferencesP2WeaponMenu';
3282 for i := WP_FIRST to WP_LAST do
3283 begin
3284 with AddSwitch(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]) do
3285 begin
3286 Name := IntToStr(i);
3287 for a := WP_FIRST to WP_LAST+1 do
3288 begin
3289 AddItem(IntToStr(a));
3290 end;
3291 ItemIndex := i
3292 end;
3293 end;
3294 with AddSwitch(_lc[I_GAME_WEAPON_BERSERK]) do
3295 begin
3296 Name := IntToStr(WP_LAST+1);
3297 for a := WP_FIRST to WP_LAST+1 do
3298 begin
3299 AddItem(IntToStr(a));
3300 end;
3301 ItemIndex := WP_LAST + 1;
3302 end;
3303 end;
3304 Menu.DefControl := 'mOptionsPreferencesP2WeaponMenu';
3305 g_GUI_AddWindow(Menu);
3307 Menu := TGUIWindow.Create('OptionsLanguageMenu');
3308 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
3309 begin
3310 Name := 'mOptionsLanguageMenu';
3311 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
3312 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
3313 ReAlign();
3314 end;
3315 Menu.DefControl := 'mOptionsLanguageMenu';
3316 g_GUI_AddWindow(Menu);
3318 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
3319 gMenuSmallFont, @ProcDefaultMenuKeyDown);
3320 g_GUI_AddWindow(Menu);
3322 Menu := TGUIWindow.Create('AuthorsMenu');
3323 Menu.BackTexture := 'INTER';
3324 Menu.OnClose := ProcAuthorsClose;
3326 // Çàãîëîâîê:
3327 _y := 16;
3328 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
3329 begin
3330 Color := _RGB(255, 0, 0);
3331 X := (gScreenWidth div 2)-(GetWidth() div 2);
3332 Y := _y;
3333 _y := _y+GetHeight();
3334 end;
3335 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
3336 begin
3337 Color := _RGB(255, 0, 0);
3338 X := (gScreenWidth div 2)-(GetWidth() div 2);
3339 Y := _y;
3340 _y := _y+GetHeight()+32;
3341 end;
3342 // ×òî äåëàë: Êòî äåëàë
3343 cx := gScreenWidth div 2 - 320 + 64;
3344 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
3345 begin
3346 Color := _RGB(255, 0, 0);
3347 X := cx;
3348 Y := _y;
3349 _y := _y+22;
3350 end;
3351 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
3352 begin
3353 Color := _RGB(255, 255, 255);
3354 X := cx+32;
3355 Y := _y;
3356 _y := _y+36;
3357 end;
3358 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
3359 begin
3360 Color := _RGB(255, 0, 0);
3361 X := cx;
3362 Y := _y;
3363 _y := _y+22;
3364 end;
3365 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
3366 begin
3367 Color := _RGB(255, 255, 255);
3368 X := cx+32;
3369 Y := _y;
3370 _y := _y+22;
3371 end;
3372 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
3373 begin
3374 Color := _RGB(255, 255, 255);
3375 X := cx+32;
3376 Y := _y;
3377 _y := _y+36;
3378 end;
3379 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
3380 begin
3381 Color := _RGB(255, 0, 0);
3382 X := cx;
3383 Y := _y;
3384 _y := _y+22;
3385 end;
3386 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
3387 begin
3388 Color := _RGB(255, 255, 255);
3389 X := cx+32;
3390 Y := _y;
3391 _y := _y+36;
3392 end;
3393 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
3394 begin
3395 Color := _RGB(255, 0, 0);
3396 X := cx;
3397 Y := _y;
3398 _y := _y+22;
3399 end;
3400 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
3401 begin
3402 Color := _RGB(255, 255, 255);
3403 X := cx+32;
3404 Y := _y;
3405 _y := gScreenHeight - 128;
3406 end;
3407 // Çàêëþ÷åíèå:
3408 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
3409 begin
3410 Color := _RGB(255, 0, 0);
3411 X := cx;
3412 Y := _y;
3413 _y := _y+16;
3414 end;
3415 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
3416 begin
3417 Color := _RGB(255, 255, 255);
3418 X := cx+32;
3419 Y := _y;
3420 _y := _y+GetHeight();
3421 end;
3422 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
3423 begin
3424 Color := _RGB(255, 255, 255);
3425 X := cx+32;
3426 Y := _y;
3427 _y := _y+GetHeight();
3428 end;
3429 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
3430 begin
3431 Color := _RGB(255, 255, 255);
3432 X := cx+32;
3433 Y := _y;
3434 _y := gScreenHeight - 32;
3435 end;
3436 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
3437 begin
3438 Color := _RGB(255, 0, 0);
3439 X := gScreenWidth div 2 - GetWidth() div 2;
3440 Y := _y;
3441 end;
3442 g_GUI_AddWindow(Menu);
3444 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
3445 gMenuSmallFont, @ProcExitMenuKeyDown);
3446 g_GUI_AddWindow(Menu);
3448 Menu := TGUIWindow.Create('GameSingleMenu');
3449 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3450 begin
3451 Name := 'mmGameSingleMenu';
3452 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3453 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3454 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3455 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3456 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3457 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3458 end;
3459 Menu.DefControl := 'mmGameSingleMenu';
3460 Menu.MainWindow := True;
3461 Menu.OnClose := ProcGMClose;
3462 Menu.OnShow := ProcGMShow;
3463 g_GUI_AddWindow(Menu);
3465 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
3466 gMenuSmallFont, @ProcEndMenuKeyDown);
3467 g_GUI_AddWindow(Menu);
3469 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
3470 gMenuSmallFont, @ProcRestartMenuKeyDown);
3471 g_GUI_AddWindow(Menu);
3473 Menu := TGUIWindow.Create('GameCustomMenu');
3474 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3475 begin
3476 Name := 'mmGameCustomMenu';
3477 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3478 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3479 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3480 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3481 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3482 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3483 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3484 end;
3485 Menu.DefControl := 'mmGameCustomMenu';
3486 Menu.MainWindow := True;
3487 Menu.OnClose := ProcGMClose;
3488 Menu.OnShow := ProcGMShow;
3489 g_GUI_AddWindow(Menu);
3491 Menu := TGUIWindow.Create('GameServerMenu');
3492 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3493 begin
3494 Name := 'mmGameServerMenu';
3495 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3496 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3497 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3498 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3499 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3500 end;
3501 Menu.DefControl := 'mmGameServerMenu';
3502 Menu.MainWindow := True;
3503 Menu.OnClose := ProcGMClose;
3504 Menu.OnShow := ProcGMShow;
3505 g_GUI_AddWindow(Menu);
3507 Menu := TGUIWindow.Create('GameClientMenu');
3508 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3509 begin
3510 Name := 'mmGameClientMenu';
3511 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3512 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3513 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3514 end;
3515 Menu.DefControl := 'mmGameClientMenu';
3516 Menu.MainWindow := True;
3517 Menu.OnClose := ProcGMClose;
3518 Menu.OnShow := ProcGMShow;
3519 g_GUI_AddWindow(Menu);
3521 Menu := TGUIWindow.Create('ClientPasswordMenu');
3522 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
3523 begin
3524 Name := 'mClientPasswordMenu';
3525 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3526 begin
3527 Name := 'edPW';
3528 Width := 12;
3529 MaxLength := 32;
3530 end;
3531 AddSpace;
3533 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3534 ReAlign();
3535 end;
3536 Menu.DefControl := 'mClientPasswordMenu';
3537 g_GUI_AddWindow(Menu);
3539 Menu := TGUIWindow.Create('GameSetGameMenu');
3540 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3541 begin
3542 Name := 'mGameSetGameMenu';
3543 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3544 begin
3545 Name := 'swTeamDamage';
3546 AddItem(_lc[I_MENU_YES]);
3547 AddItem(_lc[I_MENU_NO]);
3548 ItemIndex := 1;
3549 end;
3550 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
3551 begin
3552 Name := 'swTeamHit';
3553 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
3554 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
3555 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
3556 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
3557 ItemIndex := 0
3558 end;
3559 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
3560 begin
3561 Name := 'swDeathmatchKeys';
3562 AddItem(_lc[I_MENU_YES]);
3563 AddItem(_lc[I_MENU_NO]);
3564 ItemIndex := 1;
3565 end;
3566 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3567 begin
3568 Name := 'edTimeLimit';
3569 OnlyDigits := True;
3570 Width := 4;
3571 MaxLength := 5;
3572 end;
3573 with AddEdit(_lc[I_MENU_SCORE_LIMIT]) do
3574 begin
3575 Name := 'edScoreLimit';
3576 OnlyDigits := True;
3577 Width := 4;
3578 MaxLength := 5;
3579 end;
3580 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3581 begin
3582 Name := 'edMaxLives';
3583 OnlyDigits := True;
3584 Width := 4;
3585 MaxLength := 5;
3586 end;
3587 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3588 begin
3589 Name := 'swBotsVS';
3590 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3591 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3592 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3593 ItemIndex := 2;
3594 end;
3595 with AddSwitch(_lc[I_MENU_FLAG_DROP]) do
3596 begin
3597 Name := 'swFlagDrop';
3598 AddItem(_lc[I_MENU_FLAG_THROW]);
3599 AddItem(_lc[I_MENU_YES]);
3600 AddItem(_lc[I_MENU_NO]);
3601 ItemIndex := 2;
3602 end;
3604 ReAlign();
3605 end;
3606 Menu.DefControl := 'mGameSetGameMenu';
3607 Menu.OnClose := ProcApplyGameSet;
3608 g_GUI_AddWindow(Menu);
3610 Menu := TGUIWindow.Create('TeamMenu');
3611 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_CHANGE_PLAYERS]))) do
3612 begin
3613 Name := 'mmTeamMenu';
3614 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3615 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3616 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3617 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3618 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3619 end;
3620 Menu.DefControl := 'mmTeamMenu';
3621 Menu.OnShow := ProcChangePlayers;
3622 g_GUI_AddWindow(Menu);
3623 end;
3625 procedure g_Menu_Show_SaveMenu();
3626 begin
3627 if g_Game_IsTestMap then
3628 Exit;
3629 if gGameSettings.GameType = GT_SINGLE then
3630 g_GUI_ShowWindow('GameSingleMenu')
3631 else
3632 begin
3633 if g_Game_IsClient then
3634 Exit
3635 else
3636 if g_Game_IsNet then
3637 Exit
3638 else
3639 g_GUI_ShowWindow('GameCustomMenu');
3640 end;
3641 g_GUI_ShowWindow('SaveMenu');
3642 g_Sound_PlayEx('MENU_OPEN');
3643 end;
3645 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3646 begin
3647 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3648 if gGameSettings.GameType = GT_SINGLE then
3649 begin
3650 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3651 end
3652 else
3653 begin
3654 if g_Game_IsClient then exit;
3655 if g_Game_IsNet then exit;
3656 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3657 end;
3658 g_GUI_ShowWindow('LoadMenu');
3659 g_Sound_PlayEx('MENU_OPEN');
3660 end;
3662 procedure g_Menu_Show_GameSetGame();
3663 begin
3664 if gGameSettings.GameType = GT_SINGLE then
3665 g_GUI_ShowWindow('GameSingleMenu')
3666 else
3667 begin
3668 if g_Game_IsClient then
3669 Exit
3670 else
3671 if g_Game_IsNet then
3672 g_GUI_ShowWindow('GameServerMenu')
3673 else
3674 g_GUI_ShowWindow('GameCustomMenu');
3675 end;
3676 ReadGameSettings();
3677 g_GUI_ShowWindow('GameSetGameMenu');
3678 g_Sound_PlayEx('MENU_OPEN');
3679 end;
3681 procedure g_Menu_Show_OptionsVideo();
3682 begin
3683 if gGameSettings.GameType = GT_SINGLE then
3684 g_GUI_ShowWindow('GameSingleMenu')
3685 else
3686 begin
3687 if g_Game_IsClient then
3688 g_GUI_ShowWindow('GameClientMenu')
3689 else
3690 if g_Game_IsNet then
3691 g_GUI_ShowWindow('GameServerMenu')
3692 else
3693 g_GUI_ShowWindow('GameCustomMenu');
3694 end;
3695 ReadOptions();
3696 g_GUI_ShowWindow('OptionsMenu');
3697 g_GUI_ShowWindow('OptionsVideoMenu');
3698 g_Sound_PlayEx('MENU_OPEN');
3699 end;
3701 procedure g_Menu_Show_OptionsSound();
3702 begin
3703 if gGameSettings.GameType = GT_SINGLE then
3704 g_GUI_ShowWindow('GameSingleMenu')
3705 else
3706 begin
3707 if g_Game_IsClient then
3708 g_GUI_ShowWindow('GameClientMenu')
3709 else
3710 if g_Game_IsNet then
3711 g_GUI_ShowWindow('GameServerMenu')
3712 else
3713 g_GUI_ShowWindow('GameCustomMenu');
3714 end;
3715 ReadOptions();
3716 g_GUI_ShowWindow('OptionsMenu');
3717 g_GUI_ShowWindow('OptionsSoundMenu');
3718 g_Sound_PlayEx('MENU_OPEN');
3719 end;
3721 procedure g_Menu_Show_EndGameMenu();
3722 begin
3723 g_GUI_ShowWindow('EndGameMenu');
3724 g_Sound_PlayEx('MENU_OPEN');
3725 end;
3727 procedure g_Menu_Show_QuitGameMenu();
3728 begin
3729 g_GUI_ShowWindow('ExitMenu');
3730 g_Sound_PlayEx('MENU_OPEN');
3731 end;
3733 procedure g_Menu_Init();
3734 begin
3735 MenuLoadData();
3736 CreateAllMenus();
3737 end;
3739 procedure g_Menu_Free();
3740 begin
3741 MenuFreeData();
3742 end;
3744 procedure g_Menu_Reset();
3745 var
3746 ex: Boolean;
3747 begin
3748 g_GUI_SaveMenuPos();
3749 ex := g_GUI_Destroy();
3751 if ex then
3752 begin
3753 e_WriteLog('Recreating menu...', TMsgType.Notify);
3755 CreateAllMenus();
3757 if gDebugMode then
3758 g_Game_SetDebugMode();
3760 g_GUI_LoadMenuPos();
3761 end;
3762 end;
3764 end.