From 38e52c062e1b13b8ddfe86ade54986993f7327aa Mon Sep 17 00:00:00 2001 From: michaeldgg2 <119738087+michaeldgg2@users.noreply.github.com> Date: Wed, 25 Jan 2023 11:41:32 +0100 Subject: [PATCH] ProductionTabsWidget: allow customizing left/right arrow buttons. This moves initialization of Initialize getters for left/right arrow image from constructor Initialize method making it possible to override fields Decorations, DecorationScrollLeft and DecorationScrollRight after widget creation. --- OpenRA.Mods.Common/Widgets/ProductionTabsWidget.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/ProductionTabsWidget.cs b/OpenRA.Mods.Common/Widgets/ProductionTabsWidget.cs index cf8af1f268..93d03cc4cc 100644 --- a/OpenRA.Mods.Common/Widgets/ProductionTabsWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ProductionTabsWidget.cs @@ -86,8 +86,8 @@ namespace OpenRA.Mods.Common.Widgets public readonly string Decorations = "scrollpanel-decorations"; public readonly string DecorationScrollLeft = "left"; public readonly string DecorationScrollRight = "right"; - readonly CachedTransform<(bool Disabled, bool Pressed, bool Hover, bool Focused, bool Highlighted), Sprite> getLeftArrowImage; - readonly CachedTransform<(bool Disabled, bool Pressed, bool Hover, bool Focused, bool Highlighted), Sprite> getRightArrowImage; + CachedTransform<(bool Disabled, bool Pressed, bool Hover, bool Focused, bool Highlighted), Sprite> getLeftArrowImage; + CachedTransform<(bool Disabled, bool Pressed, bool Hover, bool Focused, bool Highlighted), Sprite> getRightArrowImage; int contentWidth = 0; float listOffset = 0; @@ -111,9 +111,6 @@ namespace OpenRA.Mods.Common.Widgets IsVisible = () => queueGroup != null && Groups[queueGroup].Tabs.Count > 0; paletteWidget = Exts.Lazy(() => Ui.Root.Get(PaletteWidget)); - - getLeftArrowImage = WidgetUtils.GetCachedStatefulImage(Decorations, DecorationScrollLeft); - getRightArrowImage = WidgetUtils.GetCachedStatefulImage(Decorations, DecorationScrollRight); } public override void Initialize(WidgetArgs args) @@ -124,6 +121,9 @@ namespace OpenRA.Mods.Common.Widgets leftButtonRect = new Rectangle(rb.X, rb.Y, ArrowWidth, rb.Height); rightButtonRect = new Rectangle(rb.Right - ArrowWidth, rb.Y, ArrowWidth, rb.Height); font = Game.Renderer.Fonts["TinyBold"]; + + getLeftArrowImage = WidgetUtils.GetCachedStatefulImage(Decorations, DecorationScrollLeft); + getRightArrowImage = WidgetUtils.GetCachedStatefulImage(Decorations, DecorationScrollRight); } public bool SelectNextTab(bool reverse)