Add support for transient text notifications matching speech notifications
This commit is contained in:
committed by
Paul Chote
parent
9f723be65a
commit
24b9482cc1
@@ -61,18 +61,29 @@ namespace OpenRA.Mods.Common.Traits
|
||||
"The filename of the audio is defined per faction in notifications.yaml.")]
|
||||
public readonly string ReadyAudio = null;
|
||||
|
||||
[Desc("Notification displayed when production is complete.")]
|
||||
public readonly string ReadyTextNotification = null;
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
[Desc("Notification played when you can't train another actor",
|
||||
"when the build limit exceeded or the exit is jammed.",
|
||||
"The filename of the audio is defined per faction in notifications.yaml.")]
|
||||
public readonly string BlockedAudio = null;
|
||||
|
||||
[Desc("Notification displayed when you can't train another actor",
|
||||
"when the build limit exceeded or the exit is jammed.")]
|
||||
public readonly string BlockedTextNotification = null;
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
[Desc("Notification played when you can't queue another actor",
|
||||
"when the queue length limit is exceeded.",
|
||||
"The filename of the audio is defined per faction in notifications.yaml.")]
|
||||
public readonly string LimitedAudio = null;
|
||||
|
||||
[Desc("Notification displayed when you can't queue another actor",
|
||||
"when the queue length limit is exceeded.")]
|
||||
public readonly string LimitedTextNotification = null;
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
[Desc("Notification played when you can't place a building.",
|
||||
"Overrides PlaceBuilding.CannotPlaceNotification for this queue.",
|
||||
@@ -84,16 +95,25 @@ namespace OpenRA.Mods.Common.Traits
|
||||
"The filename of the audio is defined per faction in notifications.yaml.")]
|
||||
public readonly string QueuedAudio = null;
|
||||
|
||||
[Desc("Notification displayed when user clicks on the build palette icon.")]
|
||||
public readonly string QueuedTextNotification = null;
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
[Desc("Notification played when player right-clicks on the build palette icon.",
|
||||
"The filename of the audio is defined per faction in notifications.yaml.")]
|
||||
public readonly string OnHoldAudio = null;
|
||||
|
||||
[Desc("Notification displayed when player right-clicks on the build palette icon.")]
|
||||
public readonly string OnHoldTextNotification = null;
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
[Desc("Notification played when player right-clicks on a build palette icon that is already on hold.",
|
||||
"The filename of the audio is defined per faction in notifications.yaml.")]
|
||||
public readonly string CancelledAudio = null;
|
||||
|
||||
[Desc("Notification displayed when player right-clicks on a build palette icon that is already on hold.")]
|
||||
public readonly string CancelledTextNotification = null;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new ProductionQueue(init, this); }
|
||||
|
||||
public void RulesetLoaded(Ruleset rules, ActorInfo ai)
|
||||
@@ -333,9 +353,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanQueue(ActorInfo actor, out string notificationAudio)
|
||||
public bool CanQueue(ActorInfo actor, out string notificationAudio, out string notificationText)
|
||||
{
|
||||
notificationAudio = Info.BlockedAudio;
|
||||
notificationText = Info.BlockedTextNotification;
|
||||
|
||||
var bi = actor.TraitInfoOrDefault<BuildableInfo>();
|
||||
if (bi == null)
|
||||
@@ -346,6 +367,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (Info.QueueLimit > 0 && Queue.Count >= Info.QueueLimit)
|
||||
{
|
||||
notificationAudio = Info.LimitedAudio;
|
||||
notificationText = Info.LimitedTextNotification;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -353,6 +375,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (Info.ItemLimit > 0 && queueCount >= Info.ItemLimit)
|
||||
{
|
||||
notificationAudio = Info.LimitedAudio;
|
||||
notificationText = Info.LimitedTextNotification;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -366,6 +389,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
notificationAudio = Info.QueuedAudio;
|
||||
notificationText = Info.QueuedTextNotification;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -424,13 +448,22 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var isBuilding = unit.HasTraitInfo<BuildingInfo>();
|
||||
if (isBuilding && !hasPlayedSound)
|
||||
{
|
||||
hasPlayedSound = Game.Sound.PlayNotification(rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Faction.InternalName);
|
||||
TextNotificationsManager.AddTransientLine(Info.ReadyTextNotification, self.Owner);
|
||||
}
|
||||
else if (!isBuilding)
|
||||
{
|
||||
if (BuildUnit(unit))
|
||||
{
|
||||
Game.Sound.PlayNotification(rules, self.Owner, "Speech", Info.ReadyAudio, self.Owner.Faction.InternalName);
|
||||
TextNotificationsManager.AddTransientLine(Info.ReadyTextNotification, self.Owner);
|
||||
}
|
||||
else if (!hasPlayedSound && time > 0)
|
||||
{
|
||||
hasPlayedSound = Game.Sound.PlayNotification(rules, self.Owner, "Speech", Info.BlockedAudio, self.Owner.Faction.InternalName);
|
||||
TextNotificationsManager.AddTransientLine(Info.BlockedTextNotification, self.Owner);
|
||||
}
|
||||
}
|
||||
})), !order.Queued);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user