minicursors for minimap.
Bugs: ra doesn't define a sequence for move-blocked-minimap; cursor hotspot is wrong.
This commit is contained in:
@@ -79,6 +79,11 @@ namespace OpenRA.Graphics
|
||||
return units[unit].ContainsKey(seq);
|
||||
}
|
||||
|
||||
public static bool HasCursorSequence(string cursor)
|
||||
{
|
||||
return cursors.ContainsKey(cursor);
|
||||
}
|
||||
|
||||
public static CursorSequence GetCursorSequence(string cursor)
|
||||
{
|
||||
try { return cursors[cursor]; }
|
||||
|
||||
@@ -55,24 +55,15 @@ namespace OpenRA.Orders
|
||||
|
||||
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)
|
||||
{
|
||||
//using (new PerfSample("cursor"))
|
||||
{
|
||||
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");
|
||||
}
|
||||
return c ??
|
||||
(world.SelectActorsInBox(Game.CellSize * xy,
|
||||
Game.CellSize * xy).Any()
|
||||
? "select" : "default");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,27 @@ namespace OpenRA.Widgets
|
||||
|
||||
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)
|
||||
{
|
||||
if (!hasRadar || radarAnimating) return false; // we're not set up for this.
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<sequence name="select" start="12" length="6" 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="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="deploy" start="53" length="9" x="12" y="12" />
|
||||
<sequence name="sell" start="62" length="24" x="12" y="12" />
|
||||
|
||||
Reference in New Issue
Block a user