From cbb3a6b351b2b2c80f7c50ee7655ddfc1741a834 Mon Sep 17 00:00:00 2001 From: 60093633 Date: Thu, 19 Dec 2024 15:03:45 +0300 Subject: [PATCH 01/15] Labeler --- .../Components/ReagentDispenserComponent.cs | 8 ++ .../EntitySystems/ReagentDispenserSystem.cs | 73 ++++++++++++++++++- .../reagent-dispenser-component.ftl | 6 ++ .../cargo/stocks-comapnies.ftl | 0 .../cargo/stocks-commands.ftl | 0 .../cartridge-loader/stocktrading.ftl | 0 .../reagent-dispenser-component.ftl | 5 ++ .../dynamichostname/hostname.ftl | 0 .../entities/objects/devices/pda.ftl | 0 .../objects/misc/identification_cards.ftl | 0 10 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 Resources/Locale/en-US/_corvaxnext/chemistry/components/reagent-dispenser-component.ftl rename Resources/Locale/ru-RU/{_CorvaxNext => _corvaxnext}/cargo/stocks-comapnies.ftl (100%) rename Resources/Locale/ru-RU/{_CorvaxNext => _corvaxnext}/cargo/stocks-commands.ftl (100%) rename Resources/Locale/ru-RU/{_CorvaxNext => _corvaxnext}/cartridge-loader/stocktrading.ftl (100%) create mode 100644 Resources/Locale/ru-RU/_corvaxnext/chemistry/components/reagent-dispenser-component.ftl rename Resources/Locale/ru-RU/{_CorvaxNext => _corvaxnext}/dynamichostname/hostname.ftl (100%) rename Resources/Locale/ru-RU/{_CorvaxNext => _corvaxnext}/prototypes/entities/objects/devices/pda.ftl (100%) rename Resources/Locale/ru-RU/{_CorvaxNext => _corvaxnext}/prototypes/entities/objects/misc/identification_cards.ftl (100%) diff --git a/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs b/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs index eb1839ef2ec..182404e2ca3 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: whether or not this entity can auto-label items + [DataField] + public bool CanAutoLabel; + + // Corvax-Next: whether or not this entity is currently auto-labeling items + [ViewVariables] + public bool AutoLabel; } } diff --git a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs index f8d4a7efcd5..4d3505f974a 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-ChemLabeler public override void Initialize() { @@ -37,10 +44,13 @@ public override void Initialize() SubscribeLocalEvent(SubscribeUpdateUiState); SubscribeLocalEvent(SubscribeUpdateUiState); - SubscribeLocalEvent(SubscribeUpdateUiState); + SubscribeLocalEvent(OnEntInserted); // Corvax-Next-ChemLabeler: SubscribeUpdateUiState < OnEntInserted SubscribeLocalEvent(SubscribeUpdateUiState); SubscribeLocalEvent(SubscribeUpdateUiState); + SubscribeLocalEvent>(OnAlternateVerb); // Corvax-Next-ChemLabeler + SubscribeLocalEvent(OnExamined); // Corvax-Next-ChemLabeler + SubscribeLocalEvent(OnSetDispenseAmountMessage); SubscribeLocalEvent(OnDispenseReagentMessage); SubscribeLocalEvent(OnClearContainerSolutionMessage); @@ -53,6 +63,64 @@ private void SubscribeUpdateUiState(Entity ent, re UpdateUiState(ent); } + // Corvax-Next-ChemLabeler-Start: auto-label on insert + 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 != 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")); + } + // End Corvax-Next-ChemLabeler-End + private void UpdateUiState(Entity reagentDispenser) { var outputContainer = _itemSlotsSystem.GetItemOrNull(reagentDispenser, SharedReagentDispenser.OutputSlotName); @@ -168,6 +236,9 @@ private void ClickSound(Entity reagentDispenser) /// private void OnMapInit(EntityUid uid, ReagentDispenserComponent component, MapInitEvent args) { + // Frontier: set auto-labeller + component.AutoLabel = component.CanAutoLabel; + // 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 From 280c0cc439407f0c50777a402e9cd1a7d0f8699d Mon Sep 17 00:00:00 2001 From: Kill_Me_I_Noobs <118206719+Vonsant@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:32:17 +0300 Subject: [PATCH 02/15] fix comment --- .../Chemistry/EntitySystems/ReagentDispenserSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs index 4d3505f974a..9c9e654d3b7 100644 --- a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs @@ -236,7 +236,7 @@ private void ClickSound(Entity reagentDispenser) /// private void OnMapInit(EntityUid uid, ReagentDispenserComponent component, MapInitEvent args) { - // Frontier: set auto-labeller + // Corvax-Next-ChemLabeler: set auto-labeller component.AutoLabel = component.CanAutoLabel; // Get list of pre-loaded containers From 4ab61c5062539117b3cb6bdd09b74a652a49f509 Mon Sep 17 00:00:00 2001 From: Kill_Me_I_Noobs <118206719+Vonsant@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:33:43 +0300 Subject: [PATCH 03/15] make it happen --- Resources/Prototypes/Entities/Structures/Dispensers/chem.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/Resources/Prototypes/Entities/Structures/Dispensers/chem.yml b/Resources/Prototypes/Entities/Structures/Dispensers/chem.yml index cf51ca9b1f6..8285e348dea 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-ChemLabeler - type: ApcPowerReceiver - type: ExtensionCableReceiver - type: Destructible From db5eec319b413e8ed58338fb84b9370359f3149e Mon Sep 17 00:00:00 2001 From: Kill_Me_I_Noobs <118206719+Vonsant@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:46:24 +0300 Subject: [PATCH 04/15] Update Resources/Prototypes/Entities/Structures/Dispensers/chem.yml Co-authored-by: FN <37689533+FireNameFN@users.noreply.github.com> --- Resources/Prototypes/Entities/Structures/Dispensers/chem.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/Prototypes/Entities/Structures/Dispensers/chem.yml b/Resources/Prototypes/Entities/Structures/Dispensers/chem.yml index 8285e348dea..0f63a575fcc 100644 --- a/Resources/Prototypes/Entities/Structures/Dispensers/chem.yml +++ b/Resources/Prototypes/Entities/Structures/Dispensers/chem.yml @@ -14,7 +14,7 @@ tags: - ChemDispensable pack: ChemDispenserStandardInventory - canAutoLabel: true # Corvax-Next-ChemLabeler + canAutoLabel: true # Corvax-Next-Labeler - type: ApcPowerReceiver - type: ExtensionCableReceiver - type: Destructible From 33e2eac161f11da43e63dba1fdc8cdfb5870ced4 Mon Sep 17 00:00:00 2001 From: Kill_Me_I_Noobs <118206719+Vonsant@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:47:44 +0300 Subject: [PATCH 05/15] Update Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs Co-authored-by: FN <37689533+FireNameFN@users.noreply.github.com> --- .../Chemistry/EntitySystems/ReagentDispenserSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs index 9c9e654d3b7..4d51154d6e9 100644 --- a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs @@ -69,7 +69,7 @@ private void OnEntInserted(Entity ent, ref EntInserte if (ent.Comp.AutoLabel && _solutionContainerSystem.TryGetDrainableSolution(ev.Entity, out _, out var sol)) { ReagentId? reagentId = sol.GetPrimaryReagentId(); - if (reagentId != null && _prototypeManager.TryIndex(reagentId.Value.Prototype, out var reagent)) + if (reagentId is not null && _prototypeManager.TryIndex(reagentId.Value.Prototype, out var reagent)) { var reagentQuantity = sol.GetReagentQuantity(reagentId.Value); var totalQuantity = sol.Volume; From 76aab93bf9f8dafb63d02886aa2b2415a7691e25 Mon Sep 17 00:00:00 2001 From: Kill_Me_I_Noobs <118206719+Vonsant@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:48:17 +0300 Subject: [PATCH 06/15] Update Content.Server/Chemistry/Components/ReagentDispenserComponent.cs Co-authored-by: FN <37689533+FireNameFN@users.noreply.github.com> --- .../Chemistry/Components/ReagentDispenserComponent.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs b/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs index 182404e2ca3..d7941a5a265 100644 --- a/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs +++ b/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs @@ -62,12 +62,12 @@ public sealed partial class ReagentDispenserComponent : Component [ViewVariables(VVAccess.ReadWrite)] public ReagentDispenserDispenseAmount DispenseAmount = ReagentDispenserDispenseAmount.U10; - // Corvax-Next: whether or not this entity can auto-label items + // Corvax-Next-Labeler-Start [DataField] public bool CanAutoLabel; - // Corvax-Next: whether or not this entity is currently auto-labeling items [ViewVariables] public bool AutoLabel; + // Corvax-Next-Labeler-End } } From f74633ff284bf37fb2a84b7d814697bbbc4e585b Mon Sep 17 00:00:00 2001 From: Kill_Me_I_Noobs <118206719+Vonsant@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:48:29 +0300 Subject: [PATCH 07/15] Update Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs Co-authored-by: FN <37689533+FireNameFN@users.noreply.github.com> --- .../Chemistry/EntitySystems/ReagentDispenserSystem.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs index 4d51154d6e9..61a76758677 100644 --- a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs @@ -236,8 +236,7 @@ private void ClickSound(Entity reagentDispenser) /// private void OnMapInit(EntityUid uid, ReagentDispenserComponent component, MapInitEvent args) { - // Corvax-Next-ChemLabeler: set auto-labeller - component.AutoLabel = component.CanAutoLabel; + component.AutoLabel = component.CanAutoLabel; // Corvax-Next-Labeler // Get list of pre-loaded containers List preLoad = new List(); From ad89cbf857a9f37f776f119923045fedddea2c51 Mon Sep 17 00:00:00 2001 From: Kill_Me_I_Noobs <118206719+Vonsant@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:49:02 +0300 Subject: [PATCH 08/15] Update Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs Co-authored-by: FN <37689533+FireNameFN@users.noreply.github.com> --- .../Chemistry/EntitySystems/ReagentDispenserSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs index 61a76758677..3f3ff97c8b1 100644 --- a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs @@ -44,7 +44,7 @@ public override void Initialize() SubscribeLocalEvent(SubscribeUpdateUiState); SubscribeLocalEvent(SubscribeUpdateUiState); - SubscribeLocalEvent(OnEntInserted); // Corvax-Next-ChemLabeler: SubscribeUpdateUiState < OnEntInserted + SubscribeLocalEvent(OnEntInserted); // Corvax-Next-Labeler: SubscribeUpdateUiState < OnEntInserted SubscribeLocalEvent(SubscribeUpdateUiState); SubscribeLocalEvent(SubscribeUpdateUiState); From 7351c545f6e46bbb310f1da6ab53ad872deb99f0 Mon Sep 17 00:00:00 2001 From: Kill_Me_I_Noobs <118206719+Vonsant@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:49:15 +0300 Subject: [PATCH 09/15] Update Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs Co-authored-by: FN <37689533+FireNameFN@users.noreply.github.com> --- .../Chemistry/EntitySystems/ReagentDispenserSystem.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs index 3f3ff97c8b1..4ac3fd1254d 100644 --- a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs @@ -48,8 +48,10 @@ public override void Initialize() SubscribeLocalEvent(SubscribeUpdateUiState); SubscribeLocalEvent(SubscribeUpdateUiState); - SubscribeLocalEvent>(OnAlternateVerb); // Corvax-Next-ChemLabeler - SubscribeLocalEvent(OnExamined); // Corvax-Next-ChemLabeler + // Corvax-Next-Labeler-Start + SubscribeLocalEvent>(OnAlternateVerb); + SubscribeLocalEvent(OnExamined); + // Corvax-Next-Labeler-End SubscribeLocalEvent(OnSetDispenseAmountMessage); SubscribeLocalEvent(OnDispenseReagentMessage); From ca5ee7e0fa8079cedc0e1e85d95d608a34c58d7a Mon Sep 17 00:00:00 2001 From: Kill_Me_I_Noobs <118206719+Vonsant@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:50:49 +0300 Subject: [PATCH 10/15] Update ReagentDispenserSystem.cs --- .../Chemistry/EntitySystems/ReagentDispenserSystem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs index 4ac3fd1254d..a78baeac8a5 100644 --- a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs @@ -65,7 +65,7 @@ private void SubscribeUpdateUiState(Entity ent, re UpdateUiState(ent); } - // Corvax-Next-ChemLabeler-Start: auto-label on insert + // // Corvax-Next-Labeler-Start private void OnEntInserted(Entity ent, ref EntInsertedIntoContainerMessage ev) { if (ent.Comp.AutoLabel && _solutionContainerSystem.TryGetDrainableSolution(ev.Entity, out _, out var sol)) @@ -121,7 +121,7 @@ private void OnExamined(Entity ent, ref ExaminedEvent else args.PushMarkup(Loc.GetString("reagent-dispenser-component-examine-auto-label-off")); } - // End Corvax-Next-ChemLabeler-End + // Corvax-Next-Labeler-End private void UpdateUiState(Entity reagentDispenser) { From 6758674059bc59f6f40f5883d89ad6a9747ec7e3 Mon Sep 17 00:00:00 2001 From: Kill_Me_I_Noobs <118206719+Vonsant@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:51:55 +0300 Subject: [PATCH 11/15] Update Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs Co-authored-by: FN <37689533+FireNameFN@users.noreply.github.com> --- .../Chemistry/EntitySystems/ReagentDispenserSystem.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs index a78baeac8a5..1065daa5bd9 100644 --- a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs @@ -92,10 +92,7 @@ private void OnAlternateVerb(Entity ent, ref GetVerbs args.Verbs.Add(new AlternativeVerb() { - Act = () => - { - SetAutoLabel(ent, !ent.Comp.AutoLabel); - }, + 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"), From edaae87797e1d28501c90a2f1f5f12b731057b20 Mon Sep 17 00:00:00 2001 From: Kill_Me_I_Noobs <118206719+Vonsant@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:54:59 +0300 Subject: [PATCH 12/15] Update Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs Co-authored-by: FN <37689533+FireNameFN@users.noreply.github.com> --- .../Chemistry/EntitySystems/ReagentDispenserSystem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs index 1065daa5bd9..393ea77cd28 100644 --- a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs @@ -94,8 +94,8 @@ private void OnAlternateVerb(Entity ent, ref GetVerbs { 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"), + 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. }); } From f2cc242b9be72d1f382c729c8c23cfdbd534e9a8 Mon Sep 17 00:00:00 2001 From: Kill_Me_I_Noobs <118206719+Vonsant@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:05:13 +0300 Subject: [PATCH 13/15] last and fast --- .../Chemistry/EntitySystems/ReagentDispenserSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs index 393ea77cd28..7a97418ff63 100644 --- a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs @@ -36,7 +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-ChemLabeler + [Dependency] private readonly LabelSystem _label = default!; // Corvax-Next-Labeler public override void Initialize() { From c3d64010d9233acbb244809601a66e154e7e9890 Mon Sep 17 00:00:00 2001 From: Kill_Me_I_Noobs <118206719+Vonsant@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:15:15 +0300 Subject: [PATCH 14/15] Update Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs Co-authored-by: FN <37689533+FireNameFN@users.noreply.github.com> --- .../Chemistry/EntitySystems/ReagentDispenserSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs index 7a97418ff63..0067cb40c4d 100644 --- a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs @@ -65,7 +65,7 @@ private void SubscribeUpdateUiState(Entity ent, re UpdateUiState(ent); } - // // Corvax-Next-Labeler-Start + // Corvax-Next-Labeler-Start private void OnEntInserted(Entity ent, ref EntInsertedIntoContainerMessage ev) { if (ent.Comp.AutoLabel && _solutionContainerSystem.TryGetDrainableSolution(ev.Entity, out _, out var sol)) From 5e9ac91486b6e5c38759d34fdec579531b8f8a59 Mon Sep 17 00:00:00 2001 From: Kill_Me_I_Noobs <118206719+Vonsant@users.noreply.github.com> Date: Thu, 19 Dec 2024 18:02:27 +0300 Subject: [PATCH 15/15] Update ReagentDispenserSystem.cs --- .../EntitySystems/ReagentDispenserSystem.cs | 92 +++++++++---------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs index 0067cb40c4d..858f0b8aa33 100644 --- a/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs @@ -66,59 +66,59 @@ private void SubscribeUpdateUiState(Entity ent, re } // Corvax-Next-Labeler-Start - private void OnEntInserted(Entity ent, ref EntInsertedIntoContainerMessage ev) + 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)) { - 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); + 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))); } + } - 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. - }); - } + UpdateUiState(ent); + } - private void SetAutoLabel(Entity ent, bool autoLabel) - { - if (!ent.Comp.CanAutoLabel) - return; + private void OnAlternateVerb(Entity ent, ref GetVerbsEvent args) + { + if (!ent.Comp.CanAutoLabel) + return; - ent.Comp.AutoLabel = autoLabel; - } + 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 OnExamined(Entity ent, ref ExaminedEvent args) - { - if (!args.IsInDetailsRange || !ent.Comp.CanAutoLabel) - return; + private void SetAutoLabel(Entity ent, bool autoLabel) + { + if (!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 + 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) {