DEADSOFTWARE

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