DEADSOFTWARE

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