DEADSOFTWARE

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