DEADSOFTWARE

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