DayZ 1.24
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 = GetGame().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");
27 SetFocus(m_CustomRespawn);
28
29 return layoutRoot;
30 }
31
32 override void Update(float timeslice)
33 {
34 super.Update(timeslice);
35
36 if (GetUApi().GetInputByID(UAUIBack).LocalPress() || GetUApi().GetInputByID(UAUIMenu).LocalPress())
37 Close();
38 }
39
40 override bool OnClick(Widget w, int x, int y, int button)
41 {
42 super.OnClick(w, x, y, button);
43
44 switch (w.GetUserID())
45 {
46 case IDC_CANCEL:
47 Close();
48 return true;
49
51 return RequestRespawn(false);
52
54 return RequestRespawn(true);
55 }
56
57 return false;
58 }
59
60 override bool OnMouseEnter(Widget w, int x, int y)
61 {
62 string tooltip_header = "";
63 string tooltip_text = "";
65 switch (w.GetUserID())
66 {
68 tooltip_header = "#main_menu_respawn_random";
69 tooltip_text = "#main_menu_respawn_random_tooltip";
70 break;
71
73 tooltip_header = "#main_menu_respawn_custom";
74 tooltip_text = "#main_menu_respawn_custom_tooltip";
75 break;
76 }
77
79 return true;
80 }
81
82 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
83 {
85 return true;
86 }
87
88 override void OnShow()
89 {
90 super.OnShow();
91
92 SetFocus(m_CustomRespawn);
93 }
94
95 override bool OnFocus(Widget w, int x, int y)
96 {
97 string tooltip_header = "";
98 string tooltip_text = "";
99 if (IsFocusable(w))
100 {
102 switch (w.GetUserID())
103 {
105 tooltip_header = "#main_menu_respawn_random";
106 tooltip_text = "#main_menu_respawn_random_tooltip";
107 break;
108
110 tooltip_header = "#main_menu_respawn_custom";
111 tooltip_text = "#main_menu_respawn_custom_tooltip";
112 break;
113 }
114
116 return true;
117 }
118
120 return false;
121 }
122
123 override bool OnFocusLost(Widget w, int x, int y)
124 {
125 if (IsFocusable(w))
126 {
127 ColorNormal(w);
128 return true;
129 }
130
131 return false;
132 }
133
135 {
136 if (w)
137 {
138 if (w.GetUserID() == IDC_CANCEL || w.GetUserID() == ID_RESPAWN_CUSTOM || w.GetUserID() == ID_RESPAWN_RANDOM);
139 return true;
140 }
141
142 return false;
143 }
144
145 protected void ColorHighlight(Widget w)
146 {
147 if (!w)
148 return;
149
150 if (m_CurrentlyHighlighted != w)
151 {
152 if (m_CurrentlyHighlighted)
153 ColorNormal(m_CurrentlyHighlighted);
154
155 m_CurrentlyHighlighted = w;
156 }
157
158 ButtonSetColor(w, ARGB(255, 0, 0, 0));
159 ButtonSetTextColor(w, ARGB(255, 255, 0, 0));
160 }
161
162 protected void ColorNormal(Widget w)
163 {
164 if (!w)
165 return;
166
167 ButtonSetColor(w, ARGB(0, 0, 0, 0));
168 ButtonSetTextColor(w, ARGB(255, 255, 255, 255));
169 }
170
171 protected void ButtonSetColor(Widget w, int color)
172 {
173 Widget panel = w.FindWidget(w.GetName() + "_panel");
174 if (panel)
175 panel.SetColor(color);
176 }
177
178 protected void ButtonSetTextColor(Widget w, int color)
179 {
180 TextWidget label = TextWidget.Cast(w.FindAnyWidget(w.GetName() + "_label"));
181 if (label)
182 label.SetColor(color);
183 }
184
185 void SetTooltipTexts(Widget w, string header = "", string desc = "")
186 {
187 bool show = header != "" && desc != "";
188 m_DetailsRoot.Show(show);
189 m_DetailsLabel.SetText(header);
190 m_DetailsText.SetText(desc);
191
192 m_DetailsText.Update();
193 m_DetailsLabel.Update();
194 m_DetailsRoot.Update();
195 }
196
198 {
199 IngameHud.Cast(GetGame().GetMission().GetHud()).InitBadgesAndNotifiers();
200 Man player = GetGame().GetPlayer();
201 if (player && (player.GetPlayerState() == EPlayerStates.ALIVE && !player.IsUnconscious()))
202 return false;
203
204#ifdef PLATFORM_CONSOLE
205 InGameMenuXbox menu_ingame = InGameMenuXbox.Cast(GetGame().GetUIManager().FindMenu(MENU_INGAME));
206#else
207 InGameMenu menu_ingame = InGameMenu.Cast(GetGame().GetUIManager().FindMenu(MENU_INGAME));
208#endif
209
210 if (!menu_ingame)
211 return false;
212
213 menu_ingame.MenuRequestRespawn(this, random);
214 return true;
215 }
216}
EPlayerStates
Icon x
Icon y
void Close()
proto native UAInputAPI GetUApi()
void ~RespawnDialogue()
RichTextWidget m_DetailsText
bool RequestRespawn(bool random)
override bool OnMouseEnter(Widget w, int x, int y)
override void OnShow()
override bool OnFocus(Widget w, int x, int y)
override void Update(float timeslice)
const int ID_RESPAWN_CUSTOM
void ColorHighlight(Widget w)
bool IsFocusable(Widget w)
void SetTooltipTexts(Widget w, string header="", string desc="")
const int ID_RESPAWN_RANDOM
override bool OnFocusLost(Widget w, int x, int y)
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Widget m_CurrentlyHighlighted
void RespawnDialogue()
void ButtonSetTextColor(Widget w, int color)
override Widget Init()
override bool OnClick(Widget w, int x, int y, int button)
void ButtonSetColor(Widget w, int color)
void ColorNormal(Widget w)
proto native CGame GetGame()
const int MENU_INGAME
Definition constants.c:168
const int IDC_CANCEL
Definition constants.c:128
proto native void SetFocus(Widget w)
int ARGB(int a, int r, int g, int b)
Definition proto.c:322