DEADSOFTWARE

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