From fed80cc76be9f4a9169d53bc47e93b2ea3088745 Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Sun, 19 Mar 2023 17:39:47 +0700 Subject: [PATCH] Fix noficications not respecting provided duration time --- sources/Players/PlayerNotificationQueue.uc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sources/Players/PlayerNotificationQueue.uc b/sources/Players/PlayerNotificationQueue.uc index 968d619..5880e1f 100644 --- a/sources/Players/PlayerNotificationQueue.uc +++ b/sources/Players/PlayerNotificationQueue.uc @@ -28,7 +28,7 @@ class PlayerNotificationQueue extends AcediaObject struct Notification { var Text title; var Text body; - var float time; + var float duration; }; var private array notificationQueue; /// 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 -public final function AddNotification(BaseText title, BaseText body, float time) { +public final function AddNotification(BaseText title, BaseText body, float duration) { local Notification newNotification; if (body == none) { @@ -91,6 +91,7 @@ public final function AddNotification(BaseText title, BaseText body, float time) newNotification.title = title.Copy(); } newNotification.body = body.Copy(); + newNotification.duration = duration; notificationQueue[notificationQueue.length] = newNotification; if (!IsUpdateScheduled()) { SetupNextNotification(none); @@ -193,14 +194,14 @@ private function SetupNextNotification(Timer callerInstance) { } nextNotification = notificationQueue[0]; notificationQueue.Remove(0, 1); - nextNotification.time = FMin(nextNotification.time, maximumNotifyTime); - if (nextNotification.time <= 0) { - nextNotification.time = 10.0; + nextNotification.duration = FMin(nextNotification.duration, maximumNotifyTime); + if (nextNotification.duration <= 0) { + nextNotification.duration = 10.0; } // And print playerController.ClearProgressMessages(); - playerController.SetProgressTime(nextNotification.time); + playerController.SetProgressTime(nextNotification.duration); if (nextNotification.title != none) { upperCaseTitle = nextNotification.title.UpperMutableCopy(); upperCaseTitle.ChangeDefaultColor(_.color.TextHeader); @@ -209,7 +210,7 @@ private function SetupNextNotification(Timer callerInstance) { _.memory.Free(upperCaseTitle); } PrintNotifcationAt(playerController, nextNotification.body, titleShift, 4 - titleShift); - ScheduleUpdate(nextNotification.time); + ScheduleUpdate(nextNotification.duration); _.memory.Free2(nextNotification.title, nextNotification.body); }