diff --git a/OpenRA.Mods.Common/Widgets/ProductionPaletteWidget.cs b/OpenRA.Mods.Common/Widgets/ProductionPaletteWidget.cs index 6a4654a255..a3ca17598d 100644 --- a/OpenRA.Mods.Common/Widgets/ProductionPaletteWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ProductionPaletteWidget.cs @@ -27,6 +27,8 @@ namespace OpenRA.Mods.Common.Widgets public Hotkey Hotkey; public Sprite Sprite; public PaletteReference Palette; + public PaletteReference IconClockPalette; + public PaletteReference IconDarkenPalette; public float2 Pos; public List Queued; } @@ -46,6 +48,14 @@ namespace OpenRA.Mods.Common.Widgets public readonly string TooltipContainer; public readonly string TooltipTemplate = "PRODUCTION_TOOLTIP"; + public readonly string ClockAnimation = "clock"; + public readonly string ClockSequence = "idle"; + public readonly string ClockPalette = "chrome"; + + public readonly string NotBuildableAnimation = "clock"; + public readonly string NotBuildableSequence = "idle"; + public readonly string NotBuildablePalette = "chrome"; + [Translate] public readonly string ReadyText = ""; [Translate] public readonly string HoldText = ""; @@ -89,9 +99,9 @@ namespace OpenRA.Mods.Common.Widgets tooltipContainer = Exts.Lazy(() => Ui.Root.Get(TooltipContainer)); - cantBuild = new Animation(world, "clock"); - cantBuild.PlayFetchIndex("idle", () => 0); - clock = new Animation(world, "clock"); + cantBuild = new Animation(world, NotBuildableAnimation); + cantBuild.PlayFetchIndex(NotBuildableSequence, () => 0); + clock = new Animation(world, ClockAnimation); } public void ScrollDown() @@ -322,6 +332,8 @@ namespace OpenRA.Mods.Common.Widgets Hotkey = ks.GetProductionHotkey(DisplayedIconCount), Sprite = icon.Image, Palette = worldRenderer.Palette(bi.IconPalette), + IconClockPalette = worldRenderer.Palette(ClockPalette), + IconDarkenPalette = worldRenderer.Palette(NotBuildablePalette), Pos = new float2(rect.Location), Queued = CurrentQueue.AllQueued().Where(a => a.Item == item.Name).ToList() }; @@ -367,15 +379,15 @@ namespace OpenRA.Mods.Common.Widgets if (icon.Queued.Count > 0) { var first = icon.Queued[0]; - clock.PlayFetchIndex("idle", + clock.PlayFetchIndex(ClockSequence, () => (first.TotalTime - first.RemainingTime) * (clock.CurrentSequence.Length - 1) / first.TotalTime); clock.Tick(); - WidgetUtils.DrawSHPCentered(clock.Image, icon.Pos + iconOffset, icon.Palette); + WidgetUtils.DrawSHPCentered(clock.Image, icon.Pos + iconOffset, icon.IconClockPalette); } else if (!buildableItems.Any(a => a.Name == icon.Name)) - WidgetUtils.DrawSHPCentered(cantBuild.Image, icon.Pos + iconOffset, icon.Palette); + WidgetUtils.DrawSHPCentered(cantBuild.Image, icon.Pos + iconOffset, icon.IconDarkenPalette); } // Overlays diff --git a/OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs b/OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs index 7af9bef3b4..bbbe88f62b 100644 --- a/OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs +++ b/OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs @@ -30,6 +30,10 @@ namespace OpenRA.Mods.Common.Widgets public readonly string TooltipContainer; public readonly string TooltipTemplate = "SUPPORT_POWER_TOOLTIP"; + public readonly string ClockAnimation = "clock"; + public readonly string ClockSequence = "idle"; + public readonly string ClockPalette = "chrome"; + public int IconCount { get; private set; } public event Action OnIconCountChanged = (a, b) => { }; @@ -57,7 +61,7 @@ namespace OpenRA.Mods.Common.Widgets Ui.Root.Get(TooltipContainer)); icon = new Animation(world, "icon"); - clock = new Animation(world, "clock"); + clock = new Animation(world, ClockAnimation); } public class SupportPowerIcon @@ -66,6 +70,7 @@ namespace OpenRA.Mods.Common.Widgets public float2 Pos; public Sprite Sprite; public PaletteReference Palette; + public PaletteReference IconClockPalette; public Hotkey Hotkey; } @@ -91,6 +96,7 @@ namespace OpenRA.Mods.Common.Widgets Pos = new float2(rect.Location), Sprite = icon.Image, Palette = worldRenderer.Palette(p.Info.IconPalette), + IconClockPalette = worldRenderer.Palette(ClockPalette), Hotkey = ks.GetSupportPowerHotkey(IconCount) }; @@ -145,12 +151,12 @@ namespace OpenRA.Mods.Common.Widgets // Charge progress var sp = p.Power; - clock.PlayFetchIndex("idle", + clock.PlayFetchIndex(ClockSequence, () => sp.TotalTime == 0 ? clock.CurrentSequence.Length - 1 : (sp.TotalTime - sp.RemainingTime) * (clock.CurrentSequence.Length - 1) / sp.TotalTime); clock.Tick(); - WidgetUtils.DrawSHPCentered(clock.Image, p.Pos + iconOffset, p.Palette); + WidgetUtils.DrawSHPCentered(clock.Image, p.Pos + iconOffset, p.IconClockPalette); } // Overlay