DEADSOFTWARE

9aa5b5604d5f4611a6b7fb2783058a4c3a416b82
[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_LOGO', GameWAD+':TEXTURES\MAINLOGO');
1078 g_Texture_CreateWADEx('MAINMENU_MARKER1', GameWAD+':TEXTURES\MARKER1');
1079 g_Texture_CreateWADEx('MAINMENU_MARKER2', GameWAD+':TEXTURES\MARKER2');
1080 g_Texture_CreateWADEx('SCROLL_LEFT', GameWAD+':TEXTURES\SLEFT');
1081 g_Texture_CreateWADEx('SCROLL_RIGHT', GameWAD+':TEXTURES\SRIGHT');
1082 g_Texture_CreateWADEx('SCROLL_MIDDLE', GameWAD+':TEXTURES\SMIDDLE');
1083 g_Texture_CreateWADEx('SCROLL_MARKER', GameWAD+':TEXTURES\SMARKER');
1084 g_Texture_CreateWADEx('EDIT_LEFT', GameWAD+':TEXTURES\ELEFT');
1085 g_Texture_CreateWADEx('EDIT_RIGHT', GameWAD+':TEXTURES\ERIGHT');
1086 g_Texture_CreateWADEx('EDIT_MIDDLE', GameWAD+':TEXTURES\EMIDDLE');
1087 g_Texture_CreateWADEx('BOX1', GameWAD+':TEXTURES\BOX1');
1088 g_Texture_CreateWADEx('BOX2', GameWAD+':TEXTURES\BOX2');
1089 g_Texture_CreateWADEx('BOX3', GameWAD+':TEXTURES\BOX3');
1090 g_Texture_CreateWADEx('BOX4', GameWAD+':TEXTURES\BOX4');
1091 g_Texture_CreateWADEx('BOX5', GameWAD+':TEXTURES\BOX5');
1092 g_Texture_CreateWADEx('BOX6', GameWAD+':TEXTURES\BOX6');
1093 g_Texture_CreateWADEx('BOX7', GameWAD+':TEXTURES\BOX7');
1094 g_Texture_CreateWADEx('BOX8', GameWAD+':TEXTURES\BOX8');
1095 g_Texture_CreateWADEx('BOX9', GameWAD+':TEXTURES\BOX9');
1096 g_Texture_CreateWADEx('BSCROLL_UP_A', GameWAD+':TEXTURES\SCROLLUPA');
1097 g_Texture_CreateWADEx('BSCROLL_UP_U', GameWAD+':TEXTURES\SCROLLUPU');
1098 g_Texture_CreateWADEx('BSCROLL_DOWN_A', GameWAD+':TEXTURES\SCROLLDOWNA');
1099 g_Texture_CreateWADEx('BSCROLL_DOWN_U', GameWAD+':TEXTURES\SCROLLDOWNU');
1100 g_Texture_CreateWADEx('BSCROLL_MIDDLE', GameWAD+':TEXTURES\SCROLLMIDDLE');
1101 g_Texture_CreateWADEx('NOPIC', GameWAD+':TEXTURES\NOPIC');
1103 g_Sound_CreateWADEx('MENU_SELECT', GameWAD+':SOUNDS\MENUSELECT');
1104 g_Sound_CreateWADEx('MENU_OPEN', GameWAD+':SOUNDS\MENUOPEN');
1105 g_Sound_CreateWADEx('MENU_CLOSE', GameWAD+':SOUNDS\MENUCLOSE');
1106 g_Sound_CreateWADEx('MENU_CHANGE', GameWAD+':SOUNDS\MENUCHANGE');
1107 g_Sound_CreateWADEx('SCROLL_ADD', GameWAD+':SOUNDS\SCROLLADD');
1108 g_Sound_CreateWADEx('SCROLL_SUB', GameWAD+':SOUNDS\SCROLLSUB');
1109 g_Sound_CreateWADEx('SOUND_PLAYER_FALL', GameWAD+':SOUNDS\FALL');
1110 end;
1112 procedure MenuFreeData();
1113 begin
1114 e_CharFont_Remove(gMenuFont);
1115 e_CharFont_Remove(gMenuSmallFont);
1117 g_Texture_Delete('MAINMENU_LOGO');
1118 g_Texture_Delete('MAINMENU_MARKER1');
1119 g_Texture_Delete('MAINMENU_MARKER2');
1120 g_Texture_Delete('SCROLL_LEFT');
1121 g_Texture_Delete('SCROLL_RIGHT');
1122 g_Texture_Delete('SCROLL_MIDDLE');
1123 g_Texture_Delete('SCROLL_MARKER');
1124 g_Texture_Delete('EDIT_LEFT');
1125 g_Texture_Delete('EDIT_RIGHT');
1126 g_Texture_Delete('EDIT_MIDDLE');
1127 g_Texture_Delete('BOX1');
1128 g_Texture_Delete('BOX2');
1129 g_Texture_Delete('BOX3');
1130 g_Texture_Delete('BOX4');
1131 g_Texture_Delete('BOX5');
1132 g_Texture_Delete('BOX6');
1133 g_Texture_Delete('BOX7');
1134 g_Texture_Delete('BOX8');
1135 g_Texture_Delete('BOX9');
1136 g_Texture_Delete('BSCROLL_UP_A');
1137 g_Texture_Delete('BSCROLL_UP_U');
1138 g_Texture_Delete('BSCROLL_DOWN_A');
1139 g_Texture_Delete('BSCROLL_DOWN_U');
1140 g_Texture_Delete('BSCROLL_MIDDLE');
1141 g_Texture_Delete('NOPIC');
1143 g_Sound_Delete('MENU_SELECT');
1144 g_Sound_Delete('MENU_OPEN');
1145 g_Sound_Delete('MENU_CLOSE');
1146 g_Sound_Delete('MENU_CHANGE');
1147 g_Sound_Delete('SCROLL_ADD');
1148 g_Sound_Delete('SCROLL_SUB');
1149 g_Sound_Delete('SOUND_PLAYER_FALL');
1150 end;
1152 procedure ProcAuthorsMenu();
1153 begin
1154 gMusic.SetByName('MUSIC_INTERMUS');
1155 gMusic.Play();
1156 end;
1158 procedure ProcExitMenuKeyDown (yes: Boolean);
1159 var
1160 s: ShortString;
1161 snd: TPlayableSound;
1162 res: Boolean;
1163 begin
1164 if yes then
1165 begin
1166 g_Game_StopAllSounds(True);
1167 case (Random(18)) of
1168 0: s := 'SOUND_MONSTER_PAIN';
1169 1: s := 'SOUND_MONSTER_DIE_3';
1170 2: s := 'SOUND_MONSTER_SLOP';
1171 3: s := 'SOUND_MONSTER_DEMON_DIE';
1172 4: s := 'SOUND_MONSTER_IMP_DIE_2';
1173 5: s := 'SOUND_MONSTER_MAN_DIE';
1174 6: s := 'SOUND_MONSTER_BSP_DIE';
1175 7: s := 'SOUND_MONSTER_VILE_DIE';
1176 8: s := 'SOUND_MONSTER_SKEL_DIE';
1177 9: s := 'SOUND_MONSTER_MANCUB_ALERT';
1178 10: s := 'SOUND_MONSTER_PAIN_PAIN';
1179 11: s := 'SOUND_MONSTER_BARON_DIE';
1180 12: s := 'SOUND_MONSTER_CACO_DIE';
1181 13: s := 'SOUND_MONSTER_CYBER_DIE';
1182 14: s := 'SOUND_MONSTER_KNIGHT_ALERT';
1183 15: s := 'SOUND_MONSTER_SPIDER_ALERT';
1184 else s := 'SOUND_PLAYER_FALL';
1185 end;
1186 snd := TPlayableSound.Create();
1187 res := snd.SetByName(s);
1188 if not res then res := snd.SetByName('SOUND_PLAYER_FALL');
1189 if res then
1190 begin
1191 snd.Play(True);
1192 while snd.IsPlaying() do begin end;
1193 end;
1194 g_Game_Quit();
1195 exit;
1196 end;
1197 g_GUI_HideWindow();
1198 end;
1200 procedure ProcLoadMenu();
1201 var
1202 a: Integer;
1203 valid: Boolean;
1204 begin
1205 for a := 1 to 8 do
1206 begin
1207 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Text := g_GetSaveName(a, valid);
1208 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := not valid;
1209 //TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a)).Enabled := valid;
1210 end;
1211 end;
1213 procedure ProcSaveMenu();
1214 var
1215 a: Integer;
1216 valid: Boolean;
1217 name: AnsiString;
1218 begin
1219 for a := 1 to 8 do
1220 begin
1221 name := g_GetSaveName(a, valid);
1222 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Text := name;
1223 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := (name <> '') and (not valid);
1224 end;
1225 end;
1227 procedure ProcSaveGame(Sender: TGUIControl);
1228 var
1229 a: Integer;
1230 begin
1231 if g_Game_IsNet then Exit;
1232 if g_Game_IsTestMap then Exit;
1233 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1234 g_Game_PauseAllSounds(True);
1235 g_SaveGame(a, TGUIEdit(Sender).Text);
1237 g_ActiveWindow := nil;
1238 g_Game_Pause(False);
1239 end;
1241 procedure ProcLoadGame(Sender: TGUIControl);
1242 var
1243 a: Integer;
1244 begin
1245 if g_Game_IsNet then Exit;
1246 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1247 if g_LoadGame(a) then
1248 begin
1249 g_Game_PauseAllSounds(False)
1250 end
1251 else // Íå çàãðóçèëîñü - âîçâðàò â ìåíþ
1252 begin
1253 g_Console_Add(_lc[I_MSG_BAD_SAVE_VERSION], true);
1254 g_GUI_GetWindow('LoadMenu').SetActive(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu'));
1255 //g_ActiveWindow := nil;
1256 end;
1257 end;
1259 procedure ProcSingle1Player();
1260 begin
1261 g_Game_StartSingle(gDefaultMegawadStart, False, 1);
1262 end;
1264 procedure ProcSingle2Players();
1265 begin
1266 g_Game_StartSingle(gDefaultMegawadStart, True, 2);
1267 end;
1269 procedure ProcSelectMapMenu();
1270 var
1271 menu: TGUIMenu;
1272 wad_lb: TGUIFileListBox;
1273 map_lb: TGUIListBox;
1274 map: String;
1275 begin
1276 menu := TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1277 wad_lb := TGUIFileListBox(menu.GetControl('lsMapWAD'));
1278 map_lb := TGUIListBox(menu.GetControl('lsMapRes'));
1280 if wad_lb.SelectedItem() <> '' then
1281 map := map_lb.SelectedItem()
1282 else
1283 map := '';
1285 wad_lb.UpdateFileList();
1286 map_lb.Clear();
1288 if wad_lb.SelectedItem() <> '' then
1289 begin
1290 ProcSelectWAD(nil);
1291 map_lb.SelectItem(map);
1293 if map_lb.SelectedItem() <> '' then
1294 ProcSelectMap(nil);
1295 end;
1297 g_GUI_ShowWindow('SelectMapMenu');
1298 end;
1300 procedure ProcSelectCampaignMenu();
1301 var
1302 menu: TGUIMenu;
1303 wad_lb: TGUIFileListBox;
1304 begin
1305 menu := TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1306 wad_lb := TGUIFileListBox(menu.GetControl('lsWAD'));
1308 wad_lb.UpdateFileList();
1310 if wad_lb.SelectedItem() <> '' then
1311 ProcSelectCampaignWAD(nil);
1312 end;
1314 procedure ProcSetMap();
1315 var
1316 wad, map, res: String;
1317 begin
1318 with TGUIMenu(g_ActiveWindow.GetControl('mSelectMapMenu')) do
1319 begin
1320 wad := ExtractRelativePath(MapsDir, TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem());
1321 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1322 end;
1324 if (wad = '') or (map = '') then
1325 Exit;
1327 res := wad+':\'+map;
1329 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
1330 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res;
1331 end;
1333 procedure ProcChangeSoundSettings(Sender: TGUIControl);
1334 var
1335 menu: TGUIMenu;
1336 begin
1337 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1339 g_Sound_SetupAllVolumes(
1340 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
1341 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
1342 );
1343 end;
1345 procedure ProcChangeGameSettings(Sender: TGUIControl);
1346 var
1347 menu: TGUIMenu;
1348 begin
1349 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
1350 if TGUIScroll(menu.GetControl('scScaleFactor')).Value <> TempScale then
1351 begin
1352 TempScale := TGUIScroll(menu.GetControl('scScaleFactor')).Value;
1353 g_dbg_scale := TempScale + 1;
1354 end;
1355 end;
1357 procedure ProcChangeTouchSettings(Sender: TGUIControl);
1358 var
1359 menu: TGUIMenu;
1360 begin
1361 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
1362 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
1363 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
1364 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
1365 end;
1367 procedure ProcOptionsPlayersMIMenu();
1368 var
1369 s, a: string;
1370 b: TModelInfo;
1371 begin
1372 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1374 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+s+'Menu')).GetControl('ls'+s+'Model')).SelectedItem;
1376 if a = '' then Exit;
1378 b := g_PlayerModel_GetInfo(a);
1380 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1381 begin
1382 TGUILabel(GetControl('lbName')).Text := b.Name;
1383 TGUILabel(GetControl('lbAuthor')).Text := b.Author;
1384 TGUIMemo(GetControl('meComment')).SetText(b.Description);
1386 if b.HaveWeapon then
1387 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1388 else
1389 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1390 end;
1392 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1393 end;
1395 procedure ProcOptionsPlayersAnim();
1396 var
1397 s: String;
1398 begin
1399 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1400 s := 'P1'
1401 else
1402 s := 'P2';
1404 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1405 begin
1406 NextAnim();
1407 Model.GetCurrentAnimation.Loop := True;
1408 Model.GetCurrentAnimationMask.Loop := True;
1409 end;
1410 end;
1412 procedure ProcOptionsPlayersWeap();
1413 var
1414 s: String;
1415 begin
1416 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1417 s := 'P1'
1418 else
1419 s := 'P2';
1421 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1422 NextWeapon();
1423 end;
1425 procedure ProcOptionsPlayersRot();
1426 var
1427 s: string;
1428 begin
1429 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1430 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1431 begin
1432 if Direction = TDirection.D_LEFT then Direction := TDirection.D_RIGHT else Direction := TDirection.D_LEFT;
1433 end;
1434 end;
1436 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1437 begin
1438 if yes then
1439 begin
1440 g_Options_SetDefault();
1441 ReadOptions();
1442 end;
1443 g_GUI_HideWindow();
1444 end;
1446 procedure ProcSavedMenuKeyDown (yes: Boolean);
1447 begin
1448 if yes then ReadOptions();
1449 g_GUI_HideWindow();
1450 end;
1452 procedure ProcAuthorsClose();
1453 begin
1454 gMusic.SetByName('MUSIC_MENU');
1455 gMusic.Play();
1456 gState := STATE_MENU;
1457 end;
1459 procedure ProcGMClose();
1460 begin
1461 g_Game_InGameMenu(False);
1462 end;
1464 procedure ProcGMShow();
1465 var
1466 Enabled: Boolean;
1467 begin
1468 Enabled := True;
1469 if (gGameSettings.GameType = GT_SINGLE) and
1470 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1471 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1472 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1473 if not gGameOn then
1474 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1475 if g_Game_IsTestMap then
1476 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1477 TGUIMainMenu(g_ActiveWindow.GetControl(
1478 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1479 end;
1481 procedure ProcChangePlayers();
1482 var
1483 TeamGame, Spectator, AddTwo: Boolean;
1484 P1Team{, P2Team}: Byte;
1485 bP2: TGUITextButton;
1486 begin
1487 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1488 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1489 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1490 P1Team := TEAM_NONE;
1491 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1492 // TODO
1493 //P2Team := TEAM_NONE;
1494 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1496 TGUIMainMenu(g_ActiveWindow.GetControl(
1497 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1498 TGUIMainMenu(g_ActiveWindow.GetControl(
1499 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1500 TGUIMainMenu(g_ActiveWindow.GetControl(
1501 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1503 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1504 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1505 bP2.Enabled := AddTwo and not Spectator;
1506 if bP2.Enabled then
1507 bP2.Color := MAINMENU_ITEMS_COLOR
1508 else
1509 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1510 if gPlayer2 = nil then
1511 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1512 else
1513 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1515 TGUIMainMenu(g_ActiveWindow.GetControl(
1516 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1517 end;
1519 procedure ProcJoinRed();
1520 begin
1521 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1522 Exit;
1523 if g_Game_IsServer then
1524 begin
1525 if gPlayer1 = nil then
1526 g_Game_AddPlayer(TEAM_RED)
1527 else
1528 begin
1529 if gPlayer1.Team <> TEAM_RED then
1530 begin
1531 gPlayer1.SwitchTeam;
1532 gPlayer1Settings.Team := gPlayer1.Team;
1533 end;
1535 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1536 end;
1537 end
1538 else
1539 begin
1540 gPlayer1Settings.Team := TEAM_RED;
1541 MC_SEND_PlayerSettings;
1542 if gPlayer1 = nil then
1543 g_Game_AddPlayer(TEAM_RED);
1544 end;
1545 g_ActiveWindow := nil;
1546 g_Game_Pause(False);
1547 end;
1549 procedure ProcJoinBlue();
1550 begin
1551 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1552 Exit;
1553 if g_Game_IsServer then
1554 begin
1555 if gPlayer1 = nil then
1556 g_Game_AddPlayer(TEAM_BLUE)
1557 else
1558 begin
1559 if gPlayer1.Team <> TEAM_BLUE then
1560 begin
1561 gPlayer1.SwitchTeam;
1562 gPlayer1Settings.Team := gPlayer1.Team;
1563 end;
1565 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1566 end;
1567 end
1568 else
1569 begin
1570 gPlayer1Settings.Team := TEAM_BLUE;
1571 MC_SEND_PlayerSettings;
1572 if gPlayer1 = nil then
1573 g_Game_AddPlayer(TEAM_BLUE);
1574 end;
1575 g_ActiveWindow := nil;
1576 g_Game_Pause(False);
1577 end;
1579 procedure ProcJoinGame();
1580 begin
1581 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1582 Exit;
1583 if gPlayer1 = nil then
1584 g_Game_AddPlayer();
1585 g_ActiveWindow := nil;
1586 g_Game_Pause(False);
1587 end;
1589 procedure ProcSwitchP2();
1590 begin
1591 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1592 Exit;
1593 if gPlayer1 = nil then
1594 Exit;
1595 if gPlayer2 = nil then
1596 g_Game_AddPlayer()
1597 else
1598 g_Game_RemovePlayer();
1599 g_ActiveWindow := nil;
1600 g_Game_Pause(False);
1601 end;
1603 procedure ProcSpectate();
1604 begin
1605 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1606 Exit;
1607 g_Game_Spectate();
1608 g_ActiveWindow := nil;
1609 g_Game_Pause(False);
1610 end;
1612 procedure ProcRestartMenuKeyDown (yes: Boolean);
1613 begin
1614 if yes then g_Game_Restart() else g_GUI_HideWindow;
1615 end;
1617 procedure ProcEndMenuKeyDown (yes: Boolean);
1618 begin
1619 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1620 end;
1622 procedure ProcSetRussianLanguage();
1623 begin
1624 if gLanguage <> LANGUAGE_RUSSIAN then
1625 begin
1626 gLanguage := LANGUAGE_RUSSIAN;
1627 gLanguageChange := True;
1628 gAskLanguage := False;
1630 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1632 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1633 ProcApplyOptions();
1634 end;
1635 end;
1637 procedure ProcSetEnglishLanguage();
1638 begin
1639 if gLanguage <> LANGUAGE_ENGLISH then
1640 begin
1641 gLanguage := LANGUAGE_ENGLISH;
1642 gLanguageChange := True;
1643 gAskLanguage := False;
1645 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1647 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1648 ProcApplyOptions();
1649 end;
1650 end;
1652 procedure ReadGameSettings();
1653 var
1654 menu: TGUIMenu;
1655 begin
1656 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1658 with gGameSettings do
1659 begin
1660 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1661 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1662 ItemIndex := 0
1663 else
1664 ItemIndex := 1;
1666 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1667 TGUIEdit(menu.GetControl('edGoalLimit')).Text := IntToStr(GoalLimit);
1668 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1670 with TGUISwitch(menu.GetControl('swBotsVS')) do
1671 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1672 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1673 ItemIndex := 2
1674 else
1675 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1676 ItemIndex := 1
1677 else
1678 ItemIndex := 0;
1680 if GameType in [GT_CUSTOM, GT_SERVER] then
1681 begin
1682 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1683 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1684 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1685 TGUIEdit(menu.GetControl('edGoalLimit')).Enabled := True;
1686 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_ITEMSTEXT_COLOR;
1687 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1688 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1689 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1690 end
1691 else
1692 begin
1693 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1694 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1695 begin
1696 Enabled := False;
1697 Text := '';
1698 end;
1699 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1700 with TGUIEdit(menu.GetControl('edGoalLimit')) do
1701 begin
1702 Enabled := False;
1703 Text := '';
1704 end;
1705 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1706 with TGUIEdit(menu.GetControl('edMaxLives')) do
1707 begin
1708 Enabled := False;
1709 Text := '';
1710 end;
1711 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1712 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1713 end;
1714 end;
1715 end;
1717 procedure ProcApplyGameSet();
1718 var
1719 menu: TGUIMenu;
1720 a, b, n: Integer;
1721 stat: TPlayerStatArray;
1722 begin
1723 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1725 if not g_Game_IsServer then Exit;
1727 with gGameSettings do
1728 begin
1729 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1730 begin
1731 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1732 Options := Options or GAME_OPTION_TEAMDAMAGE
1733 else
1734 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1735 end;
1737 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1738 begin
1739 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1741 if n = 0 then
1742 TimeLimit := 0
1743 else
1744 begin
1745 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1747 TimeLimit := Max(n, b);
1748 end;
1749 end;
1751 if TGUIEdit(menu.GetControl('edGoalLimit')).Enabled then
1752 begin
1753 n := StrToIntDef(TGUIEdit(menu.GetControl('edGoalLimit')).Text, GoalLimit);
1755 if n = 0 then
1756 GoalLimit := 0
1757 else
1758 begin
1759 b := 0;
1760 if GameMode = GM_DM then
1761 begin // DM
1762 stat := g_Player_GetStats();
1763 if stat <> nil then
1764 for a := 0 to High(stat) do
1765 if stat[a].Frags > b then
1766 b := stat[a].Frags;
1767 end
1768 else // CTF
1769 b := Max(gTeamStat[TEAM_RED].Goals, gTeamStat[TEAM_BLUE].Goals);
1771 GoalLimit := Max(n, b);
1772 end;
1773 end;
1775 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1776 begin
1777 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, GoalLimit);
1778 if n < 0 then n := 0;
1779 if n > 255 then n := 255;
1780 if n = 0 then
1781 MaxLives := 0
1782 else
1783 begin
1784 b := 0;
1785 stat := g_Player_GetStats();
1786 if stat <> nil then
1787 for a := 0 to High(stat) do
1788 if stat[a].Lives > b then
1789 b := stat[a].Lives;
1791 MaxLives := Max(n, b);
1792 end;
1793 end;
1795 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1796 begin
1797 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1798 1:
1799 begin
1800 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1801 Options := Options or GAME_OPTION_BOTVSMONSTER;
1802 end;
1803 2:
1804 begin
1805 Options := Options or GAME_OPTION_BOTVSPLAYER;
1806 Options := Options or GAME_OPTION_BOTVSMONSTER;
1807 end;
1808 else
1809 begin
1810 Options := Options or GAME_OPTION_BOTVSPLAYER;
1811 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1812 end;
1813 end;
1814 end;
1815 end;
1817 if g_Game_IsNet then MH_SEND_GameSettings;
1818 end;
1820 procedure ProcVideoOptionsRes();
1821 var
1822 menu: TGUIMenu;
1823 list: SSArray;
1824 SR: DWORD;
1825 begin
1826 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1828 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1829 IntToStr(gScreenWidth) +
1830 ' x ' + IntToStr(gScreenHeight) +
1831 ', ' + IntToStr(gBPP) + ' bpp';
1833 with TGUIListBox(menu.GetControl('lsResolution')) do
1834 begin
1835 list := GetDisplayModes(gBPP, SR);
1837 if list <> nil then
1838 begin
1839 Items := list;
1840 ItemIndex := SR;
1841 end
1842 else
1843 Clear();
1844 end;
1846 with TGUISwitch(menu.GetControl('swFullScreen')) do
1847 if gFullscreen then
1848 ItemIndex := 0
1849 else
1850 ItemIndex := 1;
1851 end;
1853 procedure ProcApplyVideoOptions();
1854 var
1855 menu: TGUIMenu;
1856 Fullscreen: Boolean;
1857 SWidth, SHeight: Integer;
1858 str: String;
1859 begin
1860 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1862 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1863 SScanf(str, '%dx%d', [@SWidth, @SHeight]);
1865 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1867 if (SWidth <> gScreenWidth) or
1868 (SHeight <> gScreenHeight) or
1869 (Fullscreen <> gFullscreen) then
1870 begin
1871 gResolutionChange := True;
1872 gRC_Width := SWidth;
1873 gRC_Height := SHeight;
1874 gRC_FullScreen := Fullscreen;
1875 gRC_Maximized := gWinMaximized;
1876 end;
1878 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1879 ProcApplyOptions();
1880 end;
1882 procedure ProcSetFirstRussianLanguage();
1883 begin
1884 gLanguage := LANGUAGE_RUSSIAN;
1885 gLanguageChange := True;
1886 gAskLanguage := False;
1888 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1889 end;
1891 procedure ProcSetFirstEnglishLanguage();
1892 begin
1893 gLanguage := LANGUAGE_ENGLISH;
1894 gLanguageChange := True;
1895 gAskLanguage := False;
1897 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1898 end;
1900 procedure ProcRecallAddress();
1901 begin
1902 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1903 begin
1904 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1905 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1906 end;
1907 end;
1909 procedure CreateFirstLanguageMenu();
1910 var
1911 Menu: TGUIWindow;
1912 begin
1913 Menu := TGUIWindow.Create('FirstLanguageMenu');
1915 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', ' '))) do
1916 begin
1917 Name := 'mmFirstLanguageMenu';
1918 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
1919 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
1920 end;
1922 Menu.DefControl := 'mmFirstLanguageMenu';
1923 Menu.MainWindow := True;
1924 g_GUI_AddWindow(Menu);
1925 end;
1927 procedure g_Menu_AskLanguage();
1928 begin
1929 CreateFirstLanguageMenu();
1930 g_GUI_ShowWindow('FirstLanguageMenu');
1931 end;
1933 procedure CreatePlayerOptionsMenu(s: String);
1934 var
1935 Menu: TGUIWindow;
1936 a: String;
1937 begin
1938 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
1939 if s = 'P1' then
1940 a := _lc[I_MENU_PLAYER_1]
1941 else
1942 a := _lc[I_MENU_PLAYER_2];
1943 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
1944 begin
1945 Name := 'mOptionsPlayers'+s+'Menu';
1946 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
1947 begin
1948 Name := 'ed'+s+'Name';
1949 MaxLength := 12;
1950 Width := 12;
1951 end;
1952 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
1953 begin
1954 Name := 'sw'+s+'Team';
1955 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
1956 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
1957 end ;
1958 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
1959 begin
1960 Name := 'ls'+s+'Model';
1961 Sort := True;
1962 Items := g_PlayerModel_GetNames();
1963 OnChange := ProcSelectModel;
1964 end;
1965 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
1966 begin
1967 Name := 'sc'+s+'Red';
1968 Max := 16;
1969 OnChange := ProcChangeColor;
1970 end;
1971 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
1972 begin
1973 Name := 'sc'+s+'Green';
1974 Max := 16;
1975 OnChange := ProcChangeColor;
1976 end;
1977 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
1978 begin
1979 Name := 'sc'+s+'Blue';
1980 Max := 16;
1981 OnChange := ProcChangeColor;
1982 end;
1983 AddSpace();
1984 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
1985 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
1986 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
1987 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
1989 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
1990 begin
1991 Name := 'mv'+s+'Model';
1992 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
1993 Y := GetControl('ls'+s+'Model').Y;
1994 end;
1995 end;
1996 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
1997 g_GUI_AddWindow(Menu);
1998 end;
2000 procedure CreateAllMenus();
2001 var
2002 Menu: TGUIWindow;
2003 //SR: TSearchRec;
2004 a, cx, _y, i: Integer;
2005 //list: SSArray;
2006 begin
2007 Menu := TGUIWindow.Create('MainMenu');
2008 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, 'MAINMENU_LOGO', _lc[I_MENU_MAIN_MENU]))) do
2009 begin
2010 Name := 'mmMainMenu';
2011 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
2012 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
2013 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2014 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2015 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
2016 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
2017 end;
2018 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
2019 begin
2020 Color := _RGB(255, 255, 255);
2021 X := gScreenWidth-GetWidth-8;
2022 Y := gScreenHeight-GetHeight-8;
2023 end;
2024 Menu.DefControl := 'mmMainMenu';
2025 Menu.MainWindow := True;
2026 g_GUI_AddWindow(Menu);
2028 Menu := TGUIWindow.Create('NewGameMenu');
2029 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_NEW_GAME]))) do
2030 begin
2031 Name := 'mmNewGameMenu';
2032 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
2033 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
2034 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
2035 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
2036 end;
2037 Menu.DefControl := 'mmNewGameMenu';
2038 g_GUI_AddWindow(Menu);
2040 Menu := TGUIWindow.Create('NetGameMenu');
2041 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MULTIPLAYER]))) do
2042 begin
2043 Name := 'mmNetGameMenu';
2044 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
2045 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
2046 end;
2047 Menu.DefControl := 'mmNetGameMenu';
2048 g_GUI_AddWindow(Menu);
2050 Menu := TGUIWindow.Create('NetServerMenu');
2051 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
2052 begin
2053 Name := 'mNetServerMenu';
2054 with AddEdit(_lc[I_NET_SERVER_NAME]) do
2055 begin
2056 Name := 'edSrvName';
2057 OnlyDigits := False;
2058 Width := 16;
2059 MaxLength := 64;
2060 Text := NetServerName;
2061 end;
2062 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2063 begin
2064 Name := 'edSrvPassword';
2065 OnlyDigits := False;
2066 Width := 16;
2067 MaxLength := 24;
2068 Text := NetPassword;
2069 end;
2070 with AddEdit(_lc[I_NET_PORT]) do
2071 begin
2072 Name := 'edPort';
2073 OnlyDigits := True;
2074 Width := 4;
2075 MaxLength := 5;
2076 Text := IntToStr(NetPort);
2077 end;
2078 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2079 begin
2080 Name := 'edMaxPlayers';
2081 OnlyDigits := True;
2082 Width := 4;
2083 MaxLength := 2;
2084 Text := IntToStr(NetMaxClients);
2085 end;
2086 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2087 begin
2088 Name := 'swUseMaster';
2089 AddItem(_lc[I_MENU_YES]);
2090 AddItem(_lc[I_MENU_NO]);
2091 if NetUseMaster then
2092 ItemIndex := 0
2093 else
2094 ItemIndex := 1;
2095 end;
2096 AddSpace();
2097 with AddLabel(_lc[I_MENU_MAP]) do
2098 begin
2099 Name := 'lbMap';
2100 FixedLength := 16;
2101 Text := gnMap;
2102 OnClick := @ProcSelectMapMenu;
2103 end;
2104 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2105 begin
2106 Name := 'swGameMode';
2107 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2108 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2109 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2110 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2111 case g_Game_TextToMode(gnGameMode) of
2112 GM_NONE,
2113 GM_DM: ItemIndex := 0;
2114 GM_TDM: ItemIndex := 1;
2115 GM_CTF: ItemIndex := 2;
2116 GM_SINGLE,
2117 GM_COOP: ItemIndex := 3;
2118 end;
2119 OnChange := ProcSwitchMonstersNet;
2120 end;
2121 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2122 begin
2123 Name := 'edTimeLimit';
2124 OnlyDigits := True;
2125 Width := 4;
2126 MaxLength := 5;
2127 if gnTimeLimit > 0 then
2128 Text := IntToStr(gnTimeLimit);
2129 end;
2130 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2131 begin
2132 Name := 'edGoalLimit';
2133 OnlyDigits := True;
2134 Width := 4;
2135 MaxLength := 5;
2136 if gnGoalLimit > 0 then
2137 Text := IntToStr(gnGoalLimit);
2138 end;
2139 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2140 begin
2141 Name := 'edMaxLives';
2142 OnlyDigits := True;
2143 Width := 4;
2144 MaxLength := 3;
2145 if gnMaxLives > 0 then
2146 Text := IntToStr(gnMaxLives);
2147 end;
2148 with AddSwitch(_lc[I_MENU_SERVER_PLAYERS]) do
2149 begin
2150 Name := 'swPlayers';
2151 AddItem(_lc[I_MENU_COUNT_NONE]);
2152 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2153 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2154 ItemIndex := gnPlayers;
2155 end;
2156 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2157 begin
2158 Name := 'swTeamDamage';
2159 AddItem(_lc[I_MENU_YES]);
2160 AddItem(_lc[I_MENU_NO]);
2161 if gnTeamDamage then
2162 ItemIndex := 0
2163 else
2164 ItemIndex := 1;
2165 end;
2166 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2167 begin
2168 Name := 'swEnableExits';
2169 AddItem(_lc[I_MENU_YES]);
2170 AddItem(_lc[I_MENU_NO]);
2171 if gnAllowExit then
2172 ItemIndex := 0
2173 else
2174 ItemIndex := 1;
2175 end;
2176 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2177 begin
2178 Name := 'swWeaponStay';
2179 AddItem(_lc[I_MENU_YES]);
2180 AddItem(_lc[I_MENU_NO]);
2181 if gnWeaponStay then
2182 ItemIndex := 0
2183 else
2184 ItemIndex := 1;
2185 end;
2186 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2187 begin
2188 Name := 'swMonsters';
2189 AddItem(_lc[I_MENU_YES]);
2190 AddItem(_lc[I_MENU_NO]);
2191 if gnMonsters then
2192 ItemIndex := 0
2193 else
2194 ItemIndex := 1;
2195 end;
2196 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2197 begin
2198 Name := 'swBotsVS';
2199 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2200 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2201 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2202 ItemIndex := 2;
2203 if gnBotsVS = 'Players' then
2204 ItemIndex := 0;
2205 if gnBotsVS = 'Monsters' then
2206 ItemIndex := 1;
2207 end;
2208 AddSpace();
2209 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2211 ReAlign();
2212 end;
2213 Menu.DefControl := 'mNetServerMenu';
2214 g_GUI_AddWindow(Menu);
2216 Menu := TGUIWindow.Create('NetClientMenu');
2217 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2218 begin
2219 Name := 'mNetClientMenu';
2221 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2222 AddSpace();
2224 with AddEdit(_lc[I_NET_ADDRESS]) do
2225 begin
2226 Name := 'edIP';
2227 OnlyDigits :=False;
2228 Width := 12;
2229 MaxLength := 64;
2230 Text := 'localhost';
2231 end;
2232 with AddEdit(_lc[I_NET_PORT]) do
2233 begin
2234 Name := 'edPort';
2235 OnlyDigits := True;
2236 Width := 4;
2237 MaxLength := 5;
2238 Text := '25666';
2239 end;
2240 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2241 begin
2242 Name := 'edPW';
2243 OnlyDigits := False;
2244 Width := 12;
2245 MaxLength := 32;
2246 Text := '';
2247 end;
2249 AddSpace();
2250 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2252 ReAlign();
2253 end;
2254 Menu.DefControl := 'mNetClientMenu';
2255 g_GUI_AddWindow(Menu);
2257 Menu := TGUIWindow.Create('LoadMenu');
2258 Menu.OnShow := ProcLoadMenu;
2259 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2260 begin
2261 Name := 'mmLoadMenu';
2263 for a := 1 to 8 do
2264 with AddEdit('') do
2265 begin
2266 Name := 'edSlot'+IntToStr(a);
2267 Width := 16;
2268 MaxLength := 16;
2269 OnEnter := ProcLoadGame;
2270 end;
2271 end;
2272 Menu.DefControl := 'mmLoadMenu';
2273 g_GUI_AddWindow(Menu);
2275 Menu := TGUIWindow.Create('SaveMenu');
2276 Menu.OnShow := ProcSaveMenu;
2277 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2278 begin
2279 Name := 'mmSaveMenu';
2281 for a := 1 to 8 do
2282 with AddEdit('') do
2283 begin
2284 Name := 'edSlot'+IntToStr(a);
2285 Width := 16;
2286 MaxLength := 16;
2287 OnChange := ProcSaveGame;
2288 end;
2289 end;
2290 Menu.DefControl := 'mmSaveMenu';
2291 g_GUI_AddWindow(Menu);
2293 Menu := TGUIWindow.Create('CustomGameMenu');
2294 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2295 begin
2296 Name := 'mCustomGameMenu';
2297 with AddLabel(_lc[I_MENU_MAP]) do
2298 begin
2299 Name := 'lbMap';
2300 FixedLength := 16;
2301 Text := gcMap;
2302 OnClick := @ProcSelectMapMenu;
2303 end;
2304 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2305 begin
2306 Name := 'swGameMode';
2307 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2308 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2309 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2310 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2311 case g_Game_TextToMode(gcGameMode) of
2312 GM_NONE,
2313 GM_DM: ItemIndex := 0;
2314 GM_TDM: ItemIndex := 1;
2315 GM_CTF: ItemIndex := 2;
2316 GM_SINGLE,
2317 GM_COOP: ItemIndex := 3;
2318 end;
2319 OnChange := ProcSwitchMonstersCustom;
2320 end;
2321 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2322 begin
2323 Name := 'edTimeLimit';
2324 OnlyDigits := True;
2325 Width := 4;
2326 MaxLength := 5;
2327 if gcTimeLimit > 0 then
2328 Text := IntToStr(gcTimeLimit);
2329 end;
2330 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2331 begin
2332 Name := 'edGoalLimit';
2333 OnlyDigits := True;
2334 Width := 4;
2335 MaxLength := 5;
2336 if gcGoalLimit > 0 then
2337 Text := IntToStr(gcGoalLimit);
2338 end;
2339 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2340 begin
2341 Name := 'edMaxLives';
2342 OnlyDigits := True;
2343 Width := 4;
2344 MaxLength := 5;
2345 if gcMaxLives > 0 then
2346 Text := IntToStr(gcMaxLives);
2347 end;
2348 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2349 begin
2350 Name := 'swPlayers';
2351 AddItem(_lc[I_MENU_COUNT_NONE]);
2352 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2353 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2354 ItemIndex := gcPlayers;
2355 end;
2356 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2357 begin
2358 Name := 'swTeamDamage';
2359 AddItem(_lc[I_MENU_YES]);
2360 AddItem(_lc[I_MENU_NO]);
2361 if gcTeamDamage then
2362 ItemIndex := 0
2363 else
2364 ItemIndex := 1;
2365 end;
2366 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2367 begin
2368 Name := 'swEnableExits';
2369 AddItem(_lc[I_MENU_YES]);
2370 AddItem(_lc[I_MENU_NO]);
2371 if gcAllowExit then
2372 ItemIndex := 0
2373 else
2374 ItemIndex := 1;
2375 end;
2376 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2377 begin
2378 Name := 'swWeaponStay';
2379 AddItem(_lc[I_MENU_YES]);
2380 AddItem(_lc[I_MENU_NO]);
2381 if gcWeaponStay then
2382 ItemIndex := 0
2383 else
2384 ItemIndex := 1;
2385 end;
2386 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2387 begin
2388 Name := 'swMonsters';
2389 AddItem(_lc[I_MENU_YES]);
2390 AddItem(_lc[I_MENU_NO]);
2391 if gcMonsters then
2392 ItemIndex := 0
2393 else
2394 ItemIndex := 1;
2395 end;
2396 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2397 begin
2398 Name := 'swBotsVS';
2399 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2400 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2401 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2402 ItemIndex := 2;
2403 if gcBotsVS = 'Players' then
2404 ItemIndex := 0;
2405 if gcBotsVS = 'Monsters' then
2406 ItemIndex := 1;
2407 end;
2408 AddSpace();
2409 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2411 ReAlign();
2412 end;
2413 Menu.DefControl := 'mCustomGameMenu';
2414 g_GUI_AddWindow(Menu);
2416 Menu := TGUIWindow.Create('CampaignMenu');
2417 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2418 begin
2419 Name := 'mCampaignMenu';
2421 AddSpace();
2422 AddSpace();
2423 AddSpace();
2424 AddSpace();
2425 AddSpace();
2426 AddSpace();
2428 with AddFileList('', 15, 4) do
2429 begin
2430 Name := 'lsWAD';
2431 OnChange := ProcSelectCampaignWAD;
2433 Sort := True;
2434 Dirs := True;
2435 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2436 SetBase(MapsDir+'megawads/');
2437 end;
2439 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2440 begin
2441 Name := 'lbWADName';
2442 FixedLength := 8;
2443 Enabled := False;
2444 end;
2445 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2446 begin
2447 Name := 'lbWADAuthor';
2448 FixedLength := 8;
2449 Enabled := False;
2450 end;
2451 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2452 with AddMemo('', 15, 3) do
2453 begin
2454 Name := 'meWADDescription';
2455 Color := MENU_ITEMSCTRL_COLOR;
2456 end;
2457 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2458 begin
2459 Name := 'swPlayers';
2460 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2461 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2462 end;
2463 AddSpace();
2464 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2466 ReAlign();
2468 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2469 begin
2470 Name := 'mpWADImage';
2471 DefaultRes := 'NOPIC';
2472 X := GetControl('lsWAD').X+4;
2473 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2474 end;
2475 end;
2476 Menu.DefControl := 'mCampaignMenu';
2477 g_GUI_AddWindow(Menu);
2479 Menu := TGUIWindow.Create('SelectMapMenu');
2480 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2481 begin
2482 Name := 'mSelectMapMenu';
2483 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2484 begin
2485 Name := 'lsMapWAD';
2486 OnChange := ProcSelectWAD;
2488 Sort := True;
2489 Dirs := True;
2490 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2491 SetBase(MapsDir);
2492 end;
2493 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2494 begin
2495 Name := 'lsMapRes';
2496 Sort := True;
2497 OnChange := ProcSelectMap;
2498 end;
2499 AddSpace();
2500 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2501 begin
2502 Name := 'lbMapName';
2503 FixedLength := 24;
2504 Enabled := False;
2505 end;
2506 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2507 begin
2508 Name := 'lbMapAuthor';
2509 FixedLength := 16;
2510 Enabled := False;
2511 end;
2512 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2513 begin
2514 Name := 'lbMapSize';
2515 FixedLength := 10;
2516 Enabled := False;
2517 end;
2518 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 12, 4) do
2519 begin
2520 Name := 'meMapDescription';
2521 end;
2523 ReAlign();
2525 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2526 begin
2527 Name := 'mpMapPreview';
2528 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2529 Y := GetControl('lsMapWAD').Y;
2530 end;
2531 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2532 begin
2533 Name := 'lbMapScale';
2534 FixedLength := 8;
2535 Enabled := False;
2536 Color := MENU_ITEMSCTRL_COLOR;
2537 X := GetControl('lsMapWAD').X +
2538 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2539 2 + MAPPREVIEW_WIDTH*4;
2540 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2541 end;
2542 end;
2543 Menu.OnClose := ProcSetMap;
2544 Menu.DefControl := 'mSelectMapMenu';
2545 g_GUI_AddWindow(Menu);
2547 Menu := TGUIWindow.Create('OptionsMenu');
2548 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_OPTIONS]))) do
2549 begin
2550 Name := 'mmOptionsMenu';
2551 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2552 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2553 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2554 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2555 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2556 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2557 AddSpace();
2558 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2559 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2560 end;
2561 Menu.OnClose := ProcApplyOptions;
2562 Menu.DefControl := 'mmOptionsMenu';
2563 g_GUI_AddWindow(Menu);
2565 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2566 gMenuSmallFont, @ProcSavedMenuKeyDown);
2567 g_GUI_AddWindow(Menu);
2569 Menu := TGUIWindow.Create('OptionsVideoMenu');
2570 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2571 begin
2572 Name := 'mOptionsVideoMenu';
2573 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2574 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2575 begin
2576 Name := 'swBPP';
2577 AddItem('16');
2578 AddItem('32');
2579 end;
2580 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2581 begin
2582 Name := 'swVSync';
2583 AddItem(_lc[I_MENU_YES]);
2584 AddItem(_lc[I_MENU_NO]);
2585 end;
2586 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2587 begin
2588 Name := 'swTextureFilter';
2589 AddItem(_lc[I_MENU_YES]);
2590 AddItem(_lc[I_MENU_NO]);
2591 end;
2592 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2593 begin
2594 Name := 'swLegacyNPOT';
2595 AddItem(_lc[I_MENU_NO]);
2596 AddItem(_lc[I_MENU_YES]);
2597 end;
2598 AddSpace();
2599 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2600 ReAlign();
2601 end;
2602 Menu.DefControl := 'mOptionsVideoMenu';
2603 g_GUI_AddWindow(Menu);
2605 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2606 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2607 begin
2608 Name := 'mOptionsVideoResMenu';
2609 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2610 begin
2611 Name := 'lbCurrentRes';
2612 FixedLength := 24;
2613 Enabled := False;
2614 end;
2615 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2616 begin
2617 Name := 'lsResolution';
2618 Sort := False;
2619 end;
2620 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2621 begin
2622 Name := 'swFullScreen';
2623 AddItem(_lc[I_MENU_YES]);
2624 AddItem(_lc[I_MENU_NO]);
2625 end;
2626 AddSpace();
2627 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2628 UpdateIndex();
2629 end;
2630 Menu.DefControl := 'mOptionsVideoResMenu';
2631 g_GUI_AddWindow(Menu);
2633 Menu := TGUIWindow.Create('OptionsSoundMenu');
2634 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
2635 begin
2636 Name := 'mOptionsSoundMenu';
2637 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2638 begin
2639 Name := 'scMusicLevel';
2640 Max := 16;
2641 OnChange := ProcChangeSoundSettings;
2642 end;
2643 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2644 begin
2645 Name := 'scSoundLevel';
2646 Max := 16;
2647 OnChange := ProcChangeSoundSettings;
2648 end;
2649 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2650 begin
2651 Name := 'scMaxSimSounds';
2652 Max := 16;
2653 end;
2654 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2655 begin;
2656 Name := 'swAnnouncer';
2657 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2658 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2659 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2660 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2661 end;
2662 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2663 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2664 begin;
2665 Name := 'swSoundEffects';
2666 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2667 AddItem(_lc[I_MENU_COMPAT_DF]);
2668 end;
2669 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
2670 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
2671 begin;
2672 Name := 'swChatSpeech';
2673 AddItem(_lc[I_MENU_YES]);
2674 AddItem(_lc[I_MENU_NO]);
2675 end;
2676 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2677 begin
2678 Name := 'swInactiveSounds';
2679 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2680 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2681 end;
2682 ReAlign();
2683 end;
2684 Menu.DefControl := 'mOptionsSoundMenu';
2685 g_GUI_AddWindow(Menu);
2687 Menu := TGUIWindow.Create('OptionsGameMenu');
2688 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
2689 begin
2690 Name := 'mOptionsGameMenu';
2691 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2692 begin
2693 Name := 'scParticlesCount';
2694 Max := 20;
2695 end;
2696 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2697 begin
2698 Name := 'swBloodCount';
2699 AddItem(_lc[I_MENU_COUNT_NONE]);
2700 AddItem(_lc[I_MENU_COUNT_SMALL]);
2701 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2702 AddItem(_lc[I_MENU_COUNT_BIG]);
2703 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2704 end;
2705 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2706 begin
2707 Name := 'scShellsMax';
2708 Max := 20;
2709 end;
2710 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2711 begin
2712 Name := 'scGibsMax';
2713 Max := 20;
2714 end;
2715 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2716 begin
2717 Name := 'scCorpsesMax';
2718 Max := 20;
2719 end;
2720 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2721 begin
2722 Name := 'swGibsCount';
2723 AddItem(_lc[I_MENU_COUNT_NONE]);
2724 AddItem(_lc[I_MENU_COUNT_SMALL]);
2725 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2726 AddItem(_lc[I_MENU_COUNT_BIG]);
2727 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2728 end;
2729 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2730 begin
2731 Name := 'swCorpseType';
2732 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2733 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2734 end;
2735 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2736 begin
2737 Name := 'swGibsType';
2738 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2739 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2740 end;
2741 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2742 begin
2743 Name := 'swBloodType';
2744 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2745 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2746 end;
2747 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2748 begin
2749 Name := 'swScreenFlash';
2750 AddItem(_lc[I_MENU_NO]);
2751 AddItem(_lc[I_MENU_COMPAT_DF]);
2752 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2753 end;
2754 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2755 begin
2756 Name := 'swBackground';
2757 AddItem(_lc[I_MENU_YES]);
2758 AddItem(_lc[I_MENU_NO]);
2759 end;
2760 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2761 begin
2762 Name := 'swMessages';
2763 AddItem(_lc[I_MENU_YES]);
2764 AddItem(_lc[I_MENU_NO]);
2765 end;
2766 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2767 begin
2768 Name := 'swRevertPlayers';
2769 AddItem(_lc[I_MENU_YES]);
2770 AddItem(_lc[I_MENU_NO]);
2771 end;
2772 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2773 begin
2774 Name := 'swChatBubble';
2775 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2776 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2777 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2778 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2779 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2780 end;
2781 with AddSwitch(_lc[I_MENU_GAME_PLAYER_INDICATOR]) do
2782 begin
2783 Name := 'swPlayerIndicator';
2784 AddItem(_lc[I_MENU_YES]);
2785 AddItem(_lc[I_MENU_NO]);
2786 end;
2787 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2788 begin
2789 Name := 'scScaleFactor';
2790 Max := 10;
2791 OnChange := ProcChangeGameSettings;
2792 end;
2793 ReAlign();
2794 end;
2795 Menu.DefControl := 'mOptionsGameMenu';
2796 g_GUI_AddWindow(Menu);
2798 Menu := TGUIWindow.Create('OptionsControlsMenu');
2799 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
2800 begin
2801 Name := 'mOptionsControlsMenu';
2802 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
2803 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
2804 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
2805 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
2806 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
2807 AddSpace();
2808 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
2809 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
2810 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
2811 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
2812 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
2813 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
2814 if e_HasJoysticks then
2815 begin
2816 AddSpace();
2817 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
2818 end;
2819 if g_touch_enabled then
2820 begin
2821 AddSpace();
2822 AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
2823 end;
2824 end;
2825 Menu.DefControl := 'mOptionsControlsMenu';
2826 g_GUI_AddWindow(Menu);
2828 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
2829 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
2830 begin
2831 Name := 'mOptionsControlsP1Menu';
2832 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2833 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2834 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2835 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2836 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2837 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2838 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2839 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2840 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2841 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2842 end;
2843 Menu.DefControl := 'mOptionsControlsP1Menu';
2844 g_GUI_AddWindow(Menu);
2846 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
2847 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
2848 begin
2849 Name := 'mOptionsControlsP1MenuWeapons';
2850 for i := WP_FIRST to WP_LAST do
2851 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2852 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2853 end;
2854 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
2855 g_GUI_AddWindow(Menu);
2857 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
2858 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
2859 begin
2860 Name := 'mOptionsControlsP2Menu';
2861 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2862 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2863 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2864 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2865 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2866 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2867 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2868 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2869 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2870 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2871 end;
2872 Menu.DefControl := 'mOptionsControlsP2Menu';
2873 g_GUI_AddWindow(Menu);
2875 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
2876 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
2877 begin
2878 Name := 'mOptionsControlsP2MenuWeapons';
2879 for i := WP_FIRST to WP_LAST do
2880 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2881 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2882 end;
2883 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
2884 g_GUI_AddWindow(Menu);
2886 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
2887 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
2888 begin
2889 Name := 'mOptionsControlsJoystickMenu';
2890 for i := 0 to e_MaxJoys - 1 do
2891 if e_JoystickAvailable[i] then
2892 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
2893 begin
2894 Name := 'scDeadzone' + IntToStr(i);
2895 Max := 20
2896 end
2897 end;
2898 Menu.DefControl := 'mOptionsControlsJoystickMenu';
2899 g_GUI_AddWindow(Menu);
2901 Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
2902 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do
2903 begin
2904 Name := 'mOptionsControlsTouchMenu';
2905 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
2906 begin
2907 Name := 'swTouchAlt';
2908 AddItem(_lc[I_MENU_NO]);
2909 AddItem(_lc[I_MENU_YES]);
2910 OnChange := ProcChangeTouchSettings;
2911 end;
2912 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
2913 begin
2914 Name := 'scTouchSize';
2915 Max := 20;
2916 OnChange := ProcChangeTouchSettings;
2917 end;
2918 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
2919 begin
2920 Name := 'swTouchFire';
2921 AddItem(_lc[I_MENU_NO]);
2922 AddItem(_lc[I_MENU_YES]);
2923 end;
2924 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do
2925 begin
2926 Name := 'scTouchOffset';
2927 Max := 20;
2928 OnChange := ProcChangeTouchSettings;
2929 end;
2930 end;
2931 Menu.DefControl := 'mOptionsControlsTouchMenu';
2932 g_GUI_AddWindow(Menu);
2934 Menu := TGUIWindow.Create('OptionsPlayersMenu');
2935 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
2936 begin
2937 Name := 'mOptionsPlayersMenu';
2938 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
2939 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
2940 end;
2941 Menu.DefControl := 'mOptionsPlayersMenu';
2942 g_GUI_AddWindow(Menu);
2944 CreatePlayerOptionsMenu('P1');
2945 CreatePlayerOptionsMenu('P2');
2947 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
2948 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
2949 begin
2950 Name := 'mOptionsPlayersMIMenu';
2951 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
2952 begin
2953 Name := 'lbName';
2954 FixedLength := 16;
2955 end;
2956 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
2957 begin
2958 Name := 'lbAuthor';
2959 FixedLength := 16;
2960 end;
2961 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
2962 begin
2963 Name := 'meComment';
2964 end;
2965 AddSpace();
2966 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
2967 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
2968 begin
2969 Name := 'lbWeapon';
2970 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
2971 end;
2972 ReAlign();
2973 end;
2974 Menu.DefControl := 'mOptionsPlayersMIMenu';
2975 g_GUI_AddWindow(Menu);
2977 Menu := TGUIWindow.Create('OptionsLanguageMenu');
2978 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
2979 begin
2980 Name := 'mOptionsLanguageMenu';
2981 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
2982 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
2983 ReAlign();
2984 end;
2985 Menu.DefControl := 'mOptionsLanguageMenu';
2986 g_GUI_AddWindow(Menu);
2988 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
2989 gMenuSmallFont, @ProcDefaultMenuKeyDown);
2990 g_GUI_AddWindow(Menu);
2992 Menu := TGUIWindow.Create('AuthorsMenu');
2993 Menu.BackTexture := 'INTER';
2994 Menu.OnClose := ProcAuthorsClose;
2996 // Çàãîëîâîê:
2997 _y := 16;
2998 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
2999 begin
3000 Color := _RGB(255, 0, 0);
3001 X := (gScreenWidth div 2)-(GetWidth() div 2);
3002 Y := _y;
3003 _y := _y+GetHeight();
3004 end;
3005 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
3006 begin
3007 Color := _RGB(255, 0, 0);
3008 X := (gScreenWidth div 2)-(GetWidth() div 2);
3009 Y := _y;
3010 _y := _y+GetHeight()+32;
3011 end;
3012 // ×òî äåëàë: Êòî äåëàë
3013 cx := gScreenWidth div 2 - 320 + 64;
3014 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
3015 begin
3016 Color := _RGB(255, 0, 0);
3017 X := cx;
3018 Y := _y;
3019 _y := _y+22;
3020 end;
3021 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
3022 begin
3023 Color := _RGB(255, 255, 255);
3024 X := cx+32;
3025 Y := _y;
3026 _y := _y+36;
3027 end;
3028 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
3029 begin
3030 Color := _RGB(255, 0, 0);
3031 X := cx;
3032 Y := _y;
3033 _y := _y+22;
3034 end;
3035 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
3036 begin
3037 Color := _RGB(255, 255, 255);
3038 X := cx+32;
3039 Y := _y;
3040 _y := _y+22;
3041 end;
3042 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
3043 begin
3044 Color := _RGB(255, 255, 255);
3045 X := cx+32;
3046 Y := _y;
3047 _y := _y+36;
3048 end;
3049 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
3050 begin
3051 Color := _RGB(255, 0, 0);
3052 X := cx;
3053 Y := _y;
3054 _y := _y+22;
3055 end;
3056 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
3057 begin
3058 Color := _RGB(255, 255, 255);
3059 X := cx+32;
3060 Y := _y;
3061 _y := _y+36;
3062 end;
3063 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
3064 begin
3065 Color := _RGB(255, 0, 0);
3066 X := cx;
3067 Y := _y;
3068 _y := _y+22;
3069 end;
3070 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
3071 begin
3072 Color := _RGB(255, 255, 255);
3073 X := cx+32;
3074 Y := _y;
3075 _y := gScreenHeight - 128;
3076 end;
3077 // Çàêëþ÷åíèå:
3078 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
3079 begin
3080 Color := _RGB(255, 0, 0);
3081 X := cx;
3082 Y := _y;
3083 _y := _y+16;
3084 end;
3085 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
3086 begin
3087 Color := _RGB(255, 255, 255);
3088 X := cx+32;
3089 Y := _y;
3090 _y := _y+GetHeight();
3091 end;
3092 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
3093 begin
3094 Color := _RGB(255, 255, 255);
3095 X := cx+32;
3096 Y := _y;
3097 _y := _y+GetHeight();
3098 end;
3099 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
3100 begin
3101 Color := _RGB(255, 255, 255);
3102 X := cx+32;
3103 Y := _y;
3104 _y := gScreenHeight - 32;
3105 end;
3106 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
3107 begin
3108 Color := _RGB(255, 0, 0);
3109 X := gScreenWidth div 2 - GetWidth() div 2;
3110 Y := _y;
3111 end;
3112 g_GUI_AddWindow(Menu);
3114 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
3115 gMenuSmallFont, @ProcExitMenuKeyDown);
3116 g_GUI_AddWindow(Menu);
3118 Menu := TGUIWindow.Create('GameSingleMenu');
3119 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3120 begin
3121 Name := 'mmGameSingleMenu';
3122 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3123 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3124 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3125 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3126 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3127 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3128 end;
3129 Menu.DefControl := 'mmGameSingleMenu';
3130 Menu.MainWindow := True;
3131 Menu.OnClose := ProcGMClose;
3132 Menu.OnShow := ProcGMShow;
3133 g_GUI_AddWindow(Menu);
3135 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
3136 gMenuSmallFont, @ProcEndMenuKeyDown);
3137 g_GUI_AddWindow(Menu);
3139 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
3140 gMenuSmallFont, @ProcRestartMenuKeyDown);
3141 g_GUI_AddWindow(Menu);
3143 Menu := TGUIWindow.Create('GameCustomMenu');
3144 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3145 begin
3146 Name := 'mmGameCustomMenu';
3147 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3148 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3149 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3150 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3151 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3152 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3153 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3154 end;
3155 Menu.DefControl := 'mmGameCustomMenu';
3156 Menu.MainWindow := True;
3157 Menu.OnClose := ProcGMClose;
3158 Menu.OnShow := ProcGMShow;
3159 g_GUI_AddWindow(Menu);
3161 Menu := TGUIWindow.Create('GameServerMenu');
3162 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3163 begin
3164 Name := 'mmGameServerMenu';
3165 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3166 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3167 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3168 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3169 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3170 end;
3171 Menu.DefControl := 'mmGameServerMenu';
3172 Menu.MainWindow := True;
3173 Menu.OnClose := ProcGMClose;
3174 Menu.OnShow := ProcGMShow;
3175 g_GUI_AddWindow(Menu);
3177 Menu := TGUIWindow.Create('GameClientMenu');
3178 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3179 begin
3180 Name := 'mmGameClientMenu';
3181 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3182 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3183 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3184 end;
3185 Menu.DefControl := 'mmGameClientMenu';
3186 Menu.MainWindow := True;
3187 Menu.OnClose := ProcGMClose;
3188 Menu.OnShow := ProcGMShow;
3189 g_GUI_AddWindow(Menu);
3191 Menu := TGUIWindow.Create('ClientPasswordMenu');
3192 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
3193 begin
3194 Name := 'mClientPasswordMenu';
3195 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3196 begin
3197 Name := 'edPW';
3198 Width := 12;
3199 MaxLength := 32;
3200 end;
3201 AddSpace;
3203 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3204 ReAlign();
3205 end;
3206 Menu.DefControl := 'mClientPasswordMenu';
3207 g_GUI_AddWindow(Menu);
3209 Menu := TGUIWindow.Create('GameSetGameMenu');
3210 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3211 begin
3212 Name := 'mGameSetGameMenu';
3213 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3214 begin
3215 Name := 'swTeamDamage';
3216 AddItem(_lc[I_MENU_YES]);
3217 AddItem(_lc[I_MENU_NO]);
3218 ItemIndex := 1;
3219 end;
3220 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3221 begin
3222 Name := 'edTimeLimit';
3223 OnlyDigits := True;
3224 Width := 4;
3225 MaxLength := 5;
3226 end;
3227 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
3228 begin
3229 Name := 'edGoalLimit';
3230 OnlyDigits := True;
3231 Width := 4;
3232 MaxLength := 5;
3233 end;
3234 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3235 begin
3236 Name := 'edMaxLives';
3237 OnlyDigits := True;
3238 Width := 4;
3239 MaxLength := 5;
3240 end;
3241 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3242 begin
3243 Name := 'swBotsVS';
3244 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3245 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3246 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3247 ItemIndex := 2;
3248 end;
3250 ReAlign();
3251 end;
3252 Menu.DefControl := 'mGameSetGameMenu';
3253 Menu.OnClose := ProcApplyGameSet;
3254 g_GUI_AddWindow(Menu);
3256 Menu := TGUIWindow.Create('TeamMenu');
3257 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_CHANGE_PLAYERS]))) do
3258 begin
3259 Name := 'mmTeamMenu';
3260 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3261 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3262 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3263 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3264 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3265 end;
3266 Menu.DefControl := 'mmTeamMenu';
3267 Menu.OnShow := ProcChangePlayers;
3268 g_GUI_AddWindow(Menu);
3269 end;
3271 procedure g_Menu_Show_SaveMenu();
3272 begin
3273 if g_Game_IsTestMap then
3274 Exit;
3275 if gGameSettings.GameType = GT_SINGLE then
3276 g_GUI_ShowWindow('GameSingleMenu')
3277 else
3278 begin
3279 if g_Game_IsClient then
3280 Exit
3281 else
3282 if g_Game_IsNet then
3283 Exit
3284 else
3285 g_GUI_ShowWindow('GameCustomMenu');
3286 end;
3287 g_GUI_ShowWindow('SaveMenu');
3288 g_Sound_PlayEx('MENU_OPEN');
3289 end;
3291 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3292 begin
3293 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3294 if gGameSettings.GameType = GT_SINGLE then
3295 begin
3296 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3297 end
3298 else
3299 begin
3300 if g_Game_IsClient then exit;
3301 if g_Game_IsNet then exit;
3302 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3303 end;
3304 g_GUI_ShowWindow('LoadMenu');
3305 g_Sound_PlayEx('MENU_OPEN');
3306 end;
3308 procedure g_Menu_Show_GameSetGame();
3309 begin
3310 if gGameSettings.GameType = GT_SINGLE then
3311 g_GUI_ShowWindow('GameSingleMenu')
3312 else
3313 begin
3314 if g_Game_IsClient then
3315 Exit
3316 else
3317 if g_Game_IsNet then
3318 g_GUI_ShowWindow('GameServerMenu')
3319 else
3320 g_GUI_ShowWindow('GameCustomMenu');
3321 end;
3322 ReadGameSettings();
3323 g_GUI_ShowWindow('GameSetGameMenu');
3324 g_Sound_PlayEx('MENU_OPEN');
3325 end;
3327 procedure g_Menu_Show_OptionsVideo();
3328 begin
3329 if gGameSettings.GameType = GT_SINGLE then
3330 g_GUI_ShowWindow('GameSingleMenu')
3331 else
3332 begin
3333 if g_Game_IsClient then
3334 g_GUI_ShowWindow('GameClientMenu')
3335 else
3336 if g_Game_IsNet then
3337 g_GUI_ShowWindow('GameServerMenu')
3338 else
3339 g_GUI_ShowWindow('GameCustomMenu');
3340 end;
3341 ReadOptions();
3342 g_GUI_ShowWindow('OptionsMenu');
3343 g_GUI_ShowWindow('OptionsVideoMenu');
3344 g_Sound_PlayEx('MENU_OPEN');
3345 end;
3347 procedure g_Menu_Show_OptionsSound();
3348 begin
3349 if gGameSettings.GameType = GT_SINGLE then
3350 g_GUI_ShowWindow('GameSingleMenu')
3351 else
3352 begin
3353 if g_Game_IsClient then
3354 g_GUI_ShowWindow('GameClientMenu')
3355 else
3356 if g_Game_IsNet then
3357 g_GUI_ShowWindow('GameServerMenu')
3358 else
3359 g_GUI_ShowWindow('GameCustomMenu');
3360 end;
3361 ReadOptions();
3362 g_GUI_ShowWindow('OptionsMenu');
3363 g_GUI_ShowWindow('OptionsSoundMenu');
3364 g_Sound_PlayEx('MENU_OPEN');
3365 end;
3367 procedure g_Menu_Show_EndGameMenu();
3368 begin
3369 g_GUI_ShowWindow('EndGameMenu');
3370 g_Sound_PlayEx('MENU_OPEN');
3371 end;
3373 procedure g_Menu_Show_QuitGameMenu();
3374 begin
3375 g_GUI_ShowWindow('ExitMenu');
3376 g_Sound_PlayEx('MENU_OPEN');
3377 end;
3379 procedure g_Menu_Init();
3380 begin
3381 MenuLoadData();
3382 g_GUI_Init();
3383 CreateAllMenus();
3384 end;
3386 procedure g_Menu_Free();
3387 begin
3388 g_GUI_Destroy();
3390 e_WriteLog('Releasing menu data...', TMsgType.Notify);
3392 MenuFreeData();
3393 end;
3395 procedure g_Menu_Reset();
3396 var
3397 ex: Boolean;
3398 begin
3399 g_GUI_SaveMenuPos();
3400 ex := g_GUI_Destroy();
3402 if ex then
3403 begin
3404 e_WriteLog('Recreating menu...', TMsgType.Notify);
3406 CreateAllMenus();
3408 if gDebugMode then
3409 g_Game_SetDebugMode();
3411 g_GUI_LoadMenuPos();
3412 end;
3413 end;
3415 end.