Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
invitemenu.c
Go to the documentation of this file.
1
class
InviteMenu
extends
UIScriptedMenu
2
{
3
private
TextWidget
m_LogoutTimeText
;
4
private
MultilineTextWidget
m_DescriptionText
;
5
private
ButtonWidget
m_bCancel
;
6
private
ButtonWidget
m_bCancelConsole
;
7
private
int
m_iTime
;
8
9
private
ref
FullTimeData
m_FullTime
;
10
11
void
InviteMenu
()
12
{
13
m_iTime
= 15;
14
15
m_FullTime
=
new
FullTimeData
();
16
17
if
(
g_Game
.GetMission())
18
{
19
g_Game
.GetMission().AddActiveInputExcludes({
"menu"
});
20
21
g_Game
.GetMission().GetHud().ShowHudUI(
false
);
22
g_Game
.GetMission().GetHud().ShowQuickbarUI(
false
);
23
}
24
}
25
26
void
~InviteMenu
()
27
{
28
if
(
g_Game
&&
g_Game
.GetMission())
29
{
30
g_Game
.GetMission().RemoveActiveInputExcludes({
"menu"
},
true
);
31
32
g_Game
.GetMission().GetHud().ShowHudUI(
true
);
33
g_Game
.GetMission().GetHud().ShowQuickbarUI(
true
);
34
35
g_Game
.GetMission().GetOnInputPresetChanged().Remove(
OnInputPresetChanged
);
36
g_Game
.GetMission().GetOnInputDeviceChanged().Remove(
OnInputDeviceChanged
);
37
}
38
}
39
40
override
Widget
Init
()
41
{
42
layoutRoot =
g_Game
.GetWorkspace().CreateWidgets(
"gui/layouts/day_z_invite_dialog.layout"
);
43
44
m_LogoutTimeText
=
TextWidget
.Cast(layoutRoot.FindAnyWidget(
"txtLogoutTime"
));
45
m_DescriptionText
= MultilineTextWidget.Cast(layoutRoot.FindAnyWidget(
"txtDescription"
));
46
m_bCancel
= ButtonWidget.Cast(layoutRoot.FindAnyWidget(
"bCancel"
));
47
48
m_DescriptionText
.SetText(
"#layout_logout_dialog_note_invite"
);
49
m_DescriptionText
.Update();
50
51
// player should sit down if possible
52
PlayerBase
player =
PlayerBase
.Cast(
g_Game
.GetPlayer());
53
if
(player && player.GetEmoteManager() && !player.IsRestrained() && !player.IsUnconscious())
54
{
55
player.GetEmoteManager().CreateEmoteCBFromMenu(
EmoteConstants
.
ID_EMOTE_SITA
);
56
player.GetEmoteManager().GetEmoteLauncher().SetForced(
EmoteLauncher
.
FORCE_DIFFERENT
);
57
}
58
59
if
(
g_Game
.GetMission())
60
{
61
g_Game
.GetMission().GetOnInputPresetChanged().Insert(
OnInputPresetChanged
);
62
g_Game
.GetMission().GetOnInputDeviceChanged().Insert(
OnInputDeviceChanged
);
63
}
64
65
OnInputDeviceChanged
(
g_Game
.GetInput().GetCurrentInputDevice());
66
67
SetTime
(
m_iTime
);
68
g_Game
.GetCallQueue(
CALL_CATEGORY_SYSTEM
).CallLater(
UpdateTime
, 1000,
true
);
69
70
return
layoutRoot;
71
}
72
73
override
void
Update
(
float
timeslice)
74
{
75
if
(
GetUApi
().GetInputByID(UAUIBack).LocalPress())
76
Cancel
();
77
78
if
(
m_iTime
<= 0)
79
{
80
g_Game
.GetCallQueue(
CALL_CATEGORY_SYSTEM
).Remove(this.
UpdateTime
);
81
string
ip;
82
int
port;
83
OnlineServices
.
GetInviteServerInfo
(ip, port);
84
g_Game
.GetCallQueue(
CALL_CATEGORY_SYSTEM
).Call(
g_Game
.ConnectFromJoin, ip, port);
85
}
86
}
87
88
override
bool
OnClick
(
Widget
w,
int
x
,
int
y
,
int
button)
89
{
90
super.OnClick(w,
x
,
y
, button);
91
92
if
(w.GetUserID() ==
IDC_CANCEL
)
93
{
94
Cancel
();
95
return
true
;
96
}
97
98
return
false
;
99
}
100
101
void
SetTime
(
int
time)
102
{
103
m_iTime
= time;
104
string
text =
"#layout_logout_dialog_until_logout_"
;
105
106
TimeConversions.ConvertSecondsToFullTime(time,
m_FullTime
);
107
108
if
(
m_FullTime
.m_Days > 0)
109
text +=
"dhms"
;
110
else
if
(
m_FullTime
.m_Hours > 0)
111
text +=
"hms"
;
112
else
if
(
m_FullTime
.m_Minutes > 0)
113
text +=
"ms"
;
114
else
115
text +=
"s"
;
116
117
text =
Widget
.TranslateString(text);
118
text =
string
.
Format
(text,
m_FullTime
.m_Seconds,
m_FullTime
.m_Minutes,
m_FullTime
.m_Hours,
m_FullTime
.m_Days);
119
m_LogoutTimeText
.SetText(text);
120
}
121
122
void
UpdateTime
()
123
{
124
if
(
m_iTime
> 0)
125
{
126
m_iTime
-= 1;
127
SetTime
(
m_iTime
);
128
}
129
}
130
131
void
Cancel
()
132
{
133
g_Game
.GetCallQueue(
CALL_CATEGORY_SYSTEM
).Remove(this.
UpdateTime
);
134
135
g_Game
.SetGameState(DayZGameState.IN_GAME);
136
g_Game
.SetLoadState(DayZLoadState.CONNECT_CONTROLLER_SELECT);
137
Close
();
138
}
139
140
protected
void
OnInputPresetChanged
()
141
{
142
#ifdef PLATFORM_CONSOLE
143
UpdateControlsElements
();
144
#endif
145
}
146
147
protected
void
OnInputDeviceChanged
(
EInputDeviceType
pInputDeviceType)
148
{
149
UpdateControlsElements
();
150
UpdateControlsElementVisibility
();
151
}
152
153
protected
void
UpdateControlsElements
()
154
{
155
RichTextWidget
toolbarText =
RichTextWidget
.Cast(layoutRoot.FindAnyWidget(
"ContextToolbarText"
));
156
string
context =
string
.Format(
" %1"
,
InputUtils
.
GetRichtextButtonIconFromInputAction
(
"UAUIBack"
,
"#dialog_cancel"
, EUAINPUT_DEVICE_CONTROLLER,
InputUtils
.
ICON_SCALE_TOOLBAR
));
157
158
toolbarText.SetText(context);
159
}
160
161
protected
void
UpdateControlsElementVisibility
()
162
{
163
bool
toolbarShow =
false
;
164
#ifdef PLATFORM_CONSOLE
165
toolbarShow = !
g_Game
.GetInput().IsEnabledMouseAndKeyboard() ||
g_Game
.GetInput().GetCurrentInputDevice() ==
EInputDeviceType
.CONTROLLER;
166
#endif
167
168
layoutRoot.FindAnyWidget(
"BottomConsoleToolbar"
).Show(toolbarShow);
169
m_bCancel
.Show(!toolbarShow);
170
}
171
}
EmoteConstants
Definition
constants.c:359
EmoteLauncher
Definition
emotemanager.c:65
EmoteLauncher::FORCE_DIFFERENT
static const int FORCE_DIFFERENT
Definition
emotemanager.c:67
FullTimeData
struct that keeps Time relevant information for future formatting
Definition
timeconversions.c:5
InputUtils
Definition
inpututils.c:2
InputUtils::ICON_SCALE_TOOLBAR
static const float ICON_SCALE_TOOLBAR
Definition
inpututils.c:15
InputUtils::GetRichtextButtonIconFromInputAction
static string GetRichtextButtonIconFromInputAction(notnull UAInput pInput, string pLocalizedDescription, int pInputDeviceType=EUAINPUT_DEVICE_CONTROLLER, float pScale=ICON_SCALE_NORMAL, bool pVertical=false)
Definition
inpututils.c:167
OnlineServices
Definition
onlineservices.c:2
OnlineServices::GetInviteServerInfo
static void GetInviteServerInfo(out string ip, out int port)
Definition
onlineservices.c:191
PlayerBase
Definition
playerbaseclient.c:2
RichTextWidget
Definition
gameplay.c:317
TextWidget
Definition
enwidgets.c:220
UIScriptedMenu
Xbox menu.
Definition
dayzgame.c:64
UIScriptedMenu::m_FullTime
ref FullTimeData m_FullTime
Definition
invitemenu.c:9
UIScriptedMenu::OnInputPresetChanged
void OnInputPresetChanged()
Definition
controlsxboxnew.c:63
UIScriptedMenu::m_bCancelConsole
ButtonWidget m_bCancelConsole
Definition
invitemenu.c:6
UIScriptedMenu::UpdateControlsElementVisibility
void UpdateControlsElementVisibility()
Definition
controlsxboxnew.c:545
UIScriptedMenu::Update
override void Update(float timeslice)
Definition
invitemenu.c:73
UIScriptedMenu::m_bCancel
ButtonWidget m_bCancel
Definition
invitemenu.c:5
UIScriptedMenu::UpdateTime
void UpdateTime()
Definition
invitemenu.c:122
UIScriptedMenu::m_LogoutTimeText
TextWidget m_LogoutTimeText
Definition
invitemenu.c:3
UIScriptedMenu::SetTime
void SetTime(int time)
Definition
invitemenu.c:101
UIScriptedMenu::OnInputDeviceChanged
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
Definition
controlsxboxnew.c:71
UIScriptedMenu::Cancel
void Cancel()
Definition
invitemenu.c:131
UIScriptedMenu::~InviteMenu
void ~InviteMenu()
Definition
invitemenu.c:26
UIScriptedMenu::Init
override Widget Init()
Definition
invitemenu.c:40
UIScriptedMenu::UpdateControlsElements
void UpdateControlsElements()
Definition
controlsxboxnew.c:535
UIScriptedMenu::m_DescriptionText
MultilineTextWidget m_DescriptionText
Definition
invitemenu.c:4
UIScriptedMenu::OnClick
override bool OnClick(Widget w, int x, int y, int button)
Definition
invitemenu.c:88
UIScriptedMenu::InviteMenu
void InviteMenu()
Definition
invitemenu.c:11
UIScriptedMenu::m_iTime
int m_iTime
Definition
invitemenu.c:7
Widget
Definition
enwidgets.c:190
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
EmoteConstants::ID_EMOTE_SITA
const int ID_EMOTE_SITA
Definition
constants.c:373
string::Format
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
CALL_CATEGORY_SYSTEM
const int CALL_CATEGORY_SYSTEM
Definition
tools.c:8
IDC_CANCEL
const int IDC_CANCEL
Definition
constants.c:136
x
Icon x
y
Icon y
EInputDeviceType
EInputDeviceType
Definition
input.c:3
Close
void Close()
GetUApi
proto native UAInputAPI GetUApi()
Games
Dayz
scripts
5_mission
gui
invitemenu.c
Generated by
1.17.0