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