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.
This commit is contained in:
@@ -86,8 +86,8 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
public readonly string Decorations = "scrollpanel-decorations";
|
public readonly string Decorations = "scrollpanel-decorations";
|
||||||
public readonly string DecorationScrollLeft = "left";
|
public readonly string DecorationScrollLeft = "left";
|
||||||
public readonly string DecorationScrollRight = "right";
|
public readonly string DecorationScrollRight = "right";
|
||||||
readonly 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> 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> getRightArrowImage;
|
||||||
|
|
||||||
int contentWidth = 0;
|
int contentWidth = 0;
|
||||||
float listOffset = 0;
|
float listOffset = 0;
|
||||||
@@ -111,9 +111,6 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
IsVisible = () => queueGroup != null && Groups[queueGroup].Tabs.Count > 0;
|
IsVisible = () => queueGroup != null && Groups[queueGroup].Tabs.Count > 0;
|
||||||
|
|
||||||
paletteWidget = Exts.Lazy(() => Ui.Root.Get<ProductionPaletteWidget>(PaletteWidget));
|
paletteWidget = Exts.Lazy(() => Ui.Root.Get<ProductionPaletteWidget>(PaletteWidget));
|
||||||
|
|
||||||
getLeftArrowImage = WidgetUtils.GetCachedStatefulImage(Decorations, DecorationScrollLeft);
|
|
||||||
getRightArrowImage = WidgetUtils.GetCachedStatefulImage(Decorations, DecorationScrollRight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Initialize(WidgetArgs args)
|
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);
|
leftButtonRect = new Rectangle(rb.X, rb.Y, ArrowWidth, rb.Height);
|
||||||
rightButtonRect = new Rectangle(rb.Right - ArrowWidth, rb.Y, ArrowWidth, rb.Height);
|
rightButtonRect = new Rectangle(rb.Right - ArrowWidth, rb.Y, ArrowWidth, rb.Height);
|
||||||
font = Game.Renderer.Fonts["TinyBold"];
|
font = Game.Renderer.Fonts["TinyBold"];
|
||||||
|
|
||||||
|
getLeftArrowImage = WidgetUtils.GetCachedStatefulImage(Decorations, DecorationScrollLeft);
|
||||||
|
getRightArrowImage = WidgetUtils.GetCachedStatefulImage(Decorations, DecorationScrollRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SelectNextTab(bool reverse)
|
public bool SelectNextTab(bool reverse)
|
||||||
|
|||||||
Reference in New Issue
Block a user