DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
LogoutMenu.c
См. документацию.
1
2class LogoutMenu extends UIScriptedMenu
3{
4 private TextWidget m_LogoutTimeText;
6 private ButtonWidget m_bLogoutNow;
7 private ButtonWidget m_bCancel;
8 #ifdef PLATFORM_CONSOLE
9 private ButtonWidget m_bCancelConsole;
10 #endif
11 private int m_iTime;
12 private bool m_bCancelSent;
13
14 private ref FullTimeData m_FullTime;
15
17 {
18 m_iTime = 0;
19 g_Game.SetKeyboardHandle(this);
20
22 }
23
25 {
26 g_Game.SetKeyboardHandle(null);
27 if (g_Game.GetMission())
28 Cancel(); //cancels request on irregular close (player death, suicide, some mass-menu closure...)
29
30 m_FullTime = null;
31
32 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
33 if (player && player.GetEmoteManager())
34 {
35 player.GetEmoteManager().SetClientLoggingOut(false);
36 }
37
38 #ifdef PLATFORM_CONSOLE
39 if (g_Game.GetMission())
40 {
41 g_Game.GetMission().GetOnInputDeviceChanged().Remove(OnInputDeviceChanged);
42 }
43 #endif
44 }
45
46 override Widget Init()
47 {
48 layoutRoot = g_Game.GetWorkspace().CreateWidgets("gui/layouts/day_z_logout_dialog.layout");
49
50 m_LogoutTimeText = TextWidget.Cast(layoutRoot.FindAnyWidget("txtLogoutTime"));
51 m_DescriptionText = TextWidget.Cast(layoutRoot.FindAnyWidget("txtDescription"));
52 m_bLogoutNow = ButtonWidget.Cast(layoutRoot.FindAnyWidget("bLogoutNow"));
53 m_bCancel = ButtonWidget.Cast(layoutRoot.FindAnyWidget("bCancel"));
54
55 #ifdef PLATFORM_CONSOLE
56 m_bCancelConsole = ButtonWidget.Cast(layoutRoot.FindAnyWidget("bCancelConsole"));
57 m_bCancel.Show(false);
58 m_bLogoutNow.Show(false);
59 #else
60 m_bCancel.Show(true);
61 m_bLogoutNow.Show(true);
62 layoutRoot.FindAnyWidget("toolbar_bg").Show(false);
63 #endif
64
65 UpdateInfo();
66
67 // player should sit down if possible
68 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
69 if (player.GetEmoteManager() && !player.IsRestrained() && !player.IsUnconscious())
70 {
71 player.GetEmoteManager().SetClientLoggingOut(true);
72 }
73
74 #ifdef PLATFORM_CONSOLE
75 if (g_Game.GetMission())
76 {
77 g_Game.GetMission().GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
78 }
79
80 OnInputDeviceChanged(g_Game.GetInput().GetCurrentInputDevice());
81 #endif
82
83 return layoutRoot;
84 }
85
86 void Show()
87 {
88 if (layoutRoot)
89 layoutRoot.Show(true);
90 }
91
92 void Hide()
93 {
94 if (layoutRoot)
95 layoutRoot.Show(false);
96 }
97
98 override bool OnClick(Widget w, int x, int y, int button)
99 {
100 super.OnClick(w, x, y, button);
101
102 if (w == m_bLogoutNow)
103 {
104 g_Game.GetMission().AbortMission();
105
106 return true;
107 }
108 #ifdef PLATFORM_CONSOLE
109 else if (w == m_bCancelConsole)
110 #else
111 else if (w == m_bCancel)
112 #endif
113 {
114 Hide();
115 Cancel();
116 return true;
117 }
118
119 return false;
120 }
121
122 override void Update(float timeslice)
123 {
124 if (GetUApi().GetInputByID(UAUIBack).LocalPress())
125 {
126 Hide();
127 Cancel();
128 }
129 }
130
132 {
133 m_LogoutTimeText.SetText(" ");
134 }
135
136 void SetTime(int time)
137 {
138 m_iTime = time;
139 string text = "#layout_logout_dialog_until_logout_";
140
141 TimeConversions.ConvertSecondsToFullTime(time, m_FullTime);
142
143 if (m_FullTime.m_Days > 0)
144 text += "dhms";
145 else if (m_FullTime.m_Hours > 0)
146 text += "hms";
147 else if (m_FullTime.m_Minutes > 0)
148 text += "ms";
149 else
150 text += "s";
151
152 text = Widget.TranslateString(text);
153 text = string.Format(text, m_FullTime.m_Seconds, m_FullTime.m_Minutes, m_FullTime.m_Hours, m_FullTime.m_Days);
154 m_LogoutTimeText.SetText(text);
155 }
156
158 {
159
160 if (m_iTime > 0)
161 {
162 SetTime(--m_iTime);
163 }
164 else
165 {
166 Exit();
167 }
168 }
169
171 {
172 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
173 if (player.IsRestrained() || player.IsUnconscious())
174 {
175 // display killInfo
176 m_DescriptionText.SetText("#layout_logout_dialog_note_killed");
177 }
178 else
179 {
180 // hide killInfo
181 m_DescriptionText.SetText("#layout_logout_dialog_note");
182 }
183 }
184
185 void Exit()
186 {
187 // exit menu and logout screen
188 g_Game.GetMission().Continue();
189
190 // stop updating of logout screen
191 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(this.UpdateTime);
192
193 // go back to main menu
194 g_Game.GetMission().AbortMission();
195 }
196
197 void Cancel()
198 {
199 // this menu outlives its widgets, so the destructor can come back here long after an
200 // explicit cancel. Only ever tell the server once, a late second cancel would take back
201 // a logout somebody else has since asked for.
202 if (m_bCancelSent)
203 return;
204
205 m_bCancelSent = true;
206
207 g_Game.GetMission().Continue();
208 g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(this.UpdateTime);
209
210 // request logout cancel from server
211 g_Game.LogoutRequestCancel();
212 }
213
214 #ifdef PLATFORM_CONSOLE
215 protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
216 {
218 }
219
220 protected void UpdateControlsElementVisibility()
221 {
222 bool toolbarShow = false;
223 toolbarShow = !g_Game.GetInput().IsEnabledMouseAndKeyboard() || g_Game.GetInput().GetCurrentInputDevice() == EInputDeviceType.CONTROLLER;
224 layoutRoot.FindAnyWidget("toolbar_bg").Show(toolbarShow);
225 m_bCancelConsole.Show(!toolbarShow);
226
227 if (toolbarShow)
228 {
229 RichTextWidget toolbar_b = RichTextWidget.Cast(layoutRoot.FindAnyWidget("BackIcon"));
230 toolbar_b.SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIBack", "", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
231 }
232 }
233 #endif
234}
DayZGame g_Game
Определения DayZGame.c:4074
Icon x
Icon y
proto native UAInputAPI GetUApi()
struct that keeps Time relevant information for future formatting
Определения TimeConversions.c:5
Определения PlayerBaseClient.c:2
Определения EnWidgets.c:220
void UpdateControlsElementVisibility()
Определения ControlsXboxNew.c:545
override void Update(float timeslice)
Определения LogoutMenu.c:122
void LogoutMenu()
Определения LogoutMenu.c:16
bool m_bCancelSent
Определения LogoutMenu.c:12
TextWidget m_LogoutTimeText
Определения InviteMenu.c:8
void SetTime(int time)
Определения LogoutMenu.c:136
void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
Определения ControlsXboxNew.c:71
void UpdateTime()
Определения LogoutMenu.c:157
void SetLogoutTime()
Определения LogoutMenu.c:131
void Cancel()
Определения LogoutMenu.c:197
MultilineTextWidget m_DescriptionText
Определения InviteMenu.c:9
ref FullTimeData m_FullTime
Определения InviteMenu.c:13
void Hide()
Определения LogoutMenu.c:92
ButtonWidget m_bLogoutNow
Определения LogoutMenu.c:6
override Widget Init()
Определения LogoutMenu.c:46
override bool OnClick(Widget w, int x, int y, int button)
Определения LogoutMenu.c:98
ButtonWidget m_bCancel
Определения LogoutMenu.c:7
void Show()
Определения LogoutMenu.c:86
int m_iTime
Определения InviteMenu.c:10
void Exit()
Определения LogoutMenu.c:185
void ~LogoutMenu()
Определения LogoutMenu.c:24
void UpdateInfo()
Определения LogoutMenu.c:170
Определения DayZGame.c:64
Определения EnWidgets.c:190
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.
const int CALL_CATEGORY_SYSTEM
Определения 3_Game/DayZ/tools/tools.c:8
EInputDeviceType
Определения input.c:3