DEADSOFTWARE

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