Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
respawndialogue.c
Go to the documentation of this file.
1class RespawnDialogue extends UIScriptedMenu
2{
3 const int ID_RESPAWN_CUSTOM = 101;
4 const int ID_RESPAWN_RANDOM = 102;
5
6 //tooltips
7 protected Widget m_DetailsRoot;
10
12
13 //helper
15
18
19 override Widget Init()
20 {
21 layoutRoot = g_Game.GetWorkspace().CreateWidgets("gui/layouts/day_z_respawn_dialogue.layout");
22 m_DetailsRoot = layoutRoot.FindAnyWidget("menu_details_tooltip");
23 m_DetailsLabel = TextWidget.Cast(m_DetailsRoot.FindAnyWidget("menu_details_label"));
24 m_DetailsText = RichTextWidget.Cast(m_DetailsRoot.FindAnyWidget("menu_details_tooltip_content"));
25
26 m_CustomRespawn = layoutRoot.FindAnyWidget("respawn_button_custom");
28
29 return layoutRoot;
30 }
31
32 override void Update(float timeslice)
33 {
34 super.Update(timeslice);
35
36 Man player = g_Game.GetPlayer();
37 bool playerAlive = player && player.GetPlayerState() == EPlayerStates.ALIVE;
38 if (playerAlive && !player.IsUnconscious())
39 {
40 Close();
41 return;
42 }
43
44 if (GetUApi().GetInputByID(UAUIBack).LocalPress() || GetUApi().GetInputByID(UAUIMenu).LocalPress())
45 Close();
46 }
47
48 override bool OnClick(Widget w, int x, int y, int button)
49 {
50 super.OnClick(w, x, y, button);
51
52 switch (w.GetUserID())
53 {
54 case IDC_CANCEL:
55 Close();
56 return true;
57
59 return RequestRespawn(false);
60
62 return RequestRespawn(true);
63 }
64
65 return false;
66 }
67
68 override bool OnMouseEnter(Widget w, int x, int y)
69 {
70 string tooltip_header = "";
71 string tooltip_text = "";
73 switch (w.GetUserID())
74 {
76 tooltip_header = "#main_menu_respawn_random";
77 tooltip_text = "#main_menu_respawn_random_tooltip";
78 break;
79
81 tooltip_header = "#main_menu_respawn_custom";
82 tooltip_text = "#main_menu_respawn_custom_tooltip";
83 break;
84 }
85
86 SetTooltipTexts(w, tooltip_header, tooltip_text);
87 return true;
88 }
89
90 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
91 {
92 ColorNormal(w);
93 return true;
94 }
95
96 override void OnShow()
97 {
98 super.OnShow();
99
101 }
102
103 override bool OnFocus(Widget w, int x, int y)
104 {
105 string tooltip_header = "";
106 string tooltip_text = "";
107 if (IsFocusable(w))
108 {
110 switch (w.GetUserID())
111 {
113 tooltip_header = "#main_menu_respawn_random";
114 tooltip_text = "#main_menu_respawn_random_tooltip";
115 break;
116
118 tooltip_header = "#main_menu_respawn_custom";
119 tooltip_text = "#main_menu_respawn_custom_tooltip";
120 break;
121 }
122
123 SetTooltipTexts(w, tooltip_header, tooltip_text);
124 return true;
125 }
126
127 SetTooltipTexts(w, tooltip_header, tooltip_text);
128 return false;
129 }
130
131 override bool OnFocusLost(Widget w, int x, int y)
132 {
133 if (IsFocusable(w))
134 {
135 ColorNormal(w);
136 return true;
137 }
138
139 return false;
140 }
141
143 {
144 if (w)
145 {
146 if (w.GetUserID() == IDC_CANCEL || w.GetUserID() == ID_RESPAWN_CUSTOM || w.GetUserID() == ID_RESPAWN_RANDOM)
147 return true;
148 }
149
150 return false;
151 }
152
153 protected void ColorHighlight(Widget w)
154 {
155 if (!w)
156 return;
157
158 if (m_CurrentlyHighlighted != w)
159 {
162
164 }
165
166 ButtonSetColor(w, ARGB(255, 0, 0, 0));
167 ButtonSetTextColor(w, ARGB(255, 255, 0, 0));
168 }
169
170 protected void ColorNormal(Widget w)
171 {
172 if (!w)
173 return;
174
175 ButtonSetColor(w, ARGB(0, 0, 0, 0));
176 ButtonSetTextColor(w, ARGB(255, 255, 255, 255));
177 }
178
179 protected void ButtonSetColor(Widget w, int color)
180 {
181 Widget panel = w.FindWidget(w.GetName() + "_panel");
182 if (panel)
183 panel.SetColor(color);
184 }
185
186 protected void ButtonSetTextColor(Widget w, int color)
187 {
188 TextWidget label = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_label"));
189 if (label)
190 label.SetColor(color);
191 }
192
193 void SetTooltipTexts(Widget w, string header = "", string desc = "")
194 {
195 bool show = header != "" && desc != "";
196 m_DetailsRoot.Show(show);
197 m_DetailsLabel.SetText(header);
198 m_DetailsText.SetText(desc);
199
200 m_DetailsText.Update();
201 m_DetailsLabel.Update();
202 m_DetailsRoot.Update();
203 }
204
205 bool RequestRespawn(bool random)
206 {
207 IngameHud.Cast(g_Game.GetMission().GetHud()).InitBadgesAndNotifiers();
208 Man player = g_Game.GetPlayer();
209 if (player && (player.GetPlayerState() == EPlayerStates.ALIVE && !player.IsUnconscious()))
210 return false;
211
212 #ifdef PLATFORM_CONSOLE
213 InGameMenuXbox menu_ingame = InGameMenuXbox.Cast(g_Game.GetUIManager().FindMenu(MENU_INGAME));
214 #else
215 InGameMenu menu_ingame = InGameMenu.Cast(g_Game.GetUIManager().FindMenu(MENU_INGAME));
216 #endif
217
218 if (!menu_ingame)
219 return false;
220
221 menu_ingame.MenuRequestRespawn(this, random);
222 return true;
223 }
224}
Xbox menu.
Definition dayzgame.c:64
void ~RespawnDialogue()
override void Update(float timeslice)
Widget m_CurrentlyHighlighted
void RespawnDialogue()
const int ID_RESPAWN_CUSTOM
const int ID_RESPAWN_RANDOM
void SetTooltipTexts(Widget w, string header="", string desc="")
override void OnShow()
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
void ButtonSetColor(Widget w, int color)
void ButtonSetTextColor(Widget w, int color)
void ColorNormal(Widget w)
RichTextWidget m_DetailsText
override Widget Init()
bool RequestRespawn(bool random)
override bool OnFocusLost(Widget w, int x, int y)
bool IsFocusable(Widget w)
override bool OnMouseEnter(Widget w, int x, int y)
void ColorHighlight(Widget w)
override bool OnFocus(Widget w, int x, int y)
override bool OnClick(Widget w, int x, int y, int button)
DayZGame g_Game
Definition dayzgame.c:3942
EPlayerStates
const int MENU_INGAME
Definition constants.c:178
const int IDC_CANCEL
Definition constants.c:136
proto native void SetFocus(Widget w)
Icon x
Icon y
void Close()
int ARGB(int a, int r, int g, int b)
Definition proto.c:322
proto native UAInputAPI GetUApi()