DEADSOFTWARE

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