From 7e3830e053d7bce2019315a425c648b4cd34dd44 Mon Sep 17 00:00:00 2001 From: teinarss Date: Sat, 22 Jun 2019 11:57:18 +0200 Subject: [PATCH] Updated production spec widget to handle overflow --- .../Widgets/ObserverProductionIconsWidget.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Widgets/ObserverProductionIconsWidget.cs b/OpenRA.Mods.Common/Widgets/ObserverProductionIconsWidget.cs index fbbbfa850c..e421478550 100644 --- a/OpenRA.Mods.Common/Widgets/ObserverProductionIconsWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ObserverProductionIconsWidget.cs @@ -47,6 +47,7 @@ namespace OpenRA.Mods.Common.Widgets float2 iconSize; int lastIconIdx; + public int MinWidth = 240; [ObjectCreator.UseCtor] public ObserverProductionIconsWidget(World world, WorldRenderer worldRenderer) @@ -82,6 +83,8 @@ namespace OpenRA.Mods.Common.Widgets TooltipIcon = other.TooltipIcon; GetTooltipIcon = () => TooltipIcon; + MinWidth = other.MinWidth; + TooltipTemplate = other.TooltipTemplate; TooltipContainer = other.TooltipContainer; @@ -114,7 +117,7 @@ namespace OpenRA.Mods.Common.Widgets .ThenBy(g => g.First().BuildPaletteOrder) .ToList(); - Bounds.Width = currentItemsByItem.Count * (IconWidth + IconSpacing); + Bounds.Width = Math.Max(currentItemsByItem.Count * (IconWidth + IconSpacing), MinWidth); Game.Renderer.EnableAntialiasingFilter(); @@ -193,6 +196,19 @@ namespace OpenRA.Mods.Common.Widgets Color.White, Color.Black, 1); } } + + var parentWidth = Bounds.X + Bounds.Width; + Parent.Bounds.Width = parentWidth; + + var gradient = Parent.Get("PLAYER_GRADIENT"); + + var offset = gradient.Bounds.X - Bounds.X; + var gradientWidth = Math.Max(MinWidth - offset, currentItemsByItem.Count * (IconWidth + IconSpacing)); + + gradient.Bounds.Width = gradientWidth; + var widestChildWidth = Parent.Parent.Children.Max(x => x.Bounds.Width); + + Parent.Parent.Bounds.Width = Math.Max(25 + widestChildWidth, Bounds.Left + MinWidth); } static string GetOverlayForItem(ProductionItem item, int timestep)