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

Protected Member Functions

void NotificationSystem ()
 
NotificationData GetNotificationData (NotificationType type)
 

Static Protected Member Functions

static void InitInstance ()
 
static void CleanupInstance ()
 
static NotificationSystem GetInstance ()
 
static void SendNotificationToPlayerExtended (Man player, float show_time, string title_text, string detail_text="", string icon="")
 Send custom notification to player from server.
 
static void SendNotificationToPlayerIdentityExtended (PlayerIdentity player, float show_time, string title_text, string detail_text="", string icon="")
 Send custom notification to player identity from server.
 
static void SendNotificationToPlayer (Man player, NotificationType type, float show_time, string detail_text="")
 Send notification from default types to player from server.
 
static void SendNotificationToPlayerIdentity (PlayerIdentity player, NotificationType type, float show_time, string detail_text="")
 Send notification from default types to player identity from server.
 
static void AddNotification (NotificationType type, float show_time, string detail_text="")
 Send notification from default types to local player.
 
static void AddNotificationExtended (float show_time, string title_text, string detail_text="", string icon="")
 Send custom notification from to local player.
 
static void Update (float timeslice)
 
static void LoadNotificationData ()
 

Protected Attributes

ref array< ref NotificationRuntimeDatam_TimeArray
 
ref array< ref NotificationRuntimeDatam_DeferredArray
 
ref map< NotificationType, ref NotificationDatam_DataArray
 
float m_TimeElapsed
 
ref ScriptInvoker m_OnNotificationAdded = new ScriptInvoker()
 
ref ScriptInvoker m_OnNotificationRemoved = new ScriptInvoker()
 

Static Protected Attributes

static const string JSON_FILE_PATH = "scripts/data/notifications.json"
 
static const int MAX_NOTIFICATIONS = 5
 
static ref NotificationSystem m_Instance
 

Private Attributes

const int DEFAULT_TIME_DISPLAYED = 10
 
const float NOTIFICATION_FADE_TIME = 3.0
 

Static Private Attributes

static const float UPDATE_INTERVAL_THRESHOLD = 1.0
 

Detailed Description

Definition at line 69 of file NotificationSystem.c.

Constructor & Destructor Documentation

◆ NotificationSystem()

void NotificationSystem::NotificationSystem ( )
inlineprotected

Definition at line 109 of file NotificationSystem.c.

110 {
111 m_TimeElapsed = 0.0;
112
115 }
ref array< ref NotificationRuntimeData > m_DeferredArray
ref array< ref NotificationRuntimeData > m_TimeArray

References m_DeferredArray, m_TimeArray, and m_TimeElapsed.

Referenced by InitInstance().

Member Function Documentation

◆ AddNotification()

static void NotificationSystem::AddNotification ( NotificationType type,
float show_time,
string detail_text = "" )
inlinestaticprotected

Send notification from default types to local player.

Parameters
typethe type of notification to send - these can be viewed in /Scripts/Data/Notifications.json
show_timeamount of time this notification is displayed
detail_textadditional text that can be added to the notification under the title - will not display additional text if not set

Definition at line 188 of file NotificationSystem.c.

189 {
190 if (m_Instance.m_TimeArray.Count() < MAX_NOTIFICATIONS)
191 {
193
194 m_Instance.m_TimeArray.Insert(data);
195 m_Instance.m_OnNotificationAdded.Invoke(data);
196 }
197 else
198 {
200 m_Instance.m_DeferredArray.Insert(dataDeferred);
201 }
202 }
void NotificationRuntimeData(float time, NotificationData data, string detail_text)
static ref NotificationSystem m_Instance
static const int MAX_NOTIFICATIONS

References m_Instance, MAX_NOTIFICATIONS, and NotificationRuntimeData().

Referenced by CGame::DisconnectSessionEx(), OnlineServices::OnFriendsAsync(), BiosSessionService::OnGetGameplaySession(), CGame::OnRPC(), and BiosUserManager::SelectUserEx().

◆ AddNotificationExtended()

static void NotificationSystem::AddNotificationExtended ( float show_time,
string title_text,
string detail_text = "",
string icon = "" )
inlinestaticprotected

Send custom notification from to local player.

Parameters
show_timeamount of time this notification is displayed
title_textthe title text that is displayed in the notification
detail_textadditional text that can be added to the notification under the title - will not display additional text if not set
iconthe icon that is displayed in the notification - will use default icon if not set

Definition at line 211 of file NotificationSystem.c.

References m_Instance, MAX_NOTIFICATIONS, and NotificationRuntimeData().

Referenced by CGame::OnRPC().

◆ CleanupInstance()

static void NotificationSystem::CleanupInstance ( )
inlinestaticprotected

Definition at line 99 of file NotificationSystem.c.

100 {
102 }

References m_Instance.

Referenced by CGame::~DayZGame().

