DEADSOFTWARE

save/load UI cosmetix
[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...', MSG_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 if Direction = D_LEFT then Direction := D_RIGHT else Direction := D_LEFT;
1304 end;
1306 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1307 begin
1308 if yes then
1309 begin
1310 g_Options_SetDefault();
1311 ReadOptions();
1312 end;
1313 g_GUI_HideWindow();
1314 end;
1316 procedure ProcSavedMenuKeyDown (yes: Boolean);
1317 begin
1318 if yes then ReadOptions();
1319 g_GUI_HideWindow();
1320 end;
1322 procedure ProcAuthorsClose();
1323 begin
1324 gMusic.SetByName('MUSIC_MENU');
1325 gMusic.Play();
1326 gState := STATE_MENU;
1327 end;
1329 procedure ProcGMClose();
1330 begin
1331 g_Game_InGameMenu(False);
1332 end;
1334 procedure ProcGMShow();
1335 var
1336 Enabled: Boolean;
1337 begin
1338 Enabled := True;
1339 if (gGameSettings.GameType = GT_SINGLE) and
1340 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1341 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1342 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1343 if not gGameOn then
1344 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1345 if g_Game_IsTestMap then
1346 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1347 TGUIMainMenu(g_ActiveWindow.GetControl(
1348 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1349 end;
1351 procedure ProcChangePlayers();
1352 var
1353 TeamGame, Spectator, AddTwo: Boolean;
1354 P1Team{, P2Team}: Byte;
1355 bP2: TGUITextButton;
1356 begin
1357 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1358 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1359 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1360 P1Team := TEAM_NONE;
1361 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1362 // TODO
1363 //P2Team := TEAM_NONE;
1364 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1366 TGUIMainMenu(g_ActiveWindow.GetControl(
1367 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1368 TGUIMainMenu(g_ActiveWindow.GetControl(
1369 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1370 TGUIMainMenu(g_ActiveWindow.GetControl(
1371 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1373 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1374 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1375 bP2.Enabled := AddTwo and not Spectator;
1376 if bP2.Enabled then
1377 bP2.Color := MAINMENU_ITEMS_COLOR
1378 else
1379 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1380 if gPlayer2 = nil then
1381 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1382 else
1383 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1385 TGUIMainMenu(g_ActiveWindow.GetControl(
1386 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1387 end;
1389 procedure ProcJoinRed();
1390 begin
1391 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1392 Exit;
1393 if g_Game_IsServer then
1394 begin
1395 if gPlayer1 = nil then
1396 g_Game_AddPlayer(TEAM_RED)
1397 else
1398 begin
1399 if gPlayer1.Team <> TEAM_RED then
1400 begin
1401 gPlayer1.SwitchTeam;
1402 gPlayer1Settings.Team := gPlayer1.Team;
1403 end;
1405 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1406 end;
1407 end
1408 else
1409 begin
1410 gPlayer1Settings.Team := TEAM_RED;
1411 MC_SEND_PlayerSettings;
1412 if gPlayer1 = nil then
1413 g_Game_AddPlayer(TEAM_RED);
1414 end;
1415 g_ActiveWindow := nil;
1416 g_Game_Pause(False);
1417 end;
1419 procedure ProcJoinBlue();
1420 begin
1421 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1422 Exit;
1423 if g_Game_IsServer then
1424 begin
1425 if gPlayer1 = nil then
1426 g_Game_AddPlayer(TEAM_BLUE)
1427 else
1428 begin
1429 if gPlayer1.Team <> TEAM_BLUE then
1430 begin
1431 gPlayer1.SwitchTeam;
1432 gPlayer1Settings.Team := gPlayer1.Team;
1433 end;
1435 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1436 end;
1437 end
1438 else
1439 begin
1440 gPlayer1Settings.Team := TEAM_BLUE;
1441 MC_SEND_PlayerSettings;
1442 if gPlayer1 = nil then
1443 g_Game_AddPlayer(TEAM_BLUE);
1444 end;
1445 g_ActiveWindow := nil;
1446 g_Game_Pause(False);
1447 end;
1449 procedure ProcJoinGame();
1450 begin
1451 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1452 Exit;
1453 if gPlayer1 = nil then
1454 g_Game_AddPlayer();
1455 g_ActiveWindow := nil;
1456 g_Game_Pause(False);
1457 end;
1459 procedure ProcSwitchP2();
1460 begin
1461 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1462 Exit;
1463 if gPlayer1 = nil then
1464 Exit;
1465 if gPlayer2 = nil then
1466 g_Game_AddPlayer()
1467 else
1468 g_Game_RemovePlayer();
1469 g_ActiveWindow := nil;
1470 g_Game_Pause(False);
1471 end;
1473 procedure ProcSpectate();
1474 begin
1475 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1476 Exit;
1477 g_Game_Spectate();
1478 g_ActiveWindow := nil;
1479 g_Game_Pause(False);
1480 end;
1482 procedure ProcRestartMenuKeyDown (yes: Boolean);
1483 begin
1484 if yes then g_Game_Restart() else g_GUI_HideWindow;
1485 end;
1487 procedure ProcEndMenuKeyDown (yes: Boolean);
1488 begin
1489 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1490 end;
1492 procedure ProcSetRussianLanguage();
1493 begin
1494 if gLanguage <> LANGUAGE_RUSSIAN then
1495 begin
1496 gLanguage := LANGUAGE_RUSSIAN;
1497 gLanguageChange := True;
1498 gAskLanguage := False;
1500 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1502 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1503 ProcApplyOptions();
1504 end;
1505 end;
1507 procedure ProcSetEnglishLanguage();
1508 begin
1509 if gLanguage <> LANGUAGE_ENGLISH then
1510 begin
1511 gLanguage := LANGUAGE_ENGLISH;
1512 gLanguageChange := True;
1513 gAskLanguage := False;
1515 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1517 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1518 ProcApplyOptions();
1519 end;
1520 end;
1522 procedure ReadGameSettings();
1523 var
1524 menu: TGUIMenu;
1525 begin
1526 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1528 with gGameSettings do
1529 begin
1530 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1531 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1532 ItemIndex := 0
1533 else
1534 ItemIndex := 1;
1536 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1537 TGUIEdit(menu.GetControl('edGoalLimit')).Text := IntToStr(GoalLimit);
1538 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1540 with TGUISwitch(menu.GetControl('swBotsVS')) do
1541 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1542 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1543 ItemIndex := 2
1544 else
1545 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1546 ItemIndex := 1
1547 else
1548 ItemIndex := 0;
1550 if GameType in [GT_CUSTOM, GT_SERVER] then
1551 begin
1552 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1553 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1554 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1555 TGUIEdit(menu.GetControl('edGoalLimit')).Enabled := True;
1556 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_ITEMSTEXT_COLOR;
1557 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1558 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1559 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1560 end
1561 else
1562 begin
1563 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1564 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1565 begin
1566 Enabled := False;
1567 Text := '';
1568 end;
1569 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1570 with TGUIEdit(menu.GetControl('edGoalLimit')) do
1571 begin
1572 Enabled := False;
1573 Text := '';
1574 end;
1575 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1576 with TGUIEdit(menu.GetControl('edMaxLives')) do
1577 begin
1578 Enabled := False;
1579 Text := '';
1580 end;
1581 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1582 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1583 end;
1584 end;
1585 end;
1587 procedure ProcApplyGameSet();
1588 var
1589 menu: TGUIMenu;
1590 a, b, n: Integer;
1591 stat: TPlayerStatArray;
1592 begin
1593 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1595 if not g_Game_IsServer then Exit;
1597 with gGameSettings do
1598 begin
1599 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1600 begin
1601 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1602 Options := Options or GAME_OPTION_TEAMDAMAGE
1603 else
1604 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1605 end;
1607 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1608 begin
1609 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1611 if n = 0 then
1612 TimeLimit := 0
1613 else
1614 begin
1615 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1617 TimeLimit := Max(n, b);
1618 end;
1619 end;
1621 if TGUIEdit(menu.GetControl('edGoalLimit')).Enabled then
1622 begin
1623 n := StrToIntDef(TGUIEdit(menu.GetControl('edGoalLimit')).Text, GoalLimit);
1625 if n = 0 then
1626 GoalLimit := 0
1627 else
1628 begin
1629 b := 0;
1630 if GameMode = GM_DM then
1631 begin // DM
1632 stat := g_Player_GetStats();
1633 if stat <> nil then
1634 for a := 0 to High(stat) do
1635 if stat[a].Frags > b then
1636 b := stat[a].Frags;
1637 end
1638 else // CTF
1639 b := Max(gTeamStat[TEAM_RED].Goals, gTeamStat[TEAM_BLUE].Goals);
1641 GoalLimit := Max(n, b);
1642 end;
1643 end;
1645 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1646 begin
1647 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, GoalLimit);
1648 if n < 0 then n := 0;
1649 if n > 255 then n := 255;
1650 if n = 0 then
1651 MaxLives := 0
1652 else
1653 begin
1654 b := 0;
1655 stat := g_Player_GetStats();
1656 if stat <> nil then
1657 for a := 0 to High(stat) do
1658 if stat[a].Lives > b then
1659 b := stat[a].Lives;
1661 MaxLives := Max(n, b);
1662 end;
1663 end;
1665 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1666 begin
1667 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1668 1:
1669 begin
1670 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1671 Options := Options or GAME_OPTION_BOTVSMONSTER;
1672 end;
1673 2:
1674 begin
1675 Options := Options or GAME_OPTION_BOTVSPLAYER;
1676 Options := Options or GAME_OPTION_BOTVSMONSTER;
1677 end;
1678 else
1679 begin
1680 Options := Options or GAME_OPTION_BOTVSPLAYER;
1681 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1682 end;
1683 end;
1684 end;
1685 end;
1687 if g_Game_IsNet then MH_SEND_GameSettings;
1688 end;
1690 procedure ProcVideoOptionsRes();
1691 var
1692 menu: TGUIMenu;
1693 list: SArray;
1694 SR: DWORD;
1695 begin
1696 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1698 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1699 IntToStr(gScreenWidth) +
1700 ' x ' + IntToStr(gScreenHeight) +
1701 ', ' + IntToStr(gBPP) + ' bpp';
1703 with TGUIListBox(menu.GetControl('lsResolution')) do
1704 begin
1705 list := GetDisplayModes(gBPP, SR);
1707 if list <> nil then
1708 begin
1709 Items := list;
1710 ItemIndex := SR;
1711 end
1712 else
1713 Clear();
1714 end;
1716 with TGUISwitch(menu.GetControl('swFullScreen')) do
1717 if gFullscreen then
1718 ItemIndex := 0
1719 else
1720 ItemIndex := 1;
1721 end;
1723 procedure ProcApplyVideoOptions();
1724 var
1725 menu: TGUIMenu;
1726 Fullscreen: Boolean;
1727 SWidth, SHeight: Integer;
1728 str: String;
1729 begin
1730 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1732 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1733 SScanf(str, '%dx%d', [@SWidth, @SHeight]);
1735 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1737 if (SWidth <> gScreenWidth) or
1738 (SHeight <> gScreenHeight) or
1739 (Fullscreen <> gFullscreen) then
1740 begin
1741 gResolutionChange := True;
1742 gRC_Width := SWidth;
1743 gRC_Height := SHeight;
1744 gRC_FullScreen := Fullscreen;
1745 gRC_Maximized := gWinMaximized;
1746 end;
1748 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1749 ProcApplyOptions();
1750 end;
1752 procedure ProcSetFirstRussianLanguage();
1753 begin
1754 gLanguage := LANGUAGE_RUSSIAN;
1755 gLanguageChange := True;
1756 gAskLanguage := False;
1758 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1759 end;
1761 procedure ProcSetFirstEnglishLanguage();
1762 begin
1763 gLanguage := LANGUAGE_ENGLISH;
1764 gLanguageChange := True;
1765 gAskLanguage := False;
1767 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1768 end;
1770 procedure ProcRecallAddress();
1771 begin
1772 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1773 begin
1774 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1775 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1776 end;
1777 end;
1779 procedure CreateFirstLanguageMenu();
1780 var
1781 Menu: TGUIWindow;
1782 begin
1783 Menu := TGUIWindow.Create('FirstLanguageMenu');
1785 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, ' '))) do
1786 begin
1787 Name := 'mmFirstLanguageMenu';
1788 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
1789 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
1790 end;
1792 Menu.DefControl := 'mmFirstLanguageMenu';
1793 Menu.MainWindow := True;
1794 g_GUI_AddWindow(Menu);
1795 end;
1797 procedure g_Menu_AskLanguage();
1798 begin
1799 CreateFirstLanguageMenu();
1800 g_GUI_ShowWindow('FirstLanguageMenu');
1801 end;
1803 procedure CreatePlayerOptionsMenu(s: String);
1804 var
1805 Menu: TGUIWindow;
1806 a: String;
1807 begin
1808 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
1809 if s = 'P1' then
1810 a := _lc[I_MENU_PLAYER_1]
1811 else
1812 a := _lc[I_MENU_PLAYER_2];
1813 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
1814 begin
1815 Name := 'mOptionsPlayers'+s+'Menu';
1816 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
1817 begin
1818 Name := 'ed'+s+'Name';
1819 MaxLength := 12;
1820 Width := 12;
1821 end;
1822 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
1823 begin
1824 Name := 'sw'+s+'Team';
1825 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
1826 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
1827 end ;
1828 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
1829 begin
1830 Name := 'ls'+s+'Model';
1831 Sort := True;
1832 Items := g_PlayerModel_GetNames();
1833 OnChange := ProcSelectModel;
1834 end;
1835 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
1836 begin
1837 Name := 'sc'+s+'Red';
1838 Max := 16;
1839 OnChange := ProcChangeColor;
1840 end;
1841 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
1842 begin
1843 Name := 'sc'+s+'Green';
1844 Max := 16;
1845 OnChange := ProcChangeColor;
1846 end;
1847 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
1848 begin
1849 Name := 'sc'+s+'Blue';
1850 Max := 16;
1851 OnChange := ProcChangeColor;
1852 end;
1853 AddSpace();
1854 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
1855 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
1856 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
1857 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
1859 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
1860 begin
1861 Name := 'mv'+s+'Model';
1862 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
1863 Y := GetControl('ls'+s+'Model').Y;
1864 end;
1865 end;
1866 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
1867 g_GUI_AddWindow(Menu);
1868 end;
1870 procedure CreateAllMenus();
1871 var
1872 Menu: TGUIWindow;
1873 //SR: TSearchRec;
1874 a, cx, _y, i: Integer;
1875 //list: SArray;
1876 begin
1877 Menu := TGUIWindow.Create('MainMenu');
1878 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
1879 begin
1880 Name := 'mmMainMenu';
1881 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
1882 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
1883 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
1884 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
1885 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
1886 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
1887 end;
1888 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
1889 begin
1890 Color := _RGB(255, 255, 255);
1891 X := gScreenWidth-GetWidth-8;
1892 Y := gScreenHeight-GetHeight-8;
1893 end;
1894 Menu.DefControl := 'mmMainMenu';
1895 Menu.MainWindow := True;
1896 g_GUI_AddWindow(Menu);
1898 Menu := TGUIWindow.Create('NewGameMenu');
1899 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_NEW_GAME]))) do
1900 begin
1901 Name := 'mmNewGameMenu';
1902 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
1903 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
1904 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
1905 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
1906 end;
1907 Menu.DefControl := 'mmNewGameMenu';
1908 g_GUI_AddWindow(Menu);
1910 Menu := TGUIWindow.Create('NetGameMenu');
1911 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MULTIPLAYER]))) do
1912 begin
1913 Name := 'mmNetGameMenu';
1914 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
1915 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
1916 end;
1917 Menu.DefControl := 'mmNetGameMenu';
1918 g_GUI_AddWindow(Menu);
1920 Menu := TGUIWindow.Create('NetServerMenu');
1921 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
1922 begin
1923 Name := 'mNetServerMenu';
1924 with AddEdit(_lc[I_NET_SERVER_NAME]) do
1925 begin
1926 Name := 'edSrvName';
1927 OnlyDigits := False;
1928 Width := 16;
1929 MaxLength := 64;
1930 Text := NetServerName;
1931 end;
1932 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
1933 begin
1934 Name := 'edSrvPassword';
1935 OnlyDigits := False;
1936 Width := 16;
1937 MaxLength := 24;
1938 Text := NetPassword;
1939 end;
1940 with AddEdit(_lc[I_NET_PORT]) do
1941 begin
1942 Name := 'edPort';
1943 OnlyDigits := True;
1944 Width := 4;
1945 MaxLength := 5;
1946 Text := IntToStr(NetPort);
1947 end;
1948 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
1949 begin
1950 Name := 'edMaxPlayers';
1951 OnlyDigits := True;
1952 Width := 4;
1953 MaxLength := 2;
1954 Text := IntToStr(NetMaxClients);
1955 end;
1956 with AddSwitch(_lc[I_NET_USE_MASTER]) do
1957 begin
1958 Name := 'swUseMaster';
1959 AddItem(_lc[I_MENU_YES]);
1960 AddItem(_lc[I_MENU_NO]);
1961 if NetUseMaster then
1962 ItemIndex := 0
1963 else
1964 ItemIndex := 1;
1965 end;
1966 AddSpace();
1967 with AddLabel(_lc[I_MENU_MAP]) do
1968 begin
1969 Name := 'lbMap';
1970 FixedLength := 16;
1971 Text := gnMap;
1972 OnClick := @ProcSelectMapMenu;
1973 end;
1974 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
1975 begin
1976 Name := 'swGameMode';
1977 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
1978 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
1979 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
1980 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
1981 case g_Game_TextToMode(gnGameMode) of
1982 GM_NONE,
1983 GM_DM: ItemIndex := 0;
1984 GM_TDM: ItemIndex := 1;
1985 GM_CTF: ItemIndex := 2;
1986 GM_SINGLE,
1987 GM_COOP: ItemIndex := 3;
1988 end;
1989 OnChange := ProcSwitchMonstersNet;
1990 end;
1991 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
1992 begin
1993 Name := 'edTimeLimit';
1994 OnlyDigits := True;
1995 Width := 4;
1996 MaxLength := 5;
1997 if gnTimeLimit > 0 then
1998 Text := IntToStr(gnTimeLimit);
1999 end;
2000 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2001 begin
2002 Name := 'edGoalLimit';
2003 OnlyDigits := True;
2004 Width := 4;
2005 MaxLength := 5;
2006 if gnGoalLimit > 0 then
2007 Text := IntToStr(gnGoalLimit);
2008 end;
2009 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2010 begin
2011 Name := 'edMaxLives';
2012 OnlyDigits := True;
2013 Width := 4;
2014 MaxLength := 3;
2015 if gnMaxLives > 0 then
2016 Text := IntToStr(gnMaxLives);
2017 end;
2018 with AddSwitch(_lc[I_MENU_SERVER_PLAYERS]) do
2019 begin
2020 Name := 'swPlayers';
2021 AddItem(_lc[I_MENU_COUNT_NONE]);
2022 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2023 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2024 ItemIndex := gnPlayers;
2025 end;
2026 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2027 begin
2028 Name := 'swTeamDamage';
2029 AddItem(_lc[I_MENU_YES]);
2030 AddItem(_lc[I_MENU_NO]);
2031 if gnTeamDamage then
2032 ItemIndex := 0
2033 else
2034 ItemIndex := 1;
2035 end;
2036 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2037 begin
2038 Name := 'swEnableExits';
2039 AddItem(_lc[I_MENU_YES]);
2040 AddItem(_lc[I_MENU_NO]);
2041 if gnAllowExit then
2042 ItemIndex := 0
2043 else
2044 ItemIndex := 1;
2045 end;
2046 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2047 begin
2048 Name := 'swWeaponStay';
2049 AddItem(_lc[I_MENU_YES]);
2050 AddItem(_lc[I_MENU_NO]);
2051 if gnWeaponStay then
2052 ItemIndex := 0
2053 else
2054 ItemIndex := 1;
2055 end;
2056 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2057 begin
2058 Name := 'swMonsters';
2059 AddItem(_lc[I_MENU_YES]);
2060 AddItem(_lc[I_MENU_NO]);
2061 if gnMonsters then
2062 ItemIndex := 0
2063 else
2064 ItemIndex := 1;
2065 end;
2066 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2067 begin
2068 Name := 'swBotsVS';
2069 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2070 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2071 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2072 ItemIndex := 2;
2073 if gnBotsVS = 'Players' then
2074 ItemIndex := 0;
2075 if gnBotsVS = 'Monsters' then
2076 ItemIndex := 1;
2077 end;
2078 AddSpace();
2079 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2081 ReAlign();
2082 end;
2083 Menu.DefControl := 'mNetServerMenu';
2084 g_GUI_AddWindow(Menu);
2086 Menu := TGUIWindow.Create('NetClientMenu');
2087 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2088 begin
2089 Name := 'mNetClientMenu';
2091 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2092 AddSpace();
2094 with AddEdit(_lc[I_NET_ADDRESS]) do
2095 begin
2096 Name := 'edIP';
2097 OnlyDigits :=False;
2098 Width := 12;
2099 MaxLength := 64;
2100 Text := 'localhost';
2101 end;
2102 with AddEdit(_lc[I_NET_PORT]) do
2103 begin
2104 Name := 'edPort';
2105 OnlyDigits := True;
2106 Width := 4;
2107 MaxLength := 5;
2108 Text := '25666';
2109 end;
2110 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2111 begin
2112 Name := 'edPW';
2113 OnlyDigits := False;
2114 Width := 12;
2115 MaxLength := 32;
2116 Text := '';
2117 end;
2119 AddSpace();
2120 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2122 ReAlign();
2123 end;
2124 Menu.DefControl := 'mNetClientMenu';
2125 g_GUI_AddWindow(Menu);
2127 Menu := TGUIWindow.Create('LoadMenu');
2128 Menu.OnShow := ProcLoadMenu;
2129 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2130 begin
2131 Name := 'mmLoadMenu';
2133 for a := 1 to 8 do
2134 with AddEdit('') do
2135 begin
2136 Name := 'edSlot'+IntToStr(a);
2137 Width := 16;
2138 MaxLength := 16;
2139 OnEnter := ProcLoadGame;
2140 end;
2141 end;
2142 Menu.DefControl := 'mmLoadMenu';
2143 g_GUI_AddWindow(Menu);
2145 Menu := TGUIWindow.Create('SaveMenu');
2146 Menu.OnShow := ProcSaveMenu;
2147 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2148 begin
2149 Name := 'mmSaveMenu';
2151 for a := 1 to 8 do
2152 with AddEdit('') do
2153 begin
2154 Name := 'edSlot'+IntToStr(a);
2155 Width := 16;
2156 MaxLength := 16;
2157 OnChange := ProcSaveGame;
2158 end;
2159 end;
2160 Menu.DefControl := 'mmSaveMenu';
2161 g_GUI_AddWindow(Menu);
2163 Menu := TGUIWindow.Create('CustomGameMenu');
2164 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2165 begin
2166 Name := 'mCustomGameMenu';
2167 with AddLabel(_lc[I_MENU_MAP]) do
2168 begin
2169 Name := 'lbMap';
2170 FixedLength := 16;
2171 Text := gcMap;
2172 OnClick := @ProcSelectMapMenu;
2173 end;
2174 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2175 begin
2176 Name := 'swGameMode';
2177 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2178 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2179 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2180 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2181 case g_Game_TextToMode(gcGameMode) of
2182 GM_NONE,
2183 GM_DM: ItemIndex := 0;
2184 GM_TDM: ItemIndex := 1;
2185 GM_CTF: ItemIndex := 2;
2186 GM_SINGLE,
2187 GM_COOP: ItemIndex := 3;
2188 end;
2189 OnChange := ProcSwitchMonstersCustom;
2190 end;
2191 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2192 begin
2193 Name := 'edTimeLimit';
2194 OnlyDigits := True;
2195 Width := 4;
2196 MaxLength := 5;
2197 if gcTimeLimit > 0 then
2198 Text := IntToStr(gcTimeLimit);
2199 end;
2200 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2201 begin
2202 Name := 'edGoalLimit';
2203 OnlyDigits := True;
2204 Width := 4;
2205 MaxLength := 5;
2206 if gcGoalLimit > 0 then
2207 Text := IntToStr(gcGoalLimit);
2208 end;
2209 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2210 begin
2211 Name := 'edMaxLives';
2212 OnlyDigits := True;
2213 Width := 4;
2214 MaxLength := 5;
2215 if gcMaxLives > 0 then
2216 Text := IntToStr(gcMaxLives);
2217 end;
2218 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2219 begin
2220 Name := 'swPlayers';
2221 AddItem(_lc[I_MENU_COUNT_NONE]);
2222 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2223 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2224 ItemIndex := gcPlayers;
2225 end;
2226 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2227 begin
2228 Name := 'swTeamDamage';
2229 AddItem(_lc[I_MENU_YES]);
2230 AddItem(_lc[I_MENU_NO]);
2231 if gcTeamDamage then
2232 ItemIndex := 0
2233 else
2234 ItemIndex := 1;
2235 end;
2236 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2237 begin
2238 Name := 'swEnableExits';
2239 AddItem(_lc[I_MENU_YES]);
2240 AddItem(_lc[I_MENU_NO]);
2241 if gcAllowExit then
2242 ItemIndex := 0
2243 else
2244 ItemIndex := 1;
2245 end;
2246 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2247 begin
2248 Name := 'swWeaponStay';
2249 AddItem(_lc[I_MENU_YES]);
2250 AddItem(_lc[I_MENU_NO]);
2251 if gcWeaponStay then
2252 ItemIndex := 0
2253 else
2254 ItemIndex := 1;
2255 end;
2256 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2257 begin
2258 Name := 'swMonsters';
2259 AddItem(_lc[I_MENU_YES]);
2260 AddItem(_lc[I_MENU_NO]);
2261 if gcMonsters then
2262 ItemIndex := 0
2263 else
2264 ItemIndex := 1;
2265 end;
2266 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2267 begin
2268 Name := 'swBotsVS';
2269 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2270 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2271 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2272 ItemIndex := 2;
2273 if gcBotsVS = 'Players' then
2274 ItemIndex := 0;
2275 if gcBotsVS = 'Monsters' then
2276 ItemIndex := 1;
2277 end;
2278 AddSpace();
2279 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2281 ReAlign();
2282 end;
2283 Menu.DefControl := 'mCustomGameMenu';
2284 g_GUI_AddWindow(Menu);
2286 Menu := TGUIWindow.Create('CampaignMenu');
2287 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2288 begin
2289 Name := 'mCampaignMenu';
2291 AddSpace();
2292 AddSpace();
2293 AddSpace();
2294 AddSpace();
2295 AddSpace();
2296 AddSpace();
2298 with AddFileList('', 15, 4) do
2299 begin
2300 Name := 'lsWAD';
2301 OnChange := ProcSelectCampaignWAD;
2303 Sort := True;
2304 Dirs := True;
2305 FileMask := '*.wad|*.pk3|*.zip';
2306 SetBase(MapsDir+'megawads/');
2307 end;
2309 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2310 begin
2311 Name := 'lbWADName';
2312 FixedLength := 8;
2313 Enabled := False;
2314 end;
2315 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2316 begin
2317 Name := 'lbWADAuthor';
2318 FixedLength := 8;
2319 Enabled := False;
2320 end;
2321 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2322 with AddMemo('', 15, 3) do
2323 begin
2324 Name := 'meWADDescription';
2325 Color := MENU_ITEMSCTRL_COLOR;
2326 end;
2327 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2328 begin
2329 Name := 'swPlayers';
2330 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2331 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2332 end;
2333 AddSpace();
2334 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2336 ReAlign();
2338 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2339 begin
2340 Name := 'mpWADImage';
2341 DefaultRes := 'NOPIC';
2342 X := GetControl('lsWAD').X+4;
2343 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2344 end;
2345 end;
2346 Menu.DefControl := 'mCampaignMenu';
2347 g_GUI_AddWindow(Menu);
2349 Menu := TGUIWindow.Create('SelectMapMenu');
2350 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2351 begin
2352 Name := 'mSelectMapMenu';
2353 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2354 begin
2355 Name := 'lsMapWAD';
2356 OnChange := ProcSelectWAD;
2358 Sort := True;
2359 Dirs := True;
2360 FileMask := '*.wad|*.pk3|*.zip';
2361 SetBase(MapsDir);
2362 end;
2363 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2364 begin
2365 Name := 'lsMapRes';
2366 Sort := True;
2367 OnChange := ProcSelectMap;
2368 end;
2369 AddSpace();
2370 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2371 begin
2372 Name := 'lbMapName';
2373 FixedLength := 24;
2374 Enabled := False;
2375 end;
2376 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2377 begin
2378 Name := 'lbMapAuthor';
2379 FixedLength := 16;
2380 Enabled := False;
2381 end;
2382 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2383 begin
2384 Name := 'lbMapSize';
2385 FixedLength := 10;
2386 Enabled := False;
2387 end;
2388 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 12, 4) do
2389 begin
2390 Name := 'meMapDescription';
2391 end;
2393 ReAlign();
2395 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2396 begin
2397 Name := 'mpMapPreview';
2398 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2399 Y := GetControl('lsMapWAD').Y;
2400 end;
2401 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2402 begin
2403 Name := 'lbMapScale';
2404 FixedLength := 8;
2405 Enabled := False;
2406 Color := MENU_ITEMSCTRL_COLOR;
2407 X := GetControl('lsMapWAD').X +
2408 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2409 2 + MAPPREVIEW_WIDTH*4;
2410 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2411 end;
2412 end;
2413 Menu.OnClose := ProcSetMap;
2414 Menu.DefControl := 'mSelectMapMenu';
2415 g_GUI_AddWindow(Menu);
2417 Menu := TGUIWindow.Create('OptionsMenu');
2418 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_OPTIONS]))) do
2419 begin
2420 Name := 'mmOptionsMenu';
2421 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2422 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2423 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2424 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2425 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2426 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2427 AddSpace();
2428 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2429 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2430 end;
2431 Menu.OnClose := ProcApplyOptions;
2432 Menu.DefControl := 'mmOptionsMenu';
2433 g_GUI_AddWindow(Menu);
2435 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2436 gMenuSmallFont, @ProcSavedMenuKeyDown);
2437 g_GUI_AddWindow(Menu);
2439 Menu := TGUIWindow.Create('OptionsVideoMenu');
2440 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2441 begin
2442 Name := 'mOptionsVideoMenu';
2443 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2444 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2445 begin
2446 Name := 'swBPP';
2447 AddItem('16');
2448 AddItem('32');
2449 end;
2450 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2451 begin
2452 Name := 'swVSync';
2453 AddItem(_lc[I_MENU_YES]);
2454 AddItem(_lc[I_MENU_NO]);
2455 end;
2456 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2457 begin
2458 Name := 'swTextureFilter';
2459 AddItem(_lc[I_MENU_YES]);
2460 AddItem(_lc[I_MENU_NO]);
2461 end;
2462 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2463 begin
2464 Name := 'swLegacyNPOT';
2465 AddItem(_lc[I_MENU_NO]);
2466 AddItem(_lc[I_MENU_YES]);
2467 end;
2468 AddSpace();
2469 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2470 ReAlign();
2471 end;
2472 Menu.DefControl := 'mOptionsVideoMenu';
2473 g_GUI_AddWindow(Menu);
2475 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2476 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2477 begin
2478 Name := 'mOptionsVideoResMenu';
2479 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2480 begin
2481 Name := 'lbCurrentRes';
2482 FixedLength := 24;
2483 Enabled := False;
2484 end;
2485 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2486 begin
2487 Name := 'lsResolution';
2488 Sort := False;
2489 end;
2490 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2491 begin
2492 Name := 'swFullScreen';
2493 AddItem(_lc[I_MENU_YES]);
2494 AddItem(_lc[I_MENU_NO]);
2495 end;
2496 AddSpace();
2497 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2498 UpdateIndex();
2499 end;
2500 Menu.DefControl := 'mOptionsVideoResMenu';
2501 g_GUI_AddWindow(Menu);
2503 Menu := TGUIWindow.Create('OptionsSoundMenu');
2504 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
2505 begin
2506 Name := 'mOptionsSoundMenu';
2507 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2508 begin
2509 Name := 'scMusicLevel';
2510 Max := 16;
2511 OnChange := ProcChangeSoundSettings;
2512 end;
2513 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2514 begin
2515 Name := 'scSoundLevel';
2516 Max := 16;
2517 OnChange := ProcChangeSoundSettings;
2518 end;
2519 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2520 begin
2521 Name := 'scMaxSimSounds';
2522 Max := 16;
2523 end;
2524 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2525 begin;
2526 Name := 'swAnnouncer';
2527 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2528 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2529 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2530 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2531 end;
2532 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2533 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2534 begin;
2535 Name := 'swSoundEffects';
2536 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2537 AddItem(_lc[I_MENU_COMPAT_DF]);
2538 end;
2539 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2540 begin
2541 Name := 'swInactiveSounds';
2542 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2543 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2544 end;
2545 ReAlign();
2546 end;
2547 Menu.DefControl := 'mOptionsSoundMenu';
2548 g_GUI_AddWindow(Menu);
2550 Menu := TGUIWindow.Create('OptionsGameMenu');
2551 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
2552 begin
2553 Name := 'mOptionsGameMenu';
2554 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2555 begin
2556 Name := 'scParticlesCount';
2557 Max := 20;
2558 end;
2559 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2560 begin
2561 Name := 'swBloodCount';
2562 AddItem(_lc[I_MENU_COUNT_NONE]);
2563 AddItem(_lc[I_MENU_COUNT_SMALL]);
2564 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2565 AddItem(_lc[I_MENU_COUNT_BIG]);
2566 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2567 end;
2568 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2569 begin
2570 Name := 'scShellsMax';
2571 Max := 20;
2572 end;
2573 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2574 begin
2575 Name := 'scGibsMax';
2576 Max := 20;
2577 end;
2578 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2579 begin
2580 Name := 'scCorpsesMax';
2581 Max := 20;
2582 end;
2583 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2584 begin
2585 Name := 'swGibsCount';
2586 AddItem(_lc[I_MENU_COUNT_NONE]);
2587 AddItem(_lc[I_MENU_COUNT_SMALL]);
2588 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2589 AddItem(_lc[I_MENU_COUNT_BIG]);
2590 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2591 end;
2592 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2593 begin
2594 Name := 'swCorpseType';
2595 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2596 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2597 end;
2598 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2599 begin
2600 Name := 'swGibsType';
2601 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2602 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2603 end;
2604 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2605 begin
2606 Name := 'swBloodType';
2607 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2608 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2609 end;
2610 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2611 begin
2612 Name := 'swScreenFlash';
2613 AddItem(_lc[I_MENU_NO]);
2614 AddItem(_lc[I_MENU_COMPAT_DF]);
2615 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2616 end;
2617 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2618 begin
2619 Name := 'swBackground';
2620 AddItem(_lc[I_MENU_YES]);
2621 AddItem(_lc[I_MENU_NO]);
2622 end;
2623 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2624 begin
2625 Name := 'swMessages';
2626 AddItem(_lc[I_MENU_YES]);
2627 AddItem(_lc[I_MENU_NO]);
2628 end;
2629 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2630 begin
2631 Name := 'swRevertPlayers';
2632 AddItem(_lc[I_MENU_YES]);
2633 AddItem(_lc[I_MENU_NO]);
2634 end;
2635 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2636 begin
2637 Name := 'swChatBubble';
2638 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2639 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2640 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2641 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2642 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2643 end;
2644 ReAlign();
2645 end;
2646 Menu.DefControl := 'mOptionsGameMenu';
2647 g_GUI_AddWindow(Menu);
2649 Menu := TGUIWindow.Create('OptionsControlsMenu');
2650 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
2651 begin
2652 Name := 'mOptionsControlsMenu';
2653 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
2654 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
2655 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
2656 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
2657 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
2658 AddSpace();
2659 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
2660 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
2661 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
2662 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
2663 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
2664 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
2665 AddSpace();
2666 if e_JoysticksAvailable <> 0 then
2667 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
2668 end;
2669 Menu.DefControl := 'mOptionsControlsMenu';
2670 g_GUI_AddWindow(Menu);
2672 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
2673 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
2674 begin
2675 Name := 'mOptionsControlsP1Menu';
2676 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2677 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2678 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2679 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2680 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2681 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2682 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2683 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2684 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2685 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2686 end;
2687 Menu.DefControl := 'mOptionsControlsP1Menu';
2688 g_GUI_AddWindow(Menu);
2690 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
2691 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
2692 begin
2693 Name := 'mOptionsControlsP1MenuWeapons';
2694 for i := WP_FIRST to WP_LAST do
2695 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2696 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2697 end;
2698 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
2699 g_GUI_AddWindow(Menu);
2701 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
2702 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
2703 begin
2704 Name := 'mOptionsControlsP2Menu';
2705 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2706 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2707 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2708 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2709 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2710 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2711 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2712 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2713 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2714 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2715 end;
2716 Menu.DefControl := 'mOptionsControlsP2Menu';
2717 g_GUI_AddWindow(Menu);
2719 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
2720 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
2721 begin
2722 Name := 'mOptionsControlsP2MenuWeapons';
2723 for i := WP_FIRST to WP_LAST do
2724 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2725 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2726 end;
2727 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
2728 g_GUI_AddWindow(Menu);
2730 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
2731 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
2732 begin
2733 Name := 'mOptionsControlsJoystickMenu';
2734 for i := 0 to e_JoysticksAvailable-1 do
2735 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
2736 begin
2737 Name := 'scDeadzone' + IntToStr(i);
2738 Max := 20;
2739 end;
2740 end;
2741 Menu.DefControl := 'mOptionsControlsJoystickMenu';
2742 g_GUI_AddWindow(Menu);
2744 Menu := TGUIWindow.Create('OptionsPlayersMenu');
2745 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
2746 begin
2747 Name := 'mOptionsPlayersMenu';
2748 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
2749 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
2750 end;
2751 Menu.DefControl := 'mOptionsPlayersMenu';
2752 g_GUI_AddWindow(Menu);
2754 CreatePlayerOptionsMenu('P1');
2755 CreatePlayerOptionsMenu('P2');
2757 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
2758 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
2759 begin
2760 Name := 'mOptionsPlayersMIMenu';
2761 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
2762 begin
2763 Name := 'lbName';
2764 FixedLength := 16;
2765 end;
2766 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
2767 begin
2768 Name := 'lbAuthor';
2769 FixedLength := 16;
2770 end;
2771 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
2772 begin
2773 Name := 'meComment';
2774 end;
2775 AddSpace();
2776 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
2777 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
2778 begin
2779 Name := 'lbWeapon';
2780 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
2781 end;
2782 ReAlign();
2783 end;
2784 Menu.DefControl := 'mOptionsPlayersMIMenu';
2785 g_GUI_AddWindow(Menu);
2787 Menu := TGUIWindow.Create('OptionsLanguageMenu');
2788 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
2789 begin
2790 Name := 'mOptionsLanguageMenu';
2791 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
2792 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
2793 ReAlign();
2794 end;
2795 Menu.DefControl := 'mOptionsLanguageMenu';
2796 g_GUI_AddWindow(Menu);
2798 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
2799 gMenuSmallFont, @ProcDefaultMenuKeyDown);
2800 g_GUI_AddWindow(Menu);
2802 Menu := TGUIWindow.Create('AuthorsMenu');
2803 Menu.BackTexture := 'INTER';
2804 Menu.OnClose := ProcAuthorsClose;
2806 // Çàãîëîâîê:
2807 _y := 16;
2808 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
2809 begin
2810 Color := _RGB(255, 0, 0);
2811 X := (gScreenWidth div 2)-(GetWidth() div 2);
2812 Y := _y;
2813 _y := _y+GetHeight();
2814 end;
2815 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
2816 begin
2817 Color := _RGB(255, 0, 0);
2818 X := (gScreenWidth div 2)-(GetWidth() div 2);
2819 Y := _y;
2820 _y := _y+GetHeight()+32;
2821 end;
2822 // ×òî äåëàë: Êòî äåëàë
2823 cx := gScreenWidth div 2 - 320 + 64;
2824 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
2825 begin
2826 Color := _RGB(255, 0, 0);
2827 X := cx;
2828 Y := _y;
2829 _y := _y+22;
2830 end;
2831 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
2832 begin
2833 Color := _RGB(255, 255, 255);
2834 X := cx+32;
2835 Y := _y;
2836 _y := _y+36;
2837 end;
2838 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
2839 begin
2840 Color := _RGB(255, 0, 0);
2841 X := cx;
2842 Y := _y;
2843 _y := _y+22;
2844 end;
2845 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
2846 begin
2847 Color := _RGB(255, 255, 255);
2848 X := cx+32;
2849 Y := _y;
2850 _y := _y+22;
2851 end;
2852 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
2853 begin
2854 Color := _RGB(255, 255, 255);
2855 X := cx+32;
2856 Y := _y;
2857 _y := _y+36;
2858 end;
2859 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
2860 begin
2861 Color := _RGB(255, 0, 0);
2862 X := cx;
2863 Y := _y;
2864 _y := _y+22;
2865 end;
2866 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
2867 begin
2868 Color := _RGB(255, 255, 255);
2869 X := cx+32;
2870 Y := _y;
2871 _y := _y+36;
2872 end;
2873 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
2874 begin
2875 Color := _RGB(255, 0, 0);
2876 X := cx;
2877 Y := _y;
2878 _y := _y+22;
2879 end;
2880 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
2881 begin
2882 Color := _RGB(255, 255, 255);
2883 X := cx+32;
2884 Y := _y;
2885 _y := gScreenHeight - 128;
2886 end;
2887 // Çàêëþ÷åíèå:
2888 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
2889 begin
2890 Color := _RGB(255, 0, 0);
2891 X := cx;
2892 Y := _y;
2893 _y := _y+16;
2894 end;
2895 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
2896 begin
2897 Color := _RGB(255, 255, 255);
2898 X := cx+32;
2899 Y := _y;
2900 _y := _y+GetHeight();
2901 end;
2902 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
2903 begin
2904 Color := _RGB(255, 255, 255);
2905 X := cx+32;
2906 Y := _y;
2907 _y := _y+GetHeight();
2908 end;
2909 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
2910 begin
2911 Color := _RGB(255, 255, 255);
2912 X := cx+32;
2913 Y := _y;
2914 _y := gScreenHeight - 32;
2915 end;
2916 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
2917 begin
2918 Color := _RGB(255, 0, 0);
2919 X := gScreenWidth div 2 - GetWidth() div 2;
2920 Y := _y;
2921 end;
2922 g_GUI_AddWindow(Menu);
2924 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
2925 gMenuSmallFont, @ProcExitMenuKeyDown);
2926 g_GUI_AddWindow(Menu);
2928 Menu := TGUIWindow.Create('GameSingleMenu');
2929 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
2930 begin
2931 Name := 'mmGameSingleMenu';
2932 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2933 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
2934 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
2935 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2936 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
2937 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
2938 end;
2939 Menu.DefControl := 'mmGameSingleMenu';
2940 Menu.MainWindow := True;
2941 Menu.OnClose := ProcGMClose;
2942 Menu.OnShow := ProcGMShow;
2943 g_GUI_AddWindow(Menu);
2945 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
2946 gMenuSmallFont, @ProcEndMenuKeyDown);
2947 g_GUI_AddWindow(Menu);
2949 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
2950 gMenuSmallFont, @ProcRestartMenuKeyDown);
2951 g_GUI_AddWindow(Menu);
2953 Menu := TGUIWindow.Create('GameCustomMenu');
2954 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
2955 begin
2956 Name := 'mmGameCustomMenu';
2957 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
2958 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2959 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
2960 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
2961 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2962 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
2963 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
2964 end;
2965 Menu.DefControl := 'mmGameCustomMenu';
2966 Menu.MainWindow := True;
2967 Menu.OnClose := ProcGMClose;
2968 Menu.OnShow := ProcGMShow;
2969 g_GUI_AddWindow(Menu);
2971 Menu := TGUIWindow.Create('GameServerMenu');
2972 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
2973 begin
2974 Name := 'mmGameServerMenu';
2975 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
2976 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
2977 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2978 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
2979 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
2980 end;
2981 Menu.DefControl := 'mmGameServerMenu';
2982 Menu.MainWindow := True;
2983 Menu.OnClose := ProcGMClose;
2984 Menu.OnShow := ProcGMShow;
2985 g_GUI_AddWindow(Menu);
2987 Menu := TGUIWindow.Create('GameClientMenu');
2988 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
2989 begin
2990 Name := 'mmGameClientMenu';
2991 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
2992 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2993 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
2994 end;
2995 Menu.DefControl := 'mmGameClientMenu';
2996 Menu.MainWindow := True;
2997 Menu.OnClose := ProcGMClose;
2998 Menu.OnShow := ProcGMShow;
2999 g_GUI_AddWindow(Menu);
3001 Menu := TGUIWindow.Create('ClientPasswordMenu');
3002 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
3003 begin
3004 Name := 'mClientPasswordMenu';
3005 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3006 begin
3007 Name := 'edPW';
3008 Width := 12;
3009 MaxLength := 32;
3010 end;
3011 AddSpace;
3013 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3014 ReAlign();
3015 end;
3016 Menu.DefControl := 'mClientPasswordMenu';
3017 g_GUI_AddWindow(Menu);
3019 Menu := TGUIWindow.Create('GameSetGameMenu');
3020 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3021 begin
3022 Name := 'mGameSetGameMenu';
3023 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3024 begin
3025 Name := 'swTeamDamage';
3026 AddItem(_lc[I_MENU_YES]);
3027 AddItem(_lc[I_MENU_NO]);
3028 ItemIndex := 1;
3029 end;
3030 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3031 begin
3032 Name := 'edTimeLimit';
3033 OnlyDigits := True;
3034 Width := 4;
3035 MaxLength := 5;
3036 end;
3037 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
3038 begin
3039 Name := 'edGoalLimit';
3040 OnlyDigits := True;
3041 Width := 4;
3042 MaxLength := 5;
3043 end;
3044 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3045 begin
3046 Name := 'edMaxLives';
3047 OnlyDigits := True;
3048 Width := 4;
3049 MaxLength := 5;
3050 end;
3051 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3052 begin
3053 Name := 'swBotsVS';
3054 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3055 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3056 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3057 ItemIndex := 2;
3058 end;
3060 ReAlign();
3061 end;
3062 Menu.DefControl := 'mGameSetGameMenu';
3063 Menu.OnClose := ProcApplyGameSet;
3064 g_GUI_AddWindow(Menu);
3066 Menu := TGUIWindow.Create('TeamMenu');
3067 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_CHANGE_PLAYERS]))) do
3068 begin
3069 Name := 'mmTeamMenu';
3070 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3071 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3072 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3073 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3074 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3075 end;
3076 Menu.DefControl := 'mmTeamMenu';
3077 Menu.OnShow := ProcChangePlayers;
3078 g_GUI_AddWindow(Menu);
3079 end;
3081 procedure g_Menu_Show_SaveMenu();
3082 begin
3083 if g_Game_IsTestMap then
3084 Exit;
3085 if gGameSettings.GameType = GT_SINGLE then
3086 g_GUI_ShowWindow('GameSingleMenu')
3087 else
3088 begin
3089 if g_Game_IsClient then
3090 Exit
3091 else
3092 if g_Game_IsNet then
3093 Exit
3094 else
3095 g_GUI_ShowWindow('GameCustomMenu');
3096 end;
3097 g_GUI_ShowWindow('SaveMenu');
3098 g_Sound_PlayEx('MENU_OPEN');
3099 end;
3101 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3102 begin
3103 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3104 if gGameSettings.GameType = GT_SINGLE then
3105 begin
3106 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3107 end
3108 else
3109 begin
3110 if g_Game_IsClient then exit;
3111 if g_Game_IsNet then exit;
3112 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3113 end;
3114 g_GUI_ShowWindow('LoadMenu');
3115 g_Sound_PlayEx('MENU_OPEN');
3116 end;
3118 procedure g_Menu_Show_GameSetGame();
3119 begin
3120 if gGameSettings.GameType = GT_SINGLE then
3121 g_GUI_ShowWindow('GameSingleMenu')
3122 else
3123 begin
3124 if g_Game_IsClient then
3125 Exit
3126 else
3127 if g_Game_IsNet then
3128 g_GUI_ShowWindow('GameServerMenu')
3129 else
3130 g_GUI_ShowWindow('GameCustomMenu');
3131 end;
3132 ReadGameSettings();
3133 g_GUI_ShowWindow('GameSetGameMenu');
3134 g_Sound_PlayEx('MENU_OPEN');
3135 end;
3137 procedure g_Menu_Show_OptionsVideo();
3138 begin
3139 if gGameSettings.GameType = GT_SINGLE then
3140 g_GUI_ShowWindow('GameSingleMenu')
3141 else
3142 begin
3143 if g_Game_IsClient then
3144 g_GUI_ShowWindow('GameClientMenu')
3145 else
3146 if g_Game_IsNet then
3147 g_GUI_ShowWindow('GameServerMenu')
3148 else
3149 g_GUI_ShowWindow('GameCustomMenu');
3150 end;
3151 ReadOptions();
3152 g_GUI_ShowWindow('OptionsMenu');
3153 g_GUI_ShowWindow('OptionsVideoMenu');
3154 g_Sound_PlayEx('MENU_OPEN');
3155 end;
3157 procedure g_Menu_Show_OptionsSound();
3158 begin
3159 if gGameSettings.GameType = GT_SINGLE then
3160 g_GUI_ShowWindow('GameSingleMenu')
3161 else
3162 begin
3163 if g_Game_IsClient then
3164 g_GUI_ShowWindow('GameClientMenu')
3165 else
3166 if g_Game_IsNet then
3167 g_GUI_ShowWindow('GameServerMenu')
3168 else
3169 g_GUI_ShowWindow('GameCustomMenu');
3170 end;
3171 ReadOptions();
3172 g_GUI_ShowWindow('OptionsMenu');
3173 g_GUI_ShowWindow('OptionsSoundMenu');
3174 g_Sound_PlayEx('MENU_OPEN');
3175 end;
3177 procedure g_Menu_Show_EndGameMenu();
3178 begin
3179 g_GUI_ShowWindow('EndGameMenu');
3180 g_Sound_PlayEx('MENU_OPEN');
3181 end;
3183 procedure g_Menu_Show_QuitGameMenu();
3184 begin
3185 g_GUI_ShowWindow('ExitMenu');
3186 g_Sound_PlayEx('MENU_OPEN');
3187 end;
3189 procedure g_Menu_Init();
3190 begin
3191 MenuLoadData();
3192 g_GUI_Init();
3193 CreateAllMenus();
3194 end;
3196 procedure g_Menu_Free();
3197 begin
3198 g_GUI_Destroy();
3200 e_WriteLog('Releasing menu data...', MSG_NOTIFY);
3202 MenuFreeData();
3203 end;
3205 procedure g_Menu_Reset();
3206 var
3207 ex: Boolean;
3208 begin
3209 g_GUI_SaveMenuPos();
3210 ex := g_GUI_Destroy();
3212 if ex then
3213 begin
3214 e_WriteLog('Recreating menu...', MSG_NOTIFY);
3216 CreateAllMenus();
3218 if gDebugMode then
3219 g_Game_SetDebugMode();
3221 g_GUI_LoadMenuPos();
3222 end;
3223 end;
3225 end.