DEADSOFTWARE

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