minicursors for minimap.

Bugs: ra doesn't define a sequence for move-blocked-minimap; cursor hotspot is wrong.
This commit is contained in:
Paul Chote
2010-07-21 00:26:32 +12:00
parent bd69047e8c
commit 7d02a801ad
4 changed files with 35 additions and 18 deletions

View File

@@ -78,6 +78,11 @@ namespace OpenRA.Graphics
{ {
return units[unit].ContainsKey(seq); return units[unit].ContainsKey(seq);
} }
public static bool HasCursorSequence(string cursor)
{
return cursors.ContainsKey(cursor);
}
public static CursorSequence GetCursorSequence(string cursor) public static CursorSequence GetCursorSequence(string cursor)
{ {

View File

@@ -55,24 +55,15 @@ namespace OpenRA.Orders
public string GetCursor( World world, int2 xy, MouseInput mi ) public string GetCursor( World world, int2 xy, MouseInput mi )
{ {
return ChooseCursor(world, mi); var c = Order(world, xy, mi)
} .Select(o => o.Subject.traits.WithInterface<IProvideCursor>()
.Select(pc => pc.CursorForOrderString(o.OrderString, o.Subject, o.TargetLocation)).FirstOrDefault(a => a != null))
.FirstOrDefault(a => a != null);
string ChooseCursor(World world, MouseInput mi) return c ??
{ (world.SelectActorsInBox(Game.CellSize * xy,
//using (new PerfSample("cursor")) Game.CellSize * xy).Any()
{ ? "select" : "default");
var p = Game.controller.MousePosition;
var c = Order(world, p.ToInt2(), mi)
.Select(o => o.Subject.traits.WithInterface<IProvideCursor>()
.Select(pc => pc.CursorForOrderString(o.OrderString, o.Subject, o.TargetLocation)).FirstOrDefault(a => a != null))
.FirstOrDefault(a => a != null);
return c ??
(world.SelectActorsInBox(Game.CellSize * p,
Game.CellSize * p).Any()
? "select" : "default");
}
} }
} }
} }

View File

@@ -29,6 +29,27 @@ namespace OpenRA.Widgets
string radarCollection; string radarCollection;
public override string GetCursor(int2 pos)
{
var mapRect = new RectangleF(radarOrigin.X + 9, radarOrigin.Y + (192 - radarMinimapHeight) / 2,
192, radarMinimapHeight);
var loc = Game.world.Minimap.MinimapPixelToCell(mapRect, pos);
var mi = new MouseInput
{
Location = loc,
Button = MouseButton.Right,
Modifiers = Game.controller.GetModifiers()
};
var cursor = Game.controller.orderGenerator.GetCursor( Game.world, loc, mi );
if (cursor == null)
return "default";
return SequenceProvider.HasCursorSequence(cursor+"-minimap") ? cursor+"-minimap" : cursor;
}
public override bool HandleInput(MouseInput mi) public override bool HandleInput(MouseInput mi)
{ {
if (!hasRadar || radarAnimating) return false; // we're not set up for this. if (!hasRadar || radarAnimating) return false; // we're not set up for this.

View File

@@ -13,7 +13,7 @@
<sequence name="select" start="12" length="6" x="12" y="12" /> <sequence name="select" start="12" length="6" x="12" y="12" />
<sequence name="attackmove" start="18" length="8" x="12" y="12" /> <sequence name="attackmove" start="18" length="8" x="12" y="12" />
<sequence name="move-minimap" start="26" length="1" /> <sequence name="move-minimap" start="26" length="1" />
<sequence name="blocked-minimap" start="27" length="1" /> <sequence name="move-blocked-minimap" start="27" length="1" />
<sequence name="repair" start="29" length="24" x="12" y="12" /> <sequence name="repair" start="29" length="24" x="12" y="12" />
<sequence name="deploy" start="53" length="9" x="12" y="12" /> <sequence name="deploy" start="53" length="9" x="12" y="12" />
<sequence name="sell" start="62" length="24" x="12" y="12" /> <sequence name="sell" start="62" length="24" x="12" y="12" />