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

@@ -25,7 +25,6 @@ namespace Content.Server.GameObjects.Components.Access
public class IdCardConsoleComponent : SharedIdCardConsoleComponent, IActivate
{
[Dependency] private readonly IServerNotifyManager _notifyManager = default!;
[Dependency] private readonly ILocalizationManager _localizationManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private ContainerSlot _privilegedIdContainer = default!;
@@ -137,7 +136,7 @@ namespace Content.Server.GameObjects.Components.Access
{
if (!user.TryGetComponent(out IHandsComponent? hands))
{
_notifyManager.PopupMessage(Owner.Transform.GridPosition, user, _localizationManager.GetString("You have no hands."));
_notifyManager.PopupMessage(Owner.Transform.GridPosition, user, Loc.GetString("You have no hands."));
return;
}
@@ -166,7 +165,7 @@ namespace Content.Server.GameObjects.Components.Access
if (!hands.Drop(hands.ActiveHand, container))
{
_notifyManager.PopupMessage(Owner.Transform.GridPosition, user, _localizationManager.GetString("You can't let go of the ID card!"));
_notifyManager.PopupMessage(Owner.Transform.GridPosition, user, Loc.GetString("You can't let go of the ID card!"));
return;
}
UpdateUserInterface();

View File

@@ -43,7 +43,6 @@ namespace Content.Server.GameObjects.Components.Chemistry
public class ChemMasterComponent : SharedChemMasterComponent, IActivate, IInteractUsing, ISolutionChange
{
[Dependency] private readonly IServerNotifyManager _notifyManager = default!;
[Dependency] private readonly ILocalizationManager _localizationManager = default!;
[ViewVariables] private ContainerSlot _beakerContainer = default!;
[ViewVariables] private string _packPrototypeId = "";
@@ -373,7 +372,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
if (!args.User.TryGetComponent(out IHandsComponent? hands))
{
_notifyManager.PopupMessage(Owner.Transform.GridPosition, args.User,
_localizationManager.GetString("You have no hands."));
Loc.GetString("You have no hands."));
return;
}
@@ -396,7 +395,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
if (!args.User.TryGetComponent(out IHandsComponent? hands))
{
_notifyManager.PopupMessage(Owner.Transform.GridPosition, args.User,
_localizationManager.GetString("You have no hands."));
Loc.GetString("You have no hands."));
return true;
}
@@ -413,13 +412,13 @@ namespace Content.Server.GameObjects.Components.Chemistry
if (HasBeaker)
{
_notifyManager.PopupMessage(Owner.Transform.GridPosition, args.User,
_localizationManager.GetString("This ChemMaster already has a container in it."));
Loc.GetString("This ChemMaster already has a container in it."));
}
else if ((solution.Capabilities & SolutionCaps.FitsInDispenser) == 0) //Close enough to a chem master...
{
//If it can't fit in the chem master, don't put it in. For example, buckets and mop buckets can't fit.
_notifyManager.PopupMessage(Owner.Transform.GridPosition, args.User,
_localizationManager.GetString("That can't fit in the ChemMaster."));
Loc.GetString("That can't fit in the ChemMaster."));
}
else
{
@@ -430,7 +429,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
else
{
_notifyManager.PopupMessage(Owner.Transform.GridPosition, args.User,
_localizationManager.GetString("You can't put this in the ChemMaster."));
Loc.GetString("You can't put this in the ChemMaster."));
}
return true;

View File

@@ -21,7 +21,6 @@ namespace Content.Server.GameObjects.Components.Chemistry
{
#pragma warning disable 649
[Dependency] private readonly IServerNotifyManager _notifyManager;
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
public override string Name => "Pourable";
@@ -91,7 +90,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
if (realTransferAmount <= 0) //Special message if container is full
{
_notifyManager.PopupMessage(Owner.Transform.GridPosition, eventArgs.User,
_localizationManager.GetString("Container is full"));
Loc.GetString("Container is full"));
return false;
}
@@ -101,7 +100,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
return false;
_notifyManager.PopupMessage(Owner.Transform.GridPosition, eventArgs.User,
_localizationManager.GetString("Transferred {0}u", removedSolution.TotalVolume));
Loc.GetString("Transferred {0}u", removedSolution.TotalVolume));
return true;
}

