diff --git a/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs b/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs index eb1839ef2ec..d7941a5a265 100644 --- a/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs +++ b/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs @@ -61,5 +61,13 @@ public sealed partial class ReagentDispenserComponent : Component [ViewVariables(VVAccess.ReadWrite)] public ReagentDispenserDispenseAmount DispenseAmount = ReagentDispenserDispenseAmount.U10; + + // Corvax-Next-Labeler-Start + [DataField] + public bool CanAutoLabel; + + [ViewVariables] + public bool AutoLabel; + // Corvax-Next-Labeler-End } } diff --git a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs index f8d4a7efcd5..858f0b8aa33 100644 --- a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs @@ -13,6 +13,12 @@ using Robust.Shared.Containers; using Robust.Shared.Prototypes; using Content.Shared.Labels.Components; +using Content.Shared.Chemistry.Components.SolutionManager; +using Content.Shared.Chemistry.Components; +using Content.Shared.Chemistry.Reagent; +using Content.Server.Labels; +using Content.Shared.Verbs; +using Content.Shared.Examine; namespace Content.Server.Chemistry.EntitySystems { @@ -30,6 +36,7 @@ public sealed class ReagentDispenserSystem : EntitySystem [Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly OpenableSystem _openable = default!; + [Dependency] private readonly LabelSystem _label = default!; // Corvax-Next-Labeler public override void Initialize() { @@ -37,10 +44,15 @@ public override void Initialize() SubscribeLocalEvent(SubscribeUpdateUiState); SubscribeLocalEvent(SubscribeUpdateUiState); - SubscribeLocalEvent(SubscribeUpdateUiState); + SubscribeLocalEvent(OnEntInserted); // Corvax-Next-Labeler: SubscribeUpdateUiState < OnEntInserted SubscribeLocalEvent(SubscribeUpdateUiState); SubscribeLocalEvent(SubscribeUpdateUiState); + // Corvax-Next-Labeler-Start + SubscribeLocalEvent>(OnAlternateVerb); + SubscribeLocalEvent(OnExamined); + // Corvax-Next-Labeler-End + SubscribeLocalEvent(OnSetDispenseAmountMessage); SubscribeLocalEvent(OnDispenseReagentMessage); SubscribeLocalEvent(OnClearContainerSolutionMessage); @@ -53,6 +65,61 @@ private void SubscribeUpdateUiState(Entity ent, re UpdateUiState(ent); } + // Corvax-Next-Labeler-Start + private void OnEntInserted(Entity ent, ref EntInsertedIntoContainerMessage ev) + { + if (ent.Comp.AutoLabel && _solutionContainerSystem.TryGetDrainableSolution(ev.Entity, out _, out var sol)) + { + ReagentId? reagentId = sol.GetPrimaryReagentId(); + if (reagentId is not null && _prototypeManager.TryIndex(reagentId.Value.Prototype, out var reagent)) + { + var reagentQuantity = sol.GetReagentQuantity(reagentId.Value); + var totalQuantity = sol.Volume; + if (reagentQuantity == totalQuantity) + _label.Label(ev.Entity, reagent.LocalizedName); + else + _label.Label(ev.Entity, Loc.GetString("reagent-dispenser-component-impure-auto-label", ("reagent", reagent.LocalizedName), ("purity", 100.0f * reagentQuantity / totalQuantity))); + } + } + + UpdateUiState(ent); + } + + private void OnAlternateVerb(Entity ent, ref GetVerbsEvent args) + { + if (!ent.Comp.CanAutoLabel) + return; + + args.Verbs.Add(new AlternativeVerb() + { + Act = () => SetAutoLabel(ent, !ent.Comp.AutoLabel), + Text = ent.Comp.AutoLabel ? + Loc.GetString("reagent-dispenser-component-set-auto-label-off-verb") + : Loc.GetString("reagent-dispenser-component-set-auto-label-on-verb"), + Priority = -1, // Not important, low priority. + }); + } + + private void SetAutoLabel(Entity ent, bool autoLabel) + { + if (!ent.Comp.CanAutoLabel) + return; + + ent.Comp.AutoLabel = autoLabel; + } + + private void OnExamined(Entity ent, ref ExaminedEvent args) + { + if (!args.IsInDetailsRange || !ent.Comp.CanAutoLabel) + return; + + if (ent.Comp.AutoLabel) + args.PushMarkup(Loc.GetString("reagent-dispenser-component-examine-auto-label-on")); + else + args.PushMarkup(Loc.GetString("reagent-dispenser-component-examine-auto-label-off")); + } + // Corvax-Next-Labeler-End + private void UpdateUiState(Entity reagentDispenser) { var outputContainer = _itemSlotsSystem.GetItemOrNull(reagentDispenser, SharedReagentDispenser.OutputSlotName); @@ -168,6 +235,8 @@ private void ClickSound(Entity reagentDispenser) /// private void OnMapInit(EntityUid uid, ReagentDispenserComponent component, MapInitEvent args) { + component.AutoLabel = component.CanAutoLabel; // Corvax-Next-Labeler + // Get list of pre-loaded containers List preLoad = new List(); if (component.PackPrototypeId is not null diff --git a/Resources/Locale/en-US/_corvaxnext/chemistry/components/reagent-dispenser-component.ftl b/Resources/Locale/en-US/_corvaxnext/chemistry/components/reagent-dispenser-component.ftl new file mode 100644 index 00000000000..41a3344fe55 --- /dev/null +++ b/Resources/Locale/en-US/_corvaxnext/chemistry/components/reagent-dispenser-component.ftl @@ -0,0 +1,6 @@ +reagent-dispenser-component-impure-auto-label = {$reagent} ({$purity}%) +reagent-dispenser-component-set-auto-label-on-verb = Turn on auto-labeler +reagent-dispenser-component-set-auto-label-off-verb = Turn off auto-labeler +reagent-dispenser-component-examine-auto-label-on = The auto-labeler is turned [color=darkgreen]on[/color]. +reagent-dispenser-component-examine-auto-label-off = The auto-labeler is turned [color=red]off[/color]. +reagent-dispenser-component-examine-extra-slots = Number of jug slots diff --git a/Resources/Locale/ru-RU/_CorvaxNext/cargo/stocks-comapnies.ftl b/Resources/Locale/ru-RU/_corvaxnext/cargo/stocks-comapnies.ftl similarity index 100% rename from Resources/Locale/ru-RU/_CorvaxNext/cargo/stocks-comapnies.ftl rename to Resources/Locale/ru-RU/_corvaxnext/cargo/stocks-comapnies.ftl diff --git a/Resources/Locale/ru-RU/_CorvaxNext/cargo/stocks-commands.ftl b/Resources/Locale/ru-RU/_corvaxnext/cargo/stocks-commands.ftl similarity index 100% rename from Resources/Locale/ru-RU/_CorvaxNext/cargo/stocks-commands.ftl rename to Resources/Locale/ru-RU/_corvaxnext/cargo/stocks-commands.ftl diff --git a/Resources/Locale/ru-RU/_CorvaxNext/cartridge-loader/stocktrading.ftl b/Resources/Locale/ru-RU/_corvaxnext/cartridge-loader/stocktrading.ftl similarity index 100% rename from Resources/Locale/ru-RU/_CorvaxNext/cartridge-loader/stocktrading.ftl rename to Resources/Locale/ru-RU/_corvaxnext/cartridge-loader/stocktrading.ftl diff --git a/Resources/Locale/ru-RU/_corvaxnext/chemistry/components/reagent-dispenser-component.ftl b/Resources/Locale/ru-RU/_corvaxnext/chemistry/components/reagent-dispenser-component.ftl new file mode 100644 index 00000000000..4c11d2e8090 --- /dev/null +++ b/Resources/Locale/ru-RU/_corvaxnext/chemistry/components/reagent-dispenser-component.ftl @@ -0,0 +1,5 @@ +reagent-dispenser-component-impure-auto-label = {$reagent} ({$purity}%) +reagent-dispenser-component-set-auto-label-on-verb = Включить авто-этикеровщик +reagent-dispenser-component-set-auto-label-off-verb = Выключить авто-этикеровщик +reagent-dispenser-component-examine-auto-label-on = Авто-этикеровщик [color=darkgreen]включен[/color]. +reagent-dispenser-component-examine-auto-label-off = Авто-этикеровщик [color=red]выключен[/color]. diff --git a/Resources/Locale/ru-RU/_CorvaxNext/dynamichostname/hostname.ftl b/Resources/Locale/ru-RU/_corvaxnext/dynamichostname/hostname.ftl similarity index 100% rename from Resources/Locale/ru-RU/_CorvaxNext/dynamichostname/hostname.ftl rename to Resources/Locale/ru-RU/_corvaxnext/dynamichostname/hostname.ftl diff --git a/Resources/Locale/ru-RU/_CorvaxNext/prototypes/entities/objects/devices/pda.ftl b/Resources/Locale/ru-RU/_corvaxnext/prototypes/entities/objects/devices/pda.ftl similarity index 100% rename from Resources/Locale/ru-RU/_CorvaxNext/prototypes/entities/objects/devices/pda.ftl rename to Resources/Locale/ru-RU/_corvaxnext/prototypes/entities/objects/devices/pda.ftl diff --git a/Resources/Locale/ru-RU/_CorvaxNext/prototypes/entities/objects/misc/identification_cards.ftl b/Resources/Locale/ru-RU/_corvaxnext/prototypes/entities/objects/misc/identification_cards.ftl similarity index 100% rename from Resources/Locale/ru-RU/_CorvaxNext/prototypes/entities/objects/misc/identification_cards.ftl rename to Resources/Locale/ru-RU/_corvaxnext/prototypes/entities/objects/misc/identification_cards.ftl diff --git a/Resources/Prototypes/Entities/Structures/Dispensers/chem.yml b/Resources/Prototypes/Entities/Structures/Dispensers/chem.yml index cf51ca9b1f6..0f63a575fcc 100644 --- a/Resources/Prototypes/Entities/Structures/Dispensers/chem.yml +++ b/Resources/Prototypes/Entities/Structures/Dispensers/chem.yml @@ -14,6 +14,7 @@ tags: - ChemDispensable pack: ChemDispenserStandardInventory + canAutoLabel: true # Corvax-Next-Labeler - type: ApcPowerReceiver - type: ExtensionCableReceiver - type: Destructible