DEADSOFTWARE

menu: fix background in credits
[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,
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; 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(False, False, '')));
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}
899 slReturnPressed := True;
900 if g_Net_Slist_Fetch(slCurrent) then
901 begin
902 if slCurrent = nil then
903 slWaitStr := _lc[I_NET_SLIST_NOSERVERS];
904 end
905 else
906 slWaitStr := _lc[I_NET_SLIST_ERROR];
907 g_Serverlist_GenerateTable(slCurrent, slTable);
908 end;
910 procedure ProcStartCampaign();
911 var
912 WAD: String;
913 TwoPlayers: Boolean;
914 n: Byte;
915 begin
916 with TGUIMenu(g_ActiveWindow.GetControl('mCampaignMenu')) do
917 begin
918 WAD := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
919 TwoPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex = 1;
920 end;
921 WAD := e_FindWadRel(MegawadDirs, WAD);
923 if TwoPlayers then
924 n := 2
925 else
926 n := 1;
927 g_Game_StartSingle(WAD + ':\MAP01', TwoPlayers, n);
928 end;
930 procedure ProcSelectMap(Sender: TGUIControl);
931 var
932 win: TGUIWindow;
933 a: TMapInfo;
934 wad, map, res: String;
935 begin
936 win := g_GUI_GetWindow('SelectMapMenu');
937 with TGUIMenu(win.GetControl('mSelectMapMenu')) do
938 begin
939 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
940 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
942 if (wad = '') or (map = '') then
943 begin // Ýòî íå êàðòà
944 TGUILabel(GetControl('lbMapName')).Text := '';
945 TGUILabel(GetControl('lbMapAuthor')).Text := '';
946 TGUILabel(GetControl('lbMapSize')).Text := '';
947 TGUIMemo(GetControl('meMapDescription')).SetText('');
948 TGUIMapPreview(win.GetControl('mpMapPreview')).ClearMap();
949 TGUILabel(win.GetControl('lbMapScale')).Text := '';
950 end
951 else // Ýòî êàðòà
952 begin
953 res := wad+':\'+map;
955 a := g_Map_GetMapInfo(res);
957 TGUILabel(GetControl('lbMapName')).Text := a.Name;
958 TGUILabel(GetControl('lbMapAuthor')).Text := a.Author;
959 TGUILabel(GetControl('lbMapSize')).Text := Format('%dx%d', [a.Width, a.Height]);
960 TGUIMemo(GetControl('meMapDescription')).SetText(a.Description);
961 TGUIMapPreview(win.GetControl('mpMapPreview')).SetMap(res);
962 TGUILabel(win.GetControl('lbMapScale')).Text :=
963 TGUIMapPreview(win.GetControl('mpMapPreview')).GetScaleStr;
964 end;
965 end;
966 end;
968 procedure ProcSelectWAD(Sender: TGUIControl);
969 var
970 wad: String;
971 list: SSArray;
972 begin
973 with TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu')) do
974 begin
975 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
977 with TGUIListBox(GetControl('lsMapRes')) do
978 begin
979 Clear();
981 if wad <> '' then
982 begin
983 list := g_Map_GetMapsList(wad);
985 if list <> nil then
986 begin
987 Items := list;
988 ItemIndex := 0;
989 end
990 end;
991 end;
992 end;
994 ProcSelectMap(nil);
995 end;
997 procedure ProcSelectCampaignWAD(Sender: TGUIControl);
998 var
999 win: TGUIWindow;
1000 a: TMegaWADInfo;
1001 wad, fn: String;
1002 begin
1003 win := g_GUI_GetWindow('CampaignMenu');
1004 with TGUIMenu(win.GetControl('mCampaignMenu')) do
1005 begin
1006 wad := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
1008 if wad = '' then
1009 begin
1010 TGUILabel(GetControl('lbWADName')).Text := '';
1011 TGUILabel(GetControl('lbWADAuthor')).Text := '';
1012 TGUIMemo(GetControl('meWADDescription')).SetText('');
1013 end;
1015 a := g_Game_GetMegaWADInfo(wad);
1017 TGUILabel(GetControl('lbWADName')).Text := a.Name;
1018 TGUILabel(GetControl('lbWADAuthor')).Text := a.Author;
1019 TGUIMemo(GetControl('meWADDescription')).SetText(a.Description);
1021 TGUIImage(win.GetControl('mpWADImage')).ClearImage();
1023 if a.pic <> '' then
1024 begin
1025 fn := g_ExtractWadName(a.pic);
1026 if fn = '' then
1027 TGUIImage(win.GetControl('mpWADImage')).SetImage(wad+a.pic)
1028 else
1029 TGUIImage(win.GetControl('mpWADImage')).SetImage(a.pic);
1030 end;
1031 end;
1032 end;
1034 procedure ProcChangeColor(Sender: TGUIControl);
1035 var
1036 window: TGUIWindow;
1037 begin
1038 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
1039 with TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')) do
1040 TGUIModelView(window.GetControl('mvP1Model')).SetColor(
1041 Min(TGUIScroll(GetControl('scP1Red')).Value*16, 255),
1042 Min(TGUIScroll(GetControl('scP1Green')).Value*16, 255),
1043 Min(TGUIScroll(GetControl('scP1Blue')).Value*16, 255));
1045 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
1046 with TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')) do
1047 TGUIModelView(window.GetControl('mvP2Model')).SetColor(
1048 Min(TGUIScroll(GetControl('scP2Red')).Value*16, 255),
1049 Min(TGUIScroll(GetControl('scP2Green')).Value*16, 255),
1050 Min(TGUIScroll(GetControl('scP2Blue')).Value*16, 255));
1051 end;
1053 procedure ProcSelectModel(Sender: TGUIControl);
1054 var
1055 a: string;
1056 window: TGUIWindow;
1057 begin
1058 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
1059 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')).GetControl('lsP1Model')).SelectedItem;
1060 if a <> '' then TGUIModelView(window.GetControl('mvP1Model')).SetModel(a);
1062 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
1063 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')).GetControl('lsP2Model')).SelectedItem;
1064 if a <> '' then TGUIModelView(window.GetControl('mvP2Model')).SetModel(a);
1066 ProcChangeColor(nil);
1067 end;
1069 procedure MenuLoadData();
1070 begin
1071 e_WriteLog('Loading menu data...', TMsgType.Notify);
1073 g_Sound_CreateWADEx('MENU_SELECT', GameWAD+':SOUNDS\MENUSELECT');
1074 g_Sound_CreateWADEx('MENU_OPEN', GameWAD+':SOUNDS\MENUOPEN');
1075 g_Sound_CreateWADEx('MENU_CLOSE', GameWAD+':SOUNDS\MENUCLOSE');
1076 g_Sound_CreateWADEx('MENU_CHANGE', GameWAD+':SOUNDS\MENUCHANGE');
1077 g_Sound_CreateWADEx('SCROLL_ADD', GameWAD+':SOUNDS\SCROLLADD');
1078 g_Sound_CreateWADEx('SCROLL_SUB', GameWAD+':SOUNDS\SCROLLSUB');
1079 g_Sound_CreateWADEx('SOUND_PLAYER_FALL', GameWAD+':SOUNDS\FALL');
1080 end;
1082 procedure MenuFreeData();
1083 begin
1084 g_Sound_Delete('MENU_SELECT');
1085 g_Sound_Delete('MENU_OPEN');
1086 g_Sound_Delete('MENU_CLOSE');
1087 g_Sound_Delete('MENU_CHANGE');
1088 g_Sound_Delete('SCROLL_ADD');
1089 g_Sound_Delete('SCROLL_SUB');
1090 g_Sound_Delete('SOUND_PLAYER_FALL');
1091 end;
1093 procedure ProcAuthorsMenu();
1094 begin
1095 gMusic.SetByName('MUSIC_INTERMUS');
1096 gMusic.Play();
1097 end;
1099 procedure ProcExitMenuKeyDown (yes: Boolean);
1100 var
1101 s: ShortString;
1102 snd: TPlayableSound;
1103 res: Boolean;
1104 begin
1105 if yes then
1106 begin
1107 g_Game_StopAllSounds(True);
1108 case (Random(18)) of
1109 0: s := 'SOUND_MONSTER_PAIN';
1110 1: s := 'SOUND_MONSTER_DIE_3';
1111 2: s := 'SOUND_MONSTER_SLOP';
1112 3: s := 'SOUND_MONSTER_DEMON_DIE';
1113 4: s := 'SOUND_MONSTER_IMP_DIE_2';
1114 5: s := 'SOUND_MONSTER_MAN_DIE';
1115 6: s := 'SOUND_MONSTER_BSP_DIE';
1116 7: s := 'SOUND_MONSTER_VILE_DIE';
1117 8: s := 'SOUND_MONSTER_SKEL_DIE';
1118 9: s := 'SOUND_MONSTER_MANCUB_ALERT';
1119 10: s := 'SOUND_MONSTER_PAIN_PAIN';
1120 11: s := 'SOUND_MONSTER_BARON_DIE';
1121 12: s := 'SOUND_MONSTER_CACO_DIE';
1122 13: s := 'SOUND_MONSTER_CYBER_DIE';
1123 14: s := 'SOUND_MONSTER_KNIGHT_ALERT';
1124 15: s := 'SOUND_MONSTER_SPIDER_ALERT';
1125 else s := 'SOUND_PLAYER_FALL';
1126 end;
1127 snd := TPlayableSound.Create();
1128 res := snd.SetByName(s);
1129 if not res then res := snd.SetByName('SOUND_PLAYER_FALL');
1130 if res then
1131 begin
1132 snd.Play(True);
1133 while snd.IsPlaying() do begin end;
1134 end;
1135 g_Game_Quit();
1136 exit;
1137 end;
1138 g_GUI_HideWindow();
1139 end;
1141 procedure ProcLoadMenu();
1142 var
1143 a: Integer;
1144 valid: Boolean;
1145 begin
1146 for a := 1 to 8 do
1147 begin
1148 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Text := g_GetSaveName(a, valid);
1149 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := not valid;
1150 //TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a)).Enabled := valid;
1151 end;
1152 end;
1154 procedure ProcSaveMenu();
1155 var
1156 a: Integer;
1157 valid: Boolean;
1158 name: AnsiString;
1159 begin
1160 for a := 1 to 8 do
1161 begin
1162 name := g_GetSaveName(a, valid);
1163 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Text := name;
1164 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := (name <> '') and (not valid);
1165 end;
1166 end;
1168 procedure ProcSaveGame(Sender: TGUIControl);
1169 var
1170 a: Integer;
1171 begin
1172 if g_Game_IsNet then Exit;
1173 if g_Game_IsTestMap then Exit;
1174 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1175 g_Game_PauseAllSounds(True);
1176 g_SaveGame(a, TGUIEdit(Sender).Text);
1178 g_ActiveWindow := nil;
1179 g_Game_Pause(False);
1180 end;
1182 procedure ProcLoadGame(Sender: TGUIControl);
1183 var
1184 a: Integer;
1185 begin
1186 if g_Game_IsNet then Exit;
1187 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1188 if g_LoadGame(a) then
1189 begin
1190 g_Game_PauseAllSounds(False)
1191 end
1192 else // Íå çàãðóçèëîñü - âîçâðàò â ìåíþ
1193 begin
1194 g_Console_Add(_lc[I_MSG_BAD_SAVE_VERSION], true);
1195 g_GUI_GetWindow('LoadMenu').SetActive(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu'));
1196 //g_ActiveWindow := nil;
1197 end;
1198 end;
1200 procedure ProcSinglePlayer (n: Integer);
1201 var wad, map: AnsiString;
1202 begin
1203 assert(n >= 1);
1204 wad := g_ExtractWadName(gDefaultMegawadStart);
1205 map := g_ExtractFilePathName(gDefaultMegawadStart);
1206 if e_FindResource(AllMapDirs, wad) then
1207 begin
1208 wad := ExpandFileName(wad);
1209 g_Game_StartSingle(wad + ':\' + map, n > 1, n)
1210 end
1211 end;
1213 procedure ProcSingle1Player;
1214 begin
1215 ProcSinglePlayer(1)
1216 end;
1218 procedure ProcSingle2Players;
1219 begin
1220 ProcSinglePlayer(2)
1221 end;
1223 procedure ProcSelectMapMenu();
1224 var
1225 menu: TGUIMenu;
1226 wad_lb: TGUIFileListBox;
1227 map_lb: TGUIListBox;
1228 map: String;
1229 begin
1230 menu := TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1231 wad_lb := TGUIFileListBox(menu.GetControl('lsMapWAD'));
1232 map_lb := TGUIListBox(menu.GetControl('lsMapRes'));
1234 if wad_lb.SelectedItem() <> '' then
1235 map := map_lb.SelectedItem()
1236 else
1237 map := '';
1239 wad_lb.UpdateFileList();
1240 map_lb.Clear();
1242 if wad_lb.SelectedItem() <> '' then
1243 begin
1244 ProcSelectWAD(nil);
1245 map_lb.SelectItem(map);
1247 if map_lb.SelectedItem() <> '' then
1248 ProcSelectMap(nil);
1249 end;
1251 g_GUI_ShowWindow('SelectMapMenu');
1252 end;
1254 procedure ProcSelectCampaignMenu();
1255 var
1256 menu: TGUIMenu;
1257 wad_lb: TGUIFileListBox;
1258 begin
1259 menu := TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1260 wad_lb := TGUIFileListBox(menu.GetControl('lsWAD'));
1262 wad_lb.UpdateFileList();
1264 if wad_lb.SelectedItem() <> '' then
1265 ProcSelectCampaignWAD(nil);
1266 end;
1268 procedure ProcSetMap();
1269 var
1270 wad, map, res: String;
1271 begin
1272 with TGUIMenu(g_ActiveWindow.GetControl('mSelectMapMenu')) do
1273 begin
1274 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
1275 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1276 end;
1278 if (wad = '') or (map = '') then
1279 Exit;
1281 wad := e_FindWadRel(MapDirs, WAD);
1283 res := wad+':\'+map;
1285 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
1286 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res;
1287 end;
1289 procedure ProcChangeSoundSettings(Sender: TGUIControl);
1290 var
1291 menu: TGUIMenu;
1292 begin
1293 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1295 g_Sound_SetupAllVolumes(
1296 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
1297 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
1298 );
1299 end;
1301 procedure ProcChangeGameSettings(Sender: TGUIControl);
1302 var
1303 menu: TGUIMenu;
1304 begin
1305 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
1306 if TGUIScroll(menu.GetControl('scScaleFactor')).Value <> TempScale then
1307 begin
1308 TempScale := TGUIScroll(menu.GetControl('scScaleFactor')).Value;
1309 g_dbg_scale := TempScale + 1;
1310 end;
1311 end;
1313 procedure ProcChangeTouchSettings(Sender: TGUIControl);
1314 var
1315 menu: TGUIMenu;
1316 begin
1317 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
1318 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
1319 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
1320 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
1321 end;
1323 procedure ProcOptionsPlayersMIMenu();
1324 var
1325 s, a: string;
1326 i: Integer;
1327 begin
1328 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1330 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+s+'Menu')).GetControl('ls'+s+'Model')).SelectedItem;
1332 if a = '' then Exit;
1334 i := g_PlayerModel_GetIndex(a);
1335 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1336 begin
1337 TGUILabel(GetControl('lbName')).Text := PlayerModelsArray[i].Name;
1338 TGUILabel(GetControl('lbAuthor')).Text := PlayerModelsArray[i].Author;
1339 TGUIMemo(GetControl('meComment')).SetText(PlayerModelsArray[i].Description);
1341 if PlayerModelsArray[i].HaveWeapon then
1342 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1343 else
1344 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1345 end;
1347 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1348 end;
1350 procedure ProcOptionsPlayerP1WeaponMenu();
1351 var
1352 a: string;
1353 begin
1354 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+'P1'+'Menu')).GetControl('ls'+'P1'+'Model')).SelectedItem;
1355 if a = '' then Exit;
1356 g_GUI_ShowWindow('OptionsPlayersP1WeaponMenu');
1357 end;
1359 procedure ProcOptionsPlayerP1WeaponPreferencesMenu();
1360 begin
1361 g_GUI_ShowWindow('OptionsPreferencesP1WeaponMenu');
1362 end;
1364 procedure ProcOptionsPlayerP2WeaponMenu();
1365 var
1366 a: string;
1367 begin
1368 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+'P2'+'Menu')).GetControl('ls'+'P2'+'Model')).SelectedItem;
1369 if a = '' then Exit;
1370 g_GUI_ShowWindow('OptionsPlayersP2WeaponMenu');
1371 end;
1373 procedure ProcOptionsPlayerP2WeaponPreferencesMenu();
1374 begin
1375 g_GUI_ShowWindow('OptionsPreferencesP2WeaponMenu');
1376 end;
1378 procedure ProcOptionsPlayersAnim();
1379 var
1380 s: String;
1381 begin
1382 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1383 s := 'P1'
1384 else
1385 s := 'P2';
1387 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1388 begin
1389 NextAnim();
1390 Model.AnimState.Loop := True;
1391 end;
1392 end;
1394 procedure ProcOptionsPlayersWeap();
1395 var
1396 s: String;
1397 begin
1398 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1399 s := 'P1'
1400 else
1401 s := 'P2';
1403 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1404 NextWeapon();
1405 end;
1407 procedure ProcOptionsPlayersRot();
1408 var
1409 s: string;
1410 begin
1411 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1412 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1413 begin
1414 if Direction = TDirection.D_LEFT then Direction := TDirection.D_RIGHT else Direction := TDirection.D_LEFT;
1415 end;
1416 end;
1418 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1419 begin
1420 if yes then
1421 begin
1422 g_Options_SetDefault();
1423 ReadOptions();
1424 end;
1425 g_GUI_HideWindow();
1426 end;
1428 procedure ProcSavedMenuKeyDown (yes: Boolean);
1429 begin
1430 if yes then ReadOptions();
1431 g_GUI_HideWindow();
1432 end;
1434 procedure ProcAuthorsClose();
1435 begin
1436 gMusic.SetByName('MUSIC_MENU');
1437 gMusic.Play();
1438 gState := STATE_MENU;
1439 end;
1441 procedure ProcGMClose();
1442 begin
1443 g_Game_InGameMenu(False);
1444 end;
1446 procedure ProcGMShow();
1447 var
1448 Enabled: Boolean;
1449 begin
1450 Enabled := True;
1451 if (gGameSettings.GameType = GT_SINGLE) and
1452 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1453 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1454 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1455 if not gGameOn then
1456 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1457 if g_Game_IsTestMap then
1458 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1459 TGUIMainMenu(g_ActiveWindow.GetControl(
1460 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1461 end;
1463 procedure ProcChangePlayers();
1464 var
1465 TeamGame, Spectator, AddTwo: Boolean;
1466 P1Team{, P2Team}: Byte;
1467 bP2: TGUITextButton;
1468 begin
1469 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1470 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1471 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1472 P1Team := TEAM_NONE;
1473 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1474 // TODO
1475 //P2Team := TEAM_NONE;
1476 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1478 TGUIMainMenu(g_ActiveWindow.GetControl(
1479 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1480 TGUIMainMenu(g_ActiveWindow.GetControl(
1481 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1482 TGUIMainMenu(g_ActiveWindow.GetControl(
1483 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1485 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1486 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1487 bP2.Enabled := AddTwo and not Spectator;
1488 if bP2.Enabled then
1489 bP2.Color := MAINMENU_ITEMS_COLOR
1490 else
1491 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1492 if gPlayer2 = nil then
1493 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1494 else
1495 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1497 TGUIMainMenu(g_ActiveWindow.GetControl(
1498 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1499 end;
1501 procedure ProcJoinRed();
1502 begin
1503 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1504 Exit;
1505 if g_Game_IsServer then
1506 begin
1507 if gPlayer1 = nil then
1508 g_Game_AddPlayer(TEAM_RED)
1509 else
1510 begin
1511 if gPlayer1.Team <> TEAM_RED then
1512 begin
1513 gPlayer1.SwitchTeam;
1514 gPlayer1Settings.Team := gPlayer1.Team;
1515 end;
1517 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1518 end;
1519 end
1520 else
1521 begin
1522 gPlayer1Settings.Team := TEAM_RED;
1523 MC_SEND_PlayerSettings;
1524 if gPlayer1 = nil then
1525 g_Game_AddPlayer(TEAM_RED);
1526 end;
1527 g_ActiveWindow := nil;
1528 g_Game_Pause(False);
1529 end;
1531 procedure ProcJoinBlue();
1532 begin
1533 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1534 Exit;
1535 if g_Game_IsServer then
1536 begin
1537 if gPlayer1 = nil then
1538 g_Game_AddPlayer(TEAM_BLUE)
1539 else
1540 begin
1541 if gPlayer1.Team <> TEAM_BLUE then
1542 begin
1543 gPlayer1.SwitchTeam;
1544 gPlayer1Settings.Team := gPlayer1.Team;
1545 end;
1547 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1548 end;
1549 end
1550 else
1551 begin
1552 gPlayer1Settings.Team := TEAM_BLUE;
1553 MC_SEND_PlayerSettings;
1554 if gPlayer1 = nil then
1555 g_Game_AddPlayer(TEAM_BLUE);
1556 end;
1557 g_ActiveWindow := nil;
1558 g_Game_Pause(False);
1559 end;
1561 procedure ProcJoinGame();
1562 begin
1563 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1564 Exit;
1565 if gPlayer1 = nil then
1566 g_Game_AddPlayer();
1567 g_ActiveWindow := nil;
1568 g_Game_Pause(False);
1569 end;
1571 procedure ProcSwitchP2();
1572 begin
1573 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1574 Exit;
1575 if gPlayer1 = nil then
1576 Exit;
1577 if gPlayer2 = nil then
1578 g_Game_AddPlayer()
1579 else
1580 g_Game_RemovePlayer();
1581 g_ActiveWindow := nil;
1582 g_Game_Pause(False);
1583 end;
1585 procedure ProcSpectate();
1586 begin
1587 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1588 Exit;
1589 g_Game_Spectate();
1590 g_ActiveWindow := nil;
1591 g_Game_Pause(False);
1592 end;
1594 procedure ProcRestartMenuKeyDown (yes: Boolean);
1595 begin
1596 if yes then g_Game_Restart() else g_GUI_HideWindow;
1597 end;
1599 procedure ProcEndMenuKeyDown (yes: Boolean);
1600 begin
1601 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1602 end;
1604 procedure ProcSetRussianLanguage;
1605 begin
1606 if gLanguage <> LANGUAGE_RUSSIAN then
1607 begin
1608 gLanguage := LANGUAGE_RUSSIAN;
1609 gLanguageChange := True;
1610 gAskLanguage := False;
1611 ProcApplyOptions();
1612 end;
1613 end;
1615 procedure ProcSetEnglishLanguage;
1616 begin
1617 if gLanguage <> LANGUAGE_ENGLISH then
1618 begin
1619 gLanguage := LANGUAGE_ENGLISH;
1620 gLanguageChange := True;
1621 gAskLanguage := False;
1622 ProcApplyOptions();
1623 end;
1624 end;
1626 procedure ReadGameSettings();
1627 var
1628 menu: TGUIMenu;
1629 begin
1630 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1632 with gGameSettings do
1633 begin
1634 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1635 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1636 ItemIndex := 0
1637 else
1638 ItemIndex := 1;
1639 with TGUISwitch(menu.GetControl('swTeamHit')) do
1640 if (Options and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
1641 ItemIndex := 0
1642 else if LongBool(Options and GAME_OPTION_TEAMHITTRACE) then
1643 ItemIndex := 1
1644 else if LongBool(Options and GAME_OPTION_TEAMHITPROJECTILE) then
1645 ItemIndex := 2
1646 else
1647 ItemIndex := 3;
1648 with TGUISwitch(menu.GetControl('swDeathmatchKeys')) do
1649 if LongBool(Options and GAME_OPTION_DMKEYS) then
1650 ItemIndex := 0
1651 else
1652 ItemIndex := 1;
1653 with TGUISwitch(menu.GetControl('swFlagDrop')) do
1654 if LongBool(Options and GAME_OPTION_ALLOWDROPFLAG) and LongBool(Options and GAME_OPTION_THROWFLAG) then
1655 ItemIndex := 0
1656 else if LongBool(Options and GAME_OPTION_ALLOWDROPFLAG) then
1657 ItemIndex := 1
1658 else
1659 ItemIndex := 2;
1661 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1662 TGUIEdit(menu.GetControl('edScoreLimit')).Text := IntToStr(ScoreLimit);
1663 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1665 with TGUISwitch(menu.GetControl('swBotsVS')) do
1666 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1667 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1668 ItemIndex := 2
1669 else
1670 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1671 ItemIndex := 1
1672 else
1673 ItemIndex := 0;
1675 if GameType in [GT_CUSTOM, GT_SERVER] then
1676 begin
1677 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1678 TGUISwitch(menu.GetControl('swTeamHit')).Enabled := True;
1679 if (GameMode in [GM_DM, GM_TDM, GM_CTF]) then
1680 begin
1681 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := True;
1682 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_ITEMSTEXT_COLOR;
1683 end
1684 else
1685 begin
1686 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1687 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1688 end;
1689 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1690 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1691 TGUIEdit(menu.GetControl('edScoreLimit')).Enabled := True;
1692 TGUILabel(menu.GetControlsText('edScoreLimit')).Color := MENU_ITEMSTEXT_COLOR;
1693 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1694 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1695 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1696 TGUISwitch(menu.GetControl('swFlagDrop')).Enabled := True;
1697 end
1698 else
1699 begin
1700 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1701 TGUISwitch(menu.GetControl('swTeamHit')).Enabled := True;
1702 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1703 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1704 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1705 begin
1706 Enabled := False;
1707 Text := '';
1708 end;
1709 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1710 with TGUIEdit(menu.GetControl('edScoreLimit')) do
1711 begin
1712 Enabled := False;
1713 Text := '';
1714 end;
1715 TGUILabel(menu.GetControlsText('edScoreLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1716 with TGUIEdit(menu.GetControl('edMaxLives')) do
1717 begin
1718 Enabled := False;
1719 Text := '';
1720 end;
1721 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1722 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1723 TGUISwitch(menu.GetControl('swFlagDrop')).Enabled := False;
1724 end;
1725 end;
1726 end;
1728 procedure ProcApplyGameSet();
1729 var
1730 menu: TGUIMenu;
1731 a, b, n: Integer;
1732 stat: TPlayerStatArray;
1733 begin
1734 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1736 if not g_Game_IsServer then Exit;
1738 with gGameSettings do
1739 begin
1740 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1741 begin
1742 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1743 Options := Options or GAME_OPTION_TEAMDAMAGE
1744 else
1745 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1746 end;
1748 if TGUISwitch(menu.GetControl('swTeamHit')).Enabled then
1749 begin
1750 Options := Options and not (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE);
1751 case TGUISwitch(menu.GetControl('swTeamHit')).ItemIndex of
1752 1: Options := Options or GAME_OPTION_TEAMHITTRACE;
1753 2: Options := Options or GAME_OPTION_TEAMHITPROJECTILE;
1754 0: Options := Options or GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE;
1755 end;
1756 end;
1758 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled then
1759 begin
1760 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).ItemIndex = 0 then
1761 Options := Options or GAME_OPTION_DMKEYS
1762 else
1763 Options := Options and (not GAME_OPTION_DMKEYS);
1764 end;
1766 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1767 begin
1768 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1770 if n = 0 then
1771 TimeLimit := 0
1772 else
1773 begin
1774 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1776 TimeLimit := Max(n, b);
1777 end;
1778 end;
1780 if TGUIEdit(menu.GetControl('edScoreLimit')).Enabled then
1781 begin
1782 n := StrToIntDef(TGUIEdit(menu.GetControl('edScoreLimit')).Text, ScoreLimit);
1784 if n = 0 then
1785 ScoreLimit := 0
1786 else
1787 begin
1788 b := 0;
1789 if GameMode = GM_DM then
1790 begin // DM
1791 stat := g_Player_GetStats();
1792 if stat <> nil then
1793 for a := 0 to High(stat) do
1794 if stat[a].Frags > b then
1795 b := stat[a].Frags;
1796 end
1797 else // CTF
1798 b := Max(gTeamStat[TEAM_RED].Score, gTeamStat[TEAM_BLUE].Score);
1800 ScoreLimit := Max(n, b);
1801 end;
1802 end;
1804 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1805 begin
1806 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, MaxLives);
1807 if n < 0 then n := 0;
1808 if n > 255 then n := 255;
1809 if n = 0 then
1810 MaxLives := 0
1811 else
1812 begin
1813 b := 0;
1814 stat := g_Player_GetStats();
1815 if stat <> nil then
1816 for a := 0 to High(stat) do
1817 if stat[a].Lives > b then
1818 b := stat[a].Lives;
1820 MaxLives := Max(n, b);
1821 end;
1822 end;
1824 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1825 begin
1826 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1827 1:
1828 begin
1829 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1830 Options := Options or GAME_OPTION_BOTVSMONSTER;
1831 end;
1832 2:
1833 begin
1834 Options := Options or GAME_OPTION_BOTVSPLAYER;
1835 Options := Options or GAME_OPTION_BOTVSMONSTER;
1836 end;
1837 else
1838 begin
1839 Options := Options or GAME_OPTION_BOTVSPLAYER;
1840 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1841 end;
1842 end;
1843 end;
1845 if TGUISwitch(menu.GetControl('swFlagDrop')).Enabled then
1846 begin
1847 case TGUISwitch(menu.GetControl('swFlagDrop')).ItemIndex of
1848 0: Options := Options or GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG;
1849 1: Options := Options or GAME_OPTION_ALLOWDROPFLAG;
1850 else Options := Options and not (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG);
1851 end;
1852 end;
1854 // don't forget to latch this shit
1855 gsGameFlags := Options;
1856 gsMaxLives := MaxLives;
1857 gsScoreLimit := ScoreLimit;
1858 gsTimeLimit := TimeLimit;
1859 end;
1861 if g_Game_IsNet then MH_SEND_GameSettings;
1862 end;
1864 procedure ProcVideoOptionsRes();
1865 var
1866 menu: TGUIMenu;
1867 list: SSArray;
1868 begin
1869 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1871 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1872 IntToStr(gWinSizeX) +
1873 ' x ' + IntToStr(gWinSizeY) +
1874 ', ' + IntToStr(gBPP) + ' bpp';
1876 with TGUIListBox(menu.GetControl('lsResolution')) do
1877 begin
1878 {$IFDEF ENABLE_SYSTEM}
1879 list := sys_GetDisplayModes(gBPP);
1880 {$ELSE}
1881 list := nil;
1882 {$ENDIF}
1883 if list <> nil then
1884 begin
1885 Items := list;
1886 ItemIndex := Length(list)
1887 end
1888 else
1889 begin
1890 Clear
1891 end
1892 end;
1894 with TGUISwitch(menu.GetControl('swFullScreen')) do
1895 if gFullscreen then
1896 ItemIndex := 0
1897 else
1898 ItemIndex := 1;
1900 TempResScale := Round(r_pixel_scale - 1);
1901 with TGUISwitch(menu.GetControl('swResFactor')) do
1902 ItemIndex := Min(TempResScale, gRC_Width div 640 - 1);
1903 end;
1905 procedure ProcApplyVideoOptions();
1906 var
1907 menu: TGUIMenu;
1908 Fullscreen: Boolean;
1909 SWidth, SHeight: Integer;
1910 ScaleChanged: Boolean;
1911 str: String;
1912 begin
1913 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1915 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1916 if str <> '' then
1917 SScanf(str, '%dx%d', [@SWidth, @SHeight])
1918 else
1919 begin
1920 SWidth := gWinSizeX;
1921 SHeight := gWinSizeY;
1922 TempResScale := Min(TempResScale, SWidth div 640 - 1);
1923 end;
1925 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1927 ScaleChanged := False;
1928 if TGUISwitch(menu.GetControl('swResFactor')).ItemIndex <> TempResScale then
1929 begin
1930 TempResScale := Min(TGUISwitch(menu.GetControl('swResFactor')).ItemIndex, SWidth div 640 - 1);
1931 r_pixel_scale := TempResScale + 1;
1932 ScaleChanged := True;
1933 end;
1935 if (SWidth <> gWinSizeX) or
1936 (SHeight <> gWinSizeY) or
1937 (Fullscreen <> gFullscreen) or
1938 ScaleChanged then
1939 begin
1940 gResolutionChange := True;
1941 gRC_Width := SWidth;
1942 gRC_Height := SHeight;
1943 gRC_FullScreen := Fullscreen;
1944 gRC_Maximized := gWinMaximized;
1945 end;
1947 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1948 ProcApplyOptions();
1949 end;
1951 procedure ProcSetFirstRussianLanguage;
1952 begin
1953 gLanguage := LANGUAGE_RUSSIAN;
1954 gLanguageChange := True;
1955 gAskLanguage := False;
1956 end;
1958 procedure ProcSetFirstEnglishLanguage;
1959 begin
1960 gLanguage := LANGUAGE_ENGLISH;
1961 gLanguageChange := True;
1962 gAskLanguage := False;
1963 end;
1965 procedure ProcRecallAddress();
1966 begin
1967 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1968 begin
1969 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1970 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1971 end;
1972 end;
1974 procedure CreateFirstLanguageMenu();
1975 var
1976 Menu: TGUIWindow;
1977 begin
1978 Menu := TGUIWindow.Create('FirstLanguageMenu');
1980 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, ' '))) do // space to prevent show logo
1981 begin
1982 Name := 'mmFirstLanguageMenu';
1983 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
1984 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
1985 end;
1987 Menu.DefControl := 'mmFirstLanguageMenu';
1988 Menu.MainWindow := True;
1989 g_GUI_AddWindow(Menu);
1990 end;
1992 procedure g_Menu_AskLanguage();
1993 begin
1994 CreateFirstLanguageMenu();
1995 g_GUI_ShowWindow('FirstLanguageMenu');
1996 end;
1998 procedure CreatePlayerOptionsMenu(s: String);
1999 var
2000 Menu: TGUIWindow;
2001 a: String;
2002 begin
2003 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
2004 if s = 'P1' then
2005 a := _lc[I_MENU_PLAYER_1]
2006 else
2007 a := _lc[I_MENU_PLAYER_2];
2008 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, a))) do
2009 begin
2010 Name := 'mOptionsPlayers'+s+'Menu';
2011 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
2012 begin
2013 Name := 'ed'+s+'Name';
2014 MaxLength := 12;
2015 Width := 12;
2016 end;
2017 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
2018 begin
2019 Name := 'sw'+s+'Team';
2020 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
2021 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
2022 end ;
2023 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
2024 begin
2025 Name := 'ls'+s+'Model';
2026 Sort := True;
2027 Items := g_PlayerModel_GetNames();
2028 OnChange := ProcSelectModel;
2029 end;
2030 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
2031 begin
2032 Name := 'sc'+s+'Red';
2033 Max := 16;
2034 OnChange := ProcChangeColor;
2035 end;
2036 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
2037 begin
2038 Name := 'sc'+s+'Green';
2039 Max := 16;
2040 OnChange := ProcChangeColor;
2041 end;
2042 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
2043 begin
2044 Name := 'sc'+s+'Blue';
2045 Max := 16;
2046 OnChange := ProcChangeColor;
2047 end;
2048 AddSpace();
2049 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
2050 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
2051 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
2052 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
2053 if s = 'P1' then AddButton(@ProcOptionsPlayerP1WeaponMenu, _lc[I_MENU_WEAPON])
2054 else AddButton(@ProcOptionsPlayerP2WeaponMenu, _lc[I_MENU_WEAPON]);
2055 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
2056 begin
2057 Name := 'mv'+s+'Model';
2058 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
2059 Y := GetControl('ls'+s+'Model').Y;
2060 end;
2061 end;
2062 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
2063 g_GUI_AddWindow(Menu);
2064 end;
2066 procedure CreateAllMenus();
2067 var
2068 Menu: TGUIWindow;
2069 //SR: TSearchRec;
2070 a, cx, _y, i: Integer;
2071 //list: SSArray;
2072 begin
2073 Menu := TGUIWindow.Create('MainMenu');
2074 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, '' (*_lc[I_MENU_MAIN_MENU]*) ))) do
2075 begin
2076 Name := 'mmMainMenu';
2077 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
2078 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
2079 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2080 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2081 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
2082 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
2083 end;
2084 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), False))) do
2085 begin
2086 Color := _RGB(255, 255, 255);
2087 X := gScreenWidth-GetWidth-8;
2088 Y := gScreenHeight-GetHeight-8;
2089 end;
2090 Menu.DefControl := 'mmMainMenu';
2091 Menu.MainWindow := True;
2092 g_GUI_AddWindow(Menu);
2094 Menu := TGUIWindow.Create('NewGameMenu');
2095 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_NEW_GAME]))) do
2096 begin
2097 Name := 'mmNewGameMenu';
2098 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
2099 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
2100 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
2101 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
2102 end;
2103 Menu.DefControl := 'mmNewGameMenu';
2104 g_GUI_AddWindow(Menu);
2106 Menu := TGUIWindow.Create('NetGameMenu');
2107 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_MULTIPLAYER]))) do
2108 begin
2109 Name := 'mmNetGameMenu';
2110 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
2111 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
2112 end;
2113 Menu.DefControl := 'mmNetGameMenu';
2114 g_GUI_AddWindow(Menu);
2116 Menu := TGUIWindow.Create('NetServerMenu');
2117 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_START_SERVER]))) do
2118 begin
2119 Name := 'mNetServerMenu';
2120 with AddEdit(_lc[I_NET_SERVER_NAME]) do
2121 begin
2122 Name := 'edSrvName';
2123 OnlyDigits := False;
2124 Width := 16;
2125 MaxLength := 64;
2126 Text := NetServerName;
2127 end;
2128 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2129 begin
2130 Name := 'edSrvPassword';
2131 OnlyDigits := False;
2132 Width := 16;
2133 MaxLength := 24;
2134 Text := NetPassword;
2135 end;
2136 with AddEdit(_lc[I_NET_PORT]) do
2137 begin
2138 Name := 'edPort';
2139 OnlyDigits := True;
2140 Width := 4;
2141 MaxLength := 5;
2142 Text := IntToStr(NetPort);
2143 end;
2144 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2145 begin
2146 Name := 'edMaxPlayers';
2147 OnlyDigits := True;
2148 Width := 4;
2149 MaxLength := 2;
2150 Text := IntToStr(NetMaxClients);
2151 end;
2152 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2153 begin
2154 Name := 'swUseMaster';
2155 AddItem(_lc[I_MENU_YES]);
2156 AddItem(_lc[I_MENU_NO]);
2157 if NetUseMaster then
2158 ItemIndex := 0
2159 else
2160 ItemIndex := 1;
2161 end;
2162 AddSpace();
2163 with AddLabel(_lc[I_MENU_MAP]) do
2164 begin
2165 Name := 'lbMap';
2166 FixedLength := 16;
2167 Text := gsMap;
2168 OnClick := @ProcSelectMapMenu;
2169 end;
2170 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2171 begin
2172 Name := 'swGameMode';
2173 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2174 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2175 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2176 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2177 case g_Game_TextToMode(gsGameMode) of
2178 GM_NONE,
2179 GM_DM: ItemIndex := 0;
2180 GM_TDM: ItemIndex := 1;
2181 GM_CTF: ItemIndex := 2;
2182 GM_SINGLE,
2183 GM_COOP: ItemIndex := 3;
2184 end;
2185 OnChange := ProcSwitchMonstersCustom;
2186 end;
2187 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2188 begin
2189 Name := 'edTimeLimit';
2190 OnlyDigits := True;
2191 Width := 4;
2192 MaxLength := 5;
2193 if gsTimeLimit > 0 then
2194 Text := IntToStr(gsTimeLimit);
2195 end;
2196 with AddEdit(_lc[I_MENU_SCORE_LIMIT]) do
2197 begin
2198 Name := 'edScoreLimit';
2199 OnlyDigits := True;
2200 Width := 4;
2201 MaxLength := 5;
2202 if gsScoreLimit > 0 then
2203 Text := IntToStr(gsScoreLimit);
2204 end;
2205 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2206 begin
2207 Name := 'edMaxLives';
2208 OnlyDigits := True;
2209 Width := 4;
2210 MaxLength := 5;
2211 if gsMaxLives > 0 then
2212 Text := IntToStr(gsMaxLives);
2213 end;
2214 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2215 begin
2216 Name := 'edItemRespawnTime';
2217 OnlyDigits := True;
2218 Width := 4;
2219 MaxLength := 5;
2220 if gsItemRespawnTime > 0 then
2221 Text := IntToStr(gsItemRespawnTime);
2222 end;
2223 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2224 begin
2225 Name := 'swPlayers';
2226 AddItem(_lc[I_MENU_COUNT_NONE]);
2227 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2228 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2229 ItemIndex := gsPlayers;
2230 end;
2231 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2232 begin
2233 Name := 'swTeamDamage';
2234 AddItem(_lc[I_MENU_YES]);
2235 AddItem(_lc[I_MENU_NO]);
2236 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2237 ItemIndex := 0
2238 else
2239 ItemIndex := 1;
2240 end;
2241 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
2242 begin
2243 Name := 'swTeamHit';
2244 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
2245 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
2246 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
2247 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
2248 if (gsGameFlags and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
2249 ItemIndex := 0
2250 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITTRACE) then
2251 ItemIndex := 1
2252 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITPROJECTILE) then
2253 ItemIndex := 2
2254 else
2255 ItemIndex := 3;
2256 end;
2257 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2258 begin
2259 Name := 'swDeathmatchKeys';
2260 AddItem(_lc[I_MENU_YES]);
2261 AddItem(_lc[I_MENU_NO]);
2262 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2263 ItemIndex := 0
2264 else
2265 ItemIndex := 1;
2266 end;
2267 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2268 begin
2269 Name := 'swEnableExits';
2270 AddItem(_lc[I_MENU_YES]);
2271 AddItem(_lc[I_MENU_NO]);
2272 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2273 ItemIndex := 0
2274 else
2275 ItemIndex := 1;
2276 end;
2277 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2278 begin
2279 Name := 'swWeaponStay';
2280 AddItem(_lc[I_MENU_YES]);
2281 AddItem(_lc[I_MENU_NO]);
2282 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2283 ItemIndex := 0
2284 else
2285 ItemIndex := 1;
2286 end;
2287 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2288 begin
2289 Name := 'swMonsters';
2290 AddItem(_lc[I_MENU_YES]);
2291 AddItem(_lc[I_MENU_NO]);
2292 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2293 ItemIndex := 0
2294 else
2295 ItemIndex := 1;
2296 end;
2297 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2298 begin
2299 Name := 'swBotsVS';
2300 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2301 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2302 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2303 ItemIndex := 2;
2304 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2305 ItemIndex := 0;
2306 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2307 ItemIndex := 1;
2308 end;
2309 with AddSwitch(_lc[I_MENU_FLAG_DROP]) do
2310 begin
2311 Name := 'swFlagDrop';
2312 AddItem(_lc[I_MENU_FLAG_THROW]);
2313 AddItem(_lc[I_MENU_YES]);
2314 AddItem(_lc[I_MENU_NO]);
2315 if (gsGameFlags and (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG)) = (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG) then
2316 ItemIndex := 0
2317 else if LongBool(gsGameFlags and GAME_OPTION_ALLOWDROPFLAG) then
2318 ItemIndex := 1
2319 else
2320 ItemIndex := 2;
2321 end;
2322 AddSpace();
2323 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2325 ReAlign();
2326 end;
2327 Menu.DefControl := 'mNetServerMenu';
2328 g_GUI_AddWindow(Menu);
2330 Menu := TGUIWindow.Create('NetClientMenu');
2331 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_START_CLIENT]))) do
2332 begin
2333 Name := 'mNetClientMenu';
2335 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2336 AddSpace();
2338 with AddEdit(_lc[I_NET_ADDRESS]) do
2339 begin
2340 Name := 'edIP';
2341 OnlyDigits :=False;
2342 Width := 12;
2343 MaxLength := 64;
2344 Text := 'localhost';
2345 end;
2346 with AddEdit(_lc[I_NET_PORT]) do
2347 begin
2348 Name := 'edPort';
2349 OnlyDigits := True;
2350 Width := 4;
2351 MaxLength := 5;
2352 Text := '25666';
2353 end;
2354 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2355 begin
2356 Name := 'edPW';
2357 OnlyDigits := False;
2358 Width := 12;
2359 MaxLength := 32;
2360 Text := '';
2361 end;
2363 AddSpace();
2364 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2366 ReAlign();
2367 end;
2368 Menu.DefControl := 'mNetClientMenu';
2369 g_GUI_AddWindow(Menu);
2371 Menu := TGUIWindow.Create('LoadMenu');
2372 Menu.OnShow := ProcLoadMenu;
2373 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_LOAD_GAME]))) do
2374 begin
2375 Name := 'mmLoadMenu';
2377 for a := 1 to 8 do
2378 with AddEdit('') do
2379 begin
2380 Name := 'edSlot'+IntToStr(a);
2381 Width := 16;
2382 MaxLength := 16;
2383 OnEnter := ProcLoadGame;
2384 end;
2385 end;
2386 Menu.DefControl := 'mmLoadMenu';
2387 g_GUI_AddWindow(Menu);
2389 Menu := TGUIWindow.Create('SaveMenu');
2390 Menu.OnShow := ProcSaveMenu;
2391 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_SAVE_GAME]))) do
2392 begin
2393 Name := 'mmSaveMenu';
2395 for a := 1 to 8 do
2396 with AddEdit('') do
2397 begin
2398 Name := 'edSlot'+IntToStr(a);
2399 Width := 16;
2400 MaxLength := 16;
2401 OnChange := ProcSaveGame;
2402 end;
2403 end;
2404 Menu.DefControl := 'mmSaveMenu';
2405 g_GUI_AddWindow(Menu);
2407 Menu := TGUIWindow.Create('CustomGameMenu');
2408 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_CUSTOM_GAME]))) do
2409 begin
2410 Name := 'mCustomGameMenu';
2411 with AddLabel(_lc[I_MENU_MAP]) do
2412 begin
2413 Name := 'lbMap';
2414 FixedLength := 16;
2415 Text := gsMap;
2416 OnClick := @ProcSelectMapMenu;
2417 end;
2418 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2419 begin
2420 Name := 'swGameMode';
2421 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2422 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2423 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2424 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2425 case g_Game_TextToMode(gsGameMode) of
2426 GM_NONE,
2427 GM_DM: ItemIndex := 0;
2428 GM_TDM: ItemIndex := 1;
2429 GM_CTF: ItemIndex := 2;
2430 GM_SINGLE,
2431 GM_COOP: ItemIndex := 3;
2432 end;
2433 OnChange := ProcSwitchMonstersCustom;
2434 end;
2435 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2436 begin
2437 Name := 'edTimeLimit';
2438 OnlyDigits := True;
2439 Width := 4;
2440 MaxLength := 5;
2441 if gsTimeLimit > 0 then
2442 Text := IntToStr(gsTimeLimit);
2443 end;
2444 with AddEdit(_lc[I_MENU_SCORE_LIMIT]) do
2445 begin
2446 Name := 'edScoreLimit';
2447 OnlyDigits := True;
2448 Width := 4;
2449 MaxLength := 5;
2450 if gsScoreLimit > 0 then
2451 Text := IntToStr(gsScoreLimit);
2452 end;
2453 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2454 begin
2455 Name := 'edMaxLives';
2456 OnlyDigits := True;
2457 Width := 4;
2458 MaxLength := 5;
2459 if gsMaxLives > 0 then
2460 Text := IntToStr(gsMaxLives);
2461 end;
2462 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2463 begin
2464 Name := 'edItemRespawnTime';
2465 OnlyDigits := True;
2466 Width := 4;
2467 MaxLength := 5;
2468 if gsItemRespawnTime > 0 then
2469 Text := IntToStr(gsItemRespawnTime);
2470 end;
2471 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2472 begin
2473 Name := 'swPlayers';
2474 AddItem(_lc[I_MENU_COUNT_NONE]);
2475 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2476 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2477 ItemIndex := gsPlayers;
2478 end;
2479 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2480 begin
2481 Name := 'swTeamDamage';
2482 AddItem(_lc[I_MENU_YES]);
2483 AddItem(_lc[I_MENU_NO]);
2484 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2485 ItemIndex := 0
2486 else
2487 ItemIndex := 1;
2488 end;
2489 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
2490 begin
2491 Name := 'swTeamHit';
2492 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
2493 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
2494 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
2495 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
2496 if (gsGameFlags and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
2497 ItemIndex := 0
2498 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITTRACE) then
2499 ItemIndex := 1
2500 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITPROJECTILE) then
2501 ItemIndex := 2
2502 else
2503 ItemIndex := 3;
2504 end;
2505 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2506 begin
2507 Name := 'swDeathmatchKeys';
2508 AddItem(_lc[I_MENU_YES]);
2509 AddItem(_lc[I_MENU_NO]);
2510 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2511 ItemIndex := 0
2512 else
2513 ItemIndex := 1;
2514 end;
2515 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2516 begin
2517 Name := 'swEnableExits';
2518 AddItem(_lc[I_MENU_YES]);
2519 AddItem(_lc[I_MENU_NO]);
2520 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2521 ItemIndex := 0
2522 else
2523 ItemIndex := 1;
2524 end;
2525 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2526 begin
2527 Name := 'swWeaponStay';
2528 AddItem(_lc[I_MENU_YES]);
2529 AddItem(_lc[I_MENU_NO]);
2530 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2531 ItemIndex := 0
2532 else
2533 ItemIndex := 1;
2534 end;
2535 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2536 begin
2537 Name := 'swMonsters';
2538 AddItem(_lc[I_MENU_YES]);
2539 AddItem(_lc[I_MENU_NO]);
2540 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2541 ItemIndex := 0
2542 else
2543 ItemIndex := 1;
2544 end;
2545 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2546 begin
2547 Name := 'swBotsVS';
2548 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2549 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2550 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2551 ItemIndex := 2;
2552 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2553 ItemIndex := 0;
2554 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2555 ItemIndex := 1;
2556 end;
2557 with AddSwitch(_lc[I_MENU_FLAG_DROP]) do
2558 begin
2559 Name := 'swFlagDrop';
2560 AddItem(_lc[I_MENU_FLAG_THROW]);
2561 AddItem(_lc[I_MENU_YES]);
2562 AddItem(_lc[I_MENU_NO]);
2563 if (gsGameFlags and (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG)) = (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG) then
2564 ItemIndex := 0
2565 else if LongBool(gsGameFlags and GAME_OPTION_ALLOWDROPFLAG) then
2566 ItemIndex := 1
2567 else
2568 ItemIndex := 2;
2569 end;
2570 AddSpace();
2571 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2573 ReAlign();
2574 end;
2575 Menu.DefControl := 'mCustomGameMenu';
2576 g_GUI_AddWindow(Menu);
2578 Menu := TGUIWindow.Create('CampaignMenu');
2579 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_CAMPAIGN]))) do
2580 begin
2581 Name := 'mCampaignMenu';
2583 AddSpace();
2584 AddSpace();
2585 AddSpace();
2586 AddSpace();
2587 AddSpace();
2588 AddSpace();
2590 with AddFileList('', 15, 4) do
2591 begin
2592 Name := 'lsWAD';
2593 OnChange := ProcSelectCampaignWAD;
2595 Sort := True;
2596 Dirs := True;
2597 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2598 SetBase(MegawadDirs);
2599 end;
2601 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2602 begin
2603 Name := 'lbWADName';
2604 FixedLength := 8;
2605 Enabled := False;
2606 end;
2607 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2608 begin
2609 Name := 'lbWADAuthor';
2610 FixedLength := 8;
2611 Enabled := False;
2612 end;
2613 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2614 with AddMemo('', 15, 3) do
2615 begin
2616 Name := 'meWADDescription';
2617 Color := MENU_ITEMSCTRL_COLOR;
2618 end;
2619 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2620 begin
2621 Name := 'swPlayers';
2622 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2623 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2624 end;
2625 AddSpace();
2626 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2628 ReAlign();
2630 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2631 begin
2632 Name := 'mpWADImage';
2633 DefaultRes := 'NOPIC';
2634 X := GetControl('lsWAD').X+4;
2635 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2636 end;
2637 end;
2638 Menu.DefControl := 'mCampaignMenu';
2639 g_GUI_AddWindow(Menu);
2641 Menu := TGUIWindow.Create('SelectMapMenu');
2642 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_SELECT_MAP]))) do
2643 begin
2644 Name := 'mSelectMapMenu';
2645 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2646 begin
2647 Name := 'lsMapWAD';
2648 OnChange := ProcSelectWAD;
2650 Sort := True;
2651 Dirs := True;
2652 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2653 SetBase(MapDirs);
2654 end;
2655 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2656 begin
2657 Name := 'lsMapRes';
2658 Sort := True;
2659 OnChange := ProcSelectMap;
2660 end;
2661 AddSpace();
2662 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2663 begin
2664 Name := 'lbMapName';
2665 FixedLength := 24;
2666 Enabled := False;
2667 end;
2668 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2669 begin
2670 Name := 'lbMapAuthor';
2671 FixedLength := 16;
2672 Enabled := False;
2673 end;
2674 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2675 begin
2676 Name := 'lbMapSize';
2677 FixedLength := 10;
2678 Enabled := False;
2679 end;
2680 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 20, 4) do
2681 begin
2682 Name := 'meMapDescription';
2683 end;
2685 ReAlign();
2687 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2688 begin
2689 Name := 'mpMapPreview';
2690 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2691 Y := GetControl('lsMapWAD').Y;
2692 end;
2693 with TGUILabel(Menu.AddChild(TGUILabel.Create('', False))) do
2694 begin
2695 Name := 'lbMapScale';
2696 FixedLength := 8;
2697 Enabled := False;
2698 Color := MENU_ITEMSCTRL_COLOR;
2699 X := GetControl('lsMapWAD').X +
2700 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2701 2 + MAPPREVIEW_WIDTH*4;
2702 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2703 end;
2704 end;
2705 Menu.OnClose := ProcSetMap;
2706 Menu.DefControl := 'mSelectMapMenu';
2707 g_GUI_AddWindow(Menu);
2709 Menu := TGUIWindow.Create('OptionsMenu');
2710 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_OPTIONS]))) do
2711 begin
2712 Name := 'mmOptionsMenu';
2713 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2714 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2715 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2716 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2717 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2718 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2719 AddSpace();
2720 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2721 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2722 end;
2723 Menu.OnClose := ProcApplyOptions;
2724 Menu.DefControl := 'mmOptionsMenu';
2725 g_GUI_AddWindow(Menu);
2727 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6), @ProcSavedMenuKeyDown);
2728 g_GUI_AddWindow(Menu);
2730 Menu := TGUIWindow.Create('OptionsVideoMenu');
2731 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _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(True, False, _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(True, False, _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(True, False, _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(True, False, _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(True, False, _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(True, False, _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(True, False, _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(True, False, _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(True, False, _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(True, False, _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(True, False, _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(True, False, _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(True, False, _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(True, False, _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(True, False, _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(True, False, _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(True, False, _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), @ProcDefaultMenuKeyDown);
3288 g_GUI_AddWindow(Menu);
3290 Menu := TGUIWindow.Create('AuthorsMenu');
3291 Menu.BackTexture := GameWad + ':/TEXTURES/INTER';
3292 Menu.OnClose := ProcAuthorsClose;
3294 // Çàãîëîâîê:
3295 _y := 16;
3296 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], False))) do
3297 begin
3298 Color := _RGB(255, 0, 0);
3299 X := (gScreenWidth div 2)-(GetWidth() div 2);
3300 Y := _y;
3301 _y := _y+GetHeight();
3302 end;
3303 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), False))) do
3304 begin
3305 Color := _RGB(255, 0, 0);
3306 X := (gScreenWidth div 2)-(GetWidth() div 2);
3307 Y := _y;
3308 _y := _y+GetHeight()+32;
3309 end;
3310 // ×òî äåëàë: Êòî äåëàë
3311 cx := gScreenWidth div 2 - 320 + 64;
3312 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], False))) do
3313 begin
3314 Color := _RGB(255, 0, 0);
3315 X := cx;
3316 Y := _y;
3317 _y := _y+22;
3318 end;
3319 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], False))) do
3320 begin
3321 Color := _RGB(255, 255, 255);
3322 X := cx+32;
3323 Y := _y;
3324 _y := _y+36;
3325 end;
3326 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], False))) do
3327 begin
3328 Color := _RGB(255, 0, 0);
3329 X := cx;
3330 Y := _y;
3331 _y := _y+22;
3332 end;
3333 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], False))) do
3334 begin
3335 Color := _RGB(255, 255, 255);
3336 X := cx+32;
3337 Y := _y;
3338 _y := _y+22;
3339 end;
3340 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], False))) do
3341 begin
3342 Color := _RGB(255, 255, 255);
3343 X := cx+32;
3344 Y := _y;
3345 _y := _y+36;
3346 end;
3347 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], False))) do
3348 begin
3349 Color := _RGB(255, 0, 0);
3350 X := cx;
3351 Y := _y;
3352 _y := _y+22;
3353 end;
3354 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], False))) do
3355 begin
3356 Color := _RGB(255, 255, 255);
3357 X := cx+32;
3358 Y := _y;
3359 _y := _y+36;
3360 end;
3361 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], False))) do
3362 begin
3363 Color := _RGB(255, 0, 0);
3364 X := cx;
3365 Y := _y;
3366 _y := _y+22;
3367 end;
3368 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], False))) do
3369 begin
3370 Color := _RGB(255, 255, 255);
3371 X := cx+32;
3372 Y := _y;
3373 _y := gScreenHeight - 128;
3374 end;
3375 // Çàêëþ÷åíèå:
3376 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], False))) do
3377 begin
3378 Color := _RGB(255, 0, 0);
3379 X := cx;
3380 Y := _y;
3381 _y := _y+16;
3382 end;
3383 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], False))) do
3384 begin
3385 Color := _RGB(255, 255, 255);
3386 X := cx+32;
3387 Y := _y;
3388 _y := _y+GetHeight();
3389 end;
3390 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], False))) do
3391 begin
3392 Color := _RGB(255, 255, 255);
3393 X := cx+32;
3394 Y := _y;
3395 _y := _y+GetHeight();
3396 end;
3397 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], False))) do
3398 begin
3399 Color := _RGB(255, 255, 255);
3400 X := cx+32;
3401 Y := _y;
3402 _y := gScreenHeight - 32;
3403 end;
3404 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], False))) do
3405 begin
3406 Color := _RGB(255, 0, 0);
3407 X := gScreenWidth div 2 - GetWidth() div 2;
3408 Y := _y;
3409 end;
3410 g_GUI_AddWindow(Menu);
3412 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6), @ProcExitMenuKeyDown);
3413 g_GUI_AddWindow(Menu);
3415 Menu := TGUIWindow.Create('GameSingleMenu');
3416 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_MAIN_MENU]))) do
3417 begin
3418 Name := 'mmGameSingleMenu';
3419 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3420 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3421 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3422 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3423 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3424 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3425 end;
3426 Menu.DefControl := 'mmGameSingleMenu';
3427 Menu.MainWindow := True;
3428 Menu.OnClose := ProcGMClose;
3429 Menu.OnShow := ProcGMShow;
3430 g_GUI_AddWindow(Menu);
3432 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6), @ProcEndMenuKeyDown);
3433 g_GUI_AddWindow(Menu);
3435 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6), @ProcRestartMenuKeyDown);
3436 g_GUI_AddWindow(Menu);
3438 Menu := TGUIWindow.Create('GameCustomMenu');
3439 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_MAIN_MENU]))) do
3440 begin
3441 Name := 'mmGameCustomMenu';
3442 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3443 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3444 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3445 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3446 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3447 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3448 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3449 end;
3450 Menu.DefControl := 'mmGameCustomMenu';
3451 Menu.MainWindow := True;
3452 Menu.OnClose := ProcGMClose;
3453 Menu.OnShow := ProcGMShow;
3454 g_GUI_AddWindow(Menu);
3456 Menu := TGUIWindow.Create('GameServerMenu');
3457 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_MAIN_MENU]))) do
3458 begin
3459 Name := 'mmGameServerMenu';
3460 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3461 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3462 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3463 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3464 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3465 end;
3466 Menu.DefControl := 'mmGameServerMenu';
3467 Menu.MainWindow := True;
3468 Menu.OnClose := ProcGMClose;
3469 Menu.OnShow := ProcGMShow;
3470 g_GUI_AddWindow(Menu);
3472 Menu := TGUIWindow.Create('GameClientMenu');
3473 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_MAIN_MENU]))) do
3474 begin
3475 Name := 'mmGameClientMenu';
3476 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3477 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3478 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3479 end;
3480 Menu.DefControl := 'mmGameClientMenu';
3481 Menu.MainWindow := True;
3482 Menu.OnClose := ProcGMClose;
3483 Menu.OnShow := ProcGMShow;
3484 g_GUI_AddWindow(Menu);
3486 Menu := TGUIWindow.Create('ClientPasswordMenu');
3487 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(False, False, _lc[I_MENU_ENTERPASSWORD]))) do
3488 begin
3489 Name := 'mClientPasswordMenu';
3490 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3491 begin
3492 Name := 'edPW';
3493 Width := 12;
3494 MaxLength := 32;
3495 end;
3496 AddSpace;
3498 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3499 ReAlign();
3500 end;
3501 Menu.DefControl := 'mClientPasswordMenu';
3502 g_GUI_AddWindow(Menu);
3504 Menu := TGUIWindow.Create('GameSetGameMenu');
3505 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_SET_GAME]))) do
3506 begin
3507 Name := 'mGameSetGameMenu';
3508 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3509 begin
3510 Name := 'swTeamDamage';
3511 AddItem(_lc[I_MENU_YES]);
3512 AddItem(_lc[I_MENU_NO]);
3513 ItemIndex := 1;
3514 end;
3515 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
3516 begin
3517 Name := 'swTeamHit';
3518 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
3519 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
3520 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
3521 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
3522 ItemIndex := 0
3523 end;
3524 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
3525 begin
3526 Name := 'swDeathmatchKeys';
3527 AddItem(_lc[I_MENU_YES]);
3528 AddItem(_lc[I_MENU_NO]);
3529 ItemIndex := 1;
3530 end;
3531 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3532 begin
3533 Name := 'edTimeLimit';
3534 OnlyDigits := True;
3535 Width := 4;
3536 MaxLength := 5;
3537 end;
3538 with AddEdit(_lc[I_MENU_SCORE_LIMIT]) do
3539 begin
3540 Name := 'edScoreLimit';
3541 OnlyDigits := True;
3542 Width := 4;
3543 MaxLength := 5;
3544 end;
3545 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3546 begin
3547 Name := 'edMaxLives';
3548 OnlyDigits := True;
3549 Width := 4;
3550 MaxLength := 5;
3551 end;
3552 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3553 begin
3554 Name := 'swBotsVS';
3555 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3556 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3557 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3558 ItemIndex := 2;
3559 end;
3560 with AddSwitch(_lc[I_MENU_FLAG_DROP]) do
3561 begin
3562 Name := 'swFlagDrop';
3563 AddItem(_lc[I_MENU_FLAG_THROW]);
3564 AddItem(_lc[I_MENU_YES]);
3565 AddItem(_lc[I_MENU_NO]);
3566 ItemIndex := 2;
3567 end;
3569 ReAlign();
3570 end;
3571 Menu.DefControl := 'mGameSetGameMenu';
3572 Menu.OnClose := ProcApplyGameSet;
3573 g_GUI_AddWindow(Menu);
3575 Menu := TGUIWindow.Create('TeamMenu');
3576 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_CHANGE_PLAYERS]))) do
3577 begin
3578 Name := 'mmTeamMenu';
3579 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3580 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3581 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3582 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3583 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3584 end;
3585 Menu.DefControl := 'mmTeamMenu';
3586 Menu.OnShow := ProcChangePlayers;
3587 g_GUI_AddWindow(Menu);
3588 end;
3590 procedure g_Menu_Show_SaveMenu();
3591 begin
3592 if g_Game_IsTestMap then
3593 Exit;
3594 if gGameSettings.GameType = GT_SINGLE then
3595 g_GUI_ShowWindow('GameSingleMenu')
3596 else
3597 begin
3598 if g_Game_IsClient then
3599 Exit
3600 else
3601 if g_Game_IsNet then
3602 Exit
3603 else
3604 g_GUI_ShowWindow('GameCustomMenu');
3605 end;
3606 g_GUI_ShowWindow('SaveMenu');
3607 g_Sound_PlayEx('MENU_OPEN');
3608 end;
3610 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3611 begin
3612 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3613 if gGameSettings.GameType = GT_SINGLE then
3614 begin
3615 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3616 end
3617 else
3618 begin
3619 if g_Game_IsClient then exit;
3620 if g_Game_IsNet then exit;
3621 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3622 end;
3623 g_GUI_ShowWindow('LoadMenu');
3624 g_Sound_PlayEx('MENU_OPEN');
3625 end;
3627 procedure g_Menu_Show_GameSetGame();
3628 begin
3629 if gGameSettings.GameType = GT_SINGLE then
3630 g_GUI_ShowWindow('GameSingleMenu')
3631 else
3632 begin
3633 if g_Game_IsClient then
3634 Exit
3635 else
3636 if g_Game_IsNet then
3637 g_GUI_ShowWindow('GameServerMenu')
3638 else
3639 g_GUI_ShowWindow('GameCustomMenu');
3640 end;
3641 ReadGameSettings();
3642 g_GUI_ShowWindow('GameSetGameMenu');
3643 g_Sound_PlayEx('MENU_OPEN');
3644 end;
3646 procedure g_Menu_Show_OptionsVideo();
3647 begin
3648 if gGameSettings.GameType = GT_SINGLE then
3649 g_GUI_ShowWindow('GameSingleMenu')
3650 else
3651 begin
3652 if g_Game_IsClient then
3653 g_GUI_ShowWindow('GameClientMenu')
3654 else
3655 if g_Game_IsNet then
3656 g_GUI_ShowWindow('GameServerMenu')
3657 else
3658 g_GUI_ShowWindow('GameCustomMenu');
3659 end;
3660 ReadOptions();
3661 g_GUI_ShowWindow('OptionsMenu');
3662 g_GUI_ShowWindow('OptionsVideoMenu');
3663 g_Sound_PlayEx('MENU_OPEN');
3664 end;
3666 procedure g_Menu_Show_OptionsSound();
3667 begin
3668 if gGameSettings.GameType = GT_SINGLE then
3669 g_GUI_ShowWindow('GameSingleMenu')
3670 else
3671 begin
3672 if g_Game_IsClient then
3673 g_GUI_ShowWindow('GameClientMenu')
3674 else
3675 if g_Game_IsNet then
3676 g_GUI_ShowWindow('GameServerMenu')
3677 else
3678 g_GUI_ShowWindow('GameCustomMenu');
3679 end;
3680 ReadOptions();
3681 g_GUI_ShowWindow('OptionsMenu');
3682 g_GUI_ShowWindow('OptionsSoundMenu');
3683 g_Sound_PlayEx('MENU_OPEN');
3684 end;
3686 procedure g_Menu_Show_EndGameMenu();
3687 begin
3688 g_GUI_ShowWindow('EndGameMenu');
3689 g_Sound_PlayEx('MENU_OPEN');
3690 end;
3692 procedure g_Menu_Show_QuitGameMenu();
3693 begin
3694 g_GUI_ShowWindow('ExitMenu');
3695 g_Sound_PlayEx('MENU_OPEN');
3696 end;
3698 procedure g_Menu_Init();
3699 begin
3700 MenuLoadData();
3701 CreateAllMenus();
3702 end;
3704 procedure g_Menu_Free();
3705 begin
3706 MenuFreeData();
3707 end;
3709 procedure g_Menu_Reset();
3710 var
3711 ex: Boolean;
3712 begin
3713 g_GUI_SaveMenuPos();
3714 ex := g_GUI_Destroy();
3716 if ex then
3717 begin
3718 e_WriteLog('Recreating menu...', TMsgType.Notify);
3720 CreateAllMenus();
3722 if gDebugMode then
3723 g_Game_SetDebugMode();
3725 g_GUI_LoadMenuPos();
3726 end;
3727 end;
3729 end.