Add support for transient text notifications matching speech notifications
This commit is contained in:
committed by
Paul Chote
parent
9f723be65a
commit
24b9482cc1
@@ -16,8 +16,12 @@ namespace OpenRA.Mods.Common.Traits.Sound
|
||||
class ActorLostNotificationInfo : ConditionalTraitInfo
|
||||
{
|
||||
[NotificationReference("Speech")]
|
||||
[Desc("Speech notification to play.")]
|
||||
public readonly string Notification = "UnitLost";
|
||||
|
||||
[Desc("Text notification to display.")]
|
||||
public readonly string TextNotification = null;
|
||||
|
||||
public readonly bool NotifyAll = false;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new ActorLostNotification(this); }
|
||||
@@ -33,8 +37,15 @@ namespace OpenRA.Mods.Common.Traits.Sound
|
||||
if (IsTraitDisabled)
|
||||
return;
|
||||
|
||||
var player = Info.NotifyAll ? self.World.LocalPlayer : self.Owner;
|
||||
var localPlayer = self.World.LocalPlayer;
|
||||
|
||||
if (localPlayer == null || localPlayer.Spectating)
|
||||
return;
|
||||
|
||||
var player = Info.NotifyAll ? localPlayer : self.Owner;
|
||||
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, player, "Speech", Info.Notification, self.Owner.Faction.InternalName);
|
||||
TextNotificationsManager.AddTransientLine(Info.TextNotification, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,12 @@ namespace OpenRA.Mods.Common.Traits.Sound
|
||||
public readonly bool PingRadar = false;
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
[Desc("Speech notification to play.")]
|
||||
public readonly string Notification = null;
|
||||
|
||||
[Desc("Text notification to display.")]
|
||||
public readonly string TextNotification = null;
|
||||
|
||||
public readonly bool AnnounceNeutrals = false;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new AnnounceOnSeen(init.Self, this); }
|
||||
@@ -56,6 +60,9 @@ namespace OpenRA.Mods.Common.Traits.Sound
|
||||
if (discoverer != null && !string.IsNullOrEmpty(Info.Notification))
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, discoverer, "Speech", Info.Notification, discoverer.Faction.InternalName);
|
||||
|
||||
if (discoverer != null)
|
||||
TextNotificationsManager.AddTransientLine(Info.TextNotification, discoverer);
|
||||
|
||||
// Radar notification
|
||||
if (Info.PingRadar)
|
||||
radarPings.Value?.Add(() => true, self.CenterPosition, Color.Red, 50);
|
||||
|
||||
@@ -17,16 +17,22 @@ namespace OpenRA.Mods.Common.Traits.Sound
|
||||
public class CaptureNotificationInfo : TraitInfo
|
||||
{
|
||||
[NotificationReference("Speech")]
|
||||
[Desc("The speech notification to play to the new owner.")]
|
||||
[Desc("Speech notification to play to the new owner.")]
|
||||
public readonly string Notification = "BuildingCaptured";
|
||||
|
||||
[Desc("Text notification to display to the new owner.")]
|
||||
public readonly string TextNotification = null;
|
||||
|
||||
[Desc("Specifies if Notification is played with the voice of the new owners faction.")]
|
||||
public readonly bool NewOwnerVoice = true;
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
[Desc("The speech notification to play to the old owner.")]
|
||||
[Desc("Speech notification to play to the old owner.")]
|
||||
public readonly string LoseNotification = null;
|
||||
|
||||
[Desc("Text notification to display to the old owner.")]
|
||||
public readonly string LoseTextNotification = null;
|
||||
|
||||
[Desc("Specifies if LoseNotification is played with the voice of the new owners faction.")]
|
||||
public readonly bool LoseNewOwnerVoice = false;
|
||||
|
||||
@@ -45,9 +51,11 @@ namespace OpenRA.Mods.Common.Traits.Sound
|
||||
{
|
||||
var faction = info.NewOwnerVoice ? newOwner.Faction.InternalName : oldOwner.Faction.InternalName;
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, newOwner, "Speech", info.Notification, faction);
|
||||
TextNotificationsManager.AddTransientLine(info.TextNotification, newOwner);
|
||||
|
||||
var loseFaction = info.LoseNewOwnerVoice ? newOwner.Faction.InternalName : oldOwner.Faction.InternalName;
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, oldOwner, "Speech", info.LoseNotification, loseFaction);
|
||||
TextNotificationsManager.AddTransientLine(info.LoseTextNotification, oldOwner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user