From a0f7bd358a7a15f9ba2c30f8524d8325527b6cb4 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Fri, 16 Apr 2010 18:32:21 +1200 Subject: [PATCH] fix tab tooltip regression --- OpenRA.Game/Chrome.cs | 9 -------- OpenRA.Game/Widgets/BuildPaletteWidget.cs | 28 ++++++++++++++++++++--- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/OpenRA.Game/Chrome.cs b/OpenRA.Game/Chrome.cs index 2c9a8fae28..91603c769b 100644 --- a/OpenRA.Game/Chrome.cs +++ b/OpenRA.Game/Chrome.cs @@ -421,15 +421,6 @@ namespace OpenRA } void AddButton(RectangleF r, Action b) { buttons.Add(Pair.New(r, b)); } - - Dictionary CategoryNameRemaps = new Dictionary - { - { "Building", "Structures" }, - { "Defense", "Defenses" }, - { "Plane", "Aircraft" }, - { "Ship", "Ships" }, - { "Vehicle", "Vehicles" }, - }; float? lastPowerProvidedPos; float? lastPowerDrainedPos; diff --git a/OpenRA.Game/Widgets/BuildPaletteWidget.cs b/OpenRA.Game/Widgets/BuildPaletteWidget.cs index 5fef65d2fd..ad8f78634a 100644 --- a/OpenRA.Game/Widgets/BuildPaletteWidget.cs +++ b/OpenRA.Game/Widgets/BuildPaletteWidget.cs @@ -446,7 +446,16 @@ namespace OpenRA.Widgets Sound.Play(unit.Traits.Contains() ? eva.BuildingSelectAudio : eva.UnitSelectAudio); Game.IssueOrder(Order.StartProduction(world.LocalPlayer, item, Game.controller.GetModifiers().HasModifier(Modifiers.Shift) ? 5 : 1)); - } + } + + static Dictionary CategoryNameRemaps = new Dictionary + { + { "Building", "Structures" }, + { "Defense", "Defenses" }, + { "Plane", "Aircraft" }, + { "Ship", "Ships" }, + { "Vehicle", "Vehicles" }, + }; void DrawBuildTabs( World world, int paletteHeight) { @@ -469,8 +478,21 @@ namespace OpenRA.Widgets var race = world.LocalPlayer.Country.Race; WidgetUtils.DrawRGBA(ChromeProvider.GetImage(Game.chrome.renderer,"tabs-"+tabKeys[index], race+"-"+q.Key), new float2(x, y)); - buttons.Add(Pair.New(new Rectangle((int)x,(int)y,(int)tabWidth,(int)tabHeight), - HandleTabClick(groupName, world))); + var rect = new Rectangle((int)x,(int)y,(int)tabWidth,(int)tabHeight); + buttons.Add(Pair.New(rect, HandleTabClick(groupName, world))); + + if (rect.Contains(Game.chrome.lastMousePos.ToPoint())) + { + var text = CategoryNameRemaps.ContainsKey(groupName) ? CategoryNameRemaps[groupName] : groupName; + var sz = Game.chrome.renderer.BoldFont.Measure(text); + WidgetUtils.DrawPanelPartial("dialog4", + Rectangle.FromLTRB((int)rect.Left - sz.X - 30, (int)rect.Top, (int)rect.Left - 5, (int)rect.Bottom), + PanelSides.All); + + Game.chrome.renderer.BoldFont.DrawText(text, + new float2(rect.Left - sz.X - 20, rect.Top + 12), Color.White); + } + y += tabHeight; }