working orders via minimap
This commit is contained in:
@@ -150,14 +150,24 @@ namespace OpenRA.Graphics
|
||||
rgbaRenderer.Flush();
|
||||
}
|
||||
|
||||
int2 TransformCellToMinimapPixel(RectangleF viewRect, int2 p)
|
||||
int2 CellToMinimapPixel(RectangleF viewRect, int2 p)
|
||||
{
|
||||
var fx = (float)(p.X - bounds.X) / bounds.Width;
|
||||
var fy = (float)(p.Y - bounds.Y) / bounds.Height;
|
||||
|
||||
return new int2(
|
||||
(int)(viewRect.Width * fx + viewRect.Left) - 8,
|
||||
(int)(viewRect.Height * fy + viewRect.Top) - 8);
|
||||
(int)(viewRect.Width * fx + viewRect.Left),
|
||||
(int)(viewRect.Height * fy + viewRect.Top));
|
||||
}
|
||||
|
||||
public int2 MinimapPixelToCell(RectangleF viewRect, int2 p)
|
||||
{
|
||||
var fx = (float)(p.X - viewRect.Left) / viewRect.Width;
|
||||
var fy = (float)(p.Y - viewRect.Top) / viewRect.Height;
|
||||
|
||||
return new int2(
|
||||
(int)(bounds.Width * fx + bounds.Left),
|
||||
(int)(bounds.Height * fy + bounds.Top));
|
||||
}
|
||||
|
||||
public void DrawSpawnPoints(RectangleF rect)
|
||||
@@ -169,7 +179,7 @@ namespace OpenRA.Graphics
|
||||
|
||||
foreach (var p in points)
|
||||
{
|
||||
var pos = TransformCellToMinimapPixel(rect, p.First);
|
||||
var pos = CellToMinimapPixel(rect, p.First) - new int2(8, 8);
|
||||
|
||||
if (p.Second == null)
|
||||
rgbaRenderer.DrawSprite(unownedSpawnPoint, pos, "chrome");
|
||||
|
||||
@@ -48,11 +48,6 @@ namespace OpenRA.Widgets
|
||||
|
||||
string radarCollection;
|
||||
|
||||
int2 MinimapPixelToCell(RectangleF r, int2 p)
|
||||
{
|
||||
return int2.Zero;
|
||||
}
|
||||
|
||||
public override bool HandleInput(MouseInput mi)
|
||||
{
|
||||
if (!hasRadar || radarAnimating) return false; // we're not set up for this.
|
||||
@@ -63,11 +58,29 @@ namespace OpenRA.Widgets
|
||||
if (!mapRect.Contains(mi.Location.ToPointF()))
|
||||
return false;
|
||||
|
||||
var loc = MinimapPixelToCell(mapRect, mi.Location);
|
||||
var loc = Game.world.Minimap.MinimapPixelToCell(mapRect, mi.Location);
|
||||
|
||||
if ((mi.Event == MouseInputEvent.Down || mi.Event == MouseInputEvent.Move) && mi.Button == MouseButton.Left)
|
||||
Game.viewport.Center(loc);
|
||||
|
||||
if (mi.Event == MouseInputEvent.Down && mi.Button == MouseButton.Right)
|
||||
{
|
||||
// fake a mousedown/mouseup here
|
||||
|
||||
var fakemi = new MouseInput
|
||||
{
|
||||
Event = MouseInputEvent.Down,
|
||||
Button = MouseButton.Right,
|
||||
Modifiers = mi.Modifiers,
|
||||
Location = (loc * Game.CellSize - Game.viewport.Location).ToInt2()
|
||||
};
|
||||
|
||||
Game.controller.HandleInput(Game.world, fakemi);
|
||||
|
||||
fakemi.Event = MouseInputEvent.Up;
|
||||
Game.controller.HandleInput(Game.world, fakemi);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -143,7 +156,7 @@ namespace OpenRA.Widgets
|
||||
|
||||
if (radarAnimationFrame >= radarSlideAnimationLength)
|
||||
{
|
||||
RectangleF mapRect = new RectangleF(radarOrigin.X + 9, radarOrigin.Y + (192 - radarMinimapHeight) / 2, 192, radarMinimapHeight);
|
||||
var mapRect = new RectangleF(radarOrigin.X + 9, radarOrigin.Y + (192 - radarMinimapHeight) / 2, 192, radarMinimapHeight);
|
||||
world.Minimap.Draw(mapRect);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user