DEADSOFTWARE

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