DEADSOFTWARE

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