Add selected actors count to feedback notification text

This commit is contained in:
Ivaylo Draganov
2022-01-08 19:29:32 +02:00
committed by Matthias Mailänder
parent fe05382b24
commit 99ac128820
2 changed files with 26 additions and 8 deletions

View File

@@ -44,19 +44,28 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
var eligiblePlayers = SelectionUtils.GetPlayersToIncludeInSelection(world); var eligiblePlayers = SelectionUtils.GetPlayersToIncludeInSelection(world);
// Select actors on the screen which belong to the current player(s) // Select actors on the screen which belong to the current player(s)
var ownUnitsOnScreen = SelectionUtils.SelectActorsOnScreen(world, worldRenderer, null, eligiblePlayers).SubsetWithHighestSelectionPriority(e.Modifiers).ToList(); var newSelection = SelectionUtils.SelectActorsOnScreen(world, worldRenderer, null, eligiblePlayers).SubsetWithHighestSelectionPriority(e.Modifiers).ToList();
// Check if selecting actors on the screen has selected new units // Check if selecting actors on the screen has selected new units
if (ownUnitsOnScreen.Count > selection.Actors.Count()) if (newSelection.Count > selection.Actors.Count())
TextNotificationsManager.AddFeedbackLine("Selected across screen."); {
if (newSelection.Count > 1)
TextNotificationsManager.AddFeedbackLine($"Selected {newSelection.Count} units across screen.");
else
TextNotificationsManager.AddFeedbackLine($"Selected one unit across screen.");
}
else else
{ {
// Select actors in the world that have highest selection priority // Select actors in the world that have highest selection priority
ownUnitsOnScreen = SelectionUtils.SelectActorsInWorld(world, null, eligiblePlayers).SubsetWithHighestSelectionPriority(e.Modifiers).ToList(); newSelection = SelectionUtils.SelectActorsInWorld(world, null, eligiblePlayers).SubsetWithHighestSelectionPriority(e.Modifiers).ToList();
TextNotificationsManager.AddFeedbackLine("Selected across map.");
if (newSelection.Count > 1)
TextNotificationsManager.AddFeedbackLine($"Selected {newSelection.Count} units across map.");
else
TextNotificationsManager.AddFeedbackLine($"Selected one unit across map.");
} }
selection.Combine(world, ownUnitsOnScreen, false, false); selection.Combine(world, newSelection, false, false);
Game.Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Sounds", ClickSound, null); Game.Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Sounds", ClickSound, null);

View File

@@ -70,12 +70,21 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
// 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 > selection.Actors.Count()) if (newSelection.Count > selection.Actors.Count())
TextNotificationsManager.AddFeedbackLine("Selected across screen."); {
if (newSelection.Count > 1)
TextNotificationsManager.AddFeedbackLine($"Selected {newSelection.Count} units across screen.");
else
TextNotificationsManager.AddFeedbackLine($"Selected one unit across screen.");
}
else else
{ {
// Select actors in the world that have the same selection class as one of the already selected actors // Select actors in the world that have the same selection class as one of the already selected actors
newSelection = SelectionUtils.SelectActorsInWorld(world, selectedClasses, eligiblePlayers).ToList(); newSelection = SelectionUtils.SelectActorsInWorld(world, selectedClasses, eligiblePlayers).ToList();
TextNotificationsManager.AddFeedbackLine("Selected across map.");
if (newSelection.Count > 1)
TextNotificationsManager.AddFeedbackLine($"Selected {newSelection.Count} units across map.");
else
TextNotificationsManager.AddFeedbackLine($"Selected one unit across map.");
} }
selection.Combine(world, newSelection, true, false); selection.Combine(world, newSelection, true, false);