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