DEADSOFTWARE

Game: Use proper syntax of sets for game options instead of raw bitwise operations
[d2df-sdl.git] / src / game / g_menu.pas
1 (* Copyright (C) Doom 2D: Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *)
15 {$INCLUDE ../shared/a_modes.inc}
16 unit g_menu;
18 interface
20 procedure g_Menu_Init();
21 procedure g_Menu_Free();
22 procedure g_Menu_Reset();
23 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
24 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
25 procedure g_Menu_AskLanguage();
27 procedure g_Menu_Show_SaveMenu();
28 procedure g_Menu_Show_LoadMenu(standalone: Boolean=false);
29 procedure g_Menu_Show_GameSetGame();
30 procedure g_Menu_Show_OptionsVideo();
31 procedure g_Menu_Show_OptionsSound();
32 procedure g_Menu_Show_EndGameMenu();
33 procedure g_Menu_Show_QuitGameMenu();
35 var
36 gMenuFont: DWORD;
37 gMenuSmallFont: DWORD;
38 PromptIP: string;
39 PromptPort: Word;
40 TempScale: Integer = -1;
41 TempResScale: Integer = -1;
43 implementation
45 uses
46 {$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();
108 var
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)
134 );
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)
321 end
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();
427 var
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)
561 end
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;
720 var
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();
808 var
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();
821 var
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();
843 var
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();
858 var
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;
880 end
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];
900 end
901 else
902 slWaitStr := _lc[I_NET_SLIST_ERROR];
903 g_Serverlist_GenerateTable(slCurrent, slTable);
904 end;
906 procedure ProcStartCampaign();
907 var
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);
927 var
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 := '';
946 end
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);
965 var
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;
985 end
986 end;
987 end;
988 end;
990 ProcSelectMap(nil);
991 end;
993 procedure ProcSelectCampaignWAD(Sender: TGUIControl);
994 var
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);
1031 var
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);
1050 var
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);
1066 var
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);
1101 var
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);
1235 var
1236 s: ShortString;
1237 snd: TPlayableSound;
1238 res: Boolean;
1239 begin
1240 if yes then
1241 begin
1242 g_Game_StopAllSounds(True);
1243 case (Random(18)) of
1244 0: s := 'SOUND_MONSTER_PAIN';
1245 1: s := 'SOUND_MONSTER_DIE_3';
1246 2: s := 'SOUND_MONSTER_SLOP';
1247 3: s := 'SOUND_MONSTER_DEMON_DIE';
1248 4: s := 'SOUND_MONSTER_IMP_DIE_2';
1249 5: s := 'SOUND_MONSTER_MAN_DIE';
1250 6: s := 'SOUND_MONSTER_BSP_DIE';
1251 7: s := 'SOUND_MONSTER_VILE_DIE';
1252 8: s := 'SOUND_MONSTER_SKEL_DIE';
1253 9: s := 'SOUND_MONSTER_MANCUB_ALERT';
1254 10: s := 'SOUND_MONSTER_PAIN_PAIN';
1255 11: s := 'SOUND_MONSTER_BARON_DIE';
1256 12: s := 'SOUND_MONSTER_CACO_DIE';
1257 13: s := 'SOUND_MONSTER_CYBER_DIE';
1258 14: s := 'SOUND_MONSTER_KNIGHT_ALERT';
1259 15: s := 'SOUND_MONSTER_SPIDER_ALERT';
1260 else s := 'SOUND_PLAYER_FALL';
1261 end;
1262 snd := TPlayableSound.Create();
1263 res := snd.SetByName(s);
1264 if not res then res := snd.SetByName('SOUND_PLAYER_FALL');
1265 if res then
1266 begin
1267 snd.Play(True);
1268 while snd.IsPlaying() do begin end;
1269 end;
1270 g_Game_Quit();
1271 exit;
1272 end;
1273 g_GUI_HideWindow();
1274 end;
1276 procedure ProcLoadMenu();
1277 var
1278 a: Integer;
1279 valid: Boolean;
1280 begin
1281 for a := 1 to 8 do
1282 begin
1283 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Text := g_GetSaveName(a, valid);
1284 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := not valid;
1285 //TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a)).Enabled := valid;
1286 end;
1287 end;
1289 procedure ProcSaveMenu();
1290 var
1291 a: Integer;
1292 valid: Boolean;
1293 name: AnsiString;
1294 begin
1295 for a := 1 to 8 do
1296 begin
1297 name := g_GetSaveName(a, valid);
1298 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Text := name;
1299 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := (name <> '') and (not valid);
1300 end;
1301 end;
1303 procedure ProcSaveGame(Sender: TGUIControl);
1304 var
1305 a: Integer;
1306 begin
1307 if g_Game_IsNet then Exit;
1308 if g_Game_IsTestMap then Exit;
1309 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1310 g_Game_PauseAllSounds(True);
1311 g_SaveGame(a, TGUIEdit(Sender).Text);
1313 g_ActiveWindow := nil;
1314 g_Game_Pause(False);
1315 end;
1317 procedure ProcLoadGame(Sender: TGUIControl);
1318 var
1319 a: Integer;
1320 begin
1321 if g_Game_IsNet then Exit;
1322 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1323 if g_LoadGame(a) then
1324 begin
1325 g_Game_PauseAllSounds(False)
1326 end
1327 else // Íå çàãðóçèëîñü - âîçâðàò â ìåíþ
1328 begin
1329 g_Console_Add(_lc[I_MSG_BAD_SAVE_VERSION], true);
1330 g_GUI_GetWindow('LoadMenu').SetActive(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu'));
1331 //g_ActiveWindow := nil;
1332 end;
1333 end;
1335 procedure ProcSinglePlayer (n: Integer);
1336 var wad, map: AnsiString;
1337 begin
1338 assert(n >= 1);
1339 wad := g_ExtractWadName(gDefaultMegawadStart);
1340 map := g_ExtractFilePathName(gDefaultMegawadStart);
1341 if e_FindResource(AllMapDirs, wad) then
1342 begin
1343 wad := ExpandFileName(wad);
1344 g_Game_StartSingle(wad + ':\' + map, n > 1, n)
1345 end
1346 end;
1348 procedure ProcSingle1Player;
1349 begin
1350 ProcSinglePlayer(1)
1351 end;
1353 procedure ProcSingle2Players;
1354 begin
1355 ProcSinglePlayer(2)
1356 end;
1358 procedure ProcSelectMapMenu();
1359 var
1360 menu: TGUIMenu;
1361 wad_lb: TGUIFileListBox;
1362 map_lb: TGUIListBox;
1363 map: String;
1364 begin
1365 menu := TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1366 wad_lb := TGUIFileListBox(menu.GetControl('lsMapWAD'));
1367 map_lb := TGUIListBox(menu.GetControl('lsMapRes'));
1369 if wad_lb.SelectedItem() <> '' then
1370 map := map_lb.SelectedItem()
1371 else
1372 map := '';
1374 wad_lb.UpdateFileList();
1375 map_lb.Clear();
1377 if wad_lb.SelectedItem() <> '' then
1378 begin
1379 ProcSelectWAD(nil);
1380 map_lb.SelectItem(map);
1382 if map_lb.SelectedItem() <> '' then
1383 ProcSelectMap(nil);
1384 end;
1386 g_GUI_ShowWindow('SelectMapMenu');
1387 end;
1389 procedure ProcSelectCampaignMenu();
1390 var
1391 menu: TGUIMenu;
1392 wad_lb: TGUIFileListBox;
1393 begin
1394 menu := TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1395 wad_lb := TGUIFileListBox(menu.GetControl('lsWAD'));
1397 wad_lb.UpdateFileList();
1399 if wad_lb.SelectedItem() <> '' then
1400 ProcSelectCampaignWAD(nil);
1401 end;
1403 procedure ProcSetMap();
1404 var
1405 wad, map, res: String;
1406 begin
1407 with TGUIMenu(g_ActiveWindow.GetControl('mSelectMapMenu')) do
1408 begin
1409 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
1410 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1411 end;
1413 if (wad = '') or (map = '') then
1414 Exit;
1416 wad := e_FindWadRel(MapDirs, WAD);
1418 res := wad+':\'+map;
1420 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
1421 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res;
1422 end;
1424 procedure ProcChangeSoundSettings(Sender: TGUIControl);
1425 var
1426 menu: TGUIMenu;
1427 begin
1428 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1430 g_Sound_SetupAllVolumes(
1431 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
1432 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
1433 );
1434 end;
1436 procedure ProcChangeGameSettings(Sender: TGUIControl);
1437 var
1438 menu: TGUIMenu;
1439 begin
1440 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
1441 if TGUIScroll(menu.GetControl('scScaleFactor')).Value <> TempScale then
1442 begin
1443 TempScale := TGUIScroll(menu.GetControl('scScaleFactor')).Value;
1444 g_dbg_scale := TempScale + 1;
1445 end;
1446 end;
1448 procedure ProcChangeTouchSettings(Sender: TGUIControl);
1449 var
1450 menu: TGUIMenu;
1451 begin
1452 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
1453 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
1454 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
1455 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
1456 end;
1458 procedure ProcOptionsPlayersMIMenu();
1459 var
1460 s, a: string;
1461 b: TModelInfo;
1462 begin
1463 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1465 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+s+'Menu')).GetControl('ls'+s+'Model')).SelectedItem;
1467 if a = '' then Exit;
1469 b := g_PlayerModel_GetInfo(a);
1471 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1472 begin
1473 TGUILabel(GetControl('lbName')).Text := b.Name;
1474 TGUILabel(GetControl('lbAuthor')).Text := b.Author;
1475 TGUIMemo(GetControl('meComment')).SetText(b.Description);
1477 if b.HaveWeapon then
1478 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1479 else
1480 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1481 end;
1483 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1484 end;
1486 procedure ProcOptionsPlayerP1WeaponMenu();
1487 var
1488 a: string;
1489 begin
1490 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+'P1'+'Menu')).GetControl('ls'+'P1'+'Model')).SelectedItem;
1491 if a = '' then Exit;
1492 g_GUI_ShowWindow('OptionsPlayersP1WeaponMenu');
1493 end;
1495 procedure ProcOptionsPlayerP1WeaponPreferencesMenu();
1496 begin
1497 g_GUI_ShowWindow('OptionsPreferencesP1WeaponMenu');
1498 end;
1500 procedure ProcOptionsPlayerP2WeaponMenu();
1501 var
1502 a: string;
1503 begin
1504 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+'P2'+'Menu')).GetControl('ls'+'P2'+'Model')).SelectedItem;
1505 if a = '' then Exit;
1506 g_GUI_ShowWindow('OptionsPlayersP2WeaponMenu');
1507 end;
1509 procedure ProcOptionsPlayerP2WeaponPreferencesMenu();
1510 begin
1511 g_GUI_ShowWindow('OptionsPreferencesP2WeaponMenu');
1512 end;
1514 procedure ProcOptionsPlayersAnim();
1515 var
1516 s: String;
1517 begin
1518 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1519 s := 'P1'
1520 else
1521 s := 'P2';
1523 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1524 begin
1525 NextAnim();
1526 Model.GetCurrentAnimation.Loop := True;
1527 Model.GetCurrentAnimationMask.Loop := True;
1528 end;
1529 end;
1531 procedure ProcOptionsPlayersWeap();
1532 var
1533 s: String;
1534 begin
1535 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1536 s := 'P1'
1537 else
1538 s := 'P2';
1540 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1541 NextWeapon();
1542 end;
1544 procedure ProcOptionsPlayersRot();
1545 var
1546 s: string;
1547 begin
1548 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1549 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1550 begin
1551 if Direction = TDirection.D_LEFT then Direction := TDirection.D_RIGHT else Direction := TDirection.D_LEFT;
1552 end;
1553 end;
1555 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1556 begin
1557 if yes then
1558 begin
1559 g_Options_SetDefault();
1560 ReadOptions();
1561 end;
1562 g_GUI_HideWindow();
1563 end;
1565 procedure ProcSavedMenuKeyDown (yes: Boolean);
1566 begin
1567 if yes then ReadOptions();
1568 g_GUI_HideWindow();
1569 end;
1571 procedure ProcAuthorsClose();
1572 begin
1573 gMusic.SetByName('MUSIC_MENU');
1574 gMusic.Play();
1575 gState := STATE_MENU;
1576 end;
1578 procedure ProcGMClose();
1579 begin
1580 g_Game_InGameMenu(False);
1581 end;
1583 procedure ProcGMShow();
1584 var
1585 Enabled: Boolean;
1586 begin
1587 Enabled := True;
1588 if (gGameSettings.GameType = GT_SINGLE) and
1589 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1590 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1591 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1592 if not gGameOn then
1593 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1594 if g_Game_IsTestMap then
1595 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1596 TGUIMainMenu(g_ActiveWindow.GetControl(
1597 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1598 end;
1600 procedure ProcChangePlayers();
1601 var
1602 TeamGame, Spectator, AddTwo: Boolean;
1603 P1Team{, P2Team}: Byte;
1604 bP2: TGUITextButton;
1605 begin
1606 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1607 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1608 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1609 P1Team := TEAM_NONE;
1610 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1611 // TODO
1612 //P2Team := TEAM_NONE;
1613 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1615 TGUIMainMenu(g_ActiveWindow.GetControl(
1616 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1617 TGUIMainMenu(g_ActiveWindow.GetControl(
1618 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1619 TGUIMainMenu(g_ActiveWindow.GetControl(
1620 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1622 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1623 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1624 bP2.Enabled := AddTwo and not Spectator;
1625 if bP2.Enabled then
1626 bP2.Color := MAINMENU_ITEMS_COLOR
1627 else
1628 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1629 if gPlayer2 = nil then
1630 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1631 else
1632 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1634 TGUIMainMenu(g_ActiveWindow.GetControl(
1635 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1636 end;
1638 procedure ProcJoinRed();
1639 begin
1640 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1641 Exit;
1642 if g_Game_IsServer then
1643 begin
1644 if gPlayer1 = nil then
1645 g_Game_AddPlayer(TEAM_RED)
1646 else
1647 begin
1648 if gPlayer1.Team <> TEAM_RED then
1649 begin
1650 gPlayer1.SwitchTeam;
1651 gPlayer1Settings.Team := gPlayer1.Team;
1652 end;
1654 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1655 end;
1656 end
1657 else
1658 begin
1659 gPlayer1Settings.Team := TEAM_RED;
1660 MC_SEND_PlayerSettings;
1661 if gPlayer1 = nil then
1662 g_Game_AddPlayer(TEAM_RED);
1663 end;
1664 g_ActiveWindow := nil;
1665 g_Game_Pause(False);
1666 end;
1668 procedure ProcJoinBlue();
1669 begin
1670 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1671 Exit;
1672 if g_Game_IsServer then
1673 begin
1674 if gPlayer1 = nil then
1675 g_Game_AddPlayer(TEAM_BLUE)
1676 else
1677 begin
1678 if gPlayer1.Team <> TEAM_BLUE then
1679 begin
1680 gPlayer1.SwitchTeam;
1681 gPlayer1Settings.Team := gPlayer1.Team;
1682 end;
1684 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1685 end;
1686 end
1687 else
1688 begin
1689 gPlayer1Settings.Team := TEAM_BLUE;
1690 MC_SEND_PlayerSettings;
1691 if gPlayer1 = nil then
1692 g_Game_AddPlayer(TEAM_BLUE);
1693 end;
1694 g_ActiveWindow := nil;
1695 g_Game_Pause(False);
1696 end;
1698 procedure ProcJoinGame();
1699 begin
1700 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1701 Exit;
1702 if gPlayer1 = nil then
1703 g_Game_AddPlayer();
1704 g_ActiveWindow := nil;
1705 g_Game_Pause(False);
1706 end;
1708 procedure ProcSwitchP2();
1709 begin
1710 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1711 Exit;
1712 if gPlayer1 = nil then
1713 Exit;
1714 if gPlayer2 = nil then
1715 g_Game_AddPlayer()
1716 else
1717 g_Game_RemovePlayer();
1718 g_ActiveWindow := nil;
1719 g_Game_Pause(False);
1720 end;
1722 procedure ProcSpectate();
1723 begin
1724 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1725 Exit;
1726 g_Game_Spectate();
1727 g_ActiveWindow := nil;
1728 g_Game_Pause(False);
1729 end;
1731 procedure ProcRestartMenuKeyDown (yes: Boolean);
1732 begin
1733 if yes then g_Game_Restart() else g_GUI_HideWindow;
1734 end;
1736 procedure ProcEndMenuKeyDown (yes: Boolean);
1737 begin
1738 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1739 end;
1741 procedure ProcSetRussianLanguage;
1742 begin
1743 if gLanguage <> LANGUAGE_RUSSIAN then
1744 begin
1745 gLanguage := LANGUAGE_RUSSIAN;
1746 gLanguageChange := True;
1747 gAskLanguage := False;
1748 ProcApplyOptions();
1749 end;
1750 end;
1752 procedure ProcSetEnglishLanguage;
1753 begin
1754 if gLanguage <> LANGUAGE_ENGLISH then
1755 begin
1756 gLanguage := LANGUAGE_ENGLISH;
1757 gLanguageChange := True;
1758 gAskLanguage := False;
1759 ProcApplyOptions();
1760 end;
1761 end;
1763 procedure ProcItemsRespawnMenu();
1764 var
1765 menu: TGUIMenu;
1766 begin
1767 menu := TGUIMenu(g_GUI_GetWindow('ItemsRespawnMenu').GetControl('mItemsRespawnMenu'));
1769 g_GUI_ShowWindow('ItemsRespawnMenu');
1770 end;
1772 procedure ReadGameSettings();
1773 var
1774 menu: TGUIMenu;
1775 begin
1776 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1778 with gGameSettings do
1779 begin
1780 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1781 if TGameOption.TEAM_DAMAGE in Options
1782 then ItemIndex := 0
1783 else ItemIndex := 1;
1784 with TGUISwitch(menu.GetControl('swTeamHit')) do
1785 if [TGameOption.TEAM_HIT_TRACE, TGameOption.TEAM_HIT_PROJECTILE] <= Options then
1786 ItemIndex := 0
1787 else if TGameOption.TEAM_HIT_TRACE in Options then
1788 ItemIndex := 1
1789 else if TGameOption.TEAM_HIT_PROJECTILE in Options then
1790 ItemIndex := 2
1791 else
1792 ItemIndex := 3;
1793 with TGUISwitch(menu.GetControl('swDeathmatchKeys')) do
1794 if TGameOption.DM_KEYS in Options
1795 then ItemIndex := 0
1796 else ItemIndex := 1;
1797 with TGUISwitch(menu.GetControl('swFlagDrop')) do
1798 if [TGameOption.ALLOW_DROP_FLAG, TGameOption.THROW_FLAG] <= Options then
1799 ItemIndex := 0
1800 else if TGameOption.ALLOW_DROP_FLAG in Options then
1801 ItemIndex := 1
1802 else
1803 ItemIndex := 2;
1805 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1806 TGUIEdit(menu.GetControl('edScoreLimit')).Text := IntToStr(ScoreLimit);
1807 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1809 with TGUISwitch(menu.GetControl('swBotsVS')) do
1810 if [TGameOption.BOTS_VS_PLAYERS, TGameOption.BOTS_VS_MONSTERS] <= Options then
1811 ItemIndex := 2
1812 else if TGameOption.BOTS_VS_MONSTERS in Options then
1813 ItemIndex := 1
1814 else
1815 ItemIndex := 0;
1817 if GameType in [GT_CUSTOM, GT_SERVER] then
1818 begin
1819 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1820 TGUISwitch(menu.GetControl('swTeamHit')).Enabled := True;
1821 if (GameMode in [GM_DM, GM_TDM, GM_CTF]) then
1822 begin
1823 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := True;
1824 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_ITEMSTEXT_COLOR;
1825 end
1826 else
1827 begin
1828 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1829 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1830 end;
1831 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1832 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1833 TGUIEdit(menu.GetControl('edScoreLimit')).Enabled := True;
1834 TGUILabel(menu.GetControlsText('edScoreLimit')).Color := MENU_ITEMSTEXT_COLOR;
1835 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1836 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1837 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1838 TGUISwitch(menu.GetControl('swFlagDrop')).Enabled := True;
1839 end
1840 else
1841 begin
1842 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1843 TGUISwitch(menu.GetControl('swTeamHit')).Enabled := True;
1844 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1845 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1846 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1847 begin
1848 Enabled := False;
1849 Text := '';
1850 end;
1851 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1852 with TGUIEdit(menu.GetControl('edScoreLimit')) do
1853 begin
1854 Enabled := False;
1855 Text := '';
1856 end;
1857 TGUILabel(menu.GetControlsText('edScoreLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1858 with TGUIEdit(menu.GetControl('edMaxLives')) do
1859 begin
1860 Enabled := False;
1861 Text := '';
1862 end;
1863 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1864 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1865 TGUISwitch(menu.GetControl('swFlagDrop')).Enabled := False;
1866 end;
1867 end;
1868 end;
1870 procedure ProcApplyGameSet();
1871 var
1872 menu: TGUIMenu;
1873 a, b, n: Integer;
1874 stat: TPlayerStatArray;
1875 begin
1876 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1878 if not g_Game_IsServer then Exit;
1880 with gGameSettings do
1881 begin
1882 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1883 begin
1884 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0
1885 then Options += [TGameOption.TEAM_DAMAGE]
1886 else Options -= [TGameOption.TEAM_DAMAGE];
1887 end;
1889 if TGUISwitch(menu.GetControl('swTeamHit')).Enabled then
1890 begin
1891 Options -= [TGameOption.TEAM_HIT_TRACE, TGameOption.TEAM_HIT_PROJECTILE];
1892 case TGUISwitch(menu.GetControl('swTeamHit')).ItemIndex of
1893 1: Options += [TGameOption.TEAM_HIT_TRACE];
1894 2: Options += [TGameOption.TEAM_HIT_PROJECTILE];
1895 0: Options += [TGameOption.TEAM_HIT_TRACE, TGameOption.TEAM_HIT_PROJECTILE];
1896 end;
1897 end;
1899 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled then
1900 begin
1901 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).ItemIndex = 0
1902 then Options += [TGameOption.DM_KEYS]
1903 else Options -= [TGameOption.DM_KEYS];
1904 end;
1906 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1907 begin
1908 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1910 if n = 0 then
1911 TimeLimit := 0
1912 else
1913 begin
1914 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1916 TimeLimit := Max(n, b);
1917 end;
1918 end;
1920 if TGUIEdit(menu.GetControl('edScoreLimit')).Enabled then
1921 begin
1922 n := StrToIntDef(TGUIEdit(menu.GetControl('edScoreLimit')).Text, ScoreLimit);
1924 if n = 0 then
1925 ScoreLimit := 0
1926 else
1927 begin
1928 b := 0;
1929 if GameMode = GM_DM then
1930 begin // DM
1931 stat := g_Player_GetStats();
1932 if stat <> nil then
1933 for a := 0 to High(stat) do
1934 if stat[a].Frags > b then
1935 b := stat[a].Frags;
1936 end
1937 else // CTF
1938 b := Max(gTeamStat[TEAM_RED].Score, gTeamStat[TEAM_BLUE].Score);
1940 ScoreLimit := Max(n, b);
1941 end;
1942 end;
1944 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1945 begin
1946 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, MaxLives);
1947 if n < 0 then n := 0;
1948 if n > 255 then n := 255;
1949 if n = 0 then
1950 MaxLives := 0
1951 else
1952 begin
1953 b := 0;
1954 stat := g_Player_GetStats();
1955 if stat <> nil then
1956 for a := 0 to High(stat) do
1957 if stat[a].Lives > b then
1958 b := stat[a].Lives;
1960 MaxLives := Max(n, b);
1961 end;
1962 end;
1964 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1965 begin
1966 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1967 1: begin
1968 Options -= [TGameOption.BOTS_VS_PLAYERS];
1969 Options += [TGameOption.BOTS_VS_MONSTERS];
1970 end;
1972 2: Options += [TGameOption.BOTS_VS_PLAYERS, TGameOption.BOTS_VS_MONSTERS];
1974 else
1975 Options -= [TGameOption.BOTS_VS_MONSTERS];
1976 Options += [TGameOption.BOTS_VS_PLAYERS];
1977 end;
1978 end;
1980 if TGUISwitch(menu.GetControl('swFlagDrop')).Enabled then
1981 begin
1982 case TGUISwitch(menu.GetControl('swFlagDrop')).ItemIndex of
1983 0: Options += [TGameOption.ALLOW_DROP_FLAG, TGameOption.THROW_FLAG];
1984 1: Options += [TGameOption.ALLOW_DROP_FLAG];
1985 else Options -= [TGameOption.ALLOW_DROP_FLAG, TGameOption.THROW_FLAG];
1986 end;
1987 end;
1989 // don't forget to latch this shit
1990 gsGameFlags := Options;
1991 gsMaxLives := MaxLives;
1992 gsScoreLimit := ScoreLimit;
1993 gsTimeLimit := TimeLimit;
1994 end;
1996 if g_Game_IsNet then MH_SEND_GameSettings;
1997 end;
1999 procedure ProcVideoOptionsRes();
2000 var
2001 menu: TGUIMenu;
2002 list: SSArray;
2003 begin
2004 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
2006 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
2007 IntToStr(gWinSizeX) +
2008 ' x ' + IntToStr(gWinSizeY) +
2009 ', ' + IntToStr(gBPP) + ' bpp';
2011 with TGUIListBox(menu.GetControl('lsResolution')) do
2012 begin
2013 list := sys_GetDisplayModes(gBPP);
2014 if list <> nil then
2015 begin
2016 Items := list;
2017 ItemIndex := -1; (* nothing selected *)
2018 end
2019 else
2020 begin
2021 Clear
2022 end
2023 end;
2025 with TGUISwitch(menu.GetControl('swFullScreen')) do
2026 if gFullscreen then
2027 ItemIndex := 0
2028 else
2029 ItemIndex := 1;
2031 TempResScale := Round(r_pixel_scale - 1);
2032 with TGUISwitch(menu.GetControl('swResFactor')) do
2033 ItemIndex := Max(Min(TempResScale, gRC_Width div 640 - 1), 0);
2034 end;
2036 procedure ProcApplyVideoOptions();
2037 var
2038 menu: TGUIMenu;
2039 Fullscreen: Boolean;
2040 SWidth, SHeight: Integer;
2041 ScaleChanged: Boolean;
2042 str: String;
2043 begin
2044 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
2046 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
2047 if str <> '' then
2048 SScanf(str, '%dx%d', [@SWidth, @SHeight])
2049 else
2050 begin
2051 SWidth := gWinSizeX;
2052 SHeight := gWinSizeY;
2053 TempResScale := Min(TempResScale, SWidth div 640 - 1);
2054 end;
2056 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
2058 ScaleChanged := False;
2059 if TGUISwitch(menu.GetControl('swResFactor')).ItemIndex <> TempResScale then
2060 begin
2061 TempResScale := Min(TGUISwitch(menu.GetControl('swResFactor')).ItemIndex, SWidth div 640 - 1);
2062 r_pixel_scale := TempResScale + 1;
2063 ScaleChanged := True;
2064 end;
2066 if (SWidth <> gWinSizeX) or
2067 (SHeight <> gWinSizeY) or
2068 (Fullscreen <> gFullscreen) or
2069 ScaleChanged then
2070 begin
2071 gResolutionChange := True;
2072 gRC_Width := SWidth;
2073 gRC_Height := SHeight;
2074 gRC_FullScreen := Fullscreen;
2075 gRC_Maximized := gWinMaximized;
2076 end;
2078 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
2079 ProcApplyOptions();
2080 end;
2082 procedure ProcSetFirstRussianLanguage;
2083 begin
2084 gLanguage := LANGUAGE_RUSSIAN;
2085 gLanguageChange := True;
2086 gAskLanguage := False;
2087 end;
2089 procedure ProcSetFirstEnglishLanguage;
2090 begin
2091 gLanguage := LANGUAGE_ENGLISH;
2092 gLanguageChange := True;
2093 gAskLanguage := False;
2094 end;
2096 procedure ProcRecallAddress();
2097 begin
2098 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
2099 begin
2100 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
2101 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
2102 end;
2103 end;
2105 procedure CreateFirstLanguageMenu();
2106 var
2107 Menu: TGUIWindow;
2108 begin
2109 Menu := TGUIWindow.Create('FirstLanguageMenu');
2111 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', ' '))) do
2112 begin
2113 Name := 'mmFirstLanguageMenu';
2114 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
2115 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
2116 end;
2118 Menu.DefControl := 'mmFirstLanguageMenu';
2119 Menu.MainWindow := True;
2120 g_GUI_AddWindow(Menu);
2121 end;
2123 procedure g_Menu_AskLanguage();
2124 begin
2125 CreateFirstLanguageMenu();
2126 g_GUI_ShowWindow('FirstLanguageMenu');
2127 end;
2129 procedure CreatePlayerOptionsMenu(s: String);
2130 var
2131 Menu: TGUIWindow;
2132 a: String;
2133 begin
2134 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
2135 if s = 'P1' then
2136 a := _lc[I_MENU_PLAYER_1]
2137 else
2138 a := _lc[I_MENU_PLAYER_2];
2139 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
2140 begin
2141 Name := 'mOptionsPlayers'+s+'Menu';
2142 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
2143 begin
2144 Name := 'ed'+s+'Name';
2145 MaxLength := 12;
2146 Width := 12;
2147 end;
2148 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
2149 begin
2150 Name := 'sw'+s+'Team';
2151 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
2152 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
2153 end ;
2154 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
2155 begin
2156 Name := 'ls'+s+'Model';
2157 Sort := True;
2158 Items := g_PlayerModel_GetNames();
2159 OnChange := ProcSelectModel;
2160 end;
2161 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
2162 begin
2163 Name := 'sc'+s+'Red';
2164 Max := 16;
2165 OnChange := ProcChangeColor;
2166 end;
2167 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
2168 begin
2169 Name := 'sc'+s+'Green';
2170 Max := 16;
2171 OnChange := ProcChangeColor;
2172 end;
2173 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
2174 begin
2175 Name := 'sc'+s+'Blue';
2176 Max := 16;
2177 OnChange := ProcChangeColor;
2178 end;
2179 AddSpace();
2180 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
2181 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
2182 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
2183 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
2184 if s = 'P1' then AddButton(@ProcOptionsPlayerP1WeaponMenu, _lc[I_MENU_WEAPON])
2185 else AddButton(@ProcOptionsPlayerP2WeaponMenu, _lc[I_MENU_WEAPON]);
2186 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
2187 begin
2188 Name := 'mv'+s+'Model';
2189 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
2190 Y := GetControl('ls'+s+'Model').Y;
2191 end;
2192 end;
2193 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
2194 g_GUI_AddWindow(Menu);
2195 end;
2197 procedure CreateAllMenus();
2198 var
2199 Menu: TGUIWindow;
2200 //SR: TSearchRec;
2201 a, cx, _y, i: Integer;
2202 //list: SSArray;
2203 begin
2204 Menu := TGUIWindow.Create('MainMenu');
2205 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, 'MAINMENU_LOGO', _lc[I_MENU_MAIN_MENU]))) do
2206 begin
2207 Name := 'mmMainMenu';
2208 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
2209 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
2210 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2211 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2212 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
2213 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
2214 end;
2215 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
2216 begin
2217 Color := _RGB(255, 255, 255);
2218 X := gScreenWidth-GetWidth-8;
2219 Y := gScreenHeight-GetHeight-8;
2220 end;
2221 Menu.DefControl := 'mmMainMenu';
2222 Menu.MainWindow := True;
2223 g_GUI_AddWindow(Menu);
2225 Menu := TGUIWindow.Create('NewGameMenu');
2226 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_NEW_GAME]))) do
2227 begin
2228 Name := 'mmNewGameMenu';
2229 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
2230 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
2231 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
2232 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
2233 end;
2234 Menu.DefControl := 'mmNewGameMenu';
2235 g_GUI_AddWindow(Menu);
2237 Menu := TGUIWindow.Create('NetGameMenu');
2238 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MULTIPLAYER]))) do
2239 begin
2240 Name := 'mmNetGameMenu';
2241 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
2242 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
2243 end;
2244 Menu.DefControl := 'mmNetGameMenu';
2245 g_GUI_AddWindow(Menu);
2247 Menu := TGUIWindow.Create('NetServerMenu');
2248 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
2249 begin
2250 Name := 'mNetServerMenu';
2251 with AddEdit(_lc[I_NET_SERVER_NAME]) do
2252 begin
2253 Name := 'edSrvName';
2254 OnlyDigits := False;
2255 Width := 16;
2256 MaxLength := 64;
2257 Text := NetServerName;
2258 end;
2259 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2260 begin
2261 Name := 'edSrvPassword';
2262 OnlyDigits := False;
2263 Width := 16;
2264 MaxLength := 24;
2265 Text := NetPassword;
2266 end;
2267 with AddEdit(_lc[I_NET_PORT]) do
2268 begin
2269 Name := 'edPort';
2270 OnlyDigits := True;
2271 Width := 4;
2272 MaxLength := 5;
2273 Text := IntToStr(NetPort);
2274 end;
2275 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2276 begin
2277 Name := 'edMaxPlayers';
2278 OnlyDigits := True;
2279 Width := 4;
2280 MaxLength := 2;
2281 Text := IntToStr(NetMaxClients);
2282 end;
2283 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2284 begin
2285 Name := 'swUseMaster';
2286 AddItem(_lc[I_MENU_YES]);
2287 AddItem(_lc[I_MENU_NO]);
2288 if NetUseMaster then
2289 ItemIndex := 0
2290 else
2291 ItemIndex := 1;
2292 end;
2293 AddSpace();
2294 with AddLabel(_lc[I_MENU_MAP]) do
2295 begin
2296 Name := 'lbMap';
2297 FixedLength := 16;
2298 Text := gsMap;
2299 OnClick := @ProcSelectMapMenu;
2300 end;
2301 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2302 begin
2303 Name := 'swGameMode';
2304 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2305 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2306 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2307 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2308 case g_Game_TextToMode(gsGameMode) of
2309 GM_NONE,
2310 GM_DM: ItemIndex := 0;
2311 GM_TDM: ItemIndex := 1;
2312 GM_CTF: ItemIndex := 2;
2313 GM_SINGLE,
2314 GM_COOP: ItemIndex := 3;
2315 end;
2316 OnChange := ProcSwitchMonstersCustom;
2317 end;
2318 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2319 begin
2320 Name := 'edTimeLimit';
2321 OnlyDigits := True;
2322 Width := 4;
2323 MaxLength := 5;
2324 if gsTimeLimit > 0 then
2325 Text := IntToStr(gsTimeLimit);
2326 end;
2327 with AddEdit(_lc[I_MENU_SCORE_LIMIT]) do
2328 begin
2329 Name := 'edScoreLimit';
2330 OnlyDigits := True;
2331 Width := 4;
2332 MaxLength := 5;
2333 if gsScoreLimit > 0 then
2334 Text := IntToStr(gsScoreLimit);
2335 end;
2336 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2337 begin
2338 Name := 'edMaxLives';
2339 OnlyDigits := True;
2340 Width := 4;
2341 MaxLength := 5;
2342 if gsMaxLives > 0 then
2343 Text := IntToStr(gsMaxLives);
2344 end;
2345 with AddLabel(_lc[I_MENU_SELECT_ITEM_RESPAWN]) do
2346 begin
2347 Name := 'lbItemsRespawn';
2348 FixedLength := 16;
2349 OnClick := @ProcItemsRespawnMenu;
2350 end;
2351 AddSpace();
2352 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2353 begin
2354 Name := 'swPlayers';
2355 AddItem(_lc[I_MENU_COUNT_NONE]);
2356 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2357 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2358 ItemIndex := gsPlayers;
2359 end;
2360 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2361 begin
2362 Name := 'swTeamDamage';
2363 AddItem(_lc[I_MENU_YES]);
2364 AddItem(_lc[I_MENU_NO]);
2365 if TGameOption.TEAM_DAMAGE in gsGameFlags
2366 then ItemIndex := 0
2367 else ItemIndex := 1;
2368 end;
2369 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
2370 begin
2371 Name := 'swTeamHit';
2372 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
2373 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
2374 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
2375 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
2376 if [TGameOption.TEAM_HIT_TRACE, TGameOption.TEAM_HIT_PROJECTILE] <= gsGameFlags then
2377 ItemIndex := 0
2378 else if TGameOption.TEAM_HIT_TRACE in gsGameFlags then
2379 ItemIndex := 1
2380 else if TGameOption.TEAM_HIT_PROJECTILE in gsGameFlags then
2381 ItemIndex := 2
2382 else
2383 ItemIndex := 3;
2384 end;
2385 with AddSwitch(_lc[I_MENU_ENABLE_TEAM_DAMAGE_ABSOBR]) do
2386 begin
2387 Name := 'swTeamAbsorbDamage';
2388 AddItem(_lc[I_MENU_YES]);
2389 AddItem(_lc[I_MENU_NO]);
2390 if TGameOption.TEAM_ABSORB_DAMAGE in gsGameFlags
2391 then ItemIndex := 0
2392 else ItemIndex := 1;
2393 end;
2394 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2395 begin
2396 Name := 'swDeathmatchKeys';
2397 AddItem(_lc[I_MENU_YES]);
2398 AddItem(_lc[I_MENU_NO]);
2399 if TGameOption.DM_KEYS in gsGameFlags
2400 then ItemIndex := 0
2401 else ItemIndex := 1;
2402 end;
2403 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2404 begin
2405 Name := 'swEnableExits';
2406 AddItem(_lc[I_MENU_YES]);
2407 AddItem(_lc[I_MENU_NO]);
2408 if TGameOption.ALLOW_EXIT in gsGameFlags
2409 then ItemIndex := 0
2410 else ItemIndex := 1;
2411 end;
2412 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2413 begin
2414 Name := 'swWeaponStay';
2415 AddItem(_lc[I_MENU_YES]);
2416 AddItem(_lc[I_MENU_NO]);
2417 if TGameOption.WEAPONS_STAY in gsGameFlags
2418 then ItemIndex := 0
2419 else ItemIndex := 1;
2420 end;
2421 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2422 begin
2423 Name := 'swMonsters';
2424 AddItem(_lc[I_MENU_YES]);
2425 AddItem(_lc[I_MENU_NO]);
2426 if TGameOption.MONSTERS in gsGameFlags
2427 then ItemIndex := 0
2428 else ItemIndex := 1;
2429 end;
2430 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2431 begin
2432 Name := 'swBotsVS';
2433 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2434 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2435 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2436 ItemIndex := 2;
2437 if not (TGameOption.BOTS_VS_MONSTERS in gsGameFlags) then
2438 ItemIndex := 0;
2439 if not (TGameOption.BOTS_VS_PLAYERS in gsGameFlags) then
2440 ItemIndex := 1;
2441 end;
2442 with AddSwitch(_lc[I_MENU_FLAG_DROP]) do
2443 begin
2444 Name := 'swFlagDrop';
2445 AddItem(_lc[I_MENU_FLAG_THROW]);
2446 AddItem(_lc[I_MENU_YES]);
2447 AddItem(_lc[I_MENU_NO]);
2448 if [TGameOption.ALLOW_DROP_FLAG, TGameOption.THROW_FLAG] <= gsGameFlags then
2449 ItemIndex := 0
2450 else if TGameOption.ALLOW_DROP_FLAG in gsGameFlags then
2451 ItemIndex := 1
2452 else
2453 ItemIndex := 2;
2454 end;
2455 AddSpace();
2456 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2458 ReAlign();
2459 end;
2460 Menu.DefControl := 'mNetServerMenu';
2461 g_GUI_AddWindow(Menu);
2463 Menu := TGUIWindow.Create('NetClientMenu');
2464 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2465 begin
2466 Name := 'mNetClientMenu';
2468 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2469 AddSpace();
2471 with AddEdit(_lc[I_NET_ADDRESS]) do
2472 begin
2473 Name := 'edIP';
2474 OnlyDigits := False;
2475 Width := 12;
2476 MaxLength := 64;
2477 Text := 'localhost';
2478 end;
2479 with AddEdit(_lc[I_NET_PORT]) do
2480 begin
2481 Name := 'edPort';
2482 OnlyDigits := True;
2483 Width := 4;
2484 MaxLength := 5;
2485 Text := '25666';
2486 end;
2487 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2488 begin
2489 Name := 'edPW';
2490 OnlyDigits := False;
2491 Width := 12;
2492 MaxLength := 32;
2493 Text := '';
2494 end;
2496 AddSpace();
2497 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2499 ReAlign();
2500 end;
2501 Menu.DefControl := 'mNetClientMenu';
2502 g_GUI_AddWindow(Menu);
2504 Menu := TGUIWindow.Create('LoadMenu');
2505 Menu.OnShow := ProcLoadMenu;
2506 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2507 begin
2508 Name := 'mmLoadMenu';
2510 for a := 1 to 8 do
2511 with AddEdit('') do
2512 begin
2513 Name := 'edSlot'+IntToStr(a);
2514 Width := 16;
2515 MaxLength := 16;
2516 OnEnter := ProcLoadGame;
2517 end;
2518 end;
2519 Menu.DefControl := 'mmLoadMenu';
2520 g_GUI_AddWindow(Menu);
2522 Menu := TGUIWindow.Create('SaveMenu');
2523 Menu.OnShow := ProcSaveMenu;
2524 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2525 begin
2526 Name := 'mmSaveMenu';
2528 for a := 1 to 8 do
2529 with AddEdit('') do
2530 begin
2531 Name := 'edSlot'+IntToStr(a);
2532 Width := 16;
2533 MaxLength := 16;
2534 OnChange := ProcSaveGame;
2535 end;
2536 end;
2537 Menu.DefControl := 'mmSaveMenu';
2538 g_GUI_AddWindow(Menu);
2540 Menu := TGUIWindow.Create('CustomGameMenu');
2541 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2542 begin
2543 Name := 'mCustomGameMenu';
2544 with AddLabel(_lc[I_MENU_MAP]) do
2545 begin
2546 Name := 'lbMap';
2547 FixedLength := 16;
2548 Text := gsMap;
2549 OnClick := @ProcSelectMapMenu;
2550 end;
2551 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2552 begin
2553 Name := 'swGameMode';
2554 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2555 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2556 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2557 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2558 case g_Game_TextToMode(gsGameMode) of
2559 GM_NONE,
2560 GM_DM: ItemIndex := 0;
2561 GM_TDM: ItemIndex := 1;
2562 GM_CTF: ItemIndex := 2;
2563 GM_SINGLE,
2564 GM_COOP: ItemIndex := 3;
2565 end;
2566 OnChange := ProcSwitchMonstersCustom;
2567 end;
2568 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2569 begin
2570 Name := 'edTimeLimit';
2571 OnlyDigits := True;
2572 Width := 4;
2573 MaxLength := 5;
2574 if gsTimeLimit > 0 then
2575 Text := IntToStr(gsTimeLimit);
2576 end;
2577 with AddEdit(_lc[I_MENU_SCORE_LIMIT]) do
2578 begin
2579 Name := 'edScoreLimit';
2580 OnlyDigits := True;
2581 Width := 4;
2582 MaxLength := 5;
2583 if gsScoreLimit > 0 then
2584 Text := IntToStr(gsScoreLimit);
2585 end;
2586 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2587 begin
2588 Name := 'edMaxLives';
2589 OnlyDigits := True;
2590 Width := 4;
2591 MaxLength := 5;
2592 if gsMaxLives > 0 then
2593 Text := IntToStr(gsMaxLives);
2594 end;
2595 with AddLabel(_lc[I_MENU_SELECT_ITEM_RESPAWN]) do
2596 begin
2597 Name := 'lbItemsRespawn';
2598 FixedLength := 16;
2599 OnClick := @ProcItemsRespawnMenu;
2600 end;
2601 AddSpace();
2602 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2603 begin
2604 Name := 'swPlayers';
2605 AddItem(_lc[I_MENU_COUNT_NONE]);
2606 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2607 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2608 ItemIndex := gsPlayers;
2609 end;
2610 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2611 begin
2612 Name := 'swTeamDamage';
2613 AddItem(_lc[I_MENU_YES]);
2614 AddItem(_lc[I_MENU_NO]);
2615 if TGameOption.TEAM_DAMAGE in gsGameFlags
2616 then ItemIndex := 0
2617 else ItemIndex := 1;
2618 end;
2619 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
2620 begin
2621 Name := 'swTeamHit';
2622 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
2623 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
2624 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
2625 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
2626 if [TGameOption.TEAM_HIT_TRACE, TGameOption.TEAM_HIT_PROJECTILE] <= gsGameFlags then
2627 ItemIndex := 0
2628 else if TGameOption.TEAM_HIT_TRACE in gsGameFlags then
2629 ItemIndex := 1
2630 else if TGameOption.TEAM_HIT_PROJECTILE in gsGameFlags then
2631 ItemIndex := 2
2632 else
2633 ItemIndex := 3;
2634 end;
2635 with AddSwitch(_lc[I_MENU_ENABLE_TEAM_DAMAGE_ABSOBR]) do
2636 begin
2637 Name := 'swTeamAbsorbDamage';
2638 AddItem(_lc[I_MENU_YES]);
2639 AddItem(_lc[I_MENU_NO]);
2640 if TGameOption.TEAM_ABSORB_DAMAGE in gsGameFlags
2641 then ItemIndex := 0
2642 else ItemIndex := 1;
2643 end;
2644 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2645 begin
2646 Name := 'swDeathmatchKeys';
2647 AddItem(_lc[I_MENU_YES]);
2648 AddItem(_lc[I_MENU_NO]);
2649 if TGameOption.DM_KEYS in gsGameFlags
2650 then ItemIndex := 0
2651 else ItemIndex := 1;
2652 end;
2653 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2654 begin
2655 Name := 'swEnableExits';
2656 AddItem(_lc[I_MENU_YES]);
2657 AddItem(_lc[I_MENU_NO]);
2658 if TGameOption.ALLOW_EXIT in gsGameFlags
2659 then ItemIndex := 0
2660 else ItemIndex := 1;
2661 end;
2662 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2663 begin
2664 Name := 'swWeaponStay';
2665 AddItem(_lc[I_MENU_YES]);
2666 AddItem(_lc[I_MENU_NO]);
2667 if TGameOption.WEAPONS_STAY in gsGameFlags
2668 then ItemIndex := 0
2669 else ItemIndex := 1;
2670 end;
2671 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2672 begin
2673 Name := 'swMonsters';
2674 AddItem(_lc[I_MENU_YES]);
2675 AddItem(_lc[I_MENU_NO]);
2676 if TGameOption.MONSTERS in gsGameFlags
2677 then ItemIndex := 0
2678 else ItemIndex := 1;
2679 end;
2680 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2681 begin
2682 Name := 'swBotsVS';
2683 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2684 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2685 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2686 ItemIndex := 2;
2687 if not (TGameOption.BOTS_VS_MONSTERS in gsGameFlags) then
2688 ItemIndex := 0;
2689 if not (TGameOption.BOTS_VS_PLAYERS in gsGameFlags) then
2690 ItemIndex := 1;
2691 end;
2692 with AddSwitch(_lc[I_MENU_FLAG_DROP]) do
2693 begin
2694 Name := 'swFlagDrop';
2695 AddItem(_lc[I_MENU_FLAG_THROW]);
2696 AddItem(_lc[I_MENU_YES]);
2697 AddItem(_lc[I_MENU_NO]);
2698 if [TGameOption.ALLOW_DROP_FLAG, TGameOption.THROW_FLAG] <= gsGameFlags then
2699 ItemIndex := 0
2700 else if TGameOption.ALLOW_DROP_FLAG in gsGameFlags then
2701 ItemIndex := 1
2702 else
2703 ItemIndex := 2;
2704 end;
2705 AddSpace();
2706 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2708 ReAlign();
2709 end;
2710 Menu.DefControl := 'mCustomGameMenu';
2711 g_GUI_AddWindow(Menu);
2713 Menu := TGUIWindow.Create('CampaignMenu');
2714 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2715 begin
2716 Name := 'mCampaignMenu';
2718 AddSpace();
2719 AddSpace();
2720 AddSpace();
2721 AddSpace();
2722 AddSpace();
2723 AddSpace();
2725 with AddFileList('', 15, 4) do
2726 begin
2727 Name := 'lsWAD';
2728 OnChange := ProcSelectCampaignWAD;
2730 Sort := True;
2731 Dirs := True;
2732 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2733 SetBase(MegawadDirs);
2734 end;
2736 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2737 begin
2738 Name := 'lbWADName';
2739 FixedLength := 8;
2740 Enabled := False;
2741 end;
2742 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2743 begin
2744 Name := 'lbWADAuthor';
2745 FixedLength := 8;
2746 Enabled := False;
2747 end;
2748 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2749 with AddMemo('', 15, 3) do
2750 begin
2751 Name := 'meWADDescription';
2752 Color := MENU_ITEMSCTRL_COLOR;
2753 end;
2754 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2755 begin
2756 Name := 'swPlayers';
2757 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2758 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2759 end;
2760 AddSpace();
2761 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2763 ReAlign();
2765 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2766 begin
2767 Name := 'mpWADImage';
2768 DefaultRes := 'NOPIC';
2769 X := GetControl('lsWAD').X+4;
2770 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2771 end;
2772 end;
2773 Menu.DefControl := 'mCampaignMenu';
2774 g_GUI_AddWindow(Menu);
2776 Menu := TGUIWindow.Create('SelectMapMenu');
2777 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2778 begin
2779 Name := 'mSelectMapMenu';
2780 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2781 begin
2782 Name := 'lsMapWAD';
2783 OnChange := ProcSelectWAD;
2785 Sort := True;
2786 Dirs := True;
2787 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2788 SetBase(MapDirs);
2789 end;
2790 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2791 begin
2792 Name := 'lsMapRes';
2793 Sort := True;
2794 OnChange := ProcSelectMap;
2795 end;
2796 AddSpace();
2797 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2798 begin
2799 Name := 'lbMapName';
2800 FixedLength := 24;
2801 Enabled := False;
2802 end;
2803 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2804 begin
2805 Name := 'lbMapAuthor';
2806 FixedLength := 16;
2807 Enabled := False;
2808 end;
2809 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2810 begin
2811 Name := 'lbMapSize';
2812 FixedLength := 10;
2813 Enabled := False;
2814 end;
2815 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 20, 4) do
2816 begin
2817 Name := 'meMapDescription';
2818 end;
2820 ReAlign();
2822 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2823 begin
2824 Name := 'mpMapPreview';
2825 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2826 Y := GetControl('lsMapWAD').Y;
2827 end;
2828 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2829 begin
2830 Name := 'lbMapScale';
2831 FixedLength := 8;
2832 Enabled := False;
2833 Color := MENU_ITEMSCTRL_COLOR;
2834 X := GetControl('lsMapWAD').X +
2835 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2836 2 + MAPPREVIEW_WIDTH*4;
2837 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2838 end;
2839 end;
2840 Menu.OnClose := ProcSetMap;
2841 Menu.DefControl := 'mSelectMapMenu';
2842 g_GUI_AddWindow(Menu);
2844 Menu := TGUIWindow.Create('ItemsRespawnMenu');
2845 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_ITEM_RESPAWN]))) do
2846 begin
2847 Name := 'mItemsRespawnMenu';
2849 // Switches separate from the time entry fields
2850 with AddSwitch(_lc[I_MENU_ENABLE_POWERUP_RANDOM]) do
2851 begin
2852 Name := 'swPowerupRandom';
2853 AddItem(_lc[I_MENU_YES]);
2854 AddItem(_lc[I_MENU_NO]);
2855 if TGameOption.POWERUP_RANDOM in gsGameFlags
2856 then ItemIndex := 0
2857 else ItemIndex := 1;
2858 end;
2859 with AddSwitch(_lc[I_MENU_ENABLE_ITEM_RANDOM]) do
2860 begin
2861 Name := 'swItemsRandom';
2862 AddItem(_lc[I_MENU_ITEM_RANDOM_ALL]);
2863 AddItem(_lc[I_MENU_ITEM_RANDOM_LIFE_ONLY]);
2864 AddItem(_lc[I_MENU_ITEM_RANDOM_AMMO_ONLY]);
2865 AddItem(_lc[I_MENU_ITEM_RANDOM_WEAPON_ONLY]);
2866 AddItem(_lc[I_MENU_ITEM_RANDOM_LIFE_AMMO]);
2867 AddItem(_lc[I_MENU_ITEM_RANDOM_LIFE_WEAPON]);
2868 AddItem(_lc[I_MENU_ITEM_RANDOM_WEAPON_AMMO]);
2869 AddItem(_lc[I_MENU_ITEM_RANDOM_NOTHING]);
2870 if TGameOption.ITEM_ALL_RANDOM in gsGameFlags then
2871 ItemIndex := 0
2872 else if TGameOption.ITEM_LIFE_RANDOM in gsGameFlags then
2873 ItemIndex := 1
2874 else if TGameOption.ITEM_AMMO_RANDOM in gsGameFlags then
2875 ItemIndex := 2
2876 else if TGameOption.ITEM_WEAPON_RANDOM in gsGameFlags then
2877 ItemIndex := 3
2878 else if [TGameOption.ITEM_LIFE_RANDOM, TGameOption.ITEM_AMMO_RANDOM] <= gsGameFlags then
2879 ItemIndex := 4
2880 else if [TGameOption.ITEM_LIFE_RANDOM, TGameOption.ITEM_WEAPON_RANDOM] <= gsGameFlags then
2881 ItemIndex := 5
2882 else if [TGameOption.ITEM_AMMO_RANDOM, TGameOption.ITEM_WEAPON_RANDOM] <= gsGameFlags then
2883 ItemIndex := 6
2884 else
2885 ItemIndex := 7;
2886 end;
2887 AddSpace();// Items Respawn block
2888 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2889 begin
2890 Name := 'edItemRespawnTime';
2891 OnlyDigits := True;
2892 Width := 4;
2893 MaxLength := 5;
2894 if gsItemRespawnTime > 0 then
2895 Text := IntToStr(gsItemRespawnTime);
2896 end;
2897 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_RANDOM]) do
2898 begin
2899 Name := 'edItemRespawnRandom';
2900 OnlyDigits := True;
2901 Width := 4;
2902 MaxLength := 5;
2903 if gsItemRespawnTime > 0 then
2904 Text := IntToStr(gsItemRespawnRandom);
2905 end;
2906 // Powerup Respawn block
2907 with AddEdit(_lc[I_MENU_POWERUP_RESPAWN_TIME]) do
2908 begin
2909 Name := 'edPowerupRespawnTime';
2910 OnlyDigits := True;
2911 Width := 4;
2912 MaxLength := 5;
2913 if gsPowerupRespawnTime > 0 then
2914 Text := IntToStr(gsPowerupRespawnTime);
2915 end;
2916 with AddEdit(_lc[I_MENU_POWERUP_RESPAWN_RANDOM]) do
2917 begin
2918 Name := 'edPowerupRespawnRandom';
2919 OnlyDigits := True;
2920 Width := 4;
2921 MaxLength := 5;
2922 if gsPowerupRespawnRandom > 0 then
2923 Text := IntToStr(gsPowerupRespawnRandom);
2924 end;
2925 AddSpace();
2926 end;
2927 Menu.DefControl := 'mItemsRespawnMenu';
2928 g_GUI_AddWindow(Menu);
2930 Menu := TGUIWindow.Create('OptionsMenu');
2931 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_OPTIONS]))) do
2932 begin
2933 Name := 'mmOptionsMenu';
2934 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2935 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2936 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2937 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2938 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2939 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2940 AddSpace();
2941 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2942 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2943 end;
2944 Menu.OnClose := ProcApplyOptions;
2945 Menu.DefControl := 'mmOptionsMenu';
2946 g_GUI_AddWindow(Menu);
2948 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2949 gMenuSmallFont, @ProcSavedMenuKeyDown);
2950 g_GUI_AddWindow(Menu);
2952 Menu := TGUIWindow.Create('OptionsVideoMenu');
2953 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2954 begin
2955 Name := 'mOptionsVideoMenu';
2956 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2957 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2958 begin
2959 Name := 'swBPP';
2960 AddItem('16');
2961 AddItem('32');
2962 end;
2963 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2964 begin
2965 Name := 'swVSync';
2966 AddItem(_lc[I_MENU_YES]);
2967 AddItem(_lc[I_MENU_NO]);
2968 end;
2969 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2970 begin
2971 Name := 'swTextureFilter';
2972 AddItem(_lc[I_MENU_YES]);
2973 AddItem(_lc[I_MENU_NO]);
2974 end;
2975 with AddSwitch(_lc[I_MENU_VIDEO_INTERPOLATION]) do
2976 begin
2977 Name := 'swInterp';
2978 AddItem(_lc[I_MENU_YES]);
2979 AddItem(_lc[I_MENU_NO]);
2980 end;
2981 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2982 begin
2983 Name := 'swLegacyNPOT';
2984 AddItem(_lc[I_MENU_NO]);
2985 AddItem(_lc[I_MENU_YES]);
2986 end;
2987 AddSpace();
2988 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2989 ReAlign();
2990 end;
2991 Menu.DefControl := 'mOptionsVideoMenu';
2992 g_GUI_AddWindow(Menu);
2994 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2995 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2996 begin
2997 Name := 'mOptionsVideoResMenu';
2998 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2999 begin
3000 Name := 'lbCurrentRes';
3001 FixedLength := 24;
3002 Enabled := False;
3003 end;
3004 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
3005 begin
3006 Name := 'lsResolution';
3007 Sort := False;
3008 end;
3009 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
3010 begin
3011 Name := 'swFullScreen';
3012 AddItem(_lc[I_MENU_YES]);
3013 AddItem(_lc[I_MENU_NO]);
3014 end;
3015 with AddSwitch(_lc[I_MENU_GAME_SCALE_FACTOR]) do
3016 begin
3017 Name := 'swResFactor';
3018 AddItem('1x');
3019 for i := 2 to gRC_Width div 640 do
3020 AddItem(IntToStr(i) + 'x');
3021 end;
3022 AddSpace();
3023 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
3024 UpdateIndex();
3025 end;
3026 Menu.DefControl := 'mOptionsVideoResMenu';
3027 g_GUI_AddWindow(Menu);
3029 Menu := TGUIWindow.Create('OptionsSoundMenu');
3030 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
3031 begin
3032 Name := 'mOptionsSoundMenu';
3033 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
3034 begin
3035 Name := 'scMusicLevel';
3036 Max := 16;
3037 OnChange := ProcChangeSoundSettings;
3038 end;
3039 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
3040 begin
3041 Name := 'scSoundLevel';
3042 Max := 16;
3043 OnChange := ProcChangeSoundSettings;
3044 end;
3045 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
3046 begin
3047 Name := 'scMaxSimSounds';
3048 Max := 16;
3049 end;
3050 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
3051 begin;
3052 Name := 'swAnnouncer';
3053 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
3054 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
3055 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
3056 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
3057 end;
3058 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
3059 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
3060 begin;
3061 Name := 'swSoundEffects';
3062 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
3063 AddItem(_lc[I_MENU_COMPAT_DF]);
3064 end;
3065 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
3066 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
3067 begin;
3068 Name := 'swChatSpeech';
3069 AddItem(_lc[I_MENU_YES]);
3070 AddItem(_lc[I_MENU_NO]);
3071 end;
3072 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
3073 begin
3074 Name := 'swInactiveSounds';
3075 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
3076 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
3077 end;
3078 ReAlign();
3079 end;
3080 Menu.DefControl := 'mOptionsSoundMenu';
3081 g_GUI_AddWindow(Menu);
3083 Menu := TGUIWindow.Create('OptionsGameMenu');
3084 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
3085 begin
3086 Name := 'mOptionsGameMenu';
3087 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
3088 begin
3089 Name := 'scParticlesCount';
3090 Max := 20;
3091 end;
3092 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
3093 begin
3094 Name := 'swBloodCount';
3095 AddItem(_lc[I_MENU_COUNT_NONE]);
3096 AddItem(_lc[I_MENU_COUNT_SMALL]);
3097 AddItem(_lc[I_MENU_COUNT_NORMAL]);
3098 AddItem(_lc[I_MENU_COUNT_BIG]);
3099 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
3100 end;
3101 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
3102 begin
3103 Name := 'scShellsMax';
3104 Max := 20;
3105 end;
3106 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
3107 begin
3108 Name := 'scGibsMax';
3109 Max := 20;
3110 end;
3111 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
3112 begin
3113 Name := 'scCorpsesMax';
3114 Max := 20;
3115 end;
3116 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
3117 begin
3118 Name := 'swGibsCount';
3119 AddItem(_lc[I_MENU_COUNT_NONE]);
3120 AddItem(_lc[I_MENU_COUNT_SMALL]);
3121 AddItem(_lc[I_MENU_COUNT_NORMAL]);
3122 AddItem(_lc[I_MENU_COUNT_BIG]);
3123 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
3124 end;
3125 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
3126 begin
3127 Name := 'swCorpseType';
3128 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
3129 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
3130 end;
3131 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
3132 begin
3133 Name := 'swGibsType';
3134 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
3135 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
3136 end;
3137 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
3138 begin
3139 Name := 'swBloodType';
3140 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
3141 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
3142 end;
3143 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
3144 begin
3145 Name := 'swScreenFlash';
3146 AddItem(_lc[I_MENU_NO]);
3147 AddItem(_lc[I_MENU_COMPAT_DF]);
3148 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
3149 end;
3150 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
3151 begin
3152 Name := 'swBackground';
3153 AddItem(_lc[I_MENU_YES]);
3154 AddItem(_lc[I_MENU_NO]);
3155 end;
3156 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
3157 begin
3158 Name := 'swMessages';
3159 AddItem(_lc[I_MENU_YES]);
3160 AddItem(_lc[I_MENU_NO]);
3161 end;
3162 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
3163 begin
3164 Name := 'swRevertPlayers';
3165 AddItem(_lc[I_MENU_YES]);
3166 AddItem(_lc[I_MENU_NO]);
3167 end;
3168 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
3169 begin
3170 Name := 'swChatBubble';
3171 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
3172 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
3173 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
3174 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
3175 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
3176 end;
3177 with AddSwitch(_lc[I_MENU_GAME_PLAYER_INDICATOR]) do
3178 begin
3179 Name := 'swPlayerIndicator';
3180 AddItem(_lc[I_MENU_GAME_INDICATOR_NONE]);
3181 AddItem(_lc[I_MENU_GAME_INDICATOR_OWN]);
3182 AddItem(_lc[I_MENU_GAME_INDICATOR_ALL]);
3183 end;
3184 with AddSwitch(_lc[I_MENU_GAME_INDICATOR_STYLE]) do
3185 begin
3186 Name := 'swPlayerIndicatorStyle';
3187 AddItem(_lc[I_MENU_GAME_INDICATOR_ARROW]);
3188 AddItem(_lc[I_MENU_GAME_INDICATOR_NAME]);
3189 end;
3190 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
3191 begin
3192 Name := 'scScaleFactor';
3193 Max := 10;
3194 OnChange := ProcChangeGameSettings;
3195 end;
3196 ReAlign();
3197 end;
3198 Menu.DefControl := 'mOptionsGameMenu';
3199 g_GUI_AddWindow(Menu);
3201 Menu := TGUIWindow.Create('OptionsControlsMenu');
3202 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
3203 begin
3204 Name := 'mOptionsControlsMenu';
3205 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
3206 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
3207 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
3208 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
3209 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
3210 AddSpace();
3211 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
3212 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
3213 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
3214 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
3215 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
3216 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
3217 if e_HasJoysticks then
3218 begin
3219 AddSpace();
3220 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
3221 end;
3222 if g_touch_enabled then
3223 begin
3224 AddSpace();
3225 AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
3226 end;
3227 end;
3228 Menu.DefControl := 'mOptionsControlsMenu';
3229 g_GUI_AddWindow(Menu);
3231 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
3232 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
3233 begin
3234 Name := 'mOptionsControlsP1Menu';
3235 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
3236 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
3237 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
3238 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
3239 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
3240 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
3241 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
3242 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
3243 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
3244 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
3245 AddKeyRead2(_lc[I_MENU_CONTROL_DROPFLAG]).Name := _lc[I_MENU_CONTROL_DROPFLAG];
3246 end;
3247 Menu.DefControl := 'mOptionsControlsP1Menu';
3248 g_GUI_AddWindow(Menu);
3250 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
3251 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
3252 begin
3253 Name := 'mOptionsControlsP1MenuWeapons';
3254 for i := WP_FIRST to WP_LAST do
3255 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
3256 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
3257 end;
3258 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
3259 g_GUI_AddWindow(Menu);
3261 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
3262 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
3263 begin
3264 Name := 'mOptionsControlsP2Menu';
3265 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
3266 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
3267 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
3268 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
3269 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
3270 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
3271 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
3272 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
3273 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
3274 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
3275 AddKeyRead2(_lc[I_MENU_CONTROL_DROPFLAG]).Name := _lc[I_MENU_CONTROL_DROPFLAG];
3276 end;
3277 Menu.DefControl := 'mOptionsControlsP2Menu';
3278 g_GUI_AddWindow(Menu);
3280 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
3281 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
3282 begin
3283 Name := 'mOptionsControlsP2MenuWeapons';
3284 for i := WP_FIRST to WP_LAST do
3285 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
3286 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
3287 end;
3288 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
3289 g_GUI_AddWindow(Menu);
3291 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
3292 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
3293 begin
3294 Name := 'mOptionsControlsJoystickMenu';
3295 for i := 0 to e_MaxJoys - 1 do
3296 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
3297 begin
3298 Name := 'scDeadzone' + IntToStr(i);
3299 Max := 20
3300 end
3301 end;
3302 Menu.DefControl := 'mOptionsControlsJoystickMenu';
3303 g_GUI_AddWindow(Menu);
3305 Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
3306 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do
3307 begin
3308 Name := 'mOptionsControlsTouchMenu';
3309 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
3310 begin
3311 Name := 'swTouchAlt';
3312 AddItem(_lc[I_MENU_NO]);
3313 AddItem(_lc[I_MENU_YES]);
3314 OnChange := ProcChangeTouchSettings;
3315 end;
3316 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
3317 begin
3318 Name := 'scTouchSize';
3319 Max := 20;
3320 OnChange := ProcChangeTouchSettings;
3321 end;
3322 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
3323 begin
3324 Name := 'swTouchFire';
3325 AddItem(_lc[I_MENU_NO]);
3326 AddItem(_lc[I_MENU_YES]);
3327 end;
3328 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do
3329 begin
3330 Name := 'scTouchOffset';
3331 Max := 20;
3332 OnChange := ProcChangeTouchSettings;
3333 end;
3334 end;
3335 Menu.DefControl := 'mOptionsControlsTouchMenu';
3336 g_GUI_AddWindow(Menu);
3338 Menu := TGUIWindow.Create('OptionsPlayersMenu');
3339 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
3340 begin
3341 Name := 'mOptionsPlayersMenu';
3342 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
3343 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
3344 end;
3345 Menu.DefControl := 'mOptionsPlayersMenu';
3346 g_GUI_AddWindow(Menu);
3348 CreatePlayerOptionsMenu('P1');
3349 CreatePlayerOptionsMenu('P2');
3351 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
3352 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
3353 begin
3354 Name := 'mOptionsPlayersMIMenu';
3355 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
3356 begin
3357 Name := 'lbName';
3358 FixedLength := 16;
3359 end;
3360 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
3361 begin
3362 Name := 'lbAuthor';
3363 FixedLength := 16;
3364 end;
3365 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
3366 begin
3367 Name := 'meComment';
3368 end;
3369 AddSpace();
3370 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
3371 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
3372 begin
3373 Name := 'lbWeapon';
3374 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
3375 end;
3376 ReAlign();
3377 end;
3378 Menu.DefControl := 'mOptionsPlayersMIMenu';
3379 g_GUI_AddWindow(Menu);
3381 Menu := TGUIWindow.Create('OptionsPlayersP1WeaponMenu');
3382 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_WEAPON]))) do
3383 begin
3384 Name := 'mOptionsPlayersP1WeaponMenu';
3385 with AddSwitch(_lc[I_MENU_WEAPON_SWITCH]) do
3386 begin
3387 Name := 'swWeaponAutoswitch';
3388 AddItem(_lc[I_MENU_NO]);
3389 AddItem(_lc[I_MENU_WEAPON_SWITCH_LINEAR]);
3390 AddItem(_lc[I_MENU_WEAPON_SWITCH_PREFERENCE]);
3391 end;
3392 with AddSwitch(_lc[I_MENU_WEAPON_ALLOW_EMPTY]) do
3393 begin
3394 Name := 'swWeaponAllowEmpty';
3395 AddItem(_lc[I_MENU_YES]);
3396 AddItem(_lc[I_MENU_NO]);
3397 end;
3398 with AddSwitch(_lc[I_MENU_IRONFIST_ALLOW]) do
3399 begin
3400 Name := 'swWeaponAllowIronFist';
3401 AddItem(_lc[I_MENU_IRONFIST_ALLOW_ALWAYS]);
3402 AddItem(_lc[I_MENU_IRONFIST_ALLOW_BERSERK]);
3403 end;
3404 AddButton(@ProcOptionsPlayerP1WeaponPreferencesMenu, _lc[I_MENU_WEAPON_SWITCH_PRIORITY]);
3405 ReAlign();
3406 end;
3407 Menu.DefControl := 'mOptionsPlayersP1WeaponMenu';
3408 g_GUI_AddWindow(Menu);
3410 Menu := TGUIWindow.Create('OptionsPreferencesP1WeaponMenu');
3411 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_WEAPON_PRIORITY_PLAYER_1]))) do
3412 begin
3413 Name := 'mOptionsPreferencesP1WeaponMenu';
3414 for i := WP_FIRST to WP_LAST do
3415 begin
3416 with AddSwitch(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]) do
3417 begin
3418 Name := IntToStr(i);
3419 for a := WP_FIRST to WP_LAST+1 do
3420 begin
3421 AddItem(IntToStr(a));
3422 end;
3423 ItemIndex := i
3424 end;
3425 end;
3426 with AddSwitch(_lc[I_GAME_WEAPON_BERSERK]) do
3427 begin
3428 Name := IntToStr(WP_LAST+1);
3429 for a := WP_FIRST to WP_LAST+1 do
3430 begin
3431 AddItem(IntToStr(a));
3432 end;
3433 ItemIndex := WP_LAST + 1;
3434 end;
3435 end;
3436 Menu.DefControl := 'mOptionsPreferencesP1WeaponMenu';
3437 g_GUI_AddWindow(Menu);
3440 Menu := TGUIWindow.Create('OptionsPlayersP2WeaponMenu');
3441 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_WEAPON]))) do
3442 begin
3443 Name := 'mOptionsPlayersP2WeaponMenu';
3444 with AddSwitch(_lc[I_MENU_WEAPON_SWITCH]) do
3445 begin
3446 Name := 'swWeaponAutoswitch';
3447 AddItem(_lc[I_MENU_NO]);
3448 AddItem(_lc[I_MENU_WEAPON_SWITCH_LINEAR]);
3449 AddItem(_lc[I_MENU_WEAPON_SWITCH_PREFERENCE]);
3450 end;
3451 with AddSwitch(_lc[I_MENU_WEAPON_ALLOW_EMPTY]) do
3452 begin
3453 Name := 'swWeaponAllowEmpty';
3454 AddItem(_lc[I_MENU_YES]);
3455 AddItem(_lc[I_MENU_NO]);
3456 end;
3457 with AddSwitch(_lc[I_MENU_IRONFIST_ALLOW]) do
3458 begin
3459 Name := 'swWeaponAllowIronFist';
3460 AddItem(_lc[I_MENU_IRONFIST_ALLOW_ALWAYS]);
3461 AddItem(_lc[I_MENU_IRONFIST_ALLOW_BERSERK]);
3462 end;
3463 AddButton(@ProcOptionsPlayerP2WeaponPreferencesMenu, _lc[I_MENU_WEAPON_SWITCH_PRIORITY]);
3464 ReAlign();
3465 end;
3466 Menu.DefControl := 'mOptionsPlayersP2WeaponMenu';
3467 g_GUI_AddWindow(Menu);
3469 Menu := TGUIWindow.Create('OptionsPreferencesP2WeaponMenu');
3470 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_WEAPON_PRIORITY_PLAYER_2]))) do
3471 begin
3472 Name := 'mOptionsPreferencesP2WeaponMenu';
3473 for i := WP_FIRST to WP_LAST do
3474 begin
3475 with AddSwitch(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]) do
3476 begin
3477 Name := IntToStr(i);
3478 for a := WP_FIRST to WP_LAST+1 do
3479 begin
3480 AddItem(IntToStr(a));
3481 end;
3482 ItemIndex := i
3483 end;
3484 end;
3485 with AddSwitch(_lc[I_GAME_WEAPON_BERSERK]) do
3486 begin
3487 Name := IntToStr(WP_LAST+1);
3488 for a := WP_FIRST to WP_LAST+1 do
3489 begin
3490 AddItem(IntToStr(a));
3491 end;
3492 ItemIndex := WP_LAST + 1;
3493 end;
3494 end;
3495 Menu.DefControl := 'mOptionsPreferencesP2WeaponMenu';
3496 g_GUI_AddWindow(Menu);
3498 Menu := TGUIWindow.Create('OptionsLanguageMenu');
3499 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
3500 begin
3501 Name := 'mOptionsLanguageMenu';
3502 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
3503 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
3504 ReAlign();
3505 end;
3506 Menu.DefControl := 'mOptionsLanguageMenu';
3507 g_GUI_AddWindow(Menu);
3509 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
3510 gMenuSmallFont, @ProcDefaultMenuKeyDown);
3511 g_GUI_AddWindow(Menu);
3513 Menu := TGUIWindow.Create('AuthorsMenu');
3514 Menu.BackTexture := 'INTER';
3515 Menu.OnClose := ProcAuthorsClose;
3517 // Çàãîëîâîê:
3518 _y := 16;
3519 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
3520 begin
3521 Color := _RGB(255, 0, 0);
3522 X := (gScreenWidth div 2)-(GetWidth() div 2);
3523 Y := _y;
3524 _y := _y+GetHeight();
3525 end;
3526 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
3527 begin
3528 Color := _RGB(255, 0, 0);
3529 X := (gScreenWidth div 2)-(GetWidth() div 2);
3530 Y := _y;
3531 _y := _y+GetHeight()+32;
3532 end;
3533 // ×òî äåëàë: Êòî äåëàë
3534 cx := gScreenWidth div 2 - 320 + 64;
3535 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
3536 begin
3537 Color := _RGB(255, 0, 0);
3538 X := cx;
3539 Y := _y;
3540 _y := _y+22;
3541 end;
3542 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
3543 begin
3544 Color := _RGB(255, 255, 255);
3545 X := cx+32;
3546 Y := _y;
3547 _y := _y+36;
3548 end;
3549 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
3550 begin
3551 Color := _RGB(255, 0, 0);
3552 X := cx;
3553 Y := _y;
3554 _y := _y+22;
3555 end;
3556 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
3557 begin
3558 Color := _RGB(255, 255, 255);
3559 X := cx+32;
3560 Y := _y;
3561 _y := _y+22;
3562 end;
3563 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
3564 begin
3565 Color := _RGB(255, 255, 255);
3566 X := cx+32;
3567 Y := _y;
3568 _y := _y+36;
3569 end;
3570 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
3571 begin
3572 Color := _RGB(255, 0, 0);
3573 X := cx;
3574 Y := _y;
3575 _y := _y+22;
3576 end;
3577 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
3578 begin
3579 Color := _RGB(255, 255, 255);
3580 X := cx+32;
3581 Y := _y;
3582 _y := _y+36;
3583 end;
3584 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
3585 begin
3586 Color := _RGB(255, 0, 0);
3587 X := cx;
3588 Y := _y;
3589 _y := _y+22;
3590 end;
3591 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
3592 begin
3593 Color := _RGB(255, 255, 255);
3594 X := cx+32;
3595 Y := _y;
3596 _y := gScreenHeight - 128;
3597 end;
3598 // Çàêëþ÷åíèå:
3599 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
3600 begin
3601 Color := _RGB(255, 0, 0);
3602 X := cx;
3603 Y := _y;
3604 _y := _y+16;
3605 end;
3606 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
3607 begin
3608 Color := _RGB(255, 255, 255);
3609 X := cx+32;
3610 Y := _y;
3611 _y := _y+GetHeight();
3612 end;
3613 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
3614 begin
3615 Color := _RGB(255, 255, 255);
3616 X := cx+32;
3617 Y := _y;
3618 _y := _y+GetHeight();
3619 end;
3620 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
3621 begin
3622 Color := _RGB(255, 255, 255);
3623 X := cx+32;
3624 Y := _y;
3625 _y := gScreenHeight - 32;
3626 end;
3627 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
3628 begin
3629 Color := _RGB(255, 0, 0);
3630 X := gScreenWidth div 2 - GetWidth() div 2;
3631 Y := _y;
3632 end;
3633 g_GUI_AddWindow(Menu);
3635 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
3636 gMenuSmallFont, @ProcExitMenuKeyDown);
3637 g_GUI_AddWindow(Menu);
3639 Menu := TGUIWindow.Create('GameSingleMenu');
3640 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3641 begin
3642 Name := 'mmGameSingleMenu';
3643 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3644 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3645 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3646 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3647 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3648 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3649 end;
3650 Menu.DefControl := 'mmGameSingleMenu';
3651 Menu.MainWindow := True;
3652 Menu.OnClose := ProcGMClose;
3653 Menu.OnShow := ProcGMShow;
3654 g_GUI_AddWindow(Menu);
3656 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
3657 gMenuSmallFont, @ProcEndMenuKeyDown);
3658 g_GUI_AddWindow(Menu);
3660 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
3661 gMenuSmallFont, @ProcRestartMenuKeyDown);
3662 g_GUI_AddWindow(Menu);
3664 Menu := TGUIWindow.Create('GameCustomMenu');
3665 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3666 begin
3667 Name := 'mmGameCustomMenu';
3668 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3669 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3670 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3671 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3672 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3673 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3674 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3675 end;
3676 Menu.DefControl := 'mmGameCustomMenu';
3677 Menu.MainWindow := True;
3678 Menu.OnClose := ProcGMClose;
3679 Menu.OnShow := ProcGMShow;
3680 g_GUI_AddWindow(Menu);
3682 Menu := TGUIWindow.Create('GameServerMenu');
3683 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3684 begin
3685 Name := 'mmGameServerMenu';
3686 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3687 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3688 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3689 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3690 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3691 end;
3692 Menu.DefControl := 'mmGameServerMenu';
3693 Menu.MainWindow := True;
3694 Menu.OnClose := ProcGMClose;
3695 Menu.OnShow := ProcGMShow;
3696 g_GUI_AddWindow(Menu);
3698 Menu := TGUIWindow.Create('GameClientMenu');
3699 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3700 begin
3701 Name := 'mmGameClientMenu';
3702 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3703 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3704 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3705 end;
3706 Menu.DefControl := 'mmGameClientMenu';
3707 Menu.MainWindow := True;
3708 Menu.OnClose := ProcGMClose;
3709 Menu.OnShow := ProcGMShow;
3710 g_GUI_AddWindow(Menu);
3712 Menu := TGUIWindow.Create('ClientPasswordMenu');
3713 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
3714 begin
3715 Name := 'mClientPasswordMenu';
3716 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3717 begin
3718 Name := 'edPW';
3719 Width := 12;
3720 MaxLength := 32;
3721 end;
3722 AddSpace;
3724 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3725 ReAlign();
3726 end;
3727 Menu.DefControl := 'mClientPasswordMenu';
3728 g_GUI_AddWindow(Menu);
3730 Menu := TGUIWindow.Create('GameSetGameMenu');
3731 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3732 begin
3733 Name := 'mGameSetGameMenu';
3734 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3735 begin
3736 Name := 'swTeamDamage';
3737 AddItem(_lc[I_MENU_YES]);
3738 AddItem(_lc[I_MENU_NO]);
3739 ItemIndex := 1;
3740 end;
3741 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
3742 begin
3743 Name := 'swTeamHit';
3744 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
3745 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
3746 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
3747 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
3748 ItemIndex := 0
3749 end;
3750 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
3751 begin
3752 Name := 'swDeathmatchKeys';
3753 AddItem(_lc[I_MENU_YES]);
3754 AddItem(_lc[I_MENU_NO]);
3755 ItemIndex := 1;
3756 end;
3757 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3758 begin
3759 Name := 'edTimeLimit';
3760 OnlyDigits := True;
3761 Width := 4;
3762 MaxLength := 5;
3763 end;
3764 with AddEdit(_lc[I_MENU_SCORE_LIMIT]) do
3765 begin
3766 Name := 'edScoreLimit';
3767 OnlyDigits := True;
3768 Width := 4;
3769 MaxLength := 5;
3770 end;
3771 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3772 begin
3773 Name := 'edMaxLives';
3774 OnlyDigits := True;
3775 Width := 4;
3776 MaxLength := 5;
3777 end;
3778 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3779 begin
3780 Name := 'swBotsVS';
3781 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3782 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3783 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3784 ItemIndex := 2;
3785 end;
3786 with AddSwitch(_lc[I_MENU_FLAG_DROP]) do
3787 begin
3788 Name := 'swFlagDrop';
3789 AddItem(_lc[I_MENU_FLAG_THROW]);
3790 AddItem(_lc[I_MENU_YES]);
3791 AddItem(_lc[I_MENU_NO]);
3792 ItemIndex := 2;
3793 end;
3795 ReAlign();
3796 end;
3797 Menu.DefControl := 'mGameSetGameMenu';
3798 Menu.OnClose := ProcApplyGameSet;
3799 g_GUI_AddWindow(Menu);
3801 Menu := TGUIWindow.Create('TeamMenu');
3802 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_CHANGE_PLAYERS]))) do
3803 begin
3804 Name := 'mmTeamMenu';
3805 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3806 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3807 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3808 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3809 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3810 end;
3811 Menu.DefControl := 'mmTeamMenu';
3812 Menu.OnShow := ProcChangePlayers;
3813 g_GUI_AddWindow(Menu);
3814 end;
3816 procedure g_Menu_Show_SaveMenu();
3817 begin
3818 if g_Game_IsTestMap then
3819 Exit;
3820 if gGameSettings.GameType = GT_SINGLE then
3821 g_GUI_ShowWindow('GameSingleMenu')
3822 else
3823 begin
3824 if g_Game_IsClient then
3825 Exit
3826 else
3827 if g_Game_IsNet then
3828 Exit
3829 else
3830 g_GUI_ShowWindow('GameCustomMenu');
3831 end;
3832 g_GUI_ShowWindow('SaveMenu');
3833 g_Sound_PlayEx('MENU_OPEN');
3834 end;
3836 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3837 begin
3838 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3839 if gGameSettings.GameType = GT_SINGLE then
3840 begin
3841 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3842 end
3843 else
3844 begin
3845 if g_Game_IsClient then exit;
3846 if g_Game_IsNet then exit;
3847 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3848 end;
3849 g_GUI_ShowWindow('LoadMenu');
3850 g_Sound_PlayEx('MENU_OPEN');
3851 end;
3853 procedure g_Menu_Show_GameSetGame();
3854 begin
3855 if gGameSettings.GameType = GT_SINGLE then
3856 g_GUI_ShowWindow('GameSingleMenu')
3857 else
3858 begin
3859 if g_Game_IsClient then
3860 Exit
3861 else
3862 if g_Game_IsNet then
3863 g_GUI_ShowWindow('GameServerMenu')
3864 else
3865 g_GUI_ShowWindow('GameCustomMenu');
3866 end;
3867 ReadGameSettings();
3868 g_GUI_ShowWindow('GameSetGameMenu');
3869 g_Sound_PlayEx('MENU_OPEN');
3870 end;
3872 procedure g_Menu_Show_OptionsVideo();
3873 begin
3874 if gGameSettings.GameType = GT_SINGLE then
3875 g_GUI_ShowWindow('GameSingleMenu')
3876 else
3877 begin
3878 if g_Game_IsClient then
3879 g_GUI_ShowWindow('GameClientMenu')
3880 else
3881 if g_Game_IsNet then
3882 g_GUI_ShowWindow('GameServerMenu')
3883 else
3884 g_GUI_ShowWindow('GameCustomMenu');
3885 end;
3886 ReadOptions();
3887 g_GUI_ShowWindow('OptionsMenu');
3888 g_GUI_ShowWindow('OptionsVideoMenu');
3889 g_Sound_PlayEx('MENU_OPEN');
3890 end;
3892 procedure g_Menu_Show_OptionsSound();
3893 begin
3894 if gGameSettings.GameType = GT_SINGLE then
3895 g_GUI_ShowWindow('GameSingleMenu')
3896 else
3897 begin
3898 if g_Game_IsClient then
3899 g_GUI_ShowWindow('GameClientMenu')
3900 else
3901 if g_Game_IsNet then
3902 g_GUI_ShowWindow('GameServerMenu')
3903 else
3904 g_GUI_ShowWindow('GameCustomMenu');
3905 end;
3906 ReadOptions();
3907 g_GUI_ShowWindow('OptionsMenu');
3908 g_GUI_ShowWindow('OptionsSoundMenu');
3909 g_Sound_PlayEx('MENU_OPEN');
3910 end;
3912 procedure g_Menu_Show_EndGameMenu();
3913 begin
3914 g_GUI_ShowWindow('EndGameMenu');
3915 g_Sound_PlayEx('MENU_OPEN');
3916 end;
3918 procedure g_Menu_Show_QuitGameMenu();
3919 begin
3920 g_GUI_ShowWindow('ExitMenu');
3921 g_Sound_PlayEx('MENU_OPEN');
3922 end;
3924 procedure g_Menu_Init();
3925 begin
3926 MenuLoadData();
3927 g_GUI_Init();
3928 CreateAllMenus();
3929 end;
3931 procedure g_Menu_Free();
3932 begin
3933 g_GUI_Destroy();
3935 e_WriteLog('Releasing menu data...', TMsgType.Notify);
3937 MenuFreeData();
3938 end;
3940 procedure g_Menu_Reset();
3941 var
3942 ex: Boolean;
3943 begin
3944 g_GUI_SaveMenuPos();
3945 ex := g_GUI_Destroy();
3947 if ex then
3948 begin
3949 e_WriteLog('Recreating menu...', TMsgType.Notify);
3951 CreateAllMenus();
3953 if gDebugMode then
3954 g_Game_SetDebugMode();
3956 g_GUI_LoadMenuPos();
3957 end;
3958 end;
3960 end.