Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
ingamemenu.c
Go to the documentation of this file.
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 = g_Game.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 (g_Game.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 g_Game.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 (g_Game.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 {
137 Mission mission = g_Game.GetMission();
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 (g_Game.IsMultiplayer() || (g_Game.GetPlayer() && g_Game.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 {
203 g_Game.CopyToClipboard(m_ServerInfoText);
204 }
205 else if (w == m_FeedbackButton)
206 {
207 OpenFeedback();
208 }
209
210 return false;
211 }
212
213 protected void OnClick_Continue()
214 {
215 g_Game.GetCallQueue(CALL_CATEGORY_GUI).Call(g_Game.GetMission().Continue);
216 }
217
218 protected void OnClick_Restart()
219 {
220 if (!g_Game.IsMultiplayer())
221 {
222 g_Game.GetCallQueue(CALL_CATEGORY_GUI).Call(g_Game.RestartMission);
223 }
224 else
225 {
227 }
228 }
229
230 protected void OnClick_Respawn()
231 {
232 Man player = g_Game.GetPlayer();
233
234 if (player && player.IsUnconscious() && !player.IsDamageDestroyed())
235 {
236 g_Game.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 (g_Game.GetMission().GetRespawnModeClient() == GameConstants.RESPAWN_MODE_CUSTOM)
241 {
242 g_Game.GetCallQueue(CALL_CATEGORY_GUI).Call(g_Game.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 {
258 g_Game.LogoutRequestTime();
259 g_Game.GetCallQueue(CALL_CATEGORY_GUI).Call(g_Game.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 (g_Game.IsMultiplayer())
268 {
269 g_Game.LogoutRequestTime();
270 g_Game.GetCallQueue(CALL_CATEGORY_GUI).Call(g_Game.GetMission().CreateLogoutMenu, this);
271 }
272 else
273 {
274 // skip logout screen in singleplayer
275 g_Game.GetMission().AbortMission();
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 && g_Game.IsMultiplayer())
285 {
286 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
288 if (player && player.IsAlive() && !player.IsUnconscious())
289 {
290 return true;
291 }
292
293 if (g_Game.GetMission().GetRespawnModeClient() == GameConstants.RESPAWN_MODE_CUSTOM)
294 {
295 g_Game.GetCallQueue(CALL_CATEGORY_GUI).Call(g_Game.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 = g_Game.GetPlayer();
321 bool playerAlive = player && player.GetPlayerState() == EPlayerStates.ALIVE;
322
323 if (g_Game.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 {
347 g_Game.GetMenuDefaultCharacterData(false).SetRandomCharacterForced(random);
348 g_Game.RespawnPlayer();
349
350 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
351 if (player)
352 {
353 player.SimulateDeath(true);
354 g_Game.GetCallQueue(CALL_CATEGORY_GUI).Call(player.ShowDeadScreen, true, 0);
355 }
356
357 MissionGameplay missionGP = MissionGameplay.Cast(g_Game.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 g_Game.OpenURL("https://feedback.bistudio.com/project/view/2/");
425 }
426
429}
void UiHintPanel(Widget parent_widget)
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
static bool GetDisableRespawnInUnconsciousness()
static int COLOR_DISABLED_TEXT
GetServersResultRow the output structure of the GetServers operation that represents one game server.
proto native int GetLastServerPort(int index)
proto native int GetLastPlayedCharacter()
proto void GetLastServerAddress(int index, out string address)
proto void GetLastServerName(int index, out string address)
Mission class.
Definition gameplay.c:686
static void GetCurrentServerInfo(string ip, int port)
Xbox menu.
Definition dayzgame.c:64
ref TextWidget m_ServerName
Definition ingamemenu.c:23
void OnClick_Exit()
Definition ingamemenu.c:256
Widget m_FeedbackButton
Definition ingamemenu.c:18
void ButtonSetText(Widget w, string text)
override void Update(float timeslice)
Definition ingamemenu.c:307
void ColorDisable(Widget w)
Definition ingamemenu.c:383
Widget m_ContinueButton
Definition ingamemenu.c:5
bool SetServerInfo()
Definition ingamemenu.c:92
void OnClick_Respawn()
Definition ingamemenu.c:230
void RespawnDialogue()
void MenuRequestRespawn(UIScriptedMenu menu, bool random)
Definition ingamemenu.c:339
string m_ServerInfoText
Definition ingamemenu.c:3
Widget m_RespawnButton
Definition ingamemenu.c:9
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Definition ingamemenu.c:155
Widget m_RestartDeadRandomButton
Definition ingamemenu.c:10
void OnClick_Continue()
Definition ingamemenu.c:213
ref UiHintPanelLoading m_HintPanel
Definition dayzgame.c:65
Widget m_RestartDeadCustomButton
Definition ingamemenu.c:11
void OnClick_Options()
Definition ingamemenu.c:251
void ButtonSetColor(Widget w, int color)
void SetGameVersion()
Definition ingamemenu.c:80
void GameRespawn(bool random)
Definition ingamemenu.c:345
Widget m_OptionsButton
Definition ingamemenu.c:12
void OpenFeedback()
Definition ingamemenu.c:422
Widget m_SeparatorPanel
Definition ingamemenu.c:6
void HudShow(bool show)
Definition ingamemenu.c:135
void ButtonSetTextColor(Widget w, int color)
ref TextWidget m_ServerIP
Definition ingamemenu.c:21
void ColorNormal(Widget w)
Widget m_ServerInfoPanel
Definition ingamemenu.c:13
Widget m_FavoriteButton
Definition ingamemenu.c:14
ref TextWidget m_ModdedWarning
Definition ingamemenu.c:20
override Widget Init()
Definition ingamemenu.c:36
ref TextWidget m_ServerPort
Definition ingamemenu.c:22
Widget m_FavoriteImage
Definition ingamemenu.c:15
override bool OnModalResult(Widget w, int x, int y, int code, int result)
Definition ingamemenu.c:262
Widget m_UnfavoriteImage
Definition ingamemenu.c:16
void OnClick_Restart()
Definition ingamemenu.c:218
Widget m_ExitButton
Definition ingamemenu.c:7
Widget m_CopyInfoButton
Definition ingamemenu.c:17
override bool OnMouseEnter(Widget w, int x, int y)
Definition ingamemenu.c:149
void SetServerInfoVisibility(bool show)
Definition ingamemenu.c:417
void ~InGameMenu()
Definition ingamemenu.c:27
Widget m_RestartButton
Definition ingamemenu.c:8
void ToggleFavoriteServer()
DEPRECATED.
void ColorHighlight(Widget w)
override bool OnClick(Widget w, int x, int y, int button)
Definition ingamemenu.c:161
DayZGame g_Game
Definition dayzgame.c:3942
Mission mission
EDayZProfilesOptions
EPlayerStates
const int DEFAULT_CHARACTER_MENU_ID
Definition constants.c:987
const int RESPAWN_MODE_CUSTOM
Definition constants.c:1050
const int MENU_RESPAWN_DIALOGUE
Definition constants.c:209
const int MENU_OPTIONS
Definition constants.c:183
const int CALL_CATEGORY_GUI
Definition tools.c:9
const int IDC_INT_EXIT
Definition constants.c:160
const int IDC_INT_RETRY
ingame menu
Definition constants.c:158
Icon x
Icon y
void Close()
int ARGB(int a, int r, int g, int b)
Definition proto.c:322