DEADSOFTWARE

Menu: Update scale only if it really changed
[d2df-sdl.git] / src / game / g_menu.pas
1 (* Copyright (C) Doom 2D: Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *)
16 {$INCLUDE ../shared/a_modes.inc}
17 unit g_menu;
19 interface
21 procedure g_Menu_Init();
22 procedure g_Menu_Free();
23 procedure g_Menu_Reset();
24 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
25 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
26 procedure g_Menu_AskLanguage();
28 procedure g_Menu_Show_SaveMenu();
29 procedure g_Menu_Show_LoadMenu(standalone: Boolean=false);
30 procedure g_Menu_Show_GameSetGame();
31 procedure g_Menu_Show_OptionsVideo();
32 procedure g_Menu_Show_OptionsSound();
33 procedure g_Menu_Show_EndGameMenu();
34 procedure g_Menu_Show_QuitGameMenu();
36 var
37 gMenuFont: DWORD;
38 gMenuSmallFont: DWORD;
39 PromptIP: string;
40 PromptPort: Word;
41 TempScale: Integer = -1;
43 implementation
45 uses
46 {$INCLUDE ../nogl/noGLuses.inc}
47 g_gui, g_textures, e_graphics, g_main, g_window, g_game, g_map,
48 g_basic, g_console, g_sound, g_gfx, g_player, g_options, g_weapons,
49 e_log, SysUtils, CONFIG, g_playermodel, DateUtils, sdl2,
50 MAPDEF, Math, g_saveload,
51 e_texture, g_language,
52 g_net, g_netmsg, g_netmaster, g_items, e_input, g_touch,
53 utils, wadreader;
56 type TYNCallback = procedure (yes:Boolean);
58 procedure YNKeyDownProc (win: TGUIWindow; Key: Byte);
59 begin
60 if win.UserData = nil then exit;
61 case Key of
62 IK_Y, IK_SPACE: TYNCallback(win.UserData)(true);
63 IK_N: TYNCallback(win.UserData)(false);
64 end;
65 end;
67 procedure YesButtonCB (ctl: TGUITextButton);
68 begin
69 if ctl.UserData = nil then exit;
70 TYNCallback(ctl.UserData)(true);
71 end;
73 procedure NoButtonCB (ctl: TGUITextButton);
74 begin
75 if ctl.UserData = nil then exit;
76 TYNCallback(ctl.UserData)(false);
77 end;
79 function CreateYNMenu (WinName, Text: String; MaxLen: Word; FontID: DWORD; ActionProc: TYNCallback): TGUIWindow;
80 var
81 menu: TGUIMenu;
82 begin
83 //if length(Text) = 0 then exit;
84 Result := TGUIWindow.Create(WinName);
85 with Result do
86 begin
87 //OnKeyDownEx := @YNKeyDownProc;
88 //UserData := @ActionProc;
89 menu := TGUIMenu(Result.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, '')));
90 with menu do
91 begin
92 Name := '__temp_yes_no_menu:'+WinName;
93 YesNo := true;
94 AddText(Text, MaxLen);
95 with AddButton(nil, _lc[I_MENU_YES]) do begin ProcEx := @YesButtonCB; UserData := @ActionProc; end;
96 with AddButton(nil, _lc[I_MENU_NO]) do begin ProcEx := @NoButtonCB; UserData := @ActionProc; end;
97 end;
98 DefControl := '__temp_yes_no_menu:'+WinName;
99 SetActive(nil);
100 end;
101 end;
104 procedure ProcChangeColor(Sender: TGUIControl); forward;
105 procedure ProcSelectModel(Sender: TGUIControl); forward;
107 procedure ProcApplyOptions();
108 var
109 menu: TGUIMenu;
110 i: Integer;
111 ovs: Boolean;
112 begin
113 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
115 if TGUISwitch(menu.GetControl('swBPP')).ItemIndex = 0 then
116 gBPP := 16
117 else
118 gBPP := 32;
120 ovs := gVSync;
121 gVSync := TGUISwitch(menu.GetControl('swVSync')).ItemIndex = 0;
122 if (ovs <> gVSync) then g_SetVSync(gVSync);
124 gTextureFilter := TGUISwitch(menu.GetControl('swTextureFilter')).ItemIndex = 0;
125 glLegacyNPOT := not (TGUISwitch(menu.GetControl('swLegacyNPOT')).ItemIndex = 0);
127 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
129 g_Sound_SetupAllVolumes(
130 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
131 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
132 );
134 gMaxSimSounds := Max(Min(TGUIScroll(menu.GetControl('scMaxSimSounds')).Value*4+2, 66), 2);
135 gMuteWhenInactive := TGUISwitch(menu.GetControl('swInactiveSounds')).ItemIndex = 1;
136 gAnnouncer := TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex;
137 gSoundEffectsDF := TGUISwitch(menu.GetControl('swSoundEffects')).ItemIndex = 1;
138 gUseChatSounds := TGUISwitch(menu.GetControl('swChatSpeech')).ItemIndex = 0;
140 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
142 g_GFX_SetMax(TGUIScroll(menu.GetControl('scParticlesCount')).Value*1000);
143 g_Shells_SetMax(TGUIScroll(menu.GetControl('scShellsMax')).Value*30);
144 g_Gibs_SetMax(TGUIScroll(menu.GetControl('scGibsMax')).Value*25);
145 g_Corpses_SetMax(TGUIScroll(menu.GetControl('scCorpsesMax')).Value*5);
147 case TGUISwitch(menu.GetControl('swGibsCount')).ItemIndex of
148 0: gGibsCount := 0;
149 1: gGibsCount := 8;
150 2: gGibsCount := 16;
151 3: gGibsCount := 32;
152 else gGibsCount := 48;
153 end;
155 gBloodCount := TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex;
156 gFlash := TGUISwitch(menu.GetControl('swScreenFlash')).ItemIndex;
157 gAdvBlood := TGUISwitch(menu.GetControl('swBloodType')).ItemIndex = 1;
158 gAdvCorpses := TGUISwitch(menu.GetControl('swCorpseType')).ItemIndex = 1;
159 gAdvGibs := TGUISwitch(menu.GetControl('swGibsType')).ItemIndex = 1;
160 gDrawBackGround := TGUISwitch(menu.GetControl('swBackGround')).ItemIndex = 0;
161 gShowMessages := TGUISwitch(menu.GetControl('swMessages')).ItemIndex = 0;
162 gRevertPlayers := TGUISwitch(menu.GetControl('swRevertPlayers')).ItemIndex = 0;
163 gChatBubble := TGUISwitch(menu.GetControl('swChatBubble')).ItemIndex;
164 gPlayerIndicator := TGUISwitch(menu.GetControl('swPlayerIndicator')).ItemIndex = 0;
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 if gPlayerIndicator then ItemIndex := 0 else ItemIndex := 1;
575 TempScale := Round(g_dbg_scale - 1);
576 TGUIScroll(menu.GetControl('scScaleFactor')).Value := TempScale;
578 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
580 TGUIListBox(menu.GetControl('lsP1Model')).SelectItem(gPlayer1Settings.Model);
581 TGUIEdit(menu.GetControl('edP1Name')).Text := gPlayer1Settings.Name;
583 TGUISwitch(menu.GetControl('swP1Team')).ItemIndex :=
584 IfThen(gPlayer1Settings.Team = TEAM_BLUE, 1, 0);
586 TGUIScroll(menu.GetControl('scP1Red')).Value := Round(gPlayer1Settings.Color.R/16);
587 TGUIScroll(menu.GetControl('scP1Green')).Value := Round(gPlayer1Settings.Color.G/16);
588 TGUIScroll(menu.GetControl('scP1Blue')).Value := Round(gPlayer1Settings.Color.B/16);
590 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
592 TGUIListBox(menu.GetControl('lsP2Model')).SelectItem(gPlayer2Settings.Model);
593 TGUIEdit(menu.GetControl('edP2Name')).Text := gPlayer2Settings.Name;
595 TGUISwitch(menu.GetControl('swP2Team')).ItemIndex :=
596 IfThen(gPlayer2Settings.Team = TEAM_BLUE, 1, 0);
598 TGUIScroll(menu.GetControl('scP2Red')).Value := Round(gPlayer2Settings.Color.R/16);
599 TGUIScroll(menu.GetControl('scP2Green')).Value := Round(gPlayer2Settings.Color.G/16);
600 TGUIScroll(menu.GetControl('scP2Blue')).Value := Round(gPlayer2Settings.Color.B/16);
602 ProcSelectModel(nil);
603 end;
605 procedure ProcSwitchMonstersCustom(Sender: TGUIControl);
606 begin
607 // don't turn off monsters in DM
609 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
610 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
611 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
612 else
613 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
616 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
617 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
618 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
619 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
621 end;
623 procedure ProcSwitchMonstersNet(Sender: TGUIControl);
624 begin
625 // don't turn off monsters in DM
627 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
628 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
629 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
630 else
631 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
634 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
635 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
636 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
637 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
639 end;
641 procedure ProcStartCustomGame();
642 var
643 Map: String;
644 GameMode: Byte;
645 Options: LongWord;
646 begin
647 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
648 begin
649 Map := TGUILabel(GetControl('lbMap')).Text;
650 if Map = '' then
651 Exit;
652 if not isWadPath(Map) then
653 Exit;
655 GameMode := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
656 gcGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
657 gcTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
658 gcGoalLimit := StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
659 gcMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
661 gcTeamDamage := TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0;
662 gcAllowExit := TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0;
663 gcWeaponStay := TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0;
664 gcMonsters := TGUISwitch(GetControl('swMonsters')).ItemIndex = 0;
665 Options := 0;
666 if gcTeamDamage then
667 Options := Options or GAME_OPTION_TEAMDAMAGE;
668 if gcAllowExit then
669 Options := Options or GAME_OPTION_ALLOWEXIT;
670 if gcWeaponStay then
671 Options := Options or GAME_OPTION_WEAPONSTAY;
672 if gcMonsters then
673 Options := Options or GAME_OPTION_MONSTERS;
674 gcPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
676 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
677 1: begin
678 Options := Options or GAME_OPTION_BOTVSMONSTER;
679 gcBotsVS := 'Monsters';
680 end;
681 2: begin
682 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
683 gcBotsVS := 'Everybody';
684 end;
685 else begin
686 Options := Options or GAME_OPTION_BOTVSPLAYER;
687 gcBotsVS := 'Players';
688 end;
689 end;
691 gcMap := Map;
692 end;
694 g_Options_Write_Gameplay_Custom(GameDir+'/'+CONFIG_FILENAME);
696 g_Game_StartCustom(Map, GameMode, gcTimeLimit, gcGoalLimit,
697 gcMaxLives, Options, gcPlayers);
698 end;
701 procedure ProcStartNetGame();
702 var
703 Map: String;
704 GameMode: Byte;
705 Options: LongWord;
706 begin
707 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
708 begin
709 Map := TGUILabel(GetControl('lbMap')).Text;
710 if Map = '' then
711 Exit;
712 if not isWadPath(Map) then
713 Exit;
715 GameMode := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
716 gnGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
717 gnTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
718 gnGoalLimit := StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
719 gnMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
720 NetPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
722 gnTeamDamage := TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0;
723 gnAllowExit := TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0;
724 gnWeaponStay := TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0;
725 gnMonsters := TGUISwitch(GetControl('swMonsters')).ItemIndex = 0;
726 Options := 0;
727 if gnTeamDamage then
728 Options := Options or GAME_OPTION_TEAMDAMAGE;
729 if gnAllowExit then
730 Options := Options or GAME_OPTION_ALLOWEXIT;
731 if gnWeaponStay then
732 Options := Options or GAME_OPTION_WEAPONSTAY;
733 if gnMonsters then
734 Options := Options or GAME_OPTION_MONSTERS;
735 gnPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
737 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
738 1: begin
739 Options := Options or GAME_OPTION_BOTVSMONSTER;
740 gnBotsVS := 'Monsters';
741 end;
742 2: begin
743 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
744 gnBotsVS := 'Everybody';
745 end;
746 else begin
747 Options := Options or GAME_OPTION_BOTVSPLAYER;
748 gnBotsVS := 'Players';
749 end;
750 end;
752 gnMap := Map;
753 NetServerName := TGUIEdit(GetControl('edSrvName')).Text;
754 NetMaxClients := Max(1, StrToIntDef(TGUIEdit(GetControl('edMaxPlayers')).Text, 1));
755 NetMaxClients := Min(NET_MAXCLIENTS, NetMaxClients);
756 NetPassword := TGUIEdit(GetControl('edSrvPassword')).Text;
757 NetUseMaster := TGUISwitch(GetControl('swUseMaster')).ItemIndex = 0;
758 end;
760 g_Options_Write_Net_Server(GameDir+'/'+CONFIG_FILENAME);
761 g_Options_Write_Gameplay_Net(GameDir+'/'+CONFIG_FILENAME);
763 g_Game_StartServer(Map, GameMode, gnTimeLimit, gnGoalLimit, gnMaxLives,
764 Options, gnPlayers, 0, NetPort);
765 end;
767 procedure ProcConnectNetGame();
768 var
769 PW: String;
770 begin
771 with TGUIMenu(g_ActiveWindow.GetControl('mNetClientMenu')) do
772 begin
773 NetClientIP := TGUIEdit(GetControl('edIP')).Text;
774 NetClientPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
775 PW := TGUIEdit(GetControl('edPW')).Text;
776 end;
778 g_Options_Write_Net_Client(GameDir+'/'+CONFIG_FILENAME);
779 g_Game_StartClient(NetClientIP, NetClientPort, PW);
780 end;
782 procedure ProcEnterPassword();
783 var
784 PW: string;
785 begin
786 with TGUIMenu(g_ActiveWindow.GetControl('mClientPasswordMenu')) do
787 begin
788 NetClientIP := PromptIP;
789 NetClientPort := PromptPort;
790 PW := TGUIEdit(GetControl('edPW')).Text;
791 end;
793 g_Options_Write_Net_Client(GameDir+'/'+CONFIG_FILENAME);
794 g_Game_StartClient(NetClientIP, NetClientPort, PW);
795 end;
797 procedure ProcServerlist();
798 begin
799 if not NetInitDone then
800 begin
801 if (not g_Net_Init()) then
802 begin
803 g_Console_Add('NET: ERROR: Failed to init ENet!');
804 Exit;
805 end
806 else
807 NetInitDone := True;
808 end;
810 g_Net_Slist_Set(NetSlistIP, NetSlistPort);
812 gState := STATE_SLIST;
813 g_ActiveWindow := nil;
815 slWaitStr := _lc[I_NET_SLIST_WAIT];
817 g_Game_Draw;
818 ReDrawWindow;
820 slReturnPressed := True;
821 if g_Net_Slist_Fetch(slCurrent) then
822 begin
823 if slCurrent = nil then
824 slWaitStr := _lc[I_NET_SLIST_NOSERVERS];
825 end
826 else
827 slWaitStr := _lc[I_NET_SLIST_ERROR];
828 g_Serverlist_GenerateTable(slCurrent, slTable);
829 end;
831 procedure ProcStartCampaign();
832 var
833 WAD: String;
834 TwoPlayers: Boolean;
835 n: Byte;
836 begin
837 with TGUIMenu(g_ActiveWindow.GetControl('mCampaignMenu')) do
838 begin
839 WAD := ExtractRelativePath(MapsDir, TGUIFileListBox(GetControl('lsWAD')).SelectedItem());
840 TwoPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex = 1;
841 end;
843 if TwoPlayers then
844 n := 2
845 else
846 n := 1;
847 g_Game_StartSingle(WAD + ':\MAP01', TwoPlayers, n);
848 end;
850 procedure ProcSelectMap(Sender: TGUIControl);
851 var
852 win: TGUIWindow;
853 a: TMapInfo;
854 wad, map, res: String;
855 begin
856 win := g_GUI_GetWindow('SelectMapMenu');
857 with TGUIMenu(win.GetControl('mSelectMapMenu')) do
858 begin
859 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
860 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
862 if (wad = '') or (map = '') then
863 begin // Ýòî íå êàðòà
864 TGUILabel(GetControl('lbMapName')).Text := '';
865 TGUILabel(GetControl('lbMapAuthor')).Text := '';
866 TGUILabel(GetControl('lbMapSize')).Text := '';
867 TGUIMemo(GetControl('meMapDescription')).SetText('');
868 TGUIMapPreview(win.GetControl('mpMapPreview')).ClearMap();
869 TGUILabel(win.GetControl('lbMapScale')).Text := '';
870 end
871 else // Ýòî êàðòà
872 begin
873 res := wad+':\'+map;
875 a := g_Map_GetMapInfo(res);
877 TGUILabel(GetControl('lbMapName')).Text := a.Name;
878 TGUILabel(GetControl('lbMapAuthor')).Text := a.Author;
879 TGUILabel(GetControl('lbMapSize')).Text := Format('%dx%d', [a.Width, a.Height]);
880 TGUIMemo(GetControl('meMapDescription')).SetText(a.Description);
881 TGUIMapPreview(win.GetControl('mpMapPreview')).SetMap(res);
882 TGUILabel(win.GetControl('lbMapScale')).Text :=
883 TGUIMapPreview(win.GetControl('mpMapPreview')).GetScaleStr;
884 end;
885 end;
886 end;
888 procedure ProcSelectWAD(Sender: TGUIControl);
889 var
890 wad: String;
891 list: SSArray;
892 begin
893 with TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu')) do
894 begin
895 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
897 with TGUIListBox(GetControl('lsMapRes')) do
898 begin
899 Clear();
901 if wad <> '' then
902 begin
903 list := g_Map_GetMapsList(wad);
905 if list <> nil then
906 begin
907 Items := list;
908 ItemIndex := 0;
909 end
910 end;
911 end;
912 end;
914 ProcSelectMap(nil);
915 end;
917 procedure ProcSelectCampaignWAD(Sender: TGUIControl);
918 var
919 win: TGUIWindow;
920 a: TMegaWADInfo;
921 wad, fn: String;
922 begin
923 win := g_GUI_GetWindow('CampaignMenu');
924 with TGUIMenu(win.GetControl('mCampaignMenu')) do
925 begin
926 wad := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
928 if wad = '' then
929 begin
930 TGUILabel(GetControl('lbWADName')).Text := '';
931 TGUILabel(GetControl('lbWADAuthor')).Text := '';
932 TGUIMemo(GetControl('meWADDescription')).SetText('');
933 end;
935 a := g_Game_GetMegaWADInfo(wad);
937 TGUILabel(GetControl('lbWADName')).Text := a.Name;
938 TGUILabel(GetControl('lbWADAuthor')).Text := a.Author;
939 TGUIMemo(GetControl('meWADDescription')).SetText(a.Description);
941 TGUIImage(win.GetControl('mpWADImage')).ClearImage();
943 if a.pic <> '' then
944 begin
945 fn := g_ExtractWadName(a.pic);
946 if fn = '' then
947 TGUIImage(win.GetControl('mpWADImage')).SetImage(wad+a.pic)
948 else
949 TGUIImage(win.GetControl('mpWADImage')).SetImage(a.pic);
950 end;
951 end;
952 end;
954 procedure ProcChangeColor(Sender: TGUIControl);
955 var
956 window: TGUIWindow;
957 begin
958 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
959 with TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')) do
960 TGUIModelView(window.GetControl('mvP1Model')).SetColor(
961 Min(TGUIScroll(GetControl('scP1Red')).Value*16, 255),
962 Min(TGUIScroll(GetControl('scP1Green')).Value*16, 255),
963 Min(TGUIScroll(GetControl('scP1Blue')).Value*16, 255));
965 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
966 with TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')) do
967 TGUIModelView(window.GetControl('mvP2Model')).SetColor(
968 Min(TGUIScroll(GetControl('scP2Red')).Value*16, 255),
969 Min(TGUIScroll(GetControl('scP2Green')).Value*16, 255),
970 Min(TGUIScroll(GetControl('scP2Blue')).Value*16, 255));
971 end;
973 procedure ProcSelectModel(Sender: TGUIControl);
974 var
975 a: string;
976 window: TGUIWindow;
977 begin
978 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
979 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')).GetControl('lsP1Model')).SelectedItem;
980 if a <> '' then TGUIModelView(window.GetControl('mvP1Model')).SetModel(a);
982 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
983 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')).GetControl('lsP2Model')).SelectedItem;
984 if a <> '' then TGUIModelView(window.GetControl('mvP2Model')).SetModel(a);
986 ProcChangeColor(nil);
987 end;
989 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
990 var
991 cwdt, chgt: Byte;
992 spc: ShortInt;
993 ID: DWORD;
994 wad: TWADFile;
995 cfgdata: Pointer;
996 cfglen: Integer;
997 config: TConfig;
998 begin
999 cfglen := 0;
1001 wad := TWADFile.Create;
1002 if wad.ReadFile(GameWAD) then
1003 wad.GetResource('FONTS/'+cfgres, cfgdata, cfglen);
1004 wad.Free();
1006 if cfglen <> 0 then
1007 begin
1008 g_Texture_CreateWADEx('FONT_STD', GameWAD+':FONTS\'+texture);
1010 config := TConfig.CreateMem(cfgdata, cfglen);
1011 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
1012 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
1013 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
1015 if g_Texture_Get('FONT_STD', ID) then
1016 e_TextureFontBuild(ID, FontID, cwdt, chgt, spc);
1018 config.Free();
1019 end;
1021 if cfglen <> 0 then FreeMem(cfgdata);
1022 end;
1024 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
1025 var
1026 cwdt, chgt: Byte;
1027 spc: ShortInt;
1028 CharID: DWORD;
1029 wad: TWADFile;
1030 cfgdata, fntdata: Pointer;
1031 cfglen, fntlen: Integer;
1032 config: TConfig;
1033 chrwidth: Integer;
1034 a: Byte;
1035 begin
1036 cfglen := 0;
1037 fntlen := 0;
1039 wad := TWADFile.Create;
1040 if wad.ReadFile(GameWAD) then
1041 begin
1042 wad.GetResource('FONTS/'+txtres, cfgdata, cfglen);
1043 wad.GetResource('FONTS/'+fntres, fntdata, fntlen);
1044 end;
1045 wad.Free();
1047 if cfglen <> 0 then
1048 begin
1049 config := TConfig.CreateMem(cfgdata, cfglen);
1050 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
1051 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
1053 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
1054 FontID := e_CharFont_Create(spc);
1056 for a := 0 to 255 do
1057 begin
1058 chrwidth := config.ReadInt(IntToStr(a), 'Width', 0);
1059 if chrwidth = 0 then Continue;
1061 if e_CreateTextureMemEx(fntdata, fntlen, CharID, cwdt*(a mod 16), chgt*(a div 16),
1062 cwdt, chgt) then
1063 e_CharFont_AddChar(FontID, CharID, Chr(a), chrwidth);
1064 end;
1066 config.Free();
1067 end;
1069 if cfglen <> 0 then FreeMem(cfgdata);
1070 if fntlen <> 0 then FreeMem(fntdata);
1071 end;
1073 procedure MenuLoadData();
1074 begin
1075 e_WriteLog('Loading menu data...', TMsgType.Notify);
1077 g_Texture_CreateWADEx('MAINMENU_MARKER1', GameWAD+':TEXTURES\MARKER1');
1078 g_Texture_CreateWADEx('MAINMENU_MARKER2', GameWAD+':TEXTURES\MARKER2');
1079 g_Texture_CreateWADEx('SCROLL_LEFT', GameWAD+':TEXTURES\SLEFT');
1080 g_Texture_CreateWADEx('SCROLL_RIGHT', GameWAD+':TEXTURES\SRIGHT');
1081 g_Texture_CreateWADEx('SCROLL_MIDDLE', GameWAD+':TEXTURES\SMIDDLE');
1082 g_Texture_CreateWADEx('SCROLL_MARKER', GameWAD+':TEXTURES\SMARKER');
1083 g_Texture_CreateWADEx('EDIT_LEFT', GameWAD+':TEXTURES\ELEFT');
1084 g_Texture_CreateWADEx('EDIT_RIGHT', GameWAD+':TEXTURES\ERIGHT');
1085 g_Texture_CreateWADEx('EDIT_MIDDLE', GameWAD+':TEXTURES\EMIDDLE');
1086 g_Texture_CreateWADEx('BOX1', GameWAD+':TEXTURES\BOX1');
1087 g_Texture_CreateWADEx('BOX2', GameWAD+':TEXTURES\BOX2');
1088 g_Texture_CreateWADEx('BOX3', GameWAD+':TEXTURES\BOX3');
1089 g_Texture_CreateWADEx('BOX4', GameWAD+':TEXTURES\BOX4');
1090 g_Texture_CreateWADEx('BOX5', GameWAD+':TEXTURES\BOX5');
1091 g_Texture_CreateWADEx('BOX6', GameWAD+':TEXTURES\BOX6');
1092 g_Texture_CreateWADEx('BOX7', GameWAD+':TEXTURES\BOX7');
1093 g_Texture_CreateWADEx('BOX8', GameWAD+':TEXTURES\BOX8');
1094 g_Texture_CreateWADEx('BOX9', GameWAD+':TEXTURES\BOX9');
1095 g_Texture_CreateWADEx('BSCROLL_UP_A', GameWAD+':TEXTURES\SCROLLUPA');
1096 g_Texture_CreateWADEx('BSCROLL_UP_U', GameWAD+':TEXTURES\SCROLLUPU');
1097 g_Texture_CreateWADEx('BSCROLL_DOWN_A', GameWAD+':TEXTURES\SCROLLDOWNA');
1098 g_Texture_CreateWADEx('BSCROLL_DOWN_U', GameWAD+':TEXTURES\SCROLLDOWNU');
1099 g_Texture_CreateWADEx('BSCROLL_MIDDLE', GameWAD+':TEXTURES\SCROLLMIDDLE');
1100 g_Texture_CreateWADEx('NOPIC', GameWAD+':TEXTURES\NOPIC');
1102 g_Sound_CreateWADEx('MENU_SELECT', GameWAD+':SOUNDS\MENUSELECT');
1103 g_Sound_CreateWADEx('MENU_OPEN', GameWAD+':SOUNDS\MENUOPEN');
1104 g_Sound_CreateWADEx('MENU_CLOSE', GameWAD+':SOUNDS\MENUCLOSE');
1105 g_Sound_CreateWADEx('MENU_CHANGE', GameWAD+':SOUNDS\MENUCHANGE');
1106 g_Sound_CreateWADEx('SCROLL_ADD', GameWAD+':SOUNDS\SCROLLADD');
1107 g_Sound_CreateWADEx('SCROLL_SUB', GameWAD+':SOUNDS\SCROLLSUB');
1108 g_Sound_CreateWADEx('SOUND_PLAYER_FALL', GameWAD+':SOUNDS\FALL');
1109 end;
1111 procedure MenuFreeData();
1112 begin
1113 e_CharFont_Remove(gMenuFont);
1114 e_CharFont_Remove(gMenuSmallFont);
1116 g_Texture_Delete('MAINMENU_MARKER1');
1117 g_Texture_Delete('MAINMENU_MARKER2');
1118 g_Texture_Delete('SCROLL_LEFT');
1119 g_Texture_Delete('SCROLL_RIGHT');
1120 g_Texture_Delete('SCROLL_MIDDLE');
1121 g_Texture_Delete('SCROLL_MARKER');
1122 g_Texture_Delete('EDIT_LEFT');
1123 g_Texture_Delete('EDIT_RIGHT');
1124 g_Texture_Delete('EDIT_MIDDLE');
1125 g_Texture_Delete('BOX1');
1126 g_Texture_Delete('BOX2');
1127 g_Texture_Delete('BOX3');
1128 g_Texture_Delete('BOX4');
1129 g_Texture_Delete('BOX5');
1130 g_Texture_Delete('BOX6');
1131 g_Texture_Delete('BOX7');
1132 g_Texture_Delete('BOX8');
1133 g_Texture_Delete('BOX9');
1134 g_Texture_Delete('BSCROLL_UP_A');
1135 g_Texture_Delete('BSCROLL_UP_U');
1136 g_Texture_Delete('BSCROLL_DOWN_A');
1137 g_Texture_Delete('BSCROLL_DOWN_U');
1138 g_Texture_Delete('BSCROLL_MIDDLE');
1139 g_Texture_Delete('NOPIC');
1141 g_Sound_Delete('MENU_SELECT');
1142 g_Sound_Delete('MENU_OPEN');
1143 g_Sound_Delete('MENU_CLOSE');
1144 g_Sound_Delete('MENU_CHANGE');
1145 g_Sound_Delete('SCROLL_ADD');
1146 g_Sound_Delete('SCROLL_SUB');
1147 g_Sound_Delete('SOUND_PLAYER_FALL');
1148 end;
1150 procedure ProcAuthorsMenu();
1151 begin
1152 gMusic.SetByName('MUSIC_INTERMUS');
1153 gMusic.Play();
1154 end;
1156 procedure ProcExitMenuKeyDown (yes: Boolean);
1157 var
1158 s: ShortString;
1159 snd: TPlayableSound;
1160 res: Boolean;
1161 begin
1162 if yes then
1163 begin
1164 g_Game_StopAllSounds(True);
1165 case (Random(18)) of
1166 0: s := 'SOUND_MONSTER_PAIN';
1167 1: s := 'SOUND_MONSTER_DIE_3';
1168 2: s := 'SOUND_MONSTER_SLOP';
1169 3: s := 'SOUND_MONSTER_DEMON_DIE';
1170 4: s := 'SOUND_MONSTER_IMP_DIE_2';
1171 5: s := 'SOUND_MONSTER_MAN_DIE';
1172 6: s := 'SOUND_MONSTER_BSP_DIE';
1173 7: s := 'SOUND_MONSTER_VILE_DIE';
1174 8: s := 'SOUND_MONSTER_SKEL_DIE';
1175 9: s := 'SOUND_MONSTER_MANCUB_ALERT';
1176 10: s := 'SOUND_MONSTER_PAIN_PAIN';
1177 11: s := 'SOUND_MONSTER_BARON_DIE';
1178 12: s := 'SOUND_MONSTER_CACO_DIE';
1179 13: s := 'SOUND_MONSTER_CYBER_DIE';
1180 14: s := 'SOUND_MONSTER_KNIGHT_ALERT';
1181 15: s := 'SOUND_MONSTER_SPIDER_ALERT';
1182 else s := 'SOUND_PLAYER_FALL';
1183 end;
1184 snd := TPlayableSound.Create();
1185 res := snd.SetByName(s);
1186 if not res then res := snd.SetByName('SOUND_PLAYER_FALL');
1187 if res then
1188 begin
1189 snd.Play(True);
1190 while snd.IsPlaying() do begin end;
1191 end;
1192 g_Game_Quit();
1193 exit;
1194 end;
1195 g_GUI_HideWindow();
1196 end;
1198 procedure ProcLoadMenu();
1199 var
1200 a: Integer;
1201 valid: Boolean;
1202 begin
1203 for a := 1 to 8 do
1204 begin
1205 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Text := g_GetSaveName(a, valid);
1206 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := not valid;
1207 //TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a)).Enabled := valid;
1208 end;
1209 end;
1211 procedure ProcSaveMenu();
1212 var
1213 a: Integer;
1214 valid: Boolean;
1215 name: AnsiString;
1216 begin
1217 for a := 1 to 8 do
1218 begin
1219 name := g_GetSaveName(a, valid);
1220 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Text := name;
1221 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := (name <> '') and (not valid);
1222 end;
1223 end;
1225 procedure ProcSaveGame(Sender: TGUIControl);
1226 var
1227 a: Integer;
1228 begin
1229 if g_Game_IsNet then Exit;
1230 if g_Game_IsTestMap then Exit;
1231 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1232 g_Game_PauseAllSounds(True);
1233 g_SaveGame(a, TGUIEdit(Sender).Text);
1235 g_ActiveWindow := nil;
1236 g_Game_Pause(False);
1237 end;
1239 procedure ProcLoadGame(Sender: TGUIControl);
1240 var
1241 a: Integer;
1242 begin
1243 if g_Game_IsNet then Exit;
1244 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1245 if g_LoadGame(a) then
1246 begin
1247 g_Game_PauseAllSounds(False)
1248 end
1249 else // Íå çàãðóçèëîñü - âîçâðàò â ìåíþ
1250 begin
1251 g_Console_Add(_lc[I_MSG_BAD_SAVE_VERSION], true);
1252 g_GUI_GetWindow('LoadMenu').SetActive(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu'));
1253 //g_ActiveWindow := nil;
1254 end;
1255 end;
1257 procedure ProcSingle1Player();
1258 begin
1259 g_Game_StartSingle(gDefaultMegawadStart, False, 1);
1260 end;
1262 procedure ProcSingle2Players();
1263 begin
1264 g_Game_StartSingle(gDefaultMegawadStart, True, 2);
1265 end;
1267 procedure ProcSelectMapMenu();
1268 var
1269 menu: TGUIMenu;
1270 wad_lb: TGUIFileListBox;
1271 map_lb: TGUIListBox;
1272 map: String;
1273 begin
1274 menu := TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1275 wad_lb := TGUIFileListBox(menu.GetControl('lsMapWAD'));
1276 map_lb := TGUIListBox(menu.GetControl('lsMapRes'));
1278 if wad_lb.SelectedItem() <> '' then
1279 map := map_lb.SelectedItem()
1280 else
1281 map := '';
1283 wad_lb.UpdateFileList();
1284 map_lb.Clear();
1286 if wad_lb.SelectedItem() <> '' then
1287 begin
1288 ProcSelectWAD(nil);
1289 map_lb.SelectItem(map);
1291 if map_lb.SelectedItem() <> '' then
1292 ProcSelectMap(nil);
1293 end;
1295 g_GUI_ShowWindow('SelectMapMenu');
1296 end;
1298 procedure ProcSelectCampaignMenu();
1299 var
1300 menu: TGUIMenu;
1301 wad_lb: TGUIFileListBox;
1302 begin
1303 menu := TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1304 wad_lb := TGUIFileListBox(menu.GetControl('lsWAD'));
1306 wad_lb.UpdateFileList();
1308 if wad_lb.SelectedItem() <> '' then
1309 ProcSelectCampaignWAD(nil);
1310 end;
1312 procedure ProcSetMap();
1313 var
1314 wad, map, res: String;
1315 begin
1316 with TGUIMenu(g_ActiveWindow.GetControl('mSelectMapMenu')) do
1317 begin
1318 wad := ExtractRelativePath(MapsDir, TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem());
1319 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1320 end;
1322 if (wad = '') or (map = '') then
1323 Exit;
1325 res := wad+':\'+map;
1327 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
1328 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res;
1329 end;
1331 procedure ProcChangeSoundSettings(Sender: TGUIControl);
1332 var
1333 menu: TGUIMenu;
1334 begin
1335 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1337 g_Sound_SetupAllVolumes(
1338 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
1339 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
1340 );
1341 end;
1343 procedure ProcChangeGameSettings(Sender: TGUIControl);
1344 var
1345 menu: TGUIMenu;
1346 begin
1347 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
1348 if TGUIScroll(menu.GetControl('scScaleFactor')).Value <> TempScale then
1349 begin
1350 TempScale := TGUIScroll(menu.GetControl('scScaleFactor')).Value;
1351 g_dbg_scale := TempScale + 1;
1352 end;
1353 end;
1355 procedure ProcChangeTouchSettings(Sender: TGUIControl);
1356 var
1357 menu: TGUIMenu;
1358 begin
1359 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
1360 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
1361 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
1362 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
1363 end;
1365 procedure ProcOptionsPlayersMIMenu();
1366 var
1367 s, a: string;
1368 b: TModelInfo;
1369 begin
1370 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1372 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+s+'Menu')).GetControl('ls'+s+'Model')).SelectedItem;
1374 if a = '' then Exit;
1376 b := g_PlayerModel_GetInfo(a);
1378 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1379 begin
1380 TGUILabel(GetControl('lbName')).Text := b.Name;
1381 TGUILabel(GetControl('lbAuthor')).Text := b.Author;
1382 TGUIMemo(GetControl('meComment')).SetText(b.Description);
1384 if b.HaveWeapon then
1385 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1386 else
1387 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1388 end;
1390 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1391 end;
1393 procedure ProcOptionsPlayersAnim();
1394 var
1395 s: String;
1396 begin
1397 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1398 s := 'P1'
1399 else
1400 s := 'P2';
1402 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1403 begin
1404 NextAnim();
1405 Model.GetCurrentAnimation.Loop := True;
1406 Model.GetCurrentAnimationMask.Loop := True;
1407 end;
1408 end;
1410 procedure ProcOptionsPlayersWeap();
1411 var
1412 s: String;
1413 begin
1414 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1415 s := 'P1'
1416 else
1417 s := 'P2';
1419 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1420 NextWeapon();
1421 end;
1423 procedure ProcOptionsPlayersRot();
1424 var
1425 s: string;
1426 begin
1427 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1428 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1429 begin
1430 if Direction = TDirection.D_LEFT then Direction := TDirection.D_RIGHT else Direction := TDirection.D_LEFT;
1431 end;
1432 end;
1434 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1435 begin
1436 if yes then
1437 begin
1438 g_Options_SetDefault();
1439 ReadOptions();
1440 end;
1441 g_GUI_HideWindow();
1442 end;
1444 procedure ProcSavedMenuKeyDown (yes: Boolean);
1445 begin
1446 if yes then ReadOptions();
1447 g_GUI_HideWindow();
1448 end;
1450 procedure ProcAuthorsClose();
1451 begin
1452 gMusic.SetByName('MUSIC_MENU');
1453 gMusic.Play();
1454 gState := STATE_MENU;
1455 end;
1457 procedure ProcGMClose();
1458 begin
1459 g_Game_InGameMenu(False);
1460 end;
1462 procedure ProcGMShow();
1463 var
1464 Enabled: Boolean;
1465 begin
1466 Enabled := True;
1467 if (gGameSettings.GameType = GT_SINGLE) and
1468 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1469 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1470 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1471 if not gGameOn then
1472 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1473 if g_Game_IsTestMap then
1474 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1475 TGUIMainMenu(g_ActiveWindow.GetControl(
1476 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1477 end;
1479 procedure ProcChangePlayers();
1480 var
1481 TeamGame, Spectator, AddTwo: Boolean;
1482 P1Team{, P2Team}: Byte;
1483 bP2: TGUITextButton;
1484 begin
1485 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1486 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1487 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1488 P1Team := TEAM_NONE;
1489 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1490 // TODO
1491 //P2Team := TEAM_NONE;
1492 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1494 TGUIMainMenu(g_ActiveWindow.GetControl(
1495 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1496 TGUIMainMenu(g_ActiveWindow.GetControl(
1497 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1498 TGUIMainMenu(g_ActiveWindow.GetControl(
1499 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1501 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1502 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1503 bP2.Enabled := AddTwo and not Spectator;
1504 if bP2.Enabled then
1505 bP2.Color := MAINMENU_ITEMS_COLOR
1506 else
1507 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1508 if gPlayer2 = nil then
1509 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1510 else
1511 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1513 TGUIMainMenu(g_ActiveWindow.GetControl(
1514 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1515 end;
1517 procedure ProcJoinRed();
1518 begin
1519 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1520 Exit;
1521 if g_Game_IsServer then
1522 begin
1523 if gPlayer1 = nil then
1524 g_Game_AddPlayer(TEAM_RED)
1525 else
1526 begin
1527 if gPlayer1.Team <> TEAM_RED then
1528 begin
1529 gPlayer1.SwitchTeam;
1530 gPlayer1Settings.Team := gPlayer1.Team;
1531 end;
1533 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1534 end;
1535 end
1536 else
1537 begin
1538 gPlayer1Settings.Team := TEAM_RED;
1539 MC_SEND_PlayerSettings;
1540 if gPlayer1 = nil then
1541 g_Game_AddPlayer(TEAM_RED);
1542 end;
1543 g_ActiveWindow := nil;
1544 g_Game_Pause(False);
1545 end;
1547 procedure ProcJoinBlue();
1548 begin
1549 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1550 Exit;
1551 if g_Game_IsServer then
1552 begin
1553 if gPlayer1 = nil then
1554 g_Game_AddPlayer(TEAM_BLUE)
1555 else
1556 begin
1557 if gPlayer1.Team <> TEAM_BLUE then
1558 begin
1559 gPlayer1.SwitchTeam;
1560 gPlayer1Settings.Team := gPlayer1.Team;
1561 end;
1563 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1564 end;
1565 end
1566 else
1567 begin
1568 gPlayer1Settings.Team := TEAM_BLUE;
1569 MC_SEND_PlayerSettings;
1570 if gPlayer1 = nil then
1571 g_Game_AddPlayer(TEAM_BLUE);
1572 end;
1573 g_ActiveWindow := nil;
1574 g_Game_Pause(False);
1575 end;
1577 procedure ProcJoinGame();
1578 begin
1579 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1580 Exit;
1581 if gPlayer1 = nil then
1582 g_Game_AddPlayer();
1583 g_ActiveWindow := nil;
1584 g_Game_Pause(False);
1585 end;
1587 procedure ProcSwitchP2();
1588 begin
1589 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1590 Exit;
1591 if gPlayer1 = nil then
1592 Exit;
1593 if gPlayer2 = nil then
1594 g_Game_AddPlayer()
1595 else
1596 g_Game_RemovePlayer();
1597 g_ActiveWindow := nil;
1598 g_Game_Pause(False);
1599 end;
1601 procedure ProcSpectate();
1602 begin
1603 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1604 Exit;
1605 g_Game_Spectate();
1606 g_ActiveWindow := nil;
1607 g_Game_Pause(False);
1608 end;
1610 procedure ProcRestartMenuKeyDown (yes: Boolean);
1611 begin
1612 if yes then g_Game_Restart() else g_GUI_HideWindow;
1613 end;
1615 procedure ProcEndMenuKeyDown (yes: Boolean);
1616 begin
1617 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1618 end;
1620 procedure ProcSetRussianLanguage();
1621 begin
1622 if gLanguage <> LANGUAGE_RUSSIAN then
1623 begin
1624 gLanguage := LANGUAGE_RUSSIAN;
1625 gLanguageChange := True;
1626 gAskLanguage := False;
1628 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1630 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1631 ProcApplyOptions();
1632 end;
1633 end;
1635 procedure ProcSetEnglishLanguage();
1636 begin
1637 if gLanguage <> LANGUAGE_ENGLISH then
1638 begin
1639 gLanguage := LANGUAGE_ENGLISH;
1640 gLanguageChange := True;
1641 gAskLanguage := False;
1643 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1645 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1646 ProcApplyOptions();
1647 end;
1648 end;
1650 procedure ReadGameSettings();
1651 var
1652 menu: TGUIMenu;
1653 begin
1654 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1656 with gGameSettings do
1657 begin
1658 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1659 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1660 ItemIndex := 0
1661 else
1662 ItemIndex := 1;
1664 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1665 TGUIEdit(menu.GetControl('edGoalLimit')).Text := IntToStr(GoalLimit);
1666 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1668 with TGUISwitch(menu.GetControl('swBotsVS')) do
1669 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1670 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1671 ItemIndex := 2
1672 else
1673 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1674 ItemIndex := 1
1675 else
1676 ItemIndex := 0;
1678 if GameType in [GT_CUSTOM, GT_SERVER] then
1679 begin
1680 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1681 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1682 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1683 TGUIEdit(menu.GetControl('edGoalLimit')).Enabled := True;
1684 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_ITEMSTEXT_COLOR;
1685 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1686 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1687 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1688 end
1689 else
1690 begin
1691 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1692 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1693 begin
1694 Enabled := False;
1695 Text := '';
1696 end;
1697 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1698 with TGUIEdit(menu.GetControl('edGoalLimit')) do
1699 begin
1700 Enabled := False;
1701 Text := '';
1702 end;
1703 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1704 with TGUIEdit(menu.GetControl('edMaxLives')) do
1705 begin
1706 Enabled := False;
1707 Text := '';
1708 end;
1709 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1710 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1711 end;
1712 end;
1713 end;
1715 procedure ProcApplyGameSet();
1716 var
1717 menu: TGUIMenu;
1718 a, b, n: Integer;
1719 stat: TPlayerStatArray;
1720 begin
1721 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1723 if not g_Game_IsServer then Exit;
1725 with gGameSettings do
1726 begin
1727 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1728 begin
1729 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1730 Options := Options or GAME_OPTION_TEAMDAMAGE
1731 else
1732 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1733 end;
1735 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1736 begin
1737 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1739 if n = 0 then
1740 TimeLimit := 0
1741 else
1742 begin
1743 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1745 TimeLimit := Max(n, b);
1746 end;
1747 end;
1749 if TGUIEdit(menu.GetControl('edGoalLimit')).Enabled then
1750 begin
1751 n := StrToIntDef(TGUIEdit(menu.GetControl('edGoalLimit')).Text, GoalLimit);
1753 if n = 0 then
1754 GoalLimit := 0
1755 else
1756 begin
1757 b := 0;
1758 if GameMode = GM_DM then
1759 begin // DM
1760 stat := g_Player_GetStats();
1761 if stat <> nil then
1762 for a := 0 to High(stat) do
1763 if stat[a].Frags > b then
1764 b := stat[a].Frags;
1765 end
1766 else // CTF
1767 b := Max(gTeamStat[TEAM_RED].Goals, gTeamStat[TEAM_BLUE].Goals);
1769 GoalLimit := Max(n, b);
1770 end;
1771 end;
1773 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1774 begin
1775 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, GoalLimit);
1776 if n < 0 then n := 0;
1777 if n > 255 then n := 255;
1778 if n = 0 then
1779 MaxLives := 0
1780 else
1781 begin
1782 b := 0;
1783 stat := g_Player_GetStats();
1784 if stat <> nil then
1785 for a := 0 to High(stat) do
1786 if stat[a].Lives > b then
1787 b := stat[a].Lives;
1789 MaxLives := Max(n, b);
1790 end;
1791 end;
1793 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1794 begin
1795 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1796 1:
1797 begin
1798 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1799 Options := Options or GAME_OPTION_BOTVSMONSTER;
1800 end;
1801 2:
1802 begin
1803 Options := Options or GAME_OPTION_BOTVSPLAYER;
1804 Options := Options or GAME_OPTION_BOTVSMONSTER;
1805 end;
1806 else
1807 begin
1808 Options := Options or GAME_OPTION_BOTVSPLAYER;
1809 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1810 end;
1811 end;
1812 end;
1813 end;
1815 if g_Game_IsNet then MH_SEND_GameSettings;
1816 end;
1818 procedure ProcVideoOptionsRes();
1819 var
1820 menu: TGUIMenu;
1821 list: SSArray;
1822 SR: DWORD;
1823 begin
1824 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1826 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1827 IntToStr(gScreenWidth) +
1828 ' x ' + IntToStr(gScreenHeight) +
1829 ', ' + IntToStr(gBPP) + ' bpp';
1831 with TGUIListBox(menu.GetControl('lsResolution')) do
1832 begin
1833 list := GetDisplayModes(gBPP, SR);
1835 if list <> nil then
1836 begin
1837 Items := list;
1838 ItemIndex := SR;
1839 end
1840 else
1841 Clear();
1842 end;
1844 with TGUISwitch(menu.GetControl('swFullScreen')) do
1845 if gFullscreen then
1846 ItemIndex := 0
1847 else
1848 ItemIndex := 1;
1849 end;
1851 procedure ProcApplyVideoOptions();
1852 var
1853 menu: TGUIMenu;
1854 Fullscreen: Boolean;
1855 SWidth, SHeight: Integer;
1856 str: String;
1857 begin
1858 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1860 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1861 SScanf(str, '%dx%d', [@SWidth, @SHeight]);
1863 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1865 if (SWidth <> gScreenWidth) or
1866 (SHeight <> gScreenHeight) or
1867 (Fullscreen <> gFullscreen) then
1868 begin
1869 gResolutionChange := True;
1870 gRC_Width := SWidth;
1871 gRC_Height := SHeight;
1872 gRC_FullScreen := Fullscreen;
1873 gRC_Maximized := gWinMaximized;
1874 end;
1876 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1877 ProcApplyOptions();
1878 end;
1880 procedure ProcSetFirstRussianLanguage();
1881 begin
1882 gLanguage := LANGUAGE_RUSSIAN;
1883 gLanguageChange := True;
1884 gAskLanguage := False;
1886 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1887 end;
1889 procedure ProcSetFirstEnglishLanguage();
1890 begin
1891 gLanguage := LANGUAGE_ENGLISH;
1892 gLanguageChange := True;
1893 gAskLanguage := False;
1895 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1896 end;
1898 procedure ProcRecallAddress();
1899 begin
1900 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1901 begin
1902 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1903 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1904 end;
1905 end;
1907 procedure CreateFirstLanguageMenu();
1908 var
1909 Menu: TGUIWindow;
1910 begin
1911 Menu := TGUIWindow.Create('FirstLanguageMenu');
1913 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, ' '))) do
1914 begin
1915 Name := 'mmFirstLanguageMenu';
1916 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
1917 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
1918 end;
1920 Menu.DefControl := 'mmFirstLanguageMenu';
1921 Menu.MainWindow := True;
1922 g_GUI_AddWindow(Menu);
1923 end;
1925 procedure g_Menu_AskLanguage();
1926 begin
1927 CreateFirstLanguageMenu();
1928 g_GUI_ShowWindow('FirstLanguageMenu');
1929 end;
1931 procedure CreatePlayerOptionsMenu(s: String);
1932 var
1933 Menu: TGUIWindow;
1934 a: String;
1935 begin
1936 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
1937 if s = 'P1' then
1938 a := _lc[I_MENU_PLAYER_1]
1939 else
1940 a := _lc[I_MENU_PLAYER_2];
1941 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
1942 begin
1943 Name := 'mOptionsPlayers'+s+'Menu';
1944 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
1945 begin
1946 Name := 'ed'+s+'Name';
1947 MaxLength := 12;
1948 Width := 12;
1949 end;
1950 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
1951 begin
1952 Name := 'sw'+s+'Team';
1953 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
1954 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
1955 end ;
1956 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
1957 begin
1958 Name := 'ls'+s+'Model';
1959 Sort := True;
1960 Items := g_PlayerModel_GetNames();
1961 OnChange := ProcSelectModel;
1962 end;
1963 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
1964 begin
1965 Name := 'sc'+s+'Red';
1966 Max := 16;
1967 OnChange := ProcChangeColor;
1968 end;
1969 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
1970 begin
1971 Name := 'sc'+s+'Green';
1972 Max := 16;
1973 OnChange := ProcChangeColor;
1974 end;
1975 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
1976 begin
1977 Name := 'sc'+s+'Blue';
1978 Max := 16;
1979 OnChange := ProcChangeColor;
1980 end;
1981 AddSpace();
1982 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
1983 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
1984 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
1985 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
1987 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
1988 begin
1989 Name := 'mv'+s+'Model';
1990 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
1991 Y := GetControl('ls'+s+'Model').Y;
1992 end;
1993 end;
1994 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
1995 g_GUI_AddWindow(Menu);
1996 end;
1998 procedure CreateAllMenus();
1999 var
2000 Menu: TGUIWindow;
2001 //SR: TSearchRec;
2002 a, cx, _y, i: Integer;
2003 //list: SSArray;
2004 begin
2005 Menu := TGUIWindow.Create('MainMenu');
2006 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
2007 begin
2008 Name := 'mmMainMenu';
2009 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
2010 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
2011 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2012 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2013 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
2014 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
2015 end;
2016 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
2017 begin
2018 Color := _RGB(255, 255, 255);
2019 X := gScreenWidth-GetWidth-8;
2020 Y := gScreenHeight-GetHeight-8;
2021 end;
2022 Menu.DefControl := 'mmMainMenu';
2023 Menu.MainWindow := True;
2024 g_GUI_AddWindow(Menu);
2026 Menu := TGUIWindow.Create('NewGameMenu');
2027 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_NEW_GAME]))) do
2028 begin
2029 Name := 'mmNewGameMenu';
2030 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
2031 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
2032 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
2033 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
2034 end;
2035 Menu.DefControl := 'mmNewGameMenu';
2036 g_GUI_AddWindow(Menu);
2038 Menu := TGUIWindow.Create('NetGameMenu');
2039 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MULTIPLAYER]))) do
2040 begin
2041 Name := 'mmNetGameMenu';
2042 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
2043 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
2044 end;
2045 Menu.DefControl := 'mmNetGameMenu';
2046 g_GUI_AddWindow(Menu);
2048 Menu := TGUIWindow.Create('NetServerMenu');
2049 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
2050 begin
2051 Name := 'mNetServerMenu';
2052 with AddEdit(_lc[I_NET_SERVER_NAME]) do
2053 begin
2054 Name := 'edSrvName';
2055 OnlyDigits := False;
2056 Width := 16;
2057 MaxLength := 64;
2058 Text := NetServerName;
2059 end;
2060 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2061 begin
2062 Name := 'edSrvPassword';
2063 OnlyDigits := False;
2064 Width := 16;
2065 MaxLength := 24;
2066 Text := NetPassword;
2067 end;
2068 with AddEdit(_lc[I_NET_PORT]) do
2069 begin
2070 Name := 'edPort';
2071 OnlyDigits := True;
2072 Width := 4;
2073 MaxLength := 5;
2074 Text := IntToStr(NetPort);
2075 end;
2076 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2077 begin
2078 Name := 'edMaxPlayers';
2079 OnlyDigits := True;
2080 Width := 4;
2081 MaxLength := 2;
2082 Text := IntToStr(NetMaxClients);
2083 end;
2084 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2085 begin
2086 Name := 'swUseMaster';
2087 AddItem(_lc[I_MENU_YES]);
2088 AddItem(_lc[I_MENU_NO]);
2089 if NetUseMaster then
2090 ItemIndex := 0
2091 else
2092 ItemIndex := 1;
2093 end;
2094 AddSpace();
2095 with AddLabel(_lc[I_MENU_MAP]) do
2096 begin
2097 Name := 'lbMap';
2098 FixedLength := 16;
2099 Text := gnMap;
2100 OnClick := @ProcSelectMapMenu;
2101 end;
2102 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2103 begin
2104 Name := 'swGameMode';
2105 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2106 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2107 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2108 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2109 case g_Game_TextToMode(gnGameMode) of
2110 GM_NONE,
2111 GM_DM: ItemIndex := 0;
2112 GM_TDM: ItemIndex := 1;
2113 GM_CTF: ItemIndex := 2;
2114 GM_SINGLE,
2115 GM_COOP: ItemIndex := 3;
2116 end;
2117 OnChange := ProcSwitchMonstersNet;
2118 end;
2119 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2120 begin
2121 Name := 'edTimeLimit';
2122 OnlyDigits := True;
2123 Width := 4;
2124 MaxLength := 5;
2125 if gnTimeLimit > 0 then
2126 Text := IntToStr(gnTimeLimit);
2127 end;
2128 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2129 begin
2130 Name := 'edGoalLimit';
2131 OnlyDigits := True;
2132 Width := 4;
2133 MaxLength := 5;
2134 if gnGoalLimit > 0 then
2135 Text := IntToStr(gnGoalLimit);
2136 end;
2137 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2138 begin
2139 Name := 'edMaxLives';
2140 OnlyDigits := True;
2141 Width := 4;
2142 MaxLength := 3;
2143 if gnMaxLives > 0 then
2144 Text := IntToStr(gnMaxLives);
2145 end;
2146 with AddSwitch(_lc[I_MENU_SERVER_PLAYERS]) do
2147 begin
2148 Name := 'swPlayers';
2149 AddItem(_lc[I_MENU_COUNT_NONE]);
2150 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2151 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2152 ItemIndex := gnPlayers;
2153 end;
2154 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2155 begin
2156 Name := 'swTeamDamage';
2157 AddItem(_lc[I_MENU_YES]);
2158 AddItem(_lc[I_MENU_NO]);
2159 if gnTeamDamage then
2160 ItemIndex := 0
2161 else
2162 ItemIndex := 1;
2163 end;
2164 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2165 begin
2166 Name := 'swEnableExits';
2167 AddItem(_lc[I_MENU_YES]);
2168 AddItem(_lc[I_MENU_NO]);
2169 if gnAllowExit then
2170 ItemIndex := 0
2171 else
2172 ItemIndex := 1;
2173 end;
2174 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2175 begin
2176 Name := 'swWeaponStay';
2177 AddItem(_lc[I_MENU_YES]);
2178 AddItem(_lc[I_MENU_NO]);
2179 if gnWeaponStay then
2180 ItemIndex := 0
2181 else
2182 ItemIndex := 1;
2183 end;
2184 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2185 begin
2186 Name := 'swMonsters';
2187 AddItem(_lc[I_MENU_YES]);
2188 AddItem(_lc[I_MENU_NO]);
2189 if gnMonsters then
2190 ItemIndex := 0
2191 else
2192 ItemIndex := 1;
2193 end;
2194 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2195 begin
2196 Name := 'swBotsVS';
2197 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2198 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2199 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2200 ItemIndex := 2;
2201 if gnBotsVS = 'Players' then
2202 ItemIndex := 0;
2203 if gnBotsVS = 'Monsters' then
2204 ItemIndex := 1;
2205 end;
2206 AddSpace();
2207 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2209 ReAlign();
2210 end;
2211 Menu.DefControl := 'mNetServerMenu';
2212 g_GUI_AddWindow(Menu);
2214 Menu := TGUIWindow.Create('NetClientMenu');
2215 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2216 begin
2217 Name := 'mNetClientMenu';
2219 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2220 AddSpace();
2222 with AddEdit(_lc[I_NET_ADDRESS]) do
2223 begin
2224 Name := 'edIP';
2225 OnlyDigits :=False;
2226 Width := 12;
2227 MaxLength := 64;
2228 Text := 'localhost';
2229 end;
2230 with AddEdit(_lc[I_NET_PORT]) do
2231 begin
2232 Name := 'edPort';
2233 OnlyDigits := True;
2234 Width := 4;
2235 MaxLength := 5;
2236 Text := '25666';
2237 end;
2238 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2239 begin
2240 Name := 'edPW';
2241 OnlyDigits := False;
2242 Width := 12;
2243 MaxLength := 32;
2244 Text := '';
2245 end;
2247 AddSpace();
2248 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2250 ReAlign();
2251 end;
2252 Menu.DefControl := 'mNetClientMenu';
2253 g_GUI_AddWindow(Menu);
2255 Menu := TGUIWindow.Create('LoadMenu');
2256 Menu.OnShow := ProcLoadMenu;
2257 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2258 begin
2259 Name := 'mmLoadMenu';
2261 for a := 1 to 8 do
2262 with AddEdit('') do
2263 begin
2264 Name := 'edSlot'+IntToStr(a);
2265 Width := 16;
2266 MaxLength := 16;
2267 OnEnter := ProcLoadGame;
2268 end;
2269 end;
2270 Menu.DefControl := 'mmLoadMenu';
2271 g_GUI_AddWindow(Menu);
2273 Menu := TGUIWindow.Create('SaveMenu');
2274 Menu.OnShow := ProcSaveMenu;
2275 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2276 begin
2277 Name := 'mmSaveMenu';
2279 for a := 1 to 8 do
2280 with AddEdit('') do
2281 begin
2282 Name := 'edSlot'+IntToStr(a);
2283 Width := 16;
2284 MaxLength := 16;
2285 OnChange := ProcSaveGame;
2286 end;
2287 end;
2288 Menu.DefControl := 'mmSaveMenu';
2289 g_GUI_AddWindow(Menu);
2291 Menu := TGUIWindow.Create('CustomGameMenu');
2292 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2293 begin
2294 Name := 'mCustomGameMenu';
2295 with AddLabel(_lc[I_MENU_MAP]) do
2296 begin
2297 Name := 'lbMap';
2298 FixedLength := 16;
2299 Text := gcMap;
2300 OnClick := @ProcSelectMapMenu;
2301 end;
2302 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2303 begin
2304 Name := 'swGameMode';
2305 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2306 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2307 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2308 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2309 case g_Game_TextToMode(gcGameMode) of
2310 GM_NONE,
2311 GM_DM: ItemIndex := 0;
2312 GM_TDM: ItemIndex := 1;
2313 GM_CTF: ItemIndex := 2;
2314 GM_SINGLE,
2315 GM_COOP: ItemIndex := 3;
2316 end;
2317 OnChange := ProcSwitchMonstersCustom;
2318 end;
2319 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2320 begin
2321 Name := 'edTimeLimit';
2322 OnlyDigits := True;
2323 Width := 4;
2324 MaxLength := 5;
2325 if gcTimeLimit > 0 then
2326 Text := IntToStr(gcTimeLimit);
2327 end;
2328 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2329 begin
2330 Name := 'edGoalLimit';
2331 OnlyDigits := True;
2332 Width := 4;
2333 MaxLength := 5;
2334 if gcGoalLimit > 0 then
2335 Text := IntToStr(gcGoalLimit);
2336 end;
2337 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2338 begin
2339 Name := 'edMaxLives';
2340 OnlyDigits := True;
2341 Width := 4;
2342 MaxLength := 5;
2343 if gcMaxLives > 0 then
2344 Text := IntToStr(gcMaxLives);
2345 end;
2346 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2347 begin
2348 Name := 'swPlayers';
2349 AddItem(_lc[I_MENU_COUNT_NONE]);
2350 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2351 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2352 ItemIndex := gcPlayers;
2353 end;
2354 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2355 begin
2356 Name := 'swTeamDamage';
2357 AddItem(_lc[I_MENU_YES]);
2358 AddItem(_lc[I_MENU_NO]);
2359 if gcTeamDamage then
2360 ItemIndex := 0
2361 else
2362 ItemIndex := 1;
2363 end;
2364 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2365 begin
2366 Name := 'swEnableExits';
2367 AddItem(_lc[I_MENU_YES]);
2368 AddItem(_lc[I_MENU_NO]);
2369 if gcAllowExit then
2370 ItemIndex := 0
2371 else
2372 ItemIndex := 1;
2373 end;
2374 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2375 begin
2376 Name := 'swWeaponStay';
2377 AddItem(_lc[I_MENU_YES]);
2378 AddItem(_lc[I_MENU_NO]);
2379 if gcWeaponStay then
2380 ItemIndex := 0
2381 else
2382 ItemIndex := 1;
2383 end;
2384 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2385 begin
2386 Name := 'swMonsters';
2387 AddItem(_lc[I_MENU_YES]);
2388 AddItem(_lc[I_MENU_NO]);
2389 if gcMonsters then
2390 ItemIndex := 0
2391 else
2392 ItemIndex := 1;
2393 end;
2394 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2395 begin
2396 Name := 'swBotsVS';
2397 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2398 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2399 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2400 ItemIndex := 2;
2401 if gcBotsVS = 'Players' then
2402 ItemIndex := 0;
2403 if gcBotsVS = 'Monsters' then
2404 ItemIndex := 1;
2405 end;
2406 AddSpace();
2407 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2409 ReAlign();
2410 end;
2411 Menu.DefControl := 'mCustomGameMenu';
2412 g_GUI_AddWindow(Menu);
2414 Menu := TGUIWindow.Create('CampaignMenu');
2415 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2416 begin
2417 Name := 'mCampaignMenu';
2419 AddSpace();
2420 AddSpace();
2421 AddSpace();
2422 AddSpace();
2423 AddSpace();
2424 AddSpace();
2426 with AddFileList('', 15, 4) do
2427 begin
2428 Name := 'lsWAD';
2429 OnChange := ProcSelectCampaignWAD;
2431 Sort := True;
2432 Dirs := True;
2433 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2434 SetBase(MapsDir+'megawads/');
2435 end;
2437 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2438 begin
2439 Name := 'lbWADName';
2440 FixedLength := 8;
2441 Enabled := False;
2442 end;
2443 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2444 begin
2445 Name := 'lbWADAuthor';
2446 FixedLength := 8;
2447 Enabled := False;
2448 end;
2449 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2450 with AddMemo('', 15, 3) do
2451 begin
2452 Name := 'meWADDescription';
2453 Color := MENU_ITEMSCTRL_COLOR;
2454 end;
2455 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2456 begin
2457 Name := 'swPlayers';
2458 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2459 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2460 end;
2461 AddSpace();
2462 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2464 ReAlign();
2466 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2467 begin
2468 Name := 'mpWADImage';
2469 DefaultRes := 'NOPIC';
2470 X := GetControl('lsWAD').X+4;
2471 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2472 end;
2473 end;
2474 Menu.DefControl := 'mCampaignMenu';
2475 g_GUI_AddWindow(Menu);
2477 Menu := TGUIWindow.Create('SelectMapMenu');
2478 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2479 begin
2480 Name := 'mSelectMapMenu';
2481 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2482 begin
2483 Name := 'lsMapWAD';
2484 OnChange := ProcSelectWAD;
2486 Sort := True;
2487 Dirs := True;
2488 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2489 SetBase(MapsDir);
2490 end;
2491 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2492 begin
2493 Name := 'lsMapRes';
2494 Sort := True;
2495 OnChange := ProcSelectMap;
2496 end;
2497 AddSpace();
2498 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2499 begin
2500 Name := 'lbMapName';
2501 FixedLength := 24;
2502 Enabled := False;
2503 end;
2504 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2505 begin
2506 Name := 'lbMapAuthor';
2507 FixedLength := 16;
2508 Enabled := False;
2509 end;
2510 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2511 begin
2512 Name := 'lbMapSize';
2513 FixedLength := 10;
2514 Enabled := False;
2515 end;
2516 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 12, 4) do
2517 begin
2518 Name := 'meMapDescription';
2519 end;
2521 ReAlign();
2523 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2524 begin
2525 Name := 'mpMapPreview';
2526 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2527 Y := GetControl('lsMapWAD').Y;
2528 end;
2529 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2530 begin
2531 Name := 'lbMapScale';
2532 FixedLength := 8;
2533 Enabled := False;
2534 Color := MENU_ITEMSCTRL_COLOR;
2535 X := GetControl('lsMapWAD').X +
2536 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2537 2 + MAPPREVIEW_WIDTH*4;
2538 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2539 end;
2540 end;
2541 Menu.OnClose := ProcSetMap;
2542 Menu.DefControl := 'mSelectMapMenu';
2543 g_GUI_AddWindow(Menu);
2545 Menu := TGUIWindow.Create('OptionsMenu');
2546 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_OPTIONS]))) do
2547 begin
2548 Name := 'mmOptionsMenu';
2549 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2550 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2551 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2552 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2553 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2554 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2555 AddSpace();
2556 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2557 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2558 end;
2559 Menu.OnClose := ProcApplyOptions;
2560 Menu.DefControl := 'mmOptionsMenu';
2561 g_GUI_AddWindow(Menu);
2563 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2564 gMenuSmallFont, @ProcSavedMenuKeyDown);
2565 g_GUI_AddWindow(Menu);
2567 Menu := TGUIWindow.Create('OptionsVideoMenu');
2568 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2569 begin
2570 Name := 'mOptionsVideoMenu';
2571 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2572 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2573 begin
2574 Name := 'swBPP';
2575 AddItem('16');
2576 AddItem('32');
2577 end;
2578 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2579 begin
2580 Name := 'swVSync';
2581 AddItem(_lc[I_MENU_YES]);
2582 AddItem(_lc[I_MENU_NO]);
2583 end;
2584 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2585 begin
2586 Name := 'swTextureFilter';
2587 AddItem(_lc[I_MENU_YES]);
2588 AddItem(_lc[I_MENU_NO]);
2589 end;
2590 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2591 begin
2592 Name := 'swLegacyNPOT';
2593 AddItem(_lc[I_MENU_NO]);
2594 AddItem(_lc[I_MENU_YES]);
2595 end;
2596 AddSpace();
2597 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2598 ReAlign();
2599 end;
2600 Menu.DefControl := 'mOptionsVideoMenu';
2601 g_GUI_AddWindow(Menu);
2603 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2604 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2605 begin
2606 Name := 'mOptionsVideoResMenu';
2607 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2608 begin
2609 Name := 'lbCurrentRes';
2610 FixedLength := 24;
2611 Enabled := False;
2612 end;
2613 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2614 begin
2615 Name := 'lsResolution';
2616 Sort := False;
2617 end;
2618 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2619 begin
2620 Name := 'swFullScreen';
2621 AddItem(_lc[I_MENU_YES]);
2622 AddItem(_lc[I_MENU_NO]);
2623 end;
2624 AddSpace();
2625 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2626 UpdateIndex();
2627 end;
2628 Menu.DefControl := 'mOptionsVideoResMenu';
2629 g_GUI_AddWindow(Menu);
2631 Menu := TGUIWindow.Create('OptionsSoundMenu');
2632 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
2633 begin
2634 Name := 'mOptionsSoundMenu';
2635 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2636 begin
2637 Name := 'scMusicLevel';
2638 Max := 16;
2639 OnChange := ProcChangeSoundSettings;
2640 end;
2641 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2642 begin
2643 Name := 'scSoundLevel';
2644 Max := 16;
2645 OnChange := ProcChangeSoundSettings;
2646 end;
2647 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2648 begin
2649 Name := 'scMaxSimSounds';
2650 Max := 16;
2651 end;
2652 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2653 begin;
2654 Name := 'swAnnouncer';
2655 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2656 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2657 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2658 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2659 end;
2660 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2661 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2662 begin;
2663 Name := 'swSoundEffects';
2664 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2665 AddItem(_lc[I_MENU_COMPAT_DF]);
2666 end;
2667 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
2668 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
2669 begin;
2670 Name := 'swChatSpeech';
2671 AddItem(_lc[I_MENU_YES]);
2672 AddItem(_lc[I_MENU_NO]);
2673 end;
2674 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2675 begin
2676 Name := 'swInactiveSounds';
2677 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2678 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2679 end;
2680 ReAlign();
2681 end;
2682 Menu.DefControl := 'mOptionsSoundMenu';
2683 g_GUI_AddWindow(Menu);
2685 Menu := TGUIWindow.Create('OptionsGameMenu');
2686 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
2687 begin
2688 Name := 'mOptionsGameMenu';
2689 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2690 begin
2691 Name := 'scParticlesCount';
2692 Max := 20;
2693 end;
2694 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2695 begin
2696 Name := 'swBloodCount';
2697 AddItem(_lc[I_MENU_COUNT_NONE]);
2698 AddItem(_lc[I_MENU_COUNT_SMALL]);
2699 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2700 AddItem(_lc[I_MENU_COUNT_BIG]);
2701 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2702 end;
2703 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2704 begin
2705 Name := 'scShellsMax';
2706 Max := 20;
2707 end;
2708 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2709 begin
2710 Name := 'scGibsMax';
2711 Max := 20;
2712 end;
2713 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2714 begin
2715 Name := 'scCorpsesMax';
2716 Max := 20;
2717 end;
2718 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2719 begin
2720 Name := 'swGibsCount';
2721 AddItem(_lc[I_MENU_COUNT_NONE]);
2722 AddItem(_lc[I_MENU_COUNT_SMALL]);
2723 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2724 AddItem(_lc[I_MENU_COUNT_BIG]);
2725 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2726 end;
2727 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2728 begin
2729 Name := 'swCorpseType';
2730 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2731 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2732 end;
2733 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2734 begin
2735 Name := 'swGibsType';
2736 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2737 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2738 end;
2739 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2740 begin
2741 Name := 'swBloodType';
2742 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2743 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2744 end;
2745 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2746 begin
2747 Name := 'swScreenFlash';
2748 AddItem(_lc[I_MENU_NO]);
2749 AddItem(_lc[I_MENU_COMPAT_DF]);
2750 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2751 end;
2752 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2753 begin
2754 Name := 'swBackground';
2755 AddItem(_lc[I_MENU_YES]);
2756 AddItem(_lc[I_MENU_NO]);
2757 end;
2758 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2759 begin
2760 Name := 'swMessages';
2761 AddItem(_lc[I_MENU_YES]);
2762 AddItem(_lc[I_MENU_NO]);
2763 end;
2764 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2765 begin
2766 Name := 'swRevertPlayers';
2767 AddItem(_lc[I_MENU_YES]);
2768 AddItem(_lc[I_MENU_NO]);
2769 end;
2770 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2771 begin
2772 Name := 'swChatBubble';
2773 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2774 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2775 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2776 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2777 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2778 end;
2779 with AddSwitch(_lc[I_MENU_GAME_PLAYER_INDICATOR]) do
2780 begin
2781 Name := 'swPlayerIndicator';
2782 AddItem(_lc[I_MENU_YES]);
2783 AddItem(_lc[I_MENU_NO]);
2784 end;
2785 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2786 begin
2787 Name := 'scScaleFactor';
2788 Max := 10;
2789 OnChange := ProcChangeGameSettings;
2790 end;
2791 ReAlign();
2792 end;
2793 Menu.DefControl := 'mOptionsGameMenu';
2794 g_GUI_AddWindow(Menu);
2796 Menu := TGUIWindow.Create('OptionsControlsMenu');
2797 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
2798 begin
2799 Name := 'mOptionsControlsMenu';
2800 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
2801 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
2802 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
2803 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
2804 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
2805 AddSpace();
2806 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
2807 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
2808 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
2809 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
2810 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
2811 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
2812 if e_HasJoysticks then
2813 begin
2814 AddSpace();
2815 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
2816 end;
2817 if g_touch_enabled then
2818 begin
2819 AddSpace();
2820 AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
2821 end;
2822 end;
2823 Menu.DefControl := 'mOptionsControlsMenu';
2824 g_GUI_AddWindow(Menu);
2826 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
2827 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
2828 begin
2829 Name := 'mOptionsControlsP1Menu';
2830 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2831 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2832 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2833 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2834 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2835 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2836 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2837 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2838 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2839 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2840 end;
2841 Menu.DefControl := 'mOptionsControlsP1Menu';
2842 g_GUI_AddWindow(Menu);
2844 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
2845 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
2846 begin
2847 Name := 'mOptionsControlsP1MenuWeapons';
2848 for i := WP_FIRST to WP_LAST do
2849 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2850 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2851 end;
2852 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
2853 g_GUI_AddWindow(Menu);
2855 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
2856 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
2857 begin
2858 Name := 'mOptionsControlsP2Menu';
2859 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2860 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2861 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2862 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2863 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2864 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2865 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2866 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2867 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2868 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2869 end;
2870 Menu.DefControl := 'mOptionsControlsP2Menu';
2871 g_GUI_AddWindow(Menu);
2873 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
2874 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
2875 begin
2876 Name := 'mOptionsControlsP2MenuWeapons';
2877 for i := WP_FIRST to WP_LAST do
2878 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2879 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2880 end;
2881 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
2882 g_GUI_AddWindow(Menu);
2884 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
2885 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
2886 begin
2887 Name := 'mOptionsControlsJoystickMenu';
2888 for i := 0 to e_MaxJoys - 1 do
2889 if e_JoystickAvailable[i] then
2890 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
2891 begin
2892 Name := 'scDeadzone' + IntToStr(i);
2893 Max := 20
2894 end
2895 end;
2896 Menu.DefControl := 'mOptionsControlsJoystickMenu';
2897 g_GUI_AddWindow(Menu);
2899 Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
2900 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do
2901 begin
2902 Name := 'mOptionsControlsTouchMenu';
2903 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
2904 begin
2905 Name := 'swTouchAlt';
2906 AddItem(_lc[I_MENU_NO]);
2907 AddItem(_lc[I_MENU_YES]);
2908 OnChange := ProcChangeTouchSettings;
2909 end;
2910 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
2911 begin
2912 Name := 'scTouchSize';
2913 Max := 20;
2914 OnChange := ProcChangeTouchSettings;
2915 end;
2916 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
2917 begin
2918 Name := 'swTouchFire';
2919 AddItem(_lc[I_MENU_NO]);
2920 AddItem(_lc[I_MENU_YES]);
2921 end;
2922 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do
2923 begin
2924 Name := 'scTouchOffset';
2925 Max := 20;
2926 OnChange := ProcChangeTouchSettings;
2927 end;
2928 end;
2929 Menu.DefControl := 'mOptionsControlsTouchMenu';
2930 g_GUI_AddWindow(Menu);
2932 Menu := TGUIWindow.Create('OptionsPlayersMenu');
2933 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
2934 begin
2935 Name := 'mOptionsPlayersMenu';
2936 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
2937 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
2938 end;
2939 Menu.DefControl := 'mOptionsPlayersMenu';
2940 g_GUI_AddWindow(Menu);
2942 CreatePlayerOptionsMenu('P1');
2943 CreatePlayerOptionsMenu('P2');
2945 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
2946 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
2947 begin
2948 Name := 'mOptionsPlayersMIMenu';
2949 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
2950 begin
2951 Name := 'lbName';
2952 FixedLength := 16;
2953 end;
2954 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
2955 begin
2956 Name := 'lbAuthor';
2957 FixedLength := 16;
2958 end;
2959 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
2960 begin
2961 Name := 'meComment';
2962 end;
2963 AddSpace();
2964 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
2965 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
2966 begin
2967 Name := 'lbWeapon';
2968 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
2969 end;
2970 ReAlign();
2971 end;
2972 Menu.DefControl := 'mOptionsPlayersMIMenu';
2973 g_GUI_AddWindow(Menu);
2975 Menu := TGUIWindow.Create('OptionsLanguageMenu');
2976 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
2977 begin
2978 Name := 'mOptionsLanguageMenu';
2979 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
2980 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
2981 ReAlign();
2982 end;
2983 Menu.DefControl := 'mOptionsLanguageMenu';
2984 g_GUI_AddWindow(Menu);
2986 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
2987 gMenuSmallFont, @ProcDefaultMenuKeyDown);
2988 g_GUI_AddWindow(Menu);
2990 Menu := TGUIWindow.Create('AuthorsMenu');
2991 Menu.BackTexture := 'INTER';
2992 Menu.OnClose := ProcAuthorsClose;
2994 // Çàãîëîâîê:
2995 _y := 16;
2996 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
2997 begin
2998 Color := _RGB(255, 0, 0);
2999 X := (gScreenWidth div 2)-(GetWidth() div 2);
3000 Y := _y;
3001 _y := _y+GetHeight();
3002 end;
3003 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
3004 begin
3005 Color := _RGB(255, 0, 0);
3006 X := (gScreenWidth div 2)-(GetWidth() div 2);
3007 Y := _y;
3008 _y := _y+GetHeight()+32;
3009 end;
3010 // ×òî äåëàë: Êòî äåëàë
3011 cx := gScreenWidth div 2 - 320 + 64;
3012 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
3013 begin
3014 Color := _RGB(255, 0, 0);
3015 X := cx;
3016 Y := _y;
3017 _y := _y+22;
3018 end;
3019 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
3020 begin
3021 Color := _RGB(255, 255, 255);
3022 X := cx+32;
3023 Y := _y;
3024 _y := _y+36;
3025 end;
3026 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
3027 begin
3028 Color := _RGB(255, 0, 0);
3029 X := cx;
3030 Y := _y;
3031 _y := _y+22;
3032 end;
3033 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
3034 begin
3035 Color := _RGB(255, 255, 255);
3036 X := cx+32;
3037 Y := _y;
3038 _y := _y+22;
3039 end;
3040 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
3041 begin
3042 Color := _RGB(255, 255, 255);
3043 X := cx+32;
3044 Y := _y;
3045 _y := _y+36;
3046 end;
3047 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
3048 begin
3049 Color := _RGB(255, 0, 0);
3050 X := cx;
3051 Y := _y;
3052 _y := _y+22;
3053 end;
3054 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
3055 begin
3056 Color := _RGB(255, 255, 255);
3057 X := cx+32;
3058 Y := _y;
3059 _y := _y+36;
3060 end;
3061 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
3062 begin
3063 Color := _RGB(255, 0, 0);
3064 X := cx;
3065 Y := _y;
3066 _y := _y+22;
3067 end;
3068 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
3069 begin
3070 Color := _RGB(255, 255, 255);
3071 X := cx+32;
3072 Y := _y;
3073 _y := gScreenHeight - 128;
3074 end;
3075 // Çàêëþ÷åíèå:
3076 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
3077 begin
3078 Color := _RGB(255, 0, 0);
3079 X := cx;
3080 Y := _y;
3081 _y := _y+16;
3082 end;
3083 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
3084 begin
3085 Color := _RGB(255, 255, 255);
3086 X := cx+32;
3087 Y := _y;
3088 _y := _y+GetHeight();
3089 end;
3090 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
3091 begin
3092 Color := _RGB(255, 255, 255);
3093 X := cx+32;
3094 Y := _y;
3095 _y := _y+GetHeight();
3096 end;
3097 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
3098 begin
3099 Color := _RGB(255, 255, 255);
3100 X := cx+32;
3101 Y := _y;
3102 _y := gScreenHeight - 32;
3103 end;
3104 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
3105 begin
3106 Color := _RGB(255, 0, 0);
3107 X := gScreenWidth div 2 - GetWidth() div 2;
3108 Y := _y;
3109 end;
3110 g_GUI_AddWindow(Menu);
3112 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
3113 gMenuSmallFont, @ProcExitMenuKeyDown);
3114 g_GUI_AddWindow(Menu);
3116 Menu := TGUIWindow.Create('GameSingleMenu');
3117 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3118 begin
3119 Name := 'mmGameSingleMenu';
3120 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3121 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3122 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3123 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3124 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3125 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3126 end;
3127 Menu.DefControl := 'mmGameSingleMenu';
3128 Menu.MainWindow := True;
3129 Menu.OnClose := ProcGMClose;
3130 Menu.OnShow := ProcGMShow;
3131 g_GUI_AddWindow(Menu);
3133 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
3134 gMenuSmallFont, @ProcEndMenuKeyDown);
3135 g_GUI_AddWindow(Menu);
3137 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
3138 gMenuSmallFont, @ProcRestartMenuKeyDown);
3139 g_GUI_AddWindow(Menu);
3141 Menu := TGUIWindow.Create('GameCustomMenu');
3142 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3143 begin
3144 Name := 'mmGameCustomMenu';
3145 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3146 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3147 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3148 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3149 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3150 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3151 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3152 end;
3153 Menu.DefControl := 'mmGameCustomMenu';
3154 Menu.MainWindow := True;
3155 Menu.OnClose := ProcGMClose;
3156 Menu.OnShow := ProcGMShow;
3157 g_GUI_AddWindow(Menu);
3159 Menu := TGUIWindow.Create('GameServerMenu');
3160 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3161 begin
3162 Name := 'mmGameServerMenu';
3163 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3164 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3165 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3166 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3167 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3168 end;
3169 Menu.DefControl := 'mmGameServerMenu';
3170 Menu.MainWindow := True;
3171 Menu.OnClose := ProcGMClose;
3172 Menu.OnShow := ProcGMShow;
3173 g_GUI_AddWindow(Menu);
3175 Menu := TGUIWindow.Create('GameClientMenu');
3176 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3177 begin
3178 Name := 'mmGameClientMenu';
3179 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3180 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3181 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3182 end;
3183 Menu.DefControl := 'mmGameClientMenu';
3184 Menu.MainWindow := True;
3185 Menu.OnClose := ProcGMClose;
3186 Menu.OnShow := ProcGMShow;
3187 g_GUI_AddWindow(Menu);
3189 Menu := TGUIWindow.Create('ClientPasswordMenu');
3190 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
3191 begin
3192 Name := 'mClientPasswordMenu';
3193 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3194 begin
3195 Name := 'edPW';
3196 Width := 12;
3197 MaxLength := 32;
3198 end;
3199 AddSpace;
3201 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3202 ReAlign();
3203 end;
3204 Menu.DefControl := 'mClientPasswordMenu';
3205 g_GUI_AddWindow(Menu);
3207 Menu := TGUIWindow.Create('GameSetGameMenu');
3208 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3209 begin
3210 Name := 'mGameSetGameMenu';
3211 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3212 begin
3213 Name := 'swTeamDamage';
3214 AddItem(_lc[I_MENU_YES]);
3215 AddItem(_lc[I_MENU_NO]);
3216 ItemIndex := 1;
3217 end;
3218 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3219 begin
3220 Name := 'edTimeLimit';
3221 OnlyDigits := True;
3222 Width := 4;
3223 MaxLength := 5;
3224 end;
3225 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
3226 begin
3227 Name := 'edGoalLimit';
3228 OnlyDigits := True;
3229 Width := 4;
3230 MaxLength := 5;
3231 end;
3232 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3233 begin
3234 Name := 'edMaxLives';
3235 OnlyDigits := True;
3236 Width := 4;
3237 MaxLength := 5;
3238 end;
3239 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3240 begin
3241 Name := 'swBotsVS';
3242 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3243 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3244 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3245 ItemIndex := 2;
3246 end;
3248 ReAlign();
3249 end;
3250 Menu.DefControl := 'mGameSetGameMenu';
3251 Menu.OnClose := ProcApplyGameSet;
3252 g_GUI_AddWindow(Menu);
3254 Menu := TGUIWindow.Create('TeamMenu');
3255 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_CHANGE_PLAYERS]))) do
3256 begin
3257 Name := 'mmTeamMenu';
3258 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3259 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3260 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3261 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3262 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3263 end;
3264 Menu.DefControl := 'mmTeamMenu';
3265 Menu.OnShow := ProcChangePlayers;
3266 g_GUI_AddWindow(Menu);
3267 end;
3269 procedure g_Menu_Show_SaveMenu();
3270 begin
3271 if g_Game_IsTestMap then
3272 Exit;
3273 if gGameSettings.GameType = GT_SINGLE then
3274 g_GUI_ShowWindow('GameSingleMenu')
3275 else
3276 begin
3277 if g_Game_IsClient then
3278 Exit
3279 else
3280 if g_Game_IsNet then
3281 Exit
3282 else
3283 g_GUI_ShowWindow('GameCustomMenu');
3284 end;
3285 g_GUI_ShowWindow('SaveMenu');
3286 g_Sound_PlayEx('MENU_OPEN');
3287 end;
3289 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3290 begin
3291 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3292 if gGameSettings.GameType = GT_SINGLE then
3293 begin
3294 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3295 end
3296 else
3297 begin
3298 if g_Game_IsClient then exit;
3299 if g_Game_IsNet then exit;
3300 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3301 end;
3302 g_GUI_ShowWindow('LoadMenu');
3303 g_Sound_PlayEx('MENU_OPEN');
3304 end;
3306 procedure g_Menu_Show_GameSetGame();
3307 begin
3308 if gGameSettings.GameType = GT_SINGLE then
3309 g_GUI_ShowWindow('GameSingleMenu')
3310 else
3311 begin
3312 if g_Game_IsClient then
3313 Exit
3314 else
3315 if g_Game_IsNet then
3316 g_GUI_ShowWindow('GameServerMenu')
3317 else
3318 g_GUI_ShowWindow('GameCustomMenu');
3319 end;
3320 ReadGameSettings();
3321 g_GUI_ShowWindow('GameSetGameMenu');
3322 g_Sound_PlayEx('MENU_OPEN');
3323 end;
3325 procedure g_Menu_Show_OptionsVideo();
3326 begin
3327 if gGameSettings.GameType = GT_SINGLE then
3328 g_GUI_ShowWindow('GameSingleMenu')
3329 else
3330 begin
3331 if g_Game_IsClient then
3332 g_GUI_ShowWindow('GameClientMenu')
3333 else
3334 if g_Game_IsNet then
3335 g_GUI_ShowWindow('GameServerMenu')
3336 else
3337 g_GUI_ShowWindow('GameCustomMenu');
3338 end;
3339 ReadOptions();
3340 g_GUI_ShowWindow('OptionsMenu');
3341 g_GUI_ShowWindow('OptionsVideoMenu');
3342 g_Sound_PlayEx('MENU_OPEN');
3343 end;
3345 procedure g_Menu_Show_OptionsSound();
3346 begin
3347 if gGameSettings.GameType = GT_SINGLE then
3348 g_GUI_ShowWindow('GameSingleMenu')
3349 else
3350 begin
3351 if g_Game_IsClient then
3352 g_GUI_ShowWindow('GameClientMenu')
3353 else
3354 if g_Game_IsNet then
3355 g_GUI_ShowWindow('GameServerMenu')
3356 else
3357 g_GUI_ShowWindow('GameCustomMenu');
3358 end;
3359 ReadOptions();
3360 g_GUI_ShowWindow('OptionsMenu');
3361 g_GUI_ShowWindow('OptionsSoundMenu');
3362 g_Sound_PlayEx('MENU_OPEN');
3363 end;
3365 procedure g_Menu_Show_EndGameMenu();
3366 begin
3367 g_GUI_ShowWindow('EndGameMenu');
3368 g_Sound_PlayEx('MENU_OPEN');
3369 end;
3371 procedure g_Menu_Show_QuitGameMenu();
3372 begin
3373 g_GUI_ShowWindow('ExitMenu');
3374 g_Sound_PlayEx('MENU_OPEN');
3375 end;
3377 procedure g_Menu_Init();
3378 begin
3379 MenuLoadData();
3380 g_GUI_Init();
3381 CreateAllMenus();
3382 end;
3384 procedure g_Menu_Free();
3385 begin
3386 g_GUI_Destroy();
3388 e_WriteLog('Releasing menu data...', TMsgType.Notify);
3390 MenuFreeData();
3391 end;
3393 procedure g_Menu_Reset();
3394 var
3395 ex: Boolean;
3396 begin
3397 g_GUI_SaveMenuPos();
3398 ex := g_GUI_Destroy();
3400 if ex then
3401 begin
3402 e_WriteLog('Recreating menu...', TMsgType.Notify);
3404 CreateAllMenus();
3406 if gDebugMode then
3407 g_Game_SetDebugMode();
3409 g_GUI_LoadMenuPos();
3410 end;
3411 end;
3413 end.