Merge pull request #9585 from ChaoticMind/select_all_map

Make "select all units" work across screen/map again
This commit is contained in:
abcdefg30
2015-11-22 01:50:48 +01:00
2 changed files with 17 additions and 3 deletions

View File

@@ -235,11 +235,25 @@ namespace OpenRA.Widgets
else if (key == Game.Settings.Keys.SelectAllUnitsKey && !World.IsGameOver) else if (key == Game.Settings.Keys.SelectAllUnitsKey && !World.IsGameOver)
{ {
// Select actors on the screen which belong to the current player // Select actors on the screen which belong to the current player
var ownUnitsOnScreen = SelectActorsOnScreen(World, worldRenderer, null, player).SubsetWithHighestSelectionPriority(); var ownUnitsOnScreen = SelectActorsOnScreen(World, worldRenderer, null, player).SubsetWithHighestSelectionPriority().ToList();
// Check if selecting actors on the screen has selected new units
if (ownUnitsOnScreen.Count > World.Selection.Actors.Count())
Game.Debug("Selected across screen");
else
{
// Select actors in the world that have highest selection priority
ownUnitsOnScreen = SelectActorsInWorld(World, null, player).SubsetWithHighestSelectionPriority().ToList();
Game.Debug("Selected across map");
}
World.Selection.Combine(World, ownUnitsOnScreen, false, false); World.Selection.Combine(World, ownUnitsOnScreen, false, false);
} }
else if (key == Game.Settings.Keys.SelectUnitsByTypeKey && !World.IsGameOver) else if (key == Game.Settings.Keys.SelectUnitsByTypeKey && !World.IsGameOver)
{ {
if (!World.Selection.Actors.Any())
return false;
// Get all the selected actors' selection classes // Get all the selected actors' selection classes
var selectedClasses = World.Selection.Actors var selectedClasses = World.Selection.Actors
.Where(x => !x.IsDead && x.Owner == player) .Where(x => !x.IsDead && x.Owner == player)
@@ -250,7 +264,7 @@ namespace OpenRA.Widgets
var newSelection = SelectActorsOnScreen(World, worldRenderer, selectedClasses, player).ToList(); var newSelection = SelectActorsOnScreen(World, worldRenderer, selectedClasses, player).ToList();
// Check if selecting actors on the screen has selected new units // Check if selecting actors on the screen has selected new units
if (newSelection.Count() > World.Selection.Actors.Count()) if (newSelection.Count > World.Selection.Actors.Count())
Game.Debug("Selected across screen"); Game.Debug("Selected across screen");
else else
{ {

View File

@@ -394,7 +394,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ "CycleBaseKey", "Jump to base" }, { "CycleBaseKey", "Jump to base" },
{ "ToLastEventKey", "Jump to last radar event" }, { "ToLastEventKey", "Jump to last radar event" },
{ "ToSelectionKey", "Jump to selection" }, { "ToSelectionKey", "Jump to selection" },
{ "SelectAllUnitsKey", "Select all units on screen" }, { "SelectAllUnitsKey", "Select all combat units" },
{ "SelectUnitsByTypeKey", "Select units by type" }, { "SelectUnitsByTypeKey", "Select units by type" },
{ "PlaceBeaconKey", "Place beacon" }, { "PlaceBeaconKey", "Place beacon" },