DEADSOFTWARE

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