1 const static float NOTIFICATION_FADE_TIME = 3.0;
29 if (detail_text !=
"")
71 const int DEFAULT_TIME_DISPLAYED = 10;
72 const float NOTIFICATION_FADE_TIME = 3.0;
74 protected static const string JSON_FILE_PATH =
"scripts/data/notifications.json";
75 protected static const int MAX_NOTIFICATIONS = 5;
77 private static const float UPDATE_INTERVAL_THRESHOLD = 1.0;
85 protected float m_TimeElapsed;
90 static void InitInstance()
95 m_Instance.LoadNotificationData();
99 static void CleanupInstance()
125 static void SendNotificationToPlayerExtended(Man player,
float show_time,
string title_text,
string detail_text =
"",
string icon =
"")
129 SendNotificationToPlayerIdentityExtended(player.GetIdentity(), show_time, title_text, detail_text, icon);
141 static void SendNotificationToPlayerIdentityExtended(
PlayerIdentity player,
float show_time,
string title_text,
string detail_text =
"",
string icon =
"")
145 rpc.Write(show_time);
146 rpc.Write(title_text);
147 rpc.Write(detail_text);
150 rpc.Send(
null,
ERPCs.RPC_SEND_NOTIFICATION_EXTENDED,
true, player);
160 static void SendNotificationToPlayer(Man player,
NotificationType type,
float show_time,
string detail_text =
"")
164 SendNotificationToPlayerIdentity(player.GetIdentity(), type, show_time, detail_text);
180 rpc.Write(show_time);
181 rpc.Write(detail_text);
183 rpc.Send(
null,
ERPCs.RPC_SEND_NOTIFICATION,
true, player);
192 static void AddNotification(
NotificationType type,
float show_time,
string detail_text =
"")
194 if (m_Instance.m_TimeArray.Count() < MAX_NOTIFICATIONS)
198 m_Instance.m_TimeArray.Insert(data);
199 m_Instance.m_OnNotificationAdded.Invoke(data);
204 m_Instance.m_DeferredArray.Insert(dataDeferred);
215 static void AddNotificationExtended(
float show_time,
string title_text,
string detail_text =
"",
string icon =
"")
217 if (m_Instance.m_TimeArray.Count() < MAX_NOTIFICATIONS)
222 m_Instance.m_TimeArray.Insert(data);
223 m_Instance.m_OnNotificationAdded.Invoke(data);
229 m_Instance.m_DeferredArray.Insert(dataDeferred);
233 static void Update(
float timeslice)
237 if (
g_Game.GetGameState() != DayZGameState.IN_GAME &&
g_Game.GetGameState() != DayZGameState.MAIN_MENU)
240 m_Instance.m_TimeElapsed += timeslice;
241 if (m_Instance.m_TimeElapsed >= UPDATE_INTERVAL_THRESHOLD)
246 if (visibleNotificationData.GetRemainingTime() <= 0.0)
247 expiredNotifications.Insert(visibleNotificationData);
249 visibleNotificationData.UpdateRemainingTime(UPDATE_INTERVAL_THRESHOLD);
254 m_Instance.m_OnNotificationRemoved.Invoke(expiredNotificationData);
255 m_Instance.m_TimeArray.RemoveItem(expiredNotificationData);
257 if (m_Instance.m_DeferredArray.Count() > 0)
259 int count = m_Instance.m_DeferredArray.Count();
261 m_Instance.m_TimeArray.Insert(deferredNotificationData);
262 m_Instance.m_OnNotificationAdded.Invoke(deferredNotificationData);
263 m_Instance.m_DeferredArray.Remove(count - 1);
267 m_Instance.m_TimeElapsed = 0;
274 if (m_DataArray.Contains(type))
275 return m_DataArray.Get(type);
280 static void LoadNotificationData()
288 m_Instance.m_DataArray.Copy(dataArray);
294 notificationTypes.Insert(notificationType);
298 for (
int i = 0; i < m_Instance.m_DataArray.Count(); ++i)
300 notificationTypes.RemoveItem(m_Instance.m_DataArray.GetKey(i));
303 if (notificationTypes.Count() > 0)
308 "please_add_an_icon",
309 "please_add_a_title",
310 "optional_description",
313 m_Instance.m_DataArray.Insert(notificationType2, notificationData);