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 {
var Text title;
var Text body;
var float time;
var float duration;
};
var private array<Notification> 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);
}

Loading…
Cancel
Save