diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index a304e758a9..214139a8d3 100755 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -227,8 +227,8 @@ - + diff --git a/OpenRA.Game/Widgets/DefaultInputControllerWidget.cs b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs similarity index 93% rename from OpenRA.Game/Widgets/DefaultInputControllerWidget.cs rename to OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs index 908512d8a3..aebaebfed8 100644 --- a/OpenRA.Game/Widgets/DefaultInputControllerWidget.cs +++ b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs @@ -18,10 +18,10 @@ using OpenRA.FileFormats; namespace OpenRA.Widgets { - class DefaultInputControllerWidget : Widget + class WorldInteractionControllerWidget : Widget { - public DefaultInputControllerWidget() : base() {} - protected DefaultInputControllerWidget(DefaultInputControllerWidget widget) : base(widget) {} + public WorldInteractionControllerWidget() : base() {} + protected WorldInteractionControllerWidget(WorldInteractionControllerWidget widget) : base(widget) {} public override void DrawInner( World world ) { @@ -171,6 +171,6 @@ namespace OpenRA.Widgets Game.viewport.Center(world.Selection.Actors); } - public override Widget Clone() { return new DefaultInputControllerWidget(this); } + public override Widget Clone() { return new WorldInteractionControllerWidget(this); } } } \ No newline at end of file diff --git a/OpenRA.Game/Widgets/WorldTooltipWidget.cs b/OpenRA.Game/Widgets/WorldTooltipWidget.cs index 534c93f38a..6f7cc7f782 100644 --- a/OpenRA.Game/Widgets/WorldTooltipWidget.cs +++ b/OpenRA.Game/Widgets/WorldTooltipWidget.cs @@ -18,18 +18,35 @@ namespace OpenRA.Widgets { public class WorldTooltipWidget : Widget { - const int worldTooltipDelay = 10; /* ticks */ - + public int TooltipDelay = 10; public WorldTooltipWidget() : base() { } - public override void DrawInner(World world) { - if (Widget.TicksSinceLastMove < worldTooltipDelay || world == null || world.LocalPlayer == null) + if (Widget.TicksSinceLastMove < TooltipDelay || world == null || world.LocalPlayer == null) return; + var cell = Game.viewport.ViewToWorld(Widget.LastMousePos).ToInt2(); + if (!world.Map.IsInMap(cell)) return; + + if (!world.LocalPlayer.Shroud.IsExplored(cell)) + { + var utext = "Unexplored Terrain"; + var usz = Game.Renderer.BoldFont.Measure(utext) + new int2(20, 24); + + WidgetUtils.DrawPanel("dialog4", Rectangle.FromLTRB( + Widget.LastMousePos.X + 20, Widget.LastMousePos.Y + 20, + Widget.LastMousePos.X + usz.X + 20, Widget.LastMousePos.Y + usz.Y + 20)); + + Game.Renderer.BoldFont.DrawText(utext, + new float2(Widget.LastMousePos.X + 30, Widget.LastMousePos.Y + 30), Color.White); + + return; + } + var actor = world.FindUnitsAtMouse(Widget.LastMousePos).FirstOrDefault(); - if (actor == null) return; - + if (actor == null || !actor.IsVisible()) + return; + var text = actor.Info.Traits.Contains() ? actor.Info.Traits.Get().Description : actor.Info.Name; @@ -68,7 +85,6 @@ namespace OpenRA.Widgets ChromeProvider.GetImage("flags", actor.Owner.Country.Race), new float2(Widget.LastMousePos.X + 30, Widget.LastMousePos.Y + 50)); } - Game.Renderer.RgbaSpriteRenderer.Flush(); } } diff --git a/mods/cnc/chrome/ingame.yaml b/mods/cnc/chrome/ingame.yaml index de1bcc6a98..89e869bef7 100644 --- a/mods/cnc/chrome/ingame.yaml +++ b/mods/cnc/chrome/ingame.yaml @@ -5,7 +5,7 @@ Container@ROOT: Delegate:IngameChromeDelegate Visible:false Children: - DefaultInputController: + WorldInteractionController: X:0 Y:0 Width:WINDOW_RIGHT @@ -65,8 +65,6 @@ Container@ROOT: Height:25 Text:Diplomacy Bold:True - WorldTooltip@INGAME_WORLD_TOOLTIP: - Id:INGAME_WORLD_TOOLTIP Button@INGAME_DEVELOPERMODE_BUTTON: Id:INGAME_DEVELOPERMODE_BUTTON X:324 @@ -108,6 +106,7 @@ Container@ROOT: Image:repair Description:Repair LongDesc:Repair damaged buildings + WorldTooltip: Background@INGAME_OPTIONS_BG: Id:INGAME_OPTIONS_BG X:(WINDOW_RIGHT - WIDTH)/2 diff --git a/mods/ra/chrome/ingame.yaml b/mods/ra/chrome/ingame.yaml index 9d0b3f48cb..34ddd28cf8 100644 --- a/mods/ra/chrome/ingame.yaml +++ b/mods/ra/chrome/ingame.yaml @@ -5,7 +5,7 @@ Container@ROOT: Delegate:IngameChromeDelegate Visible:false Children: - DefaultInputController: + WorldInteractionController: X:0 Y:0 Width:WINDOW_RIGHT @@ -115,6 +115,7 @@ Container@ROOT: Image:repair Description:Repair LongDesc:Repair damaged buildings + WorldTooltip: Background@INGAME_OPTIONS_BG: Id:INGAME_OPTIONS_BG X:(WINDOW_RIGHT - WIDTH)/2