diff --git a/OpenRA.Game/Widgets/ViewportControllerWidget.cs b/OpenRA.Game/Widgets/ViewportControllerWidget.cs
index 0f8801de55..23a1a597ca 100755
--- a/OpenRA.Game/Widgets/ViewportControllerWidget.cs
+++ b/OpenRA.Game/Widgets/ViewportControllerWidget.cs
@@ -71,7 +71,7 @@ namespace OpenRA.Widgets
return;
tooltipContainer.Value.SetTooltip(TooltipTemplate,
- new WidgetArgs() {{ "world", world }, { "wic", this }});
+ new WidgetArgs() {{ "world", world }, { "viewport", this }});
}
public override void MouseExited()
diff --git a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj
index 485b365be9..c76ff2c534 100644
--- a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj
+++ b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj
@@ -102,7 +102,6 @@
-
diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
index c488da4824..bdc1ec10cf 100644
--- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
+++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
@@ -413,7 +413,6 @@
-
@@ -462,6 +461,7 @@
+
diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/WorldTooltipLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/WorldTooltipLogic.cs
similarity index 69%
rename from OpenRA.Mods.Cnc/Widgets/Logic/WorldTooltipLogic.cs
rename to OpenRA.Mods.RA/Widgets/Logic/WorldTooltipLogic.cs
index 177572c369..e34eb34ead 100644
--- a/OpenRA.Mods.Cnc/Widgets/Logic/WorldTooltipLogic.cs
+++ b/OpenRA.Mods.RA/Widgets/Logic/WorldTooltipLogic.cs
@@ -12,14 +12,14 @@ using System;
using System.Drawing;
using OpenRA.Widgets;
-namespace OpenRA.Mods.Cnc.Widgets.Logic
+namespace OpenRA.Mods.RA.Widgets.Logic
{
public class WorldTooltipLogic
{
[ObjectCreator.UseCtor]
- public WorldTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, ViewportControllerWidget wic)
+ public WorldTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, ViewportControllerWidget viewport)
{
- widget.IsVisible = () => wic.TooltipType != WorldTooltipType.None;
+ widget.IsVisible = () => viewport.TooltipType != WorldTooltipType.None;
var label = widget.Get("LABEL");
var flag = widget.Get("FLAG");
var owner = widget.Get("OWNER");
@@ -32,24 +32,25 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
var flagRace = "";
var ownerName = "";
var ownerColor = Color.White;
- var doubleHeight = 45;
- var singleHeight = 25;
+
+ var singleHeight = widget.Get("SINGLE_HEIGHT").Bounds.Height;
+ var doubleHeight = widget.Get("DOUBLE_HEIGHT").Bounds.Height;
tooltipContainer.BeforeRender = () =>
{
- if (wic == null || wic.TooltipType == WorldTooltipType.None)
+ if (viewport == null || viewport.TooltipType == WorldTooltipType.None)
return;
- labelText = wic.TooltipType == WorldTooltipType.Unexplored ? "Unexplored Terrain" :
- wic.ActorTooltip.Name();
+ labelText = viewport.TooltipType == WorldTooltipType.Unexplored ? "Unexplored Terrain" :
+ viewport.ActorTooltip.Name();
var textWidth = font.Measure(labelText).X;
if (textWidth != cachedWidth)
{
label.Bounds.Width = textWidth;
widget.Bounds.Width = 2*label.Bounds.X + textWidth;
}
- var o = wic.ActorTooltip != null ? wic.ActorTooltip.Owner() : null;
- showOwner = wic.TooltipType == WorldTooltipType.Actor && o != null && !o.NonCombatant;
+ var o = viewport.ActorTooltip != null ? viewport.ActorTooltip.Owner() : null;
+ showOwner = viewport.TooltipType == WorldTooltipType.Actor && o != null && !o.NonCombatant;
if (showOwner)
{
@@ -58,7 +59,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
ownerColor = o.Color.RGB;
widget.Bounds.Height = doubleHeight;
widget.Bounds.Width = Math.Max(widget.Bounds.Width,
- owner.Bounds.X + ownerFont.Measure(ownerName).X + 5);
+ owner.Bounds.X + ownerFont.Measure(ownerName).X + label.Bounds.X);
}
else
widget.Bounds.Height = singleHeight;
diff --git a/OpenRA.Mods.RA/Widgets/WorldTooltipWidget.cs b/OpenRA.Mods.RA/Widgets/WorldTooltipWidget.cs
deleted file mode 100755
index f11b638a42..0000000000
--- a/OpenRA.Mods.RA/Widgets/WorldTooltipWidget.cs
+++ /dev/null
@@ -1,94 +0,0 @@
-#region Copyright & License Information
-/*
- * Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
- * This file is part of OpenRA, which is free software. It is made
- * available to you under the terms of the GNU General Public License
- * as published by the Free Software Foundation. For more information,
- * see COPYING.
- */
-#endregion
-
-using System;
-using System.Drawing;
-using System.Linq;
-using OpenRA.Graphics;
-using OpenRA.Widgets;
-using OpenRA.Traits;
-
-namespace OpenRA.Mods.RA.Widgets
-{
- public class WorldTooltipWidget : Widget
- {
- public int TooltipDelay = 10;
- readonly World world;
-
- [ObjectCreator.UseCtor]
- public WorldTooltipWidget(World world) { this.world = world; }
-
- public override void Draw()
- {
- if (Viewport.TicksSinceLastMove < TooltipDelay || world == null)
- return;
-
- var cell = Game.viewport.ViewToWorld(Viewport.LastMousePos);
- if (!world.Map.IsInMap(cell))
- return;
-
- if (world.ShroudObscures(cell))
- {
- var utext = "Unexplored Terrain";
- var usz = Game.Renderer.Fonts["Bold"].Measure(utext) + new int2(20, 24);
-
- WidgetUtils.DrawPanel("dialog4", Rectangle.FromLTRB(
- Viewport.LastMousePos.X + 20, Viewport.LastMousePos.Y + 20,
- Viewport.LastMousePos.X + usz.X + 20, Viewport.LastMousePos.Y + usz.Y + 20));
-
- Game.Renderer.Fonts["Bold"].DrawText(utext,
- new float2(Viewport.LastMousePos.X + 30, Viewport.LastMousePos.Y + 30), Color.White);
-
- return;
- }
-
- var actor = world.FindUnitsAtMouse(Viewport.LastMousePos).FirstOrDefault();
- if (actor == null)
- return;
-
- var itt = actor.TraitsImplementing().FirstOrDefault();
- if (itt == null)
- return;
-
- var owner = itt.Owner();
- var nameText = itt.Name();
- var ownerText = !owner.NonCombatant ? owner.PlayerName : "";
- var stanceText = (world.LocalPlayer != null && owner != actor.World.LocalPlayer
- && !owner.NonCombatant) ? " ({0})".F(itt.Stance()) : "";
-
- var nameSize = Game.Renderer.Fonts["Bold"].Measure(nameText);
- var ownerSize = Game.Renderer.Fonts["Regular"].Measure(ownerText);
- var stanceSize = Game.Renderer.Fonts["Regular"].Measure(stanceText);
- var panelSize = new int2(Math.Max(nameSize.X, ownerSize.X + stanceSize.X + 35) + 20, nameSize.Y + 24);
-
- if (ownerText != "") panelSize.Y += ownerSize.Y + 2;
-
- WidgetUtils.DrawPanel("dialog4", Rectangle.FromLTRB(
- Viewport.LastMousePos.X + 20, Viewport.LastMousePos.Y + 20,
- Viewport.LastMousePos.X + panelSize.X + 20, Viewport.LastMousePos.Y + panelSize.Y + 20));
-
- Game.Renderer.Fonts["Bold"].DrawText(nameText,
- new float2(Viewport.LastMousePos.X + 30, Viewport.LastMousePos.Y + 30), Color.White);
-
- if (ownerText != "")
- {
- Game.Renderer.Fonts["Regular"].DrawText(ownerText,
- new float2(Viewport.LastMousePos.X + 65, Viewport.LastMousePos.Y + 50), actor.Owner.Color.RGB);
-
- Game.Renderer.Fonts["Regular"].DrawText(stanceText,
- new float2(Viewport.LastMousePos.X + 65 + ownerSize.X, Viewport.LastMousePos.Y + 50), Color.White);
-
- WidgetUtils.DrawRGBA(
- ChromeProvider.GetImage("flags", actor.Owner.Country.Race),
- new float2(Viewport.LastMousePos.X + 30, Viewport.LastMousePos.Y + 50));
- }
- }
- }
-}
diff --git a/mods/cnc/chrome/tooltips.yaml b/mods/cnc/chrome/tooltips.yaml
index 7393067200..5edbf1862b 100644
--- a/mods/cnc/chrome/tooltips.yaml
+++ b/mods/cnc/chrome/tooltips.yaml
@@ -25,8 +25,11 @@ Background@BUTTON_TOOLTIP:
Background@WORLD_TOOLTIP:
Logic:WorldTooltipLogic
Background:panel-black
- Width:141
Children:
+ Container@SINGLE_HEIGHT:
+ Height:25
+ Container@DOUBLE_HEIGHT:
+ Height:45
Label@LABEL:
X:5
Height:23
diff --git a/mods/d2k/chrome/tooltips.yaml b/mods/d2k/chrome/tooltips.yaml
index 71b8d45f20..8513117197 100644
--- a/mods/d2k/chrome/tooltips.yaml
+++ b/mods/d2k/chrome/tooltips.yaml
@@ -9,6 +9,30 @@ Background@SIMPLE_TOOLTIP:
Height:23
Font:Bold
+Background@WORLD_TOOLTIP:
+ Logic:WorldTooltipLogic
+ Background:dialog3
+ Children:
+ Container@SINGLE_HEIGHT:
+ Height:31
+ Container@DOUBLE_HEIGHT:
+ Height:56
+ Label@LABEL:
+ X:7
+ Y:2
+ Height:23
+ Font:Bold
+ Image@FLAG:
+ X:7
+ Y:27
+ Width:23
+ Height:23
+ Label@OWNER:
+ X:35
+ Y:25
+ Height:23
+ Font:Bold
+
Background@SPAWN_TOOLTIP:
Logic:SpawnSelectorTooltipLogic
Background:dialog3
diff --git a/mods/ra/chrome/ingame.yaml b/mods/ra/chrome/ingame.yaml
index da283abe41..8baa8f51a6 100644
--- a/mods/ra/chrome/ingame.yaml
+++ b/mods/ra/chrome/ingame.yaml
@@ -11,6 +11,7 @@ Container@INGAME_ROOT:
Y:0
Width:WINDOW_RIGHT
Height:WINDOW_BOTTOM
+ TooltipContainer:TOOLTIP_CONTAINER
WorldCommand:
X:0
Y:0
@@ -31,7 +32,6 @@ Container@INGAME_ROOT:
Text:Options (ESC)
Font:Bold
Key: escape
- WorldTooltip:
Background@PERF_BG:
ClickThrough:true
Background:dialog4
diff --git a/mods/ra/chrome/tooltips.yaml b/mods/ra/chrome/tooltips.yaml
index 8553b7313b..762d84914f 100644
--- a/mods/ra/chrome/tooltips.yaml
+++ b/mods/ra/chrome/tooltips.yaml
@@ -9,6 +9,30 @@ Background@SIMPLE_TOOLTIP:
Height:23
Font:Bold
+Background@WORLD_TOOLTIP:
+ Logic:WorldTooltipLogic
+ Background:dialog4
+ Children:
+ Container@SINGLE_HEIGHT:
+ Height:29
+ Container@DOUBLE_HEIGHT:
+ Height:50
+ Label@LABEL:
+ X:7
+ Y:2
+ Height:23
+ Font:Bold
+ Image@FLAG:
+ X:7
+ Y:27
+ Width:32
+ Height:16
+ Label@OWNER:
+ X:45
+ Y:22
+ Height:23
+ Font:Bold
+
Background@SPAWN_TOOLTIP:
Logic:SpawnSelectorTooltipLogic
Background:dialog4