DEADSOFTWARE

d4fb7389faef624027406643c62c399e94b337cf
[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, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *)
16 {$INCLUDE ../shared/a_modes.inc}
17 unit g_menu;
19 interface
21 procedure g_Menu_Init();
22 procedure g_Menu_Free();
23 procedure g_Menu_Reset();
24 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
25 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
26 procedure g_Menu_AskLanguage();
28 procedure g_Menu_Show_SaveMenu();
29 procedure g_Menu_Show_LoadMenu(standalone: Boolean=false);
30 procedure g_Menu_Show_GameSetGame();
31 procedure g_Menu_Show_OptionsVideo();
32 procedure g_Menu_Show_OptionsSound();
33 procedure g_Menu_Show_EndGameMenu();
34 procedure g_Menu_Show_QuitGameMenu();
36 var
37 gMenuFont: DWORD;
38 gMenuSmallFont: DWORD;
39 PromptIP: string;
40 PromptPort: Word;
42 implementation
44 uses
45 {$INCLUDE ../nogl/noGLuses.inc}
46 g_gui, g_textures, e_graphics, g_main, g_window, g_game, g_map,
47 g_basic, g_console, g_sound, g_gfx, g_player, g_options, g_weapons,
48 e_log, SysUtils, CONFIG, g_playermodel, DateUtils, sdl2,
49 MAPDEF, Math, g_saveload,
50 e_texture, g_language,
51 g_net, g_netmsg, g_netmaster, g_items, e_input, g_touch,
52 utils, wadreader;
55 type TYNCallback = procedure (yes:Boolean);
57 procedure YNKeyDownProc (win: TGUIWindow; Key: Byte);
58 begin
59 if win.UserData = nil then exit;
60 case Key of
61 IK_Y, IK_SPACE: TYNCallback(win.UserData)(true);
62 IK_N: TYNCallback(win.UserData)(false);
63 end;
64 end;
66 procedure YesButtonCB (ctl: TGUITextButton);
67 begin
68 if ctl.UserData = nil then exit;
69 TYNCallback(ctl.UserData)(true);
70 end;
72 procedure NoButtonCB (ctl: TGUITextButton);
73 begin
74 if ctl.UserData = nil then exit;
75 TYNCallback(ctl.UserData)(false);
76 end;
78 function CreateYNMenu (WinName, Text: String; MaxLen: Word; FontID: DWORD; ActionProc: TYNCallback): TGUIWindow;
79 var
80 menu: TGUIMenu;
81 begin
82 //if length(Text) = 0 then exit;
83 Result := TGUIWindow.Create(WinName);
84 with Result do
85 begin
86 //OnKeyDownEx := @YNKeyDownProc;
87 //UserData := @ActionProc;
88 menu := TGUIMenu(Result.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, '')));
89 with menu do
90 begin
91 Name := '__temp_yes_no_menu:'+WinName;
92 YesNo := true;
93 AddText(Text, MaxLen);
94 with AddButton(nil, _lc[I_MENU_YES]) do begin ProcEx := @YesButtonCB; UserData := @ActionProc; end;
95 with AddButton(nil, _lc[I_MENU_NO]) do begin ProcEx := @NoButtonCB; UserData := @ActionProc; end;
96 end;
97 DefControl := '__temp_yes_no_menu:'+WinName;
98 SetActive(nil);
99 end;
100 end;
103 procedure ProcChangeColor(Sender: TGUIControl); forward;
104 procedure ProcSelectModel(Sender: TGUIControl); forward;
106 procedure ProcApplyOptions();
107 var
108 menu: TGUIMenu;
109 i: Integer;
110 ovs: Boolean;
111 begin
112 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
114 if TGUISwitch(menu.GetControl('swBPP')).ItemIndex = 0 then
115 gBPP := 16
116 else
117 gBPP := 32;
119 ovs := gVSync;
120 gVSync := TGUISwitch(menu.GetControl('swVSync')).ItemIndex = 0;
121 if (ovs <> gVSync) then g_SetVSync(gVSync);
123 gTextureFilter := TGUISwitch(menu.GetControl('swTextureFilter')).ItemIndex = 0;
124 glLegacyNPOT := not (TGUISwitch(menu.GetControl('swLegacyNPOT')).ItemIndex = 0);
126 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
128 g_Sound_SetupAllVolumes(
129 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
130 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
131 );
133 gMaxSimSounds := Max(Min(TGUIScroll(menu.GetControl('scMaxSimSounds')).Value*4+2, 66), 2);
134 gMuteWhenInactive := TGUISwitch(menu.GetControl('swInactiveSounds')).ItemIndex = 1;
135 gAnnouncer := TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex;
136 gSoundEffectsDF := TGUISwitch(menu.GetControl('swSoundEffects')).ItemIndex = 1;
137 gUseChatSounds := TGUISwitch(menu.GetControl('swChatSpeech')).ItemIndex = 0;
139 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
141 g_GFX_SetMax(TGUIScroll(menu.GetControl('scParticlesCount')).Value*1000);
142 g_Shells_SetMax(TGUIScroll(menu.GetControl('scShellsMax')).Value*30);
143 g_Gibs_SetMax(TGUIScroll(menu.GetControl('scGibsMax')).Value*25);
144 g_Corpses_SetMax(TGUIScroll(menu.GetControl('scCorpsesMax')).Value*5);
146 case TGUISwitch(menu.GetControl('swGibsCount')).ItemIndex of
147 0: gGibsCount := 0;
148 1: gGibsCount := 8;
149 2: gGibsCount := 16;
150 3: gGibsCount := 32;
151 else gGibsCount := 48;
152 end;
154 gBloodCount := TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex;
155 gFlash := TGUISwitch(menu.GetControl('swScreenFlash')).ItemIndex;
156 gAdvBlood := TGUISwitch(menu.GetControl('swBloodType')).ItemIndex = 1;
157 gAdvCorpses := TGUISwitch(menu.GetControl('swCorpseType')).ItemIndex = 1;
158 gAdvGibs := TGUISwitch(menu.GetControl('swGibsType')).ItemIndex = 1;
159 gDrawBackGround := TGUISwitch(menu.GetControl('swBackGround')).ItemIndex = 0;
160 gShowMessages := TGUISwitch(menu.GetControl('swMessages')).ItemIndex = 0;
161 gRevertPlayers := TGUISwitch(menu.GetControl('swRevertPlayers')).ItemIndex = 0;
162 gChatBubble := TGUISwitch(menu.GetControl('swChatBubble')).ItemIndex;
163 gPlayerIndicator := TGUISwitch(menu.GetControl('swPlayerIndicator')).ItemIndex = 0;
164 g_dbg_scale := TGUIScroll(menu.GetControl('scScaleFactor')).Value + 1;
166 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
168 with menu do
169 begin
170 g_Console_BindKey(g_Console_FindBind(1, 'screenshot'), '');
171 g_Console_BindKey(g_Console_FindBind(1, '+scores'), '');
172 g_Console_BindKey(g_Console_FindBind(1, 'togglechat'), '');
173 g_Console_BindKey(g_Console_FindBind(1, 'toggleteamchat'), '');
174 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_SCREENSHOT])).Key, 'screenshot');
175 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STAT])).Key, '+scores');
176 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_CHAT])).Key, 'togglechat');
177 g_Console_BindKey(TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_TEAMCHAT])).Key, 'toggleteamchat');
178 end;
180 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
181 with menu do
182 begin
183 g_Console_BindKey(g_Console_FindBind(1, '+moveright'), '');
184 g_Console_BindKey(g_Console_FindBind(1, '+moveleft'), '');
185 g_Console_BindKey(g_Console_FindBind(1, '+lookup'), '');
186 g_Console_BindKey(g_Console_FindBind(1, '+lookdown'), '');
187 g_Console_BindKey(g_Console_FindBind(1, '+attack'), '');
188 g_Console_BindKey(g_Console_FindBind(1, '+jump'), '');
189 g_Console_BindKey(g_Console_FindBind(1, '+weapnext'), '');
190 g_Console_BindKey(g_Console_FindBind(1, '+weapprev'), '');
191 g_Console_BindKey(g_Console_FindBind(1, '+activate'), '');
192 g_Console_BindKey(g_Console_FindBind(1, '+strafe'), '');
193 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0, '+moveright');
194 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0, '+moveleft');
195 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0, '+lookup');
196 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0, '+lookdown');
197 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0, '+attack');
198 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0, '+jump');
199 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0, '+weapnext');
200 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0, '+weapprev');
201 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0, '+activate');
202 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0, '+strafe');
203 // second set
204 g_Console_BindKey(g_Console_FindBind(2, '+moveright'), '');
205 g_Console_BindKey(g_Console_FindBind(2, '+moveleft'), '');
206 g_Console_BindKey(g_Console_FindBind(2, '+lookup'), '');
207 g_Console_BindKey(g_Console_FindBind(2, '+lookdown'), '');
208 g_Console_BindKey(g_Console_FindBind(2, '+attack'), '');
209 g_Console_BindKey(g_Console_FindBind(2, '+jump'), '');
210 g_Console_BindKey(g_Console_FindBind(2, '+weapnext'), '');
211 g_Console_BindKey(g_Console_FindBind(2, '+weapprev'), '');
212 g_Console_BindKey(g_Console_FindBind(2, '+activate'), '');
213 g_Console_BindKey(g_Console_FindBind(2, '+strafe'), '');
214 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1, '+moveright');
215 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1, '+moveleft');
216 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1, '+lookup');
217 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1, '+lookdown');
218 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1, '+attack');
219 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1, '+jump');
220 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1, '+weapnext');
221 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1, '+weapprev');
222 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1, '+activate');
223 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1, '+strafe');
224 end;
226 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
227 with menu do
228 begin
229 for i := WP_FIRST to WP_LAST do
230 begin
231 g_Console_BindKey(g_Console_FindBind(1, 'weapon ' + IntToStr(i + 1)), '');
232 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0, 'weapon ' + IntToStr(i + 1));
233 g_Console_BindKey(g_Console_FindBind(2, 'weapon ' + IntToStr(i + 1)), '');
234 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1, 'weapon ' + IntToStr(i + 1));
235 end;
236 end;
238 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
239 with menu do
240 begin
241 g_Console_BindKey(g_Console_FindBind(1, '+p2_moveright'), '');
242 g_Console_BindKey(g_Console_FindBind(1, '+p2_moveleft'), '');
243 g_Console_BindKey(g_Console_FindBind(1, '+p2_lookup'), '');
244 g_Console_BindKey(g_Console_FindBind(1, '+p2_lookdown'), '');
245 g_Console_BindKey(g_Console_FindBind(1, '+p2_attack'), '');
246 g_Console_BindKey(g_Console_FindBind(1, '+p2_jump'), '');
247 g_Console_BindKey(g_Console_FindBind(1, '+p2_weapnext'), '');
248 g_Console_BindKey(g_Console_FindBind(1, '+p2_weapprev'), '');
249 g_Console_BindKey(g_Console_FindBind(1, '+p2_activate'), '');
250 g_Console_BindKey(g_Console_FindBind(1, '+p2_strafe'), '');
251 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0, '+p2_moveright');
252 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0, '+p2_moveleft');
253 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0, '+p2_lookup');
254 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0, '+p2_lookdown');
255 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0, '+p2_attack');
256 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0, '+p2_jump');
257 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0, '+p2_weapnext');
258 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0, '+p2_weapprev');
259 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0, '+p2_activate');
260 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0, '+p2_strafe');
261 // second set
262 g_Console_BindKey(g_Console_FindBind(2, '+p2_moveright'), '');
263 g_Console_BindKey(g_Console_FindBind(2, '+p2_moveleft'), '');
264 g_Console_BindKey(g_Console_FindBind(2, '+p2_lookup'), '');
265 g_Console_BindKey(g_Console_FindBind(2, '+p2_lookdown'), '');
266 g_Console_BindKey(g_Console_FindBind(2, '+p2_attack'), '');
267 g_Console_BindKey(g_Console_FindBind(2, '+p2_jump'), '');
268 g_Console_BindKey(g_Console_FindBind(2, '+p2_weapnext'), '');
269 g_Console_BindKey(g_Console_FindBind(2, '+p2_weapprev'), '');
270 g_Console_BindKey(g_Console_FindBind(2, '+p2_activate'), '');
271 g_Console_BindKey(g_Console_FindBind(2, '+p2_strafe'), '');
272 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1, '+p2_moveright');
273 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1, '+p2_moveleft');
274 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1, '+p2_lookup');
275 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1, '+p2_lookdown');
276 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1, '+p2_attack');
277 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1, '+p2_jump');
278 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1, '+p2_weapnext');
279 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1, '+p2_weapprev');
280 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1, '+p2_activate');
281 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1, '+p2_strafe');
282 end;
284 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
285 with menu do
286 begin
287 for i := WP_FIRST to WP_LAST do
288 begin
289 g_Console_BindKey(g_Console_FindBind(1, 'p2_weapon ' + IntToStr(i + 1)), '');
290 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0, 'p2_weapon ' + IntToStr(i + 1));
291 g_Console_BindKey(g_Console_FindBind(2, 'p2_weapon ' + IntToStr(i + 1)), '');
292 g_Console_BindKey(TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1, 'p2_weapon ' + IntToStr(i + 1));
293 end;
294 end;
296 if e_JoysticksAvailable > 0 then
297 begin
298 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
299 with menu do
300 begin
301 for i := 0 to e_JoysticksAvailable-1 do
302 e_JoystickDeadzones[i] := TGUIScroll(menu.GetControl('scDeadzone' + IntToStr(i))).Value*(32767 div 20);
303 end;
304 end;
306 if g_touch_enabled then
307 begin
308 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
309 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
310 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
311 g_touch_fire := TGUISwitch(menu.GetControl('swTouchFire')).ItemIndex = 1;
312 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
313 end;
315 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
317 gPlayer1Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP1Name')).Text);
318 gPlayer1Settings.Team := IfThen(TGUISwitch(menu.GetControl('swP1Team')).ItemIndex = 0,
319 TEAM_RED, TEAM_BLUE);
321 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mvP1Model')) do
322 begin
323 gPlayer1Settings.Model := Model.Name;
324 gPlayer1Settings.Color := Model.Color;
325 end;
327 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
329 gPlayer2Settings.Name := b_Text_Unformat(TGUIEdit(menu.GetControl('edP2Name')).Text);
330 gPlayer2Settings.Team := IfThen(TGUISwitch(menu.GetControl('swP2Team')).ItemIndex = 0,
331 TEAM_RED, TEAM_BLUE);
332 with TGUIModelView(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mvP2Model')) do
333 begin
334 gPlayer2Settings.Model := Model.Name;
335 gPlayer2Settings.Color := Model.Color;
336 end;
338 if gPlayer1Settings.Name = '' then gPlayer1Settings.Name := GenPlayerName(1);
339 if gPlayer2Settings.Name = '' then gPlayer2Settings.Name := GenPlayerName(2);
341 if g_Game_IsServer then
342 begin
343 if gPlayer1 <> nil then
344 begin
345 gPlayer1.SetModel(gPlayer1Settings.Model);
346 gPlayer1.Name := gPlayer1Settings.Name;
347 if not (gGameSettings.GameMode in [GM_TDM, GM_CTF]) then
348 gPlayer1.SetColor(gPlayer1Settings.Color)
349 else
350 if gPlayer1.Team <> gPlayer1Settings.Team then
351 gPlayer1.SwitchTeam;
353 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
354 end;
356 if gPlayer2 <> nil then
357 begin
358 gPlayer2.SetModel(gPlayer2Settings.Model);
359 gPlayer2.Name := gPlayer2Settings.Name;
360 if (gGameSettings.GameMode <> GM_TDM) and (gGameSettings.GameMode <> GM_CTF) then
361 gPlayer2.SetColor(gPlayer2Settings.Color)
362 else
363 if gPlayer2.Team <> gPlayer2Settings.Team then
364 gPlayer2.SwitchTeam;
365 end;
366 end;
368 if g_Game_IsClient then MC_SEND_PlayerSettings;
370 g_Options_Write(GameDir+'/'+CONFIG_FILENAME);
371 end;
373 procedure ReadOptions();
374 var
375 menu: TGUIMenu;
376 i: Integer;
377 begin
378 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
380 with TGUISwitch(menu.GetControl('swBPP')) do
381 if gBPP = 16 then
382 ItemIndex := 0
383 else
384 ItemIndex := 1;
386 with TGUISwitch(menu.GetControl('swTextureFilter')) do
387 if gTextureFilter then ItemIndex := 0 else ItemIndex := 1;
389 with TGUISwitch(menu.GetControl('swVSync')) do
390 if gVSync then ItemIndex := 0 else ItemIndex := 1;
392 with TGUISwitch(menu.GetControl('swLegacyNPOT')) do
393 if not glLegacyNPOT then ItemIndex := 0 else ItemIndex := 1;
395 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
397 TGUIScroll(menu.GetControl('scSoundLevel')).Value := Round(gSoundLevel/16);
398 TGUIScroll(menu.GetControl('scMusicLevel')).Value := Round(gMusicLevel/16);
399 TGUIScroll(menu.GetControl('scMaxSimSounds')).Value := Round((gMaxSimSounds-2)/4);
401 with TGUISwitch(menu.GetControl('swInactiveSounds')) do
402 if gMuteWhenInactive then
403 ItemIndex := 1
404 else
405 ItemIndex := 0;
407 TGUISwitch(menu.GetControl('swAnnouncer')).ItemIndex := gAnnouncer;
409 with TGUISwitch(menu.GetControl('swSoundEffects')) do
410 if gSoundEffectsDF then
411 ItemIndex := 1
412 else
413 ItemIndex := 0;
415 with TGUISwitch(menu.GetControl('swChatSpeech')) do
416 if gUseChatSounds then
417 ItemIndex := 0
418 else
419 ItemIndex := 1;
421 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1Menu').GetControl('mOptionsControlsP1Menu'));
422 with menu do
423 begin
424 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0 := g_Console_FindBind(1, '+moveright');
425 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0 := g_Console_FindBind(1, '+moveleft');
426 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0 := g_Console_FindBind(1, '+lookup');
427 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := g_Console_FindBind(1, '+lookdown');
428 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := g_Console_FindBind(1, '+attack');
429 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := g_Console_FindBind(1, '+jump');
430 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := g_Console_FindBind(1, '+weapnext');
431 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := g_Console_FindBind(1, '+weapprev');
432 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := g_Console_FindBind(1, '+activate');
433 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := g_Console_FindBind(1, '+strafe');
434 // second set
435 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := g_Console_FindBind(2, '+moveright');
436 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := g_Console_FindBind(2, '+moveleft');
437 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1 := g_Console_FindBind(2, '+lookup');
438 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := g_Console_FindBind(2, '+lookdown');
439 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := g_Console_FindBind(2, '+attack');
440 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := g_Console_FindBind(2, '+jump');
441 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := g_Console_FindBind(2,'+weapnext');
442 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := g_Console_FindBind(2, '+weapprev');
443 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := g_Console_FindBind(2, '+activate');
444 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := g_Console_FindBind(2, '+strafe');
445 end;
447 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP1MenuWeapons').GetControl('mOptionsControlsP1MenuWeapons'));
448 with menu do
449 begin
450 for i := WP_FIRST to WP_LAST do
451 begin
452 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0 := g_Console_FindBind(1, 'weapon ' + IntToStr(i + 1));
453 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1 := g_Console_FindBind(2, 'weapon ' + IntToStr(i + 1));
454 end;
455 end;
457 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2Menu').GetControl('mOptionsControlsP2Menu'));
458 with menu do
459 begin
460 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key0 := g_Console_FindBind(1, '+p2_moveright');
461 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key0 := g_Console_FindBind(1, '+p2_moveleft');
462 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key0 := g_Console_FindBind(1, '+p2_lookup');
463 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key0 := g_Console_FindBind(1, '+p2_lookdown');
464 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key0 := g_Console_FindBind(1, '+p2_attack');
465 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key0 := g_Console_FindBind(1, '+p2_jump');
466 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key0 := g_Console_FindBind(1, '+p2_weapnext');
467 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key0 := g_Console_FindBind(1, '+p2_weapprev');
468 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key0 := g_Console_FindBind(1, '+p2_activate');
469 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key0 := g_Console_FindBind(1, '+p2_strafe');
470 // second set
471 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_RIGHT])).Key1 := g_Console_FindBind(2, '+p2_moveright');
472 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_LEFT])).Key1 := g_Console_FindBind(2, '+p2_moveleft');
473 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_UP])).Key1 := g_Console_FindBind(2, '+p2_lookup');
474 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_DOWN])).Key1 := g_Console_FindBind(2, '+p2_lookdown');
475 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_FIRE])).Key1 := g_Console_FindBind(2, '+p2_attack');
476 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_JUMP])).Key1 := g_Console_FindBind(2, '+p2_jump');
477 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_NEXT_WEAPON])).Key1 := g_Console_FindBind(2,'+p2_weapnext');
478 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_PREV_WEAPON])).Key1 := g_Console_FindBind(2, '+p2_weapprev');
479 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_USE])).Key1 := g_Console_FindBind(2, '+p2_activate');
480 TGUIKeyRead2(GetControl(_lc[I_MENU_CONTROL_STRAFE])).Key1 := g_Console_FindBind(2, '+p2_strafe');
481 end;
483 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsP2MenuWeapons').GetControl('mOptionsControlsP2MenuWeapons'));
484 with menu do
485 begin
486 for i := WP_FIRST to WP_LAST do
487 begin
488 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key0 := g_Console_FindBind(1, 'p2_weapon ' + IntToStr(i + 1));
489 TGUIKeyRead2(GetControl(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)])).Key1 := g_Console_FindBind(2, 'p2_weapon ' + IntToStr(i + 1));
490 end;
491 end;
493 if e_JoysticksAvailable > 0 then
494 begin
495 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsJoystickMenu').GetControl('mOptionsControlsJoystickMenu'));
496 with menu do
497 begin
498 for i := 0 to e_JoysticksAvailable-1 do
499 TGUIScroll(menu.GetControl('scDeadzone' + IntToStr(i))).Value := e_JoystickDeadzones[i] div (32767 div 20);
500 end;
501 end;
503 if g_touch_enabled then
504 begin
505 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
506 with TGUISwitch(menu.GetControl('swTouchAlt')) do
507 if g_touch_alt then ItemIndex := 1 else ItemIndex := 0;
508 TGUIScroll(menu.GetControl('scTouchSize')).Value := Round((g_touch_size - 0.5) * 10);
509 with TGUISwitch(menu.GetControl('swTouchFire')) do
510 if g_touch_fire then ItemIndex := 1 else ItemIndex := 0;
511 TGUIScroll(menu.GetControl('scTouchOffset')).Value := Round(g_touch_offset / 5);
512 end;
514 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsMenu').GetControl('mOptionsControlsMenu'));
515 with menu do
516 begin
517 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_SCREENSHOT])).Key := g_Console_FindBind(1, 'screenshot');
518 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_STAT])).Key := g_Console_FindBind(1, '+scores');
519 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_CHAT])).Key := g_Console_FindBind(1, 'togglechat');
520 TGUIKeyRead(GetControl(_lc[I_MENU_CONTROL_TEAMCHAT])).Key := g_Console_FindBind(1, 'toggleteamchat');
521 end;
523 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
525 TGUIScroll(menu.GetControl('scParticlesCount')).Value := g_GFX_GetMax() div 1000;
526 TGUIScroll(menu.GetControl('scShellsMax')).Value := g_Shells_GetMax() div 30;
527 TGUIScroll(menu.GetControl('scGibsMax')).Value := g_Gibs_GetMax() div 25;
528 TGUIScroll(menu.GetControl('scCorpsesMax')).Value := g_Corpses_GetMax() div 5;
529 TGUISwitch(menu.GetControl('swBloodCount')).ItemIndex := gBloodCount;
531 with TGUISwitch(menu.GetControl('swScreenFlash')) do
532 ItemIndex := gFlash;
534 with TGUISwitch(menu.GetControl('swBloodType')) do
535 if gAdvBlood then ItemIndex := 1 else ItemIndex := 0;
537 with TGUISwitch(menu.GetControl('swCorpseType')) do
538 if gAdvCorpses then ItemIndex := 1 else ItemIndex := 0;
540 with TGUISwitch(menu.GetControl('swGibsType')) do
541 if gAdvGibs then ItemIndex := 1 else ItemIndex := 0;
543 with TGUISwitch(menu.GetControl('swGibsCount')) do
544 case gGibsCount of
545 0: ItemIndex := 0;
546 8: ItemIndex := 1;
547 16: ItemIndex := 2;
548 32: ItemIndex := 3;
549 else ItemIndex := 4;
550 end;
552 with TGUISwitch(menu.GetControl('swBackGround')) do
553 if gDrawBackGround then ItemIndex := 0 else ItemIndex := 1;
555 with TGUISwitch(menu.GetControl('swMessages')) do
556 if gShowMessages then ItemIndex := 0 else ItemIndex := 1;
558 with TGUISwitch(menu.GetControl('swRevertPlayers')) do
559 if gRevertPlayers then ItemIndex := 0 else ItemIndex := 1;
561 with TGUISwitch(menu.GetControl('swChatBubble')) do
562 ItemIndex := gChatBubble;
564 with TGUISwitch(menu.GetControl('swPlayerIndicator')) do
565 if gPlayerIndicator then ItemIndex := 0 else ItemIndex := 1;
567 TGUIScroll(menu.GetControl('scScaleFactor')).Value := Round(g_dbg_scale - 1);
569 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP1Menu').GetControl('mOptionsPlayersP1Menu'));
571 TGUIListBox(menu.GetControl('lsP1Model')).SelectItem(gPlayer1Settings.Model);
572 TGUIEdit(menu.GetControl('edP1Name')).Text := gPlayer1Settings.Name;
574 TGUISwitch(menu.GetControl('swP1Team')).ItemIndex :=
575 IfThen(gPlayer1Settings.Team = TEAM_BLUE, 1, 0);
577 TGUIScroll(menu.GetControl('scP1Red')).Value := Round(gPlayer1Settings.Color.R/16);
578 TGUIScroll(menu.GetControl('scP1Green')).Value := Round(gPlayer1Settings.Color.G/16);
579 TGUIScroll(menu.GetControl('scP1Blue')).Value := Round(gPlayer1Settings.Color.B/16);
581 menu := TGUIMenu(g_GUI_GetWindow('OptionsPlayersP2Menu').GetControl('mOptionsPlayersP2Menu'));
583 TGUIListBox(menu.GetControl('lsP2Model')).SelectItem(gPlayer2Settings.Model);
584 TGUIEdit(menu.GetControl('edP2Name')).Text := gPlayer2Settings.Name;
586 TGUISwitch(menu.GetControl('swP2Team')).ItemIndex :=
587 IfThen(gPlayer2Settings.Team = TEAM_BLUE, 1, 0);
589 TGUIScroll(menu.GetControl('scP2Red')).Value := Round(gPlayer2Settings.Color.R/16);
590 TGUIScroll(menu.GetControl('scP2Green')).Value := Round(gPlayer2Settings.Color.G/16);
591 TGUIScroll(menu.GetControl('scP2Blue')).Value := Round(gPlayer2Settings.Color.B/16);
593 ProcSelectModel(nil);
594 end;
596 procedure ProcSwitchMonstersCustom(Sender: TGUIControl);
597 begin
598 // don't turn off monsters in DM
600 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
601 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
602 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
603 else
604 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
607 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
608 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
609 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
610 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
612 end;
614 procedure ProcSwitchMonstersNet(Sender: TGUIControl);
615 begin
616 // don't turn off monsters in DM
618 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
619 if TGUISwitch(GetControl('swGameMode')).GetText <> _lc[I_MENU_GAME_TYPE_CTF] then
620 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
621 else
622 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
625 if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_COOP] then
626 TGUISwitch(GetControl('swMonsters')).ItemIndex := 0
627 else if TGUISwitch(GetControl('swGameMode')).GetText = _lc[I_MENU_GAME_TYPE_CTF] then
628 TGUISwitch(GetControl('swMonsters')).ItemIndex := 1;
630 end;
632 procedure ProcStartCustomGame();
633 var
634 Map: String;
635 GameMode: Byte;
636 Options: LongWord;
637 begin
638 with TGUIMenu(g_ActiveWindow.GetControl('mCustomGameMenu')) do
639 begin
640 Map := TGUILabel(GetControl('lbMap')).Text;
641 if Map = '' then
642 Exit;
643 if not isWadPath(Map) then
644 Exit;
646 GameMode := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
647 gcGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
648 gcTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
649 gcGoalLimit := StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
650 gcMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
652 gcTeamDamage := TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0;
653 gcAllowExit := TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0;
654 gcWeaponStay := TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0;
655 gcMonsters := TGUISwitch(GetControl('swMonsters')).ItemIndex = 0;
656 Options := 0;
657 if gcTeamDamage then
658 Options := Options or GAME_OPTION_TEAMDAMAGE;
659 if gcAllowExit then
660 Options := Options or GAME_OPTION_ALLOWEXIT;
661 if gcWeaponStay then
662 Options := Options or GAME_OPTION_WEAPONSTAY;
663 if gcMonsters then
664 Options := Options or GAME_OPTION_MONSTERS;
665 gcPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
667 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
668 1: begin
669 Options := Options or GAME_OPTION_BOTVSMONSTER;
670 gcBotsVS := 'Monsters';
671 end;
672 2: begin
673 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
674 gcBotsVS := 'Everybody';
675 end;
676 else begin
677 Options := Options or GAME_OPTION_BOTVSPLAYER;
678 gcBotsVS := 'Players';
679 end;
680 end;
682 gcMap := Map;
683 end;
685 g_Options_Write_Gameplay_Custom(GameDir+'/'+CONFIG_FILENAME);
687 g_Game_StartCustom(Map, GameMode, gcTimeLimit, gcGoalLimit,
688 gcMaxLives, Options, gcPlayers);
689 end;
692 procedure ProcStartNetGame();
693 var
694 Map: String;
695 GameMode: Byte;
696 Options: LongWord;
697 begin
698 with TGUIMenu(g_ActiveWindow.GetControl('mNetServerMenu')) do
699 begin
700 Map := TGUILabel(GetControl('lbMap')).Text;
701 if Map = '' then
702 Exit;
703 if not isWadPath(Map) then
704 Exit;
706 GameMode := TGUISwitch(GetControl('swGameMode')).ItemIndex+1;
707 gnGameMode := TGUISwitch(GetControl('swGameMode')).GetText;
708 gnTimeLimit := StrToIntDef(TGUIEdit(GetControl('edTimeLimit')).Text, 0);
709 gnGoalLimit := StrToIntDef(TGUIEdit(GetControl('edGoalLimit')).Text, 0);
710 gnMaxLives := StrToIntDef(TGUIEdit(GetControl('edMaxLives')).Text, 0);
711 NetPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
713 gnTeamDamage := TGUISwitch(GetControl('swTeamDamage')).ItemIndex = 0;
714 gnAllowExit := TGUISwitch(GetControl('swEnableExits')).ItemIndex = 0;
715 gnWeaponStay := TGUISwitch(GetControl('swWeaponStay')).ItemIndex = 0;
716 gnMonsters := TGUISwitch(GetControl('swMonsters')).ItemIndex = 0;
717 Options := 0;
718 if gnTeamDamage then
719 Options := Options or GAME_OPTION_TEAMDAMAGE;
720 if gnAllowExit then
721 Options := Options or GAME_OPTION_ALLOWEXIT;
722 if gnWeaponStay then
723 Options := Options or GAME_OPTION_WEAPONSTAY;
724 if gnMonsters then
725 Options := Options or GAME_OPTION_MONSTERS;
726 gnPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex;
728 case TGUISwitch(GetControl('swBotsVS')).ItemIndex of
729 1: begin
730 Options := Options or GAME_OPTION_BOTVSMONSTER;
731 gnBotsVS := 'Monsters';
732 end;
733 2: begin
734 Options := Options or GAME_OPTION_BOTVSPLAYER or GAME_OPTION_BOTVSMONSTER;
735 gnBotsVS := 'Everybody';
736 end;
737 else begin
738 Options := Options or GAME_OPTION_BOTVSPLAYER;
739 gnBotsVS := 'Players';
740 end;
741 end;
743 gnMap := Map;
744 NetServerName := TGUIEdit(GetControl('edSrvName')).Text;
745 NetMaxClients := Max(1, StrToIntDef(TGUIEdit(GetControl('edMaxPlayers')).Text, 1));
746 NetMaxClients := Min(NET_MAXCLIENTS, NetMaxClients);
747 NetPassword := TGUIEdit(GetControl('edSrvPassword')).Text;
748 NetUseMaster := TGUISwitch(GetControl('swUseMaster')).ItemIndex = 0;
749 end;
751 g_Options_Write_Net_Server(GameDir+'/'+CONFIG_FILENAME);
752 g_Options_Write_Gameplay_Net(GameDir+'/'+CONFIG_FILENAME);
754 g_Game_StartServer(Map, GameMode, gnTimeLimit, gnGoalLimit, gnMaxLives,
755 Options, gnPlayers, 0, NetPort);
756 end;
758 procedure ProcConnectNetGame();
759 var
760 PW: String;
761 begin
762 with TGUIMenu(g_ActiveWindow.GetControl('mNetClientMenu')) do
763 begin
764 NetClientIP := TGUIEdit(GetControl('edIP')).Text;
765 NetClientPort := StrToIntDef(TGUIEdit(GetControl('edPort')).Text, 0);
766 PW := TGUIEdit(GetControl('edPW')).Text;
767 end;
769 g_Options_Write_Net_Client(GameDir+'/'+CONFIG_FILENAME);
770 g_Game_StartClient(NetClientIP, NetClientPort, PW);
771 end;
773 procedure ProcEnterPassword();
774 var
775 PW: string;
776 begin
777 with TGUIMenu(g_ActiveWindow.GetControl('mClientPasswordMenu')) do
778 begin
779 NetClientIP := PromptIP;
780 NetClientPort := PromptPort;
781 PW := TGUIEdit(GetControl('edPW')).Text;
782 end;
784 g_Options_Write_Net_Client(GameDir+'/'+CONFIG_FILENAME);
785 g_Game_StartClient(NetClientIP, NetClientPort, PW);
786 end;
788 procedure ProcServerlist();
789 begin
790 if not NetInitDone then
791 begin
792 if (not g_Net_Init()) then
793 begin
794 g_Console_Add('NET: ERROR: Failed to init ENet!');
795 Exit;
796 end
797 else
798 NetInitDone := True;
799 end;
801 g_Net_Slist_Set(NetSlistIP, NetSlistPort);
803 gState := STATE_SLIST;
804 g_ActiveWindow := nil;
806 slWaitStr := _lc[I_NET_SLIST_WAIT];
808 g_Game_Draw;
809 ReDrawWindow;
811 slReturnPressed := True;
812 if g_Net_Slist_Fetch(slCurrent) then
813 begin
814 if slCurrent = nil then
815 slWaitStr := _lc[I_NET_SLIST_NOSERVERS];
816 end
817 else
818 slWaitStr := _lc[I_NET_SLIST_ERROR];
819 g_Serverlist_GenerateTable(slCurrent, slTable);
820 end;
822 procedure ProcStartCampaign();
823 var
824 WAD: String;
825 TwoPlayers: Boolean;
826 n: Byte;
827 begin
828 with TGUIMenu(g_ActiveWindow.GetControl('mCampaignMenu')) do
829 begin
830 WAD := ExtractRelativePath(MapsDir, TGUIFileListBox(GetControl('lsWAD')).SelectedItem());
831 TwoPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex = 1;
832 end;
834 if TwoPlayers then
835 n := 2
836 else
837 n := 1;
838 g_Game_StartSingle(WAD + ':\MAP01', TwoPlayers, n);
839 end;
841 procedure ProcSelectMap(Sender: TGUIControl);
842 var
843 win: TGUIWindow;
844 a: TMapInfo;
845 wad, map, res: String;
846 begin
847 win := g_GUI_GetWindow('SelectMapMenu');
848 with TGUIMenu(win.GetControl('mSelectMapMenu')) do
849 begin
850 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
851 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
853 if (wad = '') or (map = '') then
854 begin // Ýòî íå êàðòà
855 TGUILabel(GetControl('lbMapName')).Text := '';
856 TGUILabel(GetControl('lbMapAuthor')).Text := '';
857 TGUILabel(GetControl('lbMapSize')).Text := '';
858 TGUIMemo(GetControl('meMapDescription')).SetText('');
859 TGUIMapPreview(win.GetControl('mpMapPreview')).ClearMap();
860 TGUILabel(win.GetControl('lbMapScale')).Text := '';
861 end
862 else // Ýòî êàðòà
863 begin
864 res := wad+':\'+map;
866 a := g_Map_GetMapInfo(res);
868 TGUILabel(GetControl('lbMapName')).Text := a.Name;
869 TGUILabel(GetControl('lbMapAuthor')).Text := a.Author;
870 TGUILabel(GetControl('lbMapSize')).Text := Format('%dx%d', [a.Width, a.Height]);
871 TGUIMemo(GetControl('meMapDescription')).SetText(a.Description);
872 TGUIMapPreview(win.GetControl('mpMapPreview')).SetMap(res);
873 TGUILabel(win.GetControl('lbMapScale')).Text :=
874 TGUIMapPreview(win.GetControl('mpMapPreview')).GetScaleStr;
875 end;
876 end;
877 end;
879 procedure ProcSelectWAD(Sender: TGUIControl);
880 var
881 wad: String;
882 list: SSArray;
883 begin
884 with TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu')) do
885 begin
886 wad := TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem();
888 with TGUIListBox(GetControl('lsMapRes')) do
889 begin
890 Clear();
892 if wad <> '' then
893 begin
894 list := g_Map_GetMapsList(wad);
896 if list <> nil then
897 begin
898 Items := list;
899 ItemIndex := 0;
900 end
901 end;
902 end;
903 end;
905 ProcSelectMap(nil);
906 end;
908 procedure ProcSelectCampaignWAD(Sender: TGUIControl);
909 var
910 win: TGUIWindow;
911 a: TMegaWADInfo;
912 wad, fn: String;
913 begin
914 win := g_GUI_GetWindow('CampaignMenu');
915 with TGUIMenu(win.GetControl('mCampaignMenu')) do
916 begin
917 wad := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
919 if wad = '' then
920 begin
921 TGUILabel(GetControl('lbWADName')).Text := '';
922 TGUILabel(GetControl('lbWADAuthor')).Text := '';
923 TGUIMemo(GetControl('meWADDescription')).SetText('');
924 end;
926 a := g_Game_GetMegaWADInfo(wad);
928 TGUILabel(GetControl('lbWADName')).Text := a.Name;
929 TGUILabel(GetControl('lbWADAuthor')).Text := a.Author;
930 TGUIMemo(GetControl('meWADDescription')).SetText(a.Description);
932 TGUIImage(win.GetControl('mpWADImage')).ClearImage();
934 if a.pic <> '' then
935 begin
936 fn := g_ExtractWadName(a.pic);
937 if fn = '' then
938 TGUIImage(win.GetControl('mpWADImage')).SetImage(wad+a.pic)
939 else
940 TGUIImage(win.GetControl('mpWADImage')).SetImage(a.pic);
941 end;
942 end;
943 end;
945 procedure ProcChangeColor(Sender: TGUIControl);
946 var
947 window: TGUIWindow;
948 begin
949 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
950 with TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')) do
951 TGUIModelView(window.GetControl('mvP1Model')).SetColor(
952 Min(TGUIScroll(GetControl('scP1Red')).Value*16, 255),
953 Min(TGUIScroll(GetControl('scP1Green')).Value*16, 255),
954 Min(TGUIScroll(GetControl('scP1Blue')).Value*16, 255));
956 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
957 with TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')) do
958 TGUIModelView(window.GetControl('mvP2Model')).SetColor(
959 Min(TGUIScroll(GetControl('scP2Red')).Value*16, 255),
960 Min(TGUIScroll(GetControl('scP2Green')).Value*16, 255),
961 Min(TGUIScroll(GetControl('scP2Blue')).Value*16, 255));
962 end;
964 procedure ProcSelectModel(Sender: TGUIControl);
965 var
966 a: string;
967 window: TGUIWindow;
968 begin
969 window := g_GUI_GetWindow('OptionsPlayersP1Menu');
970 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP1Menu')).GetControl('lsP1Model')).SelectedItem;
971 if a <> '' then TGUIModelView(window.GetControl('mvP1Model')).SetModel(a);
973 window := g_GUI_GetWindow('OptionsPlayersP2Menu');
974 a := TGUIListBox(TGUIMenu(window.GetControl('mOptionsPlayersP2Menu')).GetControl('lsP2Model')).SelectedItem;
975 if a <> '' then TGUIModelView(window.GetControl('mvP2Model')).SetModel(a);
977 ProcChangeColor(nil);
978 end;
980 procedure LoadStdFont(cfgres, texture: string; var FontID: DWORD);
981 var
982 cwdt, chgt: Byte;
983 spc: ShortInt;
984 ID: DWORD;
985 wad: TWADFile;
986 cfgdata: Pointer;
987 cfglen: Integer;
988 config: TConfig;
989 begin
990 cfglen := 0;
992 wad := TWADFile.Create;
993 if wad.ReadFile(GameWAD) then
994 wad.GetResource('FONTS/'+cfgres, cfgdata, cfglen);
995 wad.Free();
997 if cfglen <> 0 then
998 begin
999 g_Texture_CreateWADEx('FONT_STD', GameWAD+':FONTS\'+texture);
1001 config := TConfig.CreateMem(cfgdata, cfglen);
1002 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
1003 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
1004 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
1006 if g_Texture_Get('FONT_STD', ID) then
1007 e_TextureFontBuild(ID, FontID, cwdt, chgt, spc);
1009 config.Free();
1010 end;
1012 if cfglen <> 0 then FreeMem(cfgdata);
1013 end;
1015 procedure LoadFont(txtres, fntres: string; var FontID: DWORD);
1016 var
1017 cwdt, chgt: Byte;
1018 spc: ShortInt;
1019 CharID: DWORD;
1020 wad: TWADFile;
1021 cfgdata, fntdata: Pointer;
1022 cfglen, fntlen: Integer;
1023 config: TConfig;
1024 chrwidth: Integer;
1025 a: Byte;
1026 begin
1027 cfglen := 0;
1028 fntlen := 0;
1030 wad := TWADFile.Create;
1031 if wad.ReadFile(GameWAD) then
1032 begin
1033 wad.GetResource('FONTS/'+txtres, cfgdata, cfglen);
1034 wad.GetResource('FONTS/'+fntres, fntdata, fntlen);
1035 end;
1036 wad.Free();
1038 if cfglen <> 0 then
1039 begin
1040 config := TConfig.CreateMem(cfgdata, cfglen);
1041 cwdt := Min(Max(config.ReadInt('FontMap', 'CharWidth', 0), 0), 255);
1042 chgt := Min(Max(config.ReadInt('FontMap', 'CharHeight', 0), 0), 255);
1044 spc := Min(Max(config.ReadInt('FontMap', 'Kerning', 0), -128), 127);
1045 FontID := e_CharFont_Create(spc);
1047 for a := 0 to 255 do
1048 begin
1049 chrwidth := config.ReadInt(IntToStr(a), 'Width', 0);
1050 if chrwidth = 0 then Continue;
1052 if e_CreateTextureMemEx(fntdata, fntlen, CharID, cwdt*(a mod 16), chgt*(a div 16),
1053 cwdt, chgt) then
1054 e_CharFont_AddChar(FontID, CharID, Chr(a), chrwidth);
1055 end;
1057 config.Free();
1058 end;
1060 if cfglen <> 0 then FreeMem(cfgdata);
1061 if fntlen <> 0 then FreeMem(fntdata);
1062 end;
1064 procedure MenuLoadData();
1065 begin
1066 e_WriteLog('Loading menu data...', TMsgType.Notify);
1068 g_Texture_CreateWADEx('MAINMENU_MARKER1', GameWAD+':TEXTURES\MARKER1');
1069 g_Texture_CreateWADEx('MAINMENU_MARKER2', GameWAD+':TEXTURES\MARKER2');
1070 g_Texture_CreateWADEx('SCROLL_LEFT', GameWAD+':TEXTURES\SLEFT');
1071 g_Texture_CreateWADEx('SCROLL_RIGHT', GameWAD+':TEXTURES\SRIGHT');
1072 g_Texture_CreateWADEx('SCROLL_MIDDLE', GameWAD+':TEXTURES\SMIDDLE');
1073 g_Texture_CreateWADEx('SCROLL_MARKER', GameWAD+':TEXTURES\SMARKER');
1074 g_Texture_CreateWADEx('EDIT_LEFT', GameWAD+':TEXTURES\ELEFT');
1075 g_Texture_CreateWADEx('EDIT_RIGHT', GameWAD+':TEXTURES\ERIGHT');
1076 g_Texture_CreateWADEx('EDIT_MIDDLE', GameWAD+':TEXTURES\EMIDDLE');
1077 g_Texture_CreateWADEx('BOX1', GameWAD+':TEXTURES\BOX1');
1078 g_Texture_CreateWADEx('BOX2', GameWAD+':TEXTURES\BOX2');
1079 g_Texture_CreateWADEx('BOX3', GameWAD+':TEXTURES\BOX3');
1080 g_Texture_CreateWADEx('BOX4', GameWAD+':TEXTURES\BOX4');
1081 g_Texture_CreateWADEx('BOX5', GameWAD+':TEXTURES\BOX5');
1082 g_Texture_CreateWADEx('BOX6', GameWAD+':TEXTURES\BOX6');
1083 g_Texture_CreateWADEx('BOX7', GameWAD+':TEXTURES\BOX7');
1084 g_Texture_CreateWADEx('BOX8', GameWAD+':TEXTURES\BOX8');
1085 g_Texture_CreateWADEx('BOX9', GameWAD+':TEXTURES\BOX9');
1086 g_Texture_CreateWADEx('BSCROLL_UP_A', GameWAD+':TEXTURES\SCROLLUPA');
1087 g_Texture_CreateWADEx('BSCROLL_UP_U', GameWAD+':TEXTURES\SCROLLUPU');
1088 g_Texture_CreateWADEx('BSCROLL_DOWN_A', GameWAD+':TEXTURES\SCROLLDOWNA');
1089 g_Texture_CreateWADEx('BSCROLL_DOWN_U', GameWAD+':TEXTURES\SCROLLDOWNU');
1090 g_Texture_CreateWADEx('BSCROLL_MIDDLE', GameWAD+':TEXTURES\SCROLLMIDDLE');
1091 g_Texture_CreateWADEx('NOPIC', GameWAD+':TEXTURES\NOPIC');
1093 g_Sound_CreateWADEx('MENU_SELECT', GameWAD+':SOUNDS\MENUSELECT');
1094 g_Sound_CreateWADEx('MENU_OPEN', GameWAD+':SOUNDS\MENUOPEN');
1095 g_Sound_CreateWADEx('MENU_CLOSE', GameWAD+':SOUNDS\MENUCLOSE');
1096 g_Sound_CreateWADEx('MENU_CHANGE', GameWAD+':SOUNDS\MENUCHANGE');
1097 g_Sound_CreateWADEx('SCROLL_ADD', GameWAD+':SOUNDS\SCROLLADD');
1098 g_Sound_CreateWADEx('SCROLL_SUB', GameWAD+':SOUNDS\SCROLLSUB');
1099 g_Sound_CreateWADEx('SOUND_PLAYER_FALL', GameWAD+':SOUNDS\FALL');
1100 end;
1102 procedure MenuFreeData();
1103 begin
1104 e_CharFont_Remove(gMenuFont);
1105 e_CharFont_Remove(gMenuSmallFont);
1107 g_Texture_Delete('MAINMENU_MARKER1');
1108 g_Texture_Delete('MAINMENU_MARKER2');
1109 g_Texture_Delete('SCROLL_LEFT');
1110 g_Texture_Delete('SCROLL_RIGHT');
1111 g_Texture_Delete('SCROLL_MIDDLE');
1112 g_Texture_Delete('SCROLL_MARKER');
1113 g_Texture_Delete('EDIT_LEFT');
1114 g_Texture_Delete('EDIT_RIGHT');
1115 g_Texture_Delete('EDIT_MIDDLE');
1116 g_Texture_Delete('BOX1');
1117 g_Texture_Delete('BOX2');
1118 g_Texture_Delete('BOX3');
1119 g_Texture_Delete('BOX4');
1120 g_Texture_Delete('BOX5');
1121 g_Texture_Delete('BOX6');
1122 g_Texture_Delete('BOX7');
1123 g_Texture_Delete('BOX8');
1124 g_Texture_Delete('BOX9');
1125 g_Texture_Delete('BSCROLL_UP_A');
1126 g_Texture_Delete('BSCROLL_UP_U');
1127 g_Texture_Delete('BSCROLL_DOWN_A');
1128 g_Texture_Delete('BSCROLL_DOWN_U');
1129 g_Texture_Delete('BSCROLL_MIDDLE');
1130 g_Texture_Delete('NOPIC');
1132 g_Sound_Delete('MENU_SELECT');
1133 g_Sound_Delete('MENU_OPEN');
1134 g_Sound_Delete('MENU_CLOSE');
1135 g_Sound_Delete('MENU_CHANGE');
1136 g_Sound_Delete('SCROLL_ADD');
1137 g_Sound_Delete('SCROLL_SUB');
1138 g_Sound_Delete('SOUND_PLAYER_FALL');
1139 end;
1141 procedure ProcAuthorsMenu();
1142 begin
1143 gMusic.SetByName('MUSIC_INTERMUS');
1144 gMusic.Play();
1145 end;
1147 procedure ProcExitMenuKeyDown (yes: Boolean);
1148 var
1149 s: ShortString;
1150 snd: TPlayableSound;
1151 res: Boolean;
1152 begin
1153 if yes then
1154 begin
1155 g_Game_StopAllSounds(True);
1156 case (Random(18)) of
1157 0: s := 'SOUND_MONSTER_PAIN';
1158 1: s := 'SOUND_MONSTER_DIE_3';
1159 2: s := 'SOUND_MONSTER_SLOP';
1160 3: s := 'SOUND_MONSTER_DEMON_DIE';
1161 4: s := 'SOUND_MONSTER_IMP_DIE_2';
1162 5: s := 'SOUND_MONSTER_MAN_DIE';
1163 6: s := 'SOUND_MONSTER_BSP_DIE';
1164 7: s := 'SOUND_MONSTER_VILE_DIE';
1165 8: s := 'SOUND_MONSTER_SKEL_DIE';
1166 9: s := 'SOUND_MONSTER_MANCUB_ALERT';
1167 10: s := 'SOUND_MONSTER_PAIN_PAIN';
1168 11: s := 'SOUND_MONSTER_BARON_DIE';
1169 12: s := 'SOUND_MONSTER_CACO_DIE';
1170 13: s := 'SOUND_MONSTER_CYBER_DIE';
1171 14: s := 'SOUND_MONSTER_KNIGHT_ALERT';
1172 15: s := 'SOUND_MONSTER_SPIDER_ALERT';
1173 else s := 'SOUND_PLAYER_FALL';
1174 end;
1175 snd := TPlayableSound.Create();
1176 res := snd.SetByName(s);
1177 if not res then res := snd.SetByName('SOUND_PLAYER_FALL');
1178 if res then
1179 begin
1180 snd.Play(True);
1181 while snd.IsPlaying() do begin end;
1182 end;
1183 g_Game_Quit();
1184 exit;
1185 end;
1186 g_GUI_HideWindow();
1187 end;
1189 procedure ProcLoadMenu();
1190 var
1191 a: Integer;
1192 valid: Boolean;
1193 begin
1194 for a := 1 to 8 do
1195 begin
1196 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Text := g_GetSaveName(a, valid);
1197 TGUIEdit(TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := not valid;
1198 //TGUIMenu(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu')).GetControl('edSlot'+IntToStr(a)).Enabled := valid;
1199 end;
1200 end;
1202 procedure ProcSaveMenu();
1203 var
1204 a: Integer;
1205 valid: Boolean;
1206 name: AnsiString;
1207 begin
1208 for a := 1 to 8 do
1209 begin
1210 name := g_GetSaveName(a, valid);
1211 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Text := name;
1212 TGUIEdit(TGUIMenu(g_GUI_GetWindow('SaveMenu').GetControl('mmSaveMenu')).GetControl('edSlot'+IntToStr(a))).Invalid := (name <> '') and (not valid);
1213 end;
1214 end;
1216 procedure ProcSaveGame(Sender: TGUIControl);
1217 var
1218 a: Integer;
1219 begin
1220 if g_Game_IsNet then Exit;
1221 if g_Game_IsTestMap then Exit;
1222 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1223 g_Game_PauseAllSounds(True);
1224 g_SaveGame(a, TGUIEdit(Sender).Text);
1226 g_ActiveWindow := nil;
1227 g_Game_Pause(False);
1228 end;
1230 procedure ProcLoadGame(Sender: TGUIControl);
1231 var
1232 a: Integer;
1233 begin
1234 if g_Game_IsNet then Exit;
1235 a := StrToInt(Copy(Sender.Name, Length(Sender.Name), 1));
1236 if g_LoadGame(a) then
1237 begin
1238 g_Game_PauseAllSounds(False)
1239 end
1240 else // Íå çàãðóçèëîñü - âîçâðàò â ìåíþ
1241 begin
1242 g_Console_Add(_lc[I_MSG_BAD_SAVE_VERSION], true);
1243 g_GUI_GetWindow('LoadMenu').SetActive(g_GUI_GetWindow('LoadMenu').GetControl('mmLoadMenu'));
1244 //g_ActiveWindow := nil;
1245 end;
1246 end;
1248 procedure ProcSingle1Player();
1249 begin
1250 g_Game_StartSingle(gDefaultMegawadStart, False, 1);
1251 end;
1253 procedure ProcSingle2Players();
1254 begin
1255 g_Game_StartSingle(gDefaultMegawadStart, True, 2);
1256 end;
1258 procedure ProcSelectMapMenu();
1259 var
1260 menu: TGUIMenu;
1261 wad_lb: TGUIFileListBox;
1262 map_lb: TGUIListBox;
1263 map: String;
1264 begin
1265 menu := TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu'));
1266 wad_lb := TGUIFileListBox(menu.GetControl('lsMapWAD'));
1267 map_lb := TGUIListBox(menu.GetControl('lsMapRes'));
1269 if wad_lb.SelectedItem() <> '' then
1270 map := map_lb.SelectedItem()
1271 else
1272 map := '';
1274 wad_lb.UpdateFileList();
1275 map_lb.Clear();
1277 if wad_lb.SelectedItem() <> '' then
1278 begin
1279 ProcSelectWAD(nil);
1280 map_lb.SelectItem(map);
1282 if map_lb.SelectedItem() <> '' then
1283 ProcSelectMap(nil);
1284 end;
1286 g_GUI_ShowWindow('SelectMapMenu');
1287 end;
1289 procedure ProcSelectCampaignMenu();
1290 var
1291 menu: TGUIMenu;
1292 wad_lb: TGUIFileListBox;
1293 begin
1294 menu := TGUIMenu(g_GUI_GetWindow('CampaignMenu').GetControl('mCampaignMenu'));
1295 wad_lb := TGUIFileListBox(menu.GetControl('lsWAD'));
1297 wad_lb.UpdateFileList();
1299 if wad_lb.SelectedItem() <> '' then
1300 ProcSelectCampaignWAD(nil);
1301 end;
1303 procedure ProcSetMap();
1304 var
1305 wad, map, res: String;
1306 begin
1307 with TGUIMenu(g_ActiveWindow.GetControl('mSelectMapMenu')) do
1308 begin
1309 wad := ExtractRelativePath(MapsDir, TGUIFileListBox(GetControl('lsMapWAD')).SelectedItem());
1310 map := TGUIListBox(GetControl('lsMapRes')).SelectedItem();
1311 end;
1313 if (wad = '') or (map = '') then
1314 Exit;
1316 res := wad+':\'+map;
1318 TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
1319 TGUILabel(TGUIMenu(g_GUI_GetWindow('NetServerMenu').GetControl('mNetServerMenu')).GetControl('lbMap')).Text := res;
1320 end;
1322 procedure ProcChangeSoundSettings(Sender: TGUIControl);
1323 var
1324 menu: TGUIMenu;
1325 begin
1326 menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu'));
1328 g_Sound_SetupAllVolumes(
1329 Min(TGUIScroll(menu.GetControl('scSoundLevel')).Value*16, 255),
1330 Min(TGUIScroll(menu.GetControl('scMusicLevel')).Value*16, 255)
1331 );
1332 end;
1334 procedure ProcChangeGameSettings(Sender: TGUIControl);
1335 var
1336 menu: TGUIMenu;
1337 begin
1338 menu := TGUIMenu(g_GUI_GetWindow('OptionsGameMenu').GetControl('mOptionsGameMenu'));
1339 g_dbg_scale := TGUIScroll(menu.GetControl('scScaleFactor')).Value + 1;
1340 end;
1342 procedure ProcChangeTouchSettings(Sender: TGUIControl);
1343 var
1344 menu: TGUIMenu;
1345 begin
1346 menu := TGUIMenu(g_GUI_GetWindow('OptionsControlsTouchMenu').GetControl('mOptionsControlsTouchMenu'));
1347 g_touch_alt := TGUISwitch(menu.GetControl('swTouchAlt')).ItemIndex = 1;
1348 g_touch_size := TGUIScroll(menu.GetControl('scTouchSize')).Value / 10 + 0.5;
1349 g_touch_offset := TGUIScroll(menu.GetControl('scTouchOffset')).Value * 5;
1350 end;
1352 procedure ProcOptionsPlayersMIMenu();
1353 var
1354 s, a: string;
1355 b: TModelInfo;
1356 begin
1357 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1359 a := TGUIListBox(TGUIMenu(g_ActiveWindow.GetControl('mOptionsPlayers'+s+'Menu')).GetControl('ls'+s+'Model')).SelectedItem;
1361 if a = '' then Exit;
1363 b := g_PlayerModel_GetInfo(a);
1365 with TGUIMenu(g_GUI_GetWindow('OptionsPlayersMIMenu').GetControl('mOptionsPlayersMIMenu')) do
1366 begin
1367 TGUILabel(GetControl('lbName')).Text := b.Name;
1368 TGUILabel(GetControl('lbAuthor')).Text := b.Author;
1369 TGUIMemo(GetControl('meComment')).SetText(b.Description);
1371 if b.HaveWeapon then
1372 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_YES]
1373 else
1374 TGUILabel(GetControl('lbWeapon')).Text := _lc[I_MENU_NO];
1375 end;
1377 g_GUI_ShowWindow('OptionsPlayersMIMenu');
1378 end;
1380 procedure ProcOptionsPlayersAnim();
1381 var
1382 s: String;
1383 begin
1384 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1385 s := 'P1'
1386 else
1387 s := 'P2';
1389 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1390 begin
1391 NextAnim();
1392 Model.GetCurrentAnimation.Loop := True;
1393 Model.GetCurrentAnimationMask.Loop := True;
1394 end;
1395 end;
1397 procedure ProcOptionsPlayersWeap();
1398 var
1399 s: String;
1400 begin
1401 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then
1402 s := 'P1'
1403 else
1404 s := 'P2';
1406 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')) do
1407 NextWeapon();
1408 end;
1410 procedure ProcOptionsPlayersRot();
1411 var
1412 s: string;
1413 begin
1414 if g_ActiveWindow.Name = 'OptionsPlayersP1Menu' then s := 'P1' else s := 'P2';
1415 with TGUIModelView(g_ActiveWindow.GetControl('mv'+s+'Model')).Model do
1416 begin
1417 if Direction = TDirection.D_LEFT then Direction := TDirection.D_RIGHT else Direction := TDirection.D_LEFT;
1418 end;
1419 end;
1421 procedure ProcDefaultMenuKeyDown (yes: Boolean);
1422 begin
1423 if yes then
1424 begin
1425 g_Options_SetDefault();
1426 ReadOptions();
1427 end;
1428 g_GUI_HideWindow();
1429 end;
1431 procedure ProcSavedMenuKeyDown (yes: Boolean);
1432 begin
1433 if yes then ReadOptions();
1434 g_GUI_HideWindow();
1435 end;
1437 procedure ProcAuthorsClose();
1438 begin
1439 gMusic.SetByName('MUSIC_MENU');
1440 gMusic.Play();
1441 gState := STATE_MENU;
1442 end;
1444 procedure ProcGMClose();
1445 begin
1446 g_Game_InGameMenu(False);
1447 end;
1449 procedure ProcGMShow();
1450 var
1451 Enabled: Boolean;
1452 begin
1453 Enabled := True;
1454 if (gGameSettings.GameType = GT_SINGLE) and
1455 ((gPlayer1 = nil) or (not gPlayer1.alive)) and
1456 ((gPlayer2 = nil) or (not gPlayer2.alive)) then
1457 Enabled := False; // Îäèí èç èãðîêîâ ïîãèá â ñèíãëå
1458 if not gGameOn then
1459 Enabled := False; // Çàïðåòèòü ñîõðàíåíèå â èíòåðìèññèè (íå ðåàëèçîâàíî)
1460 if g_Game_IsTestMap then
1461 Enabled := False; // Åñëè èãðàåì íà òåñòîâîé èëè âðåìåííîé êàðòå
1462 TGUIMainMenu(g_ActiveWindow.GetControl(
1463 g_ActiveWindow.DefControl )).EnableButton('save', Enabled);
1464 end;
1466 procedure ProcChangePlayers();
1467 var
1468 TeamGame, Spectator, AddTwo: Boolean;
1469 P1Team{, P2Team}: Byte;
1470 bP2: TGUITextButton;
1471 begin
1472 TeamGame := gGameSettings.GameMode in [GM_TDM, GM_CTF];
1473 Spectator := (gPlayer1 = nil) and (gPlayer2 = nil);
1474 AddTwo := gGameSettings.GameType in [GT_CUSTOM, GT_SERVER];
1475 P1Team := TEAM_NONE;
1476 if gPlayer1 <> nil then P1Team := gPlayer1.Team;
1477 // TODO
1478 //P2Team := TEAM_NONE;
1479 //if gPlayer2 <> nil then P2Team := gPlayer2.Team;
1481 TGUIMainMenu(g_ActiveWindow.GetControl(
1482 g_ActiveWindow.DefControl )).EnableButton('tmJoinRed', TeamGame and (P1Team <> TEAM_RED));
1483 TGUIMainMenu(g_ActiveWindow.GetControl(
1484 g_ActiveWindow.DefControl )).EnableButton('tmJoinBlue', TeamGame and (P1Team <> TEAM_BLUE));
1485 TGUIMainMenu(g_ActiveWindow.GetControl(
1486 g_ActiveWindow.DefControl )).EnableButton('tmJoinGame', Spectator and not TeamGame);
1488 bP2 := TGUIMainMenu(g_ActiveWindow.GetControl(
1489 g_ActiveWindow.DefControl )).GetButton('tmPlayer2');
1490 bP2.Enabled := AddTwo and not Spectator;
1491 if bP2.Enabled then
1492 bP2.Color := MAINMENU_ITEMS_COLOR
1493 else
1494 bP2.Color := MAINMENU_UNACTIVEITEMS_COLOR;
1495 if gPlayer2 = nil then
1496 bP2.Caption := _lc[I_MENU_ADD_PLAYER_2]
1497 else
1498 bP2.Caption := _lc[I_MENU_REM_PLAYER_2];
1500 TGUIMainMenu(g_ActiveWindow.GetControl(
1501 g_ActiveWindow.DefControl )).EnableButton('tmSpectate', not Spectator);
1502 end;
1504 procedure ProcJoinRed();
1505 begin
1506 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1507 Exit;
1508 if g_Game_IsServer then
1509 begin
1510 if gPlayer1 = nil then
1511 g_Game_AddPlayer(TEAM_RED)
1512 else
1513 begin
1514 if gPlayer1.Team <> TEAM_RED then
1515 begin
1516 gPlayer1.SwitchTeam;
1517 gPlayer1Settings.Team := gPlayer1.Team;
1518 end;
1520 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1521 end;
1522 end
1523 else
1524 begin
1525 gPlayer1Settings.Team := TEAM_RED;
1526 MC_SEND_PlayerSettings;
1527 if gPlayer1 = nil then
1528 g_Game_AddPlayer(TEAM_RED);
1529 end;
1530 g_ActiveWindow := nil;
1531 g_Game_Pause(False);
1532 end;
1534 procedure ProcJoinBlue();
1535 begin
1536 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1537 Exit;
1538 if g_Game_IsServer then
1539 begin
1540 if gPlayer1 = nil then
1541 g_Game_AddPlayer(TEAM_BLUE)
1542 else
1543 begin
1544 if gPlayer1.Team <> TEAM_BLUE then
1545 begin
1546 gPlayer1.SwitchTeam;
1547 gPlayer1Settings.Team := gPlayer1.Team;
1548 end;
1550 if g_Game_IsNet then MH_SEND_PlayerSettings(gPlayer1.UID);
1551 end;
1552 end
1553 else
1554 begin
1555 gPlayer1Settings.Team := TEAM_BLUE;
1556 MC_SEND_PlayerSettings;
1557 if gPlayer1 = nil then
1558 g_Game_AddPlayer(TEAM_BLUE);
1559 end;
1560 g_ActiveWindow := nil;
1561 g_Game_Pause(False);
1562 end;
1564 procedure ProcJoinGame();
1565 begin
1566 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1567 Exit;
1568 if gPlayer1 = nil then
1569 g_Game_AddPlayer();
1570 g_ActiveWindow := nil;
1571 g_Game_Pause(False);
1572 end;
1574 procedure ProcSwitchP2();
1575 begin
1576 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER]) then
1577 Exit;
1578 if gPlayer1 = nil then
1579 Exit;
1580 if gPlayer2 = nil then
1581 g_Game_AddPlayer()
1582 else
1583 g_Game_RemovePlayer();
1584 g_ActiveWindow := nil;
1585 g_Game_Pause(False);
1586 end;
1588 procedure ProcSpectate();
1589 begin
1590 if not (gGameSettings.GameType in [GT_CUSTOM, GT_SERVER, GT_CLIENT]) then
1591 Exit;
1592 g_Game_Spectate();
1593 g_ActiveWindow := nil;
1594 g_Game_Pause(False);
1595 end;
1597 procedure ProcRestartMenuKeyDown (yes: Boolean);
1598 begin
1599 if yes then g_Game_Restart() else g_GUI_HideWindow;
1600 end;
1602 procedure ProcEndMenuKeyDown (yes: Boolean);
1603 begin
1604 if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow;
1605 end;
1607 procedure ProcSetRussianLanguage();
1608 begin
1609 if gLanguage <> LANGUAGE_RUSSIAN then
1610 begin
1611 gLanguage := LANGUAGE_RUSSIAN;
1612 gLanguageChange := True;
1613 gAskLanguage := False;
1615 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1617 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1618 ProcApplyOptions();
1619 end;
1620 end;
1622 procedure ProcSetEnglishLanguage();
1623 begin
1624 if gLanguage <> LANGUAGE_ENGLISH then
1625 begin
1626 gLanguage := LANGUAGE_ENGLISH;
1627 gLanguageChange := True;
1628 gAskLanguage := False;
1630 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1632 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1633 ProcApplyOptions();
1634 end;
1635 end;
1637 procedure ReadGameSettings();
1638 var
1639 menu: TGUIMenu;
1640 begin
1641 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1643 with gGameSettings do
1644 begin
1645 with TGUISwitch(menu.GetControl('swTeamDamage')) do
1646 if LongBool(Options and GAME_OPTION_TEAMDAMAGE) then
1647 ItemIndex := 0
1648 else
1649 ItemIndex := 1;
1651 TGUIEdit(menu.GetControl('edTimeLimit')).Text := IntToStr(TimeLimit);
1652 TGUIEdit(menu.GetControl('edGoalLimit')).Text := IntToStr(GoalLimit);
1653 TGUIEdit(menu.GetControl('edMaxLives')).Text := IntToStr(MaxLives);
1655 with TGUISwitch(menu.GetControl('swBotsVS')) do
1656 if LongBool(Options and GAME_OPTION_BOTVSPLAYER) and
1657 LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1658 ItemIndex := 2
1659 else
1660 if LongBool(Options and GAME_OPTION_BOTVSMONSTER) then
1661 ItemIndex := 1
1662 else
1663 ItemIndex := 0;
1665 if GameType in [GT_CUSTOM, GT_SERVER] then
1666 begin
1667 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1668 TGUIEdit(menu.GetControl('edTimeLimit')).Enabled := True;
1669 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_ITEMSTEXT_COLOR;
1670 TGUIEdit(menu.GetControl('edGoalLimit')).Enabled := True;
1671 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_ITEMSTEXT_COLOR;
1672 TGUIEdit(menu.GetControl('edMaxLives')).Enabled := True;
1673 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_ITEMSTEXT_COLOR;
1674 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1675 end
1676 else
1677 begin
1678 TGUISwitch(menu.GetControl('swTeamDamage')).Enabled := True;
1679 with TGUIEdit(menu.GetControl('edTimeLimit')) do
1680 begin
1681 Enabled := False;
1682 Text := '';
1683 end;
1684 TGUILabel(menu.GetControlsText('edTimeLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1685 with TGUIEdit(menu.GetControl('edGoalLimit')) do
1686 begin
1687 Enabled := False;
1688 Text := '';
1689 end;
1690 TGUILabel(menu.GetControlsText('edGoalLimit')).Color := MENU_UNACTIVEITEMS_COLOR;
1691 with TGUIEdit(menu.GetControl('edMaxLives')) do
1692 begin
1693 Enabled := False;
1694 Text := '';
1695 end;
1696 TGUILabel(menu.GetControlsText('edMaxLives')).Color := MENU_UNACTIVEITEMS_COLOR;
1697 TGUISwitch(menu.GetControl('swBotsVS')).Enabled := True;
1698 end;
1699 end;
1700 end;
1702 procedure ProcApplyGameSet();
1703 var
1704 menu: TGUIMenu;
1705 a, b, n: Integer;
1706 stat: TPlayerStatArray;
1707 begin
1708 menu := TGUIMenu(g_GUI_GetWindow('GameSetGameMenu').GetControl('mGameSetGameMenu'));
1710 if not g_Game_IsServer then Exit;
1712 with gGameSettings do
1713 begin
1714 if TGUISwitch(menu.GetControl('swTeamDamage')).Enabled then
1715 begin
1716 if TGUISwitch(menu.GetControl('swTeamDamage')).ItemIndex = 0 then
1717 Options := Options or GAME_OPTION_TEAMDAMAGE
1718 else
1719 Options := Options and (not GAME_OPTION_TEAMDAMAGE);
1720 end;
1722 if TGUIEdit(menu.GetControl('edTimeLimit')).Enabled then
1723 begin
1724 n := StrToIntDef(TGUIEdit(menu.GetControl('edTimeLimit')).Text, TimeLimit);
1726 if n = 0 then
1727 TimeLimit := 0
1728 else
1729 begin
1730 b := (gTime - gGameStartTime) div 1000 + 10; // 10 ñåêóíä íà ñìåíó
1732 TimeLimit := Max(n, b);
1733 end;
1734 end;
1736 if TGUIEdit(menu.GetControl('edGoalLimit')).Enabled then
1737 begin
1738 n := StrToIntDef(TGUIEdit(menu.GetControl('edGoalLimit')).Text, GoalLimit);
1740 if n = 0 then
1741 GoalLimit := 0
1742 else
1743 begin
1744 b := 0;
1745 if GameMode = GM_DM then
1746 begin // DM
1747 stat := g_Player_GetStats();
1748 if stat <> nil then
1749 for a := 0 to High(stat) do
1750 if stat[a].Frags > b then
1751 b := stat[a].Frags;
1752 end
1753 else // CTF
1754 b := Max(gTeamStat[TEAM_RED].Goals, gTeamStat[TEAM_BLUE].Goals);
1756 GoalLimit := Max(n, b);
1757 end;
1758 end;
1760 if TGUIEdit(menu.GetControl('edMaxLives')).Enabled then
1761 begin
1762 n := StrToIntDef(TGUIEdit(menu.GetControl('edMaxLives')).Text, GoalLimit);
1763 if n < 0 then n := 0;
1764 if n > 255 then n := 255;
1765 if n = 0 then
1766 MaxLives := 0
1767 else
1768 begin
1769 b := 0;
1770 stat := g_Player_GetStats();
1771 if stat <> nil then
1772 for a := 0 to High(stat) do
1773 if stat[a].Lives > b then
1774 b := stat[a].Lives;
1776 MaxLives := Max(n, b);
1777 end;
1778 end;
1780 if TGUISwitch(menu.GetControl('swBotsVS')).Enabled then
1781 begin
1782 case TGUISwitch(menu.GetControl('swBotsVS')).ItemIndex of
1783 1:
1784 begin
1785 Options := Options and (not GAME_OPTION_BOTVSPLAYER);
1786 Options := Options or GAME_OPTION_BOTVSMONSTER;
1787 end;
1788 2:
1789 begin
1790 Options := Options or GAME_OPTION_BOTVSPLAYER;
1791 Options := Options or GAME_OPTION_BOTVSMONSTER;
1792 end;
1793 else
1794 begin
1795 Options := Options or GAME_OPTION_BOTVSPLAYER;
1796 Options := Options and (not GAME_OPTION_BOTVSMONSTER);
1797 end;
1798 end;
1799 end;
1800 end;
1802 if g_Game_IsNet then MH_SEND_GameSettings;
1803 end;
1805 procedure ProcVideoOptionsRes();
1806 var
1807 menu: TGUIMenu;
1808 list: SSArray;
1809 SR: DWORD;
1810 begin
1811 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1813 TGUILabel(menu.GetControl('lbCurrentRes')).Text :=
1814 IntToStr(gScreenWidth) +
1815 ' x ' + IntToStr(gScreenHeight) +
1816 ', ' + IntToStr(gBPP) + ' bpp';
1818 with TGUIListBox(menu.GetControl('lsResolution')) do
1819 begin
1820 list := GetDisplayModes(gBPP, SR);
1822 if list <> nil then
1823 begin
1824 Items := list;
1825 ItemIndex := SR;
1826 end
1827 else
1828 Clear();
1829 end;
1831 with TGUISwitch(menu.GetControl('swFullScreen')) do
1832 if gFullscreen then
1833 ItemIndex := 0
1834 else
1835 ItemIndex := 1;
1836 end;
1838 procedure ProcApplyVideoOptions();
1839 var
1840 menu: TGUIMenu;
1841 Fullscreen: Boolean;
1842 SWidth, SHeight: Integer;
1843 str: String;
1844 begin
1845 menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
1847 str := TGUIListBox(menu.GetControl('lsResolution')).SelectedItem;
1848 SScanf(str, '%dx%d', [@SWidth, @SHeight]);
1850 Fullscreen := TGUISwitch(menu.GetControl('swFullScreen')).ItemIndex = 0;
1852 if (SWidth <> gScreenWidth) or
1853 (SHeight <> gScreenHeight) or
1854 (Fullscreen <> gFullscreen) then
1855 begin
1856 gResolutionChange := True;
1857 gRC_Width := SWidth;
1858 gRC_Height := SHeight;
1859 gRC_FullScreen := Fullscreen;
1860 gRC_Maximized := gWinMaximized;
1861 end;
1863 // Ñîõðàíÿåì èçìåíåíèÿ âñåõ íàñòðîåê:
1864 ProcApplyOptions();
1865 end;
1867 procedure ProcSetFirstRussianLanguage();
1868 begin
1869 gLanguage := LANGUAGE_RUSSIAN;
1870 gLanguageChange := True;
1871 gAskLanguage := False;
1873 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1874 end;
1876 procedure ProcSetFirstEnglishLanguage();
1877 begin
1878 gLanguage := LANGUAGE_ENGLISH;
1879 gLanguageChange := True;
1880 gAskLanguage := False;
1882 g_Options_Write_Language(GameDir+'/'+CONFIG_FILENAME);
1883 end;
1885 procedure ProcRecallAddress();
1886 begin
1887 with TGUIMenu(g_GUI_GetWindow('NetClientMenu').GetControl('mNetClientMenu')) do
1888 begin
1889 TGUIEdit(GetControl('edIP')).Text := NetClientIP;
1890 TGUIEdit(GetControl('edPort')).Text := IntToStr(NetClientPort);
1891 end;
1892 end;
1894 procedure CreateFirstLanguageMenu();
1895 var
1896 Menu: TGUIWindow;
1897 begin
1898 Menu := TGUIWindow.Create('FirstLanguageMenu');
1900 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, ' '))) do
1901 begin
1902 Name := 'mmFirstLanguageMenu';
1903 AddButton(@ProcSetFirstRussianLanguage, 'Ðóññêèé', '');
1904 AddButton(@ProcSetFirstEnglishLanguage, 'English', '');
1905 end;
1907 Menu.DefControl := 'mmFirstLanguageMenu';
1908 Menu.MainWindow := True;
1909 g_GUI_AddWindow(Menu);
1910 end;
1912 procedure g_Menu_AskLanguage();
1913 begin
1914 CreateFirstLanguageMenu();
1915 g_GUI_ShowWindow('FirstLanguageMenu');
1916 end;
1918 procedure CreatePlayerOptionsMenu(s: String);
1919 var
1920 Menu: TGUIWindow;
1921 a: String;
1922 begin
1923 Menu := TGUIWindow.Create('OptionsPlayers'+s+'Menu');
1924 if s = 'P1' then
1925 a := _lc[I_MENU_PLAYER_1]
1926 else
1927 a := _lc[I_MENU_PLAYER_2];
1928 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, a))) do
1929 begin
1930 Name := 'mOptionsPlayers'+s+'Menu';
1931 with AddEdit(_lc[I_MENU_PLAYER_NAME]) do
1932 begin
1933 Name := 'ed'+s+'Name';
1934 MaxLength := 12;
1935 Width := 12;
1936 end;
1937 with AddSwitch(_lc[I_MENU_PLAYER_TEAM]) do
1938 begin
1939 Name := 'sw'+s+'Team';
1940 AddItem(_lc[I_MENU_PLAYER_TEAM_RED]);
1941 AddItem(_lc[I_MENU_PLAYER_TEAM_BLUE]);
1942 end ;
1943 with AddList(_lc[I_MENU_PLAYER_MODEL], 12, 6) do
1944 begin
1945 Name := 'ls'+s+'Model';
1946 Sort := True;
1947 Items := g_PlayerModel_GetNames();
1948 OnChange := ProcSelectModel;
1949 end;
1950 with AddScroll(_lc[I_MENU_PLAYER_RED]) do
1951 begin
1952 Name := 'sc'+s+'Red';
1953 Max := 16;
1954 OnChange := ProcChangeColor;
1955 end;
1956 with AddScroll(_lc[I_MENU_PLAYER_GREEN]) do
1957 begin
1958 Name := 'sc'+s+'Green';
1959 Max := 16;
1960 OnChange := ProcChangeColor;
1961 end;
1962 with AddScroll(_lc[I_MENU_PLAYER_BLUE]) do
1963 begin
1964 Name := 'sc'+s+'Blue';
1965 Max := 16;
1966 OnChange := ProcChangeColor;
1967 end;
1968 AddSpace();
1969 AddButton(@ProcOptionsPlayersMIMenu, _lc[I_MENU_MODEL_INFO]);
1970 AddButton(@ProcOptionsPlayersAnim, _lc[I_MENU_MODEL_ANIMATION]);
1971 AddButton(@ProcOptionsPlayersWeap, _lc[I_MENU_MODEL_CHANGE_WEAPON]);
1972 AddButton(@ProcOptionsPlayersRot, _lc[I_MENU_MODEL_ROTATE]);
1974 with TGUIModelView(Menu.AddChild(TGUIModelView.Create)) do
1975 begin
1976 Name := 'mv'+s+'Model';
1977 X := GetControl('ls'+s+'Model').X+TGUIListBox(GetControl('ls'+s+'Model')).GetWidth+16;
1978 Y := GetControl('ls'+s+'Model').Y;
1979 end;
1980 end;
1981 Menu.DefControl := 'mOptionsPlayers'+s+'Menu';
1982 g_GUI_AddWindow(Menu);
1983 end;
1985 procedure CreateAllMenus();
1986 var
1987 Menu: TGUIWindow;
1988 //SR: TSearchRec;
1989 a, cx, _y, i: Integer;
1990 //list: SSArray;
1991 begin
1992 Menu := TGUIWindow.Create('MainMenu');
1993 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
1994 begin
1995 Name := 'mmMainMenu';
1996 AddButton(nil, _lc[I_MENU_NEW_GAME], 'NewGameMenu');
1997 AddButton(nil, _lc[I_MENU_MULTIPLAYER], 'NetGameMenu');
1998 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
1999 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
2000 AddButton(@ProcAuthorsMenu, _lc[I_MENU_AUTHORS], 'AuthorsMenu');
2001 AddButton(nil, _lc[I_MENU_EXIT], 'ExitMenu');
2002 end;
2003 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_VERSION], [GAME_VERSION]), gMenuSmallFont))) do
2004 begin
2005 Color := _RGB(255, 255, 255);
2006 X := gScreenWidth-GetWidth-8;
2007 Y := gScreenHeight-GetHeight-8;
2008 end;
2009 Menu.DefControl := 'mmMainMenu';
2010 Menu.MainWindow := True;
2011 g_GUI_AddWindow(Menu);
2013 Menu := TGUIWindow.Create('NewGameMenu');
2014 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_NEW_GAME]))) do
2015 begin
2016 Name := 'mmNewGameMenu';
2017 AddButton(@ProcSingle1Player, _lc[I_MENU_1_PLAYER]);
2018 AddButton(@ProcSingle2Players, _lc[I_MENU_2_PLAYERS]);
2019 AddButton(nil, _lc[I_MENU_CUSTOM_GAME], 'CustomGameMenu');
2020 AddButton(@ProcSelectCampaignMenu, _lc[I_MENU_CAMPAIGN], 'CampaignMenu');
2021 end;
2022 Menu.DefControl := 'mmNewGameMenu';
2023 g_GUI_AddWindow(Menu);
2025 Menu := TGUIWindow.Create('NetGameMenu');
2026 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MULTIPLAYER]))) do
2027 begin
2028 Name := 'mmNetGameMenu';
2029 AddButton(@ProcRecallAddress, _lc[I_MENU_START_CLIENT], 'NetClientMenu');
2030 AddButton(nil, _lc[I_MENU_START_SERVER], 'NetServerMenu');
2031 end;
2032 Menu.DefControl := 'mmNetGameMenu';
2033 g_GUI_AddWindow(Menu);
2035 Menu := TGUIWindow.Create('NetServerMenu');
2036 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_SERVER]))) do
2037 begin
2038 Name := 'mNetServerMenu';
2039 with AddEdit(_lc[I_NET_SERVER_NAME]) do
2040 begin
2041 Name := 'edSrvName';
2042 OnlyDigits := False;
2043 Width := 16;
2044 MaxLength := 64;
2045 Text := NetServerName;
2046 end;
2047 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2048 begin
2049 Name := 'edSrvPassword';
2050 OnlyDigits := False;
2051 Width := 16;
2052 MaxLength := 24;
2053 Text := NetPassword;
2054 end;
2055 with AddEdit(_lc[I_NET_PORT]) do
2056 begin
2057 Name := 'edPort';
2058 OnlyDigits := True;
2059 Width := 4;
2060 MaxLength := 5;
2061 Text := IntToStr(NetPort);
2062 end;
2063 with AddEdit(_lc[I_NET_MAX_CLIENTS]) do
2064 begin
2065 Name := 'edMaxPlayers';
2066 OnlyDigits := True;
2067 Width := 4;
2068 MaxLength := 2;
2069 Text := IntToStr(NetMaxClients);
2070 end;
2071 with AddSwitch(_lc[I_NET_USE_MASTER]) do
2072 begin
2073 Name := 'swUseMaster';
2074 AddItem(_lc[I_MENU_YES]);
2075 AddItem(_lc[I_MENU_NO]);
2076 if NetUseMaster then
2077 ItemIndex := 0
2078 else
2079 ItemIndex := 1;
2080 end;
2081 AddSpace();
2082 with AddLabel(_lc[I_MENU_MAP]) do
2083 begin
2084 Name := 'lbMap';
2085 FixedLength := 16;
2086 Text := gnMap;
2087 OnClick := @ProcSelectMapMenu;
2088 end;
2089 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2090 begin
2091 Name := 'swGameMode';
2092 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2093 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2094 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2095 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2096 case g_Game_TextToMode(gnGameMode) of
2097 GM_NONE,
2098 GM_DM: ItemIndex := 0;
2099 GM_TDM: ItemIndex := 1;
2100 GM_CTF: ItemIndex := 2;
2101 GM_SINGLE,
2102 GM_COOP: ItemIndex := 3;
2103 end;
2104 OnChange := ProcSwitchMonstersNet;
2105 end;
2106 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2107 begin
2108 Name := 'edTimeLimit';
2109 OnlyDigits := True;
2110 Width := 4;
2111 MaxLength := 5;
2112 if gnTimeLimit > 0 then
2113 Text := IntToStr(gnTimeLimit);
2114 end;
2115 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2116 begin
2117 Name := 'edGoalLimit';
2118 OnlyDigits := True;
2119 Width := 4;
2120 MaxLength := 5;
2121 if gnGoalLimit > 0 then
2122 Text := IntToStr(gnGoalLimit);
2123 end;
2124 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2125 begin
2126 Name := 'edMaxLives';
2127 OnlyDigits := True;
2128 Width := 4;
2129 MaxLength := 3;
2130 if gnMaxLives > 0 then
2131 Text := IntToStr(gnMaxLives);
2132 end;
2133 with AddSwitch(_lc[I_MENU_SERVER_PLAYERS]) do
2134 begin
2135 Name := 'swPlayers';
2136 AddItem(_lc[I_MENU_COUNT_NONE]);
2137 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2138 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2139 ItemIndex := gnPlayers;
2140 end;
2141 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2142 begin
2143 Name := 'swTeamDamage';
2144 AddItem(_lc[I_MENU_YES]);
2145 AddItem(_lc[I_MENU_NO]);
2146 if gnTeamDamage then
2147 ItemIndex := 0
2148 else
2149 ItemIndex := 1;
2150 end;
2151 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2152 begin
2153 Name := 'swEnableExits';
2154 AddItem(_lc[I_MENU_YES]);
2155 AddItem(_lc[I_MENU_NO]);
2156 if gnAllowExit then
2157 ItemIndex := 0
2158 else
2159 ItemIndex := 1;
2160 end;
2161 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2162 begin
2163 Name := 'swWeaponStay';
2164 AddItem(_lc[I_MENU_YES]);
2165 AddItem(_lc[I_MENU_NO]);
2166 if gnWeaponStay then
2167 ItemIndex := 0
2168 else
2169 ItemIndex := 1;
2170 end;
2171 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2172 begin
2173 Name := 'swMonsters';
2174 AddItem(_lc[I_MENU_YES]);
2175 AddItem(_lc[I_MENU_NO]);
2176 if gnMonsters then
2177 ItemIndex := 0
2178 else
2179 ItemIndex := 1;
2180 end;
2181 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2182 begin
2183 Name := 'swBotsVS';
2184 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2185 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2186 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2187 ItemIndex := 2;
2188 if gnBotsVS = 'Players' then
2189 ItemIndex := 0;
2190 if gnBotsVS = 'Monsters' then
2191 ItemIndex := 1;
2192 end;
2193 AddSpace();
2194 AddButton(@ProcStartNetGame, _lc[I_MENU_START_GAME]);
2196 ReAlign();
2197 end;
2198 Menu.DefControl := 'mNetServerMenu';
2199 g_GUI_AddWindow(Menu);
2201 Menu := TGUIWindow.Create('NetClientMenu');
2202 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_START_CLIENT]))) do
2203 begin
2204 Name := 'mNetClientMenu';
2206 AddButton(@ProcServerlist, _lc[I_NET_SLIST]);
2207 AddSpace();
2209 with AddEdit(_lc[I_NET_ADDRESS]) do
2210 begin
2211 Name := 'edIP';
2212 OnlyDigits :=False;
2213 Width := 12;
2214 MaxLength := 64;
2215 Text := 'localhost';
2216 end;
2217 with AddEdit(_lc[I_NET_PORT]) do
2218 begin
2219 Name := 'edPort';
2220 OnlyDigits := True;
2221 Width := 4;
2222 MaxLength := 5;
2223 Text := '25666';
2224 end;
2225 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
2226 begin
2227 Name := 'edPW';
2228 OnlyDigits := False;
2229 Width := 12;
2230 MaxLength := 32;
2231 Text := '';
2232 end;
2234 AddSpace();
2235 AddButton(@ProcConnectNetGame, _lc[I_MENU_CLIENT_CONNECT]);
2237 ReAlign();
2238 end;
2239 Menu.DefControl := 'mNetClientMenu';
2240 g_GUI_AddWindow(Menu);
2242 Menu := TGUIWindow.Create('LoadMenu');
2243 Menu.OnShow := ProcLoadMenu;
2244 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LOAD_GAME]))) do
2245 begin
2246 Name := 'mmLoadMenu';
2248 for a := 1 to 8 do
2249 with AddEdit('') do
2250 begin
2251 Name := 'edSlot'+IntToStr(a);
2252 Width := 16;
2253 MaxLength := 16;
2254 OnEnter := ProcLoadGame;
2255 end;
2256 end;
2257 Menu.DefControl := 'mmLoadMenu';
2258 g_GUI_AddWindow(Menu);
2260 Menu := TGUIWindow.Create('SaveMenu');
2261 Menu.OnShow := ProcSaveMenu;
2262 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SAVE_GAME]))) do
2263 begin
2264 Name := 'mmSaveMenu';
2266 for a := 1 to 8 do
2267 with AddEdit('') do
2268 begin
2269 Name := 'edSlot'+IntToStr(a);
2270 Width := 16;
2271 MaxLength := 16;
2272 OnChange := ProcSaveGame;
2273 end;
2274 end;
2275 Menu.DefControl := 'mmSaveMenu';
2276 g_GUI_AddWindow(Menu);
2278 Menu := TGUIWindow.Create('CustomGameMenu');
2279 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CUSTOM_GAME]))) do
2280 begin
2281 Name := 'mCustomGameMenu';
2282 with AddLabel(_lc[I_MENU_MAP]) do
2283 begin
2284 Name := 'lbMap';
2285 FixedLength := 16;
2286 Text := gcMap;
2287 OnClick := @ProcSelectMapMenu;
2288 end;
2289 with AddSwitch(_lc[I_MENU_GAME_TYPE]) do
2290 begin
2291 Name := 'swGameMode';
2292 AddItem(_lc[I_MENU_GAME_TYPE_DM]);
2293 AddItem(_lc[I_MENU_GAME_TYPE_TDM]);
2294 AddItem(_lc[I_MENU_GAME_TYPE_CTF]);
2295 AddItem(_lc[I_MENU_GAME_TYPE_COOP]);
2296 case g_Game_TextToMode(gcGameMode) of
2297 GM_NONE,
2298 GM_DM: ItemIndex := 0;
2299 GM_TDM: ItemIndex := 1;
2300 GM_CTF: ItemIndex := 2;
2301 GM_SINGLE,
2302 GM_COOP: ItemIndex := 3;
2303 end;
2304 OnChange := ProcSwitchMonstersCustom;
2305 end;
2306 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
2307 begin
2308 Name := 'edTimeLimit';
2309 OnlyDigits := True;
2310 Width := 4;
2311 MaxLength := 5;
2312 if gcTimeLimit > 0 then
2313 Text := IntToStr(gcTimeLimit);
2314 end;
2315 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
2316 begin
2317 Name := 'edGoalLimit';
2318 OnlyDigits := True;
2319 Width := 4;
2320 MaxLength := 5;
2321 if gcGoalLimit > 0 then
2322 Text := IntToStr(gcGoalLimit);
2323 end;
2324 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
2325 begin
2326 Name := 'edMaxLives';
2327 OnlyDigits := True;
2328 Width := 4;
2329 MaxLength := 5;
2330 if gcMaxLives > 0 then
2331 Text := IntToStr(gcMaxLives);
2332 end;
2333 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2334 begin
2335 Name := 'swPlayers';
2336 AddItem(_lc[I_MENU_COUNT_NONE]);
2337 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2338 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2339 ItemIndex := gcPlayers;
2340 end;
2341 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
2342 begin
2343 Name := 'swTeamDamage';
2344 AddItem(_lc[I_MENU_YES]);
2345 AddItem(_lc[I_MENU_NO]);
2346 if gcTeamDamage then
2347 ItemIndex := 0
2348 else
2349 ItemIndex := 1;
2350 end;
2351 with AddSwitch(_lc[I_MENU_ENABLE_EXITS]) do
2352 begin
2353 Name := 'swEnableExits';
2354 AddItem(_lc[I_MENU_YES]);
2355 AddItem(_lc[I_MENU_NO]);
2356 if gcAllowExit then
2357 ItemIndex := 0
2358 else
2359 ItemIndex := 1;
2360 end;
2361 with AddSwitch(_lc[I_MENU_WEAPONS_STAY]) do
2362 begin
2363 Name := 'swWeaponStay';
2364 AddItem(_lc[I_MENU_YES]);
2365 AddItem(_lc[I_MENU_NO]);
2366 if gcWeaponStay then
2367 ItemIndex := 0
2368 else
2369 ItemIndex := 1;
2370 end;
2371 with AddSwitch(_lc[I_MENU_ENABLE_MONSTERS]) do
2372 begin
2373 Name := 'swMonsters';
2374 AddItem(_lc[I_MENU_YES]);
2375 AddItem(_lc[I_MENU_NO]);
2376 if gcMonsters then
2377 ItemIndex := 0
2378 else
2379 ItemIndex := 1;
2380 end;
2381 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
2382 begin
2383 Name := 'swBotsVS';
2384 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
2385 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
2386 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
2387 ItemIndex := 2;
2388 if gcBotsVS = 'Players' then
2389 ItemIndex := 0;
2390 if gcBotsVS = 'Monsters' then
2391 ItemIndex := 1;
2392 end;
2393 AddSpace();
2394 AddButton(@ProcStartCustomGame, _lc[I_MENU_START_GAME]);
2396 ReAlign();
2397 end;
2398 Menu.DefControl := 'mCustomGameMenu';
2399 g_GUI_AddWindow(Menu);
2401 Menu := TGUIWindow.Create('CampaignMenu');
2402 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CAMPAIGN]))) do
2403 begin
2404 Name := 'mCampaignMenu';
2406 AddSpace();
2407 AddSpace();
2408 AddSpace();
2409 AddSpace();
2410 AddSpace();
2411 AddSpace();
2413 with AddFileList('', 15, 4) do
2414 begin
2415 Name := 'lsWAD';
2416 OnChange := ProcSelectCampaignWAD;
2418 Sort := True;
2419 Dirs := True;
2420 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2421 SetBase(MapsDir+'megawads/');
2422 end;
2424 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2425 begin
2426 Name := 'lbWADName';
2427 FixedLength := 8;
2428 Enabled := False;
2429 end;
2430 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2431 begin
2432 Name := 'lbWADAuthor';
2433 FixedLength := 8;
2434 Enabled := False;
2435 end;
2436 AddLine(_lc[I_MENU_MAP_DESCRIPTION]);
2437 with AddMemo('', 15, 3) do
2438 begin
2439 Name := 'meWADDescription';
2440 Color := MENU_ITEMSCTRL_COLOR;
2441 end;
2442 with AddSwitch(_lc[I_MENU_PLAYERS]) do
2443 begin
2444 Name := 'swPlayers';
2445 AddItem(_lc[I_MENU_PLAYERS_ONE]);
2446 AddItem(_lc[I_MENU_PLAYERS_TWO]);
2447 end;
2448 AddSpace();
2449 AddButton(@ProcStartCampaign, _lc[I_MENU_START_GAME]);
2451 ReAlign();
2453 with TGUIImage(Menu.AddChild(TGUIImage.Create)) do
2454 begin
2455 Name := 'mpWADImage';
2456 DefaultRes := 'NOPIC';
2457 X := GetControl('lsWAD').X+4;
2458 Y := GetControl('lsWAD').Y-128-MENU_VSPACE;
2459 end;
2460 end;
2461 Menu.DefControl := 'mCampaignMenu';
2462 g_GUI_AddWindow(Menu);
2464 Menu := TGUIWindow.Create('SelectMapMenu');
2465 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SELECT_MAP]))) do
2466 begin
2467 Name := 'mSelectMapMenu';
2468 with AddFileList(_lc[I_MENU_MAP_WAD], 12, 4) do
2469 begin
2470 Name := 'lsMapWAD';
2471 OnChange := ProcSelectWAD;
2473 Sort := True;
2474 Dirs := True;
2475 FileMask := '*.wad|*.pk3|*.zip|*.dfz';
2476 SetBase(MapsDir);
2477 end;
2478 with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do
2479 begin
2480 Name := 'lsMapRes';
2481 Sort := True;
2482 OnChange := ProcSelectMap;
2483 end;
2484 AddSpace();
2485 with AddLabel(_lc[I_MENU_MAP_NAME]) do
2486 begin
2487 Name := 'lbMapName';
2488 FixedLength := 24;
2489 Enabled := False;
2490 end;
2491 with AddLabel(_lc[I_MENU_MAP_AUTHOR]) do
2492 begin
2493 Name := 'lbMapAuthor';
2494 FixedLength := 16;
2495 Enabled := False;
2496 end;
2497 with AddLabel(_lc[I_MENU_MAP_SIZE]) do
2498 begin
2499 Name := 'lbMapSize';
2500 FixedLength := 10;
2501 Enabled := False;
2502 end;
2503 with AddMemo(_lc[I_MENU_MAP_DESCRIPTION], 12, 4) do
2504 begin
2505 Name := 'meMapDescription';
2506 end;
2508 ReAlign();
2510 with TGUIMapPreview(Menu.AddChild(TGUIMapPreview.Create)) do
2511 begin
2512 Name := 'mpMapPreview';
2513 X := GetControl('lsMapWAD').X+TGUIListBox(GetControl('lsMapWAD')).GetWidth()+2;
2514 Y := GetControl('lsMapWAD').Y;
2515 end;
2516 with TGUILabel(Menu.AddChild(TGUILabel.Create('', gMenuSmallFont))) do
2517 begin
2518 Name := 'lbMapScale';
2519 FixedLength := 8;
2520 Enabled := False;
2521 Color := MENU_ITEMSCTRL_COLOR;
2522 X := GetControl('lsMapWAD').X +
2523 TGUIListBox(GetControl('lsMapWAD')).GetWidth() +
2524 2 + MAPPREVIEW_WIDTH*4;
2525 Y := GetControl('lsMapWAD').Y + MAPPREVIEW_HEIGHT*16 + 16;
2526 end;
2527 end;
2528 Menu.OnClose := ProcSetMap;
2529 Menu.DefControl := 'mSelectMapMenu';
2530 g_GUI_AddWindow(Menu);
2532 Menu := TGUIWindow.Create('OptionsMenu');
2533 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_OPTIONS]))) do
2534 begin
2535 Name := 'mmOptionsMenu';
2536 AddButton(nil, _lc[I_MENU_VIDEO_OPTIONS], 'OptionsVideoMenu');
2537 AddButton(nil, _lc[I_MENU_SOUND_OPTIONS], 'OptionsSoundMenu');
2538 AddButton(nil, _lc[I_MENU_GAME_OPTIONS], 'OptionsGameMenu');
2539 AddButton(nil, _lc[I_MENU_CONTROLS_OPTIONS], 'OptionsControlsMenu');
2540 AddButton(nil, _lc[I_MENU_PLAYER_OPTIONS], 'OptionsPlayersMenu');
2541 AddButton(nil, _lc[I_MENU_LANGUAGE_OPTIONS], 'OptionsLanguageMenu');
2542 AddSpace();
2543 AddButton(nil, _lc[I_MENU_SAVED_OPTIONS], 'SavedOptionsMenu').Color := _RGB(255, 0, 0);
2544 AddButton(nil, _lc[I_MENU_DEFAULT_OPTIONS], 'DefaultOptionsMenu').Color := _RGB(255, 0, 0);
2545 end;
2546 Menu.OnClose := ProcApplyOptions;
2547 Menu.DefControl := 'mmOptionsMenu';
2548 g_GUI_AddWindow(Menu);
2550 Menu := CreateYNMenu('SavedOptionsMenu', _lc[I_MENU_LOAD_SAVED_PROMT], Round(gScreenWidth*0.6),
2551 gMenuSmallFont, @ProcSavedMenuKeyDown);
2552 g_GUI_AddWindow(Menu);
2554 Menu := TGUIWindow.Create('OptionsVideoMenu');
2555 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_VIDEO_OPTIONS]))) do
2556 begin
2557 Name := 'mOptionsVideoMenu';
2558 AddButton(@ProcVideoOptionsRes, _lc[I_MENU_VIDEO_RESOLUTION], 'OptionsVideoResMenu');
2559 with AddSwitch(_lc[I_MENU_VIDEO_BPP]) do
2560 begin
2561 Name := 'swBPP';
2562 AddItem('16');
2563 AddItem('32');
2564 end;
2565 with AddSwitch(_lc[I_MENU_VIDEO_VSYNC]) do
2566 begin
2567 Name := 'swVSync';
2568 AddItem(_lc[I_MENU_YES]);
2569 AddItem(_lc[I_MENU_NO]);
2570 end;
2571 with AddSwitch(_lc[I_MENU_VIDEO_FILTER_SKY]) do
2572 begin
2573 Name := 'swTextureFilter';
2574 AddItem(_lc[I_MENU_YES]);
2575 AddItem(_lc[I_MENU_NO]);
2576 end;
2577 with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do
2578 begin
2579 Name := 'swLegacyNPOT';
2580 AddItem(_lc[I_MENU_NO]);
2581 AddItem(_lc[I_MENU_YES]);
2582 end;
2583 AddSpace();
2584 AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6));
2585 ReAlign();
2586 end;
2587 Menu.DefControl := 'mOptionsVideoMenu';
2588 g_GUI_AddWindow(Menu);
2590 Menu := TGUIWindow.Create('OptionsVideoResMenu');
2591 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_RESOLUTION_SELECT]))) do
2592 begin
2593 Name := 'mOptionsVideoResMenu';
2594 with AddLabel(_lc[I_MENU_RESOLUTION_CURRENT]) do
2595 begin
2596 Name := 'lbCurrentRes';
2597 FixedLength := 24;
2598 Enabled := False;
2599 end;
2600 with AddList(_lc[I_MENU_RESOLUTION_LIST], 12, 6) do
2601 begin
2602 Name := 'lsResolution';
2603 Sort := False;
2604 end;
2605 with AddSwitch(_lc[I_MENU_RESOLUTION_FULLSCREEN]) do
2606 begin
2607 Name := 'swFullScreen';
2608 AddItem(_lc[I_MENU_YES]);
2609 AddItem(_lc[I_MENU_NO]);
2610 end;
2611 AddSpace();
2612 AddButton(@ProcApplyVideoOptions, _lc[I_MENU_RESOLUTION_APPLY]);
2613 UpdateIndex();
2614 end;
2615 Menu.DefControl := 'mOptionsVideoResMenu';
2616 g_GUI_AddWindow(Menu);
2618 Menu := TGUIWindow.Create('OptionsSoundMenu');
2619 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SOUND_OPTIONS]))) do
2620 begin
2621 Name := 'mOptionsSoundMenu';
2622 with AddScroll(_lc[I_MENU_SOUND_MUSIC_LEVEL]) do
2623 begin
2624 Name := 'scMusicLevel';
2625 Max := 16;
2626 OnChange := ProcChangeSoundSettings;
2627 end;
2628 with AddScroll(_lc[I_MENU_SOUND_SOUND_LEVEL]) do
2629 begin
2630 Name := 'scSoundLevel';
2631 Max := 16;
2632 OnChange := ProcChangeSoundSettings;
2633 end;
2634 with AddScroll(_lc[I_MENU_SOUND_MAX_SIM_SOUNDS]) do
2635 begin
2636 Name := 'scMaxSimSounds';
2637 Max := 16;
2638 end;
2639 with AddSwitch (_lc[I_MENU_SOUND_ANNOUNCE]) do
2640 begin;
2641 Name := 'swAnnouncer';
2642 AddItem(_lc[I_MENU_ANNOUNCE_NONE]);
2643 AddItem(_lc[I_MENU_ANNOUNCE_ME]);
2644 AddItem(_lc[I_MENU_ANNOUNCE_MEPLUS]);
2645 AddItem(_lc[I_MENU_ANNOUNCE_ALL]);
2646 end;
2647 // Ïåðåêëþ÷àòåëü çâóêîâûõ ýôôåêòîâ (DF / Doom 2)
2648 with AddSwitch (_lc[I_MENU_SOUND_COMPAT]) do
2649 begin;
2650 Name := 'swSoundEffects';
2651 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2652 AddItem(_lc[I_MENU_COMPAT_DF]);
2653 end;
2654 // Ïåðåêëþ÷àòåëü çâóêîâ ÷àòà
2655 with AddSwitch (_lc[I_MENU_SOUND_CHAT]) do
2656 begin;
2657 Name := 'swChatSpeech';
2658 AddItem(_lc[I_MENU_YES]);
2659 AddItem(_lc[I_MENU_NO]);
2660 end;
2661 with AddSwitch(_lc[I_MENU_SOUND_INACTIVE_SOUNDS]) do
2662 begin
2663 Name := 'swInactiveSounds';
2664 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_ON]);
2665 AddItem(_lc[I_MENU_SOUND_INACTIVE_SOUNDS_OFF]);
2666 end;
2667 ReAlign();
2668 end;
2669 Menu.DefControl := 'mOptionsSoundMenu';
2670 g_GUI_AddWindow(Menu);
2672 Menu := TGUIWindow.Create('OptionsGameMenu');
2673 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_GAME_OPTIONS]))) do
2674 begin
2675 Name := 'mOptionsGameMenu';
2676 with AddScroll(_lc[I_MENU_GAME_PARTICLES_COUNT]) do
2677 begin
2678 Name := 'scParticlesCount';
2679 Max := 20;
2680 end;
2681 with AddSwitch(_lc[I_MENU_GAME_BLOOD_COUNT]) do
2682 begin
2683 Name := 'swBloodCount';
2684 AddItem(_lc[I_MENU_COUNT_NONE]);
2685 AddItem(_lc[I_MENU_COUNT_SMALL]);
2686 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2687 AddItem(_lc[I_MENU_COUNT_BIG]);
2688 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2689 end;
2690 with AddScroll(_lc[I_MENU_GAME_MAX_SHELLS]) do
2691 begin
2692 Name := 'scShellsMax';
2693 Max := 20;
2694 end;
2695 with AddScroll(_lc[I_MENU_GAME_GIBS_COUNT]) do
2696 begin
2697 Name := 'scGibsMax';
2698 Max := 20;
2699 end;
2700 with AddScroll(_lc[I_MENU_GAME_MAX_CORPSES]) do
2701 begin
2702 Name := 'scCorpsesMax';
2703 Max := 20;
2704 end;
2705 with AddSwitch(_lc[I_MENU_GAME_MAX_GIBS]) do
2706 begin
2707 Name := 'swGibsCount';
2708 AddItem(_lc[I_MENU_COUNT_NONE]);
2709 AddItem(_lc[I_MENU_COUNT_SMALL]);
2710 AddItem(_lc[I_MENU_COUNT_NORMAL]);
2711 AddItem(_lc[I_MENU_COUNT_BIG]);
2712 AddItem(_lc[I_MENU_COUNT_VERYBIG]);
2713 end;
2714 with AddSwitch(_lc[I_MENU_GAME_CORPSE_TYPE]) do
2715 begin
2716 Name := 'swCorpseType';
2717 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_SIMPLE]);
2718 AddItem(_lc[I_MENU_GAME_CORPSE_TYPE_ADV]);
2719 end;
2720 with AddSwitch(_lc[I_MENU_GAME_GIBS_TYPE]) do
2721 begin
2722 Name := 'swGibsType';
2723 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_SIMPLE]);
2724 AddItem(_lc[I_MENU_GAME_GIBS_TYPE_ADV]);
2725 end;
2726 with AddSwitch(_lc[I_MENU_GAME_BLOOD_TYPE]) do
2727 begin
2728 Name := 'swBloodType';
2729 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_SIMPLE]);
2730 AddItem(_lc[I_MENU_GAME_BLOOD_TYPE_ADV]);
2731 end;
2732 with AddSwitch(_lc[I_MENU_GAME_SCREEN_FLASH]) do
2733 begin
2734 Name := 'swScreenFlash';
2735 AddItem(_lc[I_MENU_NO]);
2736 AddItem(_lc[I_MENU_COMPAT_DF]);
2737 AddItem(_lc[I_MENU_COMPAT_DOOM2]);
2738 end;
2739 with AddSwitch(_lc[I_MENU_GAME_BACKGROUND]) do
2740 begin
2741 Name := 'swBackground';
2742 AddItem(_lc[I_MENU_YES]);
2743 AddItem(_lc[I_MENU_NO]);
2744 end;
2745 with AddSwitch(_lc[I_MENU_GAME_MESSAGES]) do
2746 begin
2747 Name := 'swMessages';
2748 AddItem(_lc[I_MENU_YES]);
2749 AddItem(_lc[I_MENU_NO]);
2750 end;
2751 with AddSwitch(_lc[I_MENU_GAME_REVERT_PLAYERS]) do
2752 begin
2753 Name := 'swRevertPlayers';
2754 AddItem(_lc[I_MENU_YES]);
2755 AddItem(_lc[I_MENU_NO]);
2756 end;
2757 with AddSwitch(_lc[I_MENU_GAME_CHAT_BUBBLE]) do
2758 begin
2759 Name := 'swChatBubble';
2760 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_NONE]);
2761 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_SIMPLE]);
2762 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_ADV]);
2763 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_COLOR]);
2764 AddItem(_lc[I_MENU_GAME_CHAT_TYPE_TEXTURE]);
2765 end;
2766 with AddSwitch(_lc[I_MENU_GAME_PLAYER_INDICATOR]) do
2767 begin
2768 Name := 'swPlayerIndicator';
2769 AddItem(_lc[I_MENU_YES]);
2770 AddItem(_lc[I_MENU_NO]);
2771 end;
2772 with AddScroll(_lc[I_MENU_GAME_SCALE_FACTOR]) do
2773 begin
2774 Name := 'scScaleFactor';
2775 Max := 10;
2776 OnChange := ProcChangeGameSettings;
2777 end;
2778 ReAlign();
2779 end;
2780 Menu.DefControl := 'mOptionsGameMenu';
2781 g_GUI_AddWindow(Menu);
2783 Menu := TGUIWindow.Create('OptionsControlsMenu');
2784 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROLS_OPTIONS]))) do
2785 begin
2786 Name := 'mOptionsControlsMenu';
2787 AddLine(_lc[I_MENU_CONTROL_GLOBAL]);
2788 AddKeyRead(_lc[I_MENU_CONTROL_SCREENSHOT]).Name := _lc[I_MENU_CONTROL_SCREENSHOT];
2789 AddKeyRead(_lc[I_MENU_CONTROL_STAT]).Name := _lc[I_MENU_CONTROL_STAT];
2790 AddKeyRead(_lc[I_MENU_CONTROL_CHAT]).Name := _lc[I_MENU_CONTROL_CHAT];
2791 AddKeyRead(_lc[I_MENU_CONTROL_TEAMCHAT]).Name := _lc[I_MENU_CONTROL_TEAMCHAT];
2792 AddSpace();
2793 AddButton(nil, _lc[I_MENU_PLAYER_1_KBD], 'OptionsControlsP1Menu');
2794 {AddButton(nil, _lc[I_MENU_PLAYER_1_ALT], 'OptionsControlsP1MenuAlt');}
2795 AddButton(nil, _lc[I_MENU_PLAYER_1_WEAPONS], 'OptionsControlsP1MenuWeapons');
2796 AddButton(nil, _lc[I_MENU_PLAYER_2_KBD], 'OptionsControlsP2Menu');
2797 {AddButton(nil, _lc[I_MENU_PLAYER_2_ALT], 'OptionsControlsP2MenuAlt');}
2798 AddButton(nil, _lc[I_MENU_PLAYER_2_WEAPONS], 'OptionsControlsP2MenuWeapons');
2799 if e_JoysticksAvailable <> 0 then
2800 begin
2801 AddSpace();
2802 AddButton(nil, _lc[I_MENU_CONTROL_JOYSTICKS], 'OptionsControlsJoystickMenu');
2803 end;
2804 if g_touch_enabled then
2805 begin
2806 AddSpace();
2807 AddButton(nil, _lc[I_MENU_CONTROL_TOUCH], 'OptionsControlsTouchMenu');
2808 end;
2809 end;
2810 Menu.DefControl := 'mOptionsControlsMenu';
2811 g_GUI_AddWindow(Menu);
2813 Menu := TGUIWindow.Create('OptionsControlsP1Menu');
2814 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_KBD]))) do
2815 begin
2816 Name := 'mOptionsControlsP1Menu';
2817 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2818 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2819 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2820 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2821 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2822 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2823 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2824 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2825 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2826 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2827 end;
2828 Menu.DefControl := 'mOptionsControlsP1Menu';
2829 g_GUI_AddWindow(Menu);
2831 Menu := TGUIWindow.Create('OptionsControlsP1MenuWeapons');
2832 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_1_WEAPONS]))) do
2833 begin
2834 Name := 'mOptionsControlsP1MenuWeapons';
2835 for i := WP_FIRST to WP_LAST do
2836 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2837 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2838 end;
2839 Menu.DefControl := 'mOptionsControlsP1MenuWeapons';
2840 g_GUI_AddWindow(Menu);
2842 Menu := TGUIWindow.Create('OptionsControlsP2Menu');
2843 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_KBD]))) do
2844 begin
2845 Name := 'mOptionsControlsP2Menu';
2846 AddKeyRead2(_lc[I_MENU_CONTROL_LEFT]).Name := _lc[I_MENU_CONTROL_LEFT];
2847 AddKeyRead2(_lc[I_MENU_CONTROL_RIGHT]).Name := _lc[I_MENU_CONTROL_RIGHT];
2848 AddKeyRead2(_lc[I_MENU_CONTROL_UP]).Name := _lc[I_MENU_CONTROL_UP];
2849 AddKeyRead2(_lc[I_MENU_CONTROL_DOWN]).Name := _lc[I_MENU_CONTROL_DOWN];
2850 AddKeyRead2(_lc[I_MENU_CONTROL_JUMP]).Name := _lc[I_MENU_CONTROL_JUMP];
2851 AddKeyRead2(_lc[I_MENU_CONTROL_FIRE]).Name := _lc[I_MENU_CONTROL_FIRE];
2852 AddKeyRead2(_lc[I_MENU_CONTROL_USE]).Name := _lc[I_MENU_CONTROL_USE];
2853 AddKeyRead2(_lc[I_MENU_CONTROL_NEXT_WEAPON]).Name := _lc[I_MENU_CONTROL_NEXT_WEAPON];
2854 AddKeyRead2(_lc[I_MENU_CONTROL_PREV_WEAPON]).Name := _lc[I_MENU_CONTROL_PREV_WEAPON];
2855 AddKeyRead2(_lc[I_MENU_CONTROL_STRAFE]).Name := _lc[I_MENU_CONTROL_STRAFE];
2856 end;
2857 Menu.DefControl := 'mOptionsControlsP2Menu';
2858 g_GUI_AddWindow(Menu);
2860 Menu := TGUIWindow.Create('OptionsControlsP2MenuWeapons');
2861 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_2_WEAPONS]))) do
2862 begin
2863 Name := 'mOptionsControlsP2MenuWeapons';
2864 for i := WP_FIRST to WP_LAST do
2865 AddKeyRead2(_lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)]).Name :=
2866 _lc[TStrings_Locale(Cardinal(I_GAME_WEAPON0) + i)];
2867 end;
2868 Menu.DefControl := 'mOptionsControlsP2MenuWeapons';
2869 g_GUI_AddWindow(Menu);
2871 Menu := TGUIWindow.Create('OptionsControlsJoystickMenu');
2872 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_JOYSTICKS]))) do
2873 begin
2874 Name := 'mOptionsControlsJoystickMenu';
2875 for i := 0 to e_JoysticksAvailable-1 do
2876 with AddScroll(Format(_lc[I_MENU_CONTROL_DEADZONE], [i + 1])) do
2877 begin
2878 Name := 'scDeadzone' + IntToStr(i);
2879 Max := 20;
2880 end;
2881 end;
2882 Menu.DefControl := 'mOptionsControlsJoystickMenu';
2883 g_GUI_AddWindow(Menu);
2885 Menu := TGUIWindow.Create('OptionsControlsTouchMenu');
2886 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_CONTROL_TOUCH]))) do
2887 begin
2888 Name := 'mOptionsControlsTouchMenu';
2889 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_ALT]) do
2890 begin
2891 Name := 'swTouchAlt';
2892 AddItem(_lc[I_MENU_NO]);
2893 AddItem(_lc[I_MENU_YES]);
2894 OnChange := ProcChangeTouchSettings;
2895 end;
2896 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_SIZE]) do
2897 begin
2898 Name := 'scTouchSize';
2899 Max := 20;
2900 OnChange := ProcChangeTouchSettings;
2901 end;
2902 with AddSwitch(_lc[I_MENU_CONTROL_TOUCH_FIRE]) do
2903 begin
2904 Name := 'swTouchFire';
2905 AddItem(_lc[I_MENU_NO]);
2906 AddItem(_lc[I_MENU_YES]);
2907 end;
2908 with AddScroll(_lc[I_MENU_CONTROL_TOUCH_OFFSET]) do
2909 begin
2910 Name := 'scTouchOffset';
2911 Max := 20;
2912 OnChange := ProcChangeTouchSettings;
2913 end;
2914 end;
2915 Menu.DefControl := 'mOptionsControlsTouchMenu';
2916 g_GUI_AddWindow(Menu);
2918 Menu := TGUIWindow.Create('OptionsPlayersMenu');
2919 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_PLAYER_OPTIONS]))) do
2920 begin
2921 Name := 'mOptionsPlayersMenu';
2922 AddButton(nil, _lc[I_MENU_PLAYER_1], 'OptionsPlayersP1Menu');
2923 AddButton(nil, _lc[I_MENU_PLAYER_2], 'OptionsPlayersP2Menu');
2924 end;
2925 Menu.DefControl := 'mOptionsPlayersMenu';
2926 g_GUI_AddWindow(Menu);
2928 CreatePlayerOptionsMenu('P1');
2929 CreatePlayerOptionsMenu('P2');
2931 Menu := TGUIWindow.Create('OptionsPlayersMIMenu');
2932 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_MODEL_INFO]))) do
2933 begin
2934 Name := 'mOptionsPlayersMIMenu';
2935 with AddLabel(_lc[I_MENU_MODEL_NAME]) do
2936 begin
2937 Name := 'lbName';
2938 FixedLength := 16;
2939 end;
2940 with AddLabel(_lc[I_MENU_MODEL_AUTHOR]) do
2941 begin
2942 Name := 'lbAuthor';
2943 FixedLength := 16;
2944 end;
2945 with AddMemo(_lc[I_MENU_MODEL_COMMENT], 14, 6) do
2946 begin
2947 Name := 'meComment';
2948 end;
2949 AddSpace();
2950 AddLine(_lc[I_MENU_MODEL_OPTIONS]);
2951 with AddLabel(_lc[I_MENU_MODEL_WEAPON]) do
2952 begin
2953 Name := 'lbWeapon';
2954 FixedLength := Max(Length(_lc[I_MENU_YES]), Length(_lc[I_MENU_NO]));
2955 end;
2956 ReAlign();
2957 end;
2958 Menu.DefControl := 'mOptionsPlayersMIMenu';
2959 g_GUI_AddWindow(Menu);
2961 Menu := TGUIWindow.Create('OptionsLanguageMenu');
2962 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_LANGUAGE_OPTIONS]))) do
2963 begin
2964 Name := 'mOptionsLanguageMenu';
2965 AddButton(@ProcSetRussianLanguage, _lc[I_MENU_LANGUAGE_RUSSIAN]);
2966 AddButton(@ProcSetEnglishLanguage, _lc[I_MENU_LANGUAGE_ENGLISH]);
2967 ReAlign();
2968 end;
2969 Menu.DefControl := 'mOptionsLanguageMenu';
2970 g_GUI_AddWindow(Menu);
2972 Menu := CreateYNMenu('DefaultOptionsMenu', _lc[I_MENU_SET_DEFAULT_PROMT], Round(gScreenWidth*0.6),
2973 gMenuSmallFont, @ProcDefaultMenuKeyDown);
2974 g_GUI_AddWindow(Menu);
2976 Menu := TGUIWindow.Create('AuthorsMenu');
2977 Menu.BackTexture := 'INTER';
2978 Menu.OnClose := ProcAuthorsClose;
2980 // Çàãîëîâîê:
2981 _y := 16;
2982 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_1], gMenuFont))) do
2983 begin
2984 Color := _RGB(255, 0, 0);
2985 X := (gScreenWidth div 2)-(GetWidth() div 2);
2986 Y := _y;
2987 _y := _y+GetHeight();
2988 end;
2989 with TGUILabel(Menu.AddChild(TGUILabel.Create(Format(_lc[I_CREDITS_CAP_2], [GAME_VERSION, NET_PROTOCOL_VER]), gMenuSmallFont))) do
2990 begin
2991 Color := _RGB(255, 0, 0);
2992 X := (gScreenWidth div 2)-(GetWidth() div 2);
2993 Y := _y;
2994 _y := _y+GetHeight()+32;
2995 end;
2996 // ×òî äåëàë: Êòî äåëàë
2997 cx := gScreenWidth div 2 - 320 + 64;
2998 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1], gMenuSmallFont))) do
2999 begin
3000 Color := _RGB(255, 0, 0);
3001 X := cx;
3002 Y := _y;
3003 _y := _y+22;
3004 end;
3005 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_1_1], gMenuSmallFont))) do
3006 begin
3007 Color := _RGB(255, 255, 255);
3008 X := cx+32;
3009 Y := _y;
3010 _y := _y+36;
3011 end;
3012 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2], gMenuSmallFont))) do
3013 begin
3014 Color := _RGB(255, 0, 0);
3015 X := cx;
3016 Y := _y;
3017 _y := _y+22;
3018 end;
3019 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do
3020 begin
3021 Color := _RGB(255, 255, 255);
3022 X := cx+32;
3023 Y := _y;
3024 _y := _y+22;
3025 end;
3026 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do
3027 begin
3028 Color := _RGB(255, 255, 255);
3029 X := cx+32;
3030 Y := _y;
3031 _y := _y+36;
3032 end;
3033 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3], gMenuSmallFont))) do
3034 begin
3035 Color := _RGB(255, 0, 0);
3036 X := cx;
3037 Y := _y;
3038 _y := _y+22;
3039 end;
3040 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_3_1], gMenuSmallFont))) do
3041 begin
3042 Color := _RGB(255, 255, 255);
3043 X := cx+32;
3044 Y := _y;
3045 _y := _y+36;
3046 end;
3047 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4], gMenuSmallFont))) do
3048 begin
3049 Color := _RGB(255, 0, 0);
3050 X := cx;
3051 Y := _y;
3052 _y := _y+22;
3053 end;
3054 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_4_1], gMenuSmallFont))) do
3055 begin
3056 Color := _RGB(255, 255, 255);
3057 X := cx+32;
3058 Y := _y;
3059 _y := gScreenHeight - 128;
3060 end;
3061 // Çàêëþ÷åíèå:
3062 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CAP_3], gMenuSmallFont))) do
3063 begin
3064 Color := _RGB(255, 0, 0);
3065 X := cx;
3066 Y := _y;
3067 _y := _y+16;
3068 end;
3069 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_1], gMenuSmallFont))) do
3070 begin
3071 Color := _RGB(255, 255, 255);
3072 X := cx+32;
3073 Y := _y;
3074 _y := _y+GetHeight();
3075 end;
3076 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_2], gMenuSmallFont))) do
3077 begin
3078 Color := _RGB(255, 255, 255);
3079 X := cx+32;
3080 Y := _y;
3081 _y := _y+GetHeight();
3082 end;
3083 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_3], gMenuSmallFont))) do
3084 begin
3085 Color := _RGB(255, 255, 255);
3086 X := cx+32;
3087 Y := _y;
3088 _y := gScreenHeight - 32;
3089 end;
3090 with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_CLO_4], gMenuSmallFont))) do
3091 begin
3092 Color := _RGB(255, 0, 0);
3093 X := gScreenWidth div 2 - GetWidth() div 2;
3094 Y := _y;
3095 end;
3096 g_GUI_AddWindow(Menu);
3098 Menu := CreateYNMenu('ExitMenu', _lc[I_MENU_EXIT_PROMT], Round(gScreenWidth*0.6),
3099 gMenuSmallFont, @ProcExitMenuKeyDown);
3100 g_GUI_AddWindow(Menu);
3102 Menu := TGUIWindow.Create('GameSingleMenu');
3103 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3104 begin
3105 Name := 'mmGameSingleMenu';
3106 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3107 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3108 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3109 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3110 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3111 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3112 end;
3113 Menu.DefControl := 'mmGameSingleMenu';
3114 Menu.MainWindow := True;
3115 Menu.OnClose := ProcGMClose;
3116 Menu.OnShow := ProcGMShow;
3117 g_GUI_AddWindow(Menu);
3119 Menu := CreateYNMenu('EndGameMenu', _lc[I_MENU_END_GAME_PROMT], Round(gScreenWidth*0.6),
3120 gMenuSmallFont, @ProcEndMenuKeyDown);
3121 g_GUI_AddWindow(Menu);
3123 Menu := CreateYNMenu('RestartGameMenu', _lc[I_MENU_RESTART_GAME_PROMT], Round(gScreenWidth*0.6),
3124 gMenuSmallFont, @ProcRestartMenuKeyDown);
3125 g_GUI_AddWindow(Menu);
3127 Menu := TGUIWindow.Create('GameCustomMenu');
3128 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3129 begin
3130 Name := 'mmGameCustomMenu';
3131 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3132 AddButton(nil, _lc[I_MENU_LOAD_GAME], 'LoadMenu');
3133 AddButton(nil, _lc[I_MENU_SAVE_GAME], 'SaveMenu').Name := 'save';
3134 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3135 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3136 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3137 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3138 end;
3139 Menu.DefControl := 'mmGameCustomMenu';
3140 Menu.MainWindow := True;
3141 Menu.OnClose := ProcGMClose;
3142 Menu.OnShow := ProcGMShow;
3143 g_GUI_AddWindow(Menu);
3145 Menu := TGUIWindow.Create('GameServerMenu');
3146 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3147 begin
3148 Name := 'mmGameServerMenu';
3149 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3150 AddButton(@ReadGameSettings, _lc[I_MENU_SET_GAME], 'GameSetGameMenu');
3151 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3152 AddButton(nil, _lc[I_MENU_RESTART], 'RestartGameMenu');
3153 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3154 end;
3155 Menu.DefControl := 'mmGameServerMenu';
3156 Menu.MainWindow := True;
3157 Menu.OnClose := ProcGMClose;
3158 Menu.OnShow := ProcGMShow;
3159 g_GUI_AddWindow(Menu);
3161 Menu := TGUIWindow.Create('GameClientMenu');
3162 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do
3163 begin
3164 Name := 'mmGameClientMenu';
3165 AddButton(nil, _lc[I_MENU_CHANGE_PLAYERS], 'TeamMenu');
3166 AddButton(@ReadOptions, _lc[I_MENU_OPTIONS], 'OptionsMenu');
3167 AddButton(nil, _lc[I_MENU_END_GAME], 'EndGameMenu');
3168 end;
3169 Menu.DefControl := 'mmGameClientMenu';
3170 Menu.MainWindow := True;
3171 Menu.OnClose := ProcGMClose;
3172 Menu.OnShow := ProcGMShow;
3173 g_GUI_AddWindow(Menu);
3175 Menu := TGUIWindow.Create('ClientPasswordMenu');
3176 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, _lc[I_MENU_ENTERPASSWORD]))) do
3177 begin
3178 Name := 'mClientPasswordMenu';
3179 with AddEdit(_lc[I_NET_SERVER_PASSWORD]) do
3180 begin
3181 Name := 'edPW';
3182 Width := 12;
3183 MaxLength := 32;
3184 end;
3185 AddSpace;
3187 AddButton(@ProcEnterPassword, _lc[I_MENU_START_GAME]);
3188 ReAlign();
3189 end;
3190 Menu.DefControl := 'mClientPasswordMenu';
3191 g_GUI_AddWindow(Menu);
3193 Menu := TGUIWindow.Create('GameSetGameMenu');
3194 with TGUIMenu(Menu.AddChild(TGUIMenu.Create(gMenuFont, gMenuSmallFont, _lc[I_MENU_SET_GAME]))) do
3195 begin
3196 Name := 'mGameSetGameMenu';
3197 with AddSwitch(_lc[I_MENU_TEAM_DAMAGE]) do
3198 begin
3199 Name := 'swTeamDamage';
3200 AddItem(_lc[I_MENU_YES]);
3201 AddItem(_lc[I_MENU_NO]);
3202 ItemIndex := 1;
3203 end;
3204 with AddEdit(_lc[I_MENU_TIME_LIMIT]) do
3205 begin
3206 Name := 'edTimeLimit';
3207 OnlyDigits := True;
3208 Width := 4;
3209 MaxLength := 5;
3210 end;
3211 with AddEdit(_lc[I_MENU_GOAL_LIMIT]) do
3212 begin
3213 Name := 'edGoalLimit';
3214 OnlyDigits := True;
3215 Width := 4;
3216 MaxLength := 5;
3217 end;
3218 with AddEdit(_lc[I_MENU_MAX_LIVES]) do
3219 begin
3220 Name := 'edMaxLives';
3221 OnlyDigits := True;
3222 Width := 4;
3223 MaxLength := 5;
3224 end;
3225 with AddSwitch(_lc[I_MENU_BOTS_VS]) do
3226 begin
3227 Name := 'swBotsVS';
3228 AddItem(_lc[I_MENU_BOTS_VS_PLAYERS]);
3229 AddItem(_lc[I_MENU_BOTS_VS_MONSTERS]);
3230 AddItem(_lc[I_MENU_BOTS_VS_ALL]);
3231 ItemIndex := 2;
3232 end;
3234 ReAlign();
3235 end;
3236 Menu.DefControl := 'mGameSetGameMenu';
3237 Menu.OnClose := ProcApplyGameSet;
3238 g_GUI_AddWindow(Menu);
3240 Menu := TGUIWindow.Create('TeamMenu');
3241 with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_CHANGE_PLAYERS]))) do
3242 begin
3243 Name := 'mmTeamMenu';
3244 AddButton(@ProcJoinRed, _lc[I_MENU_JOIN_RED], '').Name := 'tmJoinRed';
3245 AddButton(@ProcJoinBlue, _lc[I_MENU_JOIN_BLUE], '').Name := 'tmJoinBlue';
3246 AddButton(@ProcJoinGame, _lc[I_MENU_JOIN_GAME], '').Name := 'tmJoinGame';
3247 AddButton(@ProcSwitchP2, _lc[I_MENU_ADD_PLAYER_2], '').Name := 'tmPlayer2';
3248 AddButton(@ProcSpectate, _lc[I_MENU_SPECTATE], '').Name := 'tmSpectate';
3249 end;
3250 Menu.DefControl := 'mmTeamMenu';
3251 Menu.OnShow := ProcChangePlayers;
3252 g_GUI_AddWindow(Menu);
3253 end;
3255 procedure g_Menu_Show_SaveMenu();
3256 begin
3257 if g_Game_IsTestMap then
3258 Exit;
3259 if gGameSettings.GameType = GT_SINGLE then
3260 g_GUI_ShowWindow('GameSingleMenu')
3261 else
3262 begin
3263 if g_Game_IsClient then
3264 Exit
3265 else
3266 if g_Game_IsNet then
3267 Exit
3268 else
3269 g_GUI_ShowWindow('GameCustomMenu');
3270 end;
3271 g_GUI_ShowWindow('SaveMenu');
3272 g_Sound_PlayEx('MENU_OPEN');
3273 end;
3275 procedure g_Menu_Show_LoadMenu (standalone: Boolean=false);
3276 begin
3277 if (g_ActiveWindow <> nil) and (g_ActiveWindow.name = 'LoadMenu') then exit; // nothing to do
3278 if gGameSettings.GameType = GT_SINGLE then
3279 begin
3280 if not standalone then g_GUI_ShowWindow('GameSingleMenu')
3281 end
3282 else
3283 begin
3284 if g_Game_IsClient then exit;
3285 if g_Game_IsNet then exit;
3286 if not standalone then g_GUI_ShowWindow('GameCustomMenu');
3287 end;
3288 g_GUI_ShowWindow('LoadMenu');
3289 g_Sound_PlayEx('MENU_OPEN');
3290 end;
3292 procedure g_Menu_Show_GameSetGame();
3293 begin
3294 if gGameSettings.GameType = GT_SINGLE then
3295 g_GUI_ShowWindow('GameSingleMenu')
3296 else
3297 begin
3298 if g_Game_IsClient then
3299 Exit
3300 else
3301 if g_Game_IsNet then
3302 g_GUI_ShowWindow('GameServerMenu')
3303 else
3304 g_GUI_ShowWindow('GameCustomMenu');
3305 end;
3306 ReadGameSettings();
3307 g_GUI_ShowWindow('GameSetGameMenu');
3308 g_Sound_PlayEx('MENU_OPEN');
3309 end;
3311 procedure g_Menu_Show_OptionsVideo();
3312 begin
3313 if gGameSettings.GameType = GT_SINGLE then
3314 g_GUI_ShowWindow('GameSingleMenu')
3315 else
3316 begin
3317 if g_Game_IsClient then
3318 g_GUI_ShowWindow('GameClientMenu')
3319 else
3320 if g_Game_IsNet then
3321 g_GUI_ShowWindow('GameServerMenu')
3322 else
3323 g_GUI_ShowWindow('GameCustomMenu');
3324 end;
3325 ReadOptions();
3326 g_GUI_ShowWindow('OptionsMenu');
3327 g_GUI_ShowWindow('OptionsVideoMenu');
3328 g_Sound_PlayEx('MENU_OPEN');
3329 end;
3331 procedure g_Menu_Show_OptionsSound();
3332 begin
3333 if gGameSettings.GameType = GT_SINGLE then
3334 g_GUI_ShowWindow('GameSingleMenu')
3335 else
3336 begin
3337 if g_Game_IsClient then
3338 g_GUI_ShowWindow('GameClientMenu')
3339 else
3340 if g_Game_IsNet then
3341 g_GUI_ShowWindow('GameServerMenu')
3342 else
3343 g_GUI_ShowWindow('GameCustomMenu');
3344 end;
3345 ReadOptions();
3346 g_GUI_ShowWindow('OptionsMenu');
3347 g_GUI_ShowWindow('OptionsSoundMenu');
3348 g_Sound_PlayEx('MENU_OPEN');
3349 end;
3351 procedure g_Menu_Show_EndGameMenu();
3352 begin
3353 g_GUI_ShowWindow('EndGameMenu');
3354 g_Sound_PlayEx('MENU_OPEN');
3355 end;
3357 procedure g_Menu_Show_QuitGameMenu();
3358 begin
3359 g_GUI_ShowWindow('ExitMenu');
3360 g_Sound_PlayEx('MENU_OPEN');
3361 end;
3363 procedure g_Menu_Init();
3364 begin
3365 MenuLoadData();
3366 g_GUI_Init();
3367 CreateAllMenus();
3368 end;
3370 procedure g_Menu_Free();
3371 begin
3372 g_GUI_Destroy();
3374 e_WriteLog('Releasing menu data...', TMsgType.Notify);
3376 MenuFreeData();
3377 end;
3379 procedure g_Menu_Reset();
3380 var
3381 ex: Boolean;
3382 begin
3383 g_GUI_SaveMenuPos();
3384 ex := g_GUI_Destroy();
3386 if ex then
3387 begin
3388 e_WriteLog('Recreating menu...', TMsgType.Notify);
3390 CreateAllMenus();
3392 if gDebugMode then
3393 g_Game_SetDebugMode();
3395 g_GUI_LoadMenuPos();
3396 end;
3397 end;
3399 end.