Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
invitemenu.c
Go to the documentation of this file.
1class 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 (GetGame().GetMission())
18 {
19 GetGame().GetMission().AddActiveInputExcludes({"menu"});
20
21 GetGame().GetMission().GetHud().ShowHudUI(false);
22 GetGame().GetMission().GetHud().ShowQuickbarUI(false);
23 }
24 }
25
26 void ~InviteMenu()
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 = 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(GetGame().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 (GetGame().GetMission())
60 {
61 GetGame().GetMission().GetOnInputPresetChanged().Insert(OnInputPresetChanged);
62 GetGame().GetMission().GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
63 }
64
65 OnInputDeviceChanged(GetGame().GetInput().GetCurrentInputDevice());
66
67 SetTime(m_iTime);
68 GetGame().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 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(this.UpdateTime);
81 string ip;
82 int port;
84 GetGame().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 GetGame().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
144 #endif
145 }
146
147 protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
148 {
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
162 {
163 bool toolbarShow = false;
164 #ifdef PLATFORM_CONSOLE
165 toolbarShow = !GetGame().GetInput().IsEnabledMouseAndKeyboard() || GetGame().GetInput().GetCurrentInputDevice() == EInputDeviceType.CONTROLLER;
166 #endif
167
168 layoutRoot.FindAnyWidget("BottomConsoleToolbar").Show(toolbarShow);
169 m_bCancel.Show(!toolbarShow);
170 }
171}
void OnInputPresetChanged()
Definition inventory.c:168
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
Definition inventory.c:175
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:167
static const float ICON_SCALE_TOOLBAR
Definition inpututils.c:15
static void GetInviteServerInfo(out string ip, out int port)
void UpdateControlsElementVisibility()
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
void UpdateControlsElements()
override Widget Init()
Definition bookmenu.c:11
override bool OnClick(Widget w, int x, int y, int button)
Definition bookmenu.c:34
void OnInputPresetChanged()
Definition invitemenu.c:140
DayZGame g_Game
Definition dayzgame.c:3868
proto native CGame GetGame()
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8
const int IDC_CANCEL
Definition constants.c:136
Icon x
Icon y
EInputDeviceType
Definition input.c:3
void Close()
PlayerBase GetPlayer()
void SetTime(float time)
DEPRECATED.
proto native UAInputAPI GetUApi()