fn_addNotification.sqf 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Author: Gundy
  3. *
  4. * Description:
  5. * Add a notification
  6. *
  7. * Arguments:
  8. * 0: App ID <STRING>
  9. * 1: Notification <STRING>
  10. * 2: Decay time in seconds <INTEGER>
  11. *
  12. * Return Value:
  13. * TRUE <BOOL>
  14. *
  15. * Example:
  16. * [_appID,"This is a notification",5] call cTab_fnc_addNotification;
  17. *
  18. * Public: No
  19. */
  20. private ["_appID","_notification","_time","_done","_decayTime"];
  21. _appID = _this select 0;
  22. _notification = _this select 1;
  23. _decayTime = _this select 2;
  24. _time = [] call cTab_fnc_currentTime;
  25. _done = false;
  26. // search for other _appID notifications
  27. {
  28. // if we find one, override it and increase the counter
  29. if ((_x select 0) isEqualTo _appID) exitWith {
  30. cTabNotificationCache set [_forEachIndex,[_appID,_time,_notification,_decayTime,(_x select 4) + 1]];
  31. _done = true;
  32. };
  33. } forEach cTabNotificationCache;
  34. // if we haven't added the notification to the cache above, do it now
  35. if !(_done) then {
  36. cTabNotificationCache pushBack [_appID,_time,_notification,_decayTime,1];
  37. };
  38. [] call cTab_fnc_processNotifications;
  39. true