From e2099eec3e32a10eb360ab12d72d07f12dd6121d Mon Sep 17 00:00:00 2001 From: Ser11y <160628372+Ser1-1y@users.noreply.github.com> Date: Tue, 5 Aug 2025 18:13:04 +0300 Subject: [PATCH] localization support to air alarms, wire panels and more (#39307) * Add localization to the air alarms, wire panels, network configurator list menu and loadout window * delete unused * redo gas localization, delete unused * removed the extra key * Moved and renamed air-alarm-ui-thresholds-gas-name * Moved localization to the XAML * Use existing strings for gas names * it just works * Rename _atmosphereSystem in ScrubberControl.xaml.cs _atmosphereSystem -> atmosphereSystem * Rename _atmosphereSystem in SensorInfo.xaml.cs _atmosphereSystem -> atmosphereSystem --- .../Monitor/UI/Widgets/PumpControl.xaml.cs | 4 +- .../Monitor/UI/Widgets/ScrubberControl.xaml | 2 +- .../UI/Widgets/ScrubberControl.xaml.cs | 23 ++++--- .../Monitor/UI/Widgets/SensorInfo.xaml.cs | 31 ++++++--- .../UI/Widgets/ThresholdBoundControl.xaml | 2 +- .../Monitor/UI/Widgets/ThresholdControl.xaml | 2 +- .../Lobby/UI/HumanoidProfileEditor.xaml.cs | 2 +- .../NetworkConfiguratorConfigurationMenu.xaml | 10 +-- Content.Shared/Wires/SharedWiresComponent.cs | 66 ++++++++----------- Resources/Locale/en-US/atmos/air-alarm-ui.ftl | 12 ++++ .../en-US/devices/network-configurator.ftl | 6 ++ Resources/Locale/en-US/job/loadouts.ftl | 1 + .../components/wires-panel-component.ftl | 41 ++++++++++++ 13 files changed, 135 insertions(+), 67 deletions(-) diff --git a/Content.Client/Atmos/Monitor/UI/Widgets/PumpControl.xaml.cs b/Content.Client/Atmos/Monitor/UI/Widgets/PumpControl.xaml.cs index 8502cd2712..8586049cb1 100644 --- a/Content.Client/Atmos/Monitor/UI/Widgets/PumpControl.xaml.cs +++ b/Content.Client/Atmos/Monitor/UI/Widgets/PumpControl.xaml.cs @@ -59,7 +59,7 @@ public sealed partial class PumpControl : BoxContainer foreach (var value in Enum.GetValues()) { - _pumpDirection.AddItem(Loc.GetString($"{value}"), (int) value); + _pumpDirection.AddItem(Loc.GetString($"air-alarm-ui-pump-direction-{value.ToString().ToLower()}"), (int) value); } _pumpDirection.SelectId((int) _data.PumpDirection); @@ -72,7 +72,7 @@ public sealed partial class PumpControl : BoxContainer foreach (var value in Enum.GetValues()) { - _pressureCheck.AddItem(Loc.GetString($"{value}"), (int) value); + _pressureCheck.AddItem(Loc.GetString($"air-alarm-ui-pressure-bound-{value.ToString().ToLower()}"), (int) value); } _pressureCheck.SelectId((int) _data.PressureChecks); diff --git a/Content.Client/Atmos/Monitor/UI/Widgets/ScrubberControl.xaml b/Content.Client/Atmos/Monitor/UI/Widgets/ScrubberControl.xaml index 85f63731fb..c26aa2cf6e 100644 --- a/Content.Client/Atmos/Monitor/UI/Widgets/ScrubberControl.xaml +++ b/Content.Client/Atmos/Monitor/UI/Widgets/ScrubberControl.xaml @@ -27,7 +27,7 @@ - + diff --git a/Content.Client/Atmos/Monitor/UI/Widgets/ScrubberControl.xaml.cs b/Content.Client/Atmos/Monitor/UI/Widgets/ScrubberControl.xaml.cs index 3370fc3cae..4fb5c2788d 100644 --- a/Content.Client/Atmos/Monitor/UI/Widgets/ScrubberControl.xaml.cs +++ b/Content.Client/Atmos/Monitor/UI/Widgets/ScrubberControl.xaml.cs @@ -1,23 +1,26 @@ using Content.Shared.Atmos; -using Content.Shared.Atmos.EntitySystems; // DeltaV +using Content.Shared.Atmos.EntitySystems; using Content.Shared.Atmos.Monitor.Components; using Content.Shared.Atmos.Piping.Unary.Components; +using Content.Shared.Atmos.Prototypes; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.XAML; +using Robust.Shared.Prototypes; namespace Content.Client.Atmos.Monitor.UI.Widgets; [GenerateTypedNameReferences] public sealed partial class ScrubberControl : BoxContainer { - [Dependency] private readonly IEntityManager _entMan = default!; // DeltaV - private readonly SharedAtmosphereSystem _atmos; // DeltaV + [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + [Dependency] private readonly IEntityManager _entMan = default!; + private GasVentScrubberData _data; private string _address; public event Action? ScrubberDataChanged; - public event Action? ScrubberDataCopied; + public event Action? ScrubberDataCopied; private CheckBox _enabled => CEnableDevice; private CollapsibleHeading _addressLabel => CAddress; @@ -33,9 +36,10 @@ public sealed partial class ScrubberControl : BoxContainer public ScrubberControl(GasVentScrubberData data, string address) { + IoCManager.InjectDependencies(this); + var atmosphereSystem = _entMan.System(); + RobustXamlLoader.Load(this); - IoCManager.InjectDependencies(this); // DeltaV - _atmos = _entMan.System(); // DeltaV Name = address; @@ -68,7 +72,7 @@ public sealed partial class ScrubberControl : BoxContainer foreach (var value in Enum.GetValues()) { - _pumpDirection.AddItem(Loc.GetString($"{value}"), (int) value); + _pumpDirection.AddItem(Loc.GetString($"air-alarm-ui-pump-direction-{value.ToString().ToLower()}"), (int) value); } _pumpDirection.SelectId((int) _data.PumpDirection); @@ -100,10 +104,13 @@ public sealed partial class ScrubberControl : BoxContainer foreach (var value in allGases) { + ProtoId gasProtoId = atmosphereSystem.GetGas(value); + var gasName = _prototypeManager.Index(gasProtoId).Name; + var gasButton = new Button { Name = value.ToString(), - Text = Loc.GetString(_atmos.GetGas(value).Name), // DeltaV - localize it instead of showing the enum name + Text = Loc.GetString(gasName), ToggleMode = true, HorizontalExpand = true, Pressed = _data.FilterGases.Contains(value) diff --git a/Content.Client/Atmos/Monitor/UI/Widgets/SensorInfo.xaml.cs b/Content.Client/Atmos/Monitor/UI/Widgets/SensorInfo.xaml.cs index e59c590b39..d9945b1acc 100644 --- a/Content.Client/Atmos/Monitor/UI/Widgets/SensorInfo.xaml.cs +++ b/Content.Client/Atmos/Monitor/UI/Widgets/SensorInfo.xaml.cs @@ -1,19 +1,22 @@ using Content.Client.Message; using Content.Shared.Atmos; -using Content.Shared.Atmos.EntitySystems; // DeltaV +using Content.Shared.Atmos.EntitySystems; using Content.Shared.Atmos.Monitor; +using Content.Shared.Atmos.Prototypes; using Content.Shared.Temperature; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.XAML; +using Robust.Shared.Prototypes; namespace Content.Client.Atmos.Monitor.UI.Widgets; [GenerateTypedNameReferences] public sealed partial class SensorInfo : BoxContainer { - [Dependency] private readonly IEntityManager _entMan = default!; // DeltaV - private readonly SharedAtmosphereSystem _atmos; // DeltaV + [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + [Dependency] private readonly IEntityManager _entMan = default!; + public Action? OnThresholdUpdate; public event Action? SensorDataCopied; private string _address; @@ -26,9 +29,10 @@ public sealed partial class SensorInfo : BoxContainer public SensorInfo(AtmosSensorData data, string address) { + IoCManager.InjectDependencies(this); + var atmosphereSystem = _entMan.System(); + RobustXamlLoader.Load(this); - IoCManager.InjectDependencies(this); // DeltaV - _atmos = _entMan.System(); // DeltaV _address = address; @@ -50,8 +54,12 @@ public sealed partial class SensorInfo : BoxContainer var label = new RichTextLabel(); var fractionGas = amount / data.TotalMoles; + + ProtoId gasProtoId = atmosphereSystem.GetGas(gas); + var gasName = _prototypeManager.Index(gasProtoId).Name; + label.SetMarkup(Loc.GetString("air-alarm-ui-gases-indicator", - ("gas", Loc.GetString(_atmos.GetGas(gas).Name)), // DeltaV - localize it instead of showing the enum name + ("gas", Loc.GetString(gasName)), ("color", AirAlarmWindow.ColorForThreshold(fractionGas, data.GasThresholds[gas])), ("amount", $"{amount:0.####}"), ("percentage", $"{(100 * fractionGas):0.##}"))); @@ -59,7 +67,7 @@ public sealed partial class SensorInfo : BoxContainer _gasLabels.Add(gas, label); var threshold = data.GasThresholds[gas]; - var gasThresholdControl = new ThresholdControl(Loc.GetString($"air-alarm-ui-thresholds-gas-title", ("gas", $"{gas}")), threshold, AtmosMonitorThresholdType.Gas, gas, 100); + var gasThresholdControl = new ThresholdControl(Loc.GetString($"air-alarm-ui-thresholds-gas-title"), threshold, AtmosMonitorThresholdType.Gas, gas, 100); gasThresholdControl.Margin = new Thickness(20, 2, 2, 2); gasThresholdControl.ThresholdDataChanged += (type, alarmThreshold, arg3) => { @@ -95,6 +103,9 @@ public sealed partial class SensorInfo : BoxContainer public void ChangeData(AtmosSensorData data) { + IoCManager.InjectDependencies(this); + var atmosphereSystem = _entMan.System(); + SensorAddress.Title = Loc.GetString("air-alarm-ui-window-listing-title", ("address", _address), ("state", data.AlarmState)); AlarmStateLabel.SetMarkup(Loc.GetString("air-alarm-ui-window-alarm-state-indicator", @@ -117,8 +128,12 @@ public sealed partial class SensorInfo : BoxContainer } var fractionGas = amount / data.TotalMoles; + + ProtoId gasProtoId = atmosphereSystem.GetGas(gas); + var gasName = _prototypeManager.Index(gasProtoId).Name; + label.SetMarkup(Loc.GetString("air-alarm-ui-gases-indicator", - ("gas", Loc.GetString(_atmos.GetGas(gas).Name)), // DeltaV - localize it instead of showing the enum name + ("gas", Loc.GetString(gasName)), ("color", AirAlarmWindow.ColorForThreshold(fractionGas, data.GasThresholds[gas])), ("amount", $"{amount:0.####}"), ("percentage", $"{(100 * fractionGas):0.##}"))); diff --git a/Content.Client/Atmos/Monitor/UI/Widgets/ThresholdBoundControl.xaml b/Content.Client/Atmos/Monitor/UI/Widgets/ThresholdBoundControl.xaml index 0d5e741d0f..7ce21fdd78 100644 --- a/Content.Client/Atmos/Monitor/UI/Widgets/ThresholdBoundControl.xaml +++ b/Content.Client/Atmos/Monitor/UI/Widgets/ThresholdBoundControl.xaml @@ -2,6 +2,6 @@ HorizontalExpand="True" Orientation="Vertical" Margin = "20 0 0 0" MinSize="160 0" > diff --git a/Content.Client/Atmos/Monitor/UI/Widgets/ThresholdControl.xaml b/Content.Client/Atmos/Monitor/UI/Widgets/ThresholdControl.xaml index 635a70f532..76fc1621ab 100644 --- a/Content.Client/Atmos/Monitor/UI/Widgets/ThresholdControl.xaml +++ b/Content.Client/Atmos/Monitor/UI/Widgets/ThresholdControl.xaml @@ -6,7 +6,7 @@ - + diff --git a/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs b/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs index 590f9ceae8..dada2ab5ca 100644 --- a/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs +++ b/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs @@ -1093,7 +1093,7 @@ namespace Content.Client.Lobby.UI _loadoutWindow = new LoadoutWindow(Profile, roleLoadout, roleLoadoutProto, _playerManager.LocalSession, collection) { - Title = jobProto?.ID + "-loadout", + Title = Loc.GetString("loadout-window-title-loadout", ("job", $"{jobProto?.LocalizedName}")), }; // Refresh the buttons etc. diff --git a/Content.Client/NetworkConfigurator/NetworkConfiguratorConfigurationMenu.xaml b/Content.Client/NetworkConfigurator/NetworkConfiguratorConfigurationMenu.xaml index 469faf209d..da0b9f60d8 100644 --- a/Content.Client/NetworkConfigurator/NetworkConfiguratorConfigurationMenu.xaml +++ b/Content.Client/NetworkConfigurator/NetworkConfiguratorConfigurationMenu.xaml @@ -5,15 +5,15 @@ -