Add support for transient text notifications matching speech notifications

This commit is contained in:
Ivaylo Draganov
2022-01-08 18:28:25 +02:00
committed by Paul Chote
parent 9f723be65a
commit 24b9482cc1
50 changed files with 372 additions and 46 deletions

View File

@@ -18,17 +18,19 @@ namespace OpenRA.Mods.Common.Activities
class RepairBridge : Enter
{
readonly EnterBehaviour enterBehaviour;
readonly string notification;
readonly string speechNotification;
readonly string textNotification;
Actor enterActor;
BridgeHut enterHut;
LegacyBridgeHut enterLegacyHut;
public RepairBridge(Actor self, in Target target, EnterBehaviour enterBehaviour, string notification, Color targetLineColor)
public RepairBridge(Actor self, in Target target, EnterBehaviour enterBehaviour, string speechNotification, string textNotification, Color targetLineColor)
: base(self, target, targetLineColor)
{
this.enterBehaviour = enterBehaviour;
this.notification = notification;
this.speechNotification = speechNotification;
this.textNotification = textNotification;
}
bool CanEnterHut()
@@ -75,7 +77,8 @@ namespace OpenRA.Mods.Common.Activities
else if (enterHut != null)
enterHut.Repair(self);
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", notification, self.Owner.Faction.InternalName);
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", speechNotification, self.Owner.Faction.InternalName);
TextNotificationsManager.AddTransientLine(textNotification, self.Owner);
if (enterBehaviour == EnterBehaviour.Dispose)
self.Dispose();

View File

@@ -262,6 +262,7 @@ namespace OpenRA.Mods.Common.Activities
host.Actor.Owner.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(repairsUnits.Info.PlayerExperience);
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", repairsUnits.Info.FinishRepairingNotification, self.Owner.Faction.InternalName);
TextNotificationsManager.AddTransientLine(repairsUnits.Info.FinishRepairingTextNotification, self.Owner);
activeResupplyTypes &= ~ResupplyType.Repair;
return;
@@ -279,6 +280,7 @@ namespace OpenRA.Mods.Common.Activities
{
played = true;
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", repairsUnits.Info.StartRepairingNotification, self.Owner.Faction.InternalName);
TextNotificationsManager.AddTransientLine(repairsUnits.Info.StartRepairingTextNotification, self.Owner);
}
if (!playerResources.TakeCash(cost, true))

View File

@@ -49,6 +49,7 @@ namespace OpenRA.Mods.Common.Activities
self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, self.Owner.Color, FloatingText.FormatCashTick(refund), 30)));
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", sellableInfo.Notification, self.Owner.Faction.InternalName);
TextNotificationsManager.AddTransientLine(sellableInfo.TextNotification, self.Owner);
self.Dispose();
return false;

View File

@@ -26,6 +26,7 @@ namespace OpenRA.Mods.Common.Activities
public WAngle Facing = new WAngle(384);
public string[] Sounds = Array.Empty<string>();
public string Notification = null;
public string TextNotification = null;
public int ForceHealthPercentage = 0;
public bool SkipMakeAnims = false;
public string Faction = null;
@@ -95,6 +96,7 @@ namespace OpenRA.Mods.Common.Activities
Game.Sound.PlayToPlayer(SoundType.World, self.Owner, s, self.CenterPosition);
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Notification, self.Owner.Faction.InternalName);
TextNotificationsManager.AddTransientLine(TextNotification, self.Owner);
var init = new TypeDictionary
{