DefaultInputController -> WorldInteractionController; Tooltip tweaks.

This commit is contained in:
Paul Chote
2010-07-26 20:13:16 +12:00
parent dcef8770a7
commit c39116df84
5 changed files with 32 additions and 16 deletions

View File

@@ -227,8 +227,8 @@
<Compile Include="Widgets\TimerWidget.cs" />
<Compile Include="Widgets\ShpImageWidget.cs" />
<Compile Include="Widgets\OrderButtonWidget.cs" />
<Compile Include="Widgets\DefaultInputControllerWidget.cs" />
<Compile Include="Traits\DrawLineToTarget.cs" />
<Compile Include="Widgets\WorldInteractionControllerWidget.cs" />
<Compile Include="Widgets\ViewportScrollControllerWidget.cs" />
</ItemGroup>
<ItemGroup>

View File

@@ -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); }
}
}

View File

@@ -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<ValuedInfo>()
? actor.Info.Traits.Get<ValuedInfo>().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();
}
}

View File

@@ -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

View File

@@ -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