DEADSOFTWARE

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