DEADSOFTWARE

9749ad077c3ac0e4e9d8c75e8d6f2a71c79cd712
[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}
898 {$IFDEF ENABLE_SYSTEM}
899 sys_Repaint;
900 {$ENDIF}
902 slReturnPressed := True;
903 if g_Net_Slist_Fetch(slCurrent) then
904 begin
905 if slCurrent = nil then
906 slWaitStr := _lc[I_NET_SLIST_NOSERVERS];
907 end
908 else
909 slWaitStr := _lc[I_NET_SLIST_ERROR];
910 g_Serverlist_GenerateTable(slCurrent, slTable);
911 end;
913 procedure ProcStartCampaign();
914 var
915 WAD: String;
916 TwoPlayers: Boolean;
917 n: Byte;
918 begin
919 with TGUIMenu(g_ActiveWindow.GetControl('mCampaignMenu')) do
920 begin
921 WAD := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
922 TwoPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex = 1;
923 end;
924 WAD := e_FindWadRel(MegawadDirs, WAD);
926 if TwoPlayers then
927 n := 2
928 else
929 n := 1;
930 g_Game_StartSingle(WAD + ':\MAP01', TwoPlayers, n);
931 end;
933 procedure ProcSelectMap(Sender: TGUIControl);
934 var
935 win: TGUIWindow;
936 a: TMapInfo;
937 wad, map, res: String;
938 begin
939 win := g_GUI_GetWindow('SelectMapMenu');
940 with TGUIMenu(win.GetControl('mSelectMapMenu')) do
941 begin
942 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
943 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
945 if (wad = '') or (map = '') then
946 begin // Ýòî íå êàðòà
947 TGUILabel(GetControl('lbMapName')).Text := '';
948 TGUILabel(GetControl('lbMapAuthor')).Text := '';
949 TGUILabel(GetControl('lbMapSize')).Text := '';
950 TGUIMemo(GetControl('meMapDescription')).SetText('');
951 TGUIMapPreview(win.GetControl('mpMapPreview')).ClearMap();
952 TGUILabel(win.GetControl('lbMapScale')).Text := '';
953 end
954 else // Ýòî êàðòà
955 begin
956 res := wad+':\'+map;
958 a := g_Map_GetMapInfo(res);
960 TGUILabel(GetControl('lbMapName')).Text := a.Name;
961 TGUILabel(GetControl('lbMapAuthor')).Text := a.Author;
962 TGUILabel(GetControl('lbMapSize')).Text := Format('%dx%d', [a.Width, a.Height]);
963 TGUIMemo(GetControl('meMapDescription')).SetText(a.Description);
964 TGUIMapPreview(win.GetControl('mpMapPreview')).SetMap(res);
965 TGUILabel(win.GetControl('lbMapScale')).Text :=
966 TGUIMapPreview(win.GetControl('mpMapPreview')).GetScaleStr;
967 end;
968 end;
969 end;
971 procedure ProcSelectWAD(Sender: TGUIControl);
972 var
973 wad: String;
974 list: SSArray;
975 begin
976 with TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu')) do
977 begin
978 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
980 with TGUIListBox(GetControl('lsMapRes')) do
981 begin
982 Clear();
984 if wad <> '' then
985 begin
986 list := g_Map_GetMapsList(wad);
988 if list <> nil then
989 begin
990 Items := list;
991 ItemIndex := 0;
992 end
993 end;
994 end;
995 end;
997 ProcSelectMap(nil);
998 end;
1000 procedure ProcSelectCampaignWAD(Sender: TGUIControl);
1001 var
1002 win: TGUIWindow;
1003 a: TMegaWADInfo;
1004 wad, fn: String;
1005 begin
1006 win := g_GUI_GetWindow('CampaignMenu');
1007 with TGUIMenu(win.GetControl('mCampaignMenu')) do
1008 begin
1009 wad := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
1011 if wad = '' then
1012 begin
1013 TGUILabel(GetControl('lbWADName')).Text := '';
1014 TGUILabel(GetControl('lbWADAuthor')).Text := '';
1015 TGUIMemo(GetControl('meWADDescription')).SetText('');
1016 end;
1018 a := g_Game_GetMegaWADInfo(wad);
1020 TGUILabel(GetControl('lbWADName')).Text := a.Name;
1021 TGUILabel(GetControl('lbWADAuthor')).Text := a.Author;
1022 TGUIMemo(GetControl('meWADDescription')).SetText(a.Description);
1024 TGUIImage(win.GetControl('mpWADImage')).ClearImage();
1026 if a.pic <> '' then
1027 begin
1028 fn := g_ExtractWadName(a.pic);
1029 if fn = '' then
1030 TGUIImage(win.GetControl('mpWADImage')).SetImage(wad+a.pic)
1031 else
1032 TGUIImage(win.GetControl('mpWADImage')).SetImage(a.pic);
1033 end;
1034 end;
1035 end;
1037 procedure ProcChangeColor(Sender: TGUIControl);
1038 var
1039 window: TGUIWindow;
1040 begin
1041 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
1042 with TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')) do
1043 TGUIModelView(window.GetControl('mvP1Model')).SetColor(
1044 Min(TGUIScroll(GetControl('scP1Red')).Value*16, 255),
1045 Min(TGUIScroll(GetControl('scP1Green')).Value*16, 255),
1046 Min(TGUIScroll(GetControl('scP1Blue')).Value*16, 255));
1048 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
1049 with TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')) do
1050 TGUIModelView(window.GetControl('mvP2Model')).SetColor(
1051 Min(TGUIScroll(GetControl('scP2Red')).Value*16, 255),
1052 Min(TGUIScroll(GetControl('scP2Green')).Value*16, 255),
1053 Min(TGUIScroll(GetControl('scP2Blue')).Value*16, 255));
1054 end;
1056 procedure ProcSelectModel(Sender: TGUIControl);
1057 var
1058 a: string;
1059 window: TGUIWindow;
1060 begin
1061 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
1062 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')).GetControl('lsP1Model')).SelectedItem;
1063 if a <> '' then TGUIModelView(window.GetControl('mvP1Model')).SetModel(a);
1065 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
1066 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')).GetControl('lsP2Model')).SelectedItem;
1067 if a <> '' then TGUIModelView(window.GetControl('mvP2Model')).SetModel(a);
1069 ProcChangeColor(nil);
1070 end;
1072 procedure MenuLoadData();
1073 begin
1074 e_WriteLog('Loading menu data...', TMsgType.Notify);
1076 g_Sound_CreateWADEx('MENU_SELECT', GameWAD+':SOUNDS\MENUSELECT');
1077 g_Sound_CreateWADEx('MENU_OPEN', GameWAD+':SOUNDS\MENUOPEN');
1078 g_Sound_CreateWADEx('MENU_CLOSE', GameWAD+':SOUNDS\MENUCLOSE');
1079 g_Sound_CreateWADEx('MENU_CHANGE', GameWAD+':SOUNDS\MENUCHANGE');
1080 g_Sound_CreateWADEx('SCROLL_ADD', GameWAD+':SOUNDS\SCROLLADD');
1081 g_Sound_CreateWADEx('SCROLL_SUB', GameWAD+':SOUNDS\SCROLLSUB');
1082 g_Sound_CreateWADEx('SOUND_PLAYER_FALL', GameWAD+':SOUNDS\FALL');
1083 end;
1085 procedure MenuFreeData();
1086 begin
1087 g_Sound_Delete('MENU_SELECT');
1088 g_Sound_Delete('MENU_OPEN');
1089 g_Sound_Delete('MENU_CLOSE');
1090 g_Sound_Delete('MENU_CHANGE');
1091 g_Sound_Delete('SCROLL_ADD');
1092 g_Sound_Delete('SCROLL_SUB');
1093 g_Sound_Delete('SOUND_PLAYER_FALL');
1094 end;
1096 procedure ProcAuthorsMenu();
1097 begin
1098 gMusic.SetByName('MUSIC_INTERMUS');
1099 gMusic.Play();
1100 end;
1102 procedure ProcExitMenuKeyDown (yes: Boolean);
1103 var
1104 s: ShortString;
1105 snd: TPlayableSound;
1106 res: Boolean;
1107 begin
1108 if yes then
1109 begin
1110 g_Game_StopAllSounds(True);
1111 case (Random(18)) of
1112 0: s := 'SOUND_MONSTER_PAIN';
1113 1: s := 'SOUND_MONSTER_DIE_3';
1114 2: s := 'SOUND_MONSTER_SLOP';
1115 3: s := 'SOUND_MONSTER_DEMON_DIE';
1116 4: s := 'SOUND_MONSTER_IMP_DIE_2';
1117 5: s := 'SOUND_MONSTER_MAN_DIE';
1118 6: s := 'SOUND_MONSTER_BSP_DIE';
1119 7: s := 'SOUND_MONSTER_VILE_DIE';
1120 8: s := 'SOUND_MONSTER_SKEL_DIE';
1121 9: s := 'SOUND_MONSTER_MANCUB_ALERT';
1122 10: s := 'SOUND_MONSTER_PAIN_PAIN';
1123 11: s := 'SOUND_MONSTER_BARON_DIE';
1124 12: s := 'SOUND_MONSTER_CACO_DIE';
1125 13: s := 'SOUND_MONSTER_CYBER_DIE';
1126 14: s := 'SOUND_MONSTER_KNIGHT_ALERT';
1127 15: s := 'SOUND_MONSTER_SPIDER_ALERT';
1128 else s := 'SOUND_PLAYER_FALL';
1129 end;
1130 snd := TPlayableSound.Create();
1131 res := snd.SetByName(s);
1132 if not res then res := snd.SetByName('SOUND_PLAYER_FALL');
1133 if res then
1134 begin
1135 snd.Play(True);
1136 while snd.IsPlaying() do begin end;
1137 end;
1138 g_Game_Quit();
1139 exit;
1140 end;
1141 g_GUI_HideWindow();
1142 end;
1144 procedure ProcLoadMenu();
1145 var
1146 a: Integer;
1147 valid: Boolean;
1148 begin
1149 for a := 1 to 8 do
1150 begin
1151 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Text := g_GetSaveName(a, valid);
1152 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := not valid;
1153 //TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a)).Enabled := valid;
1154 end;
1155 end;
1157 procedure ProcSaveMenu();
1158 var
1159 a: Integer;
1160 valid: Boolean;
1161 name: AnsiString;
1162 begin
1163 for a := 1 to 8 do
1164 begin
1165 name := g_GetSaveName(a, valid);
1166 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Text := name;
1167 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := (name <> '') and (not valid);
1168 end;
1169 end;
1171 procedure ProcSaveGame(Sender: TGUIControl);
1172 var
1173 a: Integer;
1174 begin
1175 if g_Game_IsNet then Exit;
1176 if g_Game_IsTestMap then Exit;
1177 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1178 g_Game_PauseAllSounds(True);
1179 g_SaveGame(a, TGUIEdit(Sender).Text);
1181 g_ActiveWindow := nil;
1182 g_Game_Pause(False);
1183 end;
1185 procedure ProcLoadGame(Sender: TGUIControl);
1186 var
1187 a: Integer;
1188 begin
1189 if g_Game_IsNet then Exit;
1190 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1191 if g_LoadGame(a) then
1192 begin
1193 g_Game_PauseAllSounds(False)
1194 end
1195 else // Íå çàãðóçèëîñü - âîçâðàò â ìåíþ
1196 begin
1197 g_Console_Add(_lc[I_MSG_BAD_SAVE_VERSION], true);
1198 g_GUI_GetWindow('LoadMenu').SetActive(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu'));
1199 //g_ActiveWindow := nil;
1200 end;
1201 end;
1203 procedure ProcSinglePlayer (n: Integer);
1204 var wad, map: AnsiString;
1205 begin
1206 assert(n >= 1);
1207 wad := g_ExtractWadName(gDefaultMegawadStart);
1208 map := g_ExtractFilePathName(gDefaultMegawadStart);
1209 if e_FindResource(AllMapDirs, wad) then
1210 begin
1211 wad := ExpandFileName(wad);
1212 g_Game_StartSingle(wad + ':\' + map, n > 1, n)
1213 end
1214 end;
1216 procedure ProcSingle1Player;
1217 begin
1218 ProcSinglePlayer(1)
1219 end;
1221 procedure ProcSingle2Players;
1222 begin
1223 ProcSinglePlayer(2)
1224 end;
1226 procedure ProcSelectMapMenu();
1227 var
1228 menu: TGUIMenu;
1229 wad_lb: TGUIFileListBox;
1230 map_lb: TGUIListBox;
1231 map: String;
1232 begin
1233 menu := TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1234 wad_lb := TGUIFileListBox(menu.GetControl('lsMapWAD'));
1235 map_lb := TGUIListBox(menu.GetControl('lsMapRes'));
1237 if wad_lb.SelectedItem() <> '' then
1238 map := map_lb.SelectedItem()
1239 else
1240 map := '';
1242 wad_lb.UpdateFileList();
1243 map_lb.Clear();
1245 if wad_lb.SelectedItem() <> '' then
1246 begin
1247 ProcSelectWAD(nil);
1248 map_lb.SelectItem(map);
1250 if map_lb.SelectedItem() <> '' then
1251 ProcSelectMap(nil);
1252 end;
1254 g_GUI_ShowWindow('SelectMapMenu');
1255 end;
1257 procedure ProcSelectCampaignMenu();
1258 var
1259 menu: TGUIMenu;
1260 wad_lb: TGUIFileListBox;
1261 begin
1262 menu := TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1263 wad_lb := TGUIFileListBox(menu.GetControl('lsWAD'));
1265 wad_lb.UpdateFileList();
1267 if wad_lb.SelectedItem() <> '' then
1268 ProcSelectCampaignWAD(nil);
1269 end;
1271 procedure ProcSetMap();
1272 var
1273 wad, map, res: String;
1274 begin
1275 with TGUIMenu(g_ActiveWindow.GetControl('mSelectMapMenu')) do
1276 begin
1277 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
1278 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1279 end;
1281 if (wad = '') or (map = '') then
1282 Exit;
1284 wad := e_FindWadRel(MapDirs, WAD);
1286 res := wad+':\'+map;
1288 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
1289 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res;
1290 end;
1292 procedure ProcChangeSoundSettings(Sender: TGUIControl);
1293 var
1294 menu: TGUIMenu;
1295 begin
1296 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1298 g_Sound_SetupAllVolumes(
1299 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
1300 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
1301 );
1302 end;
1304 procedure ProcChangeGameSettings(Sender: TGUIControl);
1305 var
1306 menu: TGUIMenu;
1307 begin
1308 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
1309 if TGUIScroll(menu.GetControl('scScaleFactor')).Value <> TempScale then
1310 begin
1311 TempScale := TGUIScroll(menu.GetControl('scScaleFactor')).Value;
1312 g_dbg_scale := TempScale + 1;
1313 end;
1314 end;
1316 procedure ProcChangeTouchSettings(Sender: TGUIControl);
1317 var
1318 menu: TGUIMenu;
1319 begin
1320 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
1321 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
1322 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
1323 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
1324 end;
1326 procedure ProcOptionsPlayersMIMenu();
1327 var
1328 s, a: string;
1329 i: Integer;
1330 begin
1331 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1333 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+s+'Menu')).GetControl('ls'+s+'Model')).SelectedItem;
1335 if a = '' then Exit;
1337 i := g_PlayerModel_GetIndex(a);
1338 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1339 begin
1340 TGUILabel(GetControl('lbName')).Text := PlayerModelsArray[i].Name;
1341 TGUILabel(GetControl('lbAuthor')).Text := PlayerModelsArray[i].Author;
1342 TGUIMemo(GetControl('meComment')).SetText(PlayerModelsArray[i].Description);
1344 if PlayerModelsArray[i].HaveWeapon then
1345 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1346 else
1347 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1348 end;
1350 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1351 end;
1353 procedure ProcOptionsPlayerP1WeaponMenu();
1354 var
1355 a: string;
1356 begin
1357 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+'P1'+'Menu')).GetControl('ls'+'P1'+'Model')).SelectedItem;
1358 if a = '' then Exit;
1359 g_GUI_ShowWindow('OptionsPlayersP1WeaponMenu');
1360 end;
1362 procedure ProcOptionsPlayerP1WeaponPreferencesMenu();
1363 begin
1364 g_GUI_ShowWindow('OptionsPreferencesP1WeaponMenu');
1365 end;
1367 procedure ProcOptionsPlayerP2WeaponMenu();
1368 var
1369 a: string;
1370 begin
1371 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+'P2'+'Menu')).GetControl('ls'+'P2'+'Model')).SelectedItem;
1372 if a = '' then Exit;
1373 g_GUI_ShowWindow('OptionsPlayersP2WeaponMenu');
1374 end;
1376 procedure ProcOptionsPlayerP2WeaponPreferencesMenu();
1377 begin
1378 g_GUI_ShowWindow('OptionsPreferencesP2WeaponMenu');
1379 end;
1381 procedure ProcOptionsPlayersAnim();
1382 var
1383 s: String;
1384 begin
1385 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1386 s := 'P1'
1387 else
1388 s := 'P2';
1390 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1391 begin
1392 NextAnim();
1393 Model.AnimState.Loop := True;
1394 end;
1395 end;
1397 procedure ProcOptionsPlayersWeap();
1398 var
1399 s: String;
1400 begin
1401 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1402 s := 'P1'
1403 else
1404 s := 'P2';
1406 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1407 NextWeapon();
1408 end;
1410 procedure ProcOptionsPlayersRot();
1411 var
1412 s: string;
1413 begin
1414 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1415 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1416 begin
1417 if Direction = TDirection.D_LEFT then Direction := TDirection.D_RIGHT else Direction := TDirection.D_LEFT;
1418 end;
1419 end;
1421 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1422 begin
1423 if yes then
1424 begin
1425 g_Options_SetDefault();
1426 ReadOptions();
1427 end;
1428 g_GUI_HideWindow();
1429 end;
1431 procedure ProcSavedMenuKeyDown (yes: Boolean);
1432 begin
1433 if yes then ReadOptions();
1434 g_GUI_HideWindow();
1435 end;
1437 procedure ProcAuthorsClose();
1438 begin
1439 gMusic.SetByName('MUSIC_MENU');
1440 gMusic.Play();
1441 gState := STATE_MENU;
1442 end;
1444 procedure ProcGMClose();
1445 begin
1446 g_Game_InGameMenu(False);
1447 end;
1449 procedure ProcGMShow();
1450 var
1451 Enabled: Boolean;
1452 begin
1453 Enabled := True;
1454 if (gGameSettings.GameType = GT_SINGLE) and
1455 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1456 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1457 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1458 if not gGameOn then
1459 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1460 if g_Game_IsTestMap then
1461 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1462 TGUIMainMenu(g_ActiveWindow.GetControl(
1463 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1464 end;
1466 procedure ProcChangePlayers();
1467 var
1468 TeamGame, Spectator, AddTwo: Boolean;
1469 P1Team{, P2Team}: Byte;
1470 bP2: TGUITextButton;
1471 begin
1472 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1473 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1474 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1475 P1Team := TEAM_NONE;
1476 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1477 // TODO
1478 //P2Team := TEAM_NONE;
1479 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1481 TGUIMainMenu(g_ActiveWindow.GetControl(
1482 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1483 TGUIMainMenu(g_ActiveWindow.GetControl(
1484 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1485 TGUIMainMenu(g_ActiveWindow.GetControl(
1486 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1488 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1489 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1490 bP2.Enabled := AddTwo and not Spectator;
1491 if bP2.Enabled then
1492 bP2.Color := MAINMENU_ITEMS_COLOR
1493 else
1494 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1495 if gPlayer2 = nil then
1496 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1497 else
1498 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1500 TGUIMainMenu(g_ActiveWindow.GetControl(
1501 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1502 end;
1504 procedure ProcJoinRed();
1505 begin
1506 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1507 Exit;
1508 if g_Game_IsServer then
1509 begin
1510 if gPlayer1 = nil then
1511 g_Game_AddPlayer(TEAM_RED)
1512 else
1513 begin
1514 if gPlayer1.Team <> TEAM_RED then
1515 begin
1516 gPlayer1.SwitchTeam;
1517 gPlayer1Settings.Team := gPlayer1.Team;
1518 end;
1520 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1521 end;
1522 end
1523 else
1524 begin
1525 gPlayer1Settings.Team := TEAM_RED;
1526 MC_SEND_PlayerSettings;
1527 if gPlayer1 = nil then
1528 g_Game_AddPlayer(TEAM_RED);
1529 end;
1530 g_ActiveWindow := nil;
1531 g_Game_Pause(False);
1532 end;
1534 procedure ProcJoinBlue();
1535 begin
1536 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1537 Exit;
1538 if g_Game_IsServer then
1539 begin
1540 if gPlayer1 = nil then
1541 g_Game_AddPlayer(TEAM_BLUE)
1542 else
1543 begin
1544 if gPlayer1.Team <> TEAM_BLUE then
1545 begin
1546 gPlayer1.SwitchTeam;
1547 gPlayer1Settings.Team := gPlayer1.Team;
1548 end;
1550 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1551 end;
1552 end
1553 else
1554 begin
1555 gPlayer1Settings.Team := TEAM_BLUE;
1556 MC_SEND_PlayerSettings;
1557 if gPlayer1 = nil then
1558 g_Game_AddPlayer(TEAM_BLUE);
1559 end;
1560 g_ActiveWindow := nil;
1561 g_Game_Pause(False);
1562 end;
1564 procedure ProcJoinGame();
1565 begin
1566 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1567 Exit;
1568 if gPlayer1 = nil then
1569 g_Game_AddPlayer();
1570 g_ActiveWindow := nil;
1571 g_Game_Pause(False);
1572 end;
1574 procedure ProcSwitchP2();
1575 begin
1576 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1577 Exit;
1578 if gPlayer1 = nil then
1579 Exit;
1580 if gPlayer2 = nil then
1581 g_Game_AddPlayer()
1582 else
1583 g_Game_RemovePlayer();
1584 g_ActiveWindow := nil;
1585 g_Game_Pause(False);
1586 end;
1588 procedure ProcSpectate();
1589 begin
1590 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1591 Exit;
1592 g_Game_Spectate();
1593 g_ActiveWindow := nil;
1594 g_Game_Pause(False);
1595 end;
1597 procedure ProcRestartMenuKeyDown (yes: Boolean);
1598 begin
1599 if yes then g_Game_Restart() else g_GUI_HideWindow;
1600 end;
1602 procedure ProcEndMenuKeyDown (yes: Boolean);
1603 begin
1604 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1605 end;
1607 procedure ProcSetRussianLanguage;
1608 begin
1609 if gLanguage <> LANGUAGE_RUSSIAN then
1610 begin
1611 gLanguage := LANGUAGE_RUSSIAN;
1612 gLanguageChange := True;
1613 gAskLanguage := False;
1614 ProcApplyOptions();
1615 end;
1616 end;
1618 procedure ProcSetEnglishLanguage;
1619 begin
1620 if gLanguage <> LANGUAGE_ENGLISH then
1621 begin
1622 gLanguage := LANGUAGE_ENGLISH;
1623 gLanguageChange := True;
1624 gAskLanguage := False;
1625 ProcApplyOptions();
1626 end;
1627 end;
1629 procedure ReadGameSettings();
1630 var
1631 menu: TGUIMenu;
1632 begin
1633 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1635 with gGameSettings do
1636 begin
1637 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1638 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1639 ItemIndex := 0
1640 else
1641 ItemIndex := 1;
1642 with TGUISwitch(menu.GetControl('swTeamHit')) do
1643 if (Options and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
1644 ItemIndex := 0
1645 else if LongBool(Options and GAME_OPTION_TEAMHITTRACE) then
1646 ItemIndex := 1
1647 else if LongBool(Options and GAME_OPTION_TEAMHITPROJECTILE) then
1648 ItemIndex := 2
1649 else
1650 ItemIndex := 3;
1651 with TGUISwitch(menu.GetControl('swDeathmatchKeys')) do
1652 if LongBool(Options and GAME_OPTION_DMKEYS) then
1653 ItemIndex := 0
1654 else
1655 ItemIndex := 1;
1656 with TGUISwitch(menu.GetControl('swFlagDrop')) do
1657 if LongBool(Options and GAME_OPTION_ALLOWDROPFLAG) and LongBool(Options and GAME_OPTION_THROWFLAG) then
1658 ItemIndex := 0
1659 else if LongBool(Options and GAME_OPTION_ALLOWDROPFLAG) then
1660 ItemIndex := 1
1661 else
1662 ItemIndex := 2;
1664 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1665 TGUIEdit(menu.GetControl('edScoreLimit')).Text := IntToStr(ScoreLimit);
1666 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1668 with TGUISwitch(menu.GetControl('swBotsVS')) do
1669 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1670 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1671 ItemIndex := 2
1672 else
1673 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1674 ItemIndex := 1
1675 else
1676 ItemIndex := 0;
1678 if GameType in [GT_CUSTOM, GT_SERVER] then
1679 begin
1680 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1681 TGUISwitch(menu.GetControl('swTeamHit')).Enabled := True;
1682 if (GameMode in [GM_DM, GM_TDM, GM_CTF]) then
1683 begin
1684 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := True;
1685 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_ITEMSTEXT_COLOR;
1686 end
1687 else
1688 begin
1689 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1690 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1691 end;
1692 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1693 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1694 TGUIEdit(menu.GetControl('edScoreLimit')).Enabled := True;
1695 TGUILabel(menu.GetControlsText('edScoreLimit')).Color := MENU_ITEMSTEXT_COLOR;
1696 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1697 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1698 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1699 TGUISwitch(menu.GetControl('swFlagDrop')).Enabled := True;
1700 end
1701 else
1702 begin
1703 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1704 TGUISwitch(menu.GetControl('swTeamHit')).Enabled := True;
1705 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1706 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1707 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1708 begin
1709 Enabled := False;
1710 Text := '';
1711 end;
1712 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1713 with TGUIEdit(menu.GetControl('edScoreLimit')) do
1714 begin
1715 Enabled := False;
1716 Text := '';
1717 end;
1718 TGUILabel(menu.GetControlsText('edScoreLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1719 with TGUIEdit(menu.GetControl('edMaxLives')) do
1720 begin
1721 Enabled := False;
1722 Text := '';
1723 end;
1724 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1725 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1726 TGUISwitch(menu.GetControl('swFlagDrop')).Enabled := False;
1727 end;
1728 end;
1729 end;
1731 procedure ProcApplyGameSet();
1732 var
1733 menu: TGUIMenu;
1734 a, b, n: Integer;
1735 stat: TPlayerStatArray;
1736 begin
1737 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1739 if not g_Game_IsServer then Exit;
1741 with gGameSettings do
1742 begin
1743 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1744 begin
1745 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1746 Options := Options or GAME_OPTION_TEAMDAMAGE
1747 else
1748 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1749 end;
1751 if TGUISwitch(menu.GetControl('swTeamHit')).Enabled then
1752 begin
1753 Options := Options and not (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE);
1754 case TGUISwitch(menu.GetControl('swTeamHit')).ItemIndex of
1755 1: Options := Options or GAME_OPTION_TEAMHITTRACE;
1756 2: Options := Options or GAME_OPTION_TEAMHITPROJECTILE;
1757 0: Options := Options or GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE;
1758 end;
1759 end;
1761 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled then
1762 begin
1763 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).ItemIndex = 0 then
1764 Options := Options or GAME_OPTION_DMKEYS
1765 else
1766 Options := Options and (not GAME_OPTION_DMKEYS);
1767 end;
1769 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1770 begin
1771 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1773 if n = 0 then
1774 TimeLimit := 0
1775 else
1776 begin
1777 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1779 TimeLimit := Max(n, b);
1780 end;
1781 end;
1783 if TGUIEdit(menu.GetControl('edScoreLimit')).Enabled then
1784 begin
1785 n := StrToIntDef(TGUIEdit(menu.GetControl('edScoreLimit')).Text, ScoreLimit);
1787 if n = 0 then
1788 ScoreLimit := 0
1789 else
1790 begin
1791 b := 0;
1792 if GameMode = GM_DM then
1793 begin // DM
1794 stat := g_Player_GetStats();
1795 if stat <> nil then
1796 for a := 0 to High(stat) do
1797 if stat[a].Frags > b then
1798 b := stat[a].Frags;
1799 end
1800 else // CTF
1801 b := Max(gTeamStat[TEAM_RED].Score, gTeamStat[TEAM_BLUE].Score);
1803 ScoreLimit := Max(n, b);
1804 end;
1805 end;
1807 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1808 begin
1809 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, MaxLives);
1810 if n < 0 then n := 0;
1811 if n > 255 then n := 255;
1812 if n = 0 then
1813 MaxLives := 0
1814 else
1815 begin
1816 b := 0;
1817 stat := g_Player_GetStats();
1818 if stat <> nil then
1819 for a := 0 to High(stat) do
1820 if stat[a].Lives > b then
1821 b := stat[a].Lives;
1823 MaxLives := Max(n, b);
1824 end;
1825 end;
1827 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1828 begin
1829 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1830 1:
1831 begin
1832 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1833 Options := Options or GAME_OPTION_BOTVSMONSTER;
1834 end;
1835 2:
1836 begin
1837 Options := Options or GAME_OPTION_BOTVSPLAYER;
1838 Options := Options or GAME_OPTION_BOTVSMONSTER;
1839 end;
1840 else
1841 begin
1842 Options := Options or GAME_OPTION_BOTVSPLAYER;
1843 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1844 end;
1845 end;
1846 end;
1848 if TGUISwitch(menu.GetControl('swFlagDrop')).Enabled then
1849 begin
1850 case TGUISwitch(menu.GetControl('swFlagDrop')).ItemIndex of
1851 0: Options := Options or GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG;
1852 1: Options := Options or GAME_OPTION_ALLOWDROPFLAG;
1853 else Options := Options and not (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG);
1854 end;
1855 end;
1857 // don't forget to latch this shit
1858 gsGameFlags := Options;
1859 gsMaxLives := MaxLives;
1860 gsScoreLimit := ScoreLimit;
1861 gsTimeLimit := TimeLimit;
1862 end;
1864 if g_Game_IsNet then MH_SEND_GameSettings;
1865 end;
1867 procedure ProcVideoOptionsRes();
1868 var
1869 menu: TGUIMenu;
1870 list: SSArray;
1871 begin
1872 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1874 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1875 IntToStr(gWinSizeX) +
1876 ' x ' + IntToStr(gWinSizeY) +
1877 ', ' + IntToStr(gBPP) + ' bpp';
1879 with TGUIListBox(menu.GetControl('lsResolution')) do
1880 begin
1881 {$IFDEF ENABLE_SYSTEM}
1882 list := sys_GetDisplayModes(gBPP);
1883 {$ELSE}
1884 list := nil;
1885 {$ENDIF}
1886 if list <> nil then
1887 begin
1888 Items := list;
1889 ItemIndex := Length(list)
1890 end
1891 else
1892 begin
1893 Clear
1894 end
1895 end;
1897 with TGUISwitch(menu.GetControl('swFullScreen')) do
1898 if gFullscreen then
1899 ItemIndex := 0
1900 else
1901 ItemIndex := 1;
1903 TempResScale := Round(r_pixel_scale - 1);
1904 with TGUISwitch(menu.GetControl('swResFactor')) do
1905 ItemIndex := Min(TempResScale, gRC_Width div 640 - 1);
1906 end;
1908 procedure ProcApplyVideoOptions();
1909 var
1910 menu: TGUIMenu;
1911 Fullscreen: Boolean;
1912 SWidth, SHeight: Integer;
1913 ScaleChanged: Boolean;
1914 str: String;
1915 begin
1916 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1918 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1919 if str <> '' then
1920 SScanf(str, '%dx%d', [@SWidth, @SHeight])
1921 else
1922 begin
1923 SWidth := gWinSizeX;
1924 SHeight := gWinSizeY;
1925 TempResScale := Min(TempResScale, SWidth div 640 - 1);
1926 end;
1928 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1930 ScaleChanged := False;
1931 if TGUISwitch(menu.GetControl('swResFactor')).ItemIndex <> TempResScale then
1932 begin
1933 TempResScale := Min(TGUISwitch(menu.GetControl('swResFactor')).ItemIndex, SWidth div 640 - 1);
1934 r_pixel_scale := TempResScale + 1;
1935 ScaleChanged := True;
1936 end;
1938 if (SWidth <> gWinSizeX) or
1939 (SHeight <> gWinSizeY) or
1940 (Fullscreen <> gFullscreen) or
1941 ScaleChanged then
1942 begin
1943 gResolutionChange := True;
1944 gRC_Width := SWidth;
1945 gRC_Height := SHeight;
1946 gRC_FullScreen := Fullscreen;
1947 gRC_Maximized := gWinMaximized;
1948 end;
1950 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1951 ProcApplyOptions();
1952 end;
1954 procedure ProcSetFirstRussianLanguage;
1955 begin
1956 gLanguage := LANGUAGE_RUSSIAN;
1957 gLanguageChange := True;
1958 gAskLanguage := False;
1959 end;
1961 procedure ProcSetFirstEnglishLanguage;
1962 begin
1963 gLanguage := LANGUAGE_ENGLISH;
1964 gLanguageChange := True;
1965 gAskLanguage := False;
1966 end;
1968 procedure ProcRecallAddress();
1969 begin
1970 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1971 begin
1972 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1973 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1974 end;
1975 end;
1977 procedure CreateFirstLanguageMenu();
1978 var
1979 Menu: TGUIWindow;
1980 begin
1981 Menu := TGUIWindow.Create('FirstLanguageMenu');
1983 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, ' '))) do // space to prevent show logo
1984 begin
1985 Name := 'mmFirstLanguageMenu';
1986 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
1987 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
1988 end;
1990 Menu.DefControl := 'mmFirstLanguageMenu';
1991 Menu.MainWindow := True;
1992 g_GUI_AddWindow(Menu);
1993 end;
1995 procedure g_Menu_AskLanguage();
1996 begin
1997 CreateFirstLanguageMenu();
1998 g_GUI_ShowWindow('FirstLanguageMenu');
1999 end;
2001 procedure CreatePlayerOptionsMenu(s: String);
2002 var
2003 Menu: TGUIWindow;
2004 a: String;
2005 begin
2006 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
2007 if s = 'P1' then
2008 a := _lc[I_MENU_PLAYER_1]
2009 else
2010 a := _lc[I_MENU_PLAYER_2];
2011 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, a))) do
2012 begin
2013 Name := 'mOptionsPlayers'+s+'Menu';
2014 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
2015 begin
2016 Name := 'ed'+s+'Name';
2017 MaxLength := 12;
2018 Width := 12;
2019 end;
2020 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
2021 begin
2022 Name := 'sw'+s+'Team';
2023 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
2024 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
2025 end ;
2026 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
2027 begin
2028 Name := 'ls'+s+'Model';
2029 Sort := True;
2030 Items := g_PlayerModel_GetNames();
2031 OnChange := ProcSelectModel;
2032 end;
2033 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
2034 begin
2035 Name := 'sc'+s+'Red';
2036 Max := 16;
2037 OnChange := ProcChangeColor;
2038 end;
2039 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
2040 begin
2041 Name := 'sc'+s+'Green';
2042 Max := 16;
2043 OnChange := ProcChangeColor;
2044 end;
2045 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
2046 begin
2047 Name := 'sc'+s+'Blue';
2048 Max := 16;
2049 OnChange := ProcChangeColor;
2050 end;
2051 AddSpace();
2052 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
2053 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
2054 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
2055 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
2056 if s = 'P1' then AddButton(@ProcOptionsPlayerP1WeaponMenu, _lc[I_MENU_WEAPON])
2057 else AddButton(@ProcOptionsPlayerP2WeaponMenu, _lc[I_MENU_WEAPON]);
2058 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
2059 begin
2060 Name := 'mv'+s+'Model';
2061 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
2062 Y := GetControl('ls'+s+'Model').Y;
2063 end;
2064 end;
2065 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
2066 g_GUI_AddWindow(Menu);
2067 end;
2069 procedure CreateAllMenus();
2070 var
2071 Menu: TGUIWindow;
2072 //SR: TSearchRec;
2073 a, cx, _y, i: Integer;
2074 //list: SSArray;
2075 begin
2076 Menu := TGUIWindow.Create('MainMenu');
2077 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, '' (*_lc[I_MENU_MAIN_MENU]*) ))) do
2078 begin
2079 Name := 'mmMainMenu';
2080 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
2081 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
2082 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2083 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2084 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
2085 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
2086 end;
2087 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), False))) do
2088 begin
2089 Color := _RGB(255, 255, 255);
2090 X := gScreenWidth-GetWidth-8;
2091 Y := gScreenHeight-GetHeight-8;
2092 end;
2093 Menu.DefControl := 'mmMainMenu';
2094 Menu.MainWindow := True;
2095 g_GUI_AddWindow(Menu);
2097 Menu := TGUIWindow.Create('NewGameMenu');
2098 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_NEW_GAME]))) do
2099 begin
2100 Name := 'mmNewGameMenu';
2101 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
2102 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
2103 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
2104 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
2105 end;
2106 Menu.DefControl := 'mmNewGameMenu';
2107 g_GUI_AddWindow(Menu);
2109 Menu := TGUIWindow.Create('NetGameMenu');
2110 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_MULTIPLAYER]))) do
2111 begin
2112 Name := 'mmNetGameMenu';
2113 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
2114 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
2115 end;
2116 Menu.DefControl := 'mmNetGameMenu';
2117 g_GUI_AddWindow(Menu);
2119 Menu := TGUIWindow.Create('NetServerMenu');
2120 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_START_SERVER]))) do
2121 begin
2122 Name := 'mNetServerMenu';
2123 with AddEdit(_lc[I_NET_SERVER_NAME]) do
2124 begin
2125 Name := 'edSrvName';
2126 OnlyDigits := False;
2127 Width := 16;
2128 MaxLength := 64;
2129 Text := NetServerName;
2130 end;
2131 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2132 begin
2133 Name := 'edSrvPassword';
2134 OnlyDigits := False;
2135 Width := 16;
2136 MaxLength := 24;
2137 Text := NetPassword;
2138 end;
2139 with AddEdit(_lc[I_NET_PORT]) do
2140 begin
2141 Name := 'edPort';
2142 OnlyDigits := True;
2143 Width := 4;
2144 MaxLength := 5;
2145 Text := IntToStr(NetPort);
2146 end;
2147 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2148 begin
2149 Name := 'edMaxPlayers';
2150 OnlyDigits := True;
2151 Width := 4;
2152 MaxLength := 2;
2153 Text := IntToStr(NetMaxClients);
2154 end;
2155 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2156 begin
2157 Name := 'swUseMaster';
2158 AddItem(_lc[I_MENU_YES]);
2159 AddItem(_lc[I_MENU_NO]);
2160 if NetUseMaster then
2161 ItemIndex := 0
2162 else
2163 ItemIndex := 1;
2164 end;
2165 AddSpace();
2166 with AddLabel(_lc[I_MENU_MAP]) do
2167 begin
2168 Name := 'lbMap';
2169 FixedLength := 16;
2170 Text := gsMap;
2171 OnClick := @ProcSelectMapMenu;
2172 end;
2173 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2174 begin
2175 Name := 'swGameMode';
2176 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2177 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2178 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2179 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2180 case g_Game_TextToMode(gsGameMode) of
2181 GM_NONE,
2182 GM_DM: ItemIndex := 0;
2183 GM_TDM: ItemIndex := 1;
2184 GM_CTF: ItemIndex := 2;
2185 GM_SINGLE,
2186 GM_COOP: ItemIndex := 3;
2187 end;
2188 OnChange := ProcSwitchMonstersCustom;
2189 end;
2190 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2191 begin
2192 Name := 'edTimeLimit';
2193 OnlyDigits := True;
2194 Width := 4;
2195 MaxLength := 5;
2196 if gsTimeLimit > 0 then
2197 Text := IntToStr(gsTimeLimit);
2198 end;
2199 with AddEdit(_lc[I_MENU_SCORE_LIMIT]) do
2200 begin
2201 Name := 'edScoreLimit';
2202 OnlyDigits := True;
2203 Width := 4;
2204 MaxLength := 5;
2205 if gsScoreLimit > 0 then
2206 Text := IntToStr(gsScoreLimit);
2207 end;
2208 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2209 begin
2210 Name := 'edMaxLives';
2211 OnlyDigits := True;
2212 Width := 4;
2213 MaxLength := 5;
2214 if gsMaxLives > 0 then
2215 Text := IntToStr(gsMaxLives);
2216 end;
2217 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2218 begin
2219 Name := 'edItemRespawnTime';
2220 OnlyDigits := True;
2221 Width := 4;
2222 MaxLength := 5;
2223 if gsItemRespawnTime > 0 then
2224 Text := IntToStr(gsItemRespawnTime);
2225 end;
2226 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2227 begin
2228 Name := 'swPlayers';
2229 AddItem(_lc[I_MENU_COUNT_NONE]);
2230 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2231 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2232 ItemIndex := gsPlayers;
2233 end;
2234 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2235 begin
2236 Name := 'swTeamDamage';
2237 AddItem(_lc[I_MENU_YES]);
2238 AddItem(_lc[I_MENU_NO]);
2239 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2240 ItemIndex := 0
2241 else
2242 ItemIndex := 1;
2243 end;
2244 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
2245 begin
2246 Name := 'swTeamHit';
2247 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
2248 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
2249 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
2250 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
2251 if (gsGameFlags and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
2252 ItemIndex := 0
2253 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITTRACE) then
2254 ItemIndex := 1
2255 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITPROJECTILE) then
2256 ItemIndex := 2
2257 else
2258 ItemIndex := 3;
2259 end;
2260 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2261 begin
2262 Name := 'swDeathmatchKeys';
2263 AddItem(_lc[I_MENU_YES]);
2264 AddItem(_lc[I_MENU_NO]);
2265 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2266 ItemIndex := 0
2267 else
2268 ItemIndex := 1;
2269 end;
2270 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2271 begin
2272 Name := 'swEnableExits';
2273 AddItem(_lc[I_MENU_YES]);
2274 AddItem(_lc[I_MENU_NO]);
2275 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2276 ItemIndex := 0
2277 else
2278 ItemIndex := 1;
2279 end;
2280 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2281 begin
2282 Name := 'swWeaponStay';
2283 AddItem(_lc[I_MENU_YES]);
2284 AddItem(_lc[I_MENU_NO]);
2285 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2286 ItemIndex := 0
2287 else
2288 ItemIndex := 1;
2289 end;
2290 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2291 begin
2292 Name := 'swMonsters';
2293 AddItem(_lc[I_MENU_YES]);
2294 AddItem(_lc[I_MENU_NO]);
2295 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2296 ItemIndex := 0
2297 else
2298 ItemIndex := 1;
2299 end;
2300 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2301 begin
2302 Name := 'swBotsVS';
2303 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2304 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2305 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2306 ItemIndex := 2;
2307 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2308 ItemIndex := 0;
2309 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2310 ItemIndex := 1;
2311 end;
2312 with AddSwitch(_lc[I_MENU_FLAG_DROP]) do
2313 begin
2314 Name := 'swFlagDrop';
2315 AddItem(_lc[I_MENU_FLAG_THROW]);
2316 AddItem(_lc[I_MENU_YES]);
2317 AddItem(_lc[I_MENU_NO]);
2318 if (gsGameFlags and (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG)) = (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG) then
2319 ItemIndex := 0
2320 else if LongBool(gsGameFlags and GAME_OPTION_ALLOWDROPFLAG) then
2321 ItemIndex := 1
2322 else
2323 ItemIndex := 2;
2324 end;
2325 AddSpace();
2326 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2328 ReAlign();
2329 end;
2330 Menu.DefControl := 'mNetServerMenu';
2331 g_GUI_AddWindow(Menu);
2333 Menu := TGUIWindow.Create('NetClientMenu');
2334 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_START_CLIENT]))) do
2335 begin
2336 Name := 'mNetClientMenu';
2338 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2339 AddSpace();
2341 with AddEdit(_lc[I_NET_ADDRESS]) do
2342 begin
2343 Name := 'edIP';
2344 OnlyDigits :=False;
2345 Width := 12;
2346 MaxLength := 64;
2347 Text := 'localhost';
2348 end;
2349 with AddEdit(_lc[I_NET_PORT]) do
2350 begin
2351 Name := 'edPort';
2352 OnlyDigits := True;
2353 Width := 4;
2354 MaxLength := 5;
2355 Text := '25666';
2356 end;
2357 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2358 begin
2359 Name := 'edPW';
2360 OnlyDigits := False;
2361 Width := 12;
2362 MaxLength := 32;
2363 Text := '';
2364 end;
2366 AddSpace();
2367 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2369 ReAlign();
2370 end;
2371 Menu.DefControl := 'mNetClientMenu';
2372 g_GUI_AddWindow(Menu);
2374 Menu := TGUIWindow.Create('LoadMenu');
2375 Menu.OnShow := ProcLoadMenu;
2376 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_LOAD_GAME]))) do
2377 begin
2378 Name := 'mmLoadMenu';
2380 for a := 1 to 8 do
2381 with AddEdit('') do
2382 begin
2383 Name := 'edSlot'+IntToStr(a);
2384 Width := 16;
2385 MaxLength := 16;
2386 OnEnter := ProcLoadGame;
2387 end;
2388 end;
2389 Menu.DefControl := 'mmLoadMenu';
2390 g_GUI_AddWindow(Menu);
2392 Menu := TGUIWindow.Create('SaveMenu');
2393 Menu.OnShow := ProcSaveMenu;
2394 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_SAVE_GAME]))) do
2395 begin
2396 Name := 'mmSaveMenu';
2398 for a := 1 to 8 do
2399 with AddEdit('') do
2400 begin
2401 Name := 'edSlot'+IntToStr(a);
2402 Width := 16;
2403 MaxLength := 16;
2404 OnChange := ProcSaveGame;
2405 end;
2406 end;
2407 Menu.DefControl := 'mmSaveMenu';
2408 g_GUI_AddWindow(Menu);
2410 Menu := TGUIWindow.Create('CustomGameMenu');
2411 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_CUSTOM_GAME]))) do
2412 begin
2413 Name := 'mCustomGameMenu';
2414 with AddLabel(_lc[I_MENU_MAP]) do
2415 begin
2416 Name := 'lbMap';
2417 FixedLength := 16;
2418 Text := gsMap;
2419 OnClick := @ProcSelectMapMenu;
2420 end;
2421 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2422 begin
2423 Name := 'swGameMode';
2424 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2425 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2426 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2427 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2428 case g_Game_TextToMode(gsGameMode) of
2429 GM_NONE,
2430 GM_DM: ItemIndex := 0;
2431 GM_TDM: ItemIndex := 1;
2432 GM_CTF: ItemIndex := 2;
2433 GM_SINGLE,
2434 GM_COOP: ItemIndex := 3;
2435 end;
2436 OnChange := ProcSwitchMonstersCustom;
2437 end;
2438 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2439 begin
2440 Name := 'edTimeLimit';
2441 OnlyDigits := True;
2442 Width := 4;
2443 MaxLength := 5;
2444 if gsTimeLimit > 0 then
2445 Text := IntToStr(gsTimeLimit);
2446 end;
2447 with AddEdit(_lc[I_MENU_SCORE_LIMIT]) do
2448 begin
2449 Name := 'edScoreLimit';
2450 OnlyDigits := True;
2451 Width := 4;
2452 MaxLength := 5;
2453 if gsScoreLimit > 0 then
2454 Text := IntToStr(gsScoreLimit);
2455 end;
2456 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2457 begin
2458 Name := 'edMaxLives';
2459 OnlyDigits := True;
2460 Width := 4;
2461 MaxLength := 5;
2462 if gsMaxLives > 0 then
2463 Text := IntToStr(gsMaxLives);
2464 end;
2465 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2466 begin
2467 Name := 'edItemRespawnTime';
2468 OnlyDigits := True;
2469 Width := 4;
2470 MaxLength := 5;
2471 if gsItemRespawnTime > 0 then
2472 Text := IntToStr(gsItemRespawnTime);
2473 end;
2474 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2475 begin
2476 Name := 'swPlayers';
2477 AddItem(_lc[I_MENU_COUNT_NONE]);
2478 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2479 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2480 ItemIndex := gsPlayers;
2481 end;
2482 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2483 begin
2484 Name := 'swTeamDamage';
2485 AddItem(_lc[I_MENU_YES]);
2486 AddItem(_lc[I_MENU_NO]);
2487 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2488 ItemIndex := 0
2489 else
2490 ItemIndex := 1;
2491 end;
2492 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
2493 begin
2494 Name := 'swTeamHit';
2495 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
2496 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
2497 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
2498 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
2499 if (gsGameFlags and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
2500 ItemIndex := 0
2501 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITTRACE) then
2502 ItemIndex := 1
2503 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITPROJECTILE) then
2504 ItemIndex := 2
2505 else
2506 ItemIndex := 3;
2507 end;
2508 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2509 begin
2510 Name := 'swDeathmatchKeys';
2511 AddItem(_lc[I_MENU_YES]);
2512 AddItem(_lc[I_MENU_NO]);
2513 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2514 ItemIndex := 0
2515 else
2516 ItemIndex := 1;
2517 end;
2518 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2519 begin
2520 Name := 'swEnableExits';
2521 AddItem(_lc[I_MENU_YES]);
2522 AddItem(_lc[I_MENU_NO]);
2523 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2524 ItemIndex := 0
2525 else
2526 ItemIndex := 1;
2527 end;
2528 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2529 begin
2530 Name := 'swWeaponStay';
2531 AddItem(_lc[I_MENU_YES]);
2532 AddItem(_lc[I_MENU_NO]);
2533 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2534 ItemIndex := 0
2535 else
2536 ItemIndex := 1;
2537 end;
2538 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2539 begin
2540 Name := 'swMonsters';
2541 AddItem(_lc[I_MENU_YES]);
2542 AddItem(_lc[I_MENU_NO]);
2543 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2544 ItemIndex := 0
2545 else
2546 ItemIndex := 1;
2547 end;
2548 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2549 begin
2550 Name := 'swBotsVS';
2551 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2552 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2553 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2554 ItemIndex := 2;
2555 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2556 ItemIndex := 0;
2557 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2558 ItemIndex := 1;
2559 end;
2560 with AddSwitch(_lc[I_MENU_FLAG_DROP]) do
2561 begin
2562 Name := 'swFlagDrop';
2563 AddItem(_lc[I_MENU_FLAG_THROW]);
2564 AddItem(_lc[I_MENU_YES]);
2565 AddItem(_lc[I_MENU_NO]);
2566 if (gsGameFlags and (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG)) = (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG) then
2567 ItemIndex := 0
2568 else if LongBool(gsGameFlags and GAME_OPTION_ALLOWDROPFLAG) then
2569 ItemIndex := 1
2570 else
2571 ItemIndex := 2;
2572 end;
2573 AddSpace();
2574 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2576 ReAlign();
2577 end;
2578 Menu.DefControl := 'mCustomGameMenu';
2579 g_GUI_AddWindow(Menu);
2581 Menu := TGUIWindow.Create('CampaignMenu');
2582 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_CAMPAIGN]))) do
2583 begin
2584 Name := 'mCampaignMenu';
2586 AddSpace();
2587 AddSpace();
2588 AddSpace();
2589 AddSpace();
2590 AddSpace();
2591 AddSpace();
2593 with AddFileList('', 15, 4) do
2594 begin
2595 Name := 'lsWAD';
2596 OnChange := ProcSelectCampaignWAD;
2598 Sort := True;
2599 Dirs := True;
2600 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2601 SetBase(MegawadDirs);
2602 end;
2604 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2605 begin
2606 Name := 'lbWADName';
2607 FixedLength := 8;
2608 Enabled := False;
2609 end;
2610 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2611 begin
2612 Name := 'lbWADAuthor';
2613 FixedLength := 8;
2614 Enabled := False;
2615 end;
2616 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2617 with AddMemo('', 15, 3) do
2618 begin
2619 Name := 'meWADDescription';
2620 Color := MENU_ITEMSCTRL_COLOR;
2621 end;
2622 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2623 begin
2624 Name := 'swPlayers';
2625 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2626 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2627 end;
2628 AddSpace();
2629 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2631 ReAlign();
2633 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2634 begin
2635 Name := 'mpWADImage';
2636 DefaultRes := 'NOPIC';
2637 X := GetControl('lsWAD').X+4;
2638 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2639 end;
2640 end;
2641 Menu.DefControl := 'mCampaignMenu';
2642 g_GUI_AddWindow(Menu);
2644 Menu := TGUIWindow.Create('SelectMapMenu');
2645 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_SELECT_MAP]))) do
2646 begin
2647 Name := 'mSelectMapMenu';
2648 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2649 begin
2650 Name := 'lsMapWAD';
2651 OnChange := ProcSelectWAD;
2653 Sort := True;
2654 Dirs := True;
2655 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2656 SetBase(MapDirs);
2657 end;
2658 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2659 begin
2660 Name := 'lsMapRes';
2661 Sort := True;
2662 OnChange := ProcSelectMap;
2663 end;
2664 AddSpace();
2665 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2666 begin
2667 Name := 'lbMapName';
2668 FixedLength := 24;
2669 Enabled := False;
2670 end;
2671 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2672 begin
2673 Name := 'lbMapAuthor';
2674 FixedLength := 16;
2675 Enabled := False;
2676 end;
2677 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2678 begin
2679 Name := 'lbMapSize';
2680 FixedLength := 10;
2681 Enabled := False;
2682 end;
2683 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 20, 4) do
2684 begin
2685 Name := 'meMapDescription';
2686 end;
2688 ReAlign();
2690 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2691 begin
2692 Name := 'mpMapPreview';
2693 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2694 Y := GetControl('lsMapWAD').Y;
2695 end;
2696 with TGUILabel(Menu.AddChild(TGUILabel.Create('', False))) do
2697 begin
2698 Name := 'lbMapScale';
2699 FixedLength := 8;
2700 Enabled := False;
2701 Color := MENU_ITEMSCTRL_COLOR;
2702 X := GetControl('lsMapWAD').X +
2703 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2704 2 + MAPPREVIEW_WIDTH*4;
2705 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2706 end;
2707 end;
2708 Menu.OnClose := ProcSetMap;
2709 Menu.DefControl := 'mSelectMapMenu';
2710 g_GUI_AddWindow(Menu);
2712 Menu := TGUIWindow.Create('OptionsMenu');
2713 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_OPTIONS]))) do
2714 begin
2715 Name := 'mmOptionsMenu';
2716 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2717 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2718 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2719 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2720 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2721 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2722 AddSpace();
2723 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2724 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2725 end;
2726 Menu.OnClose := ProcApplyOptions;
2727 Menu.DefControl := 'mmOptionsMenu';
2728 g_GUI_AddWindow(Menu);
2730 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6), @ProcSavedMenuKeyDown);
2731 g_GUI_AddWindow(Menu);
2733 Menu := TGUIWindow.Create('OptionsVideoMenu');
2734 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_VIDEO_OPTIONS]))) do
2735 begin
2736 Name := 'mOptionsVideoMenu';
2737 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2738 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2739 begin
2740 Name := 'swBPP';
2741 AddItem('16');
2742 AddItem('32');
2743 end;
2744 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2745 begin
2746 Name := 'swVSync';
2747 AddItem(_lc[I_MENU_YES]);
2748 AddItem(_lc[I_MENU_NO]);
2749 end;
2750 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2751 begin
2752 Name := 'swTextureFilter';
2753 AddItem(_lc[I_MENU_YES]);
2754 AddItem(_lc[I_MENU_NO]);
2755 end;
2756 with AddSwitch(_lc[I_MENU_VIDEO_INTERPOLATION]) do
2757 begin
2758 Name := 'swInterp';
2759 AddItem(_lc[I_MENU_YES]);
2760 AddItem(_lc[I_MENU_NO]);
2761 end;
2762 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2763 begin
2764 Name := 'swLegacyNPOT';
2765 AddItem(_lc[I_MENU_NO]);
2766 AddItem(_lc[I_MENU_YES]);
2767 end;
2768 AddSpace();
2769 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2770 ReAlign();
2771 end;
2772 Menu.DefControl := 'mOptionsVideoMenu';
2773 g_GUI_AddWindow(Menu);
2775 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2776 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_RESOLUTION_SELECT]))) do
2777 begin
2778 Name := 'mOptionsVideoResMenu';
2779 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2780 begin
2781 Name := 'lbCurrentRes';
2782 FixedLength := 24;
2783 Enabled := False;
2784 end;
2785 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2786 begin
2787 Name := 'lsResolution';
2788 Sort := False;
2789 end;
2790 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2791 begin
2792 Name := 'swFullScreen';
2793 AddItem(_lc[I_MENU_YES]);
2794 AddItem(_lc[I_MENU_NO]);
2795 end;
2796 with AddSwitch(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2797 begin
2798 Name := 'swResFactor';
2799 AddItem('1x');
2800 for i := 2 to gRC_Width div 640 do
2801 AddItem(IntToStr(i) + 'x');
2802 end;
2803 AddSpace();
2804 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2805 UpdateIndex();
2806 end;
2807 Menu.DefControl := 'mOptionsVideoResMenu';
2808 g_GUI_AddWindow(Menu);
2810 Menu := TGUIWindow.Create('OptionsSoundMenu');
2811 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_SOUND_OPTIONS]))) do
2812 begin
2813 Name := 'mOptionsSoundMenu';
2814 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2815 begin
2816 Name := 'scMusicLevel';
2817 Max := 16;
2818 OnChange := ProcChangeSoundSettings;
2819 end;
2820 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2821 begin
2822 Name := 'scSoundLevel';
2823 Max := 16;
2824 OnChange := ProcChangeSoundSettings;
2825 end;
2826 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2827 begin
2828 Name := 'scMaxSimSounds';
2829 Max := 16;
2830 end;
2831 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2832 begin;
2833 Name := 'swAnnouncer';
2834 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2835 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2836 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2837 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2838 end;
2839 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2840 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2841 begin;
2842 Name := 'swSoundEffects';
2843 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2844 AddItem(_lc[I_MENU_COMPAT_DF]);
2845 end;
2846 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
2847 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
2848 begin;
2849 Name := 'swChatSpeech';
2850 AddItem(_lc[I_MENU_YES]);
2851 AddItem(_lc[I_MENU_NO]);
2852 end;
2853 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2854 begin
2855 Name := 'swInactiveSounds';
2856 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2857 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2858 end;
2859 ReAlign();
2860 end;
2861 Menu.DefControl := 'mOptionsSoundMenu';
2862 g_GUI_AddWindow(Menu);
2864 Menu := TGUIWindow.Create('OptionsGameMenu');
2865 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_GAME_OPTIONS]))) do
2866 begin
2867 Name := 'mOptionsGameMenu';
2868 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2869 begin
2870 Name := 'scParticlesCount';
2871 Max := 20;
2872 end;
2873 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2874 begin
2875 Name := 'swBloodCount';
2876 AddItem(_lc[I_MENU_COUNT_NONE]);
2877 AddItem(_lc[I_MENU_COUNT_SMALL]);
2878 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2879 AddItem(_lc[I_MENU_COUNT_BIG]);
2880 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2881 end;
2882 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2883 begin
2884 Name := 'scShellsMax';
2885 Max := 20;
2886 end;
2887 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2888 begin
2889 Name := 'scGibsMax';
2890 Max := 20;
2891 end;
2892 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2893 begin
2894 Name := 'scCorpsesMax';
2895 Max := 20;
2896 end;
2897 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2898 begin
2899 Name := 'swGibsCount';
2900 AddItem(_lc[I_MENU_COUNT_NONE]);
2901 AddItem(_lc[I_MENU_COUNT_SMALL]);
2902 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2903 AddItem(_lc[I_MENU_COUNT_BIG]);
2904 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2905 end;
2906 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2907 begin
2908 Name := 'swCorpseType';
2909 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2910 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2911 end;
2912 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2913 begin
2914 Name := 'swGibsType';
2915 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2916 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2917 end;
2918 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2919 begin
2920 Name := 'swBloodType';
2921 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2922 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2923 end;
2924 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2925 begin
2926 Name := 'swScreenFlash';
2927 AddItem(_lc[I_MENU_NO]);
2928 AddItem(_lc[I_MENU_COMPAT_DF]);
2929 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2930 end;
2931 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2932 begin
2933 Name := 'swBackground';
2934 AddItem(_lc[I_MENU_YES]);
2935 AddItem(_lc[I_MENU_NO]);
2936 end;
2937 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2938 begin
2939 Name := 'swMessages';
2940 AddItem(_lc[I_MENU_YES]);
2941 AddItem(_lc[I_MENU_NO]);
2942 end;
2943 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2944 begin
2945 Name := 'swRevertPlayers';
2946 AddItem(_lc[I_MENU_YES]);
2947 AddItem(_lc[I_MENU_NO]);
2948 end;
2949 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2950 begin
2951 Name := 'swChatBubble';
2952 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2953 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2954 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2955 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2956 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2957 end;
2958 with AddSwitch(_lc[I_MENU_GAME_PLAYER_INDICATOR]) do
2959 begin
2960 Name := 'swPlayerIndicator';
2961 AddItem(_lc[I_MENU_GAME_INDICATOR_NONE]);
2962 AddItem(_lc[I_MENU_GAME_INDICATOR_OWN]);
2963 AddItem(_lc[I_MENU_GAME_INDICATOR_ALL]);
2964 end;
2965 with AddSwitch(_lc[I_MENU_GAME_INDICATOR_STYLE]) do
2966 begin
2967 Name := 'swPlayerIndicatorStyle';
2968 AddItem(_lc[I_MENU_GAME_INDICATOR_ARROW]);
2969 AddItem(_lc[I_MENU_GAME_INDICATOR_NAME]);
2970 end;
2971 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2972 begin
2973 Name := 'scScaleFactor';
2974 Max := 10;
2975 OnChange := ProcChangeGameSettings;
2976 end;
2977 ReAlign();
2978 end;
2979 Menu.DefControl := 'mOptionsGameMenu';
2980 g_GUI_AddWindow(Menu);
2982 Menu := TGUIWindow.Create('OptionsControlsMenu');
2983 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_CONTROLS_OPTIONS]))) do
2984 begin
2985 Name := 'mOptionsControlsMenu';
2986 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
2987 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
2988 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
2989 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
2990 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
2991 AddSpace();
2992 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
2993 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
2994 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
2995 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
2996 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
2997 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
2998 if e_HasJoysticks then
2999 begin
3000 AddSpace();
3001 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
3002 end;
3003 if g_touch_enabled then
3004 begin
3005 AddSpace();
3006 AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
3007 end;
3008 end;
3009 Menu.DefControl := 'mOptionsControlsMenu';
3010 g_GUI_AddWindow(Menu);
3012 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
3013 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_PLAYER_1_KBD]))) do
3014 begin
3015 Name := 'mOptionsControlsP1Menu';
3016 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
3017 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
3018 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
3019 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
3020 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
3021 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
3022 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
3023 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
3024 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
3025 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
3026 AddKeyRead2(_lc[I_MENU_CONTROL_DROPFLAG]).Name := _lc[I_MENU_CONTROL_DROPFLAG];
3027 end;
3028 Menu.DefControl := 'mOptionsControlsP1Menu';
3029 g_GUI_AddWindow(Menu);
3031 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
3032 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
3033 begin
3034 Name := 'mOptionsControlsP1MenuWeapons';
3035 for i := WP_FIRST to WP_LAST do
3036 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
3037 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
3038 end;
3039 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
3040 g_GUI_AddWindow(Menu);
3042 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
3043 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_PLAYER_2_KBD]))) do
3044 begin
3045 Name := 'mOptionsControlsP2Menu';
3046 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
3047 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
3048 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
3049 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
3050 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
3051 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
3052 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
3053 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
3054 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
3055 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
3056 AddKeyRead2(_lc[I_MENU_CONTROL_DROPFLAG]).Name := _lc[I_MENU_CONTROL_DROPFLAG];
3057 end;
3058 Menu.DefControl := 'mOptionsControlsP2Menu';
3059 g_GUI_AddWindow(Menu);
3061 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
3062 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
3063 begin
3064 Name := 'mOptionsControlsP2MenuWeapons';
3065 for i := WP_FIRST to WP_LAST do
3066 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
3067 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
3068 end;
3069 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
3070 g_GUI_AddWindow(Menu);
3072 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
3073 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
3074 begin
3075 Name := 'mOptionsControlsJoystickMenu';
3076 for i := 0 to e_MaxJoys - 1 do
3077 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
3078 begin
3079 Name := 'scDeadzone' + IntToStr(i);
3080 Max := 20
3081 end
3082 end;
3083 Menu.DefControl := 'mOptionsControlsJoystickMenu';
3084 g_GUI_AddWindow(Menu);
3086 Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
3087 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_CONTROL_TOUCH]))) do
3088 begin
3089 Name := 'mOptionsControlsTouchMenu';
3090 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
3091 begin
3092 Name := 'swTouchAlt';
3093 AddItem(_lc[I_MENU_NO]);
3094 AddItem(_lc[I_MENU_YES]);
3095 OnChange := ProcChangeTouchSettings;
3096 end;
3097 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
3098 begin
3099 Name := 'scTouchSize';
3100 Max := 20;
3101 OnChange := ProcChangeTouchSettings;
3102 end;
3103 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
3104 begin
3105 Name := 'swTouchFire';
3106 AddItem(_lc[I_MENU_NO]);
3107 AddItem(_lc[I_MENU_YES]);
3108 end;
3109 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do
3110 begin
3111 Name := 'scTouchOffset';
3112 Max := 20;
3113 OnChange := ProcChangeTouchSettings;
3114 end;
3115 end;
3116 Menu.DefControl := 'mOptionsControlsTouchMenu';
3117 g_GUI_AddWindow(Menu);
3119 Menu := TGUIWindow.Create('OptionsPlayersMenu');
3120 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_PLAYER_OPTIONS]))) do
3121 begin
3122 Name := 'mOptionsPlayersMenu';
3123 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
3124 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
3125 end;
3126 Menu.DefControl := 'mOptionsPlayersMenu';
3127 g_GUI_AddWindow(Menu);
3129 CreatePlayerOptionsMenu('P1');
3130 CreatePlayerOptionsMenu('P2');
3132 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
3133 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_MODEL_INFO]))) do
3134 begin
3135 Name := 'mOptionsPlayersMIMenu';
3136 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
3137 begin
3138 Name := 'lbName';
3139 FixedLength := 16;
3140 end;
3141 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
3142 begin
3143 Name := 'lbAuthor';
3144 FixedLength := 16;
3145 end;
3146 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
3147 begin
3148 Name := 'meComment';
3149 end;
3150 AddSpace();
3151 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
3152 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
3153 begin
3154 Name := 'lbWeapon';
3155 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
3156 end;
3157 ReAlign();
3158 end;
3159 Menu.DefControl := 'mOptionsPlayersMIMenu';
3160 g_GUI_AddWindow(Menu);
3162 Menu := TGUIWindow.Create('OptionsPlayersP1WeaponMenu');
3163 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_WEAPON]))) do
3164 begin
3165 Name := 'mOptionsPlayersP1WeaponMenu';
3166 with AddSwitch(_lc[I_MENU_WEAPON_SWITCH]) do
3167 begin
3168 Name := 'swWeaponAutoswitch';
3169 AddItem(_lc[I_MENU_NO]);
3170 AddItem(_lc[I_MENU_WEAPON_SWITCH_LINEAR]);
3171 AddItem(_lc[I_MENU_WEAPON_SWITCH_PREFERENCE]);
3172 end;
3173 with AddSwitch(_lc[I_MENU_WEAPON_ALLOW_EMPTY]) do
3174 begin
3175 Name := 'swWeaponAllowEmpty';
3176 AddItem(_lc[I_MENU_YES]);
3177 AddItem(_lc[I_MENU_NO]);
3178 end;
3179 with AddSwitch(_lc[I_MENU_KASTET_ALLOW]) do
3180 begin
3181 Name := 'swWeaponAllowFist';
3182 AddItem(_lc[I_MENU_KASTET_ALLOW_ALWAYS]);
3183 AddItem(_lc[I_MENU_KASTET_ALLOW_BERSERK]);
3184 end;
3185 AddButton(@ProcOptionsPlayerP1WeaponPreferencesMenu, _lc[I_MENU_WEAPON_SWITCH_PRIORITY]);
3186 ReAlign();
3187 end;
3188 Menu.DefControl := 'mOptionsPlayersP1WeaponMenu';
3189 g_GUI_AddWindow(Menu);
3191 Menu := TGUIWindow.Create('OptionsPreferencesP1WeaponMenu');
3192 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_WEAPON_PRIORITY_PLAYER_1]))) do
3193 begin
3194 Name := 'mOptionsPreferencesP1WeaponMenu';
3195 for i := WP_FIRST to WP_LAST do
3196 begin
3197 with AddSwitch(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]) do
3198 begin
3199 Name := IntToStr(i);
3200 for a := WP_FIRST to WP_LAST+1 do
3201 begin
3202 AddItem(IntToStr(a));
3203 end;
3204 ItemIndex := i
3205 end;
3206 end;
3207 with AddSwitch(_lc[I_GAME_WEAPON_BERSERK]) do
3208 begin
3209 Name := IntToStr(WP_LAST+1);
3210 for a := WP_FIRST to WP_LAST+1 do
3211 begin
3212 AddItem(IntToStr(a));
3213 end;
3214 ItemIndex := WP_LAST + 1;
3215 end;
3216 end;
3217 Menu.DefControl := 'mOptionsPreferencesP1WeaponMenu';
3218 g_GUI_AddWindow(Menu);
3221 Menu := TGUIWindow.Create('OptionsPlayersP2WeaponMenu');
3222 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_WEAPON]))) do
3223 begin
3224 Name := 'mOptionsPlayersP2WeaponMenu';
3225 with AddSwitch(_lc[I_MENU_WEAPON_SWITCH]) do
3226 begin
3227 Name := 'swWeaponAutoswitch';
3228 AddItem(_lc[I_MENU_NO]);
3229 AddItem(_lc[I_MENU_WEAPON_SWITCH_LINEAR]);
3230 AddItem(_lc[I_MENU_WEAPON_SWITCH_PREFERENCE]);
3231 end;
3232 with AddSwitch(_lc[I_MENU_WEAPON_ALLOW_EMPTY]) do
3233 begin
3234 Name := 'swWeaponAllowEmpty';
3235 AddItem(_lc[I_MENU_YES]);
3236 AddItem(_lc[I_MENU_NO]);
3237 end;
3238 with AddSwitch(_lc[I_MENU_KASTET_ALLOW]) do
3239 begin
3240 Name := 'swWeaponAllowFist';
3241 AddItem(_lc[I_MENU_KASTET_ALLOW_ALWAYS]);
3242 AddItem(_lc[I_MENU_KASTET_ALLOW_BERSERK]);
3243 end;
3244 AddButton(@ProcOptionsPlayerP2WeaponPreferencesMenu, _lc[I_MENU_WEAPON_SWITCH_PRIORITY]);
3245 ReAlign();
3246 end;
3247 Menu.DefControl := 'mOptionsPlayersP2WeaponMenu';
3248 g_GUI_AddWindow(Menu);
3250 Menu := TGUIWindow.Create('OptionsPreferencesP2WeaponMenu');
3251 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_WEAPON_PRIORITY_PLAYER_2]))) do
3252 begin
3253 Name := 'mOptionsPreferencesP2WeaponMenu';
3254 for i := WP_FIRST to WP_LAST do
3255 begin
3256 with AddSwitch(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]) do
3257 begin
3258 Name := IntToStr(i);
3259 for a := WP_FIRST to WP_LAST+1 do
3260 begin
3261 AddItem(IntToStr(a));
3262 end;
3263 ItemIndex := i
3264 end;
3265 end;
3266 with AddSwitch(_lc[I_GAME_WEAPON_BERSERK]) do
3267 begin
3268 Name := IntToStr(WP_LAST+1);
3269 for a := WP_FIRST to WP_LAST+1 do
3270 begin
3271 AddItem(IntToStr(a));
3272 end;
3273 ItemIndex := WP_LAST + 1;
3274 end;
3275 end;
3276 Menu.DefControl := 'mOptionsPreferencesP2WeaponMenu';
3277 g_GUI_AddWindow(Menu);
3279 Menu := TGUIWindow.Create('OptionsLanguageMenu');
3280 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
3281 begin
3282 Name := 'mOptionsLanguageMenu';
3283 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
3284 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
3285 ReAlign();
3286 end;
3287 Menu.DefControl := 'mOptionsLanguageMenu';
3288 g_GUI_AddWindow(Menu);
3290 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6), @ProcDefaultMenuKeyDown);
3291 g_GUI_AddWindow(Menu);
3293 Menu := TGUIWindow.Create('AuthorsMenu');
3294 Menu.BackTexture := 'INTER';
3295 Menu.OnClose := ProcAuthorsClose;
3297 // Çàãîëîâîê:
3298 _y := 16;
3299 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], False))) do
3300 begin
3301 Color := _RGB(255, 0, 0);
3302 X := (gScreenWidth div 2)-(GetWidth() div 2);
3303 Y := _y;
3304 _y := _y+GetHeight();
3305 end;
3306 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), False))) do
3307 begin
3308 Color := _RGB(255, 0, 0);
3309 X := (gScreenWidth div 2)-(GetWidth() div 2);
3310 Y := _y;
3311 _y := _y+GetHeight()+32;
3312 end;
3313 // ×òî äåëàë: Êòî äåëàë
3314 cx := gScreenWidth div 2 - 320 + 64;
3315 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], False))) do
3316 begin
3317 Color := _RGB(255, 0, 0);
3318 X := cx;
3319 Y := _y;
3320 _y := _y+22;
3321 end;
3322 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], False))) do
3323 begin
3324 Color := _RGB(255, 255, 255);
3325 X := cx+32;
3326 Y := _y;
3327 _y := _y+36;
3328 end;
3329 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], False))) do
3330 begin
3331 Color := _RGB(255, 0, 0);
3332 X := cx;
3333 Y := _y;
3334 _y := _y+22;
3335 end;
3336 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], False))) do
3337 begin
3338 Color := _RGB(255, 255, 255);
3339 X := cx+32;
3340 Y := _y;
3341 _y := _y+22;
3342 end;
3343 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], False))) do
3344 begin
3345 Color := _RGB(255, 255, 255);
3346 X := cx+32;
3347 Y := _y;
3348 _y := _y+36;
3349 end;
3350 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], False))) do
3351 begin
3352 Color := _RGB(255, 0, 0);
3353 X := cx;
3354 Y := _y;
3355 _y := _y+22;
3356 end;
3357 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], False))) do
3358 begin
3359 Color := _RGB(255, 255, 255);
3360 X := cx+32;
3361 Y := _y;
3362 _y := _y+36;
3363 end;
3364 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], False))) do
3365 begin
3366 Color := _RGB(255, 0, 0);
3367 X := cx;
3368 Y := _y;
3369 _y := _y+22;
3370 end;
3371 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], False))) do
3372 begin
3373 Color := _RGB(255, 255, 255);
3374 X := cx+32;
3375 Y := _y;
3376 _y := gScreenHeight - 128;
3377 end;
3378 // Çàêëþ÷åíèå:
3379 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], False))) do
3380 begin
3381 Color := _RGB(255, 0, 0);
3382 X := cx;
3383 Y := _y;
3384 _y := _y+16;
3385 end;
3386 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], False))) do
3387 begin
3388 Color := _RGB(255, 255, 255);
3389 X := cx+32;
3390 Y := _y;
3391 _y := _y+GetHeight();
3392 end;
3393 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], False))) do
3394 begin
3395 Color := _RGB(255, 255, 255);
3396 X := cx+32;
3397 Y := _y;
3398 _y := _y+GetHeight();
3399 end;
3400 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], False))) do
3401 begin
3402 Color := _RGB(255, 255, 255);
3403 X := cx+32;
3404 Y := _y;
3405 _y := gScreenHeight - 32;
3406 end;
3407 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], False))) do
3408 begin
3409 Color := _RGB(255, 0, 0);
3410 X := gScreenWidth div 2 - GetWidth() div 2;
3411 Y := _y;
3412 end;
3413 g_GUI_AddWindow(Menu);
3415 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6), @ProcExitMenuKeyDown);
3416 g_GUI_AddWindow(Menu);
3418 Menu := TGUIWindow.Create('GameSingleMenu');
3419 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_MAIN_MENU]))) do
3420 begin
3421 Name := 'mmGameSingleMenu';
3422 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3423 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3424 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3425 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3426 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3427 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3428 end;
3429 Menu.DefControl := 'mmGameSingleMenu';
3430 Menu.MainWindow := True;
3431 Menu.OnClose := ProcGMClose;
3432 Menu.OnShow := ProcGMShow;
3433 g_GUI_AddWindow(Menu);
3435 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6), @ProcEndMenuKeyDown);
3436 g_GUI_AddWindow(Menu);
3438 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6), @ProcRestartMenuKeyDown);
3439 g_GUI_AddWindow(Menu);
3441 Menu := TGUIWindow.Create('GameCustomMenu');
3442 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_MAIN_MENU]))) do
3443 begin
3444 Name := 'mmGameCustomMenu';
3445 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3446 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3447 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3448 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3449 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3450 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3451 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3452 end;
3453 Menu.DefControl := 'mmGameCustomMenu';
3454 Menu.MainWindow := True;
3455 Menu.OnClose := ProcGMClose;
3456 Menu.OnShow := ProcGMShow;
3457 g_GUI_AddWindow(Menu);
3459 Menu := TGUIWindow.Create('GameServerMenu');
3460 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_MAIN_MENU]))) do
3461 begin
3462 Name := 'mmGameServerMenu';
3463 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3464 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3465 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3466 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3467 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3468 end;
3469 Menu.DefControl := 'mmGameServerMenu';
3470 Menu.MainWindow := True;
3471 Menu.OnClose := ProcGMClose;
3472 Menu.OnShow := ProcGMShow;
3473 g_GUI_AddWindow(Menu);
3475 Menu := TGUIWindow.Create('GameClientMenu');
3476 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_MAIN_MENU]))) do
3477 begin
3478 Name := 'mmGameClientMenu';
3479 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3480 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3481 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3482 end;
3483 Menu.DefControl := 'mmGameClientMenu';
3484 Menu.MainWindow := True;
3485 Menu.OnClose := ProcGMClose;
3486 Menu.OnShow := ProcGMShow;
3487 g_GUI_AddWindow(Menu);
3489 Menu := TGUIWindow.Create('ClientPasswordMenu');
3490 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(False, False, _lc[I_MENU_ENTERPASSWORD]))) do
3491 begin
3492 Name := 'mClientPasswordMenu';
3493 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3494 begin
3495 Name := 'edPW';
3496 Width := 12;
3497 MaxLength := 32;
3498 end;
3499 AddSpace;
3501 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3502 ReAlign();
3503 end;
3504 Menu.DefControl := 'mClientPasswordMenu';
3505 g_GUI_AddWindow(Menu);
3507 Menu := TGUIWindow.Create('GameSetGameMenu');
3508 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(True, False, _lc[I_MENU_SET_GAME]))) do
3509 begin
3510 Name := 'mGameSetGameMenu';
3511 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3512 begin
3513 Name := 'swTeamDamage';
3514 AddItem(_lc[I_MENU_YES]);
3515 AddItem(_lc[I_MENU_NO]);
3516 ItemIndex := 1;
3517 end;
3518 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
3519 begin
3520 Name := 'swTeamHit';
3521 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
3522 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
3523 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
3524 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
3525 ItemIndex := 0
3526 end;
3527 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
3528 begin
3529 Name := 'swDeathmatchKeys';
3530 AddItem(_lc[I_MENU_YES]);
3531 AddItem(_lc[I_MENU_NO]);
3532 ItemIndex := 1;
3533 end;
3534 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3535 begin
3536 Name := 'edTimeLimit';
3537 OnlyDigits := True;
3538 Width := 4;
3539 MaxLength := 5;
3540 end;
3541 with AddEdit(_lc[I_MENU_SCORE_LIMIT]) do
3542 begin
3543 Name := 'edScoreLimit';
3544 OnlyDigits := True;
3545 Width := 4;
3546 MaxLength := 5;
3547 end;
3548 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3549 begin
3550 Name := 'edMaxLives';
3551 OnlyDigits := True;
3552 Width := 4;
3553 MaxLength := 5;
3554 end;
3555 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3556 begin
3557 Name := 'swBotsVS';
3558 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3559 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3560 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3561 ItemIndex := 2;
3562 end;
3563 with AddSwitch(_lc[I_MENU_FLAG_DROP]) do
3564 begin
3565 Name := 'swFlagDrop';
3566 AddItem(_lc[I_MENU_FLAG_THROW]);
3567 AddItem(_lc[I_MENU_YES]);
3568 AddItem(_lc[I_MENU_NO]);
3569 ItemIndex := 2;
3570 end;
3572 ReAlign();
3573 end;
3574 Menu.DefControl := 'mGameSetGameMenu';
3575 Menu.OnClose := ProcApplyGameSet;
3576 g_GUI_AddWindow(Menu);
3578 Menu := TGUIWindow.Create('TeamMenu');
3579 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(True, _lc[I_MENU_CHANGE_PLAYERS]))) do
3580 begin
3581 Name := 'mmTeamMenu';
3582 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3583 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3584 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3585 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3586 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3587 end;
3588 Menu.DefControl := 'mmTeamMenu';
3589 Menu.OnShow := ProcChangePlayers;
3590 g_GUI_AddWindow(Menu);
3591 end;
3593 procedure g_Menu_Show_SaveMenu();
3594 begin
3595 if g_Game_IsTestMap then
3596 Exit;
3597 if gGameSettings.GameType = GT_SINGLE then
3598 g_GUI_ShowWindow('GameSingleMenu')
3599 else
3600 begin
3601 if g_Game_IsClient then
3602 Exit
3603 else
3604 if g_Game_IsNet then
3605 Exit
3606 else
3607 g_GUI_ShowWindow('GameCustomMenu');
3608 end;
3609 g_GUI_ShowWindow('SaveMenu');
3610 g_Sound_PlayEx('MENU_OPEN');
3611 end;
3613 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3614 begin
3615 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3616 if gGameSettings.GameType = GT_SINGLE then
3617 begin
3618 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3619 end
3620 else
3621 begin
3622 if g_Game_IsClient then exit;
3623 if g_Game_IsNet then exit;
3624 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3625 end;
3626 g_GUI_ShowWindow('LoadMenu');
3627 g_Sound_PlayEx('MENU_OPEN');
3628 end;
3630 procedure g_Menu_Show_GameSetGame();
3631 begin
3632 if gGameSettings.GameType = GT_SINGLE then
3633 g_GUI_ShowWindow('GameSingleMenu')
3634 else
3635 begin
3636 if g_Game_IsClient then
3637 Exit
3638 else
3639 if g_Game_IsNet then
3640 g_GUI_ShowWindow('GameServerMenu')
3641 else
3642 g_GUI_ShowWindow('GameCustomMenu');
3643 end;
3644 ReadGameSettings();
3645 g_GUI_ShowWindow('GameSetGameMenu');
3646 g_Sound_PlayEx('MENU_OPEN');
3647 end;
3649 procedure g_Menu_Show_OptionsVideo();
3650 begin
3651 if gGameSettings.GameType = GT_SINGLE then
3652 g_GUI_ShowWindow('GameSingleMenu')
3653 else
3654 begin
3655 if g_Game_IsClient then
3656 g_GUI_ShowWindow('GameClientMenu')
3657 else
3658 if g_Game_IsNet then
3659 g_GUI_ShowWindow('GameServerMenu')
3660 else
3661 g_GUI_ShowWindow('GameCustomMenu');
3662 end;
3663 ReadOptions();
3664 g_GUI_ShowWindow('OptionsMenu');
3665 g_GUI_ShowWindow('OptionsVideoMenu');
3666 g_Sound_PlayEx('MENU_OPEN');
3667 end;
3669 procedure g_Menu_Show_OptionsSound();
3670 begin
3671 if gGameSettings.GameType = GT_SINGLE then
3672 g_GUI_ShowWindow('GameSingleMenu')
3673 else
3674 begin
3675 if g_Game_IsClient then
3676 g_GUI_ShowWindow('GameClientMenu')
3677 else
3678 if g_Game_IsNet then
3679 g_GUI_ShowWindow('GameServerMenu')
3680 else
3681 g_GUI_ShowWindow('GameCustomMenu');
3682 end;
3683 ReadOptions();
3684 g_GUI_ShowWindow('OptionsMenu');
3685 g_GUI_ShowWindow('OptionsSoundMenu');
3686 g_Sound_PlayEx('MENU_OPEN');
3687 end;
3689 procedure g_Menu_Show_EndGameMenu();
3690 begin
3691 g_GUI_ShowWindow('EndGameMenu');
3692 g_Sound_PlayEx('MENU_OPEN');
3693 end;
3695 procedure g_Menu_Show_QuitGameMenu();
3696 begin
3697 g_GUI_ShowWindow('ExitMenu');
3698 g_Sound_PlayEx('MENU_OPEN');
3699 end;
3701 procedure g_Menu_Init();
3702 begin
3703 MenuLoadData();
3704 CreateAllMenus();
3705 end;
3707 procedure g_Menu_Free();
3708 begin
3709 MenuFreeData();
3710 end;
3712 procedure g_Menu_Reset();
3713 var
3714 ex: Boolean;
3715 begin
3716 g_GUI_SaveMenuPos();
3717 ex := g_GUI_Destroy();
3719 if ex then
3720 begin
3721 e_WriteLog('Recreating menu...', TMsgType.Notify);
3723 CreateAllMenus();
3725 if gDebugMode then
3726 g_Game_SetDebugMode();
3728 g_GUI_LoadMenuPos();
3729 end;
3730 end;
3732 end.