View File

@@ -40,7 +40,6 @@ namespace Content.Server.GameObjects.Components.Chemistry
public class ReagentDispenserComponent : SharedReagentDispenserComponent, IActivate, IInteractUsing, ISolutionChange
{
[Dependency] private readonly IServerNotifyManager _notifyManager = default!;
[Dependency] private readonly ILocalizationManager _localizationManager = default!;
[ViewVariables] private ContainerSlot _beakerContainer = default!;
[ViewVariables] private string _packPrototypeId = "";
@@ -286,7 +285,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
if (!args.User.TryGetComponent(out IHandsComponent? hands))
{
_notifyManager.PopupMessage(Owner.Transform.GridPosition, args.User,
_localizationManager.GetString("You have no hands."));
Loc.GetString("You have no hands."));
return;
}
@@ -309,7 +308,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
if (!args.User.TryGetComponent(out IHandsComponent? hands))
{
_notifyManager.PopupMessage(Owner.Transform.GridPosition, args.User,
_localizationManager.GetString("You have no hands."));
Loc.GetString("You have no hands."));
return true;
}
@@ -326,13 +325,13 @@ namespace Content.Server.GameObjects.Components.Chemistry
if (HasBeaker)
{
_notifyManager.PopupMessage(Owner.Transform.GridPosition, args.User,
_localizationManager.GetString("This dispenser already has a container in it."));
Loc.GetString("This dispenser already has a container in it."));
}
else if ((solution.Capabilities & SolutionCaps.FitsInDispenser) == 0)
{
//If it can't fit in the dispenser, don't put it in. For example, buckets and mop buckets can't fit.
_notifyManager.PopupMessage(Owner.Transform.GridPosition, args.User,
_localizationManager.GetString("That can't fit in the dispenser."));
Loc.GetString("That can't fit in the dispenser."));
}
else
{
@@ -343,7 +342,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
else
{
_notifyManager.PopupMessage(Owner.Transform.GridPosition, args.User,
_localizationManager.GetString("You can't put this in the dispenser."));
Loc.GetString("You can't put this in the dispenser."));
}
return true;

View File

@@ -31,7 +31,6 @@ namespace Content.Server.GameObjects.Components.Chemistry
{
#pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly ILocalizationManager _loc;
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
#pragma warning restore 649
@@ -276,7 +275,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
return;
}
message.AddText(_loc.GetString("Contains:\n"));
message.AddText(Loc.GetString("Contains:\n"));
if (ReagentList.Count == 0)
{
message.AddText("Nothing.\n");
@@ -303,12 +302,12 @@ namespace Content.Server.GameObjects.Components.Chemistry
colorIsh = "Blue";
}
message.AddText(_loc.GetString("A {0} liquid\n", colorIsh));
message.AddText(Loc.GetString("A {0} liquid\n", colorIsh));
}
}
else
{
message.AddText(_loc.GetString("Unknown reagent: {0}u\n", reagent.Quantity));
message.AddText(Loc.GetString("Unknown reagent: {0}u\n", reagent.Quantity));
}
}
}

View File

