diff --git a/OpenRA.Mods.Common/Widgets/BackgroundWidget.cs b/OpenRA.Mods.Common/Widgets/BackgroundWidget.cs index eb6aa3adaf..4012e8988c 100644 --- a/OpenRA.Mods.Common/Widgets/BackgroundWidget.cs +++ b/OpenRA.Mods.Common/Widgets/BackgroundWidget.cs @@ -16,9 +16,9 @@ namespace OpenRA.Mods.Common.Widgets { public class BackgroundWidget : Widget { - public readonly string Background = "dialog"; public readonly bool ClickThrough = false; public readonly bool Draggable = false; + public string Background = "dialog"; public override void Draw() { diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/AddFactionSuffixLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/AddFactionSuffixLogic.cs index eb5000c9b9..ad6a853661 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/AddFactionSuffixLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/AddFactionSuffixLogic.cs @@ -24,17 +24,19 @@ namespace OpenRA.Mods.Common.Widgets.Logic faction = world.LocalPlayer.Faction.InternalName; var suffix = "-" + faction; - var buttonWidget = widget as ButtonWidget; - if (buttonWidget != null) - buttonWidget.Background += suffix; - else + if (widget is ButtonWidget) + ((ButtonWidget)widget).Background += suffix; + else if (widget is ImageWidget) + ((ImageWidget)widget).ImageCollection += suffix; + else if (widget is BackgroundWidget) + ((BackgroundWidget)widget).Background += suffix; + else if (widget is ProductionTabsWidget) { - var imageWidget = widget as ImageWidget; - if (imageWidget != null) - imageWidget.ImageCollection += suffix; - else - throw new InvalidOperationException("AddFactionSuffixLogic only supports ButtonWidget and ImageWidget"); + ((ProductionTabsWidget)widget).Button += suffix; + ((ProductionTabsWidget)widget).Background += suffix; } + else + throw new InvalidOperationException("AddFactionSuffixLogic only supports ButtonWidget, ImageWidget, BackgroundWidget and ProductionTabsWidget"); } } } diff --git a/OpenRA.Mods.Common/Widgets/ProductionTabsWidget.cs b/OpenRA.Mods.Common/Widgets/ProductionTabsWidget.cs index f9ae035011..ba0ba6d627 100644 --- a/OpenRA.Mods.Common/Widgets/ProductionTabsWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ProductionTabsWidget.cs @@ -81,6 +81,9 @@ namespace OpenRA.Mods.Common.Widgets public readonly Dictionary Groups; + public string Button = "button"; + public string Background = "panel-black"; + int contentWidth = 0; float listOffset = 0; bool leftPressed = false; @@ -175,9 +178,9 @@ namespace OpenRA.Mods.Common.Widgets var rightDisabled = listOffset <= Bounds.Width - rightButtonRect.Width - leftButtonRect.Width - contentWidth; var rightHover = Ui.MouseOverWidget == this && rightButtonRect.Contains(Viewport.LastMousePos); - WidgetUtils.DrawPanel("panel-black", rb); - ButtonWidget.DrawBackground("button", leftButtonRect, leftDisabled, leftPressed, leftHover, false); - ButtonWidget.DrawBackground("button", rightButtonRect, rightDisabled, rightPressed, rightHover, false); + WidgetUtils.DrawPanel(Background, rb); + ButtonWidget.DrawBackground(Button, leftButtonRect, leftDisabled, leftPressed, leftHover, false); + ButtonWidget.DrawBackground(Button, rightButtonRect, rightDisabled, rightPressed, rightHover, false); WidgetUtils.DrawRGBA(ChromeProvider.GetImage("scrollbar", leftPressed || leftDisabled ? "left_pressed" : "left_arrow"), new float2(leftButtonRect.Left + 2, leftButtonRect.Top + 2)); @@ -194,8 +197,8 @@ namespace OpenRA.Mods.Common.Widgets { var rect = new Rectangle(origin.X + contentWidth, origin.Y, TabWidth, rb.Height); var hover = !leftHover && !rightHover && Ui.MouseOverWidget == this && rect.Contains(Viewport.LastMousePos); - var baseName = tab.Queue == CurrentQueue ? "button-highlighted" : "button"; - ButtonWidget.DrawBackground(baseName, rect, false, false, hover, false); + var highlighted = tab.Queue == CurrentQueue; + ButtonWidget.DrawBackground(Button, rect, false, false, hover, highlighted); contentWidth += TabWidth - 1; var textSize = font.Measure(tab.Name);