◆ GetInstance()

static NotificationSystem NotificationSystem::GetInstance ( )
inlinestaticprotected

Definition at line 104 of file NotificationSystem.c.

105 {
106 return m_Instance;
107 }

References m_Instance.

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

◆ GetNotificationData()

NotificationData NotificationSystem::GetNotificationData ( NotificationType type)
inlineprotected

Definition at line 268 of file NotificationSystem.c.

269 {
270 if (m_DataArray.Contains(type))
271 return m_DataArray.Get(type);
272
273 return null;
274 }
ref map< NotificationType, ref NotificationData > m_DataArray

References m_DataArray.

◆ InitInstance()

static void NotificationSystem::InitInstance ( )
inlinestaticprotected

Definition at line 90 of file NotificationSystem.c.

91 {
92 if (!m_Instance)
93 {
95 m_Instance.LoadNotificationData();
96 }
97 }

References m_Instance, and NotificationSystem().

Referenced by CGame::InitNotifications().

◆ LoadNotificationData()

static void NotificationSystem::LoadNotificationData ( )
inlinestaticprotected

Definition at line 276 of file NotificationSystem.c.

277 {
280 string errorMessage;
283
284 m_Instance.m_DataArray.Copy(dataArray);
285
288 while (notificationType != NotificationType.NOTIFICATIONS_END)
289 {
292 }
293
294 for (int i = 0; i < m_Instance.m_DataArray.Count(); ++i)
295 notificationTypes.RemoveItem(m_Instance.m_DataArray.GetKey(i));
296
297 if (notificationTypes.Count() > 0)
298 {
300 {
302 "please_add_an_icon",
303 "please_add_a_title",
304 "optional_description",
305 );
306
307 m_Instance.m_DataArray.Insert(notificationType2, notificationData);
308 }
309
312 }
313 }
NotificationType
DEPRECATED (moved into NotificationSystem)
static const string JSON_FILE_PATH
enum ShapeType ErrorEx

References ErrorEx, JSON_FILE_PATH, and m_Instance.

◆ SendNotificationToPlayer()

static void NotificationSystem::SendNotificationToPlayer ( Man player,
NotificationType type,
float show_time,
string detail_text = "" )
inlinestaticprotected

Send notification from default types to player from server.

Parameters
playerthe target player to send notification to
typethe type of notification to send - these can be viewed in /Scripts/Data/Notifications.json
show_timeamount of time this notification is displayed
detail_textadditional text that can be added to the notification under the title - will not display additional text if not set

Definition at line 158 of file NotificationSystem.c.

159 {
160 if (player)
162 }
static void SendNotificationToPlayerIdentity(PlayerIdentity player, NotificationType type, float show_time, string detail_text="")
Send notification from default types to player identity from server.

References SendNotificationToPlayerIdentity().

◆ SendNotificationToPlayerExtended()

static void NotificationSystem::SendNotificationToPlayerExtended ( Man player,
float show_time,
string title_text,
string detail_text = "",
string icon = "" )
inlinestaticprotected

Send custom notification to player from server.

Parameters
playerthe target player to send notification to
show_timeamount of time this notification is displayed
title_textthe title text that is displayed in the notification
detail_textadditional text that can be added to the notification under the title - will not display additional text if not set
iconthe icon that is displayed in the notification - will use default icon if not set

Definition at line 125 of file NotificationSystem.c.

126 {
127 if (player)
129 }
static void SendNotificationToPlayerIdentityExtended(PlayerIdentity player, float show_time, string title_text, string detail_text="", string icon="")
Send custom notification to player identity from server.

References SendNotificationToPlayerIdentityExtended().

◆ SendNotificationToPlayerIdentity()

static void NotificationSystem::SendNotificationToPlayerIdentity ( PlayerIdentity player,
NotificationType type,
float show_time,
string detail_text = "" )
inlinestaticprotected

Send notification from default types to player identity from server.

Parameters
playerthe target player to send notification to - if null, will send to all players
typethe type of notification to send - these can be viewed in /Scripts/Data/Notifications.json
show_timeamount of time this notification is displayed
detail_textadditional text that can be added to the notification under the title - will not display additional text if not set

Definition at line 171 of file NotificationSystem.c.

172 {
173 ScriptRPC rpc = new ScriptRPC();
174
175 rpc.Write(type);
176 rpc.Write(show_time);
177 rpc.Write(detail_text);
178
179 rpc.Send(null, ERPCs.RPC_SEND_NOTIFICATION, true, player);
180 }
ERPCs
Definition ERPCs.c:2

Referenced by SendNotificationToPlayer().

◆ SendNotificationToPlayerIdentityExtended()

static void NotificationSystem::SendNotificationToPlayerIdentityExtended ( PlayerIdentity player,
float show_time,
string title_text,
string detail_text = "",
string icon = "" )
inlinestaticprotected

Send custom notification to player identity from server.

Parameters
playerthe target player to send notification to - if null, will send to all players
show_timeamount of time this notification is displayed
title_textthe title text that is displayed in the notification
detail_textadditional text that can be added to the notification under the title - will not display additional text if not set
iconthe icon that is displayed in the notification - will use default icon if not set

Definition at line 139 of file NotificationSystem.c.

140 {
141 ScriptRPC rpc = new ScriptRPC();
142
143 rpc.Write(show_time);
144 rpc.Write(title_text);
145 rpc.Write(detail_text);
146 rpc.Write(icon);
147
148 rpc.Send(null, ERPCs.RPC_SEND_NOTIFICATION_EXTENDED, true, player);
149 }

Referenced by SendNotificationToPlayerExtended().

◆ Update()

static void NotificationSystem::Update ( float timeslice)
inlinestaticprotected

Definition at line 229 of file NotificationSystem.c.

230 {
231 if (m_Instance)
232 {
233 if (g_Game.GetGameState() != DayZGameState.IN_GAME && g_Game.GetGameState() != DayZGameState.MAIN_MENU)
234 return;
235
236 m_Instance.m_TimeElapsed += timeslice;
237 if (m_Instance.m_TimeElapsed >= UPDATE_INTERVAL_THRESHOLD)
238 {
241 {
242 if (visibleNotificationData.GetRemainingTime() <= 0.0)
244 else
246 }
247
249 {
250 m_Instance.m_OnNotificationRemoved.Invoke(expiredNotificationData);
251 m_Instance.m_TimeArray.RemoveItem(expiredNotificationData);
252
253 if (m_Instance.m_DeferredArray.Count() > 0)
254 {
255 int count = m_Instance.m_DeferredArray.Count();
257 m_Instance.m_TimeArray.Insert(deferredNotificationData);
258 m_Instance.m_OnNotificationAdded.Invoke(deferredNotificationData);
259 m_Instance.m_DeferredArray.Remove(count - 1);
260 }
261 }
262
263 m_Instance.m_TimeElapsed = 0;
264 }
265 }
266 }
DayZGame g_Game
Definition DayZGame.c:3528
static const float UPDATE_INTERVAL_THRESHOLD

References g_Game, m_Instance, NotificationRuntimeData(), and UPDATE_INTERVAL_THRESHOLD.

Referenced by CGame::OnUpdate().

Member Data Documentation

◆ DEFAULT_TIME_DISPLAYED

const int NotificationSystem::DEFAULT_TIME_DISPLAYED = 10
private

◆ JSON_FILE_PATH

const string NotificationSystem::JSON_FILE_PATH = "scripts/data/notifications.json"
staticprotected

Definition at line 74 of file NotificationSystem.c.

Referenced by LoadNotificationData().

◆ m_DataArray

ref map<NotificationType, ref NotificationData> NotificationSystem::m_DataArray
protected

Definition at line 83 of file NotificationSystem.c.

Referenced by GetNotificationData().

◆ m_DeferredArray

ref array<ref NotificationRuntimeData> NotificationSystem::m_DeferredArray
protected

Definition at line 82 of file NotificationSystem.c.

Referenced by NotificationSystem().

◆ m_Instance

ref NotificationSystem NotificationSystem::m_Instance
staticprotected

◆ m_OnNotificationAdded

ref ScriptInvoker NotificationSystem::m_OnNotificationAdded = new ScriptInvoker()
protected

Definition at line 87 of file NotificationSystem.c.

◆ m_OnNotificationRemoved

ref ScriptInvoker NotificationSystem::m_OnNotificationRemoved = new ScriptInvoker()
protected

Definition at line 88 of file NotificationSystem.c.

◆ m_TimeArray

ref array<ref NotificationRuntimeData> NotificationSystem::m_TimeArray
protected

Definition at line 81 of file NotificationSystem.c.

Referenced by NotificationSystem().

◆ m_TimeElapsed

float NotificationSystem::m_TimeElapsed
protected

Definition at line 85 of file NotificationSystem.c.

Referenced by NotificationSystem().

◆ MAX_NOTIFICATIONS

const int NotificationSystem::MAX_NOTIFICATIONS = 5
staticprotected

Definition at line 75 of file NotificationSystem.c.

Referenced by AddNotification(), and AddNotificationExtended().

◆ NOTIFICATION_FADE_TIME

const float NotificationSystem::NOTIFICATION_FADE_TIME = 3.0
private

Definition at line 72 of file NotificationSystem.c.

Referenced by NotificationUI::Update().

◆ UPDATE_INTERVAL_THRESHOLD

const float NotificationSystem::UPDATE_INTERVAL_THRESHOLD = 1.0
staticprivate

Definition at line 77 of file NotificationSystem.c.

Referenced by Update().


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