DEADSOFTWARE

8cd9363c8da74eb2112b972339e9eab2fa7528a1
[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.SkipFist := TGUISwitch(menu.GetControl('swWeaponAllowFist')).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.SkipFist := TGUISwitch(menu.GetControl('swWeaponAllowFist')).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.SkipFist := gPlayer1Settings.SkipFist;
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.SkipFist := gPlayer2Settings.SkipFist;
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('swWeaponAllowFist')).ItemIndex := gPlayer1Settings.SkipFist;
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('swWeaponAllowFist')).ItemIndex := gPlayer2Settings.SkipFist;
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 := 0;
742 if TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0 then
743 gsGameFlags := gsGameFlags or GAME_OPTION_TEAMDAMAGE;
744 if TGUISwitch(GetControl('swTeamAbsorbDamage')).ItemIndex = 0 then
745 gsGameFlags := gsGameFlags or GAME_OPTION_TEAMABSORBDAMAGE;
746 if TGUISwitch(GetControl('swDeathmatchKeys')).ItemIndex = 0 then
747 gsGameFlags := gsGameFlags or GAME_OPTION_DMKEYS;
748 if TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0 then
749 gsGameFlags := gsGameFlags or GAME_OPTION_ALLOWEXIT;
750 if TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0 then
751 gsGameFlags := gsGameFlags or GAME_OPTION_WEAPONSTAY;
752 if TGUISwitch(GetControl('swMonsters')).ItemIndex = 0 then
753 gsGameFlags := gsGameFlags or GAME_OPTION_MONSTERS;
755 case TGUISwitch(GetControl('swTeamHit')).ItemIndex of
756 1: gsGameFlags := gsGameFlags or GAME_OPTION_TEAMHITTRACE;
757 2: gsGameFlags := gsGameFlags or GAME_OPTION_TEAMHITPROJECTILE;
758 0: gsGameFlags := gsGameFlags or GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE;
759 end;
761 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
762 1: gsGameFlags := gsGameFlags or GAME_OPTION_BOTVSMONSTER;
763 2: gsGameFlags := gsGameFlags or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
764 else gsGameFlags := gsGameFlags or GAME_OPTION_BOTVSPLAYER;
765 end;
767 case TGUISwitch(GetControl('swFlagDrop')).ItemIndex of
768 0: gsGameFlags := gsGameFlags or GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG;
769 1: gsGameFlags := gsGameFlags or GAME_OPTION_ALLOWDROPFLAG;
770 else gsGameFlags := gsGameFlags and not (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG);
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 gsRulezRespawnTime := StrToIntDef(TGUIEdit(GetControl('edRulezRespawnTime')).Text, 0);
784 gsRulezRespawnRandom := StrToIntDef(TGUIEdit(GetControl('edRulezRespawnRandom')).Text, 0);
786 if TGUISwitch(GetControl('swRulezRandom')).ItemIndex = 0 then
787 gsGameFlags := gsGameFlags or GAME_OPTION_RULEZRANDOM;
789 case TGUISwitch(GetControl('swItemsRandom')).ItemIndex of
790 1: gsGameFlags := gsGameFlags or GAME_OPTION_ITEMHELPRANDOM;
791 2: gsGameFlags := gsGameFlags or GAME_OPTION_ITEMAMMORANDOM;
792 3: gsGameFlags := gsGameFlags or GAME_OPTION_ITEMWEAPONRANDOM;
793 0: gsGameFlags := gsGameFlags or GAME_OPTION_ITEMALLRANDOM;
794 end;
796 // TODO: get this crap out of here
797 gGameSettings.ItemRespawnTime := gsItemRespawnTime;
798 gGameSettings.ItemRespawnRandom := gsItemRespawnRandom;
799 gGameSettings.RulezRespawnTime := gsRulezRespawnTime;
800 gGameSettings.RulezRespawnRandom := gsRulezRespawnRandom;
801 end;
802 end;
804 procedure ProcStartCustomGame();
805 var
806 GameMode: Byte;
807 begin
808 GameMode := LatchGameOptions('mCustomGameMenu');
809 if GameMode = GM_NONE then Exit;
811 g_Console_WriteGameConfig;
812 g_Game_StartCustom(gsMap, GameMode, gsTimeLimit, gsScoreLimit,
813 gsMaxLives, gsGameFlags, gsPlayers);
814 end;
817 procedure ProcStartNetGame();
818 var
819 GameMode: Byte;
820 begin
821 GameMode := LatchGameOptions('mNetServerMenu');
822 if GameMode = GM_NONE then Exit;
824 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
825 begin
826 NetPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
827 NetServerName := TGUIEdit(GetControl('edSrvName')).Text;
828 NetMaxClients := Max(1, StrToIntDef(TGUIEdit(GetControl('edMaxPlayers')).Text, 1));
829 NetMaxClients := Min(NET_MAXCLIENTS, NetMaxClients);
830 NetPassword := TGUIEdit(GetControl('edSrvPassword')).Text;
831 NetUseMaster := TGUISwitch(GetControl('swUseMaster')).ItemIndex = 0;
832 end;
834 g_Console_WriteGameConfig;
835 g_Game_StartServer(gsMap, GameMode, gsTimeLimit, gsScoreLimit, gsMaxLives,
836 gsGameFlags, gsPlayers, 0, NetPort);
837 end;
839 procedure ProcConnectNetGame();
840 var
841 PW: String;
842 begin
843 with TGUIMenu(g_ActiveWindow.GetControl('mNetClientMenu')) do
844 begin
845 NetClientIP := TGUIEdit(GetControl('edIP')).Text;
846 NetClientPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
847 PW := TGUIEdit(GetControl('edPW')).Text;
848 end;
850 g_Console_WriteGameConfig;
851 g_Game_StartClient(NetClientIP, NetClientPort, PW);
852 end;
854 procedure ProcEnterPassword();
855 var
856 PW: string;
857 begin
858 with TGUIMenu(g_ActiveWindow.GetControl('mClientPasswordMenu')) do
859 begin
860 NetClientIP := PromptIP;
861 NetClientPort := PromptPort;
862 PW := TGUIEdit(GetControl('edPW')).Text;
863 end;
865 g_Console_WriteGameConfig;
866 g_Game_StartClient(NetClientIP, NetClientPort, PW);
867 end;
869 procedure ProcServerlist();
870 begin
871 if not NetInitDone then
872 begin
873 if (not g_Net_Init()) then
874 begin
875 g_Console_Add('NET: ERROR: Failed to init ENet!');
876 Exit;
877 end
878 else
879 NetInitDone := True;
880 end;
882 g_Net_Slist_Set(NetMasterList);
884 gState := STATE_SLIST;
885 g_ActiveWindow := nil;
887 slWaitStr := _lc[I_NET_SLIST_WAIT];
889 g_Game_Draw;
890 sys_Repaint;
892 slReturnPressed := True;
893 if g_Net_Slist_Fetch(slCurrent) then
894 begin
895 if slCurrent = nil then
896 slWaitStr := _lc[I_NET_SLIST_NOSERVERS];
897 end
898 else
899 slWaitStr := _lc[I_NET_SLIST_ERROR];
900 g_Serverlist_GenerateTable(slCurrent, slTable);
901 end;
903 procedure ProcStartCampaign();
904 var
905 WAD: String;
906 TwoPlayers: Boolean;
907 n: Byte;
908 begin
909 with TGUIMenu(g_ActiveWindow.GetControl('mCampaignMenu')) do
910 begin
911 WAD := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
912 TwoPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex = 1;
913 end;
914 WAD := e_FindWadRel(MegawadDirs, WAD);
916 if TwoPlayers then
917 n := 2
918 else
919 n := 1;
920 g_Game_StartSingle(WAD + ':\MAP01', TwoPlayers, n);
921 end;
923 procedure ProcSelectMap(Sender: TGUIControl);
924 var
925 win: TGUIWindow;
926 a: TMapInfo;
927 wad, map, res: String;
928 begin
929 win := g_GUI_GetWindow('SelectMapMenu');
930 with TGUIMenu(win.GetControl('mSelectMapMenu')) do
931 begin
932 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
933 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
935 if (wad = '') or (map = '') then
936 begin // Ýòî íå êàðòà
937 TGUILabel(GetControl('lbMapName')).Text := '';
938 TGUILabel(GetControl('lbMapAuthor')).Text := '';
939 TGUILabel(GetControl('lbMapSize')).Text := '';
940 TGUIMemo(GetControl('meMapDescription')).SetText('');
941 TGUIMapPreview(win.GetControl('mpMapPreview')).ClearMap();
942 TGUILabel(win.GetControl('lbMapScale')).Text := '';
943 end
944 else // Ýòî êàðòà
945 begin
946 res := wad+':\'+map;
948 a := g_Map_GetMapInfo(res);
950 TGUILabel(GetControl('lbMapName')).Text := a.Name;
951 TGUILabel(GetControl('lbMapAuthor')).Text := a.Author;
952 TGUILabel(GetControl('lbMapSize')).Text := Format('%dx%d', [a.Width, a.Height]);
953 TGUIMemo(GetControl('meMapDescription')).SetText(a.Description);
954 TGUIMapPreview(win.GetControl('mpMapPreview')).SetMap(res);
955 TGUILabel(win.GetControl('lbMapScale')).Text :=
956 TGUIMapPreview(win.GetControl('mpMapPreview')).GetScaleStr;
957 end;
958 end;
959 end;
961 procedure ProcSelectWAD(Sender: TGUIControl);
962 var
963 wad: String;
964 list: SSArray;
965 begin
966 with TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu')) do
967 begin
968 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
970 with TGUIListBox(GetControl('lsMapRes')) do
971 begin
972 Clear();
974 if wad <> '' then
975 begin
976 list := g_Map_GetMapsList(wad);
978 if list <> nil then
979 begin
980 Items := list;
981 ItemIndex := 0;
982 end
983 end;
984 end;
985 end;
987 ProcSelectMap(nil);
988 end;
990 procedure ProcSelectCampaignWAD(Sender: TGUIControl);
991 var
992 win: TGUIWindow;
993 a: TMegaWADInfo;
994 wad, fn: String;
995 begin
996 win := g_GUI_GetWindow('CampaignMenu');
997 with TGUIMenu(win.GetControl('mCampaignMenu')) do
998 begin
999 wad := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
1001 if wad = '' then
1002 begin
1003 TGUILabel(GetControl('lbWADName')).Text := '';
1004 TGUILabel(GetControl('lbWADAuthor')).Text := '';
1005 TGUIMemo(GetControl('meWADDescription')).SetText('');
1006 end;
1008 a := g_Game_GetMegaWADInfo(wad);
1010 TGUILabel(GetControl('lbWADName')).Text := a.Name;
1011 TGUILabel(GetControl('lbWADAuthor')).Text := a.Author;
1012 TGUIMemo(GetControl('meWADDescription')).SetText(a.Description);
1014 TGUIImage(win.GetControl('mpWADImage')).ClearImage();
1016 if a.pic <> '' then
1017 begin
1018 fn := g_ExtractWadName(a.pic);
1019 if fn = '' then
1020 TGUIImage(win.GetControl('mpWADImage')).SetImage(wad+a.pic)
1021 else
1022 TGUIImage(win.GetControl('mpWADImage')).SetImage(a.pic);
1023 end;
1024 end;
1025 end;
1027 procedure ProcChangeColor(Sender: TGUIControl);
1028 var
1029 window: TGUIWindow;
1030 begin
1031 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
1032 with TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')) do
1033 TGUIModelView(window.GetControl('mvP1Model')).SetColor(
1034 Min(TGUIScroll(GetControl('scP1Red')).Value*16, 255),
1035 Min(TGUIScroll(GetControl('scP1Green')).Value*16, 255),
1036 Min(TGUIScroll(GetControl('scP1Blue')).Value*16, 255));
1038 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
1039 with TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')) do
1040 TGUIModelView(window.GetControl('mvP2Model')).SetColor(
1041 Min(TGUIScroll(GetControl('scP2Red')).Value*16, 255),
1042 Min(TGUIScroll(GetControl('scP2Green')).Value*16, 255),
1043 Min(TGUIScroll(GetControl('scP2Blue')).Value*16, 255));
1044 end;
1046 procedure ProcSelectModel(Sender: TGUIControl);
1047 var
1048 a: string;
1049 window: TGUIWindow;
1050 begin
1051 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
1052 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')).GetControl('lsP1Model')).SelectedItem;
1053 if a <> '' then TGUIModelView(window.GetControl('mvP1Model')).SetModel(a);
1055 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
1056 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')).GetControl('lsP2Model')).SelectedItem;
1057 if a <> '' then TGUIModelView(window.GetControl('mvP2Model')).SetModel(a);
1059 ProcChangeColor(nil);
1060 end;
1062 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
1063 var
1064 cwdt, chgt: Byte;
1065 spc: ShortInt;
1066 ID: DWORD;
1067 wad: TWADFile;
1068 cfgdata: Pointer;
1069 cfglen: Integer;
1070 config: TConfig;
1071 begin
1072 cfglen := 0;
1074 wad := TWADFile.Create;
1075 if wad.ReadFile(GameWAD) then
1076 wad.GetResource('FONTS/'+cfgres, cfgdata, cfglen);
1077 wad.Free();
1079 if cfglen <> 0 then
1080 begin
1081 g_Texture_CreateWADEx('FONT_STD', GameWAD+':FONTS\'+texture);
1083 config := TConfig.CreateMem(cfgdata, cfglen);
1084 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
1085 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
1086 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
1088 if g_Texture_Get('FONT_STD', ID) then
1089 e_TextureFontBuild(ID, FontID, cwdt, chgt, spc);
1091 config.Free();
1092 end;
1094 if cfglen <> 0 then FreeMem(cfgdata);
1095 end;
1097 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
1098 var
1099 cwdt, chgt: Byte;
1100 spc: ShortInt;
1101 CharID: DWORD;
1102 wad: TWADFile;
1103 cfgdata, fntdata: Pointer;
1104 cfglen, fntlen: Integer;
1105 config: TConfig;
1106 chrwidth: Integer;
1107 a: Byte;
1108 begin
1109 cfglen := 0;
1110 fntlen := 0;
1112 wad := TWADFile.Create;
1113 if wad.ReadFile(GameWAD) then
1114 begin
1115 wad.GetResource('FONTS/'+txtres, cfgdata, cfglen);
1116 wad.GetResource('FONTS/'+fntres, fntdata, fntlen);
1117 end;
1118 wad.Free();
1120 if cfglen <> 0 then
1121 begin
1122 config := TConfig.CreateMem(cfgdata, cfglen);
1123 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
1124 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
1126 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
1127 FontID := e_CharFont_Create(spc);
1129 for a := 0 to 255 do
1130 begin
1131 chrwidth := config.ReadInt(IntToStr(a), 'Width', 0);
1132 if chrwidth = 0 then Continue;
1134 if e_CreateTextureMemEx(fntdata, fntlen, CharID, cwdt*(a mod 16), chgt*(a div 16),
1135 cwdt, chgt) then
1136 e_CharFont_AddChar(FontID, CharID, Chr(a), chrwidth);
1137 end;
1139 config.Free();
1140 end;
1142 if cfglen <> 0 then FreeMem(cfgdata);
1143 if fntlen <> 0 then FreeMem(fntdata);
1144 end;
1146 procedure MenuLoadData();
1147 begin
1148 e_WriteLog('Loading menu data...', TMsgType.Notify);
1150 g_Texture_CreateWADEx('MAINMENU_LOGO', GameWAD+':TEXTURES\MAINLOGO');
1151 g_Texture_CreateWADEx('MAINMENU_MARKER1', GameWAD+':TEXTURES\MARKER1');
1152 g_Texture_CreateWADEx('MAINMENU_MARKER2', GameWAD+':TEXTURES\MARKER2');
1153 g_Texture_CreateWADEx('SCROLL_LEFT', GameWAD+':TEXTURES\SLEFT');
1154 g_Texture_CreateWADEx('SCROLL_RIGHT', GameWAD+':TEXTURES\SRIGHT');
1155 g_Texture_CreateWADEx('SCROLL_MIDDLE', GameWAD+':TEXTURES\SMIDDLE');
1156 g_Texture_CreateWADEx('SCROLL_MARKER', GameWAD+':TEXTURES\SMARKER');
1157 g_Texture_CreateWADEx('EDIT_LEFT', GameWAD+':TEXTURES\ELEFT');
1158 g_Texture_CreateWADEx('EDIT_RIGHT', GameWAD+':TEXTURES\ERIGHT');
1159 g_Texture_CreateWADEx('EDIT_MIDDLE', GameWAD+':TEXTURES\EMIDDLE');
1160 g_Texture_CreateWADEx('BOX1', GameWAD+':TEXTURES\BOX1');
1161 g_Texture_CreateWADEx('BOX2', GameWAD+':TEXTURES\BOX2');
1162 g_Texture_CreateWADEx('BOX3', GameWAD+':TEXTURES\BOX3');
1163 g_Texture_CreateWADEx('BOX4', GameWAD+':TEXTURES\BOX4');
1164 g_Texture_CreateWADEx('BOX5', GameWAD+':TEXTURES\BOX5');
1165 g_Texture_CreateWADEx('BOX6', GameWAD+':TEXTURES\BOX6');
1166 g_Texture_CreateWADEx('BOX7', GameWAD+':TEXTURES\BOX7');
1167 g_Texture_CreateWADEx('BOX8', GameWAD+':TEXTURES\BOX8');
1168 g_Texture_CreateWADEx('BOX9', GameWAD+':TEXTURES\BOX9');
1169 g_Texture_CreateWADEx('BSCROLL_UP_A', GameWAD+':TEXTURES\SCROLLUPA');
1170 g_Texture_CreateWADEx('BSCROLL_UP_U', GameWAD+':TEXTURES\SCROLLUPU');
1171 g_Texture_CreateWADEx('BSCROLL_DOWN_A', GameWAD+':TEXTURES\SCROLLDOWNA');
1172 g_Texture_CreateWADEx('BSCROLL_DOWN_U', GameWAD+':TEXTURES\SCROLLDOWNU');
1173 g_Texture_CreateWADEx('BSCROLL_MIDDLE', GameWAD+':TEXTURES\SCROLLMIDDLE');
1174 g_Texture_CreateWADEx('NOPIC', GameWAD+':TEXTURES\NOPIC');
1176 g_Sound_CreateWADEx('MENU_SELECT', GameWAD+':SOUNDS\MENUSELECT');
1177 g_Sound_CreateWADEx('MENU_OPEN', GameWAD+':SOUNDS\MENUOPEN');
1178 g_Sound_CreateWADEx('MENU_CLOSE', GameWAD+':SOUNDS\MENUCLOSE');
1179 g_Sound_CreateWADEx('MENU_CHANGE', GameWAD+':SOUNDS\MENUCHANGE');
1180 g_Sound_CreateWADEx('SCROLL_ADD', GameWAD+':SOUNDS\SCROLLADD');
1181 g_Sound_CreateWADEx('SCROLL_SUB', GameWAD+':SOUNDS\SCROLLSUB');
1182 g_Sound_CreateWADEx('SOUND_PLAYER_FALL', GameWAD+':SOUNDS\FALL');
1183 end;
1185 procedure MenuFreeData();
1186 begin
1187 e_CharFont_Remove(gMenuFont);
1188 e_CharFont_Remove(gMenuSmallFont);
1190 g_Texture_Delete('MAINMENU_LOGO');
1191 g_Texture_Delete('MAINMENU_MARKER1');
1192 g_Texture_Delete('MAINMENU_MARKER2');
1193 g_Texture_Delete('SCROLL_LEFT');
1194 g_Texture_Delete('SCROLL_RIGHT');
1195 g_Texture_Delete('SCROLL_MIDDLE');
1196 g_Texture_Delete('SCROLL_MARKER');
1197 g_Texture_Delete('EDIT_LEFT');
1198 g_Texture_Delete('EDIT_RIGHT');
1199 g_Texture_Delete('EDIT_MIDDLE');
1200 g_Texture_Delete('BOX1');
1201 g_Texture_Delete('BOX2');
1202 g_Texture_Delete('BOX3');
1203 g_Texture_Delete('BOX4');
1204 g_Texture_Delete('BOX5');
1205 g_Texture_Delete('BOX6');
1206 g_Texture_Delete('BOX7');
1207 g_Texture_Delete('BOX8');
1208 g_Texture_Delete('BOX9');
1209 g_Texture_Delete('BSCROLL_UP_A');
1210 g_Texture_Delete('BSCROLL_UP_U');
1211 g_Texture_Delete('BSCROLL_DOWN_A');
1212 g_Texture_Delete('BSCROLL_DOWN_U');
1213 g_Texture_Delete('BSCROLL_MIDDLE');
1214 g_Texture_Delete('NOPIC');
1216 g_Sound_Delete('MENU_SELECT');
1217 g_Sound_Delete('MENU_OPEN');
1218 g_Sound_Delete('MENU_CLOSE');
1219 g_Sound_Delete('MENU_CHANGE');
1220 g_Sound_Delete('SCROLL_ADD');
1221 g_Sound_Delete('SCROLL_SUB');
1222 g_Sound_Delete('SOUND_PLAYER_FALL');
1223 end;
1225 procedure ProcAuthorsMenu();
1226 begin
1227 gMusic.SetByName('MUSIC_INTERMUS');
1228 gMusic.Play();
1229 end;
1231 procedure ProcExitMenuKeyDown (yes: Boolean);
1232 var
1233 s: ShortString;
1234 snd: TPlayableSound;
1235 res: Boolean;
1236 begin
1237 if yes then
1238 begin
1239 g_Game_StopAllSounds(True);
1240 case (Random(18)) of
1241 0: s := 'SOUND_MONSTER_PAIN';
1242 1: s := 'SOUND_MONSTER_DIE_3';
1243 2: s := 'SOUND_MONSTER_SLOP';
1244 3: s := 'SOUND_MONSTER_DEMON_DIE';
1245 4: s := 'SOUND_MONSTER_IMP_DIE_2';
1246 5: s := 'SOUND_MONSTER_MAN_DIE';
1247 6: s := 'SOUND_MONSTER_BSP_DIE';
1248 7: s := 'SOUND_MONSTER_VILE_DIE';
1249 8: s := 'SOUND_MONSTER_SKEL_DIE';
1250 9: s := 'SOUND_MONSTER_MANCUB_ALERT';
1251 10: s := 'SOUND_MONSTER_PAIN_PAIN';
1252 11: s := 'SOUND_MONSTER_BARON_DIE';
1253 12: s := 'SOUND_MONSTER_CACO_DIE';
1254 13: s := 'SOUND_MONSTER_CYBER_DIE';
1255 14: s := 'SOUND_MONSTER_KNIGHT_ALERT';
1256 15: s := 'SOUND_MONSTER_SPIDER_ALERT';
1257 else s := 'SOUND_PLAYER_FALL';
1258 end;
1259 snd := TPlayableSound.Create();
1260 res := snd.SetByName(s);
1261 if not res then res := snd.SetByName('SOUND_PLAYER_FALL');
1262 if res then
1263 begin
1264 snd.Play(True);
1265 while snd.IsPlaying() do begin end;
1266 end;
1267 g_Game_Quit();
1268 exit;
1269 end;
1270 g_GUI_HideWindow();
1271 end;
1273 procedure ProcLoadMenu();
1274 var
1275 a: Integer;
1276 valid: Boolean;
1277 begin
1278 for a := 1 to 8 do
1279 begin
1280 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Text := g_GetSaveName(a, valid);
1281 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := not valid;
1282 //TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a)).Enabled := valid;
1283 end;
1284 end;
1286 procedure ProcSaveMenu();
1287 var
1288 a: Integer;
1289 valid: Boolean;
1290 name: AnsiString;
1291 begin
1292 for a := 1 to 8 do
1293 begin
1294 name := g_GetSaveName(a, valid);
1295 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Text := name;
1296 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := (name <> '') and (not valid);
1297 end;
1298 end;
1300 procedure ProcSaveGame(Sender: TGUIControl);
1301 var
1302 a: Integer;
1303 begin
1304 if g_Game_IsNet then Exit;
1305 if g_Game_IsTestMap then Exit;
1306 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1307 g_Game_PauseAllSounds(True);
1308 g_SaveGame(a, TGUIEdit(Sender).Text);
1310 g_ActiveWindow := nil;
1311 g_Game_Pause(False);
1312 end;
1314 procedure ProcLoadGame(Sender: TGUIControl);
1315 var
1316 a: Integer;
1317 begin
1318 if g_Game_IsNet then Exit;
1319 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1320 if g_LoadGame(a) then
1321 begin
1322 g_Game_PauseAllSounds(False)
1323 end
1324 else // Íå çàãðóçèëîñü - âîçâðàò â ìåíþ
1325 begin
1326 g_Console_Add(_lc[I_MSG_BAD_SAVE_VERSION], true);
1327 g_GUI_GetWindow('LoadMenu').SetActive(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu'));
1328 //g_ActiveWindow := nil;
1329 end;
1330 end;
1332 procedure ProcSinglePlayer (n: Integer);
1333 var wad, map: AnsiString;
1334 begin
1335 assert(n >= 1);
1336 wad := g_ExtractWadName(gDefaultMegawadStart);
1337 map := g_ExtractFilePathName(gDefaultMegawadStart);
1338 if e_FindResource(AllMapDirs, wad) then
1339 begin
1340 wad := ExpandFileName(wad);
1341 g_Game_StartSingle(wad + ':\' + map, n > 1, n)
1342 end
1343 end;
1345 procedure ProcSingle1Player;
1346 begin
1347 ProcSinglePlayer(1)
1348 end;
1350 procedure ProcSingle2Players;
1351 begin
1352 ProcSinglePlayer(2)
1353 end;
1355 procedure ProcSelectMapMenu();
1356 var
1357 menu: TGUIMenu;
1358 wad_lb: TGUIFileListBox;
1359 map_lb: TGUIListBox;
1360 map: String;
1361 begin
1362 menu := TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1363 wad_lb := TGUIFileListBox(menu.GetControl('lsMapWAD'));
1364 map_lb := TGUIListBox(menu.GetControl('lsMapRes'));
1366 if wad_lb.SelectedItem() <> '' then
1367 map := map_lb.SelectedItem()
1368 else
1369 map := '';
1371 wad_lb.UpdateFileList();
1372 map_lb.Clear();
1374 if wad_lb.SelectedItem() <> '' then
1375 begin
1376 ProcSelectWAD(nil);
1377 map_lb.SelectItem(map);
1379 if map_lb.SelectedItem() <> '' then
1380 ProcSelectMap(nil);
1381 end;
1383 g_GUI_ShowWindow('SelectMapMenu');
1384 end;
1386 procedure ProcSelectCampaignMenu();
1387 var
1388 menu: TGUIMenu;
1389 wad_lb: TGUIFileListBox;
1390 begin
1391 menu := TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1392 wad_lb := TGUIFileListBox(menu.GetControl('lsWAD'));
1394 wad_lb.UpdateFileList();
1396 if wad_lb.SelectedItem() <> '' then
1397 ProcSelectCampaignWAD(nil);
1398 end;
1400 procedure ProcSetMap();
1401 var
1402 wad, map, res: String;
1403 begin
1404 with TGUIMenu(g_ActiveWindow.GetControl('mSelectMapMenu')) do
1405 begin
1406 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
1407 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1408 end;
1410 if (wad = '') or (map = '') then
1411 Exit;
1413 wad := e_FindWadRel(MapDirs, WAD);
1415 res := wad+':\'+map;
1417 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
1418 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res;
1419 end;
1421 procedure ProcChangeSoundSettings(Sender: TGUIControl);
1422 var
1423 menu: TGUIMenu;
1424 begin
1425 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1427 g_Sound_SetupAllVolumes(
1428 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
1429 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
1430 );
1431 end;
1433 procedure ProcChangeGameSettings(Sender: TGUIControl);
1434 var
1435 menu: TGUIMenu;
1436 begin
1437 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
1438 if TGUIScroll(menu.GetControl('scScaleFactor')).Value <> TempScale then
1439 begin
1440 TempScale := TGUIScroll(menu.GetControl('scScaleFactor')).Value;
1441 g_dbg_scale := TempScale + 1;
1442 end;
1443 end;
1445 procedure ProcChangeTouchSettings(Sender: TGUIControl);
1446 var
1447 menu: TGUIMenu;
1448 begin
1449 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
1450 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
1451 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
1452 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
1453 end;
1455 procedure ProcOptionsPlayersMIMenu();
1456 var
1457 s, a: string;
1458 b: TModelInfo;
1459 begin
1460 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1462 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+s+'Menu')).GetControl('ls'+s+'Model')).SelectedItem;
1464 if a = '' then Exit;
1466 b := g_PlayerModel_GetInfo(a);
1468 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1469 begin
1470 TGUILabel(GetControl('lbName')).Text := b.Name;
1471 TGUILabel(GetControl('lbAuthor')).Text := b.Author;
1472 TGUIMemo(GetControl('meComment')).SetText(b.Description);
1474 if b.HaveWeapon then
1475 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1476 else
1477 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1478 end;
1480 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1481 end;
1483 procedure ProcOptionsPlayerP1WeaponMenu();
1484 var
1485 a: string;
1486 begin
1487 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+'P1'+'Menu')).GetControl('ls'+'P1'+'Model')).SelectedItem;
1488 if a = '' then Exit;
1489 g_GUI_ShowWindow('OptionsPlayersP1WeaponMenu');
1490 end;
1492 procedure ProcOptionsPlayerP1WeaponPreferencesMenu();
1493 begin
1494 g_GUI_ShowWindow('OptionsPreferencesP1WeaponMenu');
1495 end;
1497 procedure ProcOptionsPlayerP2WeaponMenu();
1498 var
1499 a: string;
1500 begin
1501 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+'P2'+'Menu')).GetControl('ls'+'P2'+'Model')).SelectedItem;
1502 if a = '' then Exit;
1503 g_GUI_ShowWindow('OptionsPlayersP2WeaponMenu');
1504 end;
1506 procedure ProcOptionsPlayerP2WeaponPreferencesMenu();
1507 begin
1508 g_GUI_ShowWindow('OptionsPreferencesP2WeaponMenu');
1509 end;
1511 procedure ProcOptionsPlayersAnim();
1512 var
1513 s: String;
1514 begin
1515 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1516 s := 'P1'
1517 else
1518 s := 'P2';
1520 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1521 begin
1522 NextAnim();
1523 Model.GetCurrentAnimation.Loop := True;
1524 Model.GetCurrentAnimationMask.Loop := True;
1525 end;
1526 end;
1528 procedure ProcOptionsPlayersWeap();
1529 var
1530 s: String;
1531 begin
1532 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1533 s := 'P1'
1534 else
1535 s := 'P2';
1537 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1538 NextWeapon();
1539 end;
1541 procedure ProcOptionsPlayersRot();
1542 var
1543 s: string;
1544 begin
1545 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1546 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1547 begin
1548 if Direction = TDirection.D_LEFT then Direction := TDirection.D_RIGHT else Direction := TDirection.D_LEFT;
1549 end;
1550 end;
1552 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1553 begin
1554 if yes then
1555 begin
1556 g_Options_SetDefault();
1557 ReadOptions();
1558 end;
1559 g_GUI_HideWindow();
1560 end;
1562 procedure ProcSavedMenuKeyDown (yes: Boolean);
1563 begin
1564 if yes then ReadOptions();
1565 g_GUI_HideWindow();
1566 end;
1568 procedure ProcAuthorsClose();
1569 begin
1570 gMusic.SetByName('MUSIC_MENU');
1571 gMusic.Play();
1572 gState := STATE_MENU;
1573 end;
1575 procedure ProcGMClose();
1576 begin
1577 g_Game_InGameMenu(False);
1578 end;
1580 procedure ProcGMShow();
1581 var
1582 Enabled: Boolean;
1583 begin
1584 Enabled := True;
1585 if (gGameSettings.GameType = GT_SINGLE) and
1586 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1587 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1588 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1589 if not gGameOn then
1590 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1591 if g_Game_IsTestMap then
1592 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1593 TGUIMainMenu(g_ActiveWindow.GetControl(
1594 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1595 end;
1597 procedure ProcChangePlayers();
1598 var
1599 TeamGame, Spectator, AddTwo: Boolean;
1600 P1Team{, P2Team}: Byte;
1601 bP2: TGUITextButton;
1602 begin
1603 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1604 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1605 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1606 P1Team := TEAM_NONE;
1607 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1608 // TODO
1609 //P2Team := TEAM_NONE;
1610 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1612 TGUIMainMenu(g_ActiveWindow.GetControl(
1613 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1614 TGUIMainMenu(g_ActiveWindow.GetControl(
1615 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1616 TGUIMainMenu(g_ActiveWindow.GetControl(
1617 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1619 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1620 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1621 bP2.Enabled := AddTwo and not Spectator;
1622 if bP2.Enabled then
1623 bP2.Color := MAINMENU_ITEMS_COLOR
1624 else
1625 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1626 if gPlayer2 = nil then
1627 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1628 else
1629 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1631 TGUIMainMenu(g_ActiveWindow.GetControl(
1632 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1633 end;
1635 procedure ProcJoinRed();
1636 begin
1637 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1638 Exit;
1639 if g_Game_IsServer then
1640 begin
1641 if gPlayer1 = nil then
1642 g_Game_AddPlayer(TEAM_RED)
1643 else
1644 begin
1645 if gPlayer1.Team <> TEAM_RED then
1646 begin
1647 gPlayer1.SwitchTeam;
1648 gPlayer1Settings.Team := gPlayer1.Team;
1649 end;
1651 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1652 end;
1653 end
1654 else
1655 begin
1656 gPlayer1Settings.Team := TEAM_RED;
1657 MC_SEND_PlayerSettings;
1658 if gPlayer1 = nil then
1659 g_Game_AddPlayer(TEAM_RED);
1660 end;
1661 g_ActiveWindow := nil;
1662 g_Game_Pause(False);
1663 end;
1665 procedure ProcJoinBlue();
1666 begin
1667 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1668 Exit;
1669 if g_Game_IsServer then
1670 begin
1671 if gPlayer1 = nil then
1672 g_Game_AddPlayer(TEAM_BLUE)
1673 else
1674 begin
1675 if gPlayer1.Team <> TEAM_BLUE then
1676 begin
1677 gPlayer1.SwitchTeam;
1678 gPlayer1Settings.Team := gPlayer1.Team;
1679 end;
1681 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1682 end;
1683 end
1684 else
1685 begin
1686 gPlayer1Settings.Team := TEAM_BLUE;
1687 MC_SEND_PlayerSettings;
1688 if gPlayer1 = nil then
1689 g_Game_AddPlayer(TEAM_BLUE);
1690 end;
1691 g_ActiveWindow := nil;
1692 g_Game_Pause(False);
1693 end;
1695 procedure ProcJoinGame();
1696 begin
1697 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1698 Exit;
1699 if gPlayer1 = nil then
1700 g_Game_AddPlayer();
1701 g_ActiveWindow := nil;
1702 g_Game_Pause(False);
1703 end;
1705 procedure ProcSwitchP2();
1706 begin
1707 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1708 Exit;
1709 if gPlayer1 = nil then
1710 Exit;
1711 if gPlayer2 = nil then
1712 g_Game_AddPlayer()
1713 else
1714 g_Game_RemovePlayer();
1715 g_ActiveWindow := nil;
1716 g_Game_Pause(False);
1717 end;
1719 procedure ProcSpectate();
1720 begin
1721 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1722 Exit;
1723 g_Game_Spectate();
1724 g_ActiveWindow := nil;
1725 g_Game_Pause(False);
1726 end;
1728 procedure ProcRestartMenuKeyDown (yes: Boolean);
1729 begin
1730 if yes then g_Game_Restart() else g_GUI_HideWindow;
1731 end;
1733 procedure ProcEndMenuKeyDown (yes: Boolean);
1734 begin
1735 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1736 end;
1738 procedure ProcSetRussianLanguage;
1739 begin
1740 if gLanguage <> LANGUAGE_RUSSIAN then
1741 begin
1742 gLanguage := LANGUAGE_RUSSIAN;
1743 gLanguageChange := True;
1744 gAskLanguage := False;
1745 ProcApplyOptions();
1746 end;
1747 end;
1749 procedure ProcSetEnglishLanguage;
1750 begin
1751 if gLanguage <> LANGUAGE_ENGLISH then
1752 begin
1753 gLanguage := LANGUAGE_ENGLISH;
1754 gLanguageChange := True;
1755 gAskLanguage := False;
1756 ProcApplyOptions();
1757 end;
1758 end;
1760 procedure ProcItemsRespawnMenu();
1761 var
1762 menu: TGUIMenu;
1763 begin
1764 menu := TGUIMenu(g_GUI_GetWindow('ItemsRespawnMenu').GetControl('mItemsRespawnMenu'));
1766 g_GUI_ShowWindow('ItemsRespawnMenu');
1767 end;
1769 procedure ReadGameSettings();
1770 var
1771 menu: TGUIMenu;
1772 begin
1773 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1775 with gGameSettings do
1776 begin
1777 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1778 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1779 ItemIndex := 0
1780 else
1781 ItemIndex := 1;
1782 with TGUISwitch(menu.GetControl('swTeamHit')) do
1783 if (Options and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
1784 ItemIndex := 0
1785 else if LongBool(Options and GAME_OPTION_TEAMHITTRACE) then
1786 ItemIndex := 1
1787 else if LongBool(Options and GAME_OPTION_TEAMHITPROJECTILE) then
1788 ItemIndex := 2
1789 else
1790 ItemIndex := 3;
1791 with TGUISwitch(menu.GetControl('swDeathmatchKeys')) do
1792 if LongBool(Options and GAME_OPTION_DMKEYS) then
1793 ItemIndex := 0
1794 else
1795 ItemIndex := 1;
1796 with TGUISwitch(menu.GetControl('swFlagDrop')) do
1797 if LongBool(Options and GAME_OPTION_ALLOWDROPFLAG) and LongBool(Options and GAME_OPTION_THROWFLAG) then
1798 ItemIndex := 0
1799 else if LongBool(Options and GAME_OPTION_ALLOWDROPFLAG) then
1800 ItemIndex := 1
1801 else
1802 ItemIndex := 2;
1804 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1805 TGUIEdit(menu.GetControl('edScoreLimit')).Text := IntToStr(ScoreLimit);
1806 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1808 with TGUISwitch(menu.GetControl('swBotsVS')) do
1809 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1810 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1811 ItemIndex := 2
1812 else
1813 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1814 ItemIndex := 1
1815 else
1816 ItemIndex := 0;
1818 if GameType in [GT_CUSTOM, GT_SERVER] then
1819 begin
1820 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1821 TGUISwitch(menu.GetControl('swTeamHit')).Enabled := True;
1822 if (GameMode in [GM_DM, GM_TDM, GM_CTF]) then
1823 begin
1824 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := True;
1825 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_ITEMSTEXT_COLOR;
1826 end
1827 else
1828 begin
1829 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1830 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1831 end;
1832 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1833 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1834 TGUIEdit(menu.GetControl('edScoreLimit')).Enabled := True;
1835 TGUILabel(menu.GetControlsText('edScoreLimit')).Color := MENU_ITEMSTEXT_COLOR;
1836 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1837 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1838 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1839 TGUISwitch(menu.GetControl('swFlagDrop')).Enabled := True;
1840 end
1841 else
1842 begin
1843 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1844 TGUISwitch(menu.GetControl('swTeamHit')).Enabled := True;
1845 TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled := False;
1846 TGUILabel(menu.GetControlsText('swDeathmatchKeys')).Color := MENU_UNACTIVEITEMS_COLOR;
1847 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1848 begin
1849 Enabled := False;
1850 Text := '';
1851 end;
1852 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1853 with TGUIEdit(menu.GetControl('edScoreLimit')) do
1854 begin
1855 Enabled := False;
1856 Text := '';
1857 end;
1858 TGUILabel(menu.GetControlsText('edScoreLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1859 with TGUIEdit(menu.GetControl('edMaxLives')) do
1860 begin
1861 Enabled := False;
1862 Text := '';
1863 end;
1864 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1865 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1866 TGUISwitch(menu.GetControl('swFlagDrop')).Enabled := False;
1867 end;
1868 end;
1869 end;
1871 procedure ProcApplyGameSet();
1872 var
1873 menu: TGUIMenu;
1874 a, b, n: Integer;
1875 stat: TPlayerStatArray;
1876 begin
1877 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1879 if not g_Game_IsServer then Exit;
1881 with gGameSettings do
1882 begin
1883 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1884 begin
1885 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1886 Options := Options or GAME_OPTION_TEAMDAMAGE
1887 else
1888 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1889 end;
1891 if TGUISwitch(menu.GetControl('swTeamHit')).Enabled then
1892 begin
1893 Options := Options and not (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE);
1894 case TGUISwitch(menu.GetControl('swTeamHit')).ItemIndex of
1895 1: Options := Options or GAME_OPTION_TEAMHITTRACE;
1896 2: Options := Options or GAME_OPTION_TEAMHITPROJECTILE;
1897 0: Options := Options or GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE;
1898 end;
1899 end;
1901 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).Enabled then
1902 begin
1903 if TGUISwitch(menu.GetControl('swDeathmatchKeys')).ItemIndex = 0 then
1904 Options := Options or GAME_OPTION_DMKEYS
1905 else
1906 Options := Options and (not GAME_OPTION_DMKEYS);
1907 end;
1909 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1910 begin
1911 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1913 if n = 0 then
1914 TimeLimit := 0
1915 else
1916 begin
1917 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1919 TimeLimit := Max(n, b);
1920 end;
1921 end;
1923 if TGUIEdit(menu.GetControl('edScoreLimit')).Enabled then
1924 begin
1925 n := StrToIntDef(TGUIEdit(menu.GetControl('edScoreLimit')).Text, ScoreLimit);
1927 if n = 0 then
1928 ScoreLimit := 0
1929 else
1930 begin
1931 b := 0;
1932 if GameMode = GM_DM then
1933 begin // DM
1934 stat := g_Player_GetStats();
1935 if stat <> nil then
1936 for a := 0 to High(stat) do
1937 if stat[a].Frags > b then
1938 b := stat[a].Frags;
1939 end
1940 else // CTF
1941 b := Max(gTeamStat[TEAM_RED].Score, gTeamStat[TEAM_BLUE].Score);
1943 ScoreLimit := Max(n, b);
1944 end;
1945 end;
1947 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1948 begin
1949 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, MaxLives);
1950 if n < 0 then n := 0;
1951 if n > 255 then n := 255;
1952 if n = 0 then
1953 MaxLives := 0
1954 else
1955 begin
1956 b := 0;
1957 stat := g_Player_GetStats();
1958 if stat <> nil then
1959 for a := 0 to High(stat) do
1960 if stat[a].Lives > b then
1961 b := stat[a].Lives;
1963 MaxLives := Max(n, b);
1964 end;
1965 end;
1967 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1968 begin
1969 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1970 1:
1971 begin
1972 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1973 Options := Options or GAME_OPTION_BOTVSMONSTER;
1974 end;
1975 2:
1976 begin
1977 Options := Options or GAME_OPTION_BOTVSPLAYER;
1978 Options := Options or GAME_OPTION_BOTVSMONSTER;
1979 end;
1980 else
1981 begin
1982 Options := Options or GAME_OPTION_BOTVSPLAYER;
1983 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1984 end;
1985 end;
1986 end;
1988 if TGUISwitch(menu.GetControl('swFlagDrop')).Enabled then
1989 begin
1990 case TGUISwitch(menu.GetControl('swFlagDrop')).ItemIndex of
1991 0: Options := Options or GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG;
1992 1: Options := Options or GAME_OPTION_ALLOWDROPFLAG;
1993 else Options := Options and not (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG);
1994 end;
1995 end;
1997 // don't forget to latch this shit
1998 gsGameFlags := Options;
1999 gsMaxLives := MaxLives;
2000 gsScoreLimit := ScoreLimit;
2001 gsTimeLimit := TimeLimit;
2002 end;
2004 if g_Game_IsNet then MH_SEND_GameSettings;
2005 end;
2007 procedure ProcVideoOptionsRes();
2008 var
2009 menu: TGUIMenu;
2010 list: SSArray;
2011 begin
2012 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
2014 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
2015 IntToStr(gWinSizeX) +
2016 ' x ' + IntToStr(gWinSizeY) +
2017 ', ' + IntToStr(gBPP) + ' bpp';
2019 with TGUIListBox(menu.GetControl('lsResolution')) do
2020 begin
2021 list := sys_GetDisplayModes(gBPP);
2022 if list <> nil then
2023 begin
2024 Items := list;
2025 ItemIndex := -1; (* nothing selected *)
2026 end
2027 else
2028 begin
2029 Clear
2030 end
2031 end;
2033 with TGUISwitch(menu.GetControl('swFullScreen')) do
2034 if gFullscreen then
2035 ItemIndex := 0
2036 else
2037 ItemIndex := 1;
2039 TempResScale := Round(r_pixel_scale - 1);
2040 with TGUISwitch(menu.GetControl('swResFactor')) do
2041 ItemIndex := Max(Min(TempResScale, gRC_Width div 640 - 1), 0);
2042 end;
2044 procedure ProcApplyVideoOptions();
2045 var
2046 menu: TGUIMenu;
2047 Fullscreen: Boolean;
2048 SWidth, SHeight: Integer;
2049 ScaleChanged: Boolean;
2050 str: String;
2051 begin
2052 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
2054 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
2055 if str <> '' then
2056 SScanf(str, '%dx%d', [@SWidth, @SHeight])
2057 else
2058 begin
2059 SWidth := gWinSizeX;
2060 SHeight := gWinSizeY;
2061 TempResScale := Min(TempResScale, SWidth div 640 - 1);
2062 end;
2064 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
2066 ScaleChanged := False;
2067 if TGUISwitch(menu.GetControl('swResFactor')).ItemIndex <> TempResScale then
2068 begin
2069 TempResScale := Min(TGUISwitch(menu.GetControl('swResFactor')).ItemIndex, SWidth div 640 - 1);
2070 r_pixel_scale := TempResScale + 1;
2071 ScaleChanged := True;
2072 end;
2074 if (SWidth <> gWinSizeX) or
2075 (SHeight <> gWinSizeY) or
2076 (Fullscreen <> gFullscreen) or
2077 ScaleChanged then
2078 begin
2079 gResolutionChange := True;
2080 gRC_Width := SWidth;
2081 gRC_Height := SHeight;
2082 gRC_FullScreen := Fullscreen;
2083 gRC_Maximized := gWinMaximized;
2084 end;
2086 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
2087 ProcApplyOptions();
2088 end;
2090 procedure ProcSetFirstRussianLanguage;
2091 begin
2092 gLanguage := LANGUAGE_RUSSIAN;
2093 gLanguageChange := True;
2094 gAskLanguage := False;
2095 end;
2097 procedure ProcSetFirstEnglishLanguage;
2098 begin
2099 gLanguage := LANGUAGE_ENGLISH;
2100 gLanguageChange := True;
2101 gAskLanguage := False;
2102 end;
2104 procedure ProcRecallAddress();
2105 begin
2106 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
2107 begin
2108 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
2109 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
2110 end;
2111 end;
2113 procedure CreateFirstLanguageMenu();
2114 var
2115 Menu: TGUIWindow;
2116 begin
2117 Menu := TGUIWindow.Create('FirstLanguageMenu');
2119 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', ' '))) do
2120 begin
2121 Name := 'mmFirstLanguageMenu';
2122 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
2123 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
2124 end;
2126 Menu.DefControl := 'mmFirstLanguageMenu';
2127 Menu.MainWindow := True;
2128 g_GUI_AddWindow(Menu);
2129 end;
2131 procedure g_Menu_AskLanguage();
2132 begin
2133 CreateFirstLanguageMenu();
2134 g_GUI_ShowWindow('FirstLanguageMenu');
2135 end;
2137 procedure CreatePlayerOptionsMenu(s: String);
2138 var
2139 Menu: TGUIWindow;
2140 a: String;
2141 begin
2142 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
2143 if s = 'P1' then
2144 a := _lc[I_MENU_PLAYER_1]
2145 else
2146 a := _lc[I_MENU_PLAYER_2];
2147 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
2148 begin
2149 Name := 'mOptionsPlayers'+s+'Menu';
2150 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
2151 begin
2152 Name := 'ed'+s+'Name';
2153 MaxLength := 12;
2154 Width := 12;
2155 end;
2156 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
2157 begin
2158 Name := 'sw'+s+'Team';
2159 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
2160 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
2161 end ;
2162 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
2163 begin
2164 Name := 'ls'+s+'Model';
2165 Sort := True;
2166 Items := g_PlayerModel_GetNames();
2167 OnChange := ProcSelectModel;
2168 end;
2169 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
2170 begin
2171 Name := 'sc'+s+'Red';
2172 Max := 16;
2173 OnChange := ProcChangeColor;
2174 end;
2175 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
2176 begin
2177 Name := 'sc'+s+'Green';
2178 Max := 16;
2179 OnChange := ProcChangeColor;
2180 end;
2181 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
2182 begin
2183 Name := 'sc'+s+'Blue';
2184 Max := 16;
2185 OnChange := ProcChangeColor;
2186 end;
2187 AddSpace();
2188 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
2189 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
2190 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
2191 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
2192 if s = 'P1' then AddButton(@ProcOptionsPlayerP1WeaponMenu, _lc[I_MENU_WEAPON])
2193 else AddButton(@ProcOptionsPlayerP2WeaponMenu, _lc[I_MENU_WEAPON]);
2194 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
2195 begin
2196 Name := 'mv'+s+'Model';
2197 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
2198 Y := GetControl('ls'+s+'Model').Y;
2199 end;
2200 end;
2201 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
2202 g_GUI_AddWindow(Menu);
2203 end;
2205 procedure CreateAllMenus();
2206 var
2207 Menu: TGUIWindow;
2208 //SR: TSearchRec;
2209 a, cx, _y, i: Integer;
2210 //list: SSArray;
2211 begin
2212 Menu := TGUIWindow.Create('MainMenu');
2213 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, 'MAINMENU_LOGO', _lc[I_MENU_MAIN_MENU]))) do
2214 begin
2215 Name := 'mmMainMenu';
2216 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
2217 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
2218 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
2219 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2220 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
2221 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
2222 end;
2223 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
2224 begin
2225 Color := _RGB(255, 255, 255);
2226 X := gScreenWidth-GetWidth-8;
2227 Y := gScreenHeight-GetHeight-8;
2228 end;
2229 Menu.DefControl := 'mmMainMenu';
2230 Menu.MainWindow := True;
2231 g_GUI_AddWindow(Menu);
2233 Menu := TGUIWindow.Create('NewGameMenu');
2234 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_NEW_GAME]))) do
2235 begin
2236 Name := 'mmNewGameMenu';
2237 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
2238 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
2239 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
2240 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
2241 end;
2242 Menu.DefControl := 'mmNewGameMenu';
2243 g_GUI_AddWindow(Menu);
2245 Menu := TGUIWindow.Create('NetGameMenu');
2246 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MULTIPLAYER]))) do
2247 begin
2248 Name := 'mmNetGameMenu';
2249 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
2250 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
2251 end;
2252 Menu.DefControl := 'mmNetGameMenu';
2253 g_GUI_AddWindow(Menu);
2255 Menu := TGUIWindow.Create('NetServerMenu');
2256 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
2257 begin
2258 Name := 'mNetServerMenu';
2259 with AddEdit(_lc[I_NET_SERVER_NAME]) do
2260 begin
2261 Name := 'edSrvName';
2262 OnlyDigits := False;
2263 Width := 16;
2264 MaxLength := 64;
2265 Text := NetServerName;
2266 end;
2267 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2268 begin
2269 Name := 'edSrvPassword';
2270 OnlyDigits := False;
2271 Width := 16;
2272 MaxLength := 24;
2273 Text := NetPassword;
2274 end;
2275 with AddEdit(_lc[I_NET_PORT]) do
2276 begin
2277 Name := 'edPort';
2278 OnlyDigits := True;
2279 Width := 4;
2280 MaxLength := 5;
2281 Text := IntToStr(NetPort);
2282 end;
2283 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2284 begin
2285 Name := 'edMaxPlayers';
2286 OnlyDigits := True;
2287 Width := 4;
2288 MaxLength := 2;
2289 Text := IntToStr(NetMaxClients);
2290 end;
2291 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2292 begin
2293 Name := 'swUseMaster';
2294 AddItem(_lc[I_MENU_YES]);
2295 AddItem(_lc[I_MENU_NO]);
2296 if NetUseMaster then
2297 ItemIndex := 0
2298 else
2299 ItemIndex := 1;
2300 end;
2301 AddSpace();
2302 with AddLabel(_lc[I_MENU_MAP]) do
2303 begin
2304 Name := 'lbMap';
2305 FixedLength := 16;
2306 Text := gsMap;
2307 OnClick := @ProcSelectMapMenu;
2308 end;
2309 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2310 begin
2311 Name := 'swGameMode';
2312 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2313 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2314 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2315 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2316 case g_Game_TextToMode(gsGameMode) of
2317 GM_NONE,
2318 GM_DM: ItemIndex := 0;
2319 GM_TDM: ItemIndex := 1;
2320 GM_CTF: ItemIndex := 2;
2321 GM_SINGLE,
2322 GM_COOP: ItemIndex := 3;
2323 end;
2324 OnChange := ProcSwitchMonstersCustom;
2325 end;
2326 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2327 begin
2328 Name := 'edTimeLimit';
2329 OnlyDigits := True;
2330 Width := 4;
2331 MaxLength := 5;
2332 if gsTimeLimit > 0 then
2333 Text := IntToStr(gsTimeLimit);
2334 end;
2335 with AddEdit(_lc[I_MENU_SCORE_LIMIT]) do
2336 begin
2337 Name := 'edScoreLimit';
2338 OnlyDigits := True;
2339 Width := 4;
2340 MaxLength := 5;
2341 if gsScoreLimit > 0 then
2342 Text := IntToStr(gsScoreLimit);
2343 end;
2344 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2345 begin
2346 Name := 'edMaxLives';
2347 OnlyDigits := True;
2348 Width := 4;
2349 MaxLength := 5;
2350 if gsMaxLives > 0 then
2351 Text := IntToStr(gsMaxLives);
2352 end;
2353 with AddLabel(_lc[I_MENU_SELECT_ITEM_RESPAWN]) do
2354 begin
2355 Name := 'lbItemsRespawn';
2356 FixedLength := 16;
2357 OnClick := @ProcItemsRespawnMenu;
2358 end;
2359 AddSpace();
2360 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2361 begin
2362 Name := 'swPlayers';
2363 AddItem(_lc[I_MENU_COUNT_NONE]);
2364 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2365 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2366 ItemIndex := gsPlayers;
2367 end;
2368 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2369 begin
2370 Name := 'swTeamDamage';
2371 AddItem(_lc[I_MENU_YES]);
2372 AddItem(_lc[I_MENU_NO]);
2373 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2374 ItemIndex := 0
2375 else
2376 ItemIndex := 1;
2377 end;
2378 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
2379 begin
2380 Name := 'swTeamHit';
2381 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
2382 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
2383 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
2384 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
2385 if (gsGameFlags and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
2386 ItemIndex := 0
2387 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITTRACE) then
2388 ItemIndex := 1
2389 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITPROJECTILE) then
2390 ItemIndex := 2
2391 else
2392 ItemIndex := 3;
2393 end;
2394 with AddSwitch(_lc[I_MENU_ENABLE_TEAM_DAMAGE_ABSOBR]) do
2395 begin
2396 Name := 'swTeamAbsorbDamage';
2397 AddItem(_lc[I_MENU_YES]);
2398 AddItem(_lc[I_MENU_NO]);
2399 if LongBool(gsGameFlags and GAME_OPTION_TEAMABSORBDAMAGE) then
2400 ItemIndex := 0
2401 else
2402 ItemIndex := 1;
2403 end;
2404 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2405 begin
2406 Name := 'swDeathmatchKeys';
2407 AddItem(_lc[I_MENU_YES]);
2408 AddItem(_lc[I_MENU_NO]);
2409 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2410 ItemIndex := 0
2411 else
2412 ItemIndex := 1;
2413 end;
2414 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2415 begin
2416 Name := 'swEnableExits';
2417 AddItem(_lc[I_MENU_YES]);
2418 AddItem(_lc[I_MENU_NO]);
2419 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2420 ItemIndex := 0
2421 else
2422 ItemIndex := 1;
2423 end;
2424 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2425 begin
2426 Name := 'swWeaponStay';
2427 AddItem(_lc[I_MENU_YES]);
2428 AddItem(_lc[I_MENU_NO]);
2429 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2430 ItemIndex := 0
2431 else
2432 ItemIndex := 1;
2433 end;
2434 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2435 begin
2436 Name := 'swMonsters';
2437 AddItem(_lc[I_MENU_YES]);
2438 AddItem(_lc[I_MENU_NO]);
2439 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2440 ItemIndex := 0
2441 else
2442 ItemIndex := 1;
2443 end;
2444 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2445 begin
2446 Name := 'swBotsVS';
2447 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2448 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2449 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2450 ItemIndex := 2;
2451 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2452 ItemIndex := 0;
2453 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2454 ItemIndex := 1;
2455 end;
2456 with AddSwitch(_lc[I_MENU_FLAG_DROP]) do
2457 begin
2458 Name := 'swFlagDrop';
2459 AddItem(_lc[I_MENU_FLAG_THROW]);
2460 AddItem(_lc[I_MENU_YES]);
2461 AddItem(_lc[I_MENU_NO]);
2462 if (gsGameFlags and (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG)) = (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG) then
2463 ItemIndex := 0
2464 else if LongBool(gsGameFlags and GAME_OPTION_ALLOWDROPFLAG) then
2465 ItemIndex := 1
2466 else
2467 ItemIndex := 2;
2468 end;
2469 AddSpace();
2470 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2472 ReAlign();
2473 end;
2474 Menu.DefControl := 'mNetServerMenu';
2475 g_GUI_AddWindow(Menu);
2477 Menu := TGUIWindow.Create('NetClientMenu');
2478 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2479 begin
2480 Name := 'mNetClientMenu';
2482 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2483 AddSpace();
2485 with AddEdit(_lc[I_NET_ADDRESS]) do
2486 begin
2487 Name := 'edIP';
2488 OnlyDigits :=False;
2489 Width := 12;
2490 MaxLength := 64;
2491 Text := 'localhost';
2492 end;
2493 with AddEdit(_lc[I_NET_PORT]) do
2494 begin
2495 Name := 'edPort';
2496 OnlyDigits := True;
2497 Width := 4;
2498 MaxLength := 5;
2499 Text := '25666';
2500 end;
2501 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2502 begin
2503 Name := 'edPW';
2504 OnlyDigits := False;
2505 Width := 12;
2506 MaxLength := 32;
2507 Text := '';
2508 end;
2510 AddSpace();
2511 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2513 ReAlign();
2514 end;
2515 Menu.DefControl := 'mNetClientMenu';
2516 g_GUI_AddWindow(Menu);
2518 Menu := TGUIWindow.Create('LoadMenu');
2519 Menu.OnShow := ProcLoadMenu;
2520 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2521 begin
2522 Name := 'mmLoadMenu';
2524 for a := 1 to 8 do
2525 with AddEdit('') do
2526 begin
2527 Name := 'edSlot'+IntToStr(a);
2528 Width := 16;
2529 MaxLength := 16;
2530 OnEnter := ProcLoadGame;
2531 end;
2532 end;
2533 Menu.DefControl := 'mmLoadMenu';
2534 g_GUI_AddWindow(Menu);
2536 Menu := TGUIWindow.Create('SaveMenu');
2537 Menu.OnShow := ProcSaveMenu;
2538 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2539 begin
2540 Name := 'mmSaveMenu';
2542 for a := 1 to 8 do
2543 with AddEdit('') do
2544 begin
2545 Name := 'edSlot'+IntToStr(a);
2546 Width := 16;
2547 MaxLength := 16;
2548 OnChange := ProcSaveGame;
2549 end;
2550 end;
2551 Menu.DefControl := 'mmSaveMenu';
2552 g_GUI_AddWindow(Menu);
2554 Menu := TGUIWindow.Create('CustomGameMenu');
2555 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2556 begin
2557 Name := 'mCustomGameMenu';
2558 with AddLabel(_lc[I_MENU_MAP]) do
2559 begin
2560 Name := 'lbMap';
2561 FixedLength := 16;
2562 Text := gsMap;
2563 OnClick := @ProcSelectMapMenu;
2564 end;
2565 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2566 begin
2567 Name := 'swGameMode';
2568 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2569 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2570 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2571 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2572 case g_Game_TextToMode(gsGameMode) of
2573 GM_NONE,
2574 GM_DM: ItemIndex := 0;
2575 GM_TDM: ItemIndex := 1;
2576 GM_CTF: ItemIndex := 2;
2577 GM_SINGLE,
2578 GM_COOP: ItemIndex := 3;
2579 end;
2580 OnChange := ProcSwitchMonstersCustom;
2581 end;
2582 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2583 begin
2584 Name := 'edTimeLimit';
2585 OnlyDigits := True;
2586 Width := 4;
2587 MaxLength := 5;
2588 if gsTimeLimit > 0 then
2589 Text := IntToStr(gsTimeLimit);
2590 end;
2591 with AddEdit(_lc[I_MENU_SCORE_LIMIT]) do
2592 begin
2593 Name := 'edScoreLimit';
2594 OnlyDigits := True;
2595 Width := 4;
2596 MaxLength := 5;
2597 if gsScoreLimit > 0 then
2598 Text := IntToStr(gsScoreLimit);
2599 end;
2600 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2601 begin
2602 Name := 'edMaxLives';
2603 OnlyDigits := True;
2604 Width := 4;
2605 MaxLength := 5;
2606 if gsMaxLives > 0 then
2607 Text := IntToStr(gsMaxLives);
2608 end;
2609 with AddLabel(_lc[I_MENU_SELECT_ITEM_RESPAWN]) do
2610 begin
2611 Name := 'lbItemsRespawn';
2612 FixedLength := 16;
2613 OnClick := @ProcItemsRespawnMenu;
2614 end;
2615 AddSpace();
2616 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2617 begin
2618 Name := 'swPlayers';
2619 AddItem(_lc[I_MENU_COUNT_NONE]);
2620 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2621 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2622 ItemIndex := gsPlayers;
2623 end;
2624 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2625 begin
2626 Name := 'swTeamDamage';
2627 AddItem(_lc[I_MENU_YES]);
2628 AddItem(_lc[I_MENU_NO]);
2629 if LongBool(gsGameFlags and GAME_OPTION_TEAMDAMAGE) then
2630 ItemIndex := 0
2631 else
2632 ItemIndex := 1;
2633 end;
2634 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
2635 begin
2636 Name := 'swTeamHit';
2637 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
2638 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
2639 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
2640 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
2641 if (gsGameFlags and (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE)) = (GAME_OPTION_TEAMHITTRACE or GAME_OPTION_TEAMHITPROJECTILE) then
2642 ItemIndex := 0
2643 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITTRACE) then
2644 ItemIndex := 1
2645 else if LongBool(gsGameFlags and GAME_OPTION_TEAMHITPROJECTILE) then
2646 ItemIndex := 2
2647 else
2648 ItemIndex := 3;
2649 end;
2650 with AddSwitch(_lc[I_MENU_ENABLE_TEAM_DAMAGE_ABSOBR]) do
2651 begin
2652 Name := 'swTeamAbsorbDamage';
2653 AddItem(_lc[I_MENU_YES]);
2654 AddItem(_lc[I_MENU_NO]);
2655 if LongBool(gsGameFlags and GAME_OPTION_TEAMABSORBDAMAGE) then
2656 ItemIndex := 0
2657 else
2658 ItemIndex := 1;
2659 end;
2660 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
2661 begin
2662 Name := 'swDeathmatchKeys';
2663 AddItem(_lc[I_MENU_YES]);
2664 AddItem(_lc[I_MENU_NO]);
2665 if LongBool(gsGameFlags and GAME_OPTION_DMKEYS) then
2666 ItemIndex := 0
2667 else
2668 ItemIndex := 1;
2669 end;
2670 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2671 begin
2672 Name := 'swEnableExits';
2673 AddItem(_lc[I_MENU_YES]);
2674 AddItem(_lc[I_MENU_NO]);
2675 if LongBool(gsGameFlags and GAME_OPTION_ALLOWEXIT) then
2676 ItemIndex := 0
2677 else
2678 ItemIndex := 1;
2679 end;
2680 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2681 begin
2682 Name := 'swWeaponStay';
2683 AddItem(_lc[I_MENU_YES]);
2684 AddItem(_lc[I_MENU_NO]);
2685 if LongBool(gsGameFlags and GAME_OPTION_WEAPONSTAY) then
2686 ItemIndex := 0
2687 else
2688 ItemIndex := 1;
2689 end;
2690 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2691 begin
2692 Name := 'swMonsters';
2693 AddItem(_lc[I_MENU_YES]);
2694 AddItem(_lc[I_MENU_NO]);
2695 if LongBool(gsGameFlags and GAME_OPTION_MONSTERS) then
2696 ItemIndex := 0
2697 else
2698 ItemIndex := 1;
2699 end;
2700 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2701 begin
2702 Name := 'swBotsVS';
2703 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2704 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2705 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2706 ItemIndex := 2;
2707 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSMONSTER) then
2708 ItemIndex := 0;
2709 if not LongBool(gsGameFlags and GAME_OPTION_BOTVSPLAYER) then
2710 ItemIndex := 1;
2711 end;
2712 with AddSwitch(_lc[I_MENU_FLAG_DROP]) do
2713 begin
2714 Name := 'swFlagDrop';
2715 AddItem(_lc[I_MENU_FLAG_THROW]);
2716 AddItem(_lc[I_MENU_YES]);
2717 AddItem(_lc[I_MENU_NO]);
2718 if (gsGameFlags and (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG)) = (GAME_OPTION_ALLOWDROPFLAG or GAME_OPTION_THROWFLAG) then
2719 ItemIndex := 0
2720 else if LongBool(gsGameFlags and GAME_OPTION_ALLOWDROPFLAG) then
2721 ItemIndex := 1
2722 else
2723 ItemIndex := 2;
2724 end;
2725 AddSpace();
2726 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2728 ReAlign();
2729 end;
2730 Menu.DefControl := 'mCustomGameMenu';
2731 g_GUI_AddWindow(Menu);
2733 Menu := TGUIWindow.Create('CampaignMenu');
2734 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2735 begin
2736 Name := 'mCampaignMenu';
2738 AddSpace();
2739 AddSpace();
2740 AddSpace();
2741 AddSpace();
2742 AddSpace();
2743 AddSpace();
2745 with AddFileList('', 15, 4) do
2746 begin
2747 Name := 'lsWAD';
2748 OnChange := ProcSelectCampaignWAD;
2750 Sort := True;
2751 Dirs := True;
2752 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2753 SetBase(MegawadDirs);
2754 end;
2756 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2757 begin
2758 Name := 'lbWADName';
2759 FixedLength := 8;
2760 Enabled := False;
2761 end;
2762 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2763 begin
2764 Name := 'lbWADAuthor';
2765 FixedLength := 8;
2766 Enabled := False;
2767 end;
2768 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2769 with AddMemo('', 15, 3) do
2770 begin
2771 Name := 'meWADDescription';
2772 Color := MENU_ITEMSCTRL_COLOR;
2773 end;
2774 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2775 begin
2776 Name := 'swPlayers';
2777 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2778 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2779 end;
2780 AddSpace();
2781 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2783 ReAlign();
2785 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2786 begin
2787 Name := 'mpWADImage';
2788 DefaultRes := 'NOPIC';
2789 X := GetControl('lsWAD').X+4;
2790 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2791 end;
2792 end;
2793 Menu.DefControl := 'mCampaignMenu';
2794 g_GUI_AddWindow(Menu);
2796 Menu := TGUIWindow.Create('SelectMapMenu');
2797 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2798 begin
2799 Name := 'mSelectMapMenu';
2800 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2801 begin
2802 Name := 'lsMapWAD';
2803 OnChange := ProcSelectWAD;
2805 Sort := True;
2806 Dirs := True;
2807 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2808 SetBase(MapDirs);
2809 end;
2810 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2811 begin
2812 Name := 'lsMapRes';
2813 Sort := True;
2814 OnChange := ProcSelectMap;
2815 end;
2816 AddSpace();
2817 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2818 begin
2819 Name := 'lbMapName';
2820 FixedLength := 24;
2821 Enabled := False;
2822 end;
2823 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2824 begin
2825 Name := 'lbMapAuthor';
2826 FixedLength := 16;
2827 Enabled := False;
2828 end;
2829 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2830 begin
2831 Name := 'lbMapSize';
2832 FixedLength := 10;
2833 Enabled := False;
2834 end;
2835 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 20, 4) do
2836 begin
2837 Name := 'meMapDescription';
2838 end;
2840 ReAlign();
2842 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2843 begin
2844 Name := 'mpMapPreview';
2845 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2846 Y := GetControl('lsMapWAD').Y;
2847 end;
2848 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2849 begin
2850 Name := 'lbMapScale';
2851 FixedLength := 8;
2852 Enabled := False;
2853 Color := MENU_ITEMSCTRL_COLOR;
2854 X := GetControl('lsMapWAD').X +
2855 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2856 2 + MAPPREVIEW_WIDTH*4;
2857 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2858 end;
2859 end;
2860 Menu.OnClose := ProcSetMap;
2861 Menu.DefControl := 'mSelectMapMenu';
2862 g_GUI_AddWindow(Menu);
2864 Menu := TGUIWindow.Create('ItemsRespawnMenu');
2865 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_ITEM_RESPAWN]))) do
2866 begin
2867 Name := 'mItemsRespawnMenu';
2869 // Switches separate from the time entry fields
2870 with AddSwitch(_lc[I_MENU_ENABLE_RULEZ_RANDOM]) do
2871 begin
2872 Name := 'swRulezRandom';
2873 AddItem(_lc[I_MENU_YES]);
2874 AddItem(_lc[I_MENU_NO]);
2875 if LongBool(gsGameFlags and GAME_OPTION_RULEZRANDOM) then
2876 ItemIndex := 0
2877 else
2878 ItemIndex := 1;
2879 end;
2880 with AddSwitch(_lc[I_MENU_ENABLE_ITEM_RANDOM]) do
2881 begin
2882 Name := 'swItemsRandom';
2883 AddItem(_lc[I_MENU_ITEM_RANDOM_ALL]);
2884 AddItem(_lc[I_MENU_ITEM_RANDOM_HELP_ONLY]);
2885 AddItem(_lc[I_MENU_ITEM_RANDOM_AMMO_ONLY]);
2886 AddItem(_lc[I_MENU_ITEM_RANDOM_WEAPON_ONLY]);
2887 AddItem(_lc[I_MENU_ITEM_RANDOM_NOTHING]);
2888 if LongBool(gsGameFlags and GAME_OPTION_ITEMALLRANDOM) then
2889 ItemIndex := 0
2890 else if LongBool(gsGameFlags and GAME_OPTION_ITEMHELPRANDOM) then
2891 ItemIndex := 1
2892 else if LongBool(gsGameFlags and GAME_OPTION_ITEMAMMORANDOM) then
2893 ItemIndex := 2
2894 else if LongBool(gsGameFlags and GAME_OPTION_ITEMWEAPONRANDOM) then
2895 ItemIndex := 3
2896 else
2897 ItemIndex := 4;
2898 end;
2899 AddSpace();// Items Respawn block
2900 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_TIME]) do
2901 begin
2902 Name := 'edItemRespawnTime';
2903 OnlyDigits := True;
2904 Width := 4;
2905 MaxLength := 5;
2906 if gsItemRespawnTime > 0 then
2907 Text := IntToStr(gsItemRespawnTime);
2908 end;
2909 with AddEdit(_lc[I_MENU_ITEM_RESPAWN_RANDOM]) do
2910 begin
2911 Name := 'edItemRespawnRandom';
2912 OnlyDigits := True;
2913 Width := 4;
2914 MaxLength := 5;
2915 if gsItemRespawnTime > 0 then
2916 Text := IntToStr(gsItemRespawnRandom);
2917 end;
2918 // Rulez Respawn block
2919 with AddEdit(_lc[I_MENU_RULEZ_RESPAWN_TIME]) do
2920 begin
2921 Name := 'edRulezRespawnTime';
2922 OnlyDigits := True;
2923 Width := 4;
2924 MaxLength := 5;
2925 if gsRulezRespawnTime > 0 then
2926 Text := IntToStr(gsRulezRespawnTime);
2927 end;
2928 with AddEdit(_lc[I_MENU_RULEZ_RESPAWN_RANDOM]) do
2929 begin
2930 Name := 'edRulezRespawnRandom';
2931 OnlyDigits := True;
2932 Width := 4;
2933 MaxLength := 5;
2934 if gsRulezRespawnRandom > 0 then
2935 Text := IntToStr(gsRulezRespawnRandom);
2936 end;
2937 AddSpace();
2938 end;
2939 Menu.DefControl := 'mItemsRespawnMenu';
2940 g_GUI_AddWindow(Menu);
2942 Menu := TGUIWindow.Create('OptionsMenu');
2943 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_OPTIONS]))) do
2944 begin
2945 Name := 'mmOptionsMenu';
2946 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2947 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2948 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2949 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2950 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2951 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2952 AddSpace();
2953 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2954 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2955 end;
2956 Menu.OnClose := ProcApplyOptions;
2957 Menu.DefControl := 'mmOptionsMenu';
2958 g_GUI_AddWindow(Menu);
2960 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2961 gMenuSmallFont, @ProcSavedMenuKeyDown);
2962 g_GUI_AddWindow(Menu);
2964 Menu := TGUIWindow.Create('OptionsVideoMenu');
2965 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2966 begin
2967 Name := 'mOptionsVideoMenu';
2968 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2969 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2970 begin
2971 Name := 'swBPP';
2972 AddItem('16');
2973 AddItem('32');
2974 end;
2975 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2976 begin
2977 Name := 'swVSync';
2978 AddItem(_lc[I_MENU_YES]);
2979 AddItem(_lc[I_MENU_NO]);
2980 end;
2981 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2982 begin
2983 Name := 'swTextureFilter';
2984 AddItem(_lc[I_MENU_YES]);
2985 AddItem(_lc[I_MENU_NO]);
2986 end;
2987 with AddSwitch(_lc[I_MENU_VIDEO_INTERPOLATION]) do
2988 begin
2989 Name := 'swInterp';
2990 AddItem(_lc[I_MENU_YES]);
2991 AddItem(_lc[I_MENU_NO]);
2992 end;
2993 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2994 begin
2995 Name := 'swLegacyNPOT';
2996 AddItem(_lc[I_MENU_NO]);
2997 AddItem(_lc[I_MENU_YES]);
2998 end;
2999 AddSpace();
3000 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
3001 ReAlign();
3002 end;
3003 Menu.DefControl := 'mOptionsVideoMenu';
3004 g_GUI_AddWindow(Menu);
3006 Menu := TGUIWindow.Create('OptionsVideoResMenu');
3007 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
3008 begin
3009 Name := 'mOptionsVideoResMenu';
3010 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
3011 begin
3012 Name := 'lbCurrentRes';
3013 FixedLength := 24;
3014 Enabled := False;
3015 end;
3016 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
3017 begin
3018 Name := 'lsResolution';
3019 Sort := False;
3020 end;
3021 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
3022 begin
3023 Name := 'swFullScreen';
3024 AddItem(_lc[I_MENU_YES]);
3025 AddItem(_lc[I_MENU_NO]);
3026 end;
3027 with AddSwitch(_lc[I_MENU_GAME_SCALE_FACTOR]) do
3028 begin
3029 Name := 'swResFactor';
3030 AddItem('1x');
3031 for i := 2 to gRC_Width div 640 do
3032 AddItem(IntToStr(i) + 'x');
3033 end;
3034 AddSpace();
3035 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
3036 UpdateIndex();
3037 end;
3038 Menu.DefControl := 'mOptionsVideoResMenu';
3039 g_GUI_AddWindow(Menu);
3041 Menu := TGUIWindow.Create('OptionsSoundMenu');
3042 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
3043 begin
3044 Name := 'mOptionsSoundMenu';
3045 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
3046 begin
3047 Name := 'scMusicLevel';
3048 Max := 16;
3049 OnChange := ProcChangeSoundSettings;
3050 end;
3051 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
3052 begin
3053 Name := 'scSoundLevel';
3054 Max := 16;
3055 OnChange := ProcChangeSoundSettings;
3056 end;
3057 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
3058 begin
3059 Name := 'scMaxSimSounds';
3060 Max := 16;
3061 end;
3062 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
3063 begin;
3064 Name := 'swAnnouncer';
3065 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
3066 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
3067 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
3068 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
3069 end;
3070 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
3071 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
3072 begin;
3073 Name := 'swSoundEffects';
3074 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
3075 AddItem(_lc[I_MENU_COMPAT_DF]);
3076 end;
3077 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
3078 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
3079 begin;
3080 Name := 'swChatSpeech';
3081 AddItem(_lc[I_MENU_YES]);
3082 AddItem(_lc[I_MENU_NO]);
3083 end;
3084 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
3085 begin
3086 Name := 'swInactiveSounds';
3087 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
3088 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
3089 end;
3090 ReAlign();
3091 end;
3092 Menu.DefControl := 'mOptionsSoundMenu';
3093 g_GUI_AddWindow(Menu);
3095 Menu := TGUIWindow.Create('OptionsGameMenu');
3096 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
3097 begin
3098 Name := 'mOptionsGameMenu';
3099 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
3100 begin
3101 Name := 'scParticlesCount';
3102 Max := 20;
3103 end;
3104 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
3105 begin
3106 Name := 'swBloodCount';
3107 AddItem(_lc[I_MENU_COUNT_NONE]);
3108 AddItem(_lc[I_MENU_COUNT_SMALL]);
3109 AddItem(_lc[I_MENU_COUNT_NORMAL]);
3110 AddItem(_lc[I_MENU_COUNT_BIG]);
3111 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
3112 end;
3113 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
3114 begin
3115 Name := 'scShellsMax';
3116 Max := 20;
3117 end;
3118 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
3119 begin
3120 Name := 'scGibsMax';
3121 Max := 20;
3122 end;
3123 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
3124 begin
3125 Name := 'scCorpsesMax';
3126 Max := 20;
3127 end;
3128 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
3129 begin
3130 Name := 'swGibsCount';
3131 AddItem(_lc[I_MENU_COUNT_NONE]);
3132 AddItem(_lc[I_MENU_COUNT_SMALL]);
3133 AddItem(_lc[I_MENU_COUNT_NORMAL]);
3134 AddItem(_lc[I_MENU_COUNT_BIG]);
3135 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
3136 end;
3137 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
3138 begin
3139 Name := 'swCorpseType';
3140 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
3141 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
3142 end;
3143 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
3144 begin
3145 Name := 'swGibsType';
3146 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
3147 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
3148 end;
3149 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
3150 begin
3151 Name := 'swBloodType';
3152 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
3153 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
3154 end;
3155 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
3156 begin
3157 Name := 'swScreenFlash';
3158 AddItem(_lc[I_MENU_NO]);
3159 AddItem(_lc[I_MENU_COMPAT_DF]);
3160 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
3161 end;
3162 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
3163 begin
3164 Name := 'swBackground';
3165 AddItem(_lc[I_MENU_YES]);
3166 AddItem(_lc[I_MENU_NO]);
3167 end;
3168 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
3169 begin
3170 Name := 'swMessages';
3171 AddItem(_lc[I_MENU_YES]);
3172 AddItem(_lc[I_MENU_NO]);
3173 end;
3174 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
3175 begin
3176 Name := 'swRevertPlayers';
3177 AddItem(_lc[I_MENU_YES]);
3178 AddItem(_lc[I_MENU_NO]);
3179 end;
3180 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
3181 begin
3182 Name := 'swChatBubble';
3183 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
3184 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
3185 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
3186 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
3187 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
3188 end;
3189 with AddSwitch(_lc[I_MENU_GAME_PLAYER_INDICATOR]) do
3190 begin
3191 Name := 'swPlayerIndicator';
3192 AddItem(_lc[I_MENU_GAME_INDICATOR_NONE]);
3193 AddItem(_lc[I_MENU_GAME_INDICATOR_OWN]);
3194 AddItem(_lc[I_MENU_GAME_INDICATOR_ALL]);
3195 end;
3196 with AddSwitch(_lc[I_MENU_GAME_INDICATOR_STYLE]) do
3197 begin
3198 Name := 'swPlayerIndicatorStyle';
3199 AddItem(_lc[I_MENU_GAME_INDICATOR_ARROW]);
3200 AddItem(_lc[I_MENU_GAME_INDICATOR_NAME]);
3201 end;
3202 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
3203 begin
3204 Name := 'scScaleFactor';
3205 Max := 10;
3206 OnChange := ProcChangeGameSettings;
3207 end;
3208 ReAlign();
3209 end;
3210 Menu.DefControl := 'mOptionsGameMenu';
3211 g_GUI_AddWindow(Menu);
3213 Menu := TGUIWindow.Create('OptionsControlsMenu');
3214 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
3215 begin
3216 Name := 'mOptionsControlsMenu';
3217 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
3218 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
3219 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
3220 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
3221 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
3222 AddSpace();
3223 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
3224 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
3225 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
3226 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
3227 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
3228 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
3229 if e_HasJoysticks then
3230 begin
3231 AddSpace();
3232 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
3233 end;
3234 if g_touch_enabled then
3235 begin
3236 AddSpace();
3237 AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
3238 end;
3239 end;
3240 Menu.DefControl := 'mOptionsControlsMenu';
3241 g_GUI_AddWindow(Menu);
3243 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
3244 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
3245 begin
3246 Name := 'mOptionsControlsP1Menu';
3247 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
3248 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
3249 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
3250 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
3251 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
3252 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
3253 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
3254 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
3255 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
3256 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
3257 AddKeyRead2(_lc[I_MENU_CONTROL_DROPFLAG]).Name := _lc[I_MENU_CONTROL_DROPFLAG];
3258 end;
3259 Menu.DefControl := 'mOptionsControlsP1Menu';
3260 g_GUI_AddWindow(Menu);
3262 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
3263 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
3264 begin
3265 Name := 'mOptionsControlsP1MenuWeapons';
3266 for i := WP_FIRST to WP_LAST do
3267 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
3268 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
3269 end;
3270 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
3271 g_GUI_AddWindow(Menu);
3273 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
3274 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
3275 begin
3276 Name := 'mOptionsControlsP2Menu';
3277 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
3278 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
3279 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
3280 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
3281 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
3282 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
3283 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
3284 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
3285 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
3286 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
3287 AddKeyRead2(_lc[I_MENU_CONTROL_DROPFLAG]).Name := _lc[I_MENU_CONTROL_DROPFLAG];
3288 end;
3289 Menu.DefControl := 'mOptionsControlsP2Menu';
3290 g_GUI_AddWindow(Menu);
3292 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
3293 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
3294 begin
3295 Name := 'mOptionsControlsP2MenuWeapons';
3296 for i := WP_FIRST to WP_LAST do
3297 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
3298 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
3299 end;
3300 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
3301 g_GUI_AddWindow(Menu);
3303 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
3304 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
3305 begin
3306 Name := 'mOptionsControlsJoystickMenu';
3307 for i := 0 to e_MaxJoys - 1 do
3308 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
3309 begin
3310 Name := 'scDeadzone' + IntToStr(i);
3311 Max := 20
3312 end
3313 end;
3314 Menu.DefControl := 'mOptionsControlsJoystickMenu';
3315 g_GUI_AddWindow(Menu);
3317 Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
3318 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do
3319 begin
3320 Name := 'mOptionsControlsTouchMenu';
3321 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
3322 begin
3323 Name := 'swTouchAlt';
3324 AddItem(_lc[I_MENU_NO]);
3325 AddItem(_lc[I_MENU_YES]);
3326 OnChange := ProcChangeTouchSettings;
3327 end;
3328 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
3329 begin
3330 Name := 'scTouchSize';
3331 Max := 20;
3332 OnChange := ProcChangeTouchSettings;
3333 end;
3334 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
3335 begin
3336 Name := 'swTouchFire';
3337 AddItem(_lc[I_MENU_NO]);
3338 AddItem(_lc[I_MENU_YES]);
3339 end;
3340 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do
3341 begin
3342 Name := 'scTouchOffset';
3343 Max := 20;
3344 OnChange := ProcChangeTouchSettings;
3345 end;
3346 end;
3347 Menu.DefControl := 'mOptionsControlsTouchMenu';
3348 g_GUI_AddWindow(Menu);
3350 Menu := TGUIWindow.Create('OptionsPlayersMenu');
3351 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
3352 begin
3353 Name := 'mOptionsPlayersMenu';
3354 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
3355 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
3356 end;
3357 Menu.DefControl := 'mOptionsPlayersMenu';
3358 g_GUI_AddWindow(Menu);
3360 CreatePlayerOptionsMenu('P1');
3361 CreatePlayerOptionsMenu('P2');
3363 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
3364 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
3365 begin
3366 Name := 'mOptionsPlayersMIMenu';
3367 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
3368 begin
3369 Name := 'lbName';
3370 FixedLength := 16;
3371 end;
3372 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
3373 begin
3374 Name := 'lbAuthor';
3375 FixedLength := 16;
3376 end;
3377 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
3378 begin
3379 Name := 'meComment';
3380 end;
3381 AddSpace();
3382 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
3383 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
3384 begin
3385 Name := 'lbWeapon';
3386 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
3387 end;
3388 ReAlign();
3389 end;
3390 Menu.DefControl := 'mOptionsPlayersMIMenu';
3391 g_GUI_AddWindow(Menu);
3393 Menu := TGUIWindow.Create('OptionsPlayersP1WeaponMenu');
3394 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_WEAPON]))) do
3395 begin
3396 Name := 'mOptionsPlayersP1WeaponMenu';
3397 with AddSwitch(_lc[I_MENU_WEAPON_SWITCH]) do
3398 begin
3399 Name := 'swWeaponAutoswitch';
3400 AddItem(_lc[I_MENU_NO]);
3401 AddItem(_lc[I_MENU_WEAPON_SWITCH_LINEAR]);
3402 AddItem(_lc[I_MENU_WEAPON_SWITCH_PREFERENCE]);
3403 end;
3404 with AddSwitch(_lc[I_MENU_WEAPON_ALLOW_EMPTY]) do
3405 begin
3406 Name := 'swWeaponAllowEmpty';
3407 AddItem(_lc[I_MENU_YES]);
3408 AddItem(_lc[I_MENU_NO]);
3409 end;
3410 with AddSwitch(_lc[I_MENU_KASTET_ALLOW]) do
3411 begin
3412 Name := 'swWeaponAllowFist';
3413 AddItem(_lc[I_MENU_KASTET_ALLOW_ALWAYS]);
3414 AddItem(_lc[I_MENU_KASTET_ALLOW_BERSERK]);
3415 end;
3416 AddButton(@ProcOptionsPlayerP1WeaponPreferencesMenu, _lc[I_MENU_WEAPON_SWITCH_PRIORITY]);
3417 ReAlign();
3418 end;
3419 Menu.DefControl := 'mOptionsPlayersP1WeaponMenu';
3420 g_GUI_AddWindow(Menu);
3422 Menu := TGUIWindow.Create('OptionsPreferencesP1WeaponMenu');
3423 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_WEAPON_PRIORITY_PLAYER_1]))) do
3424 begin
3425 Name := 'mOptionsPreferencesP1WeaponMenu';
3426 for i := WP_FIRST to WP_LAST do
3427 begin
3428 with AddSwitch(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]) do
3429 begin
3430 Name := IntToStr(i);
3431 for a := WP_FIRST to WP_LAST+1 do
3432 begin
3433 AddItem(IntToStr(a));
3434 end;
3435 ItemIndex := i
3436 end;
3437 end;
3438 with AddSwitch(_lc[I_GAME_WEAPON_BERSERK]) do
3439 begin
3440 Name := IntToStr(WP_LAST+1);
3441 for a := WP_FIRST to WP_LAST+1 do
3442 begin
3443 AddItem(IntToStr(a));
3444 end;
3445 ItemIndex := WP_LAST + 1;
3446 end;
3447 end;
3448 Menu.DefControl := 'mOptionsPreferencesP1WeaponMenu';
3449 g_GUI_AddWindow(Menu);
3452 Menu := TGUIWindow.Create('OptionsPlayersP2WeaponMenu');
3453 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_WEAPON]))) do
3454 begin
3455 Name := 'mOptionsPlayersP2WeaponMenu';
3456 with AddSwitch(_lc[I_MENU_WEAPON_SWITCH]) do
3457 begin
3458 Name := 'swWeaponAutoswitch';
3459 AddItem(_lc[I_MENU_NO]);
3460 AddItem(_lc[I_MENU_WEAPON_SWITCH_LINEAR]);
3461 AddItem(_lc[I_MENU_WEAPON_SWITCH_PREFERENCE]);
3462 end;
3463 with AddSwitch(_lc[I_MENU_WEAPON_ALLOW_EMPTY]) do
3464 begin
3465 Name := 'swWeaponAllowEmpty';
3466 AddItem(_lc[I_MENU_YES]);
3467 AddItem(_lc[I_MENU_NO]);
3468 end;
3469 with AddSwitch(_lc[I_MENU_KASTET_ALLOW]) do
3470 begin
3471 Name := 'swWeaponAllowFist';
3472 AddItem(_lc[I_MENU_KASTET_ALLOW_ALWAYS]);
3473 AddItem(_lc[I_MENU_KASTET_ALLOW_BERSERK]);
3474 end;
3475 AddButton(@ProcOptionsPlayerP2WeaponPreferencesMenu, _lc[I_MENU_WEAPON_SWITCH_PRIORITY]);
3476 ReAlign();
3477 end;
3478 Menu.DefControl := 'mOptionsPlayersP2WeaponMenu';
3479 g_GUI_AddWindow(Menu);
3481 Menu := TGUIWindow.Create('OptionsPreferencesP2WeaponMenu');
3482 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_WEAPON_PRIORITY_PLAYER_2]))) do
3483 begin
3484 Name := 'mOptionsPreferencesP2WeaponMenu';
3485 for i := WP_FIRST to WP_LAST do
3486 begin
3487 with AddSwitch(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]) do
3488 begin
3489 Name := IntToStr(i);
3490 for a := WP_FIRST to WP_LAST+1 do
3491 begin
3492 AddItem(IntToStr(a));
3493 end;
3494 ItemIndex := i
3495 end;
3496 end;
3497 with AddSwitch(_lc[I_GAME_WEAPON_BERSERK]) do
3498 begin
3499 Name := IntToStr(WP_LAST+1);
3500 for a := WP_FIRST to WP_LAST+1 do
3501 begin
3502 AddItem(IntToStr(a));
3503 end;
3504 ItemIndex := WP_LAST + 1;
3505 end;
3506 end;
3507 Menu.DefControl := 'mOptionsPreferencesP2WeaponMenu';
3508 g_GUI_AddWindow(Menu);
3510 Menu := TGUIWindow.Create('OptionsLanguageMenu');
3511 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
3512 begin
3513 Name := 'mOptionsLanguageMenu';
3514 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
3515 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
3516 ReAlign();
3517 end;
3518 Menu.DefControl := 'mOptionsLanguageMenu';
3519 g_GUI_AddWindow(Menu);
3521 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
3522 gMenuSmallFont, @ProcDefaultMenuKeyDown);
3523 g_GUI_AddWindow(Menu);
3525 Menu := TGUIWindow.Create('AuthorsMenu');
3526 Menu.BackTexture := 'INTER';
3527 Menu.OnClose := ProcAuthorsClose;
3529 // Çàãîëîâîê:
3530 _y := 16;
3531 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
3532 begin
3533 Color := _RGB(255, 0, 0);
3534 X := (gScreenWidth div 2)-(GetWidth() div 2);
3535 Y := _y;
3536 _y := _y+GetHeight();
3537 end;
3538 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
3539 begin
3540 Color := _RGB(255, 0, 0);
3541 X := (gScreenWidth div 2)-(GetWidth() div 2);
3542 Y := _y;
3543 _y := _y+GetHeight()+32;
3544 end;
3545 // ×òî äåëàë: Êòî äåëàë
3546 cx := gScreenWidth div 2 - 320 + 64;
3547 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
3548 begin
3549 Color := _RGB(255, 0, 0);
3550 X := cx;
3551 Y := _y;
3552 _y := _y+22;
3553 end;
3554 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
3555 begin
3556 Color := _RGB(255, 255, 255);
3557 X := cx+32;
3558 Y := _y;
3559 _y := _y+36;
3560 end;
3561 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
3562 begin
3563 Color := _RGB(255, 0, 0);
3564 X := cx;
3565 Y := _y;
3566 _y := _y+22;
3567 end;
3568 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
3569 begin
3570 Color := _RGB(255, 255, 255);
3571 X := cx+32;
3572 Y := _y;
3573 _y := _y+22;
3574 end;
3575 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
3576 begin
3577 Color := _RGB(255, 255, 255);
3578 X := cx+32;
3579 Y := _y;
3580 _y := _y+36;
3581 end;
3582 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
3583 begin
3584 Color := _RGB(255, 0, 0);
3585 X := cx;
3586 Y := _y;
3587 _y := _y+22;
3588 end;
3589 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
3590 begin
3591 Color := _RGB(255, 255, 255);
3592 X := cx+32;
3593 Y := _y;
3594 _y := _y+36;
3595 end;
3596 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
3597 begin
3598 Color := _RGB(255, 0, 0);
3599 X := cx;
3600 Y := _y;
3601 _y := _y+22;
3602 end;
3603 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
3604 begin
3605 Color := _RGB(255, 255, 255);
3606 X := cx+32;
3607 Y := _y;
3608 _y := gScreenHeight - 128;
3609 end;
3610 // Çàêëþ÷åíèå:
3611 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
3612 begin
3613 Color := _RGB(255, 0, 0);
3614 X := cx;
3615 Y := _y;
3616 _y := _y+16;
3617 end;
3618 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
3619 begin
3620 Color := _RGB(255, 255, 255);
3621 X := cx+32;
3622 Y := _y;
3623 _y := _y+GetHeight();
3624 end;
3625 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
3626 begin
3627 Color := _RGB(255, 255, 255);
3628 X := cx+32;
3629 Y := _y;
3630 _y := _y+GetHeight();
3631 end;
3632 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
3633 begin
3634 Color := _RGB(255, 255, 255);
3635 X := cx+32;
3636 Y := _y;
3637 _y := gScreenHeight - 32;
3638 end;
3639 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
3640 begin
3641 Color := _RGB(255, 0, 0);
3642 X := gScreenWidth div 2 - GetWidth() div 2;
3643 Y := _y;
3644 end;
3645 g_GUI_AddWindow(Menu);
3647 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
3648 gMenuSmallFont, @ProcExitMenuKeyDown);
3649 g_GUI_AddWindow(Menu);
3651 Menu := TGUIWindow.Create('GameSingleMenu');
3652 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3653 begin
3654 Name := 'mmGameSingleMenu';
3655 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3656 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3657 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3658 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3659 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3660 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3661 end;
3662 Menu.DefControl := 'mmGameSingleMenu';
3663 Menu.MainWindow := True;
3664 Menu.OnClose := ProcGMClose;
3665 Menu.OnShow := ProcGMShow;
3666 g_GUI_AddWindow(Menu);
3668 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
3669 gMenuSmallFont, @ProcEndMenuKeyDown);
3670 g_GUI_AddWindow(Menu);
3672 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
3673 gMenuSmallFont, @ProcRestartMenuKeyDown);
3674 g_GUI_AddWindow(Menu);
3676 Menu := TGUIWindow.Create('GameCustomMenu');
3677 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3678 begin
3679 Name := 'mmGameCustomMenu';
3680 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3681 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3682 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3683 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3684 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3685 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3686 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3687 end;
3688 Menu.DefControl := 'mmGameCustomMenu';
3689 Menu.MainWindow := True;
3690 Menu.OnClose := ProcGMClose;
3691 Menu.OnShow := ProcGMShow;
3692 g_GUI_AddWindow(Menu);
3694 Menu := TGUIWindow.Create('GameServerMenu');
3695 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3696 begin
3697 Name := 'mmGameServerMenu';
3698 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3699 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3700 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3701 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3702 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3703 end;
3704 Menu.DefControl := 'mmGameServerMenu';
3705 Menu.MainWindow := True;
3706 Menu.OnClose := ProcGMClose;
3707 Menu.OnShow := ProcGMShow;
3708 g_GUI_AddWindow(Menu);
3710 Menu := TGUIWindow.Create('GameClientMenu');
3711 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_MAIN_MENU]))) do
3712 begin
3713 Name := 'mmGameClientMenu';
3714 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3715 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3716 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3717 end;
3718 Menu.DefControl := 'mmGameClientMenu';
3719 Menu.MainWindow := True;
3720 Menu.OnClose := ProcGMClose;
3721 Menu.OnShow := ProcGMShow;
3722 g_GUI_AddWindow(Menu);
3724 Menu := TGUIWindow.Create('ClientPasswordMenu');
3725 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
3726 begin
3727 Name := 'mClientPasswordMenu';
3728 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3729 begin
3730 Name := 'edPW';
3731 Width := 12;
3732 MaxLength := 32;
3733 end;
3734 AddSpace;
3736 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3737 ReAlign();
3738 end;
3739 Menu.DefControl := 'mClientPasswordMenu';
3740 g_GUI_AddWindow(Menu);
3742 Menu := TGUIWindow.Create('GameSetGameMenu');
3743 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3744 begin
3745 Name := 'mGameSetGameMenu';
3746 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3747 begin
3748 Name := 'swTeamDamage';
3749 AddItem(_lc[I_MENU_YES]);
3750 AddItem(_lc[I_MENU_NO]);
3751 ItemIndex := 1;
3752 end;
3753 with AddSwitch(_lc[I_MENU_TEAM_HIT]) do
3754 begin
3755 Name := 'swTeamHit';
3756 AddItem(_lc[I_MENU_TEAM_HIT_BOTH]);
3757 AddItem(_lc[I_MENU_TEAM_HIT_TRACE]);
3758 AddItem(_lc[I_MENU_TEAM_HIT_PROJECTILE]);
3759 AddItem(_lc[I_MENU_TEAM_HIT_NOTHING]);
3760 ItemIndex := 0
3761 end;
3762 with AddSwitch(_lc[I_MENU_DEATHMATCH_KEYS]) do
3763 begin
3764 Name := 'swDeathmatchKeys';
3765 AddItem(_lc[I_MENU_YES]);
3766 AddItem(_lc[I_MENU_NO]);
3767 ItemIndex := 1;
3768 end;
3769 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3770 begin
3771 Name := 'edTimeLimit';
3772 OnlyDigits := True;
3773 Width := 4;
3774 MaxLength := 5;
3775 end;
3776 with AddEdit(_lc[I_MENU_SCORE_LIMIT]) do
3777 begin
3778 Name := 'edScoreLimit';
3779 OnlyDigits := True;
3780 Width := 4;
3781 MaxLength := 5;
3782 end;
3783 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3784 begin
3785 Name := 'edMaxLives';
3786 OnlyDigits := True;
3787 Width := 4;
3788 MaxLength := 5;
3789 end;
3790 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3791 begin
3792 Name := 'swBotsVS';
3793 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3794 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3795 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3796 ItemIndex := 2;
3797 end;
3798 with AddSwitch(_lc[I_MENU_FLAG_DROP]) do
3799 begin
3800 Name := 'swFlagDrop';
3801 AddItem(_lc[I_MENU_FLAG_THROW]);
3802 AddItem(_lc[I_MENU_YES]);
3803 AddItem(_lc[I_MENU_NO]);
3804 ItemIndex := 2;
3805 end;
3807 ReAlign();
3808 end;
3809 Menu.DefControl := 'mGameSetGameMenu';
3810 Menu.OnClose := ProcApplyGameSet;
3811 g_GUI_AddWindow(Menu);
3813 Menu := TGUIWindow.Create('TeamMenu');
3814 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, '', _lc[I_MENU_CHANGE_PLAYERS]))) do
3815 begin
3816 Name := 'mmTeamMenu';
3817 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3818 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3819 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3820 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3821 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3822 end;
3823 Menu.DefControl := 'mmTeamMenu';
3824 Menu.OnShow := ProcChangePlayers;
3825 g_GUI_AddWindow(Menu);
3826 end;
3828 procedure g_Menu_Show_SaveMenu();
3829 begin
3830 if g_Game_IsTestMap then
3831 Exit;
3832 if gGameSettings.GameType = GT_SINGLE then
3833 g_GUI_ShowWindow('GameSingleMenu')
3834 else
3835 begin
3836 if g_Game_IsClient then
3837 Exit
3838 else
3839 if g_Game_IsNet then
3840 Exit
3841 else
3842 g_GUI_ShowWindow('GameCustomMenu');
3843 end;
3844 g_GUI_ShowWindow('SaveMenu');
3845 g_Sound_PlayEx('MENU_OPEN');
3846 end;
3848 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3849 begin
3850 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3851 if gGameSettings.GameType = GT_SINGLE then
3852 begin
3853 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3854 end
3855 else
3856 begin
3857 if g_Game_IsClient then exit;
3858 if g_Game_IsNet then exit;
3859 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3860 end;
3861 g_GUI_ShowWindow('LoadMenu');
3862 g_Sound_PlayEx('MENU_OPEN');
3863 end;
3865 procedure g_Menu_Show_GameSetGame();
3866 begin
3867 if gGameSettings.GameType = GT_SINGLE then
3868 g_GUI_ShowWindow('GameSingleMenu')
3869 else
3870 begin
3871 if g_Game_IsClient then
3872 Exit
3873 else
3874 if g_Game_IsNet then
3875 g_GUI_ShowWindow('GameServerMenu')
3876 else
3877 g_GUI_ShowWindow('GameCustomMenu');
3878 end;
3879 ReadGameSettings();
3880 g_GUI_ShowWindow('GameSetGameMenu');
3881 g_Sound_PlayEx('MENU_OPEN');
3882 end;
3884 procedure g_Menu_Show_OptionsVideo();
3885 begin
3886 if gGameSettings.GameType = GT_SINGLE then
3887 g_GUI_ShowWindow('GameSingleMenu')
3888 else
3889 begin
3890 if g_Game_IsClient then
3891 g_GUI_ShowWindow('GameClientMenu')
3892 else
3893 if g_Game_IsNet then
3894 g_GUI_ShowWindow('GameServerMenu')
3895 else
3896 g_GUI_ShowWindow('GameCustomMenu');
3897 end;
3898 ReadOptions();
3899 g_GUI_ShowWindow('OptionsMenu');
3900 g_GUI_ShowWindow('OptionsVideoMenu');
3901 g_Sound_PlayEx('MENU_OPEN');
3902 end;
3904 procedure g_Menu_Show_OptionsSound();
3905 begin
3906 if gGameSettings.GameType = GT_SINGLE then
3907 g_GUI_ShowWindow('GameSingleMenu')
3908 else
3909 begin
3910 if g_Game_IsClient then
3911 g_GUI_ShowWindow('GameClientMenu')
3912 else
3913 if g_Game_IsNet then
3914 g_GUI_ShowWindow('GameServerMenu')
3915 else
3916 g_GUI_ShowWindow('GameCustomMenu');
3917 end;
3918 ReadOptions();
3919 g_GUI_ShowWindow('OptionsMenu');
3920 g_GUI_ShowWindow('OptionsSoundMenu');
3921 g_Sound_PlayEx('MENU_OPEN');
3922 end;
3924 procedure g_Menu_Show_EndGameMenu();
3925 begin
3926 g_GUI_ShowWindow('EndGameMenu');
3927 g_Sound_PlayEx('MENU_OPEN');
3928 end;
3930 procedure g_Menu_Show_QuitGameMenu();
3931 begin
3932 g_GUI_ShowWindow('ExitMenu');
3933 g_Sound_PlayEx('MENU_OPEN');
3934 end;
3936 procedure g_Menu_Init();
3937 begin
3938 MenuLoadData();
3939 g_GUI_Init();
3940 CreateAllMenus();
3941 end;
3943 procedure g_Menu_Free();
3944 begin
3945 g_GUI_Destroy();
3947 e_WriteLog('Releasing menu data...', TMsgType.Notify);
3949 MenuFreeData();
3950 end;
3952 procedure g_Menu_Reset();
3953 var
3954 ex: Boolean;
3955 begin
3956 g_GUI_SaveMenuPos();
3957 ex := g_GUI_Destroy();
3959 if ex then
3960 begin
3961 e_WriteLog('Recreating menu...', TMsgType.Notify);
3963 CreateAllMenus();
3965 if gDebugMode then
3966 g_Game_SetDebugMode();
3968 g_GUI_LoadMenuPos();
3969 end;
3970 end;
3972 end.