DEADSOFTWARE

Added new OpenGL ES wrapper
[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, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *)
16 {$INCLUDE ../shared/a_modes.inc}
17 unit g_menu;
19 interface
21 procedure g_Menu_Init();
22 procedure g_Menu_Free();
23 procedure g_Menu_Reset();
24 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
25 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
26 procedure g_Menu_AskLanguage();
28 procedure g_Menu_Show_SaveMenu();
29 procedure g_Menu_Show_LoadMenu(standalone: Boolean=false);
30 procedure g_Menu_Show_GameSetGame();
31 procedure g_Menu_Show_OptionsVideo();
32 procedure g_Menu_Show_OptionsSound();
33 procedure g_Menu_Show_EndGameMenu();
34 procedure g_Menu_Show_QuitGameMenu();
36 var
37 gMenuFont: DWORD;
38 gMenuSmallFont: DWORD;
39 PromptIP: string;
40 PromptPort: Word;
42 implementation
44 uses
45 {$INCLUDE ../nogl/noGLuses.inc}
46 g_gui, g_textures, e_graphics, g_main, g_window, g_game, g_map,
47 g_basic, g_console, g_sound, g_gfx, g_player, g_options, g_weapons,
48 e_log, SysUtils, CONFIG, g_playermodel, DateUtils, sdl2,
49 MAPDEF, Math, g_saveload,
50 e_texture, g_language,
51 g_net, g_netmsg, g_netmaster, g_items, e_input, g_touch,
52 utils, wadreader;
55 type TYNCallback = procedure (yes:Boolean);
57 procedure YNKeyDownProc (win: TGUIWindow; Key: Byte);
58 begin
59 if win.UserData = nil then exit;
60 case Key of
61 IK_Y, IK_SPACE: TYNCallback(win.UserData)(true);
62 IK_N: TYNCallback(win.UserData)(false);
63 end;
64 end;
66 procedure YesButtonCB (ctl: TGUITextButton);
67 begin
68 if ctl.UserData = nil then exit;
69 TYNCallback(ctl.UserData)(true);
70 end;
72 procedure NoButtonCB (ctl: TGUITextButton);
73 begin
74 if ctl.UserData = nil then exit;
75 TYNCallback(ctl.UserData)(false);
76 end;
78 function CreateYNMenu (WinName, Text: String; MaxLen: Word; FontID: DWORD; ActionProc: TYNCallback): TGUIWindow;
79 var
80 menu: TGUIMenu;
81 begin
82 //if length(Text) = 0 then exit;
83 Result := TGUIWindow.Create(WinName);
84 with Result do
85 begin
86 //OnKeyDownEx := @YNKeyDownProc;
87 //UserData := @ActionProc;
88 menu := TGUIMenu(Result.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, '')));
89 with menu do
90 begin
91 Name := '__temp_yes_no_menu:'+WinName;
92 YesNo := true;
93 AddText(Text, MaxLen);
94 with AddButton(nil, _lc[I_MENU_YES]) do begin ProcEx := @YesButtonCB; UserData := @ActionProc; end;
95 with AddButton(nil, _lc[I_MENU_NO]) do begin ProcEx := @NoButtonCB; UserData := @ActionProc; end;
96 end;
97 DefControl := '__temp_yes_no_menu:'+WinName;
98 SetActive(nil);
99 end;
100 end;
103 procedure ProcChangeColor(Sender: TGUIControl); forward;
104 procedure ProcSelectModel(Sender: TGUIControl); forward;
106 procedure ProcApplyOptions();
107 var
108 menu: TGUIMenu;
109 i: Integer;
110 ovs: Boolean;
111 begin
112 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
114 if TGUISwitch(menu.GetControl('swBPP')).ItemIndex = 0 then
115 gBPP := 16
116 else
117 gBPP := 32;
119 ovs := gVSync;
120 gVSync := TGUISwitch(menu.GetControl('swVSync')).ItemIndex = 0;
121 if (ovs <> gVSync) then g_SetVSync(gVSync);
123 gTextureFilter := TGUISwitch(menu.GetControl('swTextureFilter')).ItemIndex = 0;
124 glLegacyNPOT := not (TGUISwitch(menu.GetControl('swLegacyNPOT')).ItemIndex = 0);
126 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
128 g_Sound_SetupAllVolumes(
129 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
130 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
131 );
133 gMaxSimSounds := Max(Min(TGUIScroll(menu.GetControl('scMaxSimSounds')).Value*4+2, 66), 2);
134 gMuteWhenInactive := TGUISwitch(menu.GetControl('swInactiveSounds')).ItemIndex = 1;
135 gAnnouncer := TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex;
136 gSoundEffectsDF := TGUISwitch(menu.GetControl('swSoundEffects')).ItemIndex = 1;
137 gUseChatSounds := TGUISwitch(menu.GetControl('swChatSpeech')).ItemIndex = 0;
139 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
141 g_GFX_SetMax(TGUIScroll(menu.GetControl('scParticlesCount')).Value*1000);
142 g_Shells_SetMax(TGUIScroll(menu.GetControl('scShellsMax')).Value*30);
143 g_Gibs_SetMax(TGUIScroll(menu.GetControl('scGibsMax')).Value*25);
144 g_Corpses_SetMax(TGUIScroll(menu.GetControl('scCorpsesMax')).Value*5);
146 case TGUISwitch(menu.GetControl('swGibsCount')).ItemIndex of
147 0: gGibsCount := 0;
148 1: gGibsCount := 8;
149 2: gGibsCount := 16;
150 3: gGibsCount := 32;
151 else gGibsCount := 48;
152 end;
154 gBloodCount := TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex;
155 gFlash := TGUISwitch(menu.GetControl('swScreenFlash')).ItemIndex;
156 gAdvBlood := TGUISwitch(menu.GetControl('swBloodType')).ItemIndex = 1;
157 gAdvCorpses := TGUISwitch(menu.GetControl('swCorpseType')).ItemIndex = 1;
158 gAdvGibs := TGUISwitch(menu.GetControl('swGibsType')).ItemIndex = 1;
159 gDrawBackGround := TGUISwitch(menu.GetControl('swBackGround')).ItemIndex = 0;
160 gShowMessages := TGUISwitch(menu.GetControl('swMessages')).ItemIndex = 0;
161 gRevertPlayers := TGUISwitch(menu.GetControl('swRevertPlayers')).ItemIndex = 0;
162 gChatBubble := TGUISwitch(menu.GetControl('swChatBubble')).ItemIndex;
163 g_dbg_scale := TGUIScroll(menu.GetControl('scScaleFactor')).Value + 1;
165 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
167 with menu, gGameControls.GameControls do
168 begin
169 TakeScreenshot := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_SCREENSHOT])).Key;
170 Stat := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STAT])).Key;
171 Chat := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_CHAT])).Key;
172 TeamChat := TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_TEAMCHAT])).Key;
173 end;
175 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
176 with menu, gGameControls.P1Control do
177 begin
178 KeyRight := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0;
179 KeyLeft := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0;
180 KeyUp := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0;
181 KeyDown := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0;
182 KeyFire := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0;
183 KeyJump := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0;
184 KeyNextWeapon := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0;
185 KeyPrevWeapon := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0;
186 KeyOpen := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0;
187 KeyStrafe := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0;
188 // second set
189 KeyRight2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1;
190 KeyLeft2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1;
191 KeyUp2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1;
192 KeyDown2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1;
193 KeyFire2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1;
194 KeyJump2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1;
195 KeyNextWeapon2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1;
196 KeyPrevWeapon2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1;
197 KeyOpen2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1;
198 KeyStrafe2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1;
199 end;
201 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
202 with menu, gGameControls.P1Control do
203 begin
204 for i := WP_FIRST to WP_LAST do
205 begin
206 KeyWeapon[i] := TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0;
207 KeyWeapon2[i] := TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1;
208 end;
209 end;
211 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
212 with menu, gGameControls.P2Control do
213 begin
214 KeyRight := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0;
215 KeyLeft := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0;
216 KeyUp := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0;
217 KeyDown := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0;
218 KeyFire := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0;
219 KeyJump := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0;
220 KeyNextWeapon := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0;
221 KeyPrevWeapon := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0;
222 KeyOpen := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0;
223 KeyStrafe := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0;
224 // second set
225 KeyRight2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1;
226 KeyLeft2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1;
227 KeyUp2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1;
228 KeyDown2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1;
229 KeyFire2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1;
230 KeyJump2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1;
231 KeyNextWeapon2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1;
232 KeyPrevWeapon2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1;
233 KeyOpen2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1;
234 KeyStrafe2 := TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1;
235 end;
237 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
238 with menu, gGameControls.P2Control do
239 begin
240 for i := WP_FIRST to WP_LAST do
241 begin
242 KeyWeapon[i] := TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0;
243 KeyWeapon2[i] := TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1;
244 end;
245 end;
247 if e_JoysticksAvailable > 0 then
248 begin
249 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
250 with menu do
251 begin
252 for i := 0 to e_JoysticksAvailable-1 do
253 e_JoystickDeadzones[i] := TGUIScroll(menu.GetControl('scDeadzone' + IntToStr(i))).Value*(32767 div 20);
254 end;
255 end;
257 if g_touch_enabled then
258 begin
259 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
260 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
261 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
262 g_touch_fire := TGUISwitch(menu.GetControl('swTouchFire')).ItemIndex = 1;
263 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
264 end;
266 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
268 gPlayer1Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP1Name')).Text);
269 gPlayer1Settings.Team := IfThen(TGUISwitch(menu.GetControl('swP1Team')).ItemIndex = 0,
270 TEAM_RED, TEAM_BLUE);
272 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mvP1Model')) do
273 begin
274 gPlayer1Settings.Model := Model.Name;
275 gPlayer1Settings.Color := Model.Color;
276 end;
278 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
280 gPlayer2Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP2Name')).Text);
281 gPlayer2Settings.Team := IfThen(TGUISwitch(menu.GetControl('swP2Team')).ItemIndex = 0,
282 TEAM_RED, TEAM_BLUE);
283 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mvP2Model')) do
284 begin
285 gPlayer2Settings.Model := Model.Name;
286 gPlayer2Settings.Color := Model.Color;
287 end;
289 if gPlayer1Settings.Name = '' then gPlayer1Settings.Name := 'Player1';
290 if gPlayer2Settings.Name = '' then gPlayer2Settings.Name := 'Player2';
292 if g_Game_IsServer then
293 begin
294 if gPlayer1 <> nil then
295 begin
296 gPlayer1.SetModel(gPlayer1Settings.Model);
297 gPlayer1.Name := gPlayer1Settings.Name;
298 if not (gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
299 gPlayer1.SetColor(gPlayer1Settings.Color)
300 else
301 if gPlayer1.Team <> gPlayer1Settings.Team then
302 gPlayer1.SwitchTeam;
304 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
305 end;
307 if gPlayer2 <> nil then
308 begin
309 gPlayer2.SetModel(gPlayer2Settings.Model);
310 gPlayer2.Name := gPlayer2Settings.Name;
311 if (gGameSettings.GameMode <> GM_TDM) and (gGameSettings.GameMode <> GM_CTF) then
312 gPlayer2.SetColor(gPlayer2Settings.Color)
313 else
314 if gPlayer2.Team <> gPlayer2Settings.Team then
315 gPlayer2.SwitchTeam;
316 end;
317 end;
319 if g_Game_IsClient then MC_SEND_PlayerSettings;
321 g_Options_Write(GameDir+'/'+CONFIG_FILENAME);
322 end;
324 procedure ReadOptions();
325 var
326 menu: TGUIMenu;
327 i: Integer;
328 begin
329 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
331 with TGUISwitch(menu.GetControl('swBPP')) do
332 if gBPP = 16 then
333 ItemIndex := 0
334 else
335 ItemIndex := 1;
337 with TGUISwitch(menu.GetControl('swTextureFilter')) do
338 if gTextureFilter then ItemIndex := 0 else ItemIndex := 1;
340 with TGUISwitch(menu.GetControl('swVSync')) do
341 if gVSync then ItemIndex := 0 else ItemIndex := 1;
343 with TGUISwitch(menu.GetControl('swLegacyNPOT')) do
344 if not glLegacyNPOT then ItemIndex := 0 else ItemIndex := 1;
346 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
348 TGUIScroll(menu.GetControl('scSoundLevel')).Value := Round(gSoundLevel/16);
349 TGUIScroll(menu.GetControl('scMusicLevel')).Value := Round(gMusicLevel/16);
350 TGUIScroll(menu.GetControl('scMaxSimSounds')).Value := Round((gMaxSimSounds-2)/4);
352 with TGUISwitch(menu.GetControl('swInactiveSounds')) do
353 if gMuteWhenInactive then
354 ItemIndex := 1
355 else
356 ItemIndex := 0;
358 TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex := gAnnouncer;
360 with TGUISwitch(menu.GetControl('swSoundEffects')) do
361 if gSoundEffectsDF then
362 ItemIndex := 1
363 else
364 ItemIndex := 0;
366 with TGUISwitch(menu.GetControl('swChatSpeech')) do
367 if gUseChatSounds then
368 ItemIndex := 0
369 else
370 ItemIndex := 1;
372 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
373 with menu, gGameControls.P1Control do
374 begin
375 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0 := KeyRight;
376 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0 := KeyLeft;
377 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0 := KeyUp;
378 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := KeyDown;
379 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := KeyFire;
380 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := KeyJump;
381 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := KeyNextWeapon;
382 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := KeyPrevWeapon;
383 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := KeyOpen;
384 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := KeyStrafe;
385 // second set
386 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := KeyRight2;
387 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := KeyLeft2;
388 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1 := KeyUp2;
389 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := KeyDown2;
390 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := KeyFire2;
391 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := KeyJump2;
392 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := KeyNextWeapon2;
393 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := KeyPrevWeapon2;
394 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := KeyOpen2;
395 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := KeyStrafe2;
396 end;
398 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
399 with menu, gGameControls.P1Control do
400 begin
401 for i := WP_FIRST to WP_LAST do
402 begin
403 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0 := KeyWeapon[i];
404 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1 := KeyWeapon2[i];
405 end;
406 end;
408 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
409 with menu, gGameControls.P2Control do
410 begin
411 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0 := KeyRight;
412 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0 := KeyLeft;
413 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0 := KeyUp;
414 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := KeyDown;
415 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := KeyFire;
416 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := KeyJump;
417 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := KeyNextWeapon;
418 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := KeyPrevWeapon;
419 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := KeyOpen;
420 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := KeyStrafe;
421 // second set
422 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := KeyRight2;
423 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := KeyLeft2;
424 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1 := KeyUp2;
425 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := KeyDown2;
426 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := KeyFire2;
427 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := KeyJump2;
428 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := KeyNextWeapon2;
429 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := KeyPrevWeapon2;
430 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := KeyOpen2;
431 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := KeyStrafe2;
432 end;
434 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
435 with menu, gGameControls.P2Control do
436 begin
437 for i := WP_FIRST to WP_LAST do
438 begin
439 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0 := KeyWeapon[i];
440 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1 := KeyWeapon2[i];
441 end;
442 end;
444 if e_JoysticksAvailable > 0 then
445 begin
446 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
447 with menu do
448 begin
449 for i := 0 to e_JoysticksAvailable-1 do
450 TGUIScroll(menu.GetControl('scDeadzone' + IntToStr(i))).Value := e_JoystickDeadzones[i] div (32767 div 20);
451 end;
452 end;
454 if g_touch_enabled then
455 begin
456 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
457 with TGUISwitch(menu.GetControl('swTouchAlt')) do
458 if g_touch_alt then ItemIndex := 1 else ItemIndex := 0;
459 TGUIScroll(menu.GetControl('scTouchSize')).Value := Round((g_touch_size - 0.5) * 10);
460 with TGUISwitch(menu.GetControl('swTouchFire')) do
461 if g_touch_fire then ItemIndex := 1 else ItemIndex := 0;
462 TGUIScroll(menu.GetControl('scTouchOffset')).Value := Round(g_touch_offset / 5);
463 end;
465 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
466 with menu, gGameControls.GameControls do
467 begin
468 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_SCREENSHOT])).Key := TakeScreenshot;
469 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STAT])).Key := Stat;
470 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_CHAT])).Key := Chat;
471 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_TEAMCHAT])).Key := TeamChat;
472 end;
474 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
476 TGUIScroll(menu.GetControl('scParticlesCount')).Value := g_GFX_GetMax() div 1000;
477 TGUIScroll(menu.GetControl('scShellsMax')).Value := g_Shells_GetMax() div 30;
478 TGUIScroll(menu.GetControl('scGibsMax')).Value := g_Gibs_GetMax() div 25;
479 TGUIScroll(menu.GetControl('scCorpsesMax')).Value := g_Corpses_GetMax() div 5;
480 TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex := gBloodCount;
482 with TGUISwitch(menu.GetControl('swScreenFlash')) do
483 ItemIndex := gFlash;
485 with TGUISwitch(menu.GetControl('swBloodType')) do
486 if gAdvBlood then ItemIndex := 1 else ItemIndex := 0;
488 with TGUISwitch(menu.GetControl('swCorpseType')) do
489 if gAdvCorpses then ItemIndex := 1 else ItemIndex := 0;
491 with TGUISwitch(menu.GetControl('swGibsType')) do
492 if gAdvGibs then ItemIndex := 1 else ItemIndex := 0;
494 with TGUISwitch(menu.GetControl('swGibsCount')) do
495 case gGibsCount of
496 0: ItemIndex := 0;
497 8: ItemIndex := 1;
498 16: ItemIndex := 2;
499 32: ItemIndex := 3;
500 else ItemIndex := 4;
501 end;
503 with TGUISwitch(menu.GetControl('swBackGround')) do
504 if gDrawBackGround then ItemIndex := 0 else ItemIndex := 1;
506 with TGUISwitch(menu.GetControl('swMessages')) do
507 if gShowMessages then ItemIndex := 0 else ItemIndex := 1;
509 with TGUISwitch(menu.GetControl('swRevertPlayers')) do
510 if gRevertPlayers then ItemIndex := 0 else ItemIndex := 1;
512 with TGUISwitch(menu.GetControl('swChatBubble')) do
513 ItemIndex := gChatBubble;
515 TGUIScroll(menu.GetControl('scScaleFactor')).Value := Round(g_dbg_scale - 1);
517 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
519 TGUIListBox(menu.GetControl('lsP1Model')).SelectItem(gPlayer1Settings.Model);
520 TGUIEdit(menu.GetControl('edP1Name')).Text := gPlayer1Settings.Name;
522 TGUISwitch(menu.GetControl('swP1Team')).ItemIndex :=
523 IfThen(gPlayer1Settings.Team = TEAM_BLUE, 1, 0);
525 TGUIScroll(menu.GetControl('scP1Red')).Value := Round(gPlayer1Settings.Color.R/16);
526 TGUIScroll(menu.GetControl('scP1Green')).Value := Round(gPlayer1Settings.Color.G/16);
527 TGUIScroll(menu.GetControl('scP1Blue')).Value := Round(gPlayer1Settings.Color.B/16);
529 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
531 TGUIListBox(menu.GetControl('lsP2Model')).SelectItem(gPlayer2Settings.Model);
532 TGUIEdit(menu.GetControl('edP2Name')).Text := gPlayer2Settings.Name;
534 TGUISwitch(menu.GetControl('swP2Team')).ItemIndex :=
535 IfThen(gPlayer2Settings.Team = TEAM_BLUE, 1, 0);
537 TGUIScroll(menu.GetControl('scP2Red')).Value := Round(gPlayer2Settings.Color.R/16);
538 TGUIScroll(menu.GetControl('scP2Green')).Value := Round(gPlayer2Settings.Color.G/16);
539 TGUIScroll(menu.GetControl('scP2Blue')).Value := Round(gPlayer2Settings.Color.B/16);
541 ProcSelectModel(nil);
542 end;
544 procedure ProcSwitchMonstersCustom(Sender: TGUIControl);
545 begin
546 // don't turn off monsters in DM
548 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
549 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
550 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
551 else
552 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
555 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
556 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
557 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
558 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
560 end;
562 procedure ProcSwitchMonstersNet(Sender: TGUIControl);
563 begin
564 // don't turn off monsters in DM
566 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
567 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
568 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
569 else
570 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
573 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
574 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
575 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
576 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
578 end;
580 procedure ProcStartCustomGame();
581 var
582 Map: String;
583 GameMode: Byte;
584 Options: LongWord;
585 begin
586 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
587 begin
588 Map := TGUILabel(GetControl('lbMap')).Text;
589 if Map = '' then
590 Exit;
591 if not isWadPath(Map) then
592 Exit;
594 GameMode := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
595 gcGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
596 gcTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
597 gcGoalLimit := StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
598 gcMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
600 gcTeamDamage := TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0;
601 gcAllowExit := TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0;
602 gcWeaponStay := TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0;
603 gcMonsters := TGUISwitch(GetControl('swMonsters')).ItemIndex = 0;
604 Options := 0;
605 if gcTeamDamage then
606 Options := Options or GAME_OPTION_TEAMDAMAGE;
607 if gcAllowExit then
608 Options := Options or GAME_OPTION_ALLOWEXIT;
609 if gcWeaponStay then
610 Options := Options or GAME_OPTION_WEAPONSTAY;
611 if gcMonsters then
612 Options := Options or GAME_OPTION_MONSTERS;
613 gcPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
615 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
616 1: begin
617 Options := Options or GAME_OPTION_BOTVSMONSTER;
618 gcBotsVS := 'Monsters';
619 end;
620 2: begin
621 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
622 gcBotsVS := 'Everybody';
623 end;
624 else begin
625 Options := Options or GAME_OPTION_BOTVSPLAYER;
626 gcBotsVS := 'Players';
627 end;
628 end;
630 gcMap := Map;
631 end;
633 g_Options_Write_Gameplay_Custom(GameDir+'/'+CONFIG_FILENAME);
635 g_Game_StartCustom(Map, GameMode, gcTimeLimit, gcGoalLimit,
636 gcMaxLives, Options, gcPlayers);
637 end;
640 procedure ProcStartNetGame();
641 var
642 Map: String;
643 GameMode: Byte;
644 Options: LongWord;
645 begin
646 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
647 begin
648 Map := TGUILabel(GetControl('lbMap')).Text;
649 if Map = '' then
650 Exit;
651 if not isWadPath(Map) then
652 Exit;
654 GameMode := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
655 gnGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
656 gnTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
657 gnGoalLimit := StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
658 gnMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
659 NetPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
661 gnTeamDamage := TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0;
662 gnAllowExit := TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0;
663 gnWeaponStay := TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0;
664 gnMonsters := TGUISwitch(GetControl('swMonsters')).ItemIndex = 0;
665 Options := 0;
666 if gnTeamDamage then
667 Options := Options or GAME_OPTION_TEAMDAMAGE;
668 if gnAllowExit then
669 Options := Options or GAME_OPTION_ALLOWEXIT;
670 if gnWeaponStay then
671 Options := Options or GAME_OPTION_WEAPONSTAY;
672 if gnMonsters then
673 Options := Options or GAME_OPTION_MONSTERS;
674 gnPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
676 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
677 1: begin
678 Options := Options or GAME_OPTION_BOTVSMONSTER;
679 gnBotsVS := 'Monsters';
680 end;
681 2: begin
682 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
683 gnBotsVS := 'Everybody';
684 end;
685 else begin
686 Options := Options or GAME_OPTION_BOTVSPLAYER;
687 gnBotsVS := 'Players';
688 end;
689 end;
691 gnMap := Map;
692 NetServerName := TGUIEdit(GetControl('edSrvName')).Text;
693 NetMaxClients := Max(1, StrToIntDef(TGUIEdit(GetControl('edMaxPlayers')).Text, 1));
694 NetMaxClients := Min(NET_MAXCLIENTS, NetMaxClients);
695 NetPassword := TGUIEdit(GetControl('edSrvPassword')).Text;
696 NetUseMaster := TGUISwitch(GetControl('swUseMaster')).ItemIndex = 0;
697 end;
699 g_Options_Write_Net_Server(GameDir+'/'+CONFIG_FILENAME);
700 g_Options_Write_Gameplay_Net(GameDir+'/'+CONFIG_FILENAME);
702 g_Game_StartServer(Map, GameMode, gnTimeLimit, gnGoalLimit, gnMaxLives,
703 Options, gnPlayers, 0, NetPort);
704 end;
706 procedure ProcConnectNetGame();
707 var
708 PW: String;
709 begin
710 with TGUIMenu(g_ActiveWindow.GetControl('mNetClientMenu')) do
711 begin
712 NetClientIP := TGUIEdit(GetControl('edIP')).Text;
713 NetClientPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
714 PW := TGUIEdit(GetControl('edPW')).Text;
715 end;
717 g_Options_Write_Net_Client(GameDir+'/'+CONFIG_FILENAME);
718 g_Game_StartClient(NetClientIP, NetClientPort, PW);
719 end;
721 procedure ProcEnterPassword();
722 var
723 PW: string;
724 begin
725 with TGUIMenu(g_ActiveWindow.GetControl('mClientPasswordMenu')) do
726 begin
727 NetClientIP := PromptIP;
728 NetClientPort := PromptPort;
729 PW := TGUIEdit(GetControl('edPW')).Text;
730 end;
732 g_Options_Write_Net_Client(GameDir+'/'+CONFIG_FILENAME);
733 g_Game_StartClient(NetClientIP, NetClientPort, PW);
734 end;
736 procedure ProcServerlist();
737 begin
738 if not NetInitDone then
739 begin
740 if (not g_Net_Init()) then
741 begin
742 g_Console_Add('NET: ERROR: Failed to init ENet!');
743 Exit;
744 end
745 else
746 NetInitDone := True;
747 end;
749 g_Net_Slist_Set(NetSlistIP, NetSlistPort);
751 gState := STATE_SLIST;
752 g_ActiveWindow := nil;
754 slWaitStr := _lc[I_NET_SLIST_WAIT];
756 g_Game_Draw;
757 ReDrawWindow;
759 slReturnPressed := True;
760 if g_Net_Slist_Fetch(slCurrent) then
761 begin
762 if slCurrent = nil then
763 slWaitStr := _lc[I_NET_SLIST_NOSERVERS];
764 end
765 else
766 slWaitStr := _lc[I_NET_SLIST_ERROR];
767 end;
769 procedure ProcStartCampaign();
770 var
771 WAD: String;
772 TwoPlayers: Boolean;
773 n: Byte;
774 begin
775 with TGUIMenu(g_ActiveWindow.GetControl('mCampaignMenu')) do
776 begin
777 WAD := ExtractRelativePath(MapsDir, TGUIFileListBox(GetControl('lsWAD')).SelectedItem());
778 TwoPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex = 1;
779 end;
781 if TwoPlayers then
782 n := 2
783 else
784 n := 1;
785 g_Game_StartSingle(WAD + ':\MAP01', TwoPlayers, n);
786 end;
788 procedure ProcSelectMap(Sender: TGUIControl);
789 var
790 win: TGUIWindow;
791 a: TMapInfo;
792 wad, map, res: String;
793 begin
794 win := g_GUI_GetWindow('SelectMapMenu');
795 with TGUIMenu(win.GetControl('mSelectMapMenu')) do
796 begin
797 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
798 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
800 if (wad = '') or (map = '') then
801 begin // Ýòî íå êàðòà
802 TGUILabel(GetControl('lbMapName')).Text := '';
803 TGUILabel(GetControl('lbMapAuthor')).Text := '';
804 TGUILabel(GetControl('lbMapSize')).Text := '';
805 TGUIMemo(GetControl('meMapDescription')).SetText('');
806 TGUIMapPreview(win.GetControl('mpMapPreview')).ClearMap();
807 TGUILabel(win.GetControl('lbMapScale')).Text := '';
808 end
809 else // Ýòî êàðòà
810 begin
811 res := wad+':\'+map;
813 a := g_Map_GetMapInfo(res);
815 TGUILabel(GetControl('lbMapName')).Text := a.Name;
816 TGUILabel(GetControl('lbMapAuthor')).Text := a.Author;
817 TGUILabel(GetControl('lbMapSize')).Text := Format('%dx%d', [a.Width, a.Height]);
818 TGUIMemo(GetControl('meMapDescription')).SetText(a.Description);
819 TGUIMapPreview(win.GetControl('mpMapPreview')).SetMap(res);
820 TGUILabel(win.GetControl('lbMapScale')).Text :=
821 TGUIMapPreview(win.GetControl('mpMapPreview')).GetScaleStr;
822 end;
823 end;
824 end;
826 procedure ProcSelectWAD(Sender: TGUIControl);
827 var
828 wad: String;
829 list: SSArray;
830 begin
831 with TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu')) do
832 begin
833 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
835 with TGUIListBox(GetControl('lsMapRes')) do
836 begin
837 Clear();
839 if wad <> '' then
840 begin
841 list := g_Map_GetMapsList(wad);
843 if list <> nil then
844 begin
845 Items := list;
846 ItemIndex := 0;
847 end
848 end;
849 end;
850 end;
852 ProcSelectMap(nil);
853 end;
855 procedure ProcSelectCampaignWAD(Sender: TGUIControl);
856 var
857 win: TGUIWindow;
858 a: TMegaWADInfo;
859 wad, fn: String;
860 begin
861 win := g_GUI_GetWindow('CampaignMenu');
862 with TGUIMenu(win.GetControl('mCampaignMenu')) do
863 begin
864 wad := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
866 if wad = '' then
867 begin
868 TGUILabel(GetControl('lbWADName')).Text := '';
869 TGUILabel(GetControl('lbWADAuthor')).Text := '';
870 TGUIMemo(GetControl('meWADDescription')).SetText('');
871 end;
873 a := g_Game_GetMegaWADInfo(wad);
875 TGUILabel(GetControl('lbWADName')).Text := a.Name;
876 TGUILabel(GetControl('lbWADAuthor')).Text := a.Author;
877 TGUIMemo(GetControl('meWADDescription')).SetText(a.Description);
879 TGUIImage(win.GetControl('mpWADImage')).ClearImage();
881 if a.pic <> '' then
882 begin
883 fn := g_ExtractWadName(a.pic);
884 if fn = '' then
885 TGUIImage(win.GetControl('mpWADImage')).SetImage(wad+a.pic)
886 else
887 TGUIImage(win.GetControl('mpWADImage')).SetImage(a.pic);
888 end;
889 end;
890 end;
892 procedure ProcChangeColor(Sender: TGUIControl);
893 var
894 window: TGUIWindow;
895 begin
896 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
897 with TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')) do
898 TGUIModelView(window.GetControl('mvP1Model')).SetColor(
899 Min(TGUIScroll(GetControl('scP1Red')).Value*16, 255),
900 Min(TGUIScroll(GetControl('scP1Green')).Value*16, 255),
901 Min(TGUIScroll(GetControl('scP1Blue')).Value*16, 255));
903 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
904 with TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')) do
905 TGUIModelView(window.GetControl('mvP2Model')).SetColor(
906 Min(TGUIScroll(GetControl('scP2Red')).Value*16, 255),
907 Min(TGUIScroll(GetControl('scP2Green')).Value*16, 255),
908 Min(TGUIScroll(GetControl('scP2Blue')).Value*16, 255));
909 end;
911 procedure ProcSelectModel(Sender: TGUIControl);
912 var
913 a: string;
914 window: TGUIWindow;
915 begin
916 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
917 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')).GetControl('lsP1Model')).SelectedItem;
918 if a <> '' then TGUIModelView(window.GetControl('mvP1Model')).SetModel(a);
920 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
921 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')).GetControl('lsP2Model')).SelectedItem;
922 if a <> '' then TGUIModelView(window.GetControl('mvP2Model')).SetModel(a);
924 ProcChangeColor(nil);
925 end;
927 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
928 var
929 cwdt, chgt: Byte;
930 spc: ShortInt;
931 ID: DWORD;
932 wad: TWADFile;
933 cfgdata: Pointer;
934 cfglen: Integer;
935 config: TConfig;
936 begin
937 cfglen := 0;
939 wad := TWADFile.Create;
940 if wad.ReadFile(GameWAD) then
941 wad.GetResource('FONTS/'+cfgres, cfgdata, cfglen);
942 wad.Free();
944 if cfglen <> 0 then
945 begin
946 g_Texture_CreateWADEx('FONT_STD', GameWAD+':FONTS\'+texture);
948 config := TConfig.CreateMem(cfgdata, cfglen);
949 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
950 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
951 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
953 if g_Texture_Get('FONT_STD', ID) then
954 e_TextureFontBuild(ID, FontID, cwdt, chgt, spc);
956 config.Free();
957 end;
959 if cfglen <> 0 then FreeMem(cfgdata);
960 end;
962 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
963 var
964 cwdt, chgt: Byte;
965 spc: ShortInt;
966 CharID: DWORD;
967 wad: TWADFile;
968 cfgdata, fntdata: Pointer;
969 cfglen, fntlen: Integer;
970 config: TConfig;
971 chrwidth: Integer;
972 a: Byte;
973 begin
974 cfglen := 0;
975 fntlen := 0;
977 wad := TWADFile.Create;
978 if wad.ReadFile(GameWAD) then
979 begin
980 wad.GetResource('FONTS/'+txtres, cfgdata, cfglen);
981 wad.GetResource('FONTS/'+fntres, fntdata, fntlen);
982 end;
983 wad.Free();
985 if cfglen <> 0 then
986 begin
987 config := TConfig.CreateMem(cfgdata, cfglen);
988 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
989 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
991 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
992 FontID := e_CharFont_Create(spc);
994 for a := 0 to 255 do
995 begin
996 chrwidth := config.ReadInt(IntToStr(a), 'Width', 0);
997 if chrwidth = 0 then Continue;
999 if e_CreateTextureMemEx(fntdata, fntlen, CharID, cwdt*(a mod 16), chgt*(a div 16),
1000 cwdt, chgt) then
1001 e_CharFont_AddChar(FontID, CharID, Chr(a), chrwidth);
1002 end;
1004 config.Free();
1005 end;
1007 if cfglen <> 0 then FreeMem(cfgdata);
1008 if fntlen <> 0 then FreeMem(fntdata);
1009 end;
1011 procedure MenuLoadData();
1012 begin
1013 e_WriteLog('Loading menu data...', TMsgType.Notify);
1015 g_Texture_CreateWADEx('MAINMENU_MARKER1', GameWAD+':TEXTURES\MARKER1');
1016 g_Texture_CreateWADEx('MAINMENU_MARKER2', GameWAD+':TEXTURES\MARKER2');
1017 g_Texture_CreateWADEx('SCROLL_LEFT', GameWAD+':TEXTURES\SLEFT');
1018 g_Texture_CreateWADEx('SCROLL_RIGHT', GameWAD+':TEXTURES\SRIGHT');
1019 g_Texture_CreateWADEx('SCROLL_MIDDLE', GameWAD+':TEXTURES\SMIDDLE');
1020 g_Texture_CreateWADEx('SCROLL_MARKER', GameWAD+':TEXTURES\SMARKER');
1021 g_Texture_CreateWADEx('EDIT_LEFT', GameWAD+':TEXTURES\ELEFT');
1022 g_Texture_CreateWADEx('EDIT_RIGHT', GameWAD+':TEXTURES\ERIGHT');
1023 g_Texture_CreateWADEx('EDIT_MIDDLE', GameWAD+':TEXTURES\EMIDDLE');
1024 g_Texture_CreateWADEx('BOX1', GameWAD+':TEXTURES\BOX1');
1025 g_Texture_CreateWADEx('BOX2', GameWAD+':TEXTURES\BOX2');
1026 g_Texture_CreateWADEx('BOX3', GameWAD+':TEXTURES\BOX3');
1027 g_Texture_CreateWADEx('BOX4', GameWAD+':TEXTURES\BOX4');
1028 g_Texture_CreateWADEx('BOX5', GameWAD+':TEXTURES\BOX5');
1029 g_Texture_CreateWADEx('BOX6', GameWAD+':TEXTURES\BOX6');
1030 g_Texture_CreateWADEx('BOX7', GameWAD+':TEXTURES\BOX7');
1031 g_Texture_CreateWADEx('BOX8', GameWAD+':TEXTURES\BOX8');
1032 g_Texture_CreateWADEx('BOX9', GameWAD+':TEXTURES\BOX9');
1033 g_Texture_CreateWADEx('BSCROLL_UP_A', GameWAD+':TEXTURES\SCROLLUPA');
1034 g_Texture_CreateWADEx('BSCROLL_UP_U', GameWAD+':TEXTURES\SCROLLUPU');
1035 g_Texture_CreateWADEx('BSCROLL_DOWN_A', GameWAD+':TEXTURES\SCROLLDOWNA');
1036 g_Texture_CreateWADEx('BSCROLL_DOWN_U', GameWAD+':TEXTURES\SCROLLDOWNU');
1037 g_Texture_CreateWADEx('BSCROLL_MIDDLE', GameWAD+':TEXTURES\SCROLLMIDDLE');
1038 g_Texture_CreateWADEx('NOPIC', GameWAD+':TEXTURES\NOPIC');
1040 g_Sound_CreateWADEx('MENU_SELECT', GameWAD+':SOUNDS\MENUSELECT');
1041 g_Sound_CreateWADEx('MENU_OPEN', GameWAD+':SOUNDS\MENUOPEN');
1042 g_Sound_CreateWADEx('MENU_CLOSE', GameWAD+':SOUNDS\MENUCLOSE');
1043 g_Sound_CreateWADEx('MENU_CHANGE', GameWAD+':SOUNDS\MENUCHANGE');
1044 g_Sound_CreateWADEx('SCROLL_ADD', GameWAD+':SOUNDS\SCROLLADD');
1045 g_Sound_CreateWADEx('SCROLL_SUB', GameWAD+':SOUNDS\SCROLLSUB');
1046 g_Sound_CreateWADEx('SOUND_PLAYER_FALL', GameWAD+':SOUNDS\FALL');
1047 end;
1049 procedure MenuFreeData();
1050 begin
1051 e_CharFont_Remove(gMenuFont);
1052 e_CharFont_Remove(gMenuSmallFont);
1054 g_Texture_Delete('MAINMENU_MARKER1');
1055 g_Texture_Delete('MAINMENU_MARKER2');
1056 g_Texture_Delete('SCROLL_LEFT');
1057 g_Texture_Delete('SCROLL_RIGHT');
1058 g_Texture_Delete('SCROLL_MIDDLE');
1059 g_Texture_Delete('SCROLL_MARKER');
1060 g_Texture_Delete('EDIT_LEFT');
1061 g_Texture_Delete('EDIT_RIGHT');
1062 g_Texture_Delete('EDIT_MIDDLE');
1063 g_Texture_Delete('BOX1');
1064 g_Texture_Delete('BOX2');
1065 g_Texture_Delete('BOX3');
1066 g_Texture_Delete('BOX4');
1067 g_Texture_Delete('BOX5');
1068 g_Texture_Delete('BOX6');
1069 g_Texture_Delete('BOX7');
1070 g_Texture_Delete('BOX8');
1071 g_Texture_Delete('BOX9');
1072 g_Texture_Delete('BSCROLL_UP_A');
1073 g_Texture_Delete('BSCROLL_UP_U');
1074 g_Texture_Delete('BSCROLL_DOWN_A');
1075 g_Texture_Delete('BSCROLL_DOWN_U');
1076 g_Texture_Delete('BSCROLL_MIDDLE');
1077 g_Texture_Delete('NOPIC');
1079 g_Sound_Delete('MENU_SELECT');
1080 g_Sound_Delete('MENU_OPEN');
1081 g_Sound_Delete('MENU_CLOSE');
1082 g_Sound_Delete('MENU_CHANGE');
1083 g_Sound_Delete('SCROLL_ADD');
1084 g_Sound_Delete('SCROLL_SUB');
1085 g_Sound_Delete('SOUND_PLAYER_FALL');
1086 end;
1088 procedure ProcAuthorsMenu();
1089 begin
1090 gMusic.SetByName('MUSIC_INTERMUS');
1091 gMusic.Play();
1092 end;
1094 procedure ProcExitMenuKeyDown (yes: Boolean);
1095 var
1096 s: ShortString;
1097 snd: TPlayableSound;
1098 res: Boolean;
1099 begin
1100 if yes then
1101 begin
1102 g_Game_StopAllSounds(True);
1103 case (Random(18)) of
1104 0: s := 'SOUND_MONSTER_PAIN';
1105 1: s := 'SOUND_MONSTER_DIE_3';
1106 2: s := 'SOUND_MONSTER_SLOP';
1107 3: s := 'SOUND_MONSTER_DEMON_DIE';
1108 4: s := 'SOUND_MONSTER_IMP_DIE_2';
1109 5: s := 'SOUND_MONSTER_MAN_DIE';
1110 6: s := 'SOUND_MONSTER_BSP_DIE';
1111 7: s := 'SOUND_MONSTER_VILE_DIE';
1112 8: s := 'SOUND_MONSTER_SKEL_DIE';
1113 9: s := 'SOUND_MONSTER_MANCUB_ALERT';
1114 10: s := 'SOUND_MONSTER_PAIN_PAIN';
1115 11: s := 'SOUND_MONSTER_BARON_DIE';
1116 12: s := 'SOUND_MONSTER_CACO_DIE';
1117 13: s := 'SOUND_MONSTER_CYBER_DIE';
1118 14: s := 'SOUND_MONSTER_KNIGHT_ALERT';
1119 15: s := 'SOUND_MONSTER_SPIDER_ALERT';
1120 else s := 'SOUND_PLAYER_FALL';
1121 end;
1122 snd := TPlayableSound.Create();
1123 res := snd.SetByName(s);
1124 if not res then res := snd.SetByName('SOUND_PLAYER_FALL');
1125 if res then
1126 begin
1127 snd.Play(True);
1128 while snd.IsPlaying() do begin end;
1129 end;
1130 g_Game_Quit();
1131 exit;
1132 end;
1133 g_GUI_HideWindow();
1134 end;
1136 procedure ProcLoadMenu();
1137 var
1138 a: Integer;
1139 valid: Boolean;
1140 begin
1141 for a := 1 to 8 do
1142 begin
1143 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Text := g_GetSaveName(a, valid);
1144 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := not valid;
1145 //TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a)).Enabled := valid;
1146 end;
1147 end;
1149 procedure ProcSaveMenu();
1150 var
1151 a: Integer;
1152 valid: Boolean;
1153 name: AnsiString;
1154 begin
1155 for a := 1 to 8 do
1156 begin
1157 name := g_GetSaveName(a, valid);
1158 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Text := name;
1159 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := (name <> '') and (not valid);
1160 end;
1161 end;
1163 procedure ProcSaveGame(Sender: TGUIControl);
1164 var
1165 a: Integer;
1166 begin
1167 if g_Game_IsNet then Exit;
1168 if g_Game_IsTestMap then Exit;
1169 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1170 g_Game_PauseAllSounds(True);
1171 g_SaveGame(a, TGUIEdit(Sender).Text);
1173 g_ActiveWindow := nil;
1174 g_Game_Pause(False);
1175 end;
1177 procedure ProcLoadGame(Sender: TGUIControl);
1178 var
1179 a: Integer;
1180 begin
1181 if g_Game_IsNet then Exit;
1182 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1183 if g_LoadGame(a) then
1184 begin
1185 g_Game_PauseAllSounds(False)
1186 end
1187 else // Íå çàãðóçèëîñü - âîçâðàò â ìåíþ
1188 begin
1189 g_Console_Add(_lc[I_MSG_BAD_SAVE_VERSION], true);
1190 g_GUI_GetWindow('LoadMenu').SetActive(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu'));
1191 //g_ActiveWindow := nil;
1192 end;
1193 end;
1195 procedure ProcSingle1Player();
1196 begin
1197 g_Game_StartSingle(gDefaultMegawadStart, False, 1);
1198 end;
1200 procedure ProcSingle2Players();
1201 begin
1202 g_Game_StartSingle(gDefaultMegawadStart, True, 2);
1203 end;
1205 procedure ProcSelectMapMenu();
1206 var
1207 menu: TGUIMenu;
1208 wad_lb: TGUIFileListBox;
1209 map_lb: TGUIListBox;
1210 map: String;
1211 begin
1212 menu := TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1213 wad_lb := TGUIFileListBox(menu.GetControl('lsMapWAD'));
1214 map_lb := TGUIListBox(menu.GetControl('lsMapRes'));
1216 if wad_lb.SelectedItem() <> '' then
1217 map := map_lb.SelectedItem()
1218 else
1219 map := '';
1221 wad_lb.UpdateFileList();
1222 map_lb.Clear();
1224 if wad_lb.SelectedItem() <> '' then
1225 begin
1226 ProcSelectWAD(nil);
1227 map_lb.SelectItem(map);
1229 if map_lb.SelectedItem() <> '' then
1230 ProcSelectMap(nil);
1231 end;
1233 g_GUI_ShowWindow('SelectMapMenu');
1234 end;
1236 procedure ProcSelectCampaignMenu();
1237 var
1238 menu: TGUIMenu;
1239 wad_lb: TGUIFileListBox;
1240 begin
1241 menu := TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1242 wad_lb := TGUIFileListBox(menu.GetControl('lsWAD'));
1244 wad_lb.UpdateFileList();
1246 if wad_lb.SelectedItem() <> '' then
1247 ProcSelectCampaignWAD(nil);
1248 end;
1250 procedure ProcSetMap();
1251 var
1252 wad, map, res: String;
1253 begin
1254 with TGUIMenu(g_ActiveWindow.GetControl('mSelectMapMenu')) do
1255 begin
1256 wad := ExtractRelativePath(MapsDir, TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem());
1257 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1258 end;
1260 if (wad = '') or (map = '') then
1261 Exit;
1263 res := wad+':\'+map;
1265 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
1266 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res;
1267 end;
1269 procedure ProcChangeSoundSettings(Sender: TGUIControl);
1270 var
1271 menu: TGUIMenu;
1272 begin
1273 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1275 g_Sound_SetupAllVolumes(
1276 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
1277 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
1278 );
1279 end;
1281 procedure ProcChangeGameSettings(Sender: TGUIControl);
1282 var
1283 menu: TGUIMenu;
1284 begin
1285 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
1286 g_dbg_scale := TGUIScroll(menu.GetControl('scScaleFactor')).Value + 1;
1287 end;
1289 procedure ProcChangeTouchSettings(Sender: TGUIControl);
1290 var
1291 menu: TGUIMenu;
1292 begin
1293 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
1294 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
1295 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
1296 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
1297 end;
1299 procedure ProcOptionsPlayersMIMenu();
1300 var
1301 s, a: string;
1302 b: TModelInfo;
1303 begin
1304 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1306 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+s+'Menu')).GetControl('ls'+s+'Model')).SelectedItem;
1308 if a = '' then Exit;
1310 b := g_PlayerModel_GetInfo(a);
1312 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1313 begin
1314 TGUILabel(GetControl('lbName')).Text := b.Name;
1315 TGUILabel(GetControl('lbAuthor')).Text := b.Author;
1316 TGUIMemo(GetControl('meComment')).SetText(b.Description);
1318 if b.HaveWeapon then
1319 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1320 else
1321 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1322 end;
1324 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1325 end;
1327 procedure ProcOptionsPlayersAnim();
1328 var
1329 s: String;
1330 begin
1331 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1332 s := 'P1'
1333 else
1334 s := 'P2';
1336 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1337 begin
1338 NextAnim();
1339 Model.GetCurrentAnimation.Loop := True;
1340 Model.GetCurrentAnimationMask.Loop := True;
1341 end;
1342 end;
1344 procedure ProcOptionsPlayersWeap();
1345 var
1346 s: String;
1347 begin
1348 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1349 s := 'P1'
1350 else
1351 s := 'P2';
1353 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1354 NextWeapon();
1355 end;
1357 procedure ProcOptionsPlayersRot();
1358 var
1359 s: string;
1360 begin
1361 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1362 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1363 begin
1364 if Direction = TDirection.D_LEFT then Direction := TDirection.D_RIGHT else Direction := TDirection.D_LEFT;
1365 end;
1366 end;
1368 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1369 begin
1370 if yes then
1371 begin
1372 g_Options_SetDefault();
1373 ReadOptions();
1374 end;
1375 g_GUI_HideWindow();
1376 end;
1378 procedure ProcSavedMenuKeyDown (yes: Boolean);
1379 begin
1380 if yes then ReadOptions();
1381 g_GUI_HideWindow();
1382 end;
1384 procedure ProcAuthorsClose();
1385 begin
1386 gMusic.SetByName('MUSIC_MENU');
1387 gMusic.Play();
1388 gState := STATE_MENU;
1389 end;
1391 procedure ProcGMClose();
1392 begin
1393 g_Game_InGameMenu(False);
1394 end;
1396 procedure ProcGMShow();
1397 var
1398 Enabled: Boolean;
1399 begin
1400 Enabled := True;
1401 if (gGameSettings.GameType = GT_SINGLE) and
1402 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1403 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1404 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1405 if not gGameOn then
1406 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1407 if g_Game_IsTestMap then
1408 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1409 TGUIMainMenu(g_ActiveWindow.GetControl(
1410 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1411 end;
1413 procedure ProcChangePlayers();
1414 var
1415 TeamGame, Spectator, AddTwo: Boolean;
1416 P1Team{, P2Team}: Byte;
1417 bP2: TGUITextButton;
1418 begin
1419 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1420 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1421 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1422 P1Team := TEAM_NONE;
1423 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1424 // TODO
1425 //P2Team := TEAM_NONE;
1426 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1428 TGUIMainMenu(g_ActiveWindow.GetControl(
1429 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1430 TGUIMainMenu(g_ActiveWindow.GetControl(
1431 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1432 TGUIMainMenu(g_ActiveWindow.GetControl(
1433 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1435 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1436 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1437 bP2.Enabled := AddTwo and not Spectator;
1438 if bP2.Enabled then
1439 bP2.Color := MAINMENU_ITEMS_COLOR
1440 else
1441 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1442 if gPlayer2 = nil then
1443 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1444 else
1445 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1447 TGUIMainMenu(g_ActiveWindow.GetControl(
1448 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1449 end;
1451 procedure ProcJoinRed();
1452 begin
1453 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1454 Exit;
1455 if g_Game_IsServer then
1456 begin
1457 if gPlayer1 = nil then
1458 g_Game_AddPlayer(TEAM_RED)
1459 else
1460 begin
1461 if gPlayer1.Team <> TEAM_RED then
1462 begin
1463 gPlayer1.SwitchTeam;
1464 gPlayer1Settings.Team := gPlayer1.Team;
1465 end;
1467 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1468 end;
1469 end
1470 else
1471 begin
1472 gPlayer1Settings.Team := TEAM_RED;
1473 MC_SEND_PlayerSettings;
1474 if gPlayer1 = nil then
1475 g_Game_AddPlayer(TEAM_RED);
1476 end;
1477 g_ActiveWindow := nil;
1478 g_Game_Pause(False);
1479 end;
1481 procedure ProcJoinBlue();
1482 begin
1483 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1484 Exit;
1485 if g_Game_IsServer then
1486 begin
1487 if gPlayer1 = nil then
1488 g_Game_AddPlayer(TEAM_BLUE)
1489 else
1490 begin
1491 if gPlayer1.Team <> TEAM_BLUE then
1492 begin
1493 gPlayer1.SwitchTeam;
1494 gPlayer1Settings.Team := gPlayer1.Team;
1495 end;
1497 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1498 end;
1499 end
1500 else
1501 begin
1502 gPlayer1Settings.Team := TEAM_BLUE;
1503 MC_SEND_PlayerSettings;
1504 if gPlayer1 = nil then
1505 g_Game_AddPlayer(TEAM_BLUE);
1506 end;
1507 g_ActiveWindow := nil;
1508 g_Game_Pause(False);
1509 end;
1511 procedure ProcJoinGame();
1512 begin
1513 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1514 Exit;
1515 if gPlayer1 = nil then
1516 g_Game_AddPlayer();
1517 g_ActiveWindow := nil;
1518 g_Game_Pause(False);
1519 end;
1521 procedure ProcSwitchP2();
1522 begin
1523 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1524 Exit;
1525 if gPlayer1 = nil then
1526 Exit;
1527 if gPlayer2 = nil then
1528 g_Game_AddPlayer()
1529 else
1530 g_Game_RemovePlayer();
1531 g_ActiveWindow := nil;
1532 g_Game_Pause(False);
1533 end;
1535 procedure ProcSpectate();
1536 begin
1537 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1538 Exit;
1539 g_Game_Spectate();
1540 g_ActiveWindow := nil;
1541 g_Game_Pause(False);
1542 end;
1544 procedure ProcRestartMenuKeyDown (yes: Boolean);
1545 begin
1546 if yes then g_Game_Restart() else g_GUI_HideWindow;
1547 end;
1549 procedure ProcEndMenuKeyDown (yes: Boolean);
1550 begin
1551 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1552 end;
1554 procedure ProcSetRussianLanguage();
1555 begin
1556 if gLanguage <> LANGUAGE_RUSSIAN then
1557 begin
1558 gLanguage := LANGUAGE_RUSSIAN;
1559 gLanguageChange := True;
1560 gAskLanguage := False;
1562 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1564 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1565 ProcApplyOptions();
1566 end;
1567 end;
1569 procedure ProcSetEnglishLanguage();
1570 begin
1571 if gLanguage <> LANGUAGE_ENGLISH then
1572 begin
1573 gLanguage := LANGUAGE_ENGLISH;
1574 gLanguageChange := True;
1575 gAskLanguage := False;
1577 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1579 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1580 ProcApplyOptions();
1581 end;
1582 end;
1584 procedure ReadGameSettings();
1585 var
1586 menu: TGUIMenu;
1587 begin
1588 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1590 with gGameSettings do
1591 begin
1592 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1593 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1594 ItemIndex := 0
1595 else
1596 ItemIndex := 1;
1598 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1599 TGUIEdit(menu.GetControl('edGoalLimit')).Text := IntToStr(GoalLimit);
1600 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1602 with TGUISwitch(menu.GetControl('swBotsVS')) do
1603 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1604 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1605 ItemIndex := 2
1606 else
1607 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1608 ItemIndex := 1
1609 else
1610 ItemIndex := 0;
1612 if GameType in [GT_CUSTOM, GT_SERVER] then
1613 begin
1614 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1615 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1616 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1617 TGUIEdit(menu.GetControl('edGoalLimit')).Enabled := True;
1618 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_ITEMSTEXT_COLOR;
1619 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1620 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1621 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1622 end
1623 else
1624 begin
1625 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1626 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1627 begin
1628 Enabled := False;
1629 Text := '';
1630 end;
1631 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1632 with TGUIEdit(menu.GetControl('edGoalLimit')) do
1633 begin
1634 Enabled := False;
1635 Text := '';
1636 end;
1637 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1638 with TGUIEdit(menu.GetControl('edMaxLives')) do
1639 begin
1640 Enabled := False;
1641 Text := '';
1642 end;
1643 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1644 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1645 end;
1646 end;
1647 end;
1649 procedure ProcApplyGameSet();
1650 var
1651 menu: TGUIMenu;
1652 a, b, n: Integer;
1653 stat: TPlayerStatArray;
1654 begin
1655 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1657 if not g_Game_IsServer then Exit;
1659 with gGameSettings do
1660 begin
1661 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1662 begin
1663 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1664 Options := Options or GAME_OPTION_TEAMDAMAGE
1665 else
1666 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1667 end;
1669 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1670 begin
1671 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1673 if n = 0 then
1674 TimeLimit := 0
1675 else
1676 begin
1677 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1679 TimeLimit := Max(n, b);
1680 end;
1681 end;
1683 if TGUIEdit(menu.GetControl('edGoalLimit')).Enabled then
1684 begin
1685 n := StrToIntDef(TGUIEdit(menu.GetControl('edGoalLimit')).Text, GoalLimit);
1687 if n = 0 then
1688 GoalLimit := 0
1689 else
1690 begin
1691 b := 0;
1692 if GameMode = GM_DM then
1693 begin // DM
1694 stat := g_Player_GetStats();
1695 if stat <> nil then
1696 for a := 0 to High(stat) do
1697 if stat[a].Frags > b then
1698 b := stat[a].Frags;
1699 end
1700 else // CTF
1701 b := Max(gTeamStat[TEAM_RED].Goals, gTeamStat[TEAM_BLUE].Goals);
1703 GoalLimit := Max(n, b);
1704 end;
1705 end;
1707 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1708 begin
1709 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, GoalLimit);
1710 if n < 0 then n := 0;
1711 if n > 255 then n := 255;
1712 if n = 0 then
1713 MaxLives := 0
1714 else
1715 begin
1716 b := 0;
1717 stat := g_Player_GetStats();
1718 if stat <> nil then
1719 for a := 0 to High(stat) do
1720 if stat[a].Lives > b then
1721 b := stat[a].Lives;
1723 MaxLives := Max(n, b);
1724 end;
1725 end;
1727 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1728 begin
1729 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1730 1:
1731 begin
1732 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1733 Options := Options or GAME_OPTION_BOTVSMONSTER;
1734 end;
1735 2:
1736 begin
1737 Options := Options or GAME_OPTION_BOTVSPLAYER;
1738 Options := Options or GAME_OPTION_BOTVSMONSTER;
1739 end;
1740 else
1741 begin
1742 Options := Options or GAME_OPTION_BOTVSPLAYER;
1743 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1744 end;
1745 end;
1746 end;
1747 end;
1749 if g_Game_IsNet then MH_SEND_GameSettings;
1750 end;
1752 procedure ProcVideoOptionsRes();
1753 var
1754 menu: TGUIMenu;
1755 list: SSArray;
1756 SR: DWORD;
1757 begin
1758 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1760 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1761 IntToStr(gScreenWidth) +
1762 ' x ' + IntToStr(gScreenHeight) +
1763 ', ' + IntToStr(gBPP) + ' bpp';
1765 with TGUIListBox(menu.GetControl('lsResolution')) do
1766 begin
1767 list := GetDisplayModes(gBPP, SR);
1769 if list <> nil then
1770 begin
1771 Items := list;
1772 ItemIndex := SR;
1773 end
1774 else
1775 Clear();
1776 end;
1778 with TGUISwitch(menu.GetControl('swFullScreen')) do
1779 if gFullscreen then
1780 ItemIndex := 0
1781 else
1782 ItemIndex := 1;
1783 end;
1785 procedure ProcApplyVideoOptions();
1786 var
1787 menu: TGUIMenu;
1788 Fullscreen: Boolean;
1789 SWidth, SHeight: Integer;
1790 str: String;
1791 begin
1792 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1794 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1795 SScanf(str, '%dx%d', [@SWidth, @SHeight]);
1797 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1799 if (SWidth <> gScreenWidth) or
1800 (SHeight <> gScreenHeight) or
1801 (Fullscreen <> gFullscreen) then
1802 begin
1803 gResolutionChange := True;
1804 gRC_Width := SWidth;
1805 gRC_Height := SHeight;
1806 gRC_FullScreen := Fullscreen;
1807 gRC_Maximized := gWinMaximized;
1808 end;
1810 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1811 ProcApplyOptions();
1812 end;
1814 procedure ProcSetFirstRussianLanguage();
1815 begin
1816 gLanguage := LANGUAGE_RUSSIAN;
1817 gLanguageChange := True;
1818 gAskLanguage := False;
1820 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1821 end;
1823 procedure ProcSetFirstEnglishLanguage();
1824 begin
1825 gLanguage := LANGUAGE_ENGLISH;
1826 gLanguageChange := True;
1827 gAskLanguage := False;
1829 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1830 end;
1832 procedure ProcRecallAddress();
1833 begin
1834 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1835 begin
1836 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1837 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1838 end;
1839 end;
1841 procedure CreateFirstLanguageMenu();
1842 var
1843 Menu: TGUIWindow;
1844 begin
1845 Menu := TGUIWindow.Create('FirstLanguageMenu');
1847 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, ' '))) do
1848 begin
1849 Name := 'mmFirstLanguageMenu';
1850 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
1851 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
1852 end;
1854 Menu.DefControl := 'mmFirstLanguageMenu';
1855 Menu.MainWindow := True;
1856 g_GUI_AddWindow(Menu);
1857 end;
1859 procedure g_Menu_AskLanguage();
1860 begin
1861 CreateFirstLanguageMenu();
1862 g_GUI_ShowWindow('FirstLanguageMenu');
1863 end;
1865 procedure CreatePlayerOptionsMenu(s: String);
1866 var
1867 Menu: TGUIWindow;
1868 a: String;
1869 begin
1870 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
1871 if s = 'P1' then
1872 a := _lc[I_MENU_PLAYER_1]
1873 else
1874 a := _lc[I_MENU_PLAYER_2];
1875 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
1876 begin
1877 Name := 'mOptionsPlayers'+s+'Menu';
1878 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
1879 begin
1880 Name := 'ed'+s+'Name';
1881 MaxLength := 12;
1882 Width := 12;
1883 end;
1884 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
1885 begin
1886 Name := 'sw'+s+'Team';
1887 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
1888 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
1889 end ;
1890 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
1891 begin
1892 Name := 'ls'+s+'Model';
1893 Sort := True;
1894 Items := g_PlayerModel_GetNames();
1895 OnChange := ProcSelectModel;
1896 end;
1897 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
1898 begin
1899 Name := 'sc'+s+'Red';
1900 Max := 16;
1901 OnChange := ProcChangeColor;
1902 end;
1903 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
1904 begin
1905 Name := 'sc'+s+'Green';
1906 Max := 16;
1907 OnChange := ProcChangeColor;
1908 end;
1909 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
1910 begin
1911 Name := 'sc'+s+'Blue';
1912 Max := 16;
1913 OnChange := ProcChangeColor;
1914 end;
1915 AddSpace();
1916 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
1917 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
1918 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
1919 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
1921 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
1922 begin
1923 Name := 'mv'+s+'Model';
1924 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
1925 Y := GetControl('ls'+s+'Model').Y;
1926 end;
1927 end;
1928 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
1929 g_GUI_AddWindow(Menu);
1930 end;
1932 procedure CreateAllMenus();
1933 var
1934 Menu: TGUIWindow;
1935 //SR: TSearchRec;
1936 a, cx, _y, i: Integer;
1937 //list: SSArray;
1938 begin
1939 Menu := TGUIWindow.Create('MainMenu');
1940 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
1941 begin
1942 Name := 'mmMainMenu';
1943 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
1944 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
1945 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
1946 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
1947 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
1948 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
1949 end;
1950 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
1951 begin
1952 Color := _RGB(255, 255, 255);
1953 X := gScreenWidth-GetWidth-8;
1954 Y := gScreenHeight-GetHeight-8;
1955 end;
1956 Menu.DefControl := 'mmMainMenu';
1957 Menu.MainWindow := True;
1958 g_GUI_AddWindow(Menu);
1960 Menu := TGUIWindow.Create('NewGameMenu');
1961 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_NEW_GAME]))) do
1962 begin
1963 Name := 'mmNewGameMenu';
1964 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
1965 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
1966 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
1967 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
1968 end;
1969 Menu.DefControl := 'mmNewGameMenu';
1970 g_GUI_AddWindow(Menu);
1972 Menu := TGUIWindow.Create('NetGameMenu');
1973 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MULTIPLAYER]))) do
1974 begin
1975 Name := 'mmNetGameMenu';
1976 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
1977 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
1978 end;
1979 Menu.DefControl := 'mmNetGameMenu';
1980 g_GUI_AddWindow(Menu);
1982 Menu := TGUIWindow.Create('NetServerMenu');
1983 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
1984 begin
1985 Name := 'mNetServerMenu';
1986 with AddEdit(_lc[I_NET_SERVER_NAME]) do
1987 begin
1988 Name := 'edSrvName';
1989 OnlyDigits := False;
1990 Width := 16;
1991 MaxLength := 64;
1992 Text := NetServerName;
1993 end;
1994 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
1995 begin
1996 Name := 'edSrvPassword';
1997 OnlyDigits := False;
1998 Width := 16;
1999 MaxLength := 24;
2000 Text := NetPassword;
2001 end;
2002 with AddEdit(_lc[I_NET_PORT]) do
2003 begin
2004 Name := 'edPort';
2005 OnlyDigits := True;
2006 Width := 4;
2007 MaxLength := 5;
2008 Text := IntToStr(NetPort);
2009 end;
2010 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2011 begin
2012 Name := 'edMaxPlayers';
2013 OnlyDigits := True;
2014 Width := 4;
2015 MaxLength := 2;
2016 Text := IntToStr(NetMaxClients);
2017 end;
2018 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2019 begin
2020 Name := 'swUseMaster';
2021 AddItem(_lc[I_MENU_YES]);
2022 AddItem(_lc[I_MENU_NO]);
2023 if NetUseMaster then
2024 ItemIndex := 0
2025 else
2026 ItemIndex := 1;
2027 end;
2028 AddSpace();
2029 with AddLabel(_lc[I_MENU_MAP]) do
2030 begin
2031 Name := 'lbMap';
2032 FixedLength := 16;
2033 Text := gnMap;
2034 OnClick := @ProcSelectMapMenu;
2035 end;
2036 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2037 begin
2038 Name := 'swGameMode';
2039 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2040 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2041 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2042 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2043 case g_Game_TextToMode(gnGameMode) of
2044 GM_NONE,
2045 GM_DM: ItemIndex := 0;
2046 GM_TDM: ItemIndex := 1;
2047 GM_CTF: ItemIndex := 2;
2048 GM_SINGLE,
2049 GM_COOP: ItemIndex := 3;
2050 end;
2051 OnChange := ProcSwitchMonstersNet;
2052 end;
2053 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2054 begin
2055 Name := 'edTimeLimit';
2056 OnlyDigits := True;
2057 Width := 4;
2058 MaxLength := 5;
2059 if gnTimeLimit > 0 then
2060 Text := IntToStr(gnTimeLimit);
2061 end;
2062 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2063 begin
2064 Name := 'edGoalLimit';
2065 OnlyDigits := True;
2066 Width := 4;
2067 MaxLength := 5;
2068 if gnGoalLimit > 0 then
2069 Text := IntToStr(gnGoalLimit);
2070 end;
2071 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2072 begin
2073 Name := 'edMaxLives';
2074 OnlyDigits := True;
2075 Width := 4;
2076 MaxLength := 3;
2077 if gnMaxLives > 0 then
2078 Text := IntToStr(gnMaxLives);
2079 end;
2080 with AddSwitch(_lc[I_MENU_SERVER_PLAYERS]) do
2081 begin
2082 Name := 'swPlayers';
2083 AddItem(_lc[I_MENU_COUNT_NONE]);
2084 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2085 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2086 ItemIndex := gnPlayers;
2087 end;
2088 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2089 begin
2090 Name := 'swTeamDamage';
2091 AddItem(_lc[I_MENU_YES]);
2092 AddItem(_lc[I_MENU_NO]);
2093 if gnTeamDamage then
2094 ItemIndex := 0
2095 else
2096 ItemIndex := 1;
2097 end;
2098 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2099 begin
2100 Name := 'swEnableExits';
2101 AddItem(_lc[I_MENU_YES]);
2102 AddItem(_lc[I_MENU_NO]);
2103 if gnAllowExit then
2104 ItemIndex := 0
2105 else
2106 ItemIndex := 1;
2107 end;
2108 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2109 begin
2110 Name := 'swWeaponStay';
2111 AddItem(_lc[I_MENU_YES]);
2112 AddItem(_lc[I_MENU_NO]);
2113 if gnWeaponStay then
2114 ItemIndex := 0
2115 else
2116 ItemIndex := 1;
2117 end;
2118 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2119 begin
2120 Name := 'swMonsters';
2121 AddItem(_lc[I_MENU_YES]);
2122 AddItem(_lc[I_MENU_NO]);
2123 if gnMonsters then
2124 ItemIndex := 0
2125 else
2126 ItemIndex := 1;
2127 end;
2128 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2129 begin
2130 Name := 'swBotsVS';
2131 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2132 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2133 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2134 ItemIndex := 2;
2135 if gnBotsVS = 'Players' then
2136 ItemIndex := 0;
2137 if gnBotsVS = 'Monsters' then
2138 ItemIndex := 1;
2139 end;
2140 AddSpace();
2141 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2143 ReAlign();
2144 end;
2145 Menu.DefControl := 'mNetServerMenu';
2146 g_GUI_AddWindow(Menu);
2148 Menu := TGUIWindow.Create('NetClientMenu');
2149 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2150 begin
2151 Name := 'mNetClientMenu';
2153 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2154 AddSpace();
2156 with AddEdit(_lc[I_NET_ADDRESS]) do
2157 begin
2158 Name := 'edIP';
2159 OnlyDigits :=False;
2160 Width := 12;
2161 MaxLength := 64;
2162 Text := 'localhost';
2163 end;
2164 with AddEdit(_lc[I_NET_PORT]) do
2165 begin
2166 Name := 'edPort';
2167 OnlyDigits := True;
2168 Width := 4;
2169 MaxLength := 5;
2170 Text := '25666';
2171 end;
2172 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2173 begin
2174 Name := 'edPW';
2175 OnlyDigits := False;
2176 Width := 12;
2177 MaxLength := 32;
2178 Text := '';
2179 end;
2181 AddSpace();
2182 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2184 ReAlign();
2185 end;
2186 Menu.DefControl := 'mNetClientMenu';
2187 g_GUI_AddWindow(Menu);
2189 Menu := TGUIWindow.Create('LoadMenu');
2190 Menu.OnShow := ProcLoadMenu;
2191 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2192 begin
2193 Name := 'mmLoadMenu';
2195 for a := 1 to 8 do
2196 with AddEdit('') do
2197 begin
2198 Name := 'edSlot'+IntToStr(a);
2199 Width := 16;
2200 MaxLength := 16;
2201 OnEnter := ProcLoadGame;
2202 end;
2203 end;
2204 Menu.DefControl := 'mmLoadMenu';
2205 g_GUI_AddWindow(Menu);
2207 Menu := TGUIWindow.Create('SaveMenu');
2208 Menu.OnShow := ProcSaveMenu;
2209 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2210 begin
2211 Name := 'mmSaveMenu';
2213 for a := 1 to 8 do
2214 with AddEdit('') do
2215 begin
2216 Name := 'edSlot'+IntToStr(a);
2217 Width := 16;
2218 MaxLength := 16;
2219 OnChange := ProcSaveGame;
2220 end;
2221 end;
2222 Menu.DefControl := 'mmSaveMenu';
2223 g_GUI_AddWindow(Menu);
2225 Menu := TGUIWindow.Create('CustomGameMenu');
2226 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2227 begin
2228 Name := 'mCustomGameMenu';
2229 with AddLabel(_lc[I_MENU_MAP]) do
2230 begin
2231 Name := 'lbMap';
2232 FixedLength := 16;
2233 Text := gcMap;
2234 OnClick := @ProcSelectMapMenu;
2235 end;
2236 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2237 begin
2238 Name := 'swGameMode';
2239 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2240 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2241 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2242 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2243 case g_Game_TextToMode(gcGameMode) of
2244 GM_NONE,
2245 GM_DM: ItemIndex := 0;
2246 GM_TDM: ItemIndex := 1;
2247 GM_CTF: ItemIndex := 2;
2248 GM_SINGLE,
2249 GM_COOP: ItemIndex := 3;
2250 end;
2251 OnChange := ProcSwitchMonstersCustom;
2252 end;
2253 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2254 begin
2255 Name := 'edTimeLimit';
2256 OnlyDigits := True;
2257 Width := 4;
2258 MaxLength := 5;
2259 if gcTimeLimit > 0 then
2260 Text := IntToStr(gcTimeLimit);
2261 end;
2262 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2263 begin
2264 Name := 'edGoalLimit';
2265 OnlyDigits := True;
2266 Width := 4;
2267 MaxLength := 5;
2268 if gcGoalLimit > 0 then
2269 Text := IntToStr(gcGoalLimit);
2270 end;
2271 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2272 begin
2273 Name := 'edMaxLives';
2274 OnlyDigits := True;
2275 Width := 4;
2276 MaxLength := 5;
2277 if gcMaxLives > 0 then
2278 Text := IntToStr(gcMaxLives);
2279 end;
2280 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2281 begin
2282 Name := 'swPlayers';
2283 AddItem(_lc[I_MENU_COUNT_NONE]);
2284 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2285 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2286 ItemIndex := gcPlayers;
2287 end;
2288 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2289 begin
2290 Name := 'swTeamDamage';
2291 AddItem(_lc[I_MENU_YES]);
2292 AddItem(_lc[I_MENU_NO]);
2293 if gcTeamDamage then
2294 ItemIndex := 0
2295 else
2296 ItemIndex := 1;
2297 end;
2298 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2299 begin
2300 Name := 'swEnableExits';
2301 AddItem(_lc[I_MENU_YES]);
2302 AddItem(_lc[I_MENU_NO]);
2303 if gcAllowExit then
2304 ItemIndex := 0
2305 else
2306 ItemIndex := 1;
2307 end;
2308 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2309 begin
2310 Name := 'swWeaponStay';
2311 AddItem(_lc[I_MENU_YES]);
2312 AddItem(_lc[I_MENU_NO]);
2313 if gcWeaponStay then
2314 ItemIndex := 0
2315 else
2316 ItemIndex := 1;
2317 end;
2318 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2319 begin
2320 Name := 'swMonsters';
2321 AddItem(_lc[I_MENU_YES]);
2322 AddItem(_lc[I_MENU_NO]);
2323 if gcMonsters then
2324 ItemIndex := 0
2325 else
2326 ItemIndex := 1;
2327 end;
2328 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2329 begin
2330 Name := 'swBotsVS';
2331 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2332 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2333 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2334 ItemIndex := 2;
2335 if gcBotsVS = 'Players' then
2336 ItemIndex := 0;
2337 if gcBotsVS = 'Monsters' then
2338 ItemIndex := 1;
2339 end;
2340 AddSpace();
2341 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2343 ReAlign();
2344 end;
2345 Menu.DefControl := 'mCustomGameMenu';
2346 g_GUI_AddWindow(Menu);
2348 Menu := TGUIWindow.Create('CampaignMenu');
2349 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2350 begin
2351 Name := 'mCampaignMenu';
2353 AddSpace();
2354 AddSpace();
2355 AddSpace();
2356 AddSpace();
2357 AddSpace();
2358 AddSpace();
2360 with AddFileList('', 15, 4) do
2361 begin
2362 Name := 'lsWAD';
2363 OnChange := ProcSelectCampaignWAD;
2365 Sort := True;
2366 Dirs := True;
2367 FileMask := '*.wad|*.pk3|*.zip';
2368 SetBase(MapsDir+'megawads/');
2369 end;
2371 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2372 begin
2373 Name := 'lbWADName';
2374 FixedLength := 8;
2375 Enabled := False;
2376 end;
2377 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2378 begin
2379 Name := 'lbWADAuthor';
2380 FixedLength := 8;
2381 Enabled := False;
2382 end;
2383 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2384 with AddMemo('', 15, 3) do
2385 begin
2386 Name := 'meWADDescription';
2387 Color := MENU_ITEMSCTRL_COLOR;
2388 end;
2389 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2390 begin
2391 Name := 'swPlayers';
2392 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2393 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2394 end;
2395 AddSpace();
2396 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2398 ReAlign();
2400 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2401 begin
2402 Name := 'mpWADImage';
2403 DefaultRes := 'NOPIC';
2404 X := GetControl('lsWAD').X+4;
2405 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2406 end;
2407 end;
2408 Menu.DefControl := 'mCampaignMenu';
2409 g_GUI_AddWindow(Menu);
2411 Menu := TGUIWindow.Create('SelectMapMenu');
2412 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2413 begin
2414 Name := 'mSelectMapMenu';
2415 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2416 begin
2417 Name := 'lsMapWAD';
2418 OnChange := ProcSelectWAD;
2420 Sort := True;
2421 Dirs := True;
2422 FileMask := '*.wad|*.pk3|*.zip';
2423 SetBase(MapsDir);
2424 end;
2425 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2426 begin
2427 Name := 'lsMapRes';
2428 Sort := True;
2429 OnChange := ProcSelectMap;
2430 end;
2431 AddSpace();
2432 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2433 begin
2434 Name := 'lbMapName';
2435 FixedLength := 24;
2436 Enabled := False;
2437 end;
2438 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2439 begin
2440 Name := 'lbMapAuthor';
2441 FixedLength := 16;
2442 Enabled := False;
2443 end;
2444 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2445 begin
2446 Name := 'lbMapSize';
2447 FixedLength := 10;
2448 Enabled := False;
2449 end;
2450 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 12, 4) do
2451 begin
2452 Name := 'meMapDescription';
2453 end;
2455 ReAlign();
2457 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2458 begin
2459 Name := 'mpMapPreview';
2460 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2461 Y := GetControl('lsMapWAD').Y;
2462 end;
2463 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2464 begin
2465 Name := 'lbMapScale';
2466 FixedLength := 8;
2467 Enabled := False;
2468 Color := MENU_ITEMSCTRL_COLOR;
2469 X := GetControl('lsMapWAD').X +
2470 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2471 2 + MAPPREVIEW_WIDTH*4;
2472 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2473 end;
2474 end;
2475 Menu.OnClose := ProcSetMap;
2476 Menu.DefControl := 'mSelectMapMenu';
2477 g_GUI_AddWindow(Menu);
2479 Menu := TGUIWindow.Create('OptionsMenu');
2480 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_OPTIONS]))) do
2481 begin
2482 Name := 'mmOptionsMenu';
2483 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2484 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2485 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2486 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2487 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2488 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2489 AddSpace();
2490 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2491 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2492 end;
2493 Menu.OnClose := ProcApplyOptions;
2494 Menu.DefControl := 'mmOptionsMenu';
2495 g_GUI_AddWindow(Menu);
2497 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2498 gMenuSmallFont, @ProcSavedMenuKeyDown);
2499 g_GUI_AddWindow(Menu);
2501 Menu := TGUIWindow.Create('OptionsVideoMenu');
2502 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2503 begin
2504 Name := 'mOptionsVideoMenu';
2505 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2506 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2507 begin
2508 Name := 'swBPP';
2509 AddItem('16');
2510 AddItem('32');
2511 end;
2512 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2513 begin
2514 Name := 'swVSync';
2515 AddItem(_lc[I_MENU_YES]);
2516 AddItem(_lc[I_MENU_NO]);
2517 end;
2518 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2519 begin
2520 Name := 'swTextureFilter';
2521 AddItem(_lc[I_MENU_YES]);
2522 AddItem(_lc[I_MENU_NO]);
2523 end;
2524 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2525 begin
2526 Name := 'swLegacyNPOT';
2527 AddItem(_lc[I_MENU_NO]);
2528 AddItem(_lc[I_MENU_YES]);
2529 end;
2530 AddSpace();
2531 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2532 ReAlign();
2533 end;
2534 Menu.DefControl := 'mOptionsVideoMenu';
2535 g_GUI_AddWindow(Menu);
2537 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2538 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2539 begin
2540 Name := 'mOptionsVideoResMenu';
2541 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2542 begin
2543 Name := 'lbCurrentRes';
2544 FixedLength := 24;
2545 Enabled := False;
2546 end;
2547 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2548 begin
2549 Name := 'lsResolution';
2550 Sort := False;
2551 end;
2552 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2553 begin
2554 Name := 'swFullScreen';
2555 AddItem(_lc[I_MENU_YES]);
2556 AddItem(_lc[I_MENU_NO]);
2557 end;
2558 AddSpace();
2559 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2560 UpdateIndex();
2561 end;
2562 Menu.DefControl := 'mOptionsVideoResMenu';
2563 g_GUI_AddWindow(Menu);
2565 Menu := TGUIWindow.Create('OptionsSoundMenu');
2566 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
2567 begin
2568 Name := 'mOptionsSoundMenu';
2569 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2570 begin
2571 Name := 'scMusicLevel';
2572 Max := 16;
2573 OnChange := ProcChangeSoundSettings;
2574 end;
2575 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2576 begin
2577 Name := 'scSoundLevel';
2578 Max := 16;
2579 OnChange := ProcChangeSoundSettings;
2580 end;
2581 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2582 begin
2583 Name := 'scMaxSimSounds';
2584 Max := 16;
2585 end;
2586 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2587 begin;
2588 Name := 'swAnnouncer';
2589 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2590 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2591 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2592 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2593 end;
2594 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2595 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2596 begin;
2597 Name := 'swSoundEffects';
2598 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2599 AddItem(_lc[I_MENU_COMPAT_DF]);
2600 end;
2601 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
2602 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
2603 begin;
2604 Name := 'swChatSpeech';
2605 AddItem(_lc[I_MENU_YES]);
2606 AddItem(_lc[I_MENU_NO]);
2607 end;
2608 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2609 begin
2610 Name := 'swInactiveSounds';
2611 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2612 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2613 end;
2614 ReAlign();
2615 end;
2616 Menu.DefControl := 'mOptionsSoundMenu';
2617 g_GUI_AddWindow(Menu);
2619 Menu := TGUIWindow.Create('OptionsGameMenu');
2620 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
2621 begin
2622 Name := 'mOptionsGameMenu';
2623 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2624 begin
2625 Name := 'scParticlesCount';
2626 Max := 20;
2627 end;
2628 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2629 begin
2630 Name := 'swBloodCount';
2631 AddItem(_lc[I_MENU_COUNT_NONE]);
2632 AddItem(_lc[I_MENU_COUNT_SMALL]);
2633 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2634 AddItem(_lc[I_MENU_COUNT_BIG]);
2635 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2636 end;
2637 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2638 begin
2639 Name := 'scShellsMax';
2640 Max := 20;
2641 end;
2642 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2643 begin
2644 Name := 'scGibsMax';
2645 Max := 20;
2646 end;
2647 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2648 begin
2649 Name := 'scCorpsesMax';
2650 Max := 20;
2651 end;
2652 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2653 begin
2654 Name := 'swGibsCount';
2655 AddItem(_lc[I_MENU_COUNT_NONE]);
2656 AddItem(_lc[I_MENU_COUNT_SMALL]);
2657 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2658 AddItem(_lc[I_MENU_COUNT_BIG]);
2659 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2660 end;
2661 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2662 begin
2663 Name := 'swCorpseType';
2664 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2665 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2666 end;
2667 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2668 begin
2669 Name := 'swGibsType';
2670 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2671 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2672 end;
2673 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2674 begin
2675 Name := 'swBloodType';
2676 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2677 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2678 end;
2679 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2680 begin
2681 Name := 'swScreenFlash';
2682 AddItem(_lc[I_MENU_NO]);
2683 AddItem(_lc[I_MENU_COMPAT_DF]);
2684 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2685 end;
2686 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2687 begin
2688 Name := 'swBackground';
2689 AddItem(_lc[I_MENU_YES]);
2690 AddItem(_lc[I_MENU_NO]);
2691 end;
2692 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2693 begin
2694 Name := 'swMessages';
2695 AddItem(_lc[I_MENU_YES]);
2696 AddItem(_lc[I_MENU_NO]);
2697 end;
2698 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2699 begin
2700 Name := 'swRevertPlayers';
2701 AddItem(_lc[I_MENU_YES]);
2702 AddItem(_lc[I_MENU_NO]);
2703 end;
2704 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2705 begin
2706 Name := 'swChatBubble';
2707 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2708 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2709 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2710 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2711 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2712 end;
2713 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2714 begin
2715 Name := 'scScaleFactor';
2716 Max := 10;
2717 OnChange := ProcChangeGameSettings;
2718 end;
2719 ReAlign();
2720 end;
2721 Menu.DefControl := 'mOptionsGameMenu';
2722 g_GUI_AddWindow(Menu);
2724 Menu := TGUIWindow.Create('OptionsControlsMenu');
2725 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
2726 begin
2727 Name := 'mOptionsControlsMenu';
2728 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
2729 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
2730 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
2731 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
2732 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
2733 AddSpace();
2734 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
2735 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
2736 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
2737 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
2738 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
2739 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
2740 if e_JoysticksAvailable <> 0 then
2741 begin
2742 AddSpace();
2743 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
2744 end;
2745 if g_touch_enabled then
2746 begin
2747 AddSpace();
2748 AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
2749 end;
2750 end;
2751 Menu.DefControl := 'mOptionsControlsMenu';
2752 g_GUI_AddWindow(Menu);
2754 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
2755 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
2756 begin
2757 Name := 'mOptionsControlsP1Menu';
2758 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2759 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2760 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2761 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2762 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2763 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2764 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2765 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2766 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2767 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2768 end;
2769 Menu.DefControl := 'mOptionsControlsP1Menu';
2770 g_GUI_AddWindow(Menu);
2772 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
2773 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
2774 begin
2775 Name := 'mOptionsControlsP1MenuWeapons';
2776 for i := WP_FIRST to WP_LAST do
2777 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2778 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2779 end;
2780 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
2781 g_GUI_AddWindow(Menu);
2783 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
2784 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
2785 begin
2786 Name := 'mOptionsControlsP2Menu';
2787 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2788 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2789 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2790 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2791 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2792 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2793 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2794 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2795 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2796 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2797 end;
2798 Menu.DefControl := 'mOptionsControlsP2Menu';
2799 g_GUI_AddWindow(Menu);
2801 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
2802 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
2803 begin
2804 Name := 'mOptionsControlsP2MenuWeapons';
2805 for i := WP_FIRST to WP_LAST do
2806 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2807 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2808 end;
2809 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
2810 g_GUI_AddWindow(Menu);
2812 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
2813 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
2814 begin
2815 Name := 'mOptionsControlsJoystickMenu';
2816 for i := 0 to e_JoysticksAvailable-1 do
2817 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
2818 begin
2819 Name := 'scDeadzone' + IntToStr(i);
2820 Max := 20;
2821 end;
2822 end;
2823 Menu.DefControl := 'mOptionsControlsJoystickMenu';
2824 g_GUI_AddWindow(Menu);
2826 Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
2827 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do
2828 begin
2829 Name := 'mOptionsControlsTouchMenu';
2830 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
2831 begin
2832 Name := 'swTouchAlt';
2833 AddItem(_lc[I_MENU_NO]);
2834 AddItem(_lc[I_MENU_YES]);
2835 OnChange := ProcChangeTouchSettings;
2836 end;
2837 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
2838 begin
2839 Name := 'scTouchSize';
2840 Max := 20;
2841 OnChange := ProcChangeTouchSettings;
2842 end;
2843 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
2844 begin
2845 Name := 'swTouchFire';
2846 AddItem(_lc[I_MENU_NO]);
2847 AddItem(_lc[I_MENU_YES]);
2848 end;
2849 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do
2850 begin
2851 Name := 'scTouchOffset';
2852 Max := 20;
2853 OnChange := ProcChangeTouchSettings;
2854 end;
2855 end;
2856 Menu.DefControl := 'mOptionsControlsTouchMenu';
2857 g_GUI_AddWindow(Menu);
2859 Menu := TGUIWindow.Create('OptionsPlayersMenu');
2860 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
2861 begin
2862 Name := 'mOptionsPlayersMenu';
2863 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
2864 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
2865 end;
2866 Menu.DefControl := 'mOptionsPlayersMenu';
2867 g_GUI_AddWindow(Menu);
2869 CreatePlayerOptionsMenu('P1');
2870 CreatePlayerOptionsMenu('P2');
2872 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
2873 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
2874 begin
2875 Name := 'mOptionsPlayersMIMenu';
2876 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
2877 begin
2878 Name := 'lbName';
2879 FixedLength := 16;
2880 end;
2881 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
2882 begin
2883 Name := 'lbAuthor';
2884 FixedLength := 16;
2885 end;
2886 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
2887 begin
2888 Name := 'meComment';
2889 end;
2890 AddSpace();
2891 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
2892 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
2893 begin
2894 Name := 'lbWeapon';
2895 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
2896 end;
2897 ReAlign();
2898 end;
2899 Menu.DefControl := 'mOptionsPlayersMIMenu';
2900 g_GUI_AddWindow(Menu);
2902 Menu := TGUIWindow.Create('OptionsLanguageMenu');
2903 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
2904 begin
2905 Name := 'mOptionsLanguageMenu';
2906 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
2907 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
2908 ReAlign();
2909 end;
2910 Menu.DefControl := 'mOptionsLanguageMenu';
2911 g_GUI_AddWindow(Menu);
2913 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
2914 gMenuSmallFont, @ProcDefaultMenuKeyDown);
2915 g_GUI_AddWindow(Menu);
2917 Menu := TGUIWindow.Create('AuthorsMenu');
2918 Menu.BackTexture := 'INTER';
2919 Menu.OnClose := ProcAuthorsClose;
2921 // Çàãîëîâîê:
2922 _y := 16;
2923 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
2924 begin
2925 Color := _RGB(255, 0, 0);
2926 X := (gScreenWidth div 2)-(GetWidth() div 2);
2927 Y := _y;
2928 _y := _y+GetHeight();
2929 end;
2930 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
2931 begin
2932 Color := _RGB(255, 0, 0);
2933 X := (gScreenWidth div 2)-(GetWidth() div 2);
2934 Y := _y;
2935 _y := _y+GetHeight()+32;
2936 end;
2937 // ×òî äåëàë: Êòî äåëàë
2938 cx := gScreenWidth div 2 - 320 + 64;
2939 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
2940 begin
2941 Color := _RGB(255, 0, 0);
2942 X := cx;
2943 Y := _y;
2944 _y := _y+22;
2945 end;
2946 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
2947 begin
2948 Color := _RGB(255, 255, 255);
2949 X := cx+32;
2950 Y := _y;
2951 _y := _y+36;
2952 end;
2953 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
2954 begin
2955 Color := _RGB(255, 0, 0);
2956 X := cx;
2957 Y := _y;
2958 _y := _y+22;
2959 end;
2960 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
2961 begin
2962 Color := _RGB(255, 255, 255);
2963 X := cx+32;
2964 Y := _y;
2965 _y := _y+22;
2966 end;
2967 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
2968 begin
2969 Color := _RGB(255, 255, 255);
2970 X := cx+32;
2971 Y := _y;
2972 _y := _y+36;
2973 end;
2974 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
2975 begin
2976 Color := _RGB(255, 0, 0);
2977 X := cx;
2978 Y := _y;
2979 _y := _y+22;
2980 end;
2981 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
2982 begin
2983 Color := _RGB(255, 255, 255);
2984 X := cx+32;
2985 Y := _y;
2986 _y := _y+36;
2987 end;
2988 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
2989 begin
2990 Color := _RGB(255, 0, 0);
2991 X := cx;
2992 Y := _y;
2993 _y := _y+22;
2994 end;
2995 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
2996 begin
2997 Color := _RGB(255, 255, 255);
2998 X := cx+32;
2999 Y := _y;
3000 _y := gScreenHeight - 128;
3001 end;
3002 // Çàêëþ÷åíèå:
3003 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
3004 begin
3005 Color := _RGB(255, 0, 0);
3006 X := cx;
3007 Y := _y;
3008 _y := _y+16;
3009 end;
3010 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
3011 begin
3012 Color := _RGB(255, 255, 255);
3013 X := cx+32;
3014 Y := _y;
3015 _y := _y+GetHeight();
3016 end;
3017 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
3018 begin
3019 Color := _RGB(255, 255, 255);
3020 X := cx+32;
3021 Y := _y;
3022 _y := _y+GetHeight();
3023 end;
3024 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
3025 begin
3026 Color := _RGB(255, 255, 255);
3027 X := cx+32;
3028 Y := _y;
3029 _y := gScreenHeight - 32;
3030 end;
3031 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
3032 begin
3033 Color := _RGB(255, 0, 0);
3034 X := gScreenWidth div 2 - GetWidth() div 2;
3035 Y := _y;
3036 end;
3037 g_GUI_AddWindow(Menu);
3039 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
3040 gMenuSmallFont, @ProcExitMenuKeyDown);
3041 g_GUI_AddWindow(Menu);
3043 Menu := TGUIWindow.Create('GameSingleMenu');
3044 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3045 begin
3046 Name := 'mmGameSingleMenu';
3047 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3048 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3049 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3050 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3051 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3052 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3053 end;
3054 Menu.DefControl := 'mmGameSingleMenu';
3055 Menu.MainWindow := True;
3056 Menu.OnClose := ProcGMClose;
3057 Menu.OnShow := ProcGMShow;
3058 g_GUI_AddWindow(Menu);
3060 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
3061 gMenuSmallFont, @ProcEndMenuKeyDown);
3062 g_GUI_AddWindow(Menu);
3064 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
3065 gMenuSmallFont, @ProcRestartMenuKeyDown);
3066 g_GUI_AddWindow(Menu);
3068 Menu := TGUIWindow.Create('GameCustomMenu');
3069 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3070 begin
3071 Name := 'mmGameCustomMenu';
3072 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3073 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3074 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3075 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3076 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3077 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3078 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3079 end;
3080 Menu.DefControl := 'mmGameCustomMenu';
3081 Menu.MainWindow := True;
3082 Menu.OnClose := ProcGMClose;
3083 Menu.OnShow := ProcGMShow;
3084 g_GUI_AddWindow(Menu);
3086 Menu := TGUIWindow.Create('GameServerMenu');
3087 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3088 begin
3089 Name := 'mmGameServerMenu';
3090 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3091 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3092 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3093 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3094 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3095 end;
3096 Menu.DefControl := 'mmGameServerMenu';
3097 Menu.MainWindow := True;
3098 Menu.OnClose := ProcGMClose;
3099 Menu.OnShow := ProcGMShow;
3100 g_GUI_AddWindow(Menu);
3102 Menu := TGUIWindow.Create('GameClientMenu');
3103 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3104 begin
3105 Name := 'mmGameClientMenu';
3106 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3107 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3108 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3109 end;
3110 Menu.DefControl := 'mmGameClientMenu';
3111 Menu.MainWindow := True;
3112 Menu.OnClose := ProcGMClose;
3113 Menu.OnShow := ProcGMShow;
3114 g_GUI_AddWindow(Menu);
3116 Menu := TGUIWindow.Create('ClientPasswordMenu');
3117 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
3118 begin
3119 Name := 'mClientPasswordMenu';
3120 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3121 begin
3122 Name := 'edPW';
3123 Width := 12;
3124 MaxLength := 32;
3125 end;
3126 AddSpace;
3128 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3129 ReAlign();
3130 end;
3131 Menu.DefControl := 'mClientPasswordMenu';
3132 g_GUI_AddWindow(Menu);
3134 Menu := TGUIWindow.Create('GameSetGameMenu');
3135 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3136 begin
3137 Name := 'mGameSetGameMenu';
3138 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3139 begin
3140 Name := 'swTeamDamage';
3141 AddItem(_lc[I_MENU_YES]);
3142 AddItem(_lc[I_MENU_NO]);
3143 ItemIndex := 1;
3144 end;
3145 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3146 begin
3147 Name := 'edTimeLimit';
3148 OnlyDigits := True;
3149 Width := 4;
3150 MaxLength := 5;
3151 end;
3152 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
3153 begin
3154 Name := 'edGoalLimit';
3155 OnlyDigits := True;
3156 Width := 4;
3157 MaxLength := 5;
3158 end;
3159 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3160 begin
3161 Name := 'edMaxLives';
3162 OnlyDigits := True;
3163 Width := 4;
3164 MaxLength := 5;
3165 end;
3166 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3167 begin
3168 Name := 'swBotsVS';
3169 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3170 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3171 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3172 ItemIndex := 2;
3173 end;
3175 ReAlign();
3176 end;
3177 Menu.DefControl := 'mGameSetGameMenu';
3178 Menu.OnClose := ProcApplyGameSet;
3179 g_GUI_AddWindow(Menu);
3181 Menu := TGUIWindow.Create('TeamMenu');
3182 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_CHANGE_PLAYERS]))) do
3183 begin
3184 Name := 'mmTeamMenu';
3185 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3186 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3187 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3188 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3189 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3190 end;
3191 Menu.DefControl := 'mmTeamMenu';
3192 Menu.OnShow := ProcChangePlayers;
3193 g_GUI_AddWindow(Menu);
3194 end;
3196 procedure g_Menu_Show_SaveMenu();
3197 begin
3198 if g_Game_IsTestMap then
3199 Exit;
3200 if gGameSettings.GameType = GT_SINGLE then
3201 g_GUI_ShowWindow('GameSingleMenu')
3202 else
3203 begin
3204 if g_Game_IsClient then
3205 Exit
3206 else
3207 if g_Game_IsNet then
3208 Exit
3209 else
3210 g_GUI_ShowWindow('GameCustomMenu');
3211 end;
3212 g_GUI_ShowWindow('SaveMenu');
3213 g_Sound_PlayEx('MENU_OPEN');
3214 end;
3216 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3217 begin
3218 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3219 if gGameSettings.GameType = GT_SINGLE then
3220 begin
3221 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3222 end
3223 else
3224 begin
3225 if g_Game_IsClient then exit;
3226 if g_Game_IsNet then exit;
3227 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3228 end;
3229 g_GUI_ShowWindow('LoadMenu');
3230 g_Sound_PlayEx('MENU_OPEN');
3231 end;
3233 procedure g_Menu_Show_GameSetGame();
3234 begin
3235 if gGameSettings.GameType = GT_SINGLE then
3236 g_GUI_ShowWindow('GameSingleMenu')
3237 else
3238 begin
3239 if g_Game_IsClient then
3240 Exit
3241 else
3242 if g_Game_IsNet then
3243 g_GUI_ShowWindow('GameServerMenu')
3244 else
3245 g_GUI_ShowWindow('GameCustomMenu');
3246 end;
3247 ReadGameSettings();
3248 g_GUI_ShowWindow('GameSetGameMenu');
3249 g_Sound_PlayEx('MENU_OPEN');
3250 end;
3252 procedure g_Menu_Show_OptionsVideo();
3253 begin
3254 if gGameSettings.GameType = GT_SINGLE then
3255 g_GUI_ShowWindow('GameSingleMenu')
3256 else
3257 begin
3258 if g_Game_IsClient then
3259 g_GUI_ShowWindow('GameClientMenu')
3260 else
3261 if g_Game_IsNet then
3262 g_GUI_ShowWindow('GameServerMenu')
3263 else
3264 g_GUI_ShowWindow('GameCustomMenu');
3265 end;
3266 ReadOptions();
3267 g_GUI_ShowWindow('OptionsMenu');
3268 g_GUI_ShowWindow('OptionsVideoMenu');
3269 g_Sound_PlayEx('MENU_OPEN');
3270 end;
3272 procedure g_Menu_Show_OptionsSound();
3273 begin
3274 if gGameSettings.GameType = GT_SINGLE then
3275 g_GUI_ShowWindow('GameSingleMenu')
3276 else
3277 begin
3278 if g_Game_IsClient then
3279 g_GUI_ShowWindow('GameClientMenu')
3280 else
3281 if g_Game_IsNet then
3282 g_GUI_ShowWindow('GameServerMenu')
3283 else
3284 g_GUI_ShowWindow('GameCustomMenu');
3285 end;
3286 ReadOptions();
3287 g_GUI_ShowWindow('OptionsMenu');
3288 g_GUI_ShowWindow('OptionsSoundMenu');
3289 g_Sound_PlayEx('MENU_OPEN');
3290 end;
3292 procedure g_Menu_Show_EndGameMenu();
3293 begin
3294 g_GUI_ShowWindow('EndGameMenu');
3295 g_Sound_PlayEx('MENU_OPEN');
3296 end;
3298 procedure g_Menu_Show_QuitGameMenu();
3299 begin
3300 g_GUI_ShowWindow('ExitMenu');
3301 g_Sound_PlayEx('MENU_OPEN');
3302 end;
3304 procedure g_Menu_Init();
3305 begin
3306 MenuLoadData();
3307 g_GUI_Init();
3308 CreateAllMenus();
3309 end;
3311 procedure g_Menu_Free();
3312 begin
3313 g_GUI_Destroy();
3315 e_WriteLog('Releasing menu data...', TMsgType.Notify);
3317 MenuFreeData();
3318 end;
3320 procedure g_Menu_Reset();
3321 var
3322 ex: Boolean;
3323 begin
3324 g_GUI_SaveMenuPos();
3325 ex := g_GUI_Destroy();
3327 if ex then
3328 begin
3329 e_WriteLog('Recreating menu...', TMsgType.Notify);
3331 CreateAllMenus();
3333 if gDebugMode then
3334 g_Game_SetDebugMode();
3336 g_GUI_LoadMenuPos();
3337 end;
3338 end;
3340 end.