DayZ 1.24
Loading...
Searching...
No Matches
LogoutMenu.c
Go to the documentation of this file.
1
2class LogoutMenu extends UIScriptedMenu
3{
9 private int m_iTime;
10
12
14 {
15 m_iTime = 0;
16 g_Game.SetKeyboardHandle(this);
17
18 m_FullTime = new FullTimeData();
19 }
20
22 {
23 g_Game.SetKeyboardHandle(null);
24 if (GetGame().GetMission())
25 Cancel(); //cancels request on irregular close (player death, suicide, some mass-menu closure...)
26
27 m_FullTime = null;
28 }
29
30 override Widget Init()
31 {
32 layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/day_z_logout_dialog.layout");
33
34 m_LogoutTimeText = TextWidget.Cast(layoutRoot.FindAnyWidget("txtLogoutTime"));
35 m_DescriptionText = TextWidget.Cast(layoutRoot.FindAnyWidget("txtDescription"));
36 m_bLogoutNow = ButtonWidget.Cast(layoutRoot.FindAnyWidget("bLogoutNow"));
37 m_bCancel = ButtonWidget.Cast(layoutRoot.FindAnyWidget("bCancel"));
38
39#ifdef PLATFORM_CONSOLE
40 m_bCancel.Show(false);
41 m_bLogoutNow.Show(false);
42
43 layoutRoot.FindAnyWidget("toolbar_bg").Show(true);
44 RichTextWidget toolbar_b = RichTextWidget.Cast(layoutRoot.FindAnyWidget("BackIcon"));
46#else
47 m_bCancel.Show(true);
48 m_bLogoutNow.Show(true);
49 layoutRoot.FindAnyWidget("toolbar_bg").Show(false);
50#endif
51
52 UpdateInfo();
53
54 // player should sit down if possible
56 if (player.GetEmoteManager() && !player.IsRestrained() && !player.IsUnconscious())
57 {
58 player.GetEmoteManager().CreateEmoteCBFromMenu(EmoteConstants.ID_EMOTE_SITA);
59 player.GetEmoteManager().GetEmoteLauncher().SetForced(EmoteLauncher.FORCE_DIFFERENT);
60 }
61
62 return layoutRoot;
63 }
64
65 void Show()
66 {
67 if (layoutRoot)
68 layoutRoot.Show(true);
69 }
70
71 void Hide()
72 {
73 if (layoutRoot)
74 layoutRoot.Show(false);
75 }
76
77 override bool OnClick(Widget w, int x, int y, int button)
78 {
79 super.OnClick(w, x, y, button);
80
81 if (w == m_bLogoutNow)
82 {
83 GetGame().GetMission().AbortMission();
84
85 return true;
86 }
87 else if (w == m_bCancel)
88 {
89 Hide();
90 Cancel();
91 return true;
92 }
93
94 return false;
95 }
96
97 override void Update(float timeslice)
98 {
99 if (GetUApi().GetInputByID(UAUIBack).LocalPress())
100 {
101 Hide();
102 Cancel();
103 }
104 }
105
107 {
108 m_LogoutTimeText.SetText(" ");
109 }
110
111 void SetTime(int time)
112 {
113 m_iTime = time;
114 string text = "#layout_logout_dialog_until_logout_";
115
116 TimeConversions.ConvertSecondsToFullTime(time, m_FullTime);
117
118 if (m_FullTime.m_Days > 0)
119 text += "dhms";
120 else if (m_FullTime.m_Hours > 0)
121 text += "hms";
122 else if (m_FullTime.m_Minutes > 0)
123 text += "ms";
124 else
125 text += "s";
126
127 text = Widget.TranslateString(text);
128 text = string.Format(text, m_FullTime.m_Seconds, m_FullTime.m_Minutes, m_FullTime.m_Hours, m_FullTime.m_Days);
129 m_LogoutTimeText.SetText(text);
130 }
131
133 {
134
135 if (m_iTime > 0)
136 SetTime(--m_iTime);
137 else
138 Exit();
139 }
140
142 {
144 if (player.IsRestrained() || player.IsUnconscious())
145 {
146 // display killInfo
147 m_DescriptionText.SetText("#layout_logout_dialog_note_killed");
148 }
149 else
150 {
151 // hide killInfo
152 m_DescriptionText.SetText("#layout_logout_dialog_note");
153 }
154 }
155
156 void Exit()
157 {
158 // exit menu and logout screen
159 GetGame().GetMission().Continue();
160
161 // stop updating of logout screen
162 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(this.UpdateTime);
163
164 // go back to main menu
165 GetGame().GetMission().AbortMission();
166 }
167
168 void Cancel()
169 {
170 GetGame().GetMission().Continue();
171 GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(this.UpdateTime);
172
173 // request logout cancel from server
174 GetGame().LogoutRequestCancel();
175 }
176}
DayZGame g_Game
Definition DayZGame.c:3528
Icon x
Icon y
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
override void Update(float timeslice)
Definition LogoutMenu.c:97
void LogoutMenu()
Definition LogoutMenu.c:13
TextWidget m_LogoutTimeText
Definition InviteMenu.c:3
void SetTime(int time)
Definition LogoutMenu.c:111
void UpdateTime()
Definition LogoutMenu.c:132
void SetLogoutTime()
Definition LogoutMenu.c:106
ref FullTimeData m_FullTime
Definition InviteMenu.c:9
ButtonWidget m_bCancelConsole
Definition InviteMenu.c:6
ButtonWidget m_bLogoutNow
Definition LogoutMenu.c:6
override Widget Init()
Definition LogoutMenu.c:30
override bool OnClick(Widget w, int x, int y, int button)
Definition LogoutMenu.c:77
TextWidget m_DescriptionText
Definition InviteMenu.c:4
ButtonWidget m_bCancel
Definition InviteMenu.c:5
void ~LogoutMenu()
Definition LogoutMenu.c:21
void UpdateInfo()
Definition LogoutMenu.c:141
proto native CGame GetGame()
const int ID_EMOTE_SITA
Definition constants.c:363
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8