Add support for transient text notifications matching speech notifications
This commit is contained in:
committed by
Paul Chote
parent
9f723be65a
commit
24b9482cc1
@@ -27,9 +27,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly WVec SquadOffset = new WVec(-1536, 1536, 0);
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
[Desc("Notification to play when entering the drop zone.")]
|
||||
[Desc("Speech notification to play when entering the drop zone.")]
|
||||
public readonly string ReinforcementsArrivedSpeechNotification = null;
|
||||
|
||||
[Desc("Text notification to display when entering the drop zone.")]
|
||||
public readonly string ReinforcementsArrivedTextNotification = null;
|
||||
|
||||
[Desc("Number of facings that the delivery aircraft may approach from.")]
|
||||
public readonly int QuantizedFacings = 32;
|
||||
|
||||
@@ -134,9 +137,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
RemoveBeacon(beacon);
|
||||
|
||||
if (!aircraftInRange.Any(kv => kv.Value))
|
||||
{
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
|
||||
info.ReinforcementsArrivedSpeechNotification, self.Owner.Faction.InternalName);
|
||||
|
||||
TextNotificationsManager.AddTransientLine(info.ReinforcementsArrivedTextNotification, self.Owner);
|
||||
}
|
||||
|
||||
aircraftInRange[a] = true;
|
||||
};
|
||||
|
||||
|
||||
@@ -28,15 +28,21 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly string Type = null;
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
[Desc("Notification played when production is activated.",
|
||||
[Desc("Speech notification played when production is activated.",
|
||||
"The filename of the audio is defined per faction in notifications.yaml.")]
|
||||
public readonly string ReadyAudio = null;
|
||||
|
||||
[Desc("Text notification displayed when production is activated.")]
|
||||
public readonly string ReadyTextNotification = null;
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
[Desc("Notification played when the exit is jammed.",
|
||||
[Desc("Speech notification played when the exit is jammed.",
|
||||
"The filename of the audio is defined per faction in notifications.yaml.")]
|
||||
public readonly string BlockedAudio = null;
|
||||
|
||||
[Desc("Text notification displayed when the exit is jammed.")]
|
||||
public readonly string BlockedTextNotification = null;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new ProduceActorPower(init, this); }
|
||||
}
|
||||
|
||||
@@ -91,9 +97,15 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
if (activated)
|
||||
{
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, manager.Self.Owner, "Speech", info.ReadyAudio, self.Owner.Faction.InternalName);
|
||||
TextNotificationsManager.AddTransientLine(info.ReadyTextNotification, manager.Self.Owner);
|
||||
}
|
||||
else
|
||||
{
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, manager.Self.Owner, "Speech", info.BlockedAudio, self.Owner.Faction.InternalName);
|
||||
TextNotificationsManager.AddTransientLine(info.BlockedTextNotification, manager.Self.Owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,6 +95,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Game.Sound.PlayToPlayer(SoundType.UI, manager.Self.Owner, Info.SelectTargetSound);
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
|
||||
Info.SelectTargetSpeechNotification, self.Owner.Faction.InternalName);
|
||||
|
||||
TextNotificationsManager.AddTransientLine(Info.SelectTargetTextNotification, manager.Self.Owner);
|
||||
|
||||
self.World.OrderGenerator = new SelectSpawnActorPowerTarget(order, manager, this, MouseButton.Left);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,36 +53,50 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[NotificationReference("Speech")]
|
||||
public readonly string DetectedSpeechNotification = null;
|
||||
|
||||
public readonly string DetectedTextNotification = null;
|
||||
|
||||
public readonly string BeginChargeSound = null;
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
public readonly string BeginChargeSpeechNotification = null;
|
||||
|
||||
public readonly string BeginChargeTextNotification = null;
|
||||
|
||||
public readonly string EndChargeSound = null;
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
public readonly string EndChargeSpeechNotification = null;
|
||||
|
||||
public readonly string EndChargeTextNotification = null;
|
||||
|
||||
public readonly string SelectTargetSound = null;
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
public readonly string SelectTargetSpeechNotification = null;
|
||||
|
||||
public readonly string SelectTargetTextNotification = null;
|
||||
|
||||
public readonly string InsufficientPowerSound = null;
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
public readonly string InsufficientPowerSpeechNotification = null;
|
||||
|
||||
public readonly string InsufficientPowerTextNotification = null;
|
||||
|
||||
public readonly string LaunchSound = null;
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
public readonly string LaunchSpeechNotification = null;
|
||||
|
||||
public readonly string LaunchTextNotification = null;
|
||||
|
||||
public readonly string IncomingSound = null;
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
public readonly string IncomingSpeechNotification = null;
|
||||
|
||||
public readonly string IncomingTextNotification = null;
|
||||
|
||||
[Desc("Defines to which players the timer is shown.")]
|
||||
public readonly PlayerRelationship DisplayTimerRelationships = PlayerRelationship.None;
|
||||
|
||||
@@ -147,11 +161,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
base.Created(self);
|
||||
|
||||
var renderPlayer = self.World.RenderPlayer;
|
||||
if (renderPlayer != null && renderPlayer != self.Owner)
|
||||
var player = self.World.LocalPlayer;
|
||||
if (player != null && player != self.Owner)
|
||||
{
|
||||
Game.Sound.Play(SoundType.UI, Info.DetectedSound);
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, renderPlayer, "Speech", info.DetectedSpeechNotification, renderPlayer.Faction.InternalName);
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, player, "Speech", info.DetectedSpeechNotification, player.Faction.InternalName);
|
||||
TextNotificationsManager.AddTransientLine(info.DetectedTextNotification, player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,6 +180,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Game.Sound.PlayToPlayer(SoundType.UI, self.Owner, Info.BeginChargeSound);
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
|
||||
Info.BeginChargeSpeechNotification, self.Owner.Faction.InternalName);
|
||||
|
||||
TextNotificationsManager.AddTransientLine(Info.BeginChargeTextNotification, self.Owner);
|
||||
}
|
||||
|
||||
public virtual void Charged(Actor self, string key)
|
||||
@@ -173,6 +190,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
|
||||
Info.EndChargeSpeechNotification, self.Owner.Faction.InternalName);
|
||||
|
||||
TextNotificationsManager.AddTransientLine(Info.EndChargeTextNotification, self.Owner);
|
||||
|
||||
foreach (var notify in self.TraitsImplementing<INotifySupportPower>())
|
||||
notify.Charged(self);
|
||||
}
|
||||
@@ -199,13 +218,19 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public virtual void PlayLaunchSounds()
|
||||
{
|
||||
var renderPlayer = Self.World.RenderPlayer;
|
||||
var isAllied = Self.Owner.IsAlliedWith(renderPlayer);
|
||||
var localPlayer = Self.World.LocalPlayer;
|
||||
|
||||
if (localPlayer == null || localPlayer.Spectating)
|
||||
return;
|
||||
|
||||
var isAllied = Self.Owner.IsAlliedWith(localPlayer);
|
||||
Game.Sound.Play(SoundType.UI, isAllied ? Info.LaunchSound : Info.IncomingSound);
|
||||
|
||||
var toPlayer = isAllied ? renderPlayer ?? Self.Owner : renderPlayer;
|
||||
var toPlayer = isAllied ? localPlayer ?? Self.Owner : localPlayer;
|
||||
var speech = isAllied ? Info.LaunchSpeechNotification : Info.IncomingSpeechNotification;
|
||||
Game.Sound.PlayNotification(Self.World.Map.Rules, toPlayer, "Speech", speech, toPlayer.Faction.InternalName);
|
||||
|
||||
TextNotificationsManager.AddTransientLine(isAllied ? Info.LaunchTextNotification : Info.IncomingTextNotification, toPlayer);
|
||||
}
|
||||
|
||||
public IEnumerable<CPos> CellsMatching(CPos location, char[] footprint, CVec dimensions)
|
||||
|
||||
@@ -231,6 +231,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Game.Sound.PlayNotification(power.Self.World.Map.Rules, power.Self.Owner, "Speech",
|
||||
Info.SelectTargetSpeechNotification, power.Self.Owner.Faction.InternalName);
|
||||
|
||||
TextNotificationsManager.AddTransientLine(Info.SelectTargetTextNotification, power.Self.Owner);
|
||||
|
||||
power.SelectTarget(power.Self, Key, Manager);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user