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