From 39034b0de9af0fac11a825f61b9381ac218d7d30 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sun, 15 May 2016 22:31:44 +0200 Subject: [PATCH] Allow keeping empty selection bars visible --- OpenRA.Game/Graphics/SelectionBarsRenderable.cs | 2 +- OpenRA.Game/Traits/TraitsInterfaces.cs | 2 +- OpenRA.Mods.Common/Traits/Buildings/BaseProvider.cs | 1 + OpenRA.Mods.Common/Traits/ExternalCapturableBar.cs | 1 + OpenRA.Mods.Common/Traits/Power/AffectedByPowerOutage.cs | 2 ++ OpenRA.Mods.Common/Traits/Render/ProductionBar.cs | 1 + OpenRA.Mods.Common/Traits/Render/SupportPowerChargeBar.cs | 1 + OpenRA.Mods.Common/Traits/Render/TimedUpgradeBar.cs | 1 + OpenRA.Mods.D2k/Traits/TemporaryOwnerManager.cs | 2 ++ OpenRA.Mods.RA/Traits/Chronoshiftable.cs | 1 + OpenRA.Mods.RA/Traits/PortableChrono.cs | 1 + 11 files changed, 13 insertions(+), 2 deletions(-) diff --git a/OpenRA.Game/Graphics/SelectionBarsRenderable.cs b/OpenRA.Game/Graphics/SelectionBarsRenderable.cs index 9a07a4838d..2b6e63fd62 100644 --- a/OpenRA.Game/Graphics/SelectionBarsRenderable.cs +++ b/OpenRA.Game/Graphics/SelectionBarsRenderable.cs @@ -53,7 +53,7 @@ namespace OpenRA.Graphics foreach (var extraBar in actor.TraitsImplementing()) { var value = extraBar.GetValue(); - if (value != 0) + if (value != 0 || extraBar.DisplayWhenEmpty) { start.Y += (int)(4 / wr.Viewport.Zoom); end.Y += (int)(4 / wr.Viewport.Zoom); diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 50db274031..b7537eb0ed 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -280,7 +280,7 @@ namespace OpenRA.Traits public interface IPips { IEnumerable GetPips(Actor self); } [RequireExplicitImplementation] - public interface ISelectionBar { float GetValue(); Color GetColor(); } + public interface ISelectionBar { float GetValue(); Color GetColor(); bool DisplayWhenEmpty { get; } } public interface IPositionableInfo : ITraitInfoInterface { } public interface IPositionable : IOccupySpace diff --git a/OpenRA.Mods.Common/Traits/Buildings/BaseProvider.cs b/OpenRA.Mods.Common/Traits/Buildings/BaseProvider.cs index 599138d4e1..ce3d99871c 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/BaseProvider.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/BaseProvider.cs @@ -95,5 +95,6 @@ namespace OpenRA.Mods.Common.Traits } Color ISelectionBar.GetColor() { return Color.Purple; } + bool ISelectionBar.DisplayWhenEmpty { get { return false; } } } } diff --git a/OpenRA.Mods.Common/Traits/ExternalCapturableBar.cs b/OpenRA.Mods.Common/Traits/ExternalCapturableBar.cs index 4e38e41405..9ceb8f623c 100644 --- a/OpenRA.Mods.Common/Traits/ExternalCapturableBar.cs +++ b/OpenRA.Mods.Common/Traits/ExternalCapturableBar.cs @@ -39,5 +39,6 @@ namespace OpenRA.Mods.Common.Traits } Color ISelectionBar.GetColor() { return Color.Orange; } + bool ISelectionBar.DisplayWhenEmpty { get { return false; } } } } diff --git a/OpenRA.Mods.Common/Traits/Power/AffectedByPowerOutage.cs b/OpenRA.Mods.Common/Traits/Power/AffectedByPowerOutage.cs index 2d55f9902a..19d77e71df 100644 --- a/OpenRA.Mods.Common/Traits/Power/AffectedByPowerOutage.cs +++ b/OpenRA.Mods.Common/Traits/Power/AffectedByPowerOutage.cs @@ -42,6 +42,8 @@ namespace OpenRA.Mods.Common.Traits return Color.Yellow; } + bool ISelectionBar.DisplayWhenEmpty { get { return false; } } + public int GetPowerModifier() { return playerPower.PowerOutageRemainingTicks > 0 ? 0 : 100; diff --git a/OpenRA.Mods.Common/Traits/Render/ProductionBar.cs b/OpenRA.Mods.Common/Traits/Render/ProductionBar.cs index 3f57e6acf1..707c5f6246 100644 --- a/OpenRA.Mods.Common/Traits/Render/ProductionBar.cs +++ b/OpenRA.Mods.Common/Traits/Render/ProductionBar.cs @@ -81,6 +81,7 @@ namespace OpenRA.Mods.Common.Traits.Render } Color ISelectionBar.GetColor() { return info.Color; } + bool ISelectionBar.DisplayWhenEmpty { get { return false; } } public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) { diff --git a/OpenRA.Mods.Common/Traits/Render/SupportPowerChargeBar.cs b/OpenRA.Mods.Common/Traits/Render/SupportPowerChargeBar.cs index 8297b1ff68..80a0a7c3da 100644 --- a/OpenRA.Mods.Common/Traits/Render/SupportPowerChargeBar.cs +++ b/OpenRA.Mods.Common/Traits/Render/SupportPowerChargeBar.cs @@ -53,6 +53,7 @@ namespace OpenRA.Mods.Common.Traits.Render } Color ISelectionBar.GetColor() { return info.Color; } + bool ISelectionBar.DisplayWhenEmpty { get { return false; } } void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) { diff --git a/OpenRA.Mods.Common/Traits/Render/TimedUpgradeBar.cs b/OpenRA.Mods.Common/Traits/Render/TimedUpgradeBar.cs index cd7fba2465..7298e40f8f 100644 --- a/OpenRA.Mods.Common/Traits/Render/TimedUpgradeBar.cs +++ b/OpenRA.Mods.Common/Traits/Render/TimedUpgradeBar.cs @@ -57,5 +57,6 @@ namespace OpenRA.Mods.Common.Traits.Render } Color ISelectionBar.GetColor() { return info.Color; } + bool ISelectionBar.DisplayWhenEmpty { get { return false; } } } } diff --git a/OpenRA.Mods.D2k/Traits/TemporaryOwnerManager.cs b/OpenRA.Mods.D2k/Traits/TemporaryOwnerManager.cs index 6466e9e278..1278f8cd0e 100644 --- a/OpenRA.Mods.D2k/Traits/TemporaryOwnerManager.cs +++ b/OpenRA.Mods.D2k/Traits/TemporaryOwnerManager.cs @@ -79,5 +79,7 @@ namespace OpenRA.Mods.D2k.Traits { return info.BarColor; } + + bool ISelectionBar.DisplayWhenEmpty { get { return false; } } } } diff --git a/OpenRA.Mods.RA/Traits/Chronoshiftable.cs b/OpenRA.Mods.RA/Traits/Chronoshiftable.cs index 8835ba97f0..5fe80cb98c 100644 --- a/OpenRA.Mods.RA/Traits/Chronoshiftable.cs +++ b/OpenRA.Mods.RA/Traits/Chronoshiftable.cs @@ -128,6 +128,7 @@ namespace OpenRA.Mods.RA.Traits } Color ISelectionBar.GetColor() { return info.TimeBarColor; } + bool ISelectionBar.DisplayWhenEmpty { get { return false; } } public void ModifyDeathActorInit(Actor self, TypeDictionary init) { diff --git a/OpenRA.Mods.RA/Traits/PortableChrono.cs b/OpenRA.Mods.RA/Traits/PortableChrono.cs index ac14f32bee..3c4377afb0 100644 --- a/OpenRA.Mods.RA/Traits/PortableChrono.cs +++ b/OpenRA.Mods.RA/Traits/PortableChrono.cs @@ -118,6 +118,7 @@ namespace OpenRA.Mods.RA.Traits } Color ISelectionBar.GetColor() { return Color.Magenta; } + bool ISelectionBar.DisplayWhenEmpty { get { return false; } } } class PortableChronoOrderTargeter : IOrderTargeter