DayZ 1.24
Loading...
Searching...
No Matches
NotificationUI.c
Go to the documentation of this file.
2{
3 protected ref Widget m_Root;
4 protected ref Widget m_Spacer;
7
10
11 protected float m_Width;
12 protected float m_CurrentHeight;
13 protected float m_TargetHeight;
14 protected float m_BackupPosX;
15 protected float m_BackupPosY;
17
18 protected bool m_OffsetEnabled;;
19
21 {
22 m_Root = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/notifications/notifications.layout");
23 m_Spacer = m_Root.FindAnyWidget("NotificationSpacer");
24 m_VoiceContent = m_Root.FindAnyWidget("VoiceContent");
25 m_NotificationContent = m_Root.FindAnyWidget("NotificationContent");
29
31 if (ntfSys)
32 {
33 ntfSys.m_OnNotificationAdded.Insert(AddNotification);
34 ntfSys.m_OnNotificationRemoved.Insert(RemoveNotification);
35 }
36 }
37
39 {
41 if (ntfSys)
42 {
43 ntfSys.m_OnNotificationAdded.Remove(AddNotification);
44 ntfSys.m_OnNotificationRemoved.Remove(RemoveNotification);
45 }
46 }
47
49 {
50 Widget notification = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/notifications/notification_element.layout", m_NotificationContent);
51
52 ImageWidget icon = ImageWidget.Cast(notification.FindAnyWidget("Image"));
53 RichTextWidget title = RichTextWidget.Cast(notification.FindAnyWidget("Title"));
54
55 if (data.GetIcon() != "")
56 icon.LoadImageFile(0, data.GetIcon());
57 title.SetText(data.GetTitleText());
58
59 if (data.GetDetailText() != "")
60 {
61 Widget bottom_spacer = notification.FindAnyWidget("BottomSpacer");
62 RichTextWidget detail = RichTextWidget.Cast(notification.FindAnyWidget("Detail"));
63 bottom_spacer.Show(true);
64 detail.SetText(data.GetDetailText());
65 detail.Update();
66 bottom_spacer.Update();
67 notification.Update();
68 }
69
72 }
73
75 {
76 if (m_Notifications.Contains(data))
77 {
79 m_WidgetTimers.Insert(m_WidgetTimers.Count().ToString() + data.GetTime().ToString(), notification);
80 m_Notifications.Remove(data);
82 }
83 }
84
85 void AddVoiceNotification(string player, string name)
86 {
87 if (!m_VoiceNotifications.Contains(player))
88 {
90 if (!m_WidgetTimers.Contains(player))
91 notification = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/notifications/notification_voice_element.layout", m_VoiceContent);
92 else
93 {
95 m_WidgetTimers.Remove(player);
96 notification.SetAlpha(120 / 255);
97 Widget w_c = notification.FindAnyWidget("Name");
98 if (w_c)
99 w_c.SetAlpha(1);
100 }
101
102 RichTextWidget title = RichTextWidget.Cast(notification.FindAnyWidget("Name"));
104 title.SetText(name);
106 }
107 }
108
119
121 {
122 for (int i = 0; i < m_VoiceNotifications.Count(); i++)
123 {
124 Widget w = m_VoiceNotifications.GetElement(i);
125 delete w;
126 }
127 m_VoiceNotifications.Clear();
129 }
130
132 {
133 m_VoiceContent.Update();
134 m_NotificationContent.Update();
135 m_Spacer.Update();
136
137 float x;
138 m_Spacer.GetScreenSize(x, m_TargetHeight);
139 m_Root.GetScreenSize(m_Width, m_CurrentHeight);
140
141 UpdateOffset();
142 }
143
145 {
146 UIScriptedMenu menu = UIScriptedMenu.Cast(GetGame().GetUIManager().GetMenu());
147 if (menu)
148 {
149 Widget expNotification = menu.GetLayoutRoot().FindAnyWidget("notification_root");
150 if (expNotification && expNotification.IsVisible())
151 {
152 if (!m_OffsetEnabled)
153 {
155
156 float x, y, w, h;
157 m_Root.GetScreenPos(x, y);
158 expNotification.GetScreenSize(w, h);
159
160 m_Root.SetScreenPos(x, h);
161 m_OffsetEnabled = true;
162 }
163 }
164 else if (m_OffsetEnabled)
165 {
167 m_OffsetEnabled = false;
168 }
169 }
170 }
171
172 static float m_VelArr[1];
173 void Update(float timeslice)
174 {
175 UpdateOffset();
176
177 float x;
178 m_Spacer.GetScreenSize(x, m_TargetHeight);
180 if (is_near)
181 {
184 }
186 {
189 m_VelArr[0] = 0;
190 }
191
192 for (int i = 0; i < m_WidgetTimers.Count();)
193 {
194 Widget w = m_WidgetTimers.GetElement(i);
196 if (new_alpha > 0)
197 {
198 w.SetAlpha(new_alpha);
199 Widget w_c = w.FindAnyWidget("TopSpacer");
200 Widget w_c2 = w.FindAnyWidget("BottomSpacer");
201 Widget w_c3 = w.FindAnyWidget("Title");
202 Widget w_c4 = w.FindAnyWidget("Detail");
203 Widget w_c5 = w.FindAnyWidget("Name");
204 if (w_c && w_c2)
205 {
207 w_c.SetAlpha(new_alpha_cont);
208 w_c2.SetAlpha(new_alpha_cont);
209 w_c3.SetAlpha(new_alpha_cont);
210 w_c4.SetAlpha(new_alpha_cont);
211 }
212 if (w_c5)
213 {
215 w_c5.SetAlpha(new_alpha_voice);
216 }
217 i++;
218 }
219 else
220 {
221 delete w;
222 m_WidgetTimers.RemoveElement(i);
224 }
225 }
226 }
227}
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
Icon x
Icon y
void NotificationRuntimeData(float time, NotificationData data, string detail_text)
Definition EnMath.c:7
const float NOTIFICATION_FADE_TIME
static NotificationSystem GetInstance()
ref Widget m_VoiceContent
ref map< NotificationRuntimeData, Widget > m_Notifications
ref Widget m_Root
void AddNotification(NotificationRuntimeData data)
ref map< string, Widget > m_VoiceNotifications
void UpdateTargetHeight()
void AddVoiceNotification(string player, string name)
void RemoveNotification(NotificationRuntimeData data)
ref Widget m_NotificationContent
void Update(float timeslice)
ref map< string, Widget > m_WidgetTimers
void ClearVoiceNotifications()
static float m_VelArr[1]
ref Widget m_Spacer
void RemoveVoiceNotification(string player)
proto native CGame GetGame()
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static proto float SmoothCD(float val, float target, inout float velocity[], float smoothTime, float maxVelocity, float dt)
Does the CD smoothing function - easy in | easy out / S shaped smoothing.