DEADSOFTWARE

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