DayZ 1.24
Loading...
Searching...
No Matches
NotificationUI Class Reference
Collaboration diagram for NotificationUI:
[legend]

Protected Member Functions

void NotificationUI ()
 
void ~NotificationUI ()
 
void AddNotification (NotificationRuntimeData data)
 
void RemoveNotification (NotificationRuntimeData data)
 
void AddVoiceNotification (string player, string name)
 
void RemoveVoiceNotification (string player)
 
void ClearVoiceNotifications ()
 
void UpdateTargetHeight ()
 
void UpdateOffset ()
 
void Update (float timeslice)
 

Protected Attributes

ref Widget m_Root
 
ref Widget m_Spacer
 
ref Widget m_VoiceContent
 
ref Widget m_NotificationContent
 
ref map< NotificationRuntimeData, Widgetm_Notifications
 
ref map< string, Widgetm_VoiceNotifications
 
float m_Width
 
float m_CurrentHeight
 
float m_TargetHeight
 
float m_BackupPosX
 
float m_BackupPosY
 
ref map< string, Widgetm_WidgetTimers
 
bool m_OffsetEnabled
 

Static Protected Attributes

static float m_VelArr [1]
 

Detailed Description

Definition at line 1 of file NotificationUI.c.

Constructor & Destructor Documentation

◆ NotificationUI()

void NotificationUI::NotificationUI ( )
inlineprotected

Definition at line 20 of file NotificationUI.c.

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 }
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 RemoveNotification(NotificationRuntimeData data)
ref Widget m_NotificationContent
ref map< string, Widget > m_WidgetTimers
ref Widget m_Spacer
proto native CGame GetGame()

References AddNotification(), GetGame(), NotificationSystem::GetInstance(), m_NotificationContent, m_Notifications, m_Root, m_Spacer, m_VoiceContent, m_VoiceNotifications, m_WidgetTimers, and RemoveNotification().

◆ ~NotificationUI()

void NotificationUI::~NotificationUI ( )
inlineprotected

Definition at line 38 of file NotificationUI.c.

39 {
41 if (ntfSys)
42 {
43 ntfSys.m_OnNotificationAdded.Remove(AddNotification);
44 ntfSys.m_OnNotificationRemoved.Remove(RemoveNotification);
45 }
46 }

References AddNotification(), NotificationSystem::GetInstance(), and RemoveNotification().

Member Function Documentation

◆ AddNotification()

void NotificationUI::AddNotification ( NotificationRuntimeData data)
inlineprotected

Definition at line 48 of file NotificationUI.c.

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 }
void UpdateTargetHeight()

References GetGame(), m_NotificationContent, m_Notifications, and UpdateTargetHeight().

Referenced by NotificationUI(), and ~NotificationUI().

◆ AddVoiceNotification()

void NotificationUI::AddVoiceNotification ( string player,
string name )
inlineprotected

Definition at line 85 of file NotificationUI.c.

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 }
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo

References GetGame(), m_VoiceContent, m_VoiceNotifications, m_WidgetTimers, name, and UpdateTargetHeight().

◆ ClearVoiceNotifications()

void NotificationUI::ClearVoiceNotifications ( )
inlineprotected

Definition at line 120 of file NotificationUI.c.

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 }

References m_VoiceNotifications, and UpdateTargetHeight().

◆ RemoveNotification()

void NotificationUI::RemoveNotification ( NotificationRuntimeData data)
inlineprotected

Definition at line 74 of file NotificationUI.c.

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 }

References m_Notifications, m_WidgetTimers, and UpdateTargetHeight().

Referenced by NotificationUI(), and ~NotificationUI().

◆ RemoveVoiceNotification()

void NotificationUI::RemoveVoiceNotification ( string player)
inlineprotected

Definition at line 109 of file NotificationUI.c.

110 {
111 if (m_VoiceNotifications.Contains(player))
112 {
117 }
118 }

References m_VoiceNotifications, m_WidgetTimers, and UpdateTargetHeight().

◆ Update()

void NotificationUI::Update ( float timeslice)
inlineprotected

Definition at line 173 of file NotificationUI.c.

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 }
Icon x
Definition EnMath.c:7
const float NOTIFICATION_FADE_TIME
static float m_VelArr[1]
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.

References Math::Clamp(), m_CurrentHeight, m_Root, m_Spacer, m_TargetHeight, m_VelArr, m_WidgetTimers, m_Width, NotificationSystem::NOTIFICATION_FADE_TIME, Math::SmoothCD(), UpdateOffset(), UpdateTargetHeight(), and x.

◆ UpdateOffset()

void NotificationUI::UpdateOffset ( )
inlineprotected

Definition at line 144 of file NotificationUI.c.

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 }
Icon y

References GetGame(), m_BackupPosX, m_BackupPosY, m_OffsetEnabled, m_Root, x, and y.

Referenced by Update(), and UpdateTargetHeight().

◆ UpdateTargetHeight()

void NotificationUI::UpdateTargetHeight ( )
inlineprotected

Member Data Documentation

◆ m_BackupPosX

float NotificationUI::m_BackupPosX
protected

Definition at line 14 of file NotificationUI.c.

Referenced by UpdateOffset().

◆ m_BackupPosY

float NotificationUI::m_BackupPosY
protected

Definition at line 15 of file NotificationUI.c.

Referenced by UpdateOffset().

◆ m_CurrentHeight

float NotificationUI::m_CurrentHeight
protected

Definition at line 12 of file NotificationUI.c.

Referenced by Update(), and UpdateTargetHeight().

◆ m_NotificationContent

ref Widget NotificationUI::m_NotificationContent
protected

Definition at line 6 of file NotificationUI.c.

Referenced by AddNotification(), NotificationUI(), and UpdateTargetHeight().

◆ m_Notifications

ref map<NotificationRuntimeData, Widget> NotificationUI::m_Notifications
protected

Definition at line 8 of file NotificationUI.c.

Referenced by AddNotification(), NotificationUI(), and RemoveNotification().

◆ m_OffsetEnabled

bool NotificationUI::m_OffsetEnabled
protected

Definition at line 18 of file NotificationUI.c.

Referenced by UpdateOffset().

◆ m_Root

ref Widget NotificationUI::m_Root
protected

Definition at line 3 of file NotificationUI.c.

Referenced by NotificationUI(), Update(), UpdateOffset(), and UpdateTargetHeight().

◆ m_Spacer

ref Widget NotificationUI::m_Spacer
protected

Definition at line 4 of file NotificationUI.c.

Referenced by NotificationUI(), Update(), and UpdateTargetHeight().

◆ m_TargetHeight

float NotificationUI::m_TargetHeight
protected

Definition at line 13 of file NotificationUI.c.

Referenced by Update(), and UpdateTargetHeight().

◆ m_VelArr

float NotificationUI::m_VelArr[1]
staticprotected

Definition at line 172 of file NotificationUI.c.

Referenced by Update().

◆ m_VoiceContent

ref Widget NotificationUI::m_VoiceContent
protected

Definition at line 5 of file NotificationUI.c.

Referenced by AddVoiceNotification(), NotificationUI(), and UpdateTargetHeight().

◆ m_VoiceNotifications

ref map<string, Widget> NotificationUI::m_VoiceNotifications
protected

◆ m_WidgetTimers

ref map<string, Widget> NotificationUI::m_WidgetTimers
protected

◆ m_Width

float NotificationUI::m_Width
protected

Definition at line 11 of file NotificationUI.c.

Referenced by Update(), and UpdateTargetHeight().


The documentation for this class was generated from the following file: