DEADSOFTWARE

render: draw menu via 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, r_game,
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; FontID: DWORD; 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(gMenuSmallFont, gMenuSmallFont, '')));
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 list := sys_GetDisplayModes(gBPP);
1760 if list <> nil then
1761 begin
1762 Items := list;
1763 ItemIndex := Length(list)
1764 end
1765 else
1766 begin
1767 Clear
1768 end
1769 end;
1771 with TGUISwitch(menu.GetControl('swFullScreen')) do
1772 if gFullscreen then
1773 ItemIndex := 0
1774 else
1775 ItemIndex := 1;
1777 TempResScale := Round(r_pixel_scale - 1);
1778 with TGUISwitch(menu.GetControl('swResFactor')) do
1779 ItemIndex := Min(TempResScale, gRC_Width div 640 - 1);
1780 end;
1782 procedure ProcApplyVideoOptions();
1783 var
1784 menu: TGUIMenu;
1785 Fullscreen: Boolean;
1786 SWidth, SHeight: Integer;
1787 ScaleChanged: Boolean;
1788 str: String;
1789 begin
1790 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1792 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1793 if str <> '' then
1794 SScanf(str, '%dx%d', [@SWidth, @SHeight])
1795 else
1796 begin
1797 SWidth := gWinSizeX;
1798 SHeight := gWinSizeY;
1799 TempResScale := Min(TempResScale, SWidth div 640 - 1);
1800 end;
1802 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1804 ScaleChanged := False;
1805 if TGUISwitch(menu.GetControl('swResFactor')).ItemIndex <> TempResScale then
1806 begin
1807 TempResScale := Min(TGUISwitch(menu.GetControl('swResFactor')).ItemIndex, SWidth div 640 - 1);
1808 r_pixel_scale := TempResScale + 1;
1809 ScaleChanged := True;
1810 end;
1812 if (SWidth <> gWinSizeX) or
1813 (SHeight <> gWinSizeY) or
1814 (Fullscreen <> gFullscreen) or
1815 ScaleChanged then
1816 begin
1817 gResolutionChange := True;
1818 gRC_Width := SWidth;
1819 gRC_Height := SHeight;
1820 gRC_FullScreen := Fullscreen;
1821 gRC_Maximized := gWinMaximized;
1822 end;
1824 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1825 ProcApplyOptions();
1826 end;
1828 procedure ProcSetFirstRussianLanguage;
1829 begin
1830 gLanguage := LANGUAGE_RUSSIAN;
1831 gLanguageChange := True;
1832 gAskLanguage := False;
1833 end;
1835 procedure ProcSetFirstEnglishLanguage;
1836 begin
1837 gLanguage := LANGUAGE_ENGLISH;
1838 gLanguageChange := True;
1839 gAskLanguage := False;
1840 end;
1842 procedure ProcRecallAddress();
1843 begin
1844 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1845 begin
1846 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1847 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1848 end;
1849 end;
1851 procedure CreateFirstLanguageMenu();
1852 var
1853 Menu: TGUIWindow;
1854 begin
1855 Menu := TGUIWindow.Create('FirstLanguageMenu');
1857 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, ' '))) do // space to prevent show logo
1858 begin
1859 Name := 'mmFirstLanguageMenu';
1860 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
1861 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
1862 end;
1864 Menu.DefControl := 'mmFirstLanguageMenu';
1865 Menu.MainWindow := True;
1866 g_GUI_AddWindow(Menu);
1867 end;
1869 procedure g_Menu_AskLanguage();
1870 begin
1871 CreateFirstLanguageMenu();
1872 g_GUI_ShowWindow('FirstLanguageMenu');
1873 end;
1875 procedure CreatePlayerOptionsMenu(s: String);
1876 var
1877 Menu: TGUIWindow;
1878 a: String;
1879 begin
1880 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
1881 if s = 'P1' then
1882 a := _lc[I_MENU_PLAYER_1]
1883 else
1884 a := _lc[I_MENU_PLAYER_2];
1885 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
1886 begin
1887 Name := 'mOptionsPlayers'+s+'Menu';
1888 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
1889 begin
1890 Name := 'ed'+s+'Name';
1891 MaxLength := 12;
1892 Width := 12;
1893 end;
1894 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
1895 begin
1896 Name := 'sw'+s+'Team';
1897 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
1898 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
1899 end ;
1900 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
1901 begin
1902 Name := 'ls'+s+'Model';
1903 Sort := True;
1904 Items := g_PlayerModel_GetNames();
1905 OnChange := ProcSelectModel;
1906 end;
1907 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
1908 begin
1909 Name := 'sc'+s+'Red';
1910 Max := 16;
1911 OnChange := ProcChangeColor;
1912 end;
1913 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
1914 begin
1915 Name := 'sc'+s+'Green';
1916 Max := 16;
1917 OnChange := ProcChangeColor;
1918 end;
1919 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
1920 begin
1921 Name := 'sc'+s+'Blue';
1922 Max := 16;
1923 OnChange := ProcChangeColor;
1924 end;
1925 AddSpace();
1926 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
1927 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
1928 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
1929 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
1931 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
1932 begin
1933 Name := 'mv'+s+'Model';
1934 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
1935 Y := GetControl('ls'+s+'Model').Y;
1936 end;
1937 end;
1938 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
1939 g_GUI_AddWindow(Menu);
1940 end;
1942 procedure CreateAllMenus();
1943 var
1944 Menu: TGUIWindow;
1945 //SR: TSearchRec;
1946 a, cx, _y, i: Integer;
1947 //list: SSArray;
1948 begin
1949 Menu := TGUIWindow.Create('MainMenu');
1950 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '' (*_lc[I_MENU_MAIN_MENU]*) ))) do
1951 begin
1952 Name := 'mmMainMenu';
1953 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
1954 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
1955 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
1956 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
1957 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
1958 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
1959 end;
1960 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
1961 begin
1962 Color := _RGB(255, 255, 255);
1963 X := gScreenWidth-GetWidth-8;
1964 Y := gScreenHeight-GetHeight-8;
1965 end;
1966 Menu.DefControl := 'mmMainMenu';
1967 Menu.MainWindow := True;
1968 g_GUI_AddWindow(Menu);
1970 Menu := TGUIWindow.Create('NewGameMenu');
1971 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_NEW_GAME]))) do
1972 begin
1973 Name := 'mmNewGameMenu';
1974 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
1975 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
1976 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
1977 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
1978 end;
1979 Menu.DefControl := 'mmNewGameMenu';
1980 g_GUI_AddWindow(Menu);
1982 Menu := TGUIWindow.Create('NetGameMenu');
1983 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MULTIPLAYER]))) do
1984 begin
1985 Name := 'mmNetGameMenu';
1986 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
1987 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
1988 end;
1989 Menu.DefControl := 'mmNetGameMenu';
1990 g_GUI_AddWindow(Menu);
1992 Menu := TGUIWindow.Create('NetServerMenu');
1993 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
1994 begin
1995 Name := 'mNetServerMenu';
1996 with AddEdit(_lc[I_NET_SERVER_NAME]) do
1997 begin
1998 Name := 'edSrvName';
1999 OnlyDigits := False;
2000 Width := 16;
2001 MaxLength := 64;
2002 Text := NetServerName;
2003 end;
2004 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2005 begin
2006 Name := 'edSrvPassword';
2007 OnlyDigits := False;
2008 Width := 16;
2009 MaxLength := 24;
2010 Text := NetPassword;
2011 end;
2012 with AddEdit(_lc[I_NET_PORT]) do
2013 begin
2014 Name := 'edPort';
2015 OnlyDigits := True;
2016 Width := 4;
2017 MaxLength := 5;
2018 Text := IntToStr(NetPort);
2019 end;
2020 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2021 begin
2022 Name := 'edMaxPlayers';
2023 OnlyDigits := True;
2024 Width := 4;
2025 MaxLength := 2;
2026 Text := IntToStr(NetMaxClients);
2027 end;
2028 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2029 begin
2030 Name := 'swUseMaster';
2031 AddItem(_lc[I_MENU_YES]);
2032 AddItem(_lc[I_MENU_NO]);
2033 if NetUseMaster then
2034 ItemIndex := 0
2035 else
2036 ItemIndex := 1;
2037 end;
2038 AddSpace();
2039 with AddLabel(_lc[I_MENU_MAP]) do
2040 begin
2041 Name := 'lbMap';
2042 FixedLength := 16;
2043 Text := gsMap;
2044 OnClick := @ProcSelectMapMenu;
2045 end;
2046 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2047 begin
2048 Name := 'swGameMode';
2049 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2050 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2051 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2052 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2053 case g_Game_TextToMode(gsGameMode) of
2054 GM_NONE,
2055 GM_DM: ItemIndex := 0;
2056 GM_TDM: ItemIndex := 1;
2057 GM_CTF: ItemIndex := 2;
2058 GM_SINGLE,
2059 GM_COOP: ItemIndex := 3;
2060 end;
2061 OnChange := ProcSwitchMonstersCustom;
2062 end;
2063 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2064 begin
2065 Name := 'edTimeLimit';
2066 OnlyDigits := True;
2067 Width := 4;
2068 MaxLength := 5;
2069 if gsTimeLimit > 0 then
2070 Text := IntToStr(gsTimeLimit);
2071 end;
2072 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2073 begin
2074 Name := 'edGoalLimit';
2075 OnlyDigits := True;
2076 Width := 4;
2077 MaxLength := 5;
2078 if gsGoalLimit > 0 then
2079 Text := IntToStr(gsGoalLimit);
2080 end;
2081 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2082 begin
2083 Name := 'edMaxLives';
2084 OnlyDigits := True;
2085 Width := 4;
2086 MaxLength := 5;
2087 if gsMaxLives > 0 then
2088 Text := IntToStr(gsMaxLives);
2089 end;
2090 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2091 begin
2092 Name := 'edItemRespawnTime';
2093 OnlyDigits := True;
2094 Width := 4;
2095 MaxLength := 5;
2096 if gsItemRespawnTime > 0 then
2097 Text := IntToStr(gsItemRespawnTime);
2098 end;
2099 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2100 begin
2101 Name := 'swPlayers';
2102 AddItem(_lc[I_MENU_COUNT_NONE]);
2103 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2104 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2105 ItemIndex := gsPlayers;
2106 end;
2107 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2108 begin
2109 Name := 'swTeamDamage';
2110 AddItem(_lc[I_MENU_YES]);
2111 AddItem(_lc[I_MENU_NO]);
2112 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2113 ItemIndex := 0
2114 else
2115 ItemIndex := 1;
2116 end;
2117 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
2118 begin
2119 Name := 'swTeamHit';
2120 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
2121 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
2122 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
2123 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
2124 if (gsGameFlags and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
2125 ItemIndex := 0
2126 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITTRACE) then
2127 ItemIndex := 1
2128 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITPROJECTILE) then
2129 ItemIndex := 2
2130 else
2131 ItemIndex := 3;
2132 end;
2133 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2134 begin
2135 Name := 'swDeathmatchKeys';
2136 AddItem(_lc[I_MENU_YES]);
2137 AddItem(_lc[I_MENU_NO]);
2138 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2139 ItemIndex := 0
2140 else
2141 ItemIndex := 1;
2142 end;
2143 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2144 begin
2145 Name := 'swEnableExits';
2146 AddItem(_lc[I_MENU_YES]);
2147 AddItem(_lc[I_MENU_NO]);
2148 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2149 ItemIndex := 0
2150 else
2151 ItemIndex := 1;
2152 end;
2153 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2154 begin
2155 Name := 'swWeaponStay';
2156 AddItem(_lc[I_MENU_YES]);
2157 AddItem(_lc[I_MENU_NO]);
2158 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2159 ItemIndex := 0
2160 else
2161 ItemIndex := 1;
2162 end;
2163 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2164 begin
2165 Name := 'swMonsters';
2166 AddItem(_lc[I_MENU_YES]);
2167 AddItem(_lc[I_MENU_NO]);
2168 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2169 ItemIndex := 0
2170 else
2171 ItemIndex := 1;
2172 end;
2173 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2174 begin
2175 Name := 'swBotsVS';
2176 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2177 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2178 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2179 ItemIndex := 2;
2180 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2181 ItemIndex := 0;
2182 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2183 ItemIndex := 1;
2184 end;
2185 AddSpace();
2186 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2188 ReAlign();
2189 end;
2190 Menu.DefControl := 'mNetServerMenu';
2191 g_GUI_AddWindow(Menu);
2193 Menu := TGUIWindow.Create('NetClientMenu');
2194 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2195 begin
2196 Name := 'mNetClientMenu';
2198 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2199 AddSpace();
2201 with AddEdit(_lc[I_NET_ADDRESS]) do
2202 begin
2203 Name := 'edIP';
2204 OnlyDigits :=False;
2205 Width := 12;
2206 MaxLength := 64;
2207 Text := 'localhost';
2208 end;
2209 with AddEdit(_lc[I_NET_PORT]) do
2210 begin
2211 Name := 'edPort';
2212 OnlyDigits := True;
2213 Width := 4;
2214 MaxLength := 5;
2215 Text := '25666';
2216 end;
2217 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2218 begin
2219 Name := 'edPW';
2220 OnlyDigits := False;
2221 Width := 12;
2222 MaxLength := 32;
2223 Text := '';
2224 end;
2226 AddSpace();
2227 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2229 ReAlign();
2230 end;
2231 Menu.DefControl := 'mNetClientMenu';
2232 g_GUI_AddWindow(Menu);
2234 Menu := TGUIWindow.Create('LoadMenu');
2235 Menu.OnShow := ProcLoadMenu;
2236 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2237 begin
2238 Name := 'mmLoadMenu';
2240 for a := 1 to 8 do
2241 with AddEdit('') do
2242 begin
2243 Name := 'edSlot'+IntToStr(a);
2244 Width := 16;
2245 MaxLength := 16;
2246 OnEnter := ProcLoadGame;
2247 end;
2248 end;
2249 Menu.DefControl := 'mmLoadMenu';
2250 g_GUI_AddWindow(Menu);
2252 Menu := TGUIWindow.Create('SaveMenu');
2253 Menu.OnShow := ProcSaveMenu;
2254 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2255 begin
2256 Name := 'mmSaveMenu';
2258 for a := 1 to 8 do
2259 with AddEdit('') do
2260 begin
2261 Name := 'edSlot'+IntToStr(a);
2262 Width := 16;
2263 MaxLength := 16;
2264 OnChange := ProcSaveGame;
2265 end;
2266 end;
2267 Menu.DefControl := 'mmSaveMenu';
2268 g_GUI_AddWindow(Menu);
2270 Menu := TGUIWindow.Create('CustomGameMenu');
2271 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2272 begin
2273 Name := 'mCustomGameMenu';
2274 with AddLabel(_lc[I_MENU_MAP]) do
2275 begin
2276 Name := 'lbMap';
2277 FixedLength := 16;
2278 Text := gsMap;
2279 OnClick := @ProcSelectMapMenu;
2280 end;
2281 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2282 begin
2283 Name := 'swGameMode';
2284 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2285 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2286 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2287 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2288 case g_Game_TextToMode(gsGameMode) of
2289 GM_NONE,
2290 GM_DM: ItemIndex := 0;
2291 GM_TDM: ItemIndex := 1;
2292 GM_CTF: ItemIndex := 2;
2293 GM_SINGLE,
2294 GM_COOP: ItemIndex := 3;
2295 end;
2296 OnChange := ProcSwitchMonstersCustom;
2297 end;
2298 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2299 begin
2300 Name := 'edTimeLimit';
2301 OnlyDigits := True;
2302 Width := 4;
2303 MaxLength := 5;
2304 if gsTimeLimit > 0 then
2305 Text := IntToStr(gsTimeLimit);
2306 end;
2307 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2308 begin
2309 Name := 'edGoalLimit';
2310 OnlyDigits := True;
2311 Width := 4;
2312 MaxLength := 5;
2313 if gsGoalLimit > 0 then
2314 Text := IntToStr(gsGoalLimit);
2315 end;
2316 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2317 begin
2318 Name := 'edMaxLives';
2319 OnlyDigits := True;
2320 Width := 4;
2321 MaxLength := 5;
2322 if gsMaxLives > 0 then
2323 Text := IntToStr(gsMaxLives);
2324 end;
2325 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2326 begin
2327 Name := 'edItemRespawnTime';
2328 OnlyDigits := True;
2329 Width := 4;
2330 MaxLength := 5;
2331 if gsItemRespawnTime > 0 then
2332 Text := IntToStr(gsItemRespawnTime);
2333 end;
2334 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2335 begin
2336 Name := 'swPlayers';
2337 AddItem(_lc[I_MENU_COUNT_NONE]);
2338 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2339 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2340 ItemIndex := gsPlayers;
2341 end;
2342 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2343 begin
2344 Name := 'swTeamDamage';
2345 AddItem(_lc[I_MENU_YES]);
2346 AddItem(_lc[I_MENU_NO]);
2347 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2348 ItemIndex := 0
2349 else
2350 ItemIndex := 1;
2351 end;
2352 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
2353 begin
2354 Name := 'swTeamHit';
2355 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
2356 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
2357 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
2358 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
2359 if (gsGameFlags and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
2360 ItemIndex := 0
2361 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITTRACE) then
2362 ItemIndex := 1
2363 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITPROJECTILE) then
2364 ItemIndex := 2
2365 else
2366 ItemIndex := 3;
2367 end;
2368 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2369 begin
2370 Name := 'swDeathmatchKeys';
2371 AddItem(_lc[I_MENU_YES]);
2372 AddItem(_lc[I_MENU_NO]);
2373 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2374 ItemIndex := 0
2375 else
2376 ItemIndex := 1;
2377 end;
2378 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2379 begin
2380 Name := 'swEnableExits';
2381 AddItem(_lc[I_MENU_YES]);
2382 AddItem(_lc[I_MENU_NO]);
2383 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2384 ItemIndex := 0
2385 else
2386 ItemIndex := 1;
2387 end;
2388 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2389 begin
2390 Name := 'swWeaponStay';
2391 AddItem(_lc[I_MENU_YES]);
2392 AddItem(_lc[I_MENU_NO]);
2393 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2394 ItemIndex := 0
2395 else
2396 ItemIndex := 1;
2397 end;
2398 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2399 begin
2400 Name := 'swMonsters';
2401 AddItem(_lc[I_MENU_YES]);
2402 AddItem(_lc[I_MENU_NO]);
2403 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2404 ItemIndex := 0
2405 else
2406 ItemIndex := 1;
2407 end;
2408 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2409 begin
2410 Name := 'swBotsVS';
2411 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2412 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2413 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2414 ItemIndex := 2;
2415 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2416 ItemIndex := 0;
2417 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2418 ItemIndex := 1;
2419 end;
2420 AddSpace();
2421 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2423 ReAlign();
2424 end;
2425 Menu.DefControl := 'mCustomGameMenu';
2426 g_GUI_AddWindow(Menu);
2428 Menu := TGUIWindow.Create('CampaignMenu');
2429 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2430 begin
2431 Name := 'mCampaignMenu';
2433 AddSpace();
2434 AddSpace();
2435 AddSpace();
2436 AddSpace();
2437 AddSpace();
2438 AddSpace();
2440 with AddFileList('', 15, 4) do
2441 begin
2442 Name := 'lsWAD';
2443 OnChange := ProcSelectCampaignWAD;
2445 Sort := True;
2446 Dirs := True;
2447 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2448 SetBase(MegawadDirs);
2449 end;
2451 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2452 begin
2453 Name := 'lbWADName';
2454 FixedLength := 8;
2455 Enabled := False;
2456 end;
2457 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2458 begin
2459 Name := 'lbWADAuthor';
2460 FixedLength := 8;
2461 Enabled := False;
2462 end;
2463 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2464 with AddMemo('', 15, 3) do
2465 begin
2466 Name := 'meWADDescription';
2467 Color := MENU_ITEMSCTRL_COLOR;
2468 end;
2469 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2470 begin
2471 Name := 'swPlayers';
2472 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2473 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2474 end;
2475 AddSpace();
2476 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2478 ReAlign();
2480 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2481 begin
2482 Name := 'mpWADImage';
2483 DefaultRes := 'NOPIC';
2484 X := GetControl('lsWAD').X+4;
2485 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2486 end;
2487 end;
2488 Menu.DefControl := 'mCampaignMenu';
2489 g_GUI_AddWindow(Menu);
2491 Menu := TGUIWindow.Create('SelectMapMenu');
2492 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2493 begin
2494 Name := 'mSelectMapMenu';
2495 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2496 begin
2497 Name := 'lsMapWAD';
2498 OnChange := ProcSelectWAD;
2500 Sort := True;
2501 Dirs := True;
2502 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2503 SetBase(MapDirs);
2504 end;
2505 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2506 begin
2507 Name := 'lsMapRes';
2508 Sort := True;
2509 OnChange := ProcSelectMap;
2510 end;
2511 AddSpace();
2512 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2513 begin
2514 Name := 'lbMapName';
2515 FixedLength := 24;
2516 Enabled := False;
2517 end;
2518 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2519 begin
2520 Name := 'lbMapAuthor';
2521 FixedLength := 16;
2522 Enabled := False;
2523 end;
2524 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2525 begin
2526 Name := 'lbMapSize';
2527 FixedLength := 10;
2528 Enabled := False;
2529 end;
2530 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 12, 4) do
2531 begin
2532 Name := 'meMapDescription';
2533 end;
2535 ReAlign();
2537 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2538 begin
2539 Name := 'mpMapPreview';
2540 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2541 Y := GetControl('lsMapWAD').Y;
2542 end;
2543 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2544 begin
2545 Name := 'lbMapScale';
2546 FixedLength := 8;
2547 Enabled := False;
2548 Color := MENU_ITEMSCTRL_COLOR;
2549 X := GetControl('lsMapWAD').X +
2550 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2551 2 + MAPPREVIEW_WIDTH*4;
2552 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2553 end;
2554 end;
2555 Menu.OnClose := ProcSetMap;
2556 Menu.DefControl := 'mSelectMapMenu';
2557 g_GUI_AddWindow(Menu);
2559 Menu := TGUIWindow.Create('OptionsMenu');
2560 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_OPTIONS]))) do
2561 begin
2562 Name := 'mmOptionsMenu';
2563 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2564 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2565 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2566 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2567 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2568 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2569 AddSpace();
2570 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2571 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2572 end;
2573 Menu.OnClose := ProcApplyOptions;
2574 Menu.DefControl := 'mmOptionsMenu';
2575 g_GUI_AddWindow(Menu);
2577 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2578 gMenuSmallFont, @ProcSavedMenuKeyDown);
2579 g_GUI_AddWindow(Menu);
2581 Menu := TGUIWindow.Create('OptionsVideoMenu');
2582 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2583 begin
2584 Name := 'mOptionsVideoMenu';
2585 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2586 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2587 begin
2588 Name := 'swBPP';
2589 AddItem('16');
2590 AddItem('32');
2591 end;
2592 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2593 begin
2594 Name := 'swVSync';
2595 AddItem(_lc[I_MENU_YES]);
2596 AddItem(_lc[I_MENU_NO]);
2597 end;
2598 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2599 begin
2600 Name := 'swTextureFilter';
2601 AddItem(_lc[I_MENU_YES]);
2602 AddItem(_lc[I_MENU_NO]);
2603 end;
2604 with AddSwitch(_lc[I_MENU_VIDEO_INTERPOLATION]) do
2605 begin
2606 Name := 'swInterp';
2607 AddItem(_lc[I_MENU_YES]);
2608 AddItem(_lc[I_MENU_NO]);
2609 end;
2610 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2611 begin
2612 Name := 'swLegacyNPOT';
2613 AddItem(_lc[I_MENU_NO]);
2614 AddItem(_lc[I_MENU_YES]);
2615 end;
2616 AddSpace();
2617 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2618 ReAlign();
2619 end;
2620 Menu.DefControl := 'mOptionsVideoMenu';
2621 g_GUI_AddWindow(Menu);
2623 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2624 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2625 begin
2626 Name := 'mOptionsVideoResMenu';
2627 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2628 begin
2629 Name := 'lbCurrentRes';
2630 FixedLength := 24;
2631 Enabled := False;
2632 end;
2633 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2634 begin
2635 Name := 'lsResolution';
2636 Sort := False;
2637 end;
2638 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2639 begin
2640 Name := 'swFullScreen';
2641 AddItem(_lc[I_MENU_YES]);
2642 AddItem(_lc[I_MENU_NO]);
2643 end;
2644 with AddSwitch(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2645 begin
2646 Name := 'swResFactor';
2647 AddItem('1x');
2648 for i := 2 to gRC_Width div 640 do
2649 AddItem(IntToStr(i) + 'x');
2650 end;
2651 AddSpace();
2652 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2653 UpdateIndex();
2654 end;
2655 Menu.DefControl := 'mOptionsVideoResMenu';
2656 g_GUI_AddWindow(Menu);
2658 Menu := TGUIWindow.Create('OptionsSoundMenu');
2659 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
2660 begin
2661 Name := 'mOptionsSoundMenu';
2662 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2663 begin
2664 Name := 'scMusicLevel';
2665 Max := 16;
2666 OnChange := ProcChangeSoundSettings;
2667 end;
2668 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2669 begin
2670 Name := 'scSoundLevel';
2671 Max := 16;
2672 OnChange := ProcChangeSoundSettings;
2673 end;
2674 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2675 begin
2676 Name := 'scMaxSimSounds';
2677 Max := 16;
2678 end;
2679 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2680 begin;
2681 Name := 'swAnnouncer';
2682 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2683 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2684 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2685 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2686 end;
2687 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2688 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2689 begin;
2690 Name := 'swSoundEffects';
2691 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2692 AddItem(_lc[I_MENU_COMPAT_DF]);
2693 end;
2694 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
2695 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
2696 begin;
2697 Name := 'swChatSpeech';
2698 AddItem(_lc[I_MENU_YES]);
2699 AddItem(_lc[I_MENU_NO]);
2700 end;
2701 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2702 begin
2703 Name := 'swInactiveSounds';
2704 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2705 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2706 end;
2707 ReAlign();
2708 end;
2709 Menu.DefControl := 'mOptionsSoundMenu';
2710 g_GUI_AddWindow(Menu);
2712 Menu := TGUIWindow.Create('OptionsGameMenu');
2713 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
2714 begin
2715 Name := 'mOptionsGameMenu';
2716 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2717 begin
2718 Name := 'scParticlesCount';
2719 Max := 20;
2720 end;
2721 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2722 begin
2723 Name := 'swBloodCount';
2724 AddItem(_lc[I_MENU_COUNT_NONE]);
2725 AddItem(_lc[I_MENU_COUNT_SMALL]);
2726 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2727 AddItem(_lc[I_MENU_COUNT_BIG]);
2728 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2729 end;
2730 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2731 begin
2732 Name := 'scShellsMax';
2733 Max := 20;
2734 end;
2735 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2736 begin
2737 Name := 'scGibsMax';
2738 Max := 20;
2739 end;
2740 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2741 begin
2742 Name := 'scCorpsesMax';
2743 Max := 20;
2744 end;
2745 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2746 begin
2747 Name := 'swGibsCount';
2748 AddItem(_lc[I_MENU_COUNT_NONE]);
2749 AddItem(_lc[I_MENU_COUNT_SMALL]);
2750 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2751 AddItem(_lc[I_MENU_COUNT_BIG]);
2752 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2753 end;
2754 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2755 begin
2756 Name := 'swCorpseType';
2757 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2758 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2759 end;
2760 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2761 begin
2762 Name := 'swGibsType';
2763 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2764 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2765 end;
2766 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2767 begin
2768 Name := 'swBloodType';
2769 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2770 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2771 end;
2772 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2773 begin
2774 Name := 'swScreenFlash';
2775 AddItem(_lc[I_MENU_NO]);
2776 AddItem(_lc[I_MENU_COMPAT_DF]);
2777 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2778 end;
2779 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2780 begin
2781 Name := 'swBackground';
2782 AddItem(_lc[I_MENU_YES]);
2783 AddItem(_lc[I_MENU_NO]);
2784 end;
2785 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2786 begin
2787 Name := 'swMessages';
2788 AddItem(_lc[I_MENU_YES]);
2789 AddItem(_lc[I_MENU_NO]);
2790 end;
2791 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2792 begin
2793 Name := 'swRevertPlayers';
2794 AddItem(_lc[I_MENU_YES]);
2795 AddItem(_lc[I_MENU_NO]);
2796 end;
2797 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2798 begin
2799 Name := 'swChatBubble';
2800 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2801 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2802 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2803 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2804 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2805 end;
2806 with AddSwitch(_lc[I_MENU_GAME_PLAYER_INDICATOR]) do
2807 begin
2808 Name := 'swPlayerIndicator';
2809 AddItem(_lc[I_MENU_GAME_INDICATOR_NONE]);
2810 AddItem(_lc[I_MENU_GAME_INDICATOR_OWN]);
2811 AddItem(_lc[I_MENU_GAME_INDICATOR_ALL]);
2812 end;
2813 with AddSwitch(_lc[I_MENU_GAME_INDICATOR_STYLE]) do
2814 begin
2815 Name := 'swPlayerIndicatorStyle';
2816 AddItem(_lc[I_MENU_GAME_INDICATOR_ARROW]);
2817 AddItem(_lc[I_MENU_GAME_INDICATOR_NAME]);
2818 end;
2819 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2820 begin
2821 Name := 'scScaleFactor';
2822 Max := 10;
2823 OnChange := ProcChangeGameSettings;
2824 end;
2825 ReAlign();
2826 end;
2827 Menu.DefControl := 'mOptionsGameMenu';
2828 g_GUI_AddWindow(Menu);
2830 Menu := TGUIWindow.Create('OptionsControlsMenu');
2831 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
2832 begin
2833 Name := 'mOptionsControlsMenu';
2834 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
2835 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
2836 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
2837 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
2838 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
2839 AddSpace();
2840 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
2841 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
2842 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
2843 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
2844 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
2845 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
2846 if e_HasJoysticks then
2847 begin
2848 AddSpace();
2849 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
2850 end;
2851 if g_touch_enabled then
2852 begin
2853 AddSpace();
2854 AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
2855 end;
2856 end;
2857 Menu.DefControl := 'mOptionsControlsMenu';
2858 g_GUI_AddWindow(Menu);
2860 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
2861 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
2862 begin
2863 Name := 'mOptionsControlsP1Menu';
2864 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2865 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2866 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2867 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2868 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2869 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2870 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2871 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2872 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2873 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2874 end;
2875 Menu.DefControl := 'mOptionsControlsP1Menu';
2876 g_GUI_AddWindow(Menu);
2878 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
2879 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
2880 begin
2881 Name := 'mOptionsControlsP1MenuWeapons';
2882 for i := WP_FIRST to WP_LAST do
2883 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2884 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2885 end;
2886 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
2887 g_GUI_AddWindow(Menu);
2889 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
2890 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
2891 begin
2892 Name := 'mOptionsControlsP2Menu';
2893 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2894 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2895 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2896 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2897 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2898 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2899 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2900 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2901 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2902 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2903 end;
2904 Menu.DefControl := 'mOptionsControlsP2Menu';
2905 g_GUI_AddWindow(Menu);
2907 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
2908 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
2909 begin
2910 Name := 'mOptionsControlsP2MenuWeapons';
2911 for i := WP_FIRST to WP_LAST do
2912 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2913 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2914 end;
2915 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
2916 g_GUI_AddWindow(Menu);
2918 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
2919 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
2920 begin
2921 Name := 'mOptionsControlsJoystickMenu';
2922 for i := 0 to e_MaxJoys - 1 do
2923 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
2924 begin
2925 Name := 'scDeadzone' + IntToStr(i);
2926 Max := 20
2927 end
2928 end;
2929 Menu.DefControl := 'mOptionsControlsJoystickMenu';
2930 g_GUI_AddWindow(Menu);
2932 Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
2933 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do
2934 begin
2935 Name := 'mOptionsControlsTouchMenu';
2936 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
2937 begin
2938 Name := 'swTouchAlt';
2939 AddItem(_lc[I_MENU_NO]);
2940 AddItem(_lc[I_MENU_YES]);
2941 OnChange := ProcChangeTouchSettings;
2942 end;
2943 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
2944 begin
2945 Name := 'scTouchSize';
2946 Max := 20;
2947 OnChange := ProcChangeTouchSettings;
2948 end;
2949 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
2950 begin
2951 Name := 'swTouchFire';
2952 AddItem(_lc[I_MENU_NO]);
2953 AddItem(_lc[I_MENU_YES]);
2954 end;
2955 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do
2956 begin
2957 Name := 'scTouchOffset';
2958 Max := 20;
2959 OnChange := ProcChangeTouchSettings;
2960 end;
2961 end;
2962 Menu.DefControl := 'mOptionsControlsTouchMenu';
2963 g_GUI_AddWindow(Menu);
2965 Menu := TGUIWindow.Create('OptionsPlayersMenu');
2966 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
2967 begin
2968 Name := 'mOptionsPlayersMenu';
2969 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
2970 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
2971 end;
2972 Menu.DefControl := 'mOptionsPlayersMenu';
2973 g_GUI_AddWindow(Menu);
2975 CreatePlayerOptionsMenu('P1');
2976 CreatePlayerOptionsMenu('P2');
2978 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
2979 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
2980 begin
2981 Name := 'mOptionsPlayersMIMenu';
2982 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
2983 begin
2984 Name := 'lbName';
2985 FixedLength := 16;
2986 end;
2987 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
2988 begin
2989 Name := 'lbAuthor';
2990 FixedLength := 16;
2991 end;
2992 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
2993 begin
2994 Name := 'meComment';
2995 end;
2996 AddSpace();
2997 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
2998 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
2999 begin
3000 Name := 'lbWeapon';
3001 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
3002 end;
3003 ReAlign();
3004 end;
3005 Menu.DefControl := 'mOptionsPlayersMIMenu';
3006 g_GUI_AddWindow(Menu);
3008 Menu := TGUIWindow.Create('OptionsLanguageMenu');
3009 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
3010 begin
3011 Name := 'mOptionsLanguageMenu';
3012 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
3013 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
3014 ReAlign();
3015 end;
3016 Menu.DefControl := 'mOptionsLanguageMenu';
3017 g_GUI_AddWindow(Menu);
3019 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
3020 gMenuSmallFont, @ProcDefaultMenuKeyDown);
3021 g_GUI_AddWindow(Menu);
3023 Menu := TGUIWindow.Create('AuthorsMenu');
3024 Menu.BackTexture := 'INTER';
3025 Menu.OnClose := ProcAuthorsClose;
3027 // Çàãîëîâîê:
3028 _y := 16;
3029 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
3030 begin
3031 Color := _RGB(255, 0, 0);
3032 X := (gScreenWidth div 2)-(GetWidth() div 2);
3033 Y := _y;
3034 _y := _y+GetHeight();
3035 end;
3036 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
3037 begin
3038 Color := _RGB(255, 0, 0);
3039 X := (gScreenWidth div 2)-(GetWidth() div 2);
3040 Y := _y;
3041 _y := _y+GetHeight()+32;
3042 end;
3043 // ×òî äåëàë: Êòî äåëàë
3044 cx := gScreenWidth div 2 - 320 + 64;
3045 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
3046 begin
3047 Color := _RGB(255, 0, 0);
3048 X := cx;
3049 Y := _y;
3050 _y := _y+22;
3051 end;
3052 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
3053 begin
3054 Color := _RGB(255, 255, 255);
3055 X := cx+32;
3056 Y := _y;
3057 _y := _y+36;
3058 end;
3059 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
3060 begin
3061 Color := _RGB(255, 0, 0);
3062 X := cx;
3063 Y := _y;
3064 _y := _y+22;
3065 end;
3066 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
3067 begin
3068 Color := _RGB(255, 255, 255);
3069 X := cx+32;
3070 Y := _y;
3071 _y := _y+22;
3072 end;
3073 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
3074 begin
3075 Color := _RGB(255, 255, 255);
3076 X := cx+32;
3077 Y := _y;
3078 _y := _y+36;
3079 end;
3080 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
3081 begin
3082 Color := _RGB(255, 0, 0);
3083 X := cx;
3084 Y := _y;
3085 _y := _y+22;
3086 end;
3087 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
3088 begin
3089 Color := _RGB(255, 255, 255);
3090 X := cx+32;
3091 Y := _y;
3092 _y := _y+36;
3093 end;
3094 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
3095 begin
3096 Color := _RGB(255, 0, 0);
3097 X := cx;
3098 Y := _y;
3099 _y := _y+22;
3100 end;
3101 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
3102 begin
3103 Color := _RGB(255, 255, 255);
3104 X := cx+32;
3105 Y := _y;
3106 _y := gScreenHeight - 128;
3107 end;
3108 // Çàêëþ÷åíèå:
3109 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
3110 begin
3111 Color := _RGB(255, 0, 0);
3112 X := cx;
3113 Y := _y;
3114 _y := _y+16;
3115 end;
3116 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
3117 begin
3118 Color := _RGB(255, 255, 255);
3119 X := cx+32;
3120 Y := _y;
3121 _y := _y+GetHeight();
3122 end;
3123 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
3124 begin
3125 Color := _RGB(255, 255, 255);
3126 X := cx+32;
3127 Y := _y;
3128 _y := _y+GetHeight();
3129 end;
3130 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
3131 begin
3132 Color := _RGB(255, 255, 255);
3133 X := cx+32;
3134 Y := _y;
3135 _y := gScreenHeight - 32;
3136 end;
3137 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
3138 begin
3139 Color := _RGB(255, 0, 0);
3140 X := gScreenWidth div 2 - GetWidth() div 2;
3141 Y := _y;
3142 end;
3143 g_GUI_AddWindow(Menu);
3145 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
3146 gMenuSmallFont, @ProcExitMenuKeyDown);
3147 g_GUI_AddWindow(Menu);
3149 Menu := TGUIWindow.Create('GameSingleMenu');
3150 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3151 begin
3152 Name := 'mmGameSingleMenu';
3153 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3154 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3155 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3156 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3157 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3158 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3159 end;
3160 Menu.DefControl := 'mmGameSingleMenu';
3161 Menu.MainWindow := True;
3162 Menu.OnClose := ProcGMClose;
3163 Menu.OnShow := ProcGMShow;
3164 g_GUI_AddWindow(Menu);
3166 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
3167 gMenuSmallFont, @ProcEndMenuKeyDown);
3168 g_GUI_AddWindow(Menu);
3170 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
3171 gMenuSmallFont, @ProcRestartMenuKeyDown);
3172 g_GUI_AddWindow(Menu);
3174 Menu := TGUIWindow.Create('GameCustomMenu');
3175 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3176 begin
3177 Name := 'mmGameCustomMenu';
3178 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3179 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3180 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3181 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3182 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3183 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3184 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3185 end;
3186 Menu.DefControl := 'mmGameCustomMenu';
3187 Menu.MainWindow := True;
3188 Menu.OnClose := ProcGMClose;
3189 Menu.OnShow := ProcGMShow;
3190 g_GUI_AddWindow(Menu);
3192 Menu := TGUIWindow.Create('GameServerMenu');
3193 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3194 begin
3195 Name := 'mmGameServerMenu';
3196 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3197 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3198 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3199 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3200 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3201 end;
3202 Menu.DefControl := 'mmGameServerMenu';
3203 Menu.MainWindow := True;
3204 Menu.OnClose := ProcGMClose;
3205 Menu.OnShow := ProcGMShow;
3206 g_GUI_AddWindow(Menu);
3208 Menu := TGUIWindow.Create('GameClientMenu');
3209 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3210 begin
3211 Name := 'mmGameClientMenu';
3212 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3213 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3214 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3215 end;
3216 Menu.DefControl := 'mmGameClientMenu';
3217 Menu.MainWindow := True;
3218 Menu.OnClose := ProcGMClose;
3219 Menu.OnShow := ProcGMShow;
3220 g_GUI_AddWindow(Menu);
3222 Menu := TGUIWindow.Create('ClientPasswordMenu');
3223 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
3224 begin
3225 Name := 'mClientPasswordMenu';
3226 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3227 begin
3228 Name := 'edPW';
3229 Width := 12;
3230 MaxLength := 32;
3231 end;
3232 AddSpace;
3234 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3235 ReAlign();
3236 end;
3237 Menu.DefControl := 'mClientPasswordMenu';
3238 g_GUI_AddWindow(Menu);
3240 Menu := TGUIWindow.Create('GameSetGameMenu');
3241 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3242 begin
3243 Name := 'mGameSetGameMenu';
3244 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3245 begin
3246 Name := 'swTeamDamage';
3247 AddItem(_lc[I_MENU_YES]);
3248 AddItem(_lc[I_MENU_NO]);
3249 ItemIndex := 1;
3250 end;
3251 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
3252 begin
3253 Name := 'swTeamHit';
3254 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
3255 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
3256 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
3257 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
3258 ItemIndex := 0
3259 end;
3260 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
3261 begin
3262 Name := 'swDeathmatchKeys';
3263 AddItem(_lc[I_MENU_YES]);
3264 AddItem(_lc[I_MENU_NO]);
3265 ItemIndex := 1;
3266 end;
3267 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3268 begin
3269 Name := 'edTimeLimit';
3270 OnlyDigits := True;
3271 Width := 4;
3272 MaxLength := 5;
3273 end;
3274 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
3275 begin
3276 Name := 'edGoalLimit';
3277 OnlyDigits := True;
3278 Width := 4;
3279 MaxLength := 5;
3280 end;
3281 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3282 begin
3283 Name := 'edMaxLives';
3284 OnlyDigits := True;
3285 Width := 4;
3286 MaxLength := 5;
3287 end;
3288 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3289 begin
3290 Name := 'swBotsVS';
3291 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3292 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3293 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3294 ItemIndex := 2;
3295 end;
3297 ReAlign();
3298 end;
3299 Menu.DefControl := 'mGameSetGameMenu';
3300 Menu.OnClose := ProcApplyGameSet;
3301 g_GUI_AddWindow(Menu);
3303 Menu := TGUIWindow.Create('TeamMenu');
3304 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_CHANGE_PLAYERS]))) do
3305 begin
3306 Name := 'mmTeamMenu';
3307 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3308 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3309 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3310 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3311 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3312 end;
3313 Menu.DefControl := 'mmTeamMenu';
3314 Menu.OnShow := ProcChangePlayers;
3315 g_GUI_AddWindow(Menu);
3316 end;
3318 procedure g_Menu_Show_SaveMenu();
3319 begin
3320 if g_Game_IsTestMap then
3321 Exit;
3322 if gGameSettings.GameType = GT_SINGLE then
3323 g_GUI_ShowWindow('GameSingleMenu')
3324 else
3325 begin
3326 if g_Game_IsClient then
3327 Exit
3328 else
3329 if g_Game_IsNet then
3330 Exit
3331 else
3332 g_GUI_ShowWindow('GameCustomMenu');
3333 end;
3334 g_GUI_ShowWindow('SaveMenu');
3335 g_Sound_PlayEx('MENU_OPEN');
3336 end;
3338 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3339 begin
3340 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3341 if gGameSettings.GameType = GT_SINGLE then
3342 begin
3343 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3344 end
3345 else
3346 begin
3347 if g_Game_IsClient then exit;
3348 if g_Game_IsNet then exit;
3349 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3350 end;
3351 g_GUI_ShowWindow('LoadMenu');
3352 g_Sound_PlayEx('MENU_OPEN');
3353 end;
3355 procedure g_Menu_Show_GameSetGame();
3356 begin
3357 if gGameSettings.GameType = GT_SINGLE then
3358 g_GUI_ShowWindow('GameSingleMenu')
3359 else
3360 begin
3361 if g_Game_IsClient then
3362 Exit
3363 else
3364 if g_Game_IsNet then
3365 g_GUI_ShowWindow('GameServerMenu')
3366 else
3367 g_GUI_ShowWindow('GameCustomMenu');
3368 end;
3369 ReadGameSettings();
3370 g_GUI_ShowWindow('GameSetGameMenu');
3371 g_Sound_PlayEx('MENU_OPEN');
3372 end;
3374 procedure g_Menu_Show_OptionsVideo();
3375 begin
3376 if gGameSettings.GameType = GT_SINGLE then
3377 g_GUI_ShowWindow('GameSingleMenu')
3378 else
3379 begin
3380 if g_Game_IsClient then
3381 g_GUI_ShowWindow('GameClientMenu')
3382 else
3383 if g_Game_IsNet then
3384 g_GUI_ShowWindow('GameServerMenu')
3385 else
3386 g_GUI_ShowWindow('GameCustomMenu');
3387 end;
3388 ReadOptions();
3389 g_GUI_ShowWindow('OptionsMenu');
3390 g_GUI_ShowWindow('OptionsVideoMenu');
3391 g_Sound_PlayEx('MENU_OPEN');
3392 end;
3394 procedure g_Menu_Show_OptionsSound();
3395 begin
3396 if gGameSettings.GameType = GT_SINGLE then
3397 g_GUI_ShowWindow('GameSingleMenu')
3398 else
3399 begin
3400 if g_Game_IsClient then
3401 g_GUI_ShowWindow('GameClientMenu')
3402 else
3403 if g_Game_IsNet then
3404 g_GUI_ShowWindow('GameServerMenu')
3405 else
3406 g_GUI_ShowWindow('GameCustomMenu');
3407 end;
3408 ReadOptions();
3409 g_GUI_ShowWindow('OptionsMenu');
3410 g_GUI_ShowWindow('OptionsSoundMenu');
3411 g_Sound_PlayEx('MENU_OPEN');
3412 end;
3414 procedure g_Menu_Show_EndGameMenu();
3415 begin
3416 g_GUI_ShowWindow('EndGameMenu');
3417 g_Sound_PlayEx('MENU_OPEN');
3418 end;
3420 procedure g_Menu_Show_QuitGameMenu();
3421 begin
3422 g_GUI_ShowWindow('ExitMenu');
3423 g_Sound_PlayEx('MENU_OPEN');
3424 end;
3426 procedure g_Menu_Init();
3427 begin
3428 MenuLoadData();
3429 CreateAllMenus();
3430 end;
3432 procedure g_Menu_Free();
3433 begin
3434 MenuFreeData();
3435 end;
3437 procedure g_Menu_Reset();
3438 var
3439 ex: Boolean;
3440 begin
3441 g_GUI_SaveMenuPos();
3442 ex := g_GUI_Destroy();
3444 if ex then
3445 begin
3446 e_WriteLog('Recreating menu...', TMsgType.Notify);
3448 CreateAllMenus();
3450 if gDebugMode then
3451 g_Game_SetDebugMode();
3453 g_GUI_LoadMenuPos();
3454 end;
3455 end;
3457 end.