From e5ce9196faf88bd93ef0124450ad7e5ababd53fc Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Wed, 30 Jun 2010 19:02:37 +1200 Subject: [PATCH] Nicer tooltips --- OpenRA.Game/Player.cs | 2 +- .../Widgets/Delegates/LobbyDelegate.cs | 2 +- OpenRA.Game/Widgets/WorldTooltipWidget.cs | 26 ++++++++++++++----- mods/cnc/chrome.xml | 18 ++++++------- mods/ra/chrome.xml | 24 ++++++++--------- 5 files changed, 42 insertions(+), 30 deletions(-) diff --git a/OpenRA.Game/Player.cs b/OpenRA.Game/Player.cs index ce00a04fae..60d53971eb 100644 --- a/OpenRA.Game/Player.cs +++ b/OpenRA.Game/Player.cs @@ -75,7 +75,7 @@ namespace OpenRA PlayerName = client.Name; InternalName = "Multi{0}".F(client.Index); Country = world.GetCountries() - .FirstOrDefault(c => client != null && client.Country == c.Name) + .FirstOrDefault(c => client != null && client.Country == c.Race) ?? world.GetCountries().Random(world.SharedRandom); } diff --git a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs index f9ef21e419..f09d84d995 100644 --- a/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/LobbyDelegate.cs @@ -145,7 +145,7 @@ namespace OpenRA.Widgets.Delegates bool CycleRace(MouseInput mi) { - var countries = new[] { "Random" }.Concat(Game.world.GetCountries().Select(c => c.Name)); + var countries = new[] { "Random" }.Concat(Game.world.GetCountries().Select(c => c.Race)); if (mi.Button == MouseButton.Right) countries = countries.Reverse(); diff --git a/OpenRA.Game/Widgets/WorldTooltipWidget.cs b/OpenRA.Game/Widgets/WorldTooltipWidget.cs index f33675fd99..8513027749 100644 --- a/OpenRA.Game/Widgets/WorldTooltipWidget.cs +++ b/OpenRA.Game/Widgets/WorldTooltipWidget.cs @@ -23,6 +23,7 @@ using System; using System.Drawing; using System.Linq; using OpenRA.Traits; +using OpenRA.Graphics; namespace OpenRA.Widgets { @@ -47,15 +48,17 @@ namespace OpenRA.Widgets var text = actor.Info.Traits.Contains() ? actor.Info.Traits.Get().Description : actor.Info.Name; - var text2 = (actor.Owner == world.LocalPlayer) - ? "" : (actor.Owner.NonCombatant ? "{0}" : "{0} ({1})").F(actor.Owner.PlayerName, world.LocalPlayer.Stances[actor.Owner]); - + var text2 = (actor.Owner.NonCombatant) + ? "" : "{0}".F(actor.Owner.PlayerName); + var text3 = (actor.Owner == world.LocalPlayer || actor.Owner.NonCombatant) + ? "" : " ({0})".F(world.LocalPlayer.Stances[actor.Owner]); var renderer = Game.chrome.renderer; var sz = renderer.BoldFont.Measure(text); var sz2 = renderer.RegularFont.Measure(text2); - - sz.X = Math.Max(sz.X, sz2.X); + var sz3 = renderer.RegularFont.Measure(text3); + + sz.X = Math.Max(sz.X, sz2.X + sz3.X + 35); if (text2 != "") sz.Y += sz2.Y + 2; @@ -68,9 +71,18 @@ namespace OpenRA.Widgets renderer.BoldFont.DrawText(text, new float2(Game.chrome.lastMousePos.X + 30, Game.chrome.lastMousePos.Y + 30), Color.White); - renderer.RegularFont.DrawText(text2, - new float2(Game.chrome.lastMousePos.X + 30, Game.chrome.lastMousePos.Y + 50), Color.White); + + if (text2 != "") + { + renderer.RegularFont.DrawText(text2, + new float2(Game.chrome.lastMousePos.X + 65, Game.chrome.lastMousePos.Y + 50), actor.Owner.Color); + + renderer.RegularFont.DrawText(text3, + new float2(Game.chrome.lastMousePos.X + 65 + sz2.X, Game.chrome.lastMousePos.Y + 50), Color.White); + WidgetUtils.DrawRGBA(ChromeProvider.GetImage(Game.chrome.renderer, "flags", actor.Owner.Country.Race), new float2(Game.chrome.lastMousePos.X + 30, Game.chrome.lastMousePos.Y + 50)); + } + renderer.RgbaSpriteRenderer.Flush(); } } diff --git a/mods/cnc/chrome.xml b/mods/cnc/chrome.xml index 30ba4c80a2..cdef465386 100644 --- a/mods/cnc/chrome.xml +++ b/mods/cnc/chrome.xml @@ -197,15 +197,15 @@ - - + + - - - - - - - + + + + + + + diff --git a/mods/ra/chrome.xml b/mods/ra/chrome.xml index ac36289d8f..f41758662c 100644 --- a/mods/ra/chrome.xml +++ b/mods/ra/chrome.xml @@ -188,17 +188,17 @@ - - - - - - - - - - - - + + + + + + + + + + + +