DEADSOFTWARE

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