@@ -20,8 +20,6 @@ namespace Content.Server.GameObjects.Components.Fluids
[RegisterComponent]
public class BucketComponent : Component, IInteractUsing
{
[Dependency] private readonly ILocalizationManager _localizationManager = default!;
public override string Name => "Bucket";
public ReagentUnit MaxVolume
@@ -101,7 +99,7 @@ namespace Content.Server.GameObjects.Components.Fluids
return false;
}
Owner.PopupMessage(eventArgs.User, _localizationManager.GetString("Splish"));
Owner.PopupMessage(eventArgs.User, Loc.GetString("Splish"));
return true;
}
@@ -119,7 +117,7 @@ namespace Content.Server.GameObjects.Components.Fluids
}
// Give some visual feedback shit's happening (for anyone who can't hear sound)
Owner.PopupMessage(eventArgs.User, _localizationManager.GetString("Sploosh"));
Owner.PopupMessage(eventArgs.User, Loc.GetString("Sploosh"));
if (_sound == null)
{

View File

@@ -6,7 +6,6 @@ using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Serialization;
@@ -18,10 +17,6 @@ namespace Content.Server.GameObjects.Components.Fluids
[RegisterComponent]
public class MopComponent : Component, IAfterInteract
{
#pragma warning disable 649
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
public override string Name => "Mop";
internal SolutionComponent Contents => _contents;
private SolutionComponent _contents;
@@ -115,7 +110,7 @@ namespace Content.Server.GameObjects.Components.Fluids
}
// Give some visual feedback shit's happening (for anyone who can't hear sound)
Owner.PopupMessage(eventArgs.User, _localizationManager.GetString("Swish"));
Owner.PopupMessage(eventArgs.User, Loc.GetString("Swish"));
if (_pickupSound == null)
{

View File

@@ -48,7 +48,6 @@ namespace Content.Server.GameObjects.Components.Fluids
#pragma warning disable 649
[Dependency] private readonly IMapManager _mapManager;
[Dependency] private readonly ILocalizationManager _loc;
#pragma warning restore 649
public override string Name => "Puddle";
@@ -160,7 +159,7 @@ namespace Content.Server.GameObjects.Components.Fluids
{
if(_slippery)
{
message.AddText(_loc.GetString("It looks slippery."));
message.AddText(Loc.GetString("It looks slippery."));
}
}

View File

@@ -31,7 +31,6 @@ namespace Content.Server.GameObjects.Components.Interactable
internal sealed class HandheldLightComponent : SharedHandheldLightComponent, IUse, IExamine, IInteractUsing, IMapInit
{
[Dependency] private readonly ISharedNotifyManager _notifyManager = default!;
[Dependency] private readonly ILocalizationManager _localizationManager = default!;
[ViewVariables(VVAccess.ReadWrite)] public float Wattage { get; set; } = 10;
[ViewVariables] private ContainerSlot _cellContainer = default!;
@@ -77,11 +76,9 @@ namespace Content.Server.GameObjects.Components.Interactable
void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
{
var loc = IoCManager.Resolve<ILocalizationManager>();
if (Activated)
{
message.AddMarkup(loc.GetString("The light is currently [color=darkgreen]on[/color]."));
message.AddMarkup(Loc.GetString("The light is currently [color=darkgreen]on[/color]."));
}
}
@@ -151,7 +148,7 @@ namespace Content.Server.GameObjects.Components.Interactable
EntitySystem.Get<AudioSystem>().PlayFromEntity("/Audio/Machines/button.ogg", Owner);
_notifyManager.PopupMessage(Owner, user, _localizationManager.GetString("Cell missing..."));
_notifyManager.PopupMessage(Owner, user, Loc.GetString("Cell missing..."));
return;
}
@@ -161,7 +158,7 @@ namespace Content.Server.GameObjects.Components.Interactable
if (Wattage > cell.CurrentCharge)
{
EntitySystem.Get<AudioSystem>().PlayFromEntity("/Audio/Machines/button.ogg", Owner);
_notifyManager.PopupMessage(Owner, user, _localizationManager.GetString("Dead cell..."));
_notifyManager.PopupMessage(Owner, user, Loc.GetString("Dead cell..."));
return;
}

View File

@@ -85,9 +85,9 @@ namespace Content.Server.GameObjects.Components.Items
void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
{
//No details check, since the sprite updates to show the side.
var loc = IoCManager.Resolve<ILocalizationManager>();
message.AddMarkup(loc.GetString("A dice with [color=lightgray]{0}[/color] sides.\n" +
"It has landed on a [color=white]{1}[/color].", _sides, _currentSide));
message.AddMarkup(Loc.GetString(
"A dice with [color=lightgray]{0}[/color] sides.\n" + "It has landed on a [color=white]{1}[/color].",
_sides, _currentSide));
}
}
}

View File

@@ -13,7 +13,6 @@ using Robust.Server.GameObjects;
using Robust.Server.GameObjects.Components.Container;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -76,8 +75,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerRece
var result = TryInsertItem(eventArgs.Using);
if (!result)
{
var localizationManager = IoCManager.Resolve<ILocalizationManager>();
eventArgs.User.PopupMessage(Owner, localizationManager.GetString("Unable to insert capacitor"));
eventArgs.User.PopupMessage(Owner, Loc.GetString("Unable to insert capacitor"));
}
return result;

View File

@@ -15,7 +15,6 @@ namespace Content.Server.GameObjects.Components.Rotatable
{
#pragma warning disable 649
[Dependency] private readonly IServerNotifyManager _notifyManager;
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
public override string Name => "Rotatable";
@@ -25,7 +24,7 @@ namespace Content.Server.GameObjects.Components.Rotatable
{
if (collidable.Anchored)
{
_notifyManager.PopupMessage(Owner.Transform.GridPosition, user, _localizationManager.GetString("It's stuck."));
_notifyManager.PopupMessage(Owner.Transform.GridPosition, user, Loc.GetString("It's stuck."));
return;
}
}

View File

@@ -107,8 +107,7 @@ namespace Content.Server.GameObjects.Components.Stack
{
if (inDetailsRange)
{
var loc = IoCManager.Resolve<ILocalizationManager>();
message.AddMarkup(loc.GetPluralString(
message.AddMarkup(Loc.GetPluralString(
"There is [color=lightgray]1[/color] thing in the stack",
"There are [color=lightgray]{0}[/color] things in the stack.", Count, Count));
}

View File

@@ -23,7 +23,6 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
public class FlashComponent : MeleeWeaponComponent, IUse, IExamine
{
#pragma warning disable 649
[Dependency] private readonly ILocalizationManager _localizationManager;
[Dependency] private readonly IEntityManager _entityManager;
[Dependency] private readonly ISharedNotifyManager _notifyManager;
#pragma warning restore 649
@@ -173,10 +172,10 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
if (inDetailsRange)
{
message.AddMarkup(
_localizationManager.GetString(
Loc.GetString(
"The flash has [color=green]{0}[/color] {1} remaining.",
Uses,
_localizationManager.GetPluralString("use", "uses", Uses)
Loc.GetPluralString("use", "uses", Uses)
)
);
}

View File

@@ -33,7 +33,6 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
#pragma warning disable 649
[Dependency] private IRobustRandom _robustRandom;
[Dependency] private readonly ISharedNotifyManager _notifyManager;
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
public override string Name => "Stunbaton";
@@ -168,14 +167,14 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
{
EntitySystem.Get<AudioSystem>().PlayAtCoords("/Audio/Machines/button.ogg", Owner.Transform.GridPosition, AudioHelpers.WithVariation(0.25f));
_notifyManager.PopupMessage(Owner, user, _localizationManager.GetString("Cell missing..."));
_notifyManager.PopupMessage(Owner, user, Loc.GetString("Cell missing..."));
return;
}
if (cell.CurrentCharge < EnergyPerUse)
{
EntitySystem.Get<AudioSystem>().PlayAtCoords("/Audio/Machines/button.ogg", Owner.Transform.GridPosition, AudioHelpers.WithVariation(0.25f));
_notifyManager.PopupMessage(Owner, user, _localizationManager.GetString("Dead cell..."));
_notifyManager.PopupMessage(Owner, user, Loc.GetString("Dead cell..."));
return;
}
@@ -242,11 +241,9 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
public void Examine(FormattedMessage message, bool inDetailsRange)
{
var loc = IoCManager.Resolve<ILocalizationManager>();
if (Activated)
{
message.AddMarkup(loc.GetString("The light is currently [color=darkgreen]on[/color]."));
message.AddMarkup(Loc.GetString("The light is currently [color=darkgreen]on[/color]."));
}
}

View File

@@ -491,9 +491,7 @@ namespace Content.Server.GameObjects.Components
void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
{
var loc = IoCManager.Resolve<ILocalizationManager>();
message.AddMarkup(loc.GetString(IsPanelOpen
message.AddMarkup(Loc.GetString(IsPanelOpen
? "The [color=lightgray]maintenance panel[/color] is [color=darkgreen]open[/color]."
: "The [color=lightgray]maintenance panel[/color] is [color=darkred]closed[/color]."));
}