DayZ 1.28
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
InGameMenu.c
См. документацию.
1class InGameMenu extends UIScriptedMenu
2{
4
19
21 protected ref TextWidget m_ServerIP;
22 protected ref TextWidget m_ServerPort;
23 protected ref TextWidget m_ServerName;
24
25 protected ref UiHintPanel m_HintPanel;
26
28 {
29 HudShow(true);
30
31 Mission mission = g_Game.GetMission();
32 if (mission)
33 mission.Continue();
34 }
35
36 override Widget Init()
37 {
38 layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/day_z_ingamemenu.layout");
39
40 m_ContinueButton = layoutRoot.FindAnyWidget("continuebtn");
41 m_SeparatorPanel = layoutRoot.FindAnyWidget("separator_red");
42 m_ExitButton = layoutRoot.FindAnyWidget("exitbtn");
43 m_RestartButton = layoutRoot.FindAnyWidget("restartbtn");
44 m_RespawnButton = layoutRoot.FindAnyWidget("respawn_button");
45 m_RestartDeadRandomButton = layoutRoot.FindAnyWidget("respawn_button_random");
46 m_RestartDeadCustomButton = layoutRoot.FindAnyWidget("respawn_button_custom");
47 m_OptionsButton = layoutRoot.FindAnyWidget("optionsbtn");
48 m_ModdedWarning = TextWidget.Cast(layoutRoot.FindAnyWidget("ModdedWarning"));
49 m_HintPanel = new UiHintPanel(layoutRoot.FindAnyWidget("hint_frame"));
50 m_ServerInfoPanel = layoutRoot.FindAnyWidget("server_info");
51 m_ServerIP = TextWidget.Cast(layoutRoot.FindAnyWidget("server_ip"));
52 m_ServerPort = TextWidget.Cast(layoutRoot.FindAnyWidget("server_port"));
53 m_ServerName = TextWidget.Cast(layoutRoot.FindAnyWidget("server_name"));
54 m_FavoriteImage = layoutRoot.FindAnyWidget("favorite_image");
55 m_UnfavoriteImage = layoutRoot.FindAnyWidget("unfavorite_image");
56 m_CopyInfoButton = layoutRoot.FindAnyWidget("copy_button");
57 m_FeedbackButton = layoutRoot.FindAnyWidget("feedbackbtn");
58
59 if (GetGame().IsMultiplayer())
60 {
61 ButtonSetText(m_RestartButton, "#main_menu_respawn");
62 }
63 else
64 {
65 ButtonSetText(m_RestartButton, "#main_menu_restart");
66 }
67
68 HudShow(false);
70 SetServerInfoVisibility(SetServerInfo() && g_Game.GetProfileOption(EDayZProfilesOptions.SERVERINFO_DISPLAY));
71 m_ModdedWarning.Show(g_Game.ReportModded());
72
73 Mission mission = g_Game.GetMission();
74 if (mission)
75 mission.Pause();
76
77 return layoutRoot;
78 }
79
80 protected void SetGameVersion()
81 {
82 TextWidget version_widget = TextWidget.Cast(layoutRoot.FindAnyWidget("version"));
83 string version;
84 GetGame().GetVersion(version);
85 version_widget.SetText("#main_menu_version" + " " + version);
86
87 #ifdef PREVIEW_BUILD
88 version_widget.SetText("THIS IS PREVIEW");
89 #endif
90 }
91
92 protected bool SetServerInfo()
93 {
94 if (GetGame().IsMultiplayer())
95 {
96 MenuData menu_data = g_Game.GetMenuData();
98
99 if (info)
100 {
101 m_ServerPort.SetText(info.m_HostPort.ToString());
102 m_ServerIP.SetText(info.m_HostIp);
103 m_ServerName.SetText(info.m_Name);
104 m_UnfavoriteImage.Show(info.m_Favorite);
105 m_FavoriteImage.Show(!info.m_Favorite);
106 m_ServerInfoText = "" + info.GetIpPort();
107
108 return true;
109 }
110 //temporary, incomplete solution, OnlineServices.GetCurrentServerInfo() should be working!
111 else if (menu_data && menu_data.GetLastPlayedCharacter() != GameConstants.DEFAULT_CHARACTER_MENU_ID)
112 {
113 int char_id = menu_data.GetLastPlayedCharacter();
114 int port;
115 string address,name;
116
117 menu_data.GetLastServerAddress(char_id,address);
118 port = menu_data.GetLastServerPort(char_id);
119 menu_data.GetLastServerName(char_id,name);
120 m_ServerPort.SetText(port.ToString());
121 m_ServerIP.SetText(address);
122 m_ServerName.SetText(name);
123 m_ServerInfoText = "" + address + ":" + port;
124
125 return true;
126 }
127 else
128 {
129 g_Game.RefreshCurrentServerInfo();
130 }
131 }
132 return false;
133 }
134
135 protected void HudShow(bool show)
136 {
138 if (mission)
139 {
140 IngameHud hud = IngameHud.Cast(mission.GetHud());
141 if (hud)
142 {
143 hud.ShowHudUI(g_Game.GetProfileOption(EDayZProfilesOptions.HUD) && show);
144 hud.ShowQuickbarUI(g_Game.GetProfileOption(EDayZProfilesOptions.QUICKBAR) && show);
145 }
146 }
147 }
148
149 override bool OnMouseEnter(Widget w, int x, int y)
150 {
152 return true;
153 }
154
155 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
156 {
157 ColorNormal(w);
158 return true;
159 }
160
161 override bool OnClick(Widget w, int x, int y, int button)
162 {
163 super.OnClick(w, x, y, button);
164
165 if (w == m_ContinueButton)
166 {
168 return true;
169 }
170 else if (w == m_RestartButton)
171 {
172 #ifdef DEVELOPER
173 if (GetGame().IsMultiplayer() || (GetGame().GetPlayer() && GetGame().GetPlayer().IsUnconscious()))
175 else
176 {
177 PluginDeveloper plugin = PluginDeveloper.GetInstance();
178 if (plugin)
179 plugin.ToggleMissionLoader();
180 }
181 #else
183 #endif
184 return true;
185 }
186 else if (w == m_RespawnButton)
187 {
189 return true;
190 }
191 else if (w == m_OptionsButton)
192 {
194 return true;
195 }
196 else if (w == m_ExitButton)
197 {
198 OnClick_Exit();
199 return true;
200 }
201 else if (w == m_CopyInfoButton)
202 {
204 }
205 else if (w == m_FeedbackButton)
206 {
207 OpenFeedback();
208 }
209
210 return false;
211 }
212
213 protected void OnClick_Continue()
214 {
216 }
217
218 protected void OnClick_Restart()
219 {
220 if (!GetGame().IsMultiplayer())
221 {
223 }
224 else
225 {
227 }
228 }
229
230 protected void OnClick_Respawn()
231 {
232 Man player = GetGame().GetPlayer();
233
234 if (player && player.IsUnconscious() && !player.IsDamageDestroyed())
235 {
236 GetGame().GetUIManager().ShowDialog("#main_menu_respawn", "#main_menu_respawn_question", IDC_INT_RETRY, DBT_YESNO, DBB_YES, DMT_QUESTION, this);
237 }
238 else
239 {
240 if (GetGame().GetMission().GetRespawnModeClient() == GameConstants.RESPAWN_MODE_CUSTOM)
241 {
242 GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(GetGame().GetUIManager().EnterScriptedMenu,MENU_RESPAWN_DIALOGUE,this);
243 }
244 else
245 {
246 GameRespawn(true);
247 }
248 }
249 }
250
251 protected void OnClick_Options()
252 {
253 EnterScriptedMenu(MENU_OPTIONS);
254 }
255
256 protected void OnClick_Exit()
257 {
259 GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(GetGame().GetMission().CreateLogoutMenu, this);
260 }
261
262 override bool OnModalResult(Widget w, int x, int y, int code, int result)
263 {
264 super.OnModalResult(w, x, y, code, result);
265 if (code == IDC_INT_EXIT && result == DBB_YES)
266 {
267 if (GetGame().IsMultiplayer())
268 {
270 GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(GetGame().GetMission().CreateLogoutMenu, this);
271 }
272 else
273 {
274 // skip logout screen in singleplayer
276 }
277 g_Game.CancelLoginTimeCountdown();
278 return true;
279 }
280 else if (code == IDC_INT_EXIT && result == DBB_NO)
281 {
282 g_Game.CancelLoginTimeCountdown();
283 }
284 else if (code == IDC_INT_RETRY && result == DBB_YES && GetGame().IsMultiplayer())
285 {
286 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
288 if (player && player.IsAlive() && !player.IsUnconscious())
289 {
290 return true;
291 }
292
293 if (GetGame().GetMission().GetRespawnModeClient() == GameConstants.RESPAWN_MODE_CUSTOM)
294 {
295 GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(GetGame().GetUIManager().EnterScriptedMenu,MENU_RESPAWN_DIALOGUE,this);
296 }
297 else
298 {
299 GameRespawn(true);
300 }
301 return true;
302 }
303
304 return false;
305 }
306
307 override void Update(float timeslice)
308 {
309 super.Update(timeslice);
310
311 UpdateGUI();
312 }
313
314 protected void UpdateGUI()
315 {
316 #ifdef BULDOZER
317 m_RestartButton.Show(false);
318 m_RespawnButton.Show(false);
319 #else
320 Man player = GetGame().GetPlayer();
321 bool playerAlive = player && player.GetPlayerState() == EPlayerStates.ALIVE;
322
323 if (GetGame().IsMultiplayer())
324 {
325 m_RestartButton.Show(playerAlive && player.IsUnconscious() && !CfgGameplayHandler.GetDisableRespawnInUnconsciousness());
326 m_RespawnButton.Show(!playerAlive);
327 }
328 else
329 {
330 m_RestartButton.Show(true);
331 m_RespawnButton.Show(false);
332 m_SeparatorPanel.Show(playerAlive);
333 }
334
335 m_ContinueButton.Show(playerAlive);
336 #endif
337 }
338
339 void MenuRequestRespawn(UIScriptedMenu menu, bool random)
340 {
341 if (RespawnDialogue.Cast(menu))
342 GameRespawn(random);
343 }
344
345 protected void GameRespawn(bool random)
346 {
349
350 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
351 if (player)
352 {
353 player.SimulateDeath(true);
354 GetGame().GetCallQueue(CALL_CATEGORY_GUI).Call(player.ShowDeadScreen, true, 0);
355 }
356
357 MissionGameplay missionGP = MissionGameplay.Cast(GetGame().GetMission());
358 missionGP.DestroyAllMenus();
359 missionGP.SetPlayerRespawning(true);
360 missionGP.Continue();
361
362 Close();
363 }
364
365 protected void ColorHighlight(Widget w)
366 {
367 if (!w)
368 return;
369
370 ButtonSetColor(w, ARGB(255, 0, 0, 0));
371 ButtonSetTextColor(w, ARGB(255, 255, 0, 0));
372 }
373
374 protected void ColorNormal(Widget w)
375 {
376 if (!w)
377 return;
378
379 ButtonSetColor(w, ARGB(0, 0, 0, 0));
380 ButtonSetTextColor(w, ARGB(255, 255, 255, 255));
381 }
382
383 protected void ColorDisable(Widget w)
384 {
385 if (!w)
386 return;
387
388 ButtonSetColor(w, ARGB(0, 0, 0, 0));
390 }
391
392 protected void ButtonSetText(Widget w, string text)
393 {
394 if (!w)
395 return;
396
397 TextWidget label = TextWidget.Cast(w.FindWidget(w.GetName() + "_label"));
398 if (label)
399 label.SetText(text);
400
401 }
402
403 protected void ButtonSetColor(Widget w, int color)
404 {
405 Widget panel = w.FindWidget(w.GetName() + "_panel");
406 if (panel)
407 panel.SetColor(color);
408 }
409
410 protected void ButtonSetTextColor(Widget w, int color)
411 {
412 TextWidget label = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_label"));
413 if (label)
414 label.SetColor(color);
415 }
416
418 {
419 m_ServerInfoPanel.Show(show);
420 }
421
422 protected void OpenFeedback()
423 {
424 GetGame().OpenURL("https://feedback.bistudio.com/project/view/2/");
425 }
426
429}
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
DayZGame g_Game
Определения DayZGame.c:3868
Mission mission
Определения DisplayStatus.c:28
EDayZProfilesOptions
Определения EDayZProfilesOptions.c:2
EPlayerStates
Определения EPlayerStates.c:2
Icon x
Icon y
void Close()
PlayerBase GetPlayer()
Определения ModifierBase.c:51
void UiHintPanel(Widget parent_widget)
Определения UiHintPanel.c:324
proto native UIManager GetUIManager()
proto native void CopyToClipboard(string text)
override ScriptCallQueue GetCallQueue(int call_category)
Определения DayZGame.c:1187
proto native void LogoutRequestTime()
Logout methods.
proto native DayZPlayer GetPlayer()
proto native WorkspaceWidget GetWorkspace()
proto native void RespawnPlayer()
proto void GetVersion(out string version)
proto native void OpenURL(string url)
proto native Mission GetMission()
MenuDefaultCharacterData GetMenuDefaultCharacterData(bool fill_data=true)
Определения Global/game.c:1548
static bool GetDisableRespawnInUnconsciousness()
Определения CfgGameplayHandler.c:178
static int COLOR_DISABLED_TEXT
Определения ColorManager.c:11
Определения ColorManager.c:2
string GetIpPort()
Определения BiosLobbyService.c:195
string m_Name
Определения BiosLobbyService.c:147
bool m_Favorite
Определения BiosLobbyService.c:193
int m_HostPort
Определения BiosLobbyService.c:150
string m_HostIp
Определения BiosLobbyService.c:149
GetServersResultRow the output structure of the GetServers operation that represents one game server.
Определения BiosLobbyService.c:144
proto native int GetLastPlayedCharacter()
proto native int GetLastServerPort(int index)
proto void GetLastServerAddress(int index, out string address)
proto void GetLastServerName(int index, out string address)
Определения gameplay.c:918
void SetRandomCharacterForced(bool state)
Определения gameplay.c:1115
void AbortMission()
Определения gameplay.c:776
Mission class.
Определения gameplay.c:687
static void GetCurrentServerInfo(string ip, int port)
Определения OnlineServices.c:139
Определения OnlineServices.c:2
Определения PlayerBaseClient.c:2
proto void Call(func fn, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
Определения EnWidgets.c:220
proto native void ShowDialog(string caption, string text, int id, int butts, int def, int type, UIScriptedMenu handler)
Shows message dialog.
void MenuRequestRespawn(UIScriptedMenu menu, bool random)
Определения InGameMenu.c:339
override bool OnMouseEnter(Widget w, int x, int y)
Определения InGameMenu.c:149
Widget m_ExitButton
Определения InGameMenu.c:7
ref TextWidget m_ServerIP
Определения InGameMenu.c:21
void ToggleFavoriteServer()
DEPRECATED.
void ColorDisable(Widget w)
Определения InGameMenu.c:383
void OnClick_Restart()
Определения InGameMenu.c:218
bool SetServerInfo()
Определения InGameMenu.c:92
void SetServerInfoVisibility(bool show)
Определения InGameMenu.c:417
override void Update(float timeslice)
Определения InGameMenu.c:307
Widget m_RespawnButton
Определения InGameMenu.c:9
Widget m_ContinueButton
Определения InGameMenu.c:5
void ColorHighlight(Widget w)
Определения ControlsXboxNew.c:446
Widget m_FavoriteImage
Определения InGameMenu.c:15
Widget m_SeparatorPanel
Определения InGameMenu.c:6
void OnClick_Exit()
Определения InGameMenu.c:256
Widget m_RestartButton
Определения InGameMenu.c:8
void ButtonSetText(Widget w, string text)
Определения ControlsXboxNew.c:475
ref TextWidget m_ServerPort
Определения InGameMenu.c:22
Widget m_RestartDeadCustomButton
Определения InGameMenu.c:11
void SetGameVersion()
Определения InGameMenu.c:80
ref TextWidget m_ModdedWarning
Определения InGameMenu.c:20
Widget m_OptionsButton
Определения InGameMenu.c:12
ref TextWidget m_ServerName
Определения InGameMenu.c:23
void ~InGameMenu()
Определения InGameMenu.c:27
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Определения InGameMenu.c:155
void GameRespawn(bool random)
Определения InGameMenu.c:345
Widget m_ServerInfoPanel
Определения InGameMenu.c:13
void UpdateGUI()
Определения InGameMenu.c:314
Widget m_FeedbackButton
Определения InGameMenu.c:18
void OnClick_Continue()
Определения InGameMenu.c:213
ref UiHintPanelLoading m_HintPanel
Определения DayZGame.c:65
string m_ServerInfoText
Определения InGameMenu.c:3
Widget m_UnfavoriteImage
Определения InGameMenu.c:16
Widget m_FavoriteButton
Определения InGameMenu.c:14
void RespawnDialogue()
void ButtonSetTextColor(Widget w, int color)
Определения ControlsXboxNew.c:502
override Widget Init()
Определения InGameMenu.c:36
void OpenFeedback()
Определения InGameMenu.c:422
override bool OnClick(Widget w, int x, int y, int button)
Определения InGameMenu.c:161
void ButtonSetColor(Widget w, int color)
Определения ControlsXboxNew.c:489
void HudShow(bool show)
Определения InGameMenu.c:135
override bool OnModalResult(Widget w, int x, int y, int code, int result)
Определения InGameMenu.c:262
void OnClick_Respawn()
Определения InGameMenu.c:230
void ColorNormal(Widget w)
Определения ControlsXboxNew.c:463
Widget m_RestartDeadRandomButton
Определения InGameMenu.c:10
Widget m_CopyInfoButton
Определения InGameMenu.c:17
void OnClick_Options()
Определения InGameMenu.c:251
Определения DayZGame.c:64
Определения EnWidgets.c:190
proto native CGame GetGame()
const int DEFAULT_CHARACTER_MENU_ID
Определения 3_Game/constants.c:984
const int RESPAWN_MODE_CUSTOM
Определения 3_Game/constants.c:1047
const int MENU_RESPAWN_DIALOGUE
Определения 3_Game/constants.c:209
const int MENU_OPTIONS
Определения 3_Game/constants.c:183
void Continue()
Timer continue when it was paused.
Определения 3_Game/tools/tools.c:247
const int CALL_CATEGORY_GUI
Определения 3_Game/tools/tools.c:9
const int IDC_INT_EXIT
Определения 3_Game/constants.c:160
const int IDC_INT_RETRY
ingame menu
Определения 3_Game/constants.c:158
proto native external Widget CreateWidgets(string layout, Widget parentWidget=NULL, bool immedUpdate=true)
Create widgets from *.layout file.
int ARGB(int a, int r, int g, int b)
Определения proto.c:322