diff --git a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj
index 90b4284301..8e97ead0fd 100644
--- a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj
+++ b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj
@@ -103,6 +103,7 @@
+
diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/ProductionTooltipLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/ProductionTooltipLogic.cs
index 5d1eda2c83..fe01ed1fb7 100644
--- a/OpenRA.Mods.Cnc/Widgets/Logic/ProductionTooltipLogic.cs
+++ b/OpenRA.Mods.Cnc/Widgets/Logic/ProductionTooltipLogic.cs
@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
{
[ObjectCreator.UseCtor]
public ProductionTooltipLogic([ObjectCreator.Param] Widget widget,
- [ObjectCreator.Param] ProductionPaletteWidget palette)
+ [ObjectCreator.Param] ProductionPaletteWidget palette)
{
widget.IsVisible = () => palette.TooltipActor != null;
widget.GetWidget("NAME").GetText = () => palette.TooltipActor;
diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/SupportPowerTooltipLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/SupportPowerTooltipLogic.cs
new file mode 100644
index 0000000000..fe1773ba8f
--- /dev/null
+++ b/OpenRA.Mods.Cnc/Widgets/Logic/SupportPowerTooltipLogic.cs
@@ -0,0 +1,27 @@
+#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 OpenRA.Support;
+using OpenRA.Widgets;
+
+namespace OpenRA.Mods.Cnc.Widgets.Logic
+{
+ public class SupportPowerTooltipLogic
+ {
+ [ObjectCreator.UseCtor]
+ public SupportPowerTooltipLogic([ObjectCreator.Param] Widget widget,
+ [ObjectCreator.Param] SupportPowersWidget palette)
+ {
+ widget.IsVisible = () => palette.TooltipPower != null;
+ widget.GetWidget("NAME").GetText = () => palette.TooltipPower;
+ }
+ }
+}
+
diff --git a/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs b/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs
index e2905ff7f0..c37cfe0b32 100755
--- a/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs
+++ b/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs
@@ -35,8 +35,8 @@ namespace OpenRA.Mods.Cnc.Widgets
public readonly string TabClick = "button.aud";
public readonly string TooltipContainer;
public readonly string TooltipTemplate = "PRODUCTION_TOOLTIP";
- public string TooltipActor { get; private set; }
+ public string TooltipActor { get; private set; }
Lazy tooltipContainer;
ProductionQueue currentQueue;
public ProductionQueue CurrentQueue
diff --git a/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs b/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs
index b0af4d386a..e3e1e3dff8 100755
--- a/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs
+++ b/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs
@@ -19,7 +19,7 @@ using OpenRA.Mods.RA;
namespace OpenRA.Mods.Cnc.Widgets
{
- class SupportPowersWidget : Widget
+ public class SupportPowersWidget : Widget
{
public int Spacing = 10;
@@ -27,6 +27,11 @@ namespace OpenRA.Mods.Cnc.Widgets
Animation clock;
Dictionary Icons = new Dictionary();
+ public readonly string TooltipContainer;
+ public readonly string TooltipTemplate = "SUPPORT_POWER_TOOLTIP";
+ public string TooltipPower { get; private set; }
+ Lazy tooltipContainer;
+
Rectangle eventBounds;
public override Rectangle EventBounds { get { return eventBounds; } }
readonly WorldRenderer worldRenderer;
@@ -34,10 +39,12 @@ namespace OpenRA.Mods.Cnc.Widgets
[ObjectCreator.UseCtor]
public SupportPowersWidget([ObjectCreator.Param] World world,
- [ObjectCreator.Param] WorldRenderer worldRenderer)
+ [ObjectCreator.Param] WorldRenderer worldRenderer)
{
this.worldRenderer = worldRenderer;
spm = world.LocalPlayer.PlayerActor.Trait();
+ tooltipContainer = new Lazy(() =>
+ Widget.RootWidget.GetWidget(TooltipContainer));
iconSprites = Rules.Info.Values.SelectMany( u => u.Traits.WithInterface() )
.Select(u => u.Image).Distinct()
@@ -71,9 +78,11 @@ namespace OpenRA.Mods.Cnc.Widgets
var holdOffset = new float2(32,24) - overlayFont.Measure("On Hold") / 2;
var readyOffset = new float2(32,24) - overlayFont.Measure("Ready") / 2;
+ // Background
foreach (var kv in Icons)
WidgetUtils.DrawPanel("panel-black", kv.Key.InflateBy(1,1,1,1));
+ // Icons
foreach (var kv in Icons)
{
var rect = kv.Key;
@@ -87,6 +96,13 @@ namespace OpenRA.Mods.Cnc.Widgets
* (clock.CurrentSequence.Length - 1) / power.TotalTime);
clock.Tick();
WidgetUtils.DrawSHP(clock.Image, drawPos, worldRenderer);
+ }
+
+ // Overlays
+ foreach (var kv in Icons)
+ {
+ var power = spm.Powers[kv.Value];
+ var drawPos = new float2(kv.Key.Location);
if (power.Ready)
overlayFont.DrawTextWithContrast("Ready",
@@ -104,8 +120,30 @@ namespace OpenRA.Mods.Cnc.Widgets
RefreshIcons();
}
+ public override void MouseEntered()
+ {
+ if (TooltipContainer == null)
+ return;
+
+ var panel = Widget.LoadWidget(TooltipTemplate, null, new WidgetArgs() {{ "palette", this }});
+ tooltipContainer.Value.SetTooltip(panel);
+ }
+
+ public override void MouseExited()
+ {
+ if (TooltipContainer == null) return;
+ tooltipContainer.Value.RemoveTooltip();
+ }
+
public override bool HandleMouseInput(MouseInput mi)
{
+ if (mi.Event == MouseInputEvent.Move)
+ {
+ TooltipPower = Icons.Where(i => i.Key.Contains(mi.Location))
+ .Select(i => i.Value).FirstOrDefault();
+ return false;
+ }
+
if (mi.Event != MouseInputEvent.Down)
return false;
diff --git a/mods/cnc/chrome/ingame.yaml b/mods/cnc/chrome/ingame.yaml
index 40ab272d5f..afd631cd47 100644
--- a/mods/cnc/chrome/ingame.yaml
+++ b/mods/cnc/chrome/ingame.yaml
@@ -80,6 +80,7 @@ Container@INGAME_ROOT:
Align:Center
Font:Bold
SupportPowers:
+ TooltipContainer:TOOLTIP_CONTAINER
X:10
Y:10
Background@SIDEBAR_BACKGROUND:
diff --git a/mods/cnc/chrome/tooltips.yaml b/mods/cnc/chrome/tooltips.yaml
index 170ed60af6..86cb3eaeb9 100644
--- a/mods/cnc/chrome/tooltips.yaml
+++ b/mods/cnc/chrome/tooltips.yaml
@@ -46,6 +46,20 @@ Background@PRODUCTION_TOOLTIP:
Background:panel-black
Width:100
Height:25
+ Children:
+ Label@NAME:
+ Id:NAME
+ X:5
+ Width:PARENT_RIGHT-10
+ Height:23
+ Font:Bold
+
+Background@SUPPORT_POWER_TOOLTIP:
+ Id:SUPPORT_POWER_TOOLTIP
+ Logic:SupportPowerTooltipLogic
+ Background:panel-black
+ Width:200
+ Height:25
Children:
Label@NAME:
Id:NAME