Add smooth minimap to world movement
This commit is contained in:
@@ -250,7 +250,7 @@ namespace OpenRA.Graphics
|
||||
|
||||
public CPos ViewToWorld(int2 view)
|
||||
{
|
||||
var world = worldRenderer.Viewport.ViewToWorldPx(view);
|
||||
var world = ViewToWorldPx(view);
|
||||
var map = worldRenderer.World.Map;
|
||||
var candidates = CandidateMouseoverCells(world).ToList();
|
||||
|
||||
@@ -337,6 +337,13 @@ namespace OpenRA.Graphics
|
||||
allCellsDirty = true;
|
||||
}
|
||||
|
||||
public void Center(float2 pos)
|
||||
{
|
||||
CenterLocation = worldRenderer.ScreenPosition(pos).Clamp(mapBounds);
|
||||
cellsDirty = true;
|
||||
allCellsDirty = true;
|
||||
}
|
||||
|
||||
public void Scroll(float2 delta, bool ignoreBorders)
|
||||
{
|
||||
// Convert scroll delta from world-px to viewport-px
|
||||
|
||||
@@ -384,12 +384,22 @@ namespace OpenRA.Graphics
|
||||
Game.Renderer.SetPalette(palette);
|
||||
}
|
||||
|
||||
// Conversion between world and screen coordinates
|
||||
/// <summary>
|
||||
/// Converts a world position to a screen position.
|
||||
/// </summary>
|
||||
public float2 ScreenPosition(WPos pos)
|
||||
{
|
||||
return new float2((float)TileSize.Width * pos.X / TileScale, (float)TileSize.Height * (pos.Y - pos.Z) / TileScale);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a world position to a screen position.
|
||||
/// </summary>
|
||||
public float2 ScreenPosition(float2 pos)
|
||||
{
|
||||
return new float2(TileSize.Width * pos.X / TileScale, TileSize.Height * pos.Y / TileScale);
|
||||
}
|
||||
|
||||
public float3 Screen3DPosition(WPos pos)
|
||||
{
|
||||
// The projection from world coordinates to screen coordinates has
|
||||
|
||||
Reference in New Issue
Block a user