Remove localization manager dependencies from components (#1864)

Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
This commit is contained in:
DrSmugleaf
2020-08-23 12:53:09 +02:00
committed by GitHub
parent 0b4ca168d4
commit a4a25a9975
22 changed files with 73 additions and 117 deletions

View File

@@ -21,6 +21,10 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
/// </summary>
public class ChemMasterWindow : SS14Window
{
#pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager;
#pragma warning restore 649
/// <summary>Contains info about the reagent container such as it's contents, if one is loaded into the dispenser.</summary>
private readonly VBoxContainer ContainerInfo;
@@ -45,11 +49,6 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
public Button CreatePills { get; }
public Button CreateBottles { get; }
#pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
protected override Vector2? CustomSize => (400, 200);
/// <summary>
@@ -69,9 +68,9 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
{
Children =
{
new Label {Text = _localizationManager.GetString("Container")},
new Label {Text = Loc.GetString("Container")},
new Control {SizeFlagsHorizontal = SizeFlags.FillExpand},
(EjectButton = new Button {Text = _localizationManager.GetString("Eject")})
(EjectButton = new Button {Text = Loc.GetString("Eject")})
}
},
//Wrap the container info in a PanelContainer so we can color it's background differently.
@@ -94,7 +93,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
{
new Label
{
Text = _localizationManager.GetString("No container loaded.")
Text = Loc.GetString("No container loaded.")
}
}
}),
@@ -109,10 +108,10 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
{
Children =
{
new Label {Text = _localizationManager.GetString("Buffer")},
new Label {Text = Loc.GetString("Buffer")},
new Control {SizeFlagsHorizontal = SizeFlags.FillExpand},
(BufferTransferButton = new Button {Text = _localizationManager.GetString("Transfer"), Pressed = BufferModeTransfer, StyleClasses = { StyleBase.ButtonOpenRight }}),
(BufferDiscardButton = new Button {Text = _localizationManager.GetString("Discard"), Pressed = !BufferModeTransfer, StyleClasses = { StyleBase.ButtonOpenLeft }})
(BufferTransferButton = new Button {Text = Loc.GetString("Transfer"), Pressed = BufferModeTransfer, StyleClasses = { StyleBase.ButtonOpenRight }}),
(BufferDiscardButton = new Button {Text = Loc.GetString("Discard"), Pressed = !BufferModeTransfer, StyleClasses = { StyleBase.ButtonOpenLeft }})
}
},
@@ -136,7 +135,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
{
new Label
{
Text = _localizationManager.GetString("Buffer empty.")
Text = Loc.GetString("Buffer empty.")
}
}
}),
@@ -151,7 +150,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
{
Children =
{
new Label {Text = _localizationManager.GetString("Packaging ")},
new Label {Text = Loc.GetString("Packaging ")},
}
},
@@ -185,7 +184,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
{
new Label
{
Text = _localizationManager.GetString("Pills:")
Text = Loc.GetString("Pills:")
},
},
@@ -212,7 +211,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
};
PillInfo.AddChild((pillVolume));
CreatePills = new Button {Text = _localizationManager.GetString("Create")};
CreatePills = new Button {Text = Loc.GetString("Create")};
PillInfo.AddChild(CreatePills);
//Bottles
@@ -222,7 +221,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
{
new Label
{
Text = _localizationManager.GetString("Bottles:")
Text = Loc.GetString("Bottles:")
},
},
@@ -249,7 +248,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
};
BottleInfo.AddChild((bottleVolume));
CreateBottles = new Button {Text = _localizationManager.GetString("Create")};
CreateBottles = new Button {Text = Loc.GetString("Create")};
BottleInfo.AddChild(CreateBottles);
}
@@ -314,7 +313,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
if (!state.HasBeaker)
{
ContainerInfo.Children.Add(new Label {Text = _localizationManager.GetString("No container loaded.")});
ContainerInfo.Children.Add(new Label {Text = Loc.GetString("No container loaded.")});
return;
}
@@ -333,7 +332,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
foreach (var reagent in state.ContainerReagents)
{
var name = _localizationManager.GetString("Unknown reagent");
var name = Loc.GetString("Unknown reagent");
//Try to the prototype for the given reagent. This gives us it's name.
if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype proto))
{
@@ -370,7 +369,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
if (!state.BufferReagents.Any())
{
BufferInfo.Children.Add(new Label {Text = _localizationManager.GetString("Buffer empty.")});
BufferInfo.Children.Add(new Label {Text = Loc.GetString("Buffer empty.")});
return;
}
@@ -388,7 +387,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ChemMaster
foreach (var reagent in state.BufferReagents)
{
var name = _localizationManager.GetString("Unknown reagent");
var name = Loc.GetString("Unknown reagent");
//Try to the prototype for the given reagent. This gives us it's name.
if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype proto))
{

View File

@@ -17,10 +17,6 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
[UsedImplicitly]
public class ReagentDispenserBoundUserInterface : BoundUserInterface
{
#pragma warning disable 649
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
private ReagentDispenserWindow _window;
private ReagentDispenserBoundUserInterfaceState _lastState;
@@ -41,7 +37,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
//Setup window layout/elements
_window = new ReagentDispenserWindow
{
Title = _localizationManager.GetString("Reagent dispenser"),
Title = Loc.GetString("Reagent dispenser"),
};
_window.OpenCentered();

View File

@@ -20,6 +20,10 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
/// </summary>
public class ReagentDispenserWindow : SS14Window
{
#pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager;
#pragma warning restore 649
/// <summary>Contains info about the reagent container such as it's contents, if one is loaded into the dispenser.</summary>
private readonly VBoxContainer ContainerInfo;
@@ -50,11 +54,6 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
/// <summary>A grid of buttons for each reagent which can be dispensed.</summary>
public GridContainer ChemicalList { get; }
#pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
protected override Vector2? CustomSize => (500, 600);
/// <summary>
@@ -76,7 +75,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
{
Children =
{
new Label {Text = _localizationManager.GetString("Amount")},
new Label {Text = Loc.GetString("Amount")},
//Padding
new Control {CustomMinimumSize = (20, 0)},
(DispenseButton1 = new Button {Text = "1", Group = dispenseAmountGroup, StyleClasses = { StyleBase.ButtonOpenRight }}),
@@ -100,9 +99,9 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
{
Children =
{
new Label {Text = _localizationManager.GetString("Container: ")},
(ClearButton = new Button {Text = _localizationManager.GetString("Clear"), StyleClasses = {StyleBase.ButtonOpenRight}}),
(EjectButton = new Button {Text = _localizationManager.GetString("Eject"), StyleClasses = {StyleBase.ButtonOpenLeft}})
new Label {Text = Loc.GetString("Container: ")},
(ClearButton = new Button {Text = Loc.GetString("Clear"), StyleClasses = {StyleBase.ButtonOpenRight}}),
(EjectButton = new Button {Text = Loc.GetString("Eject"), StyleClasses = {StyleBase.ButtonOpenLeft}})
}
},
//Wrap the container info in a PanelContainer so we can color it's background differently.
@@ -125,7 +124,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
{
new Label
{
Text = _localizationManager.GetString("No container loaded.")
Text = Loc.GetString("No container loaded.")
}
}
}),
@@ -155,7 +154,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
}
else
{
ChemicalList.AddChild(new Button {Text = _localizationManager.GetString("Reagent name not found")});
ChemicalList.AddChild(new Button {Text = Loc.GetString("Reagent name not found")});
}
}
}
@@ -243,7 +242,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
if (!state.HasBeaker)
{
ContainerInfo.Children.Add(new Label {Text = _localizationManager.GetString("No container loaded.")});
ContainerInfo.Children.Add(new Label {Text = Loc.GetString("No container loaded.")});
return;
}
@@ -267,7 +266,7 @@ namespace Content.Client.GameObjects.Components.Chemistry.ReagentDispenser
foreach (var reagent in state.ContainerReagents)
{
var name = _localizationManager.GetString("Unknown reagent");
var name = Loc.GetString("Unknown reagent");
//Try to the prototype for the given reagent. This gives us it's name.
if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype proto))
{

View File

@@ -2,7 +2,6 @@
using Content.Shared.GameObjects.EntitySystems;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
@@ -12,9 +11,6 @@ namespace Content.Client.GameObjects.Components.Construction
[RegisterComponent]
public class ConstructionGhostComponent : Component, IExamine
{
#pragma warning disable 649
[Dependency] private readonly ILocalizationManager _loc;
#pragma warning restore 649
public override string Name => "ConstructionGhost";
[ViewVariables] public ConstructionPrototype Prototype { get; set; }
@@ -22,7 +18,7 @@ namespace Content.Client.GameObjects.Components.Construction
void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
{
message.AddText(_loc.GetString("Building: {0}\n", Prototype.Name));
message.AddText(Loc.GetString("Building: {0}\n", Prototype.Name));
EntitySystem.Get<SharedConstructionSystem>().DoExamine(message, Prototype, 0, inDetailsRange);
}
}

View File

@@ -14,10 +14,6 @@ namespace Content.Client.GameObjects.Components.Research
private int[] _serverIds = new int[]{};
private int _selectedServerId = -1;
#pragma warning disable 649
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
protected override Vector2? CustomSize => (300, 300);
public ResearchClientBoundUserInterface Owner { get; set; }
@@ -25,7 +21,7 @@ namespace Content.Client.GameObjects.Components.Research
{
IoCManager.InjectDependencies(this);
Title = _localizationManager.GetString("Research Server Selection");
Title = Loc.GetString("Research Server Selection");
_servers = new ItemList() {SelectMode = ItemList.ItemListSelectMode.Single};