DEADSOFTWARE

menu: allow to build menu without render
[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 {$IFDEF ENABLE_SHELLS}
49 g_shells,
50 {$ENDIF}
51 {$IFDEF ENABLE_CORPSES}
52 g_corpses,
53 {$ENDIF}
54 {$IFDEF ENABLE_RENDER}
55 r_render,
56 {$ENDIF}
57 {$IFDEF ENABLE_SYSTEM}
58 g_system,
59 {$ENDIF}
60 g_gui, g_game, g_map,
61 g_base, g_basic, g_console, g_sound, g_player, g_options, g_weapons,
62 e_log, SysUtils, CONFIG, g_playermodel, DateUtils,
63 MAPDEF, Math, g_saveload,
64 g_language, e_res,
65 g_net, g_netmsg, g_netmaster, g_items, e_input,
66 utils, wadreader;
69 type TYNCallback = procedure (yes:Boolean);
71 procedure YNKeyDownProc (win: TGUIWindow; Key: Byte);
72 begin
73 if win.UserData = nil then exit;
74 case Key of
75 IK_Y, IK_SPACE: TYNCallback(win.UserData)(true);
76 IK_N: TYNCallback(win.UserData)(false);
77 end;
78 end;
80 procedure YesButtonCB (ctl: TGUITextButton);
81 begin
82 if ctl.UserData = nil then exit;
83 TYNCallback(ctl.UserData)(true);
84 end;
86 procedure NoButtonCB (ctl: TGUITextButton);
87 begin
88 if ctl.UserData = nil then exit;
89 TYNCallback(ctl.UserData)(false);
90 end;
92 function CreateYNMenu (WinName, Text: String; MaxLen: Word; ActionProc: TYNCallback): TGUIWindow;
93 var
94 menu: TGUIMenu;
95 begin
96 //if length(Text) = 0 then exit;
97 Result := TGUIWindow.Create(WinName);
98 with Result do
99 begin
100 //OnKeyDownEx := @YNKeyDownProc;
101 //UserData := @ActionProc;
102 menu := TGUIMenu(Result.AddChild(TGUIMenu.Create(False, False, '')));
103 with menu do
104 begin
105 Name := '__temp_yes_no_menu:'+WinName;
106 YesNo := true;
107 AddText(Text, MaxLen);
108 with AddButton(nil, _lc[I_MENU_YES]) do begin ProcEx := @YesButtonCB; UserData := @ActionProc; end;
109 with AddButton(nil, _lc[I_MENU_NO]) do begin ProcEx := @NoButtonCB; UserData := @ActionProc; end;
110 end;
111 DefControl := '__temp_yes_no_menu:'+WinName;
112 SetActive(nil);
113 end;
114 end;
117 procedure ProcChangeColor(Sender: TGUIControl); forward;
118 procedure ProcSelectModel(Sender: TGUIControl); forward;
120 procedure ProcApplyOptions();
121 var
122 menu: TGUIMenu;
123 i: Integer;
124 begin
125 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
127 if TGUISwitch(menu.GetControl('swBPP')).ItemIndex = 0 then
128 gBPP := 16
129 else
130 gBPP := 32;
132 gVSync := TGUISwitch(menu.GetControl('swVSync')).ItemIndex = 0;
134 gTextureFilter := TGUISwitch(menu.GetControl('swTextureFilter')).ItemIndex = 0;
135 glNPOTOverride := not (TGUISwitch(menu.GetControl('swLegacyNPOT')).ItemIndex = 0);
136 gLerpActors := TGUISwitch(menu.GetControl('swInterp')).ItemIndex = 0;
138 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
140 g_Sound_SetupAllVolumes(
141 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
142 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
143 );
145 gMaxSimSounds := Max(Min(TGUIScroll(menu.GetControl('scMaxSimSounds')).Value*4+2, 66), 2);
146 gMuteWhenInactive := TGUISwitch(menu.GetControl('swInactiveSounds')).ItemIndex = 1;
147 gAnnouncer := TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex;
148 gSoundEffectsDF := TGUISwitch(menu.GetControl('swSoundEffects')).ItemIndex = 1;
149 gUseChatSounds := TGUISwitch(menu.GetControl('swChatSpeech')).ItemIndex = 0;
151 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
153 {$IFDEF ENABLE_GFX}
154 g_GFX_SetMax(TGUIScroll(menu.GetControl('scParticlesCount')).Value*1000);
155 {$ENDIF}
156 {$IFDEF ENABLE_SHELLS}
157 g_Shells_SetMax(TGUIScroll(menu.GetControl('scShellsMax')).Value*30);
158 {$ENDIF}
159 {$IFDEF ENABLE_GIBS}
160 g_Gibs_SetMax(TGUIScroll(menu.GetControl('scGibsMax')).Value*25);
161 {$ENDIF}
162 {$IFDEF ENABLE_CORPSES}
163 g_Corpses_SetMax(TGUIScroll(menu.GetControl('scCorpsesMax')).Value*5);
164 {$ENDIF}
166 {$IFDEF ENABLE_GIBS}
167 case TGUISwitch(menu.GetControl('swGibsCount')).ItemIndex of
168 0: gGibsCount := 0;
169 1: gGibsCount := 8;
170 2: gGibsCount := 16;
171 3: gGibsCount := 32;
172 else gGibsCount := 48;
173 end;
174 {$ENDIF}
176 gBloodCount := TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex;
177 gFlash := TGUISwitch(menu.GetControl('swScreenFlash')).ItemIndex;
178 gAdvBlood := TGUISwitch(menu.GetControl('swBloodType')).ItemIndex = 1;
179 gAdvCorpses := TGUISwitch(menu.GetControl('swCorpseType')).ItemIndex = 1;
180 gAdvGibs := TGUISwitch(menu.GetControl('swGibsType')).ItemIndex = 1;
181 gDrawBackGround := TGUISwitch(menu.GetControl('swBackGround')).ItemIndex = 0;
182 gShowMessages := TGUISwitch(menu.GetControl('swMessages')).ItemIndex = 0;
183 gRevertPlayers := TGUISwitch(menu.GetControl('swRevertPlayers')).ItemIndex = 0;
184 gChatBubble := TGUISwitch(menu.GetControl('swChatBubble')).ItemIndex;
185 gPlayerIndicator := TGUISwitch(menu.GetControl('swPlayerIndicator')).ItemIndex;
186 gPlayerIndicatorStyle := TGUISwitch(menu.GetControl('swPlayerIndicatorStyle')).ItemIndex;
187 if TGUIScroll(menu.GetControl('scScaleFactor')).Value <> TempScale then
188 begin
189 TempScale := TGUIScroll(menu.GetControl('scScaleFactor')).Value;
190 g_dbg_scale := TempScale + 1;
191 end;
193 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
195 with menu do
196 begin
197 g_Console_BindKey(g_Console_FindBind(1, 'screenshot'), '');
198 g_Console_BindKey(g_Console_FindBind(1, '+p1_scores', '-p1_scores'), '');
199 g_Console_BindKey(g_Console_FindBind(1, 'togglechat'), '');
200 g_Console_BindKey(g_Console_FindBind(1, 'toggleteamchat'), '');
201 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_SCREENSHOT])).Key, 'screenshot');
202 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STAT])).Key, '+p1_scores', '-p1_scores');
203 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_CHAT])).Key, 'togglechat');
204 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_TEAMCHAT])).Key, 'toggleteamchat');
205 end;
207 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
208 with menu do
209 begin
210 g_Console_BindKey(g_Console_FindBind(1, '+p1_moveright', '-p1_moveright'), '');
211 g_Console_BindKey(g_Console_FindBind(1, '+p1_moveleft', '-p1_moveleft'), '');
212 g_Console_BindKey(g_Console_FindBind(1, '+p1_lookup', '-p1_lookup'), '');
213 g_Console_BindKey(g_Console_FindBind(1, '+p1_lookdown', '-p1_lookdown'), '');
214 g_Console_BindKey(g_Console_FindBind(1, '+p1_attack', '-p1_attack'), '');
215 g_Console_BindKey(g_Console_FindBind(1, '+p1_jump', '-p1_jump'), '');
216 g_Console_BindKey(g_Console_FindBind(1, '+p1_weapnext', '-p1_weapnext'), '');
217 g_Console_BindKey(g_Console_FindBind(1, '+p1_weapprev', '-p1_weapprev'), '');
218 g_Console_BindKey(g_Console_FindBind(1, '+p1_activate', '-p1_activate'), '');
219 g_Console_BindKey(g_Console_FindBind(1, '+p1_strafe', '-p1_strafe'), '');
220 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0, '+p1_moveright', '-p1_moveright');
221 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0, '+p1_moveleft', '-p1_moveleft');
222 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0, '+p1_lookup', '-p1_lookup');
223 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0, '+p1_lookdown', '-p1_lookdown');
224 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0, '+p1_attack', '-p1_attack');
225 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0, '+p1_jump', '-p1_jump');
226 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0, '+p1_weapnext', '-p1_weapnext');
227 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0, '+p1_weapprev', '-p1_weapprev');
228 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0, '+p1_activate', '-p1_activate');
229 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0, '+p1_strafe', '-p1_strafe');
230 // second set
231 g_Console_BindKey(g_Console_FindBind(2, '+p1_moveright', '-p1_moveright'), '');
232 g_Console_BindKey(g_Console_FindBind(2, '+p1_moveleft', '-p1_moveleft'), '');
233 g_Console_BindKey(g_Console_FindBind(2, '+p1_lookup', '-p1_lookup'), '');
234 g_Console_BindKey(g_Console_FindBind(2, '+p1_lookdown', '-p1_lookdown'), '');
235 g_Console_BindKey(g_Console_FindBind(2, '+p1_attack', '-p1_attack'), '');
236 g_Console_BindKey(g_Console_FindBind(2, '+p1_jump', '-p1_jump'), '');
237 g_Console_BindKey(g_Console_FindBind(2, '+p1_weapnext', '-p1_weapnext'), '');
238 g_Console_BindKey(g_Console_FindBind(2, '+p1_weapprev', '-p1_weapprev'), '');
239 g_Console_BindKey(g_Console_FindBind(2, '+p1_activate', '-p1_activate'), '');
240 g_Console_BindKey(g_Console_FindBind(2, '+p1_strafe', '-p1_strafe'), '');
241 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1, '+p1_moveright', '-p1_moveright');
242 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1, '+p1_moveleft', '-p1_moveleft');
243 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1, '+p1_lookup', '-p1_lookup');
244 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1, '+p1_lookdown', '-p1_lookdown');
245 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1, '+p1_attack', '-p1_attack');
246 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1, '+p1_jump', '-p1_jump');
247 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1, '+p1_weapnext', '-p1_weapnext');
248 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1, '+p1_weapprev', '-p1_weapprev');
249 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1, '+p1_activate', '-p1_activate');
250 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1, '+p1_strafe', '-p1_strafe');
251 end;
253 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
254 with menu do
255 begin
256 for i := WP_FIRST to WP_LAST do
257 begin
258 g_Console_BindKey(g_Console_FindBind(1, 'p1_weapon ' + IntToStr(i + 1)), '');
259 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0, 'p1_weapon ' + IntToStr(i + 1));
260 g_Console_BindKey(g_Console_FindBind(2, 'p1_weapon ' + IntToStr(i + 1)), '');
261 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1, 'p1_weapon ' + IntToStr(i + 1));
262 end;
263 end;
265 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
266 with menu do
267 begin
268 g_Console_BindKey(g_Console_FindBind(1, '+p2_moveright', '-p2_moveright'), '');
269 g_Console_BindKey(g_Console_FindBind(1, '+p2_moveleft', '-p2_moveleft'), '');
270 g_Console_BindKey(g_Console_FindBind(1, '+p2_lookup', '-p2_lookup'), '');
271 g_Console_BindKey(g_Console_FindBind(1, '+p2_lookdown', '-p2_lookdown'), '');
272 g_Console_BindKey(g_Console_FindBind(1, '+p2_attack', '-p2_attack'), '');
273 g_Console_BindKey(g_Console_FindBind(1, '+p2_jump', '-p2_jump'), '');
274 g_Console_BindKey(g_Console_FindBind(1, '+p2_weapnext', '-p2_weapnext'), '');
275 g_Console_BindKey(g_Console_FindBind(1, '+p2_weapprev', '-p2_weapprev'), '');
276 g_Console_BindKey(g_Console_FindBind(1, '+p2_activate', '-p2_activate'), '');
277 g_Console_BindKey(g_Console_FindBind(1, '+p2_strafe', '-p2_strafe'), '');
278 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0, '+p2_moveright', '-p2_moveright');
279 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0, '+p2_moveleft', '-p2_moveleft');
280 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0, '+p2_lookup', '-p2_lookup');
281 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0, '+p2_lookdown', '-p2_lookdown');
282 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0, '+p2_attack', '-p2_attack');
283 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0, '+p2_jump', '-p2_jump');
284 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0, '+p2_weapnext', '-p2_weapnext');
285 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0, '+p2_weapprev', '-p2_weapprev');
286 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0, '+p2_activate', '-p2_activate');
287 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0, '+p2_strafe', '-p2_strafe');
288 // second set
289 g_Console_BindKey(g_Console_FindBind(2, '+p2_moveright', '-p2_moveright'), '');
290 g_Console_BindKey(g_Console_FindBind(2, '+p2_moveleft', '-p2_moveleft'), '');
291 g_Console_BindKey(g_Console_FindBind(2, '+p2_lookup', '-p2_lookup'), '');
292 g_Console_BindKey(g_Console_FindBind(2, '+p2_lookdown', '-p2_lookdown'), '');
293 g_Console_BindKey(g_Console_FindBind(2, '+p2_attack', '-p2_attack'), '');
294 g_Console_BindKey(g_Console_FindBind(2, '+p2_jump', '-p2_jump'), '');
295 g_Console_BindKey(g_Console_FindBind(2, '+p2_weapnext', '-p2_weapnext'), '');
296 g_Console_BindKey(g_Console_FindBind(2, '+p2_weapprev', '-p2_weapprev'), '');
297 g_Console_BindKey(g_Console_FindBind(2, '+p2_activate', '-p2_activate'), '');
298 g_Console_BindKey(g_Console_FindBind(2, '+p2_strafe', '-p2_strafe'), '');
299 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1, '+p2_moveright', '-p2_moveright');
300 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1, '+p2_moveleft', '-p2_moveleft');
301 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1, '+p2_lookup', '-p2_lookup');
302 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1, '+p2_lookdown', '-p2_lookdown');
303 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1, '+p2_attack', '-p2_attack');
304 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1, '+p2_jump', '-p2_jump');
305 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1, '+p2_weapnext', '-p2_weapnext');
306 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1, '+p2_weapprev', '-p2_weapprev');
307 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1, '+p2_activate', '-p2_activate');
308 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1, '+p2_strafe', '-p2_strafe');
309 end;
311 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
312 with menu do
313 begin
314 for i := WP_FIRST to WP_LAST do
315 begin
316 g_Console_BindKey(g_Console_FindBind(1, 'p2_weapon ' + IntToStr(i + 1)), '');
317 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0, 'p2_weapon ' + IntToStr(i + 1));
318 g_Console_BindKey(g_Console_FindBind(2, 'p2_weapon ' + IntToStr(i + 1)), '');
319 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1, 'p2_weapon ' + IntToStr(i + 1));
320 end;
321 end;
323 if e_HasJoysticks then
324 begin
325 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
326 with menu do
327 begin
328 for i := 0 to e_MaxJoys - 1 do
329 if e_JoystickAvailable[i] then
330 e_JoystickDeadzones[i] := TGUIScroll(menu.GetControl('scDeadzone' + IntToStr(i))).Value*(32767 div 20)
331 end
332 end;
334 if g_touch_enabled then
335 begin
336 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
337 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
338 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
339 g_touch_fire := TGUISwitch(menu.GetControl('swTouchFire')).ItemIndex = 1;
340 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
341 end;
343 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
345 gPlayer1Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP1Name')).Text);
346 gPlayer1Settings.Team := IfThen(TGUISwitch(menu.GetControl('swP1Team')).ItemIndex = 0,
347 TEAM_RED, TEAM_BLUE);
349 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mvP1Model')) do
350 begin
351 gPlayer1Settings.Model := Model.GetName();
352 gPlayer1Settings.Color := Model.Color;
353 end;
355 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
357 gPlayer2Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP2Name')).Text);
358 gPlayer2Settings.Team := IfThen(TGUISwitch(menu.GetControl('swP2Team')).ItemIndex = 0,
359 TEAM_RED, TEAM_BLUE);
360 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mvP2Model')) do
361 begin
362 gPlayer2Settings.Model := Model.GetName();
363 gPlayer2Settings.Color := Model.Color;
364 end;
366 if gPlayer1Settings.Name = '' then gPlayer1Settings.Name := GenPlayerName(1);
367 if gPlayer2Settings.Name = '' then gPlayer2Settings.Name := GenPlayerName(2);
369 if g_Game_IsServer then
370 begin
371 if gPlayer1 <> nil then
372 begin
373 gPlayer1.SetModel(gPlayer1Settings.Model);
374 gPlayer1.Name := gPlayer1Settings.Name;
375 if not (gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
376 gPlayer1.SetColor(gPlayer1Settings.Color)
377 else
378 if gPlayer1.Team <> gPlayer1Settings.Team then
379 gPlayer1.SwitchTeam;
381 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
382 end;
384 if gPlayer2 <> nil then
385 begin
386 gPlayer2.SetModel(gPlayer2Settings.Model);
387 gPlayer2.Name := gPlayer2Settings.Name;
388 if (gGameSettings.GameMode <> GM_TDM) and (gGameSettings.GameMode <> GM_CTF) then
389 gPlayer2.SetColor(gPlayer2Settings.Color)
390 else
391 if gPlayer2.Team <> gPlayer2Settings.Team then
392 gPlayer2.SwitchTeam;
393 end;
394 end;
396 if g_Game_IsClient then MC_SEND_PlayerSettings;
398 g_Console_WriteGameConfig;
399 end;
401 procedure ReadOptions();
402 var
403 menu: TGUIMenu;
404 i: Integer;
405 begin
406 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
408 with TGUISwitch(menu.GetControl('swBPP')) do
409 if gBPP = 16 then
410 ItemIndex := 0
411 else
412 ItemIndex := 1;
414 with TGUISwitch(menu.GetControl('swTextureFilter')) do
415 if gTextureFilter then ItemIndex := 0 else ItemIndex := 1;
417 with TGUISwitch(menu.GetControl('swVSync')) do
418 if gVSync then ItemIndex := 0 else ItemIndex := 1;
420 with TGUISwitch(menu.GetControl('swLegacyNPOT')) do
421 if not glNPOTOverride then ItemIndex := 0 else ItemIndex := 1;
423 with TGUISwitch(menu.GetControl('swInterp')) do
424 if gLerpActors then ItemIndex := 0 else ItemIndex := 1;
426 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
428 TGUIScroll(menu.GetControl('scSoundLevel')).Value := Round(gSoundLevel/16);
429 TGUIScroll(menu.GetControl('scMusicLevel')).Value := Round(gMusicLevel/16);
430 TGUIScroll(menu.GetControl('scMaxSimSounds')).Value := Round((gMaxSimSounds-2)/4);
432 with TGUISwitch(menu.GetControl('swInactiveSounds')) do
433 if gMuteWhenInactive then
434 ItemIndex := 1
435 else
436 ItemIndex := 0;
438 TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex := gAnnouncer;
440 with TGUISwitch(menu.GetControl('swSoundEffects')) do
441 if gSoundEffectsDF then
442 ItemIndex := 1
443 else
444 ItemIndex := 0;
446 with TGUISwitch(menu.GetControl('swChatSpeech')) do
447 if gUseChatSounds then
448 ItemIndex := 0
449 else
450 ItemIndex := 1;
452 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
453 with menu do
454 begin
455 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0 := g_Console_FindBind(1, '+p1_moveright', '-p1_moveright');
456 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0 := g_Console_FindBind(1, '+p1_moveleft', '-p1_moveleft');
457 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0 := g_Console_FindBind(1, '+p1_lookup', '-p1_lookup');
458 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := g_Console_FindBind(1, '+p1_lookdown', '-p1_lookdown');
459 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := g_Console_FindBind(1, '+p1_attack', '-p1_attack');
460 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := g_Console_FindBind(1, '+p1_jump', '-p1_jump');
461 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := g_Console_FindBind(1, '+p1_weapnext', '-p1_weapnext');
462 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := g_Console_FindBind(1, '+p1_weapprev', '-p1_weapprev');
463 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := g_Console_FindBind(1, '+p1_activate', '-p1_activate');
464 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := g_Console_FindBind(1, '+p1_strafe', '-p1_strafe');
465 // second set
466 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := g_Console_FindBind(2, '+p1_moveright', '-p1_moveright');
467 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := g_Console_FindBind(2, '+p1_moveleft', '-p1_moveleft');
468 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1 := g_Console_FindBind(2, '+p1_lookup', '-p1_lookup');
469 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := g_Console_FindBind(2, '+p1_lookdown', '-p1_lookdown');
470 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := g_Console_FindBind(2, '+p1_attack', '-p1_attack');
471 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := g_Console_FindBind(2, '+p1_jump', '-p1_jump');
472 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := g_Console_FindBind(2, '+p1_weapnext', '-p1_weapnext');
473 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := g_Console_FindBind(2, '+p1_weapprev', '-p1_weapprev');
474 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := g_Console_FindBind(2, '+p1_activate', '-p1_activate');
475 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := g_Console_FindBind(2, '+p1_strafe', '-p1_strafe');
476 end;
478 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
479 with menu do
480 begin
481 for i := WP_FIRST to WP_LAST do
482 begin
483 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0 := g_Console_FindBind(1, 'p1_weapon ' + IntToStr(i + 1));
484 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1 := g_Console_FindBind(2, 'p1_weapon ' + IntToStr(i + 1));
485 end;
486 end;
488 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
489 with menu do
490 begin
491 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0 := g_Console_FindBind(1, '+p2_moveright', '-p2_moveright');
492 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0 := g_Console_FindBind(1, '+p2_moveleft', '-p2_moveleft');
493 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0 := g_Console_FindBind(1, '+p2_lookup', '-p2_lookup');
494 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := g_Console_FindBind(1, '+p2_lookdown', '-p2_lookdown');
495 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := g_Console_FindBind(1, '+p2_attack', '-p2_attack');
496 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := g_Console_FindBind(1, '+p2_jump', '-p2_jump');
497 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := g_Console_FindBind(1, '+p2_weapnext', '-p2_weapnext');
498 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := g_Console_FindBind(1, '+p2_weapprev', '-p2_weapprev');
499 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := g_Console_FindBind(1, '+p2_activate', '-p2_activate');
500 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := g_Console_FindBind(1, '+p2_strafe', '-p2_strafe');
501 // second set
502 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := g_Console_FindBind(2, '+p2_moveright', '-p2_moveright');
503 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := g_Console_FindBind(2, '+p2_moveleft', '-p2_moveleft');
504 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1 := g_Console_FindBind(2, '+p2_lookup', '-p2_lookup');
505 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := g_Console_FindBind(2, '+p2_lookdown', '-p2_lookdown');
506 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := g_Console_FindBind(2, '+p2_attack', '-p2_attack');
507 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := g_Console_FindBind(2, '+p2_jump', '-p2_jump');
508 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := g_Console_FindBind(2, '+p2_weapnext', '-p2_weapnext');
509 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := g_Console_FindBind(2, '+p2_weapprev', '-p2_weapprev');
510 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := g_Console_FindBind(2, '+p2_activate', '-p2_activate');
511 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := g_Console_FindBind(2, '+p2_strafe', '-p2_strafe');
512 end;
514 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
515 with menu do
516 begin
517 for i := WP_FIRST to WP_LAST do
518 begin
519 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0 := g_Console_FindBind(1, 'p2_weapon ' + IntToStr(i + 1));
520 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1 := g_Console_FindBind(2, 'p2_weapon ' + IntToStr(i + 1));
521 end;
522 end;
524 if e_HasJoysticks then
525 begin
526 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
527 with menu do
528 begin
529 for i := 0 to e_MaxJoys - 1 do
530 if e_JoystickAvailable[i] then
531 TGUIScroll(menu.GetControl('scDeadzone' + IntToStr(i))).Value := e_JoystickDeadzones[i] div (32767 div 20)
532 end
533 end;
535 if g_touch_enabled then
536 begin
537 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
538 with TGUISwitch(menu.GetControl('swTouchAlt')) do
539 if g_touch_alt then ItemIndex := 1 else ItemIndex := 0;
540 TGUIScroll(menu.GetControl('scTouchSize')).Value := Round((g_touch_size - 0.5) * 10);
541 with TGUISwitch(menu.GetControl('swTouchFire')) do
542 if g_touch_fire then ItemIndex := 1 else ItemIndex := 0;
543 TGUIScroll(menu.GetControl('scTouchOffset')).Value := Round(g_touch_offset / 5);
544 end;
546 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
547 with menu do
548 begin
549 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_SCREENSHOT])).Key := g_Console_FindBind(1, 'screenshot');
550 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STAT])).Key := g_Console_FindBind(1, '+p1_scores', '-p1_scores');
551 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_CHAT])).Key := g_Console_FindBind(1, 'togglechat');
552 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_TEAMCHAT])).Key := g_Console_FindBind(1, 'toggleteamchat');
553 end;
555 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
557 {$IFDEF ENABLE_GFX}
558 TGUIScroll(menu.GetControl('scParticlesCount')).Value := g_GFX_GetMax() div 1000;
559 {$ENDIF}
560 {$IFDEF ENABLE_SHELLS}
561 TGUIScroll(menu.GetControl('scShellsMax')).Value := g_Shells_GetMax() div 30;
562 {$ENDIF}
563 {$IFDEF ENABLE_GIBS}
564 TGUIScroll(menu.GetControl('scGibsMax')).Value := g_Gibs_GetMax() div 25;
565 {$ENDIF}
566 {$IFDEF ENABLE_CORPSES}
567 TGUIScroll(menu.GetControl('scCorpsesMax')).Value := g_Corpses_GetMax() div 5;
568 {$ENDIF}
569 TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex := gBloodCount;
571 with TGUISwitch(menu.GetControl('swScreenFlash')) do
572 ItemIndex := gFlash;
574 with TGUISwitch(menu.GetControl('swBloodType')) do
575 if gAdvBlood then ItemIndex := 1 else ItemIndex := 0;
577 with TGUISwitch(menu.GetControl('swCorpseType')) do
578 if gAdvCorpses then ItemIndex := 1 else ItemIndex := 0;
580 with TGUISwitch(menu.GetControl('swGibsType')) do
581 if gAdvGibs then ItemIndex := 1 else ItemIndex := 0;
583 {$IFDEF ENABLE_GIBS}
584 with TGUISwitch(menu.GetControl('swGibsCount')) do
585 begin
586 case gGibsCount of
587 0: ItemIndex := 0;
588 8: ItemIndex := 1;
589 16: ItemIndex := 2;
590 32: ItemIndex := 3;
591 else ItemIndex := 4;
592 end;
593 end;
594 {$ENDIF}
596 with TGUISwitch(menu.GetControl('swBackGround')) do
597 if gDrawBackGround then ItemIndex := 0 else ItemIndex := 1;
599 with TGUISwitch(menu.GetControl('swMessages')) do
600 if gShowMessages then ItemIndex := 0 else ItemIndex := 1;
602 with TGUISwitch(menu.GetControl('swRevertPlayers')) do
603 if gRevertPlayers then ItemIndex := 0 else ItemIndex := 1;
605 with TGUISwitch(menu.GetControl('swChatBubble')) do
606 ItemIndex := gChatBubble;
608 with TGUISwitch(menu.GetControl('swPlayerIndicator')) do
609 ItemIndex := gPlayerIndicator;
611 with TGUISwitch(menu.GetControl('swPlayerIndicatorStyle')) do
612 ItemIndex := gPlayerIndicatorStyle;
614 TempScale := Round(g_dbg_scale - 1);
615 TGUIScroll(menu.GetControl('scScaleFactor')).Value := TempScale;
617 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
619 TGUIListBox(menu.GetControl('lsP1Model')).SelectItem(gPlayer1Settings.Model);
620 TGUIEdit(menu.GetControl('edP1Name')).Text := gPlayer1Settings.Name;
622 TGUISwitch(menu.GetControl('swP1Team')).ItemIndex :=
623 IfThen(gPlayer1Settings.Team = TEAM_BLUE, 1, 0);
625 TGUIScroll(menu.GetControl('scP1Red')).Value := Round(gPlayer1Settings.Color.R/16);
626 TGUIScroll(menu.GetControl('scP1Green')).Value := Round(gPlayer1Settings.Color.G/16);
627 TGUIScroll(menu.GetControl('scP1Blue')).Value := Round(gPlayer1Settings.Color.B/16);
629 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
631 TGUIListBox(menu.GetControl('lsP2Model')).SelectItem(gPlayer2Settings.Model);
632 TGUIEdit(menu.GetControl('edP2Name')).Text := gPlayer2Settings.Name;
634 TGUISwitch(menu.GetControl('swP2Team')).ItemIndex :=
635 IfThen(gPlayer2Settings.Team = TEAM_BLUE, 1, 0);
637 TGUIScroll(menu.GetControl('scP2Red')).Value := Round(gPlayer2Settings.Color.R/16);
638 TGUIScroll(menu.GetControl('scP2Green')).Value := Round(gPlayer2Settings.Color.G/16);
639 TGUIScroll(menu.GetControl('scP2Blue')).Value := Round(gPlayer2Settings.Color.B/16);
641 ProcSelectModel(nil);
642 end;
644 procedure ProcSwitchMonstersCustom(Sender: TGUIControl);
645 begin
646 // don't turn off monsters in DM
648 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
649 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
650 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
651 else
652 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
655 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
656 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
657 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
658 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
660 end;
662 procedure ProcSwitchMonstersNet(Sender: TGUIControl);
663 begin
664 // don't turn off monsters in DM
666 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
667 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
668 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
669 else
670 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
673 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
674 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
675 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
676 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
678 end;
680 function LatchGameOptions(const MenuName: string): Byte;
681 var
682 Map: string;
683 begin
684 Result := GM_NONE;
686 with TGUIMenu(g_ActiveWindow.GetControl(MenuName)) do
687 begin
688 Map := TGUILabel(GetControl('lbMap')).Text;
689 if Map = '' then
690 Exit;
691 if not isWadPath(Map) then
692 Exit;
694 Result := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
695 gsGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
696 gsTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
697 gsGoalLimit := StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
698 gsMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
699 gsItemRespawnTime := StrToIntDef(TGUIEdit(GetControl('edItemRespawnTime')).Text, 0);
700 gsPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
701 gsMap := Map;
703 gsGameFlags := 0;
704 if TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0 then
705 gsGameFlags := gsGameFlags or GAME_OPTION_TEAMDAMAGE;
706 if TGUISwitch(GetControl('swDeathmatchKeys')).ItemIndex = 0 then
707 gsGameFlags := gsGameFlags or GAME_OPTION_DMKEYS;
708 if TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0 then
709 gsGameFlags := gsGameFlags or GAME_OPTION_ALLOWEXIT;
710 if TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0 then
711 gsGameFlags := gsGameFlags or GAME_OPTION_WEAPONSTAY;
712 if TGUISwitch(GetControl('swMonsters')).ItemIndex = 0 then
713 gsGameFlags := gsGameFlags or GAME_OPTION_MONSTERS;
715 case TGUISwitch(GetControl('swTeamHit')).ItemIndex of
716 1: gsGameFlags := gsGameFlags or GAME_OPTION_TEAMHITTRACE;
717 2: gsGameFlags := gsGameFlags or GAME_OPTION_TEAMHITPROJECTILE;
718 0: gsGameFlags := gsGameFlags or GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE;
719 end;
721 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
722 1: gsGameFlags := gsGameFlags or GAME_OPTION_BOTVSMONSTER;
723 2: gsGameFlags := gsGameFlags or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
724 else gsGameFlags := gsGameFlags or GAME_OPTION_BOTVSPLAYER;
725 end;
727 // TODO: get this crap out of here
728 gGameSettings.ItemRespawnTime := gsItemRespawnTime;
729 gGameSettings.WarmupTime := gsWarmupTime;
730 gGameSettings.SpawnInvul := gsSpawnInvul;
731 end;
732 end;
734 procedure ProcStartCustomGame();
735 var
736 GameMode: Byte;
737 begin
738 GameMode := LatchGameOptions('mCustomGameMenu');
739 if GameMode = GM_NONE then Exit;
741 g_Console_WriteGameConfig;
742 g_Game_StartCustom(gsMap, GameMode, gsTimeLimit, gsGoalLimit,
743 gsMaxLives, gsGameFlags, gsPlayers);
744 end;
747 procedure ProcStartNetGame();
748 var
749 GameMode: Byte;
750 begin
751 GameMode := LatchGameOptions('mNetServerMenu');
752 if GameMode = GM_NONE then Exit;
754 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
755 begin
756 NetPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
757 NetServerName := TGUIEdit(GetControl('edSrvName')).Text;
758 NetMaxClients := Max(1, StrToIntDef(TGUIEdit(GetControl('edMaxPlayers')).Text, 1));
759 NetMaxClients := Min(NET_MAXCLIENTS, NetMaxClients);
760 NetPassword := TGUIEdit(GetControl('edSrvPassword')).Text;
761 NetUseMaster := TGUISwitch(GetControl('swUseMaster')).ItemIndex = 0;
762 end;
764 g_Console_WriteGameConfig;
765 g_Game_StartServer(gsMap, GameMode, gsTimeLimit, gsGoalLimit, gsMaxLives,
766 gsGameFlags, gsPlayers, 0, NetPort);
767 end;
769 procedure ProcConnectNetGame();
770 var
771 PW: String;
772 begin
773 with TGUIMenu(g_ActiveWindow.GetControl('mNetClientMenu')) do
774 begin
775 NetClientIP := TGUIEdit(GetControl('edIP')).Text;
776 NetClientPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
777 PW := TGUIEdit(GetControl('edPW')).Text;
778 end;
780 g_Console_WriteGameConfig;
781 g_Game_StartClient(NetClientIP, NetClientPort, PW);
782 end;
784 procedure ProcEnterPassword();
785 var
786 PW: string;
787 begin
788 with TGUIMenu(g_ActiveWindow.GetControl('mClientPasswordMenu')) do
789 begin
790 NetClientIP := PromptIP;
791 NetClientPort := PromptPort;
792 PW := TGUIEdit(GetControl('edPW')).Text;
793 end;
795 g_Console_WriteGameConfig;
796 g_Game_StartClient(NetClientIP, NetClientPort, PW);
797 end;
799 procedure ProcServerlist();
800 begin
801 if not NetInitDone then
802 begin
803 if (not g_Net_Init()) then
804 begin
805 g_Console_Add('NET: ERROR: Failed to init ENet!');
806 Exit;
807 end
808 else
809 NetInitDone := True;
810 end;
812 g_Net_Slist_Set(NetMasterList);
814 gState := STATE_SLIST;
815 g_ActiveWindow := nil;
817 slWaitStr := _lc[I_NET_SLIST_WAIT];
819 {$IFDEF ENABLE_RENDER}
820 r_Render_Draw;
821 {$ENDIF}
822 {$IFDEF ENABLE_SYSTEM}
823 sys_Repaint;
824 {$ENDIF}
826 slReturnPressed := True;
827 if g_Net_Slist_Fetch(slCurrent) then
828 begin
829 if slCurrent = nil then
830 slWaitStr := _lc[I_NET_SLIST_NOSERVERS];
831 end
832 else
833 slWaitStr := _lc[I_NET_SLIST_ERROR];
834 g_Serverlist_GenerateTable(slCurrent, slTable);
835 end;
837 procedure ProcStartCampaign();
838 var
839 WAD: String;
840 TwoPlayers: Boolean;
841 n: Byte;
842 begin
843 with TGUIMenu(g_ActiveWindow.GetControl('mCampaignMenu')) do
844 begin
845 WAD := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
846 TwoPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex = 1;
847 end;
848 WAD := e_FindWadRel(MegawadDirs, WAD);
850 if TwoPlayers then
851 n := 2
852 else
853 n := 1;
854 g_Game_StartSingle(WAD + ':\MAP01', TwoPlayers, n);
855 end;
857 procedure ProcSelectMap(Sender: TGUIControl);
858 var
859 win: TGUIWindow;
860 a: TMapInfo;
861 wad, map, res: String;
862 begin
863 win := g_GUI_GetWindow('SelectMapMenu');
864 with TGUIMenu(win.GetControl('mSelectMapMenu')) do
865 begin
866 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
867 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
869 if (wad = '') or (map = '') then
870 begin // Ýòî íå êàðòà
871 TGUILabel(GetControl('lbMapName')).Text := '';
872 TGUILabel(GetControl('lbMapAuthor')).Text := '';
873 TGUILabel(GetControl('lbMapSize')).Text := '';
874 TGUIMemo(GetControl('meMapDescription')).SetText('');
875 TGUIMapPreview(win.GetControl('mpMapPreview')).ClearMap();
876 TGUILabel(win.GetControl('lbMapScale')).Text := '';
877 end
878 else // Ýòî êàðòà
879 begin
880 res := wad+':\'+map;
882 a := g_Map_GetMapInfo(res);
884 TGUILabel(GetControl('lbMapName')).Text := a.Name;
885 TGUILabel(GetControl('lbMapAuthor')).Text := a.Author;
886 TGUILabel(GetControl('lbMapSize')).Text := Format('%dx%d', [a.Width, a.Height]);
887 TGUIMemo(GetControl('meMapDescription')).SetText(a.Description);
888 TGUIMapPreview(win.GetControl('mpMapPreview')).SetMap(res);
889 TGUILabel(win.GetControl('lbMapScale')).Text :=
890 TGUIMapPreview(win.GetControl('mpMapPreview')).GetScaleStr;
891 end;
892 end;
893 end;
895 procedure ProcSelectWAD(Sender: TGUIControl);
896 var
897 wad: String;
898 list: SSArray;
899 begin
900 with TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu')) do
901 begin
902 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
904 with TGUIListBox(GetControl('lsMapRes')) do
905 begin
906 Clear();
908 if wad <> '' then
909 begin
910 list := g_Map_GetMapsList(wad);
912 if list <> nil then
913 begin
914 Items := list;
915 ItemIndex := 0;
916 end
917 end;
918 end;
919 end;
921 ProcSelectMap(nil);
922 end;
924 procedure ProcSelectCampaignWAD(Sender: TGUIControl);
925 var
926 win: TGUIWindow;
927 a: TMegaWADInfo;
928 wad, fn: String;
929 begin
930 win := g_GUI_GetWindow('CampaignMenu');
931 with TGUIMenu(win.GetControl('mCampaignMenu')) do
932 begin
933 wad := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
935 if wad = '' then
936 begin
937 TGUILabel(GetControl('lbWADName')).Text := '';
938 TGUILabel(GetControl('lbWADAuthor')).Text := '';
939 TGUIMemo(GetControl('meWADDescription')).SetText('');
940 end;
942 a := g_Game_GetMegaWADInfo(wad);
944 TGUILabel(GetControl('lbWADName')).Text := a.Name;
945 TGUILabel(GetControl('lbWADAuthor')).Text := a.Author;
946 TGUIMemo(GetControl('meWADDescription')).SetText(a.Description);
948 TGUIImage(win.GetControl('mpWADImage')).ClearImage();
950 if a.pic <> '' then
951 begin
952 fn := g_ExtractWadName(a.pic);
953 if fn = '' then
954 TGUIImage(win.GetControl('mpWADImage')).SetImage(wad+a.pic)
955 else
956 TGUIImage(win.GetControl('mpWADImage')).SetImage(a.pic);
957 end;
958 end;
959 end;
961 procedure ProcChangeColor(Sender: TGUIControl);
962 var
963 window: TGUIWindow;
964 begin
965 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
966 with TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')) do
967 TGUIModelView(window.GetControl('mvP1Model')).SetColor(
968 Min(TGUIScroll(GetControl('scP1Red')).Value*16, 255),
969 Min(TGUIScroll(GetControl('scP1Green')).Value*16, 255),
970 Min(TGUIScroll(GetControl('scP1Blue')).Value*16, 255));
972 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
973 with TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')) do
974 TGUIModelView(window.GetControl('mvP2Model')).SetColor(
975 Min(TGUIScroll(GetControl('scP2Red')).Value*16, 255),
976 Min(TGUIScroll(GetControl('scP2Green')).Value*16, 255),
977 Min(TGUIScroll(GetControl('scP2Blue')).Value*16, 255));
978 end;
980 procedure ProcSelectModel(Sender: TGUIControl);
981 var
982 a: string;
983 window: TGUIWindow;
984 begin
985 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
986 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')).GetControl('lsP1Model')).SelectedItem;
987 if a <> '' then TGUIModelView(window.GetControl('mvP1Model')).SetModel(a);
989 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
990 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')).GetControl('lsP2Model')).SelectedItem;
991 if a <> '' then TGUIModelView(window.GetControl('mvP2Model')).SetModel(a);
993 ProcChangeColor(nil);
994 end;
996 procedure MenuLoadData();
997 begin
998 e_WriteLog('Loading menu data...', TMsgType.Notify);
1000 g_Sound_CreateWADEx('MENU_SELECT', GameWAD+':SOUNDS\MENUSELECT');
1001 g_Sound_CreateWADEx('MENU_OPEN', GameWAD+':SOUNDS\MENUOPEN');
1002 g_Sound_CreateWADEx('MENU_CLOSE', GameWAD+':SOUNDS\MENUCLOSE');
1003 g_Sound_CreateWADEx('MENU_CHANGE', GameWAD+':SOUNDS\MENUCHANGE');
1004 g_Sound_CreateWADEx('SCROLL_ADD', GameWAD+':SOUNDS\SCROLLADD');
1005 g_Sound_CreateWADEx('SCROLL_SUB', GameWAD+':SOUNDS\SCROLLSUB');
1006 g_Sound_CreateWADEx('SOUND_PLAYER_FALL', GameWAD+':SOUNDS\FALL');
1007 end;
1009 procedure MenuFreeData();
1010 begin
1011 g_Sound_Delete('MENU_SELECT');
1012 g_Sound_Delete('MENU_OPEN');
1013 g_Sound_Delete('MENU_CLOSE');
1014 g_Sound_Delete('MENU_CHANGE');
1015 g_Sound_Delete('SCROLL_ADD');
1016 g_Sound_Delete('SCROLL_SUB');
1017 g_Sound_Delete('SOUND_PLAYER_FALL');
1018 end;
1020 procedure ProcAuthorsMenu();
1021 begin
1022 gMusic.SetByName('MUSIC_INTERMUS');
1023 gMusic.Play();
1024 end;
1026 procedure ProcExitMenuKeyDown (yes: Boolean);
1027 var
1028 s: ShortString;
1029 snd: TPlayableSound;
1030 res: Boolean;
1031 begin
1032 if yes then
1033 begin
1034 g_Game_StopAllSounds(True);
1035 case (Random(18)) of
1036 0: s := 'SOUND_MONSTER_PAIN';
1037 1: s := 'SOUND_MONSTER_DIE_3';
1038 2: s := 'SOUND_MONSTER_SLOP';
1039 3: s := 'SOUND_MONSTER_DEMON_DIE';
1040 4: s := 'SOUND_MONSTER_IMP_DIE_2';
1041 5: s := 'SOUND_MONSTER_MAN_DIE';
1042 6: s := 'SOUND_MONSTER_BSP_DIE';
1043 7: s := 'SOUND_MONSTER_VILE_DIE';
1044 8: s := 'SOUND_MONSTER_SKEL_DIE';
1045 9: s := 'SOUND_MONSTER_MANCUB_ALERT';
1046 10: s := 'SOUND_MONSTER_PAIN_PAIN';
1047 11: s := 'SOUND_MONSTER_BARON_DIE';
1048 12: s := 'SOUND_MONSTER_CACO_DIE';
1049 13: s := 'SOUND_MONSTER_CYBER_DIE';
1050 14: s := 'SOUND_MONSTER_KNIGHT_ALERT';
1051 15: s := 'SOUND_MONSTER_SPIDER_ALERT';
1052 else s := 'SOUND_PLAYER_FALL';
1053 end;
1054 snd := TPlayableSound.Create();
1055 res := snd.SetByName(s);
1056 if not res then res := snd.SetByName('SOUND_PLAYER_FALL');
1057 if res then
1058 begin
1059 snd.Play(True);
1060 while snd.IsPlaying() do begin end;
1061 end;
1062 g_Game_Quit();
1063 exit;
1064 end;
1065 g_GUI_HideWindow();
1066 end;
1068 procedure ProcLoadMenu();
1069 var
1070 a: Integer;
1071 valid: Boolean;
1072 begin
1073 for a := 1 to 8 do
1074 begin
1075 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Text := g_GetSaveName(a, valid);
1076 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := not valid;
1077 //TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a)).Enabled := valid;
1078 end;
1079 end;
1081 procedure ProcSaveMenu();
1082 var
1083 a: Integer;
1084 valid: Boolean;
1085 name: AnsiString;
1086 begin
1087 for a := 1 to 8 do
1088 begin
1089 name := g_GetSaveName(a, valid);
1090 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Text := name;
1091 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := (name <> '') and (not valid);
1092 end;
1093 end;
1095 procedure ProcSaveGame(Sender: TGUIControl);
1096 var
1097 a: Integer;
1098 begin
1099 if g_Game_IsNet then Exit;
1100 if g_Game_IsTestMap then Exit;
1101 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1102 g_Game_PauseAllSounds(True);
1103 g_SaveGame(a, TGUIEdit(Sender).Text);
1105 g_ActiveWindow := nil;
1106 g_Game_Pause(False);
1107 end;
1109 procedure ProcLoadGame(Sender: TGUIControl);
1110 var
1111 a: Integer;
1112 begin
1113 if g_Game_IsNet then Exit;
1114 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1115 if g_LoadGame(a) then
1116 begin
1117 g_Game_PauseAllSounds(False)
1118 end
1119 else // Íå çàãðóçèëîñü - âîçâðàò â ìåíþ
1120 begin
1121 g_Console_Add(_lc[I_MSG_BAD_SAVE_VERSION], true);
1122 g_GUI_GetWindow('LoadMenu').SetActive(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu'));
1123 //g_ActiveWindow := nil;
1124 end;
1125 end;
1127 procedure ProcSinglePlayer (n: Integer);
1128 var wad, map: AnsiString;
1129 begin
1130 assert(n >= 1);
1131 wad := g_ExtractWadName(gDefaultMegawadStart);
1132 map := g_ExtractFilePathName(gDefaultMegawadStart);
1133 if e_FindResource(AllMapDirs, wad) then
1134 begin
1135 wad := ExpandFileName(wad);
1136 g_Game_StartSingle(wad + ':\' + map, n > 1, n)
1137 end
1138 end;
1140 procedure ProcSingle1Player;
1141 begin
1142 ProcSinglePlayer(1)
1143 end;
1145 procedure ProcSingle2Players;
1146 begin
1147 ProcSinglePlayer(2)
1148 end;
1150 procedure ProcSelectMapMenu();
1151 var
1152 menu: TGUIMenu;
1153 wad_lb: TGUIFileListBox;
1154 map_lb: TGUIListBox;
1155 map: String;
1156 begin
1157 menu := TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1158 wad_lb := TGUIFileListBox(menu.GetControl('lsMapWAD'));
1159 map_lb := TGUIListBox(menu.GetControl('lsMapRes'));
1161 if wad_lb.SelectedItem() <> '' then
1162 map := map_lb.SelectedItem()
1163 else
1164 map := '';
1166 wad_lb.UpdateFileList();
1167 map_lb.Clear();
1169 if wad_lb.SelectedItem() <> '' then
1170 begin
1171 ProcSelectWAD(nil);
1172 map_lb.SelectItem(map);
1174 if map_lb.SelectedItem() <> '' then
1175 ProcSelectMap(nil);
1176 end;
1178 g_GUI_ShowWindow('SelectMapMenu');
1179 end;
1181 procedure ProcSelectCampaignMenu();
1182 var
1183 menu: TGUIMenu;
1184 wad_lb: TGUIFileListBox;
1185 begin
1186 menu := TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1187 wad_lb := TGUIFileListBox(menu.GetControl('lsWAD'));
1189 wad_lb.UpdateFileList();
1191 if wad_lb.SelectedItem() <> '' then
1192 ProcSelectCampaignWAD(nil);
1193 end;
1195 procedure ProcSetMap();
1196 var
1197 wad, map, res: String;
1198 begin
1199 with TGUIMenu(g_ActiveWindow.GetControl('mSelectMapMenu')) do
1200 begin
1201 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
1202 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1203 end;
1205 if (wad = '') or (map = '') then
1206 Exit;
1208 wad := e_FindWadRel(MapDirs, WAD);
1210 res := wad+':\'+map;
1212 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
1213 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res;
1214 end;
1216 procedure ProcChangeSoundSettings(Sender: TGUIControl);
1217 var
1218 menu: TGUIMenu;
1219 begin
1220 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1222 g_Sound_SetupAllVolumes(
1223 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
1224 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
1225 );
1226 end;
1228 procedure ProcChangeGameSettings(Sender: TGUIControl);
1229 var
1230 menu: TGUIMenu;
1231 begin
1232 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
1233 if TGUIScroll(menu.GetControl('scScaleFactor')).Value <> TempScale then
1234 begin
1235 TempScale := TGUIScroll(menu.GetControl('scScaleFactor')).Value;
1236 g_dbg_scale := TempScale + 1;
1237 end;
1238 end;
1240 procedure ProcChangeTouchSettings(Sender: TGUIControl);
1241 var
1242 menu: TGUIMenu;
1243 begin
1244 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
1245 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
1246 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
1247 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
1248 end;
1250 procedure ProcOptionsPlayersMIMenu();
1251 var
1252 s, a: string;
1253 i: Integer;
1254 begin
1255 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1257 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+s+'Menu')).GetControl('ls'+s+'Model')).SelectedItem;
1259 if a = '' then Exit;
1261 i := g_PlayerModel_GetIndex(a);
1262 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1263 begin
1264 TGUILabel(GetControl('lbName')).Text := PlayerModelsArray[i].Name;
1265 TGUILabel(GetControl('lbAuthor')).Text := PlayerModelsArray[i].Author;
1266 TGUIMemo(GetControl('meComment')).SetText(PlayerModelsArray[i].Description);
1268 if PlayerModelsArray[i].HaveWeapon then
1269 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1270 else
1271 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1272 end;
1274 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1275 end;
1277 procedure ProcOptionsPlayersAnim();
1278 var
1279 s: String;
1280 begin
1281 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1282 s := 'P1'
1283 else
1284 s := 'P2';
1286 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1287 begin
1288 NextAnim();
1289 Model.AnimState.Loop := True;
1290 end;
1291 end;
1293 procedure ProcOptionsPlayersWeap();
1294 var
1295 s: String;
1296 begin
1297 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1298 s := 'P1'
1299 else
1300 s := 'P2';
1302 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1303 NextWeapon();
1304 end;
1306 procedure ProcOptionsPlayersRot();
1307 var
1308 s: string;
1309 begin
1310 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1311 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1312 begin
1313 if Direction = TDirection.D_LEFT then Direction := TDirection.D_RIGHT else Direction := TDirection.D_LEFT;
1314 end;
1315 end;
1317 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1318 begin
1319 if yes then
1320 begin
1321 g_Options_SetDefault();
1322 ReadOptions();
1323 end;
1324 g_GUI_HideWindow();
1325 end;
1327 procedure ProcSavedMenuKeyDown (yes: Boolean);
1328 begin
1329 if yes then ReadOptions();
1330 g_GUI_HideWindow();
1331 end;
1333 procedure ProcAuthorsClose();
1334 begin
1335 gMusic.SetByName('MUSIC_MENU');
1336 gMusic.Play();
1337 gState := STATE_MENU;
1338 end;
1340 procedure ProcGMClose();
1341 begin
1342 g_Game_InGameMenu(False);
1343 end;
1345 procedure ProcGMShow();
1346 var
1347 Enabled: Boolean;
1348 begin
1349 Enabled := True;
1350 if (gGameSettings.GameType = GT_SINGLE) and
1351 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1352 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1353 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1354 if not gGameOn then
1355 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1356 if g_Game_IsTestMap then
1357 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1358 TGUIMainMenu(g_ActiveWindow.GetControl(
1359 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1360 end;
1362 procedure ProcChangePlayers();
1363 var
1364 TeamGame, Spectator, AddTwo: Boolean;
1365 P1Team{, P2Team}: Byte;
1366 bP2: TGUITextButton;
1367 begin
1368 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1369 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1370 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1371 P1Team := TEAM_NONE;
1372 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1373 // TODO
1374 //P2Team := TEAM_NONE;
1375 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1377 TGUIMainMenu(g_ActiveWindow.GetControl(
1378 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1379 TGUIMainMenu(g_ActiveWindow.GetControl(
1380 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1381 TGUIMainMenu(g_ActiveWindow.GetControl(
1382 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1384 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1385 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1386 bP2.Enabled := AddTwo and not Spectator;
1387 if bP2.Enabled then
1388 bP2.Color := MAINMENU_ITEMS_COLOR
1389 else
1390 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1391 if gPlayer2 = nil then
1392 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1393 else
1394 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1396 TGUIMainMenu(g_ActiveWindow.GetControl(
1397 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1398 end;
1400 procedure ProcJoinRed();
1401 begin
1402 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1403 Exit;
1404 if g_Game_IsServer then
1405 begin
1406 if gPlayer1 = nil then
1407 g_Game_AddPlayer(TEAM_RED)
1408 else
1409 begin
1410 if gPlayer1.Team <> TEAM_RED then
1411 begin
1412 gPlayer1.SwitchTeam;
1413 gPlayer1Settings.Team := gPlayer1.Team;
1414 end;
1416 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1417 end;
1418 end
1419 else
1420 begin
1421 gPlayer1Settings.Team := TEAM_RED;
1422 MC_SEND_PlayerSettings;
1423 if gPlayer1 = nil then
1424 g_Game_AddPlayer(TEAM_RED);
1425 end;
1426 g_ActiveWindow := nil;
1427 g_Game_Pause(False);
1428 end;
1430 procedure ProcJoinBlue();
1431 begin
1432 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1433 Exit;
1434 if g_Game_IsServer then
1435 begin
1436 if gPlayer1 = nil then
1437 g_Game_AddPlayer(TEAM_BLUE)
1438 else
1439 begin
1440 if gPlayer1.Team <> TEAM_BLUE then
1441 begin
1442 gPlayer1.SwitchTeam;
1443 gPlayer1Settings.Team := gPlayer1.Team;
1444 end;
1446 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1447 end;
1448 end
1449 else
1450 begin
1451 gPlayer1Settings.Team := TEAM_BLUE;
1452 MC_SEND_PlayerSettings;
1453 if gPlayer1 = nil then
1454 g_Game_AddPlayer(TEAM_BLUE);
1455 end;
1456 g_ActiveWindow := nil;
1457 g_Game_Pause(False);
1458 end;
1460 procedure ProcJoinGame();
1461 begin
1462 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1463 Exit;
1464 if gPlayer1 = nil then
1465 g_Game_AddPlayer();
1466 g_ActiveWindow := nil;
1467 g_Game_Pause(False);
1468 end;
1470 procedure ProcSwitchP2();
1471 begin
1472 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1473 Exit;
1474 if gPlayer1 = nil then
1475 Exit;
1476 if gPlayer2 = nil then
1477 g_Game_AddPlayer()
1478 else
1479 g_Game_RemovePlayer();
1480 g_ActiveWindow := nil;
1481 g_Game_Pause(False);
1482 end;
1484 procedure ProcSpectate();
1485 begin
1486 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1487 Exit;
1488 g_Game_Spectate();
1489 g_ActiveWindow := nil;
1490 g_Game_Pause(False);
1491 end;
1493 procedure ProcRestartMenuKeyDown (yes: Boolean);
1494 begin
1495 if yes then g_Game_Restart() else g_GUI_HideWindow;
1496 end;
1498 procedure ProcEndMenuKeyDown (yes: Boolean);
1499 begin
1500 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1501 end;
1503 procedure ProcSetRussianLanguage;
1504 begin
1505 if gLanguage <> LANGUAGE_RUSSIAN then
1506 begin
1507 gLanguage := LANGUAGE_RUSSIAN;
1508 gLanguageChange := True;
1509 gAskLanguage := False;
1510 ProcApplyOptions();
1511 end;
1512 end;
1514 procedure ProcSetEnglishLanguage;
1515 begin
1516 if gLanguage <> LANGUAGE_ENGLISH then
1517 begin
1518 gLanguage := LANGUAGE_ENGLISH;
1519 gLanguageChange := True;
1520 gAskLanguage := False;
1521 ProcApplyOptions();
1522 end;
1523 end;
1525 procedure ReadGameSettings();
1526 var
1527 menu: TGUIMenu;
1528 begin
1529 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1531 with gGameSettings do
1532 begin
1533 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1534 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1535 ItemIndex := 0
1536 else
1537 ItemIndex := 1;
1538 with TGUISwitch(menu.GetControl('swTeamHit')) do
1539 if (Options and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
1540 ItemIndex := 0
1541 else if LongBool(Options and GAME_OPTION_TEAMHITTRACE) then
1542 ItemIndex := 1
1543 else if LongBool(Options and GAME_OPTION_TEAMHITPROJECTILE) then
1544 ItemIndex := 2
1545 else
1546 ItemIndex := 3;
1547 with TGUISwitch(menu.GetControl('swDeathmatchKeys')) do
1548 if LongBool(Options and GAME_OPTION_DMKEYS) then
1549 ItemIndex := 0
1550 else
1551 ItemIndex := 1;
1553 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1554 TGUIEdit(menu.GetControl('edGoalLimit')).Text := IntToStr(GoalLimit);
1555 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1557 with TGUISwitch(menu.GetControl('swBotsVS')) do
1558 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1559 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1560 ItemIndex := 2
1561 else
1562 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1563 ItemIndex := 1
1564 else
1565 ItemIndex := 0;
1567 if GameType in [GT_CUSTOM, GT_SERVER] then
1568 begin
1569 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1570 TGUISwitch(menu.GetControl('swTeamHit')).Enabled := True;
1571 if (GameMode in [GM_DM, GM_TDM, GM_CTF]) then
1572 begin
1573 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := True;
1574 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_ITEMSTEXT_COLOR;
1575 end
1576 else
1577 begin
1578 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1579 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1580 end;
1581 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1582 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1583 TGUIEdit(menu.GetControl('edGoalLimit')).Enabled := True;
1584 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_ITEMSTEXT_COLOR;
1585 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1586 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1587 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1588 end
1589 else
1590 begin
1591 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1592 TGUISwitch(menu.GetControl('swTeamHit')).Enabled := True;
1593 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1594 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1595 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1596 begin
1597 Enabled := False;
1598 Text := '';
1599 end;
1600 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1601 with TGUIEdit(menu.GetControl('edGoalLimit')) do
1602 begin
1603 Enabled := False;
1604 Text := '';
1605 end;
1606 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1607 with TGUIEdit(menu.GetControl('edMaxLives')) do
1608 begin
1609 Enabled := False;
1610 Text := '';
1611 end;
1612 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1613 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1614 end;
1615 end;
1616 end;
1618 procedure ProcApplyGameSet();
1619 var
1620 menu: TGUIMenu;
1621 a, b, n: Integer;
1622 stat: TPlayerStatArray;
1623 begin
1624 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1626 if not g_Game_IsServer then Exit;
1628 with gGameSettings do
1629 begin
1630 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1631 begin
1632 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1633 Options := Options or GAME_OPTION_TEAMDAMAGE
1634 else
1635 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1636 end;
1638 if TGUISwitch(menu.GetControl('swTeamHit')).Enabled then
1639 begin
1640 Options := Options and not (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE);
1641 case TGUISwitch(menu.GetControl('swTeamHit')).ItemIndex of
1642 1: Options := Options or GAME_OPTION_TEAMHITTRACE;
1643 2: Options := Options or GAME_OPTION_TEAMHITPROJECTILE;
1644 0: Options := Options or GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE;
1645 end;
1646 end;
1648 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled then
1649 begin
1650 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).ItemIndex = 0 then
1651 Options := Options or GAME_OPTION_DMKEYS
1652 else
1653 Options := Options and (not GAME_OPTION_DMKEYS);
1654 end;
1656 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1657 begin
1658 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1660 if n = 0 then
1661 TimeLimit := 0
1662 else
1663 begin
1664 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1666 TimeLimit := Max(n, b);
1667 end;
1668 end;
1670 if TGUIEdit(menu.GetControl('edGoalLimit')).Enabled then
1671 begin
1672 n := StrToIntDef(TGUIEdit(menu.GetControl('edGoalLimit')).Text, GoalLimit);
1674 if n = 0 then
1675 GoalLimit := 0
1676 else
1677 begin
1678 b := 0;
1679 if GameMode = GM_DM then
1680 begin // DM
1681 stat := g_Player_GetStats();
1682 if stat <> nil then
1683 for a := 0 to High(stat) do
1684 if stat[a].Frags > b then
1685 b := stat[a].Frags;
1686 end
1687 else // CTF
1688 b := Max(gTeamStat[TEAM_RED].Goals, gTeamStat[TEAM_BLUE].Goals);
1690 GoalLimit := Max(n, b);
1691 end;
1692 end;
1694 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1695 begin
1696 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, GoalLimit);
1697 if n < 0 then n := 0;
1698 if n > 255 then n := 255;
1699 if n = 0 then
1700 MaxLives := 0
1701 else
1702 begin
1703 b := 0;
1704 stat := g_Player_GetStats();
1705 if stat <> nil then
1706 for a := 0 to High(stat) do
1707 if stat[a].Lives > b then
1708 b := stat[a].Lives;
1710 MaxLives := Max(n, b);
1711 end;
1712 end;
1714 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1715 begin
1716 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1717 1:
1718 begin
1719 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1720 Options := Options or GAME_OPTION_BOTVSMONSTER;
1721 end;
1722 2:
1723 begin
1724 Options := Options or GAME_OPTION_BOTVSPLAYER;
1725 Options := Options or GAME_OPTION_BOTVSMONSTER;
1726 end;
1727 else
1728 begin
1729 Options := Options or GAME_OPTION_BOTVSPLAYER;
1730 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1731 end;
1732 end;
1733 end;
1735 // don't forget to latch this shit
1736 gsGameFlags := Options;
1737 gsMaxLives := MaxLives;
1738 gsGoalLimit := GoalLimit;
1739 gsTimeLimit := TimeLimit;
1740 end;
1742 if g_Game_IsNet then MH_SEND_GameSettings;
1743 end;
1745 procedure ProcVideoOptionsRes();
1746 var
1747 menu: TGUIMenu;
1748 list: SSArray;
1749 begin
1750 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1752 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1753 IntToStr(gWinSizeX) +
1754 ' x ' + IntToStr(gWinSizeY) +
1755 ', ' + IntToStr(gBPP) + ' bpp';
1757 with TGUIListBox(menu.GetControl('lsResolution')) do
1758 begin
1759 {$IFDEF ENABLE_SYSTEM}
1760 list := sys_GetDisplayModes(gBPP);
1761 {$ELSE}
1762 list := nil;
1763 {$ENDIF}
1764 if list <> nil then
1765 begin
1766 Items := list;
1767 ItemIndex := Length(list)
1768 end
1769 else
1770 begin
1771 Clear
1772 end
1773 end;
1775 with TGUISwitch(menu.GetControl('swFullScreen')) do
1776 if gFullscreen then
1777 ItemIndex := 0
1778 else
1779 ItemIndex := 1;
1781 TempResScale := Round(r_pixel_scale - 1);
1782 with TGUISwitch(menu.GetControl('swResFactor')) do
1783 ItemIndex := Min(TempResScale, gRC_Width div 640 - 1);
1784 end;
1786 procedure ProcApplyVideoOptions();
1787 var
1788 menu: TGUIMenu;
1789 Fullscreen: Boolean;
1790 SWidth, SHeight: Integer;
1791 ScaleChanged: Boolean;
1792 str: String;
1793 begin
1794 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1796 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1797 if str <> '' then
1798 SScanf(str, '%dx%d', [@SWidth, @SHeight])
1799 else
1800 begin
1801 SWidth := gWinSizeX;
1802 SHeight := gWinSizeY;
1803 TempResScale := Min(TempResScale, SWidth div 640 - 1);
1804 end;
1806 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1808 ScaleChanged := False;
1809 if TGUISwitch(menu.GetControl('swResFactor')).ItemIndex <> TempResScale then
1810 begin
1811 TempResScale := Min(TGUISwitch(menu.GetControl('swResFactor')).ItemIndex, SWidth div 640 - 1);
1812 r_pixel_scale := TempResScale + 1;
1813 ScaleChanged := True;
1814 end;
1816 if (SWidth <> gWinSizeX) or
1817 (SHeight <> gWinSizeY) or
1818 (Fullscreen <> gFullscreen) or
1819 ScaleChanged then
1820 begin
1821 gResolutionChange := True;
1822 gRC_Width := SWidth;
1823 gRC_Height := SHeight;
1824 gRC_FullScreen := Fullscreen;
1825 gRC_Maximized := gWinMaximized;
1826 end;
1828 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1829 ProcApplyOptions();
1830 end;
1832 procedure ProcSetFirstRussianLanguage;
1833 begin
1834 gLanguage := LANGUAGE_RUSSIAN;
1835 gLanguageChange := True;
1836 gAskLanguage := False;
1837 end;
1839 procedure ProcSetFirstEnglishLanguage;
1840 begin
1841 gLanguage := LANGUAGE_ENGLISH;
1842 gLanguageChange := True;
1843 gAskLanguage := False;
1844 end;
1846 procedure ProcRecallAddress();
1847 begin
1848 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1849 begin
1850 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1851 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1852 end;
1853 end;
1855 procedure CreateFirstLanguageMenu();
1856 var
1857 Menu: TGUIWindow;
1858 begin
1859 Menu := TGUIWindow.Create('FirstLanguageMenu');
1861 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, ' '))) do // space to prevent show logo
1862 begin
1863 Name := 'mmFirstLanguageMenu';
1864 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
1865 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
1866 end;
1868 Menu.DefControl := 'mmFirstLanguageMenu';
1869 Menu.MainWindow := True;
1870 g_GUI_AddWindow(Menu);
1871 end;
1873 procedure g_Menu_AskLanguage();
1874 begin
1875 CreateFirstLanguageMenu();
1876 g_GUI_ShowWindow('FirstLanguageMenu');
1877 end;
1879 procedure CreatePlayerOptionsMenu(s: String);
1880 var
1881 Menu: TGUIWindow;
1882 a: String;
1883 begin
1884 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
1885 if s = 'P1' then
1886 a := _lc[I_MENU_PLAYER_1]
1887 else
1888 a := _lc[I_MENU_PLAYER_2];
1889 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, a))) do
1890 begin
1891 Name := 'mOptionsPlayers'+s+'Menu';
1892 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
1893 begin
1894 Name := 'ed'+s+'Name';
1895 MaxLength := 12;
1896 Width := 12;
1897 end;
1898 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
1899 begin
1900 Name := 'sw'+s+'Team';
1901 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
1902 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
1903 end ;
1904 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
1905 begin
1906 Name := 'ls'+s+'Model';
1907 Sort := True;
1908 Items := g_PlayerModel_GetNames();
1909 OnChange := ProcSelectModel;
1910 end;
1911 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
1912 begin
1913 Name := 'sc'+s+'Red';
1914 Max := 16;
1915 OnChange := ProcChangeColor;
1916 end;
1917 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
1918 begin
1919 Name := 'sc'+s+'Green';
1920 Max := 16;
1921 OnChange := ProcChangeColor;
1922 end;
1923 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
1924 begin
1925 Name := 'sc'+s+'Blue';
1926 Max := 16;
1927 OnChange := ProcChangeColor;
1928 end;
1929 AddSpace();
1930 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
1931 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
1932 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
1933 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
1935 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
1936 begin
1937 Name := 'mv'+s+'Model';
1938 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
1939 Y := GetControl('ls'+s+'Model').Y;
1940 end;
1941 end;
1942 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
1943 g_GUI_AddWindow(Menu);
1944 end;
1946 procedure CreateAllMenus();
1947 var
1948 Menu: TGUIWindow;
1949 //SR: TSearchRec;
1950 a, cx, _y, i: Integer;
1951 //list: SSArray;
1952 begin
1953 Menu := TGUIWindow.Create('MainMenu');
1954 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, '' (*_lc[I_MENU_MAIN_MENU]*) ))) do
1955 begin
1956 Name := 'mmMainMenu';
1957 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
1958 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
1959 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
1960 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
1961 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
1962 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
1963 end;
1964 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), False))) do
1965 begin
1966 Color := _RGB(255, 255, 255);
1967 X := gScreenWidth-GetWidth-8;
1968 Y := gScreenHeight-GetHeight-8;
1969 end;
1970 Menu.DefControl := 'mmMainMenu';
1971 Menu.MainWindow := True;
1972 g_GUI_AddWindow(Menu);
1974 Menu := TGUIWindow.Create('NewGameMenu');
1975 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_NEW_GAME]))) do
1976 begin
1977 Name := 'mmNewGameMenu';
1978 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
1979 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
1980 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
1981 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
1982 end;
1983 Menu.DefControl := 'mmNewGameMenu';
1984 g_GUI_AddWindow(Menu);
1986 Menu := TGUIWindow.Create('NetGameMenu');
1987 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_MULTIPLAYER]))) do
1988 begin
1989 Name := 'mmNetGameMenu';
1990 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
1991 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
1992 end;
1993 Menu.DefControl := 'mmNetGameMenu';
1994 g_GUI_AddWindow(Menu);
1996 Menu := TGUIWindow.Create('NetServerMenu');
1997 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_START_SERVER]))) do
1998 begin
1999 Name := 'mNetServerMenu';
2000 with AddEdit(_lc[I_NET_SERVER_NAME]) do
2001 begin
2002 Name := 'edSrvName';
2003 OnlyDigits := False;
2004 Width := 16;
2005 MaxLength := 64;
2006 Text := NetServerName;
2007 end;
2008 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2009 begin
2010 Name := 'edSrvPassword';
2011 OnlyDigits := False;
2012 Width := 16;
2013 MaxLength := 24;
2014 Text := NetPassword;
2015 end;
2016 with AddEdit(_lc[I_NET_PORT]) do
2017 begin
2018 Name := 'edPort';
2019 OnlyDigits := True;
2020 Width := 4;
2021 MaxLength := 5;
2022 Text := IntToStr(NetPort);
2023 end;
2024 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2025 begin
2026 Name := 'edMaxPlayers';
2027 OnlyDigits := True;
2028 Width := 4;
2029 MaxLength := 2;
2030 Text := IntToStr(NetMaxClients);
2031 end;
2032 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2033 begin
2034 Name := 'swUseMaster';
2035 AddItem(_lc[I_MENU_YES]);
2036 AddItem(_lc[I_MENU_NO]);
2037 if NetUseMaster then
2038 ItemIndex := 0
2039 else
2040 ItemIndex := 1;
2041 end;
2042 AddSpace();
2043 with AddLabel(_lc[I_MENU_MAP]) do
2044 begin
2045 Name := 'lbMap';
2046 FixedLength := 16;
2047 Text := gsMap;
2048 OnClick := @ProcSelectMapMenu;
2049 end;
2050 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2051 begin
2052 Name := 'swGameMode';
2053 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2054 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2055 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2056 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2057 case g_Game_TextToMode(gsGameMode) of
2058 GM_NONE,
2059 GM_DM: ItemIndex := 0;
2060 GM_TDM: ItemIndex := 1;
2061 GM_CTF: ItemIndex := 2;
2062 GM_SINGLE,
2063 GM_COOP: ItemIndex := 3;
2064 end;
2065 OnChange := ProcSwitchMonstersCustom;
2066 end;
2067 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2068 begin
2069 Name := 'edTimeLimit';
2070 OnlyDigits := True;
2071 Width := 4;
2072 MaxLength := 5;
2073 if gsTimeLimit > 0 then
2074 Text := IntToStr(gsTimeLimit);
2075 end;
2076 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2077 begin
2078 Name := 'edGoalLimit';
2079 OnlyDigits := True;
2080 Width := 4;
2081 MaxLength := 5;
2082 if gsGoalLimit > 0 then
2083 Text := IntToStr(gsGoalLimit);
2084 end;
2085 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2086 begin
2087 Name := 'edMaxLives';
2088 OnlyDigits := True;
2089 Width := 4;
2090 MaxLength := 5;
2091 if gsMaxLives > 0 then
2092 Text := IntToStr(gsMaxLives);
2093 end;
2094 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2095 begin
2096 Name := 'edItemRespawnTime';
2097 OnlyDigits := True;
2098 Width := 4;
2099 MaxLength := 5;
2100 if gsItemRespawnTime > 0 then
2101 Text := IntToStr(gsItemRespawnTime);
2102 end;
2103 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2104 begin
2105 Name := 'swPlayers';
2106 AddItem(_lc[I_MENU_COUNT_NONE]);
2107 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2108 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2109 ItemIndex := gsPlayers;
2110 end;
2111 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2112 begin
2113 Name := 'swTeamDamage';
2114 AddItem(_lc[I_MENU_YES]);
2115 AddItem(_lc[I_MENU_NO]);
2116 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2117 ItemIndex := 0
2118 else
2119 ItemIndex := 1;
2120 end;
2121 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
2122 begin
2123 Name := 'swTeamHit';
2124 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
2125 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
2126 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
2127 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
2128 if (gsGameFlags and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
2129 ItemIndex := 0
2130 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITTRACE) then
2131 ItemIndex := 1
2132 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITPROJECTILE) then
2133 ItemIndex := 2
2134 else
2135 ItemIndex := 3;
2136 end;
2137 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2138 begin
2139 Name := 'swDeathmatchKeys';
2140 AddItem(_lc[I_MENU_YES]);
2141 AddItem(_lc[I_MENU_NO]);
2142 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2143 ItemIndex := 0
2144 else
2145 ItemIndex := 1;
2146 end;
2147 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2148 begin
2149 Name := 'swEnableExits';
2150 AddItem(_lc[I_MENU_YES]);
2151 AddItem(_lc[I_MENU_NO]);
2152 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2153 ItemIndex := 0
2154 else
2155 ItemIndex := 1;
2156 end;
2157 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2158 begin
2159 Name := 'swWeaponStay';
2160 AddItem(_lc[I_MENU_YES]);
2161 AddItem(_lc[I_MENU_NO]);
2162 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2163 ItemIndex := 0
2164 else
2165 ItemIndex := 1;
2166 end;
2167 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2168 begin
2169 Name := 'swMonsters';
2170 AddItem(_lc[I_MENU_YES]);
2171 AddItem(_lc[I_MENU_NO]);
2172 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2173 ItemIndex := 0
2174 else
2175 ItemIndex := 1;
2176 end;
2177 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2178 begin
2179 Name := 'swBotsVS';
2180 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2181 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2182 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2183 ItemIndex := 2;
2184 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2185 ItemIndex := 0;
2186 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2187 ItemIndex := 1;
2188 end;
2189 AddSpace();
2190 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2192 ReAlign();
2193 end;
2194 Menu.DefControl := 'mNetServerMenu';
2195 g_GUI_AddWindow(Menu);
2197 Menu := TGUIWindow.Create('NetClientMenu');
2198 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_START_CLIENT]))) do
2199 begin
2200 Name := 'mNetClientMenu';
2202 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2203 AddSpace();
2205 with AddEdit(_lc[I_NET_ADDRESS]) do
2206 begin
2207 Name := 'edIP';
2208 OnlyDigits :=False;
2209 Width := 12;
2210 MaxLength := 64;
2211 Text := 'localhost';
2212 end;
2213 with AddEdit(_lc[I_NET_PORT]) do
2214 begin
2215 Name := 'edPort';
2216 OnlyDigits := True;
2217 Width := 4;
2218 MaxLength := 5;
2219 Text := '25666';
2220 end;
2221 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2222 begin
2223 Name := 'edPW';
2224 OnlyDigits := False;
2225 Width := 12;
2226 MaxLength := 32;
2227 Text := '';
2228 end;
2230 AddSpace();
2231 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2233 ReAlign();
2234 end;
2235 Menu.DefControl := 'mNetClientMenu';
2236 g_GUI_AddWindow(Menu);
2238 Menu := TGUIWindow.Create('LoadMenu');
2239 Menu.OnShow := ProcLoadMenu;
2240 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_LOAD_GAME]))) do
2241 begin
2242 Name := 'mmLoadMenu';
2244 for a := 1 to 8 do
2245 with AddEdit('') do
2246 begin
2247 Name := 'edSlot'+IntToStr(a);
2248 Width := 16;
2249 MaxLength := 16;
2250 OnEnter := ProcLoadGame;
2251 end;
2252 end;
2253 Menu.DefControl := 'mmLoadMenu';
2254 g_GUI_AddWindow(Menu);
2256 Menu := TGUIWindow.Create('SaveMenu');
2257 Menu.OnShow := ProcSaveMenu;
2258 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_SAVE_GAME]))) do
2259 begin
2260 Name := 'mmSaveMenu';
2262 for a := 1 to 8 do
2263 with AddEdit('') do
2264 begin
2265 Name := 'edSlot'+IntToStr(a);
2266 Width := 16;
2267 MaxLength := 16;
2268 OnChange := ProcSaveGame;
2269 end;
2270 end;
2271 Menu.DefControl := 'mmSaveMenu';
2272 g_GUI_AddWindow(Menu);
2274 Menu := TGUIWindow.Create('CustomGameMenu');
2275 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_CUSTOM_GAME]))) do
2276 begin
2277 Name := 'mCustomGameMenu';
2278 with AddLabel(_lc[I_MENU_MAP]) do
2279 begin
2280 Name := 'lbMap';
2281 FixedLength := 16;
2282 Text := gsMap;
2283 OnClick := @ProcSelectMapMenu;
2284 end;
2285 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2286 begin
2287 Name := 'swGameMode';
2288 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2289 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2290 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2291 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2292 case g_Game_TextToMode(gsGameMode) of
2293 GM_NONE,
2294 GM_DM: ItemIndex := 0;
2295 GM_TDM: ItemIndex := 1;
2296 GM_CTF: ItemIndex := 2;
2297 GM_SINGLE,
2298 GM_COOP: ItemIndex := 3;
2299 end;
2300 OnChange := ProcSwitchMonstersCustom;
2301 end;
2302 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2303 begin
2304 Name := 'edTimeLimit';
2305 OnlyDigits := True;
2306 Width := 4;
2307 MaxLength := 5;
2308 if gsTimeLimit > 0 then
2309 Text := IntToStr(gsTimeLimit);
2310 end;
2311 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2312 begin
2313 Name := 'edGoalLimit';
2314 OnlyDigits := True;
2315 Width := 4;
2316 MaxLength := 5;
2317 if gsGoalLimit > 0 then
2318 Text := IntToStr(gsGoalLimit);
2319 end;
2320 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2321 begin
2322 Name := 'edMaxLives';
2323 OnlyDigits := True;
2324 Width := 4;
2325 MaxLength := 5;
2326 if gsMaxLives > 0 then
2327 Text := IntToStr(gsMaxLives);
2328 end;
2329 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2330 begin
2331 Name := 'edItemRespawnTime';
2332 OnlyDigits := True;
2333 Width := 4;
2334 MaxLength := 5;
2335 if gsItemRespawnTime > 0 then
2336 Text := IntToStr(gsItemRespawnTime);
2337 end;
2338 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2339 begin
2340 Name := 'swPlayers';
2341 AddItem(_lc[I_MENU_COUNT_NONE]);
2342 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2343 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2344 ItemIndex := gsPlayers;
2345 end;
2346 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2347 begin
2348 Name := 'swTeamDamage';
2349 AddItem(_lc[I_MENU_YES]);
2350 AddItem(_lc[I_MENU_NO]);
2351 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2352 ItemIndex := 0
2353 else
2354 ItemIndex := 1;
2355 end;
2356 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
2357 begin
2358 Name := 'swTeamHit';
2359 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
2360 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
2361 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
2362 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
2363 if (gsGameFlags and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
2364 ItemIndex := 0
2365 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITTRACE) then
2366 ItemIndex := 1
2367 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITPROJECTILE) then
2368 ItemIndex := 2
2369 else
2370 ItemIndex := 3;
2371 end;
2372 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2373 begin
2374 Name := 'swDeathmatchKeys';
2375 AddItem(_lc[I_MENU_YES]);
2376 AddItem(_lc[I_MENU_NO]);
2377 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2378 ItemIndex := 0
2379 else
2380 ItemIndex := 1;
2381 end;
2382 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2383 begin
2384 Name := 'swEnableExits';
2385 AddItem(_lc[I_MENU_YES]);
2386 AddItem(_lc[I_MENU_NO]);
2387 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2388 ItemIndex := 0
2389 else
2390 ItemIndex := 1;
2391 end;
2392 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2393 begin
2394 Name := 'swWeaponStay';
2395 AddItem(_lc[I_MENU_YES]);
2396 AddItem(_lc[I_MENU_NO]);
2397 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2398 ItemIndex := 0
2399 else
2400 ItemIndex := 1;
2401 end;
2402 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2403 begin
2404 Name := 'swMonsters';
2405 AddItem(_lc[I_MENU_YES]);
2406 AddItem(_lc[I_MENU_NO]);
2407 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2408 ItemIndex := 0
2409 else
2410 ItemIndex := 1;
2411 end;
2412 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2413 begin
2414 Name := 'swBotsVS';
2415 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2416 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2417 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2418 ItemIndex := 2;
2419 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2420 ItemIndex := 0;
2421 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2422 ItemIndex := 1;
2423 end;
2424 AddSpace();
2425 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2427 ReAlign();
2428 end;
2429 Menu.DefControl := 'mCustomGameMenu';
2430 g_GUI_AddWindow(Menu);
2432 Menu := TGUIWindow.Create('CampaignMenu');
2433 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_CAMPAIGN]))) do
2434 begin
2435 Name := 'mCampaignMenu';
2437 AddSpace();
2438 AddSpace();
2439 AddSpace();
2440 AddSpace();
2441 AddSpace();
2442 AddSpace();
2444 with AddFileList('', 15, 4) do
2445 begin
2446 Name := 'lsWAD';
2447 OnChange := ProcSelectCampaignWAD;
2449 Sort := True;
2450 Dirs := True;
2451 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2452 SetBase(MegawadDirs);
2453 end;
2455 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2456 begin
2457 Name := 'lbWADName';
2458 FixedLength := 8;
2459 Enabled := False;
2460 end;
2461 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2462 begin
2463 Name := 'lbWADAuthor';
2464 FixedLength := 8;
2465 Enabled := False;
2466 end;
2467 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2468 with AddMemo('', 15, 3) do
2469 begin
2470 Name := 'meWADDescription';
2471 Color := MENU_ITEMSCTRL_COLOR;
2472 end;
2473 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2474 begin
2475 Name := 'swPlayers';
2476 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2477 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2478 end;
2479 AddSpace();
2480 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2482 ReAlign();
2484 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2485 begin
2486 Name := 'mpWADImage';
2487 DefaultRes := 'NOPIC';
2488 X := GetControl('lsWAD').X+4;
2489 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2490 end;
2491 end;
2492 Menu.DefControl := 'mCampaignMenu';
2493 g_GUI_AddWindow(Menu);
2495 Menu := TGUIWindow.Create('SelectMapMenu');
2496 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_SELECT_MAP]))) do
2497 begin
2498 Name := 'mSelectMapMenu';
2499 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2500 begin
2501 Name := 'lsMapWAD';
2502 OnChange := ProcSelectWAD;
2504 Sort := True;
2505 Dirs := True;
2506 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2507 SetBase(MapDirs);
2508 end;
2509 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2510 begin
2511 Name := 'lsMapRes';
2512 Sort := True;
2513 OnChange := ProcSelectMap;
2514 end;
2515 AddSpace();
2516 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2517 begin
2518 Name := 'lbMapName';
2519 FixedLength := 24;
2520 Enabled := False;
2521 end;
2522 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2523 begin
2524 Name := 'lbMapAuthor';
2525 FixedLength := 16;
2526 Enabled := False;
2527 end;
2528 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2529 begin
2530 Name := 'lbMapSize';
2531 FixedLength := 10;
2532 Enabled := False;
2533 end;
2534 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 12, 4) do
2535 begin
2536 Name := 'meMapDescription';
2537 end;
2539 ReAlign();
2541 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2542 begin
2543 Name := 'mpMapPreview';
2544 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2545 Y := GetControl('lsMapWAD').Y;
2546 end;
2547 with TGUILabel(Menu.AddChild(TGUILabel.Create('', False))) do
2548 begin
2549 Name := 'lbMapScale';
2550 FixedLength := 8;
2551 Enabled := False;
2552 Color := MENU_ITEMSCTRL_COLOR;
2553 X := GetControl('lsMapWAD').X +
2554 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2555 2 + MAPPREVIEW_WIDTH*4;
2556 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2557 end;
2558 end;
2559 Menu.OnClose := ProcSetMap;
2560 Menu.DefControl := 'mSelectMapMenu';
2561 g_GUI_AddWindow(Menu);
2563 Menu := TGUIWindow.Create('OptionsMenu');
2564 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_OPTIONS]))) do
2565 begin
2566 Name := 'mmOptionsMenu';
2567 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2568 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2569 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2570 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2571 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2572 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2573 AddSpace();
2574 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2575 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2576 end;
2577 Menu.OnClose := ProcApplyOptions;
2578 Menu.DefControl := 'mmOptionsMenu';
2579 g_GUI_AddWindow(Menu);
2581 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6), @ProcSavedMenuKeyDown);
2582 g_GUI_AddWindow(Menu);
2584 Menu := TGUIWindow.Create('OptionsVideoMenu');
2585 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_VIDEO_OPTIONS]))) do
2586 begin
2587 Name := 'mOptionsVideoMenu';
2588 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2589 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2590 begin
2591 Name := 'swBPP';
2592 AddItem('16');
2593 AddItem('32');
2594 end;
2595 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2596 begin
2597 Name := 'swVSync';
2598 AddItem(_lc[I_MENU_YES]);
2599 AddItem(_lc[I_MENU_NO]);
2600 end;
2601 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2602 begin
2603 Name := 'swTextureFilter';
2604 AddItem(_lc[I_MENU_YES]);
2605 AddItem(_lc[I_MENU_NO]);
2606 end;
2607 with AddSwitch(_lc[I_MENU_VIDEO_INTERPOLATION]) do
2608 begin
2609 Name := 'swInterp';
2610 AddItem(_lc[I_MENU_YES]);
2611 AddItem(_lc[I_MENU_NO]);
2612 end;
2613 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2614 begin
2615 Name := 'swLegacyNPOT';
2616 AddItem(_lc[I_MENU_NO]);
2617 AddItem(_lc[I_MENU_YES]);
2618 end;
2619 AddSpace();
2620 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2621 ReAlign();
2622 end;
2623 Menu.DefControl := 'mOptionsVideoMenu';
2624 g_GUI_AddWindow(Menu);
2626 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2627 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_RESOLUTION_SELECT]))) do
2628 begin
2629 Name := 'mOptionsVideoResMenu';
2630 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2631 begin
2632 Name := 'lbCurrentRes';
2633 FixedLength := 24;
2634 Enabled := False;
2635 end;
2636 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2637 begin
2638 Name := 'lsResolution';
2639 Sort := False;
2640 end;
2641 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2642 begin
2643 Name := 'swFullScreen';
2644 AddItem(_lc[I_MENU_YES]);
2645 AddItem(_lc[I_MENU_NO]);
2646 end;
2647 with AddSwitch(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2648 begin
2649 Name := 'swResFactor';
2650 AddItem('1x');
2651 for i := 2 to gRC_Width div 640 do
2652 AddItem(IntToStr(i) + 'x');
2653 end;
2654 AddSpace();
2655 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2656 UpdateIndex();
2657 end;
2658 Menu.DefControl := 'mOptionsVideoResMenu';
2659 g_GUI_AddWindow(Menu);
2661 Menu := TGUIWindow.Create('OptionsSoundMenu');
2662 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_SOUND_OPTIONS]))) do
2663 begin
2664 Name := 'mOptionsSoundMenu';
2665 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2666 begin
2667 Name := 'scMusicLevel';
2668 Max := 16;
2669 OnChange := ProcChangeSoundSettings;
2670 end;
2671 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2672 begin
2673 Name := 'scSoundLevel';
2674 Max := 16;
2675 OnChange := ProcChangeSoundSettings;
2676 end;
2677 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2678 begin
2679 Name := 'scMaxSimSounds';
2680 Max := 16;
2681 end;
2682 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2683 begin;
2684 Name := 'swAnnouncer';
2685 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2686 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2687 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2688 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2689 end;
2690 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2691 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2692 begin;
2693 Name := 'swSoundEffects';
2694 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2695 AddItem(_lc[I_MENU_COMPAT_DF]);
2696 end;
2697 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
2698 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
2699 begin;
2700 Name := 'swChatSpeech';
2701 AddItem(_lc[I_MENU_YES]);
2702 AddItem(_lc[I_MENU_NO]);
2703 end;
2704 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2705 begin
2706 Name := 'swInactiveSounds';
2707 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2708 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2709 end;
2710 ReAlign();
2711 end;
2712 Menu.DefControl := 'mOptionsSoundMenu';
2713 g_GUI_AddWindow(Menu);
2715 Menu := TGUIWindow.Create('OptionsGameMenu');
2716 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_GAME_OPTIONS]))) do
2717 begin
2718 Name := 'mOptionsGameMenu';
2719 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2720 begin
2721 Name := 'scParticlesCount';
2722 Max := 20;
2723 end;
2724 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2725 begin
2726 Name := 'swBloodCount';
2727 AddItem(_lc[I_MENU_COUNT_NONE]);
2728 AddItem(_lc[I_MENU_COUNT_SMALL]);
2729 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2730 AddItem(_lc[I_MENU_COUNT_BIG]);
2731 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2732 end;
2733 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2734 begin
2735 Name := 'scShellsMax';
2736 Max := 20;
2737 end;
2738 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2739 begin
2740 Name := 'scGibsMax';
2741 Max := 20;
2742 end;
2743 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2744 begin
2745 Name := 'scCorpsesMax';
2746 Max := 20;
2747 end;
2748 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2749 begin
2750 Name := 'swGibsCount';
2751 AddItem(_lc[I_MENU_COUNT_NONE]);
2752 AddItem(_lc[I_MENU_COUNT_SMALL]);
2753 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2754 AddItem(_lc[I_MENU_COUNT_BIG]);
2755 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2756 end;
2757 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2758 begin
2759 Name := 'swCorpseType';
2760 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2761 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2762 end;
2763 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2764 begin
2765 Name := 'swGibsType';
2766 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2767 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2768 end;
2769 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2770 begin
2771 Name := 'swBloodType';
2772 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2773 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2774 end;
2775 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2776 begin
2777 Name := 'swScreenFlash';
2778 AddItem(_lc[I_MENU_NO]);
2779 AddItem(_lc[I_MENU_COMPAT_DF]);
2780 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2781 end;
2782 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2783 begin
2784 Name := 'swBackground';
2785 AddItem(_lc[I_MENU_YES]);
2786 AddItem(_lc[I_MENU_NO]);
2787 end;
2788 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2789 begin
2790 Name := 'swMessages';
2791 AddItem(_lc[I_MENU_YES]);
2792 AddItem(_lc[I_MENU_NO]);
2793 end;
2794 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2795 begin
2796 Name := 'swRevertPlayers';
2797 AddItem(_lc[I_MENU_YES]);
2798 AddItem(_lc[I_MENU_NO]);
2799 end;
2800 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2801 begin
2802 Name := 'swChatBubble';
2803 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2804 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2805 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2806 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2807 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2808 end;
2809 with AddSwitch(_lc[I_MENU_GAME_PLAYER_INDICATOR]) do
2810 begin
2811 Name := 'swPlayerIndicator';
2812 AddItem(_lc[I_MENU_GAME_INDICATOR_NONE]);
2813 AddItem(_lc[I_MENU_GAME_INDICATOR_OWN]);
2814 AddItem(_lc[I_MENU_GAME_INDICATOR_ALL]);
2815 end;
2816 with AddSwitch(_lc[I_MENU_GAME_INDICATOR_STYLE]) do
2817 begin
2818 Name := 'swPlayerIndicatorStyle';
2819 AddItem(_lc[I_MENU_GAME_INDICATOR_ARROW]);
2820 AddItem(_lc[I_MENU_GAME_INDICATOR_NAME]);
2821 end;
2822 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2823 begin
2824 Name := 'scScaleFactor';
2825 Max := 10;
2826 OnChange := ProcChangeGameSettings;
2827 end;
2828 ReAlign();
2829 end;
2830 Menu.DefControl := 'mOptionsGameMenu';
2831 g_GUI_AddWindow(Menu);
2833 Menu := TGUIWindow.Create('OptionsControlsMenu');
2834 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_CONTROLS_OPTIONS]))) do
2835 begin
2836 Name := 'mOptionsControlsMenu';
2837 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
2838 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
2839 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
2840 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
2841 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
2842 AddSpace();
2843 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
2844 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
2845 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
2846 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
2847 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
2848 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
2849 if e_HasJoysticks then
2850 begin
2851 AddSpace();
2852 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
2853 end;
2854 if g_touch_enabled then
2855 begin
2856 AddSpace();
2857 AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
2858 end;
2859 end;
2860 Menu.DefControl := 'mOptionsControlsMenu';
2861 g_GUI_AddWindow(Menu);
2863 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
2864 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_PLAYER_1_KBD]))) do
2865 begin
2866 Name := 'mOptionsControlsP1Menu';
2867 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2868 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2869 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2870 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2871 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2872 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2873 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2874 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2875 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2876 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2877 end;
2878 Menu.DefControl := 'mOptionsControlsP1Menu';
2879 g_GUI_AddWindow(Menu);
2881 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
2882 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
2883 begin
2884 Name := 'mOptionsControlsP1MenuWeapons';
2885 for i := WP_FIRST to WP_LAST do
2886 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2887 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2888 end;
2889 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
2890 g_GUI_AddWindow(Menu);
2892 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
2893 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_PLAYER_2_KBD]))) do
2894 begin
2895 Name := 'mOptionsControlsP2Menu';
2896 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2897 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2898 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2899 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2900 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2901 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2902 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2903 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2904 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2905 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2906 end;
2907 Menu.DefControl := 'mOptionsControlsP2Menu';
2908 g_GUI_AddWindow(Menu);
2910 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
2911 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
2912 begin
2913 Name := 'mOptionsControlsP2MenuWeapons';
2914 for i := WP_FIRST to WP_LAST do
2915 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2916 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2917 end;
2918 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
2919 g_GUI_AddWindow(Menu);
2921 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
2922 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
2923 begin
2924 Name := 'mOptionsControlsJoystickMenu';
2925 for i := 0 to e_MaxJoys - 1 do
2926 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
2927 begin
2928 Name := 'scDeadzone' + IntToStr(i);
2929 Max := 20
2930 end
2931 end;
2932 Menu.DefControl := 'mOptionsControlsJoystickMenu';
2933 g_GUI_AddWindow(Menu);
2935 Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
2936 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_CONTROL_TOUCH]))) do
2937 begin
2938 Name := 'mOptionsControlsTouchMenu';
2939 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
2940 begin
2941 Name := 'swTouchAlt';
2942 AddItem(_lc[I_MENU_NO]);
2943 AddItem(_lc[I_MENU_YES]);
2944 OnChange := ProcChangeTouchSettings;
2945 end;
2946 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
2947 begin
2948 Name := 'scTouchSize';
2949 Max := 20;
2950 OnChange := ProcChangeTouchSettings;
2951 end;
2952 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
2953 begin
2954 Name := 'swTouchFire';
2955 AddItem(_lc[I_MENU_NO]);
2956 AddItem(_lc[I_MENU_YES]);
2957 end;
2958 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do
2959 begin
2960 Name := 'scTouchOffset';
2961 Max := 20;
2962 OnChange := ProcChangeTouchSettings;
2963 end;
2964 end;
2965 Menu.DefControl := 'mOptionsControlsTouchMenu';
2966 g_GUI_AddWindow(Menu);
2968 Menu := TGUIWindow.Create('OptionsPlayersMenu');
2969 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_PLAYER_OPTIONS]))) do
2970 begin
2971 Name := 'mOptionsPlayersMenu';
2972 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
2973 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
2974 end;
2975 Menu.DefControl := 'mOptionsPlayersMenu';
2976 g_GUI_AddWindow(Menu);
2978 CreatePlayerOptionsMenu('P1');
2979 CreatePlayerOptionsMenu('P2');
2981 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
2982 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_MODEL_INFO]))) do
2983 begin
2984 Name := 'mOptionsPlayersMIMenu';
2985 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
2986 begin
2987 Name := 'lbName';
2988 FixedLength := 16;
2989 end;
2990 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
2991 begin
2992 Name := 'lbAuthor';
2993 FixedLength := 16;
2994 end;
2995 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
2996 begin
2997 Name := 'meComment';
2998 end;
2999 AddSpace();
3000 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
3001 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
3002 begin
3003 Name := 'lbWeapon';
3004 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
3005 end;
3006 ReAlign();
3007 end;
3008 Menu.DefControl := 'mOptionsPlayersMIMenu';
3009 g_GUI_AddWindow(Menu);
3011 Menu := TGUIWindow.Create('OptionsLanguageMenu');
3012 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
3013 begin
3014 Name := 'mOptionsLanguageMenu';
3015 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
3016 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
3017 ReAlign();
3018 end;
3019 Menu.DefControl := 'mOptionsLanguageMenu';
3020 g_GUI_AddWindow(Menu);
3022 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6), @ProcDefaultMenuKeyDown);
3023 g_GUI_AddWindow(Menu);
3025 Menu := TGUIWindow.Create('AuthorsMenu');
3026 Menu.BackTexture := 'INTER';
3027 Menu.OnClose := ProcAuthorsClose;
3029 // Çàãîëîâîê:
3030 _y := 16;
3031 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], False))) do
3032 begin
3033 Color := _RGB(255, 0, 0);
3034 X := (gScreenWidth div 2)-(GetWidth() div 2);
3035 Y := _y;
3036 _y := _y+GetHeight();
3037 end;
3038 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), False))) do
3039 begin
3040 Color := _RGB(255, 0, 0);
3041 X := (gScreenWidth div 2)-(GetWidth() div 2);
3042 Y := _y;
3043 _y := _y+GetHeight()+32;
3044 end;
3045 // ×òî äåëàë: Êòî äåëàë
3046 cx := gScreenWidth div 2 - 320 + 64;
3047 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], False))) do
3048 begin
3049 Color := _RGB(255, 0, 0);
3050 X := cx;
3051 Y := _y;
3052 _y := _y+22;
3053 end;
3054 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], False))) do
3055 begin
3056 Color := _RGB(255, 255, 255);
3057 X := cx+32;
3058 Y := _y;
3059 _y := _y+36;
3060 end;
3061 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], False))) do
3062 begin
3063 Color := _RGB(255, 0, 0);
3064 X := cx;
3065 Y := _y;
3066 _y := _y+22;
3067 end;
3068 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], False))) do
3069 begin
3070 Color := _RGB(255, 255, 255);
3071 X := cx+32;
3072 Y := _y;
3073 _y := _y+22;
3074 end;
3075 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], False))) do
3076 begin
3077 Color := _RGB(255, 255, 255);
3078 X := cx+32;
3079 Y := _y;
3080 _y := _y+36;
3081 end;
3082 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], False))) do
3083 begin
3084 Color := _RGB(255, 0, 0);
3085 X := cx;
3086 Y := _y;
3087 _y := _y+22;
3088 end;
3089 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], False))) do
3090 begin
3091 Color := _RGB(255, 255, 255);
3092 X := cx+32;
3093 Y := _y;
3094 _y := _y+36;
3095 end;
3096 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], False))) do
3097 begin
3098 Color := _RGB(255, 0, 0);
3099 X := cx;
3100 Y := _y;
3101 _y := _y+22;
3102 end;
3103 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], False))) do
3104 begin
3105 Color := _RGB(255, 255, 255);
3106 X := cx+32;
3107 Y := _y;
3108 _y := gScreenHeight - 128;
3109 end;
3110 // Çàêëþ÷åíèå:
3111 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], False))) do
3112 begin
3113 Color := _RGB(255, 0, 0);
3114 X := cx;
3115 Y := _y;
3116 _y := _y+16;
3117 end;
3118 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], False))) do
3119 begin
3120 Color := _RGB(255, 255, 255);
3121 X := cx+32;
3122 Y := _y;
3123 _y := _y+GetHeight();
3124 end;
3125 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], False))) do
3126 begin
3127 Color := _RGB(255, 255, 255);
3128 X := cx+32;
3129 Y := _y;
3130 _y := _y+GetHeight();
3131 end;
3132 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], False))) do
3133 begin
3134 Color := _RGB(255, 255, 255);
3135 X := cx+32;
3136 Y := _y;
3137 _y := gScreenHeight - 32;
3138 end;
3139 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], False))) do
3140 begin
3141 Color := _RGB(255, 0, 0);
3142 X := gScreenWidth div 2 - GetWidth() div 2;
3143 Y := _y;
3144 end;
3145 g_GUI_AddWindow(Menu);
3147 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6), @ProcExitMenuKeyDown);
3148 g_GUI_AddWindow(Menu);
3150 Menu := TGUIWindow.Create('GameSingleMenu');
3151 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_MAIN_MENU]))) do
3152 begin
3153 Name := 'mmGameSingleMenu';
3154 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3155 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3156 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3157 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3158 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3159 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3160 end;
3161 Menu.DefControl := 'mmGameSingleMenu';
3162 Menu.MainWindow := True;
3163 Menu.OnClose := ProcGMClose;
3164 Menu.OnShow := ProcGMShow;
3165 g_GUI_AddWindow(Menu);
3167 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6), @ProcEndMenuKeyDown);
3168 g_GUI_AddWindow(Menu);
3170 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6), @ProcRestartMenuKeyDown);
3171 g_GUI_AddWindow(Menu);
3173 Menu := TGUIWindow.Create('GameCustomMenu');
3174 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_MAIN_MENU]))) do
3175 begin
3176 Name := 'mmGameCustomMenu';
3177 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3178 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3179 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3180 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3181 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3182 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3183 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3184 end;
3185 Menu.DefControl := 'mmGameCustomMenu';
3186 Menu.MainWindow := True;
3187 Menu.OnClose := ProcGMClose;
3188 Menu.OnShow := ProcGMShow;
3189 g_GUI_AddWindow(Menu);
3191 Menu := TGUIWindow.Create('GameServerMenu');
3192 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_MAIN_MENU]))) do
3193 begin
3194 Name := 'mmGameServerMenu';
3195 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3196 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3197 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3198 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3199 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3200 end;
3201 Menu.DefControl := 'mmGameServerMenu';
3202 Menu.MainWindow := True;
3203 Menu.OnClose := ProcGMClose;
3204 Menu.OnShow := ProcGMShow;
3205 g_GUI_AddWindow(Menu);
3207 Menu := TGUIWindow.Create('GameClientMenu');
3208 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_MAIN_MENU]))) do
3209 begin
3210 Name := 'mmGameClientMenu';
3211 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3212 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3213 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3214 end;
3215 Menu.DefControl := 'mmGameClientMenu';
3216 Menu.MainWindow := True;
3217 Menu.OnClose := ProcGMClose;
3218 Menu.OnShow := ProcGMShow;
3219 g_GUI_AddWindow(Menu);
3221 Menu := TGUIWindow.Create('ClientPasswordMenu');
3222 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(False, False, _lc[I_MENU_ENTERPASSWORD]))) do
3223 begin
3224 Name := 'mClientPasswordMenu';
3225 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3226 begin
3227 Name := 'edPW';
3228 Width := 12;
3229 MaxLength := 32;
3230 end;
3231 AddSpace;
3233 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3234 ReAlign();
3235 end;
3236 Menu.DefControl := 'mClientPasswordMenu';
3237 g_GUI_AddWindow(Menu);
3239 Menu := TGUIWindow.Create('GameSetGameMenu');
3240 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_SET_GAME]))) do
3241 begin
3242 Name := 'mGameSetGameMenu';
3243 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3244 begin
3245 Name := 'swTeamDamage';
3246 AddItem(_lc[I_MENU_YES]);
3247 AddItem(_lc[I_MENU_NO]);
3248 ItemIndex := 1;
3249 end;
3250 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
3251 begin
3252 Name := 'swTeamHit';
3253 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
3254 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
3255 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
3256 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
3257 ItemIndex := 0
3258 end;
3259 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
3260 begin
3261 Name := 'swDeathmatchKeys';
3262 AddItem(_lc[I_MENU_YES]);
3263 AddItem(_lc[I_MENU_NO]);
3264 ItemIndex := 1;
3265 end;
3266 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3267 begin
3268 Name := 'edTimeLimit';
3269 OnlyDigits := True;
3270 Width := 4;
3271 MaxLength := 5;
3272 end;
3273 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
3274 begin
3275 Name := 'edGoalLimit';
3276 OnlyDigits := True;
3277 Width := 4;
3278 MaxLength := 5;
3279 end;
3280 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3281 begin
3282 Name := 'edMaxLives';
3283 OnlyDigits := True;
3284 Width := 4;
3285 MaxLength := 5;
3286 end;
3287 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3288 begin
3289 Name := 'swBotsVS';
3290 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3291 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3292 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3293 ItemIndex := 2;
3294 end;
3296 ReAlign();
3297 end;
3298 Menu.DefControl := 'mGameSetGameMenu';
3299 Menu.OnClose := ProcApplyGameSet;
3300 g_GUI_AddWindow(Menu);
3302 Menu := TGUIWindow.Create('TeamMenu');
3303 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_CHANGE_PLAYERS]))) do
3304 begin
3305 Name := 'mmTeamMenu';
3306 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3307 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3308 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3309 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3310 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3311 end;
3312 Menu.DefControl := 'mmTeamMenu';
3313 Menu.OnShow := ProcChangePlayers;
3314 g_GUI_AddWindow(Menu);
3315 end;
3317 procedure g_Menu_Show_SaveMenu();
3318 begin
3319 if g_Game_IsTestMap then
3320 Exit;
3321 if gGameSettings.GameType = GT_SINGLE then
3322 g_GUI_ShowWindow('GameSingleMenu')
3323 else
3324 begin
3325 if g_Game_IsClient then
3326 Exit
3327 else
3328 if g_Game_IsNet then
3329 Exit
3330 else
3331 g_GUI_ShowWindow('GameCustomMenu');
3332 end;
3333 g_GUI_ShowWindow('SaveMenu');
3334 g_Sound_PlayEx('MENU_OPEN');
3335 end;
3337 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3338 begin
3339 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3340 if gGameSettings.GameType = GT_SINGLE then
3341 begin
3342 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3343 end
3344 else
3345 begin
3346 if g_Game_IsClient then exit;
3347 if g_Game_IsNet then exit;
3348 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3349 end;
3350 g_GUI_ShowWindow('LoadMenu');
3351 g_Sound_PlayEx('MENU_OPEN');
3352 end;
3354 procedure g_Menu_Show_GameSetGame();
3355 begin
3356 if gGameSettings.GameType = GT_SINGLE then
3357 g_GUI_ShowWindow('GameSingleMenu')
3358 else
3359 begin
3360 if g_Game_IsClient then
3361 Exit
3362 else
3363 if g_Game_IsNet then
3364 g_GUI_ShowWindow('GameServerMenu')
3365 else
3366 g_GUI_ShowWindow('GameCustomMenu');
3367 end;
3368 ReadGameSettings();
3369 g_GUI_ShowWindow('GameSetGameMenu');
3370 g_Sound_PlayEx('MENU_OPEN');
3371 end;
3373 procedure g_Menu_Show_OptionsVideo();
3374 begin
3375 if gGameSettings.GameType = GT_SINGLE then
3376 g_GUI_ShowWindow('GameSingleMenu')
3377 else
3378 begin
3379 if g_Game_IsClient then
3380 g_GUI_ShowWindow('GameClientMenu')
3381 else
3382 if g_Game_IsNet then
3383 g_GUI_ShowWindow('GameServerMenu')
3384 else
3385 g_GUI_ShowWindow('GameCustomMenu');
3386 end;
3387 ReadOptions();
3388 g_GUI_ShowWindow('OptionsMenu');
3389 g_GUI_ShowWindow('OptionsVideoMenu');
3390 g_Sound_PlayEx('MENU_OPEN');
3391 end;
3393 procedure g_Menu_Show_OptionsSound();
3394 begin
3395 if gGameSettings.GameType = GT_SINGLE then
3396 g_GUI_ShowWindow('GameSingleMenu')
3397 else
3398 begin
3399 if g_Game_IsClient then
3400 g_GUI_ShowWindow('GameClientMenu')
3401 else
3402 if g_Game_IsNet then
3403 g_GUI_ShowWindow('GameServerMenu')
3404 else
3405 g_GUI_ShowWindow('GameCustomMenu');
3406 end;
3407 ReadOptions();
3408 g_GUI_ShowWindow('OptionsMenu');
3409 g_GUI_ShowWindow('OptionsSoundMenu');
3410 g_Sound_PlayEx('MENU_OPEN');
3411 end;
3413 procedure g_Menu_Show_EndGameMenu();
3414 begin
3415 g_GUI_ShowWindow('EndGameMenu');
3416 g_Sound_PlayEx('MENU_OPEN');
3417 end;
3419 procedure g_Menu_Show_QuitGameMenu();
3420 begin
3421 g_GUI_ShowWindow('ExitMenu');
3422 g_Sound_PlayEx('MENU_OPEN');
3423 end;
3425 procedure g_Menu_Init();
3426 begin
3427 MenuLoadData();
3428 CreateAllMenus();
3429 end;
3431 procedure g_Menu_Free();
3432 begin
3433 MenuFreeData();
3434 end;
3436 procedure g_Menu_Reset();
3437 var
3438 ex: Boolean;
3439 begin
3440 g_GUI_SaveMenuPos();
3441 ex := g_GUI_Destroy();
3443 if ex then
3444 begin
3445 e_WriteLog('Recreating menu...', TMsgType.Notify);
3447 CreateAllMenus();
3449 if gDebugMode then
3450 g_Game_SetDebugMode();
3452 g_GUI_LoadMenuPos();
3453 end;
3454 end;
3456 end.