Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
notificationui.c
Go to the documentation of this file.
1
class
NotificationUI
2
{
3
protected
ref
Widget
m_Root
;
4
protected
ref
Widget
m_Spacer
;
5
protected
ref
Widget
m_VoiceContent
;
6
protected
ref
Widget
m_NotificationContent
;
7
8
protected
ref
map<NotificationRuntimeData, Widget>
m_Notifications
;
9
protected
ref
map<string, Widget>
m_VoiceNotifications
;
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
;
16
protected
ref
map<string, Widget>
m_WidgetTimers
;
17
18
protected
bool
m_OffsetEnabled
;;
19
20
void
NotificationUI
()
21
{
22
m_Root
=
g_Game
.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"
);
26
m_Notifications
=
new
map<NotificationRuntimeData, Widget>
;
27
m_VoiceNotifications
=
new
map<string, Widget>
;
28
m_WidgetTimers
=
new
map<string, Widget>
;
29
30
NotificationSystem
ntfSys =
NotificationSystem
.
GetInstance
();
31
if
(ntfSys)
32
{
33
ntfSys.
m_OnNotificationAdded
.
Insert
(
AddNotification
);
34
ntfSys.
m_OnNotificationRemoved
.
Insert
(
RemoveNotification
);
35
}
36
}
37
38
void
~NotificationUI
()
39
{
40
NotificationSystem
ntfSys =
NotificationSystem
.
GetInstance
();
41
if
(ntfSys)
42
{
43
ntfSys.
m_OnNotificationAdded
.
Remove
(
AddNotification
);
44
ntfSys.
m_OnNotificationRemoved
.
Remove
(
RemoveNotification
);
45
}
46
}
47
48
void
AddNotification
(
NotificationRuntimeData
data )
49
{
50
Widget
notification =
g_Game
.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
70
m_Notifications
.Insert( data, notification );
71
UpdateTargetHeight
();
72
}
73
74
void
RemoveNotification
(
NotificationRuntimeData
data )
75
{
76
if
(
m_Notifications
.Contains( data ) )
77
{
78
Widget
notification =
m_Notifications
.Get( data );
79
m_WidgetTimers
.Insert(
m_WidgetTimers
.Count().ToString() + data.GetTime().ToString(), notification );
80
m_Notifications
.Remove( data );
81
UpdateTargetHeight
();
82
}
83
}
84
85
void
AddVoiceNotification
(
string
player,
string
name
)
86
{
87
if
(!
m_VoiceNotifications
.Contains(player))
88
{
89
Widget
notification;
90
if
(!
m_WidgetTimers
.Contains(player))
91
{
92
notification =
g_Game
.GetWorkspace().CreateWidgets(
"gui/layouts/new_ui/notifications/notification_voice_element.layout"
,
m_VoiceContent
);
93
}
94
else
95
{
96
notification =
m_WidgetTimers
.Get(player);
97
m_WidgetTimers
.Remove(player);
98
notification.SetAlpha( 120 / 255 );
99
Widget
w_c = notification.FindAnyWidget(
"Name"
);
100
if
( w_c )
101
{
102
w_c.SetAlpha( 1 );
103
}
104
}
105
106
RichTextWidget
title =
RichTextWidget
.Cast(notification.FindAnyWidget(
"Name"
));
107
m_VoiceNotifications
.Insert(player, notification);
108
title.SetText(
name
);
109
UpdateTargetHeight
();
110
}
111
}
112
113
void
RemoveVoiceNotification
(
string
player )
114
{
115
if
(
m_VoiceNotifications
.Contains( player ) )
116
{
117
Widget
notification =
m_VoiceNotifications
.Get( player );
118
m_WidgetTimers
.Insert( player, notification );
119
m_VoiceNotifications
.Remove( player );
120
UpdateTargetHeight
();
121
}
122
}
123
124
void
ClearVoiceNotifications
()
125
{
126
for
(
int
i = 0; i <
m_VoiceNotifications
.Count(); i++ )
127
{
128
Widget
w =
m_VoiceNotifications
.GetElement( i );
129
delete
w;
130
}
131
m_VoiceNotifications
.Clear();
132
UpdateTargetHeight
();
133
}
134
135
void
UpdateTargetHeight
()
136
{
137
m_VoiceContent
.Update();
138
m_NotificationContent
.Update();
139
m_Spacer
.Update();
140
141
float
x
;
142
m_Spacer
.GetScreenSize(
x
,
m_TargetHeight
);
143
m_Root
.GetScreenSize(
m_Width
,
m_CurrentHeight
);
144
145
UpdateOffset
();
146
}
147
148
void
UpdateOffset
()
149
{
150
UIScriptedMenu
menu =
UIScriptedMenu
.Cast(
g_Game
.GetUIManager().GetMenu());
151
if
(menu)
152
{
153
Widget
expNotification = menu.GetLayoutRoot().FindAnyWidget(
"notification_root"
);
154
if
(expNotification && expNotification.IsVisible())
155
{
156
if
(!
m_OffsetEnabled
)
157
{
158
m_Root
.GetPos(
m_BackupPosX
,
m_BackupPosY
);
159
160
float
x
,
y
, w, h;
161
m_Root
.GetScreenPos(
x
,
y
);
162
expNotification.GetScreenSize(w, h);
163
164
m_Root
.SetScreenPos(
x
, h);
165
m_OffsetEnabled
=
true
;
166
}
167
}
168
else
if
(
m_OffsetEnabled
)
169
{
170
m_Root
.SetPos(
m_BackupPosX
,
m_BackupPosY
);
171
m_OffsetEnabled
=
false
;
172
}
173
}
174
}
175
176
static
float
m_VelArr
[1];
177
void
Update
(
float
timeslice )
178
{
179
UpdateOffset
();
180
181
float
x
;
182
m_Spacer
.GetScreenSize(
x
,
m_TargetHeight
);
183
bool
is_near = (
m_CurrentHeight
+ 0.01 <
m_TargetHeight
||
m_CurrentHeight
- 0.01 >
m_TargetHeight
);
184
if
( is_near )
185
{
186
m_CurrentHeight
=
Math
.
SmoothCD
(
m_CurrentHeight
,
m_TargetHeight
,
m_VelArr
, 0.2, 10000, timeslice);
187
m_Root
.SetSize(
m_Width
,
m_CurrentHeight
);
188
}
189
else
if
(
m_TargetHeight
!=
m_CurrentHeight
)
190
{
191
m_CurrentHeight
=
m_TargetHeight
;
192
m_Root
.SetSize(
m_Width
,
m_CurrentHeight
);
193
m_VelArr
[0] = 0;
194
}
195
196
for
(
int
i = 0; i <
m_WidgetTimers
.Count(); )
197
{
198
Widget
w =
m_WidgetTimers
.GetElement( i );
199
float
new_alpha =
Math
.
Clamp
( w.GetAlpha() - timeslice /
NotificationSystem
.
NOTIFICATION_FADE_TIME
, 0, 1 );
200
if
( new_alpha > 0 )
201
{
202
w.SetAlpha( new_alpha );
203
Widget
w_c = w.FindAnyWidget(
"TopSpacer"
);
204
Widget
w_c2 = w.FindAnyWidget(
"BottomSpacer"
);
205
Widget
w_c3 = w.FindAnyWidget(
"Title"
);
206
Widget
w_c4 = w.FindAnyWidget(
"Detail"
);
207
Widget
w_c5 = w.FindAnyWidget(
"Name"
);
208
if
( w_c && w_c2 )
209
{
210
float
new_alpha_cont =
Math
.
Clamp
( w_c.GetAlpha() - timeslice /
NotificationSystem
.
NOTIFICATION_FADE_TIME
, 0, 1 );
211
w_c.SetAlpha( new_alpha_cont );
212
w_c2.SetAlpha( new_alpha_cont );
213
w_c3.SetAlpha( new_alpha_cont );
214
w_c4.SetAlpha( new_alpha_cont );
215
}
216
if
( w_c5 )
217
{
218
float
new_alpha_voice =
Math
.
Clamp
( w_c5.GetAlpha() - timeslice /
NotificationSystem
.
NOTIFICATION_FADE_TIME
, 0, 1 );
219
w_c5.SetAlpha(new_alpha_voice);
220
}
221
i++;
222
}
223
else
224
{
225
delete
w;
226
m_WidgetTimers
.RemoveElement( i );
227
UpdateTargetHeight
();
228
}
229
}
230
}
231
}
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
Math
Definition
enmath.c:7
NotificationSystem
Definition
notificationsystem.c:70
NotificationSystem::m_OnNotificationAdded
ref ScriptInvoker m_OnNotificationAdded
Definition
notificationsystem.c:87
NotificationSystem::NOTIFICATION_FADE_TIME
const float NOTIFICATION_FADE_TIME
Definition
notificationsystem.c:72
NotificationSystem::GetInstance
static NotificationSystem GetInstance()
Definition
notificationsystem.c:104
NotificationSystem::m_OnNotificationRemoved
ref ScriptInvoker m_OnNotificationRemoved
Definition
notificationsystem.c:88
NotificationUI::m_BackupPosY
float m_BackupPosY
Definition
notificationui.c:15
NotificationUI::NotificationUI
void NotificationUI()
Definition
notificationui.c:20
NotificationUI::m_WidgetTimers
ref map< string, Widget > m_WidgetTimers
Definition
notificationui.c:16
NotificationUI::Update
void Update(float timeslice)
Definition
notificationui.c:177
NotificationUI::AddVoiceNotification
void AddVoiceNotification(string player, string name)
Definition
notificationui.c:85
NotificationUI::~NotificationUI
void ~NotificationUI()
Definition
notificationui.c:38
NotificationUI::m_VoiceNotifications
ref map< string, Widget > m_VoiceNotifications
Definition
notificationui.c:9
NotificationUI::m_OffsetEnabled
bool m_OffsetEnabled
Definition
notificationui.c:18
NotificationUI::RemoveVoiceNotification
void RemoveVoiceNotification(string player)
Definition
notificationui.c:113
NotificationUI::UpdateTargetHeight
void UpdateTargetHeight()
Definition
notificationui.c:135
NotificationUI::m_Spacer
ref Widget m_Spacer
Definition
notificationui.c:4
NotificationUI::UpdateOffset
void UpdateOffset()
Definition
notificationui.c:148
NotificationUI::m_NotificationContent
ref Widget m_NotificationContent
Definition
notificationui.c:6
NotificationUI::m_VelArr
static float m_VelArr[1]
Definition
notificationui.c:176
NotificationUI::RemoveNotification
void RemoveNotification(NotificationRuntimeData data)
Definition
notificationui.c:74
NotificationUI::m_CurrentHeight
float m_CurrentHeight
Definition
notificationui.c:12
NotificationUI::m_BackupPosX
float m_BackupPosX
Definition
notificationui.c:14
NotificationUI::AddNotification
void AddNotification(NotificationRuntimeData data)
Definition
notificationui.c:48
NotificationUI::m_Root
ref Widget m_Root
Definition
notificationui.c:3
NotificationUI::m_VoiceContent
ref Widget m_VoiceContent
Definition
notificationui.c:5
NotificationUI::m_Width
float m_Width
Definition
notificationui.c:11
NotificationUI::m_Notifications
ref map< NotificationRuntimeData, Widget > m_Notifications
Definition
notificationui.c:8
NotificationUI::m_TargetHeight
float m_TargetHeight
Definition
notificationui.c:13
NotificationUI::ClearVoiceNotifications
void ClearVoiceNotifications()
Definition
notificationui.c:124
RichTextWidget
Definition
gameplay.c:317
ScriptInvoker::Remove
proto bool Remove(func fn, int flags=EScriptInvokerRemoveFlags.ALL)
remove specific call from list
ScriptInvoker::Insert
proto bool Insert(func fn, int flags=EScriptInvokerInsertFlags.IMMEDIATE)
insert method to list
UIScriptedMenu
Xbox menu.
Definition
dayzgame.c:64
Widget
Definition
enwidgets.c:190
map
Definition
cachedequipmentstorage.c:4
g_Game
DayZGame g_Game
Definition
dayzgame.c:3942
Math::Clamp
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'.
Math::SmoothCD
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.
x
Icon x
y
Icon y
NotificationRuntimeData
void NotificationRuntimeData(float time, NotificationData data, string detail_text)
Definition
notificationsystem.c:23
Games
Dayz
scripts
3_game
client
notifications
notificationui.c
Generated by
1.17.0