Extract text feedback messages.

This commit is contained in:
Matthias Mailänder
2023-08-19 13:03:15 +02:00
committed by Gustas
parent 94c8339e17
commit c609c4af14
77 changed files with 521 additions and 274 deletions

View File

@@ -316,7 +316,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (actionManager != null)
actionManager.Modified = false;
TextNotificationsManager.AddTransientLine(world.LocalPlayer, TranslationProvider.GetString(SaveCurrentMap));
TextNotificationsManager.AddTransientLine(world.LocalPlayer, SaveCurrentMap);
}
catch (Exception e)
{

View File

@@ -27,6 +27,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
public readonly string ClickSound = ChromeMetrics.Get<string>("ClickSound");
[TranslationReference("units")]
const string SelectedUnitsAcrossScreen = "selected-units-across-screen";
[TranslationReference("units")]
const string SelectedUnitsAcrossMap = "selected-units-across-map";
[ObjectCreator.UseCtor]
public SelectAllUnitsHotkeyLogic(Widget widget, ModData modData, WorldRenderer worldRenderer, World world, Dictionary<string, MiniYaml> logicArgs)
: base(widget, modData, "SelectAllUnitsKey", "WORLD_KEYHANDLER", logicArgs)
@@ -48,21 +54,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
// Check if selecting actors on the screen has selected new units
if (newSelection.Count > selection.Actors.Count())
{
if (newSelection.Count > 1)
TextNotificationsManager.AddFeedbackLine($"Selected {newSelection.Count} units across screen.");
else
TextNotificationsManager.AddFeedbackLine("Selected one unit across screen.");
}
TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossScreen, Translation.Arguments("units", newSelection.Count));
else
{
// Select actors in the world that have highest selection priority
newSelection = SelectionUtils.SelectActorsInWorld(world, null, eligiblePlayers).SubsetWithHighestSelectionPriority(e.Modifiers).ToList();
if (newSelection.Count > 1)
TextNotificationsManager.AddFeedbackLine($"Selected {newSelection.Count} units across map.");
else
TextNotificationsManager.AddFeedbackLine("Selected one unit across map.");
TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossMap, Translation.Arguments("units", newSelection.Count));
}
selection.Combine(world, newSelection, false, false);

View File

@@ -29,6 +29,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
public readonly string ClickSound = ChromeMetrics.Get<string>("ClickSound");
public readonly string ClickDisabledSound = ChromeMetrics.Get<string>("ClickDisabledSound");
[TranslationReference]
const string NothingSelected = "nothing-selected";
[TranslationReference("units")]
const string SelectedUnitsAcrossScreen = "selected-units-across-screen";
[TranslationReference("units")]
const string SelectedUnitsAcrossMap = "selected-units-across-map";
[ObjectCreator.UseCtor]
public SelectUnitsByTypeHotkeyLogic(Widget widget, ModData modData, WorldRenderer worldRenderer, World world, Dictionary<string, MiniYaml> logicArgs)
: base(widget, modData, "SelectUnitsByTypeKey", "WORLD_KEYHANDLER", logicArgs)
@@ -45,7 +54,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
if (!selection.Actors.Any())
{
TextNotificationsManager.AddFeedbackLine("Nothing selected.");
TextNotificationsManager.AddFeedbackLine(NothingSelected);
Game.Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Sounds", ClickDisabledSound, null);
return false;
@@ -70,21 +79,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
// Check if selecting actors on the screen has selected new units
if (newSelection.Count > selection.Actors.Count())
{
if (newSelection.Count > 1)
TextNotificationsManager.AddFeedbackLine($"Selected {newSelection.Count} units across screen.");
else
TextNotificationsManager.AddFeedbackLine("Selected one unit across screen.");
}
TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossScreen, Translation.Arguments("units", newSelection.Count));
else
{
// 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();
if (newSelection.Count > 1)
TextNotificationsManager.AddFeedbackLine($"Selected {newSelection.Count} units across map.");
else
TextNotificationsManager.AddFeedbackLine("Selected one unit across map.");
TextNotificationsManager.AddFeedbackLine(SelectedUnitsAcrossMap, Translation.Arguments("units", newSelection.Count));
}
selection.Combine(world, newSelection, true, false);