Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
respawndialogue.c
Go to the documentation of this file.
1
class
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
;
8
protected
TextWidget
m_DetailsLabel
;
9
protected
RichTextWidget
m_DetailsText
;
10
11
protected
Widget
m_CustomRespawn
;
12
13
//helper
14
protected
Widget
m_CurrentlyHighlighted
;
15
16
void
RespawnDialogue
();
17
void
~RespawnDialogue
();
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"
);
27
SetFocus
(
m_CustomRespawn
);
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
58
case
ID_RESPAWN_CUSTOM
:
59
return
RequestRespawn
(
false
);
60
61
case
ID_RESPAWN_RANDOM
:
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 =
""
;
72
ColorHighlight
(w);
73
switch
(w.GetUserID())
74
{
75
case
ID_RESPAWN_RANDOM
:
76
tooltip_header =
"#main_menu_respawn_random"
;
77
tooltip_text =
"#main_menu_respawn_random_tooltip"
;
78
break
;
79
80
case
ID_RESPAWN_CUSTOM
:
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
100
SetFocus
(
m_CustomRespawn
);
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
{
109
ColorHighlight
(w);
110
switch
(w.GetUserID())
111
{
112
case
ID_RESPAWN_RANDOM
:
113
tooltip_header =
"#main_menu_respawn_random"
;
114
tooltip_text =
"#main_menu_respawn_random_tooltip"
;
115
break
;
116
117
case
ID_RESPAWN_CUSTOM
:
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
142
bool
IsFocusable
(
Widget
w)
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
{
160
if
(
m_CurrentlyHighlighted
)
161
ColorNormal
(
m_CurrentlyHighlighted
);
162
163
m_CurrentlyHighlighted
= w;
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
}
RichTextWidget
Definition
gameplay.c:317
TextWidget
Definition
enwidgets.c:220
UIScriptedMenu
Xbox menu.
Definition
dayzgame.c:64
UIScriptedMenu::~RespawnDialogue
void ~RespawnDialogue()
UIScriptedMenu::Update
override void Update(float timeslice)
Definition
respawndialogue.c:32
UIScriptedMenu::m_CustomRespawn
Widget m_CustomRespawn
Definition
respawndialogue.c:11
UIScriptedMenu::m_DetailsLabel
TextWidget m_DetailsLabel
Definition
charactercreationmenu.c:21
UIScriptedMenu::m_CurrentlyHighlighted
Widget m_CurrentlyHighlighted
Definition
respawndialogue.c:14
UIScriptedMenu::RespawnDialogue
void RespawnDialogue()
UIScriptedMenu::ID_RESPAWN_CUSTOM
const int ID_RESPAWN_CUSTOM
Definition
respawndialogue.c:3
UIScriptedMenu::ID_RESPAWN_RANDOM
const int ID_RESPAWN_RANDOM
Definition
respawndialogue.c:4
UIScriptedMenu::SetTooltipTexts
void SetTooltipTexts(Widget w, string header="", string desc="")
Definition
charactercreationmenu.c:453
UIScriptedMenu::OnShow
override void OnShow()
Definition
respawndialogue.c:96
UIScriptedMenu::OnMouseLeave
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
Definition
respawndialogue.c:90
UIScriptedMenu::ButtonSetColor
void ButtonSetColor(Widget w, int color)
Definition
controlsxboxnew.c:497
UIScriptedMenu::InGameMenuXbox
void InGameMenuXbox()
Definition
ingamemenuxbox.c:48
UIScriptedMenu::ButtonSetTextColor
void ButtonSetTextColor(Widget w, int color)
Definition
controlsxboxnew.c:510
UIScriptedMenu::ColorNormal
void ColorNormal(Widget w)
Definition
controlsxboxnew.c:471
UIScriptedMenu::m_DetailsText
RichTextWidget m_DetailsText
Definition
charactercreationmenu.c:22
UIScriptedMenu::Init
override Widget Init()
Definition
respawndialogue.c:19
UIScriptedMenu::RequestRespawn
bool RequestRespawn(bool random)
Definition
respawndialogue.c:205
UIScriptedMenu::OnFocusLost
override bool OnFocusLost(Widget w, int x, int y)
Definition
respawndialogue.c:131
UIScriptedMenu::IsFocusable
bool IsFocusable(Widget w)
Definition
cameratoolsmenu.c:960
UIScriptedMenu::OnMouseEnter
override bool OnMouseEnter(Widget w, int x, int y)
Definition
respawndialogue.c:68
UIScriptedMenu::m_DetailsRoot
Widget m_DetailsRoot
Definition
charactercreationmenu.c:20
UIScriptedMenu::ColorHighlight
void ColorHighlight(Widget w)
Definition
controlsxboxnew.c:454
UIScriptedMenu::OnFocus
override bool OnFocus(Widget w, int x, int y)
Definition
respawndialogue.c:103
UIScriptedMenu::OnClick
override bool OnClick(Widget w, int x, int y, int button)
Definition
respawndialogue.c:48
Widget
Definition
enwidgets.c:190
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
EPlayerStates
EPlayerStates
Definition
eplayerstates.c:2
MENU_INGAME
const int MENU_INGAME
Definition
constants.c:178
IDC_CANCEL
const int IDC_CANCEL
Definition
constants.c:136
SetFocus
proto native void SetFocus(Widget w)
x
Icon x
y
Icon y
Close
void Close()
ARGB
int ARGB(int a, int r, int g, int b)
Definition
proto.c:322
GetUApi
proto native UAInputAPI GetUApi()
Games
Dayz
scripts
5_mission
gui
respawndialogue.c
Generated by
1.17.0