DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
RespawnDialogue.c
См. документацию.
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");
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
78 SetTooltipTexts(w, tooltip_header, tooltip_text);
79 return true;
80 }
81
82 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
83 {
84 ColorNormal(w);
85 return true;
86 }
87
88 override void OnShow()
89 {
90 super.OnShow();
91
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
115 SetTooltipTexts(w, tooltip_header, tooltip_text);
116 return true;
117 }
118
119 SetTooltipTexts(w, tooltip_header, tooltip_text);
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 {
154
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
197 bool RequestRespawn(bool random)
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
Определения EPlayerStates.c:2
Icon x
Icon y
void Close()
proto native UAInputAPI GetUApi()
proto native DayZPlayer GetPlayer()
proto native WorkspaceWidget GetWorkspace()
Определения gameplay.c:317
Определения EnWidgets.c:220
void ~RespawnDialogue()
RichTextWidget m_DetailsText
Определения CharacterCreationMenu.c:22
bool RequestRespawn(bool random)
Определения RespawnDialogue.c:197
override bool OnMouseEnter(Widget w, int x, int y)
Определения RespawnDialogue.c:60
override void OnShow()
Определения RespawnDialogue.c:88
override bool OnFocus(Widget w, int x, int y)
Определения RespawnDialogue.c:95
override void Update(float timeslice)
Определения RespawnDialogue.c:32
TextWidget m_DetailsLabel
Определения CharacterCreationMenu.c:21
const int ID_RESPAWN_CUSTOM
Определения RespawnDialogue.c:3
void ColorHighlight(Widget w)
Определения ControlsXboxNew.c:446
bool IsFocusable(Widget w)
Определения CameraToolsMenu.c:960
void SetTooltipTexts(Widget w, string header="", string desc="")
Определения CharacterCreationMenu.c:435
const int ID_RESPAWN_RANDOM
Определения RespawnDialogue.c:4
Widget m_CustomRespawn
Определения RespawnDialogue.c:11
override bool OnFocusLost(Widget w, int x, int y)
Определения RespawnDialogue.c:123
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Определения RespawnDialogue.c:82
Widget m_CurrentlyHighlighted
Определения RespawnDialogue.c:14
void InGameMenuXbox()
Определения InGameMenuXbox.c:43
void RespawnDialogue()
void ButtonSetTextColor(Widget w, int color)
Определения ControlsXboxNew.c:502
override Widget Init()
Определения RespawnDialogue.c:19
override bool OnClick(Widget w, int x, int y, int button)
Определения RespawnDialogue.c:40
Widget m_DetailsRoot
Определения CharacterCreationMenu.c:20
void ButtonSetColor(Widget w, int color)
Определения ControlsXboxNew.c:489
void ColorNormal(Widget w)
Определения ControlsXboxNew.c:463
Определения DayZGame.c:64
Определения EnWidgets.c:190
proto native CGame GetGame()
const int MENU_INGAME
Определения constants.c:178
const int IDC_CANCEL
Определения constants.c:136
proto native external Widget CreateWidgets(string layout, Widget parentWidget=NULL, bool immedUpdate=true)
Create widgets from *.layout file.
proto native void SetFocus(Widget w)
int ARGB(int a, int r, int g, int b)
Определения proto.c:322