added M-n support to center on a group
This commit is contained in:
@@ -164,7 +164,7 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
if (keys.HasModifier(Keys.Alt))
|
if (keys.HasModifier(Keys.Alt))
|
||||||
{
|
{
|
||||||
// center on this group
|
Game.viewport.Center(cache[group]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,15 +83,20 @@ namespace OpenRa.Game.Graphics
|
|||||||
return (1 / 24.0f) * (new float2(mi.Location.X, mi.Location.Y) + Location);
|
return (1 / 24.0f) * (new float2(mi.Location.X, mi.Location.Y) + Location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Center(IEnumerable<Actor> actors)
|
||||||
|
{
|
||||||
|
if (!actors.Any()) return;
|
||||||
|
|
||||||
|
var avgPos = (1f / actors.Count()) * actors
|
||||||
|
.Select(a => a.CenterLocation)
|
||||||
|
.Aggregate((a, b) => a + b);
|
||||||
|
|
||||||
|
scrollPosition = avgPos - .5f * new float2(Width, Height);
|
||||||
|
}
|
||||||
|
|
||||||
public void GoToStartLocation()
|
public void GoToStartLocation()
|
||||||
{
|
{
|
||||||
var unit = Game.world.Actors
|
Center(Game.world.Actors.Where(a => a.Owner == Game.LocalPlayer));
|
||||||
.FirstOrDefault(a => a.Owner == Game.LocalPlayer);
|
|
||||||
|
|
||||||
if (unit == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
scrollPosition = unit.CenterLocation - .5f * new float2(Width, Height);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user