Browse Source

Fix noficications not respecting provided duration time

pull/12/head
Anton Tarasenko 2 years ago
parent
commit
fed80cc76b
  1. 15
      sources/Players/PlayerNotificationQueue.uc

15
sources/Players/PlayerNotificationQueue.uc

@ -28,7 +28,7 @@ class PlayerNotificationQueue extends AcediaObject
struct Notification { struct Notification {
var Text title; var Text title;
var Text body; var Text body;
var float time; var float duration;
}; };
var private array<Notification> notificationQueue; var private array<Notification> notificationQueue;
/// Reference to the `PlayerController` for the player that owns this queue /// Reference to the `PlayerController` for the player that owns this queue
@ -81,7 +81,7 @@ public final /*native*/ function SetupController(NativeActorRef newPlayerControl
} }
/// Add new notification to the queue /// Add new notification to the queue
public final function AddNotification(BaseText title, BaseText body, float time) { public final function AddNotification(BaseText title, BaseText body, float duration) {
local Notification newNotification; local Notification newNotification;
if (body == none) { if (body == none) {
@ -91,6 +91,7 @@ public final function AddNotification(BaseText title, BaseText body, float time)
newNotification.title = title.Copy(); newNotification.title = title.Copy();
} }
newNotification.body = body.Copy(); newNotification.body = body.Copy();
newNotification.duration = duration;
notificationQueue[notificationQueue.length] = newNotification; notificationQueue[notificationQueue.length] = newNotification;
if (!IsUpdateScheduled()) { if (!IsUpdateScheduled()) {
SetupNextNotification(none); SetupNextNotification(none);
@ -193,14 +194,14 @@ private function SetupNextNotification(Timer callerInstance) {
} }
nextNotification = notificationQueue[0]; nextNotification = notificationQueue[0];
notificationQueue.Remove(0, 1); notificationQueue.Remove(0, 1);
nextNotification.time = FMin(nextNotification.time, maximumNotifyTime); nextNotification.duration = FMin(nextNotification.duration, maximumNotifyTime);
if (nextNotification.time <= 0) { if (nextNotification.duration <= 0) {
nextNotification.time = 10.0; nextNotification.duration = 10.0;
} }
// And print // And print
playerController.ClearProgressMessages(); playerController.ClearProgressMessages();
playerController.SetProgressTime(nextNotification.time); playerController.SetProgressTime(nextNotification.duration);
if (nextNotification.title != none) { if (nextNotification.title != none) {
upperCaseTitle = nextNotification.title.UpperMutableCopy(); upperCaseTitle = nextNotification.title.UpperMutableCopy();
upperCaseTitle.ChangeDefaultColor(_.color.TextHeader); upperCaseTitle.ChangeDefaultColor(_.color.TextHeader);
@ -209,7 +210,7 @@ private function SetupNextNotification(Timer callerInstance) {
_.memory.Free(upperCaseTitle); _.memory.Free(upperCaseTitle);
} }
PrintNotifcationAt(playerController, nextNotification.body, titleShift, 4 - titleShift); PrintNotifcationAt(playerController, nextNotification.body, titleShift, 4 - titleShift);
ScheduleUpdate(nextNotification.time); ScheduleUpdate(nextNotification.duration);
_.memory.Free2(nextNotification.title, nextNotification.body); _.memory.Free2(nextNotification.title, nextNotification.body);
} }

Loading…
Cancel
Save