DEADSOFTWARE

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