DEADSOFTWARE

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