DEADSOFTWARE

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