diff --git a/Content.Server/GameObjects/Components/ConfigurationComponent.cs b/Content.Server/GameObjects/Components/ConfigurationComponent.cs index 6e468e2435..7966c30815 100644 --- a/Content.Server/GameObjects/Components/ConfigurationComponent.cs +++ b/Content.Server/GameObjects/Components/ConfigurationComponent.cs @@ -1,11 +1,20 @@ using Content.Server.GameObjects.Components.Interactable; +using Content.Server.GameObjects.Components.Mobs; using Content.Server.Utility; using Content.Shared.GameObjects.Components; using Content.Shared.GameObjects.Components.Interactable; +using Content.Shared.GameObjects.EntitySystems; +using Content.Shared.GameObjects.Verbs; using Content.Shared.Interfaces.GameObjects.Components; +using Robust.Server.Console; using Robust.Server.GameObjects.Components.UserInterface; using Robust.Server.Interfaces.GameObjects; +using Robust.Server.Interfaces.Player; +using Robust.Server.Player; 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; using System.Collections.Generic; @@ -77,9 +86,7 @@ namespace Content.Server.GameObjects.Components if (!await tool.UseTool(eventArgs.User, Owner, 0.2f, ToolQuality.Multitool)) return false; - UpdateUserInterface(); - UserInterface.Open(actor.playerSession); - UserInterface.SendMessage(new ValidationUpdateMessage(_validation.ToString()), actor.playerSession); + OpenUserInterface(actor); return true; } @@ -109,11 +116,44 @@ namespace Content.Server.GameObjects.Components UserInterface?.SetState(new ConfigurationBoundUserInterfaceState(_config)); } + private void OpenUserInterface(IActorComponent actor) + { + UpdateUserInterface(); + UserInterface.Open(actor.playerSession); + UserInterface.SendMessage(new ValidationUpdateMessage(_validation.ToString()), actor.playerSession); + } + private static void FillConfiguration(List list, Dictionary configuration, T value){ for (var index = 0; index < list.Count; index++) { configuration.Add(list[index], value); } } + + [Verb] + public sealed class ConfigureVerb : Verb + { + protected override void GetData(IEntity user, ConfigurationComponent component, VerbData data) + { + var session = user.PlayerSession(); + var groupController = IoCManager.Resolve(); + if (session == null || !groupController.CanAdminMenu(session)) + { + data.Visibility = VerbVisibility.Invisible; + return; + } + + data.Text = Loc.GetString("Open Configuration"); + data.IconTexture = "/Textures/Interface/VerbIcons/settings.svg.96dpi.png"; + } + + protected override void Activate(IEntity user, ConfigurationComponent component) + { + if (user.TryGetComponent(out IActorComponent actor)) + { + component.OpenUserInterface(actor); + } + } + } } } diff --git a/Content.Server/GameObjects/Components/Disposal/DisposalRouterComponent.cs b/Content.Server/GameObjects/Components/Disposal/DisposalRouterComponent.cs index b84da4b120..6416eab035 100644 --- a/Content.Server/GameObjects/Components/Disposal/DisposalRouterComponent.cs +++ b/Content.Server/GameObjects/Components/Disposal/DisposalRouterComponent.cs @@ -2,19 +2,25 @@ using System; using System.Collections.Generic; using System.Text; +using Content.Server.GameObjects.Components.Mobs; using Content.Server.Interfaces.GameObjects.Components.Items; using Content.Server.Utility; using Content.Shared.GameObjects.EntitySystems; +using Content.Shared.GameObjects.Verbs; using Content.Shared.Interfaces; using Content.Shared.Interfaces.GameObjects.Components; +using Robust.Server.Console; using Robust.Server.GameObjects.Components.UserInterface; using Robust.Server.GameObjects.EntitySystems; using Robust.Server.Interfaces.GameObjects; +using Robust.Server.Interfaces.Player; +using Robust.Server.Player; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Maths; using Robust.Shared.ViewVariables; @@ -77,7 +83,7 @@ namespace Content.Server.GameObjects.Components.Disposal var msg = (UiActionMessage) obj.Message; - if (!PlayerCanUseDisposalTagger(obj.Session.AttachedEntity)) + if (!PlayerCanUseDisposalTagger(obj.Session)) return; //Check for correct message and ignore maleformed strings @@ -95,22 +101,25 @@ namespace Content.Server.GameObjects.Components.Disposal /// /// Checks whether the player entity is able to use the configuration interface of the pipe tagger. /// - /// The player entity. + /// The player session. /// Returns true if the entity can use the configuration interface, and false if it cannot. - private bool PlayerCanUseDisposalTagger(IEntity playerEntity) + private bool PlayerCanUseDisposalTagger(IPlayerSession session) { //Need player entity to check if they are still able to use the configuration interface - if (playerEntity == null) + if (session.AttachedEntity == null) return false; if (!Anchored) return false; + + var groupController = IoCManager.Resolve(); //Check if player can interact in their current state - if (!ActionBlockerSystem.CanInteract(playerEntity) || !ActionBlockerSystem.CanUse(playerEntity)) + if (!groupController.CanAdminMenu(session) && (!ActionBlockerSystem.CanInteract(session.AttachedEntity) || !ActionBlockerSystem.CanUse(session.AttachedEntity))) return false; return true; } + /// /// Gets component data to be used to update the user interface client-side. /// @@ -166,8 +175,7 @@ namespace Content.Server.GameObjects.Components.Disposal var activeHandEntity = hands.GetActiveHand?.Owner; if (activeHandEntity == null) { - UpdateUserInterface(); - UserInterface?.Open(actor.playerSession); + OpenUserInterface(actor); } } @@ -176,5 +184,37 @@ namespace Content.Server.GameObjects.Components.Disposal UserInterface?.CloseAll(); base.OnRemove(); } + + private void OpenUserInterface(IActorComponent actor) + { + UpdateUserInterface(); + UserInterface?.Open(actor.playerSession); + } + + [Verb] + public sealed class ConfigureVerb : Verb + { + protected override void GetData(IEntity user, DisposalRouterComponent component, VerbData data) + { + var session = user.PlayerSession(); + var groupController = IoCManager.Resolve(); + if (session == null || !groupController.CanAdminMenu(session)) + { + data.Visibility = VerbVisibility.Invisible; + return; + } + + data.Text = Loc.GetString("Open Configuration"); + data.IconTexture = "/Textures/Interface/VerbIcons/settings.svg.96dpi.png"; + } + + protected override void Activate(IEntity user, DisposalRouterComponent component) + { + if (user.TryGetComponent(out IActorComponent? actor)) + { + component.OpenUserInterface(actor); + } + } + } } } diff --git a/Content.Server/GameObjects/Components/Disposal/DisposalTaggerComponent.cs b/Content.Server/GameObjects/Components/Disposal/DisposalTaggerComponent.cs index 1dc7c43647..63d91085e1 100644 --- a/Content.Server/GameObjects/Components/Disposal/DisposalTaggerComponent.cs +++ b/Content.Server/GameObjects/Components/Disposal/DisposalTaggerComponent.cs @@ -1,20 +1,26 @@ #nullable enable +using Content.Server.GameObjects.Components.Mobs; using Content.Server.Interfaces.GameObjects.Components.Items; using Content.Server.Utility; using Content.Shared.GameObjects.EntitySystems; +using Content.Shared.GameObjects.Verbs; using Content.Shared.Interfaces; using Content.Shared.Interfaces.GameObjects.Components; +using Robust.Server.Console; using Robust.Server.GameObjects.Components.UserInterface; using Robust.Server.GameObjects.EntitySystems; using Robust.Server.Interfaces.GameObjects; +using Robust.Server.Interfaces.Player; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Maths; using Robust.Shared.ViewVariables; +using System; using static Content.Shared.GameObjects.Components.Disposal.SharedDisposalTaggerComponent; namespace Content.Server.GameObjects.Components.Disposal @@ -63,7 +69,7 @@ namespace Content.Server.GameObjects.Components.Disposal { var msg = (UiActionMessage) obj.Message; - if (!PlayerCanUseDisposalTagger(obj.Session.AttachedEntity)) + if (!PlayerCanUseDisposalTagger(obj.Session)) return; //Check for correct message and ignore maleformed strings @@ -77,17 +83,19 @@ namespace Content.Server.GameObjects.Components.Disposal /// /// Checks whether the player entity is able to use the configuration interface of the pipe tagger. /// - /// The player entity. + /// The player entity. /// Returns true if the entity can use the configuration interface, and false if it cannot. - private bool PlayerCanUseDisposalTagger(IEntity? playerEntity) + private bool PlayerCanUseDisposalTagger(IPlayerSession session) { //Need player entity to check if they are still able to use the configuration interface - if (playerEntity == null) + if (session.AttachedEntity == null) return false; if (!Anchored) return false; + + var groupController = IoCManager.Resolve(); //Check if player can interact in their current state - if (!ActionBlockerSystem.CanInteract(playerEntity) || !ActionBlockerSystem.CanUse(playerEntity)) + if (!groupController.CanAdminMenu(session) && (!ActionBlockerSystem.CanInteract(session.AttachedEntity) || !ActionBlockerSystem.CanUse(session.AttachedEntity))) return false; return true; @@ -133,8 +141,7 @@ namespace Content.Server.GameObjects.Components.Disposal var activeHandEntity = hands.GetActiveHand?.Owner; if (activeHandEntity == null) { - UpdateUserInterface(); - UserInterface?.Open(actor.playerSession); + OpenUserInterface(actor); } } @@ -143,5 +150,37 @@ namespace Content.Server.GameObjects.Components.Disposal base.OnRemove(); UserInterface?.CloseAll(); } + + [Verb] + public sealed class ConfigureVerb : Verb + { + protected override void GetData(IEntity user, DisposalTaggerComponent component, VerbData data) + { + + var groupController = IoCManager.Resolve(); + if (!user.TryGetComponent(out IActorComponent? actor) || !groupController.CanAdminMenu(actor.playerSession)) + { + data.Visibility = VerbVisibility.Invisible; + return; + } + + data.Text = Loc.GetString("Open Configuration"); + data.IconTexture = "/Textures/Interface/VerbIcons/settings.svg.96dpi.png"; + } + + protected override void Activate(IEntity user, DisposalTaggerComponent component) + { + if (user.TryGetComponent(out IActorComponent? actor)) + { + component.OpenUserInterface(actor); + } + } + } + + private void OpenUserInterface(IActorComponent actor) + { + UpdateUserInterface(); + UserInterface?.Open(actor.playerSession); + } } } diff --git a/Resources/Textures/Interface/VerbIcons/settings.svg b/Resources/Textures/Interface/VerbIcons/settings.svg new file mode 100644 index 0000000000..16adb31f18 --- /dev/null +++ b/Resources/Textures/Interface/VerbIcons/settings.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Resources/Textures/Interface/VerbIcons/settings.svg.96dpi.png b/Resources/Textures/Interface/VerbIcons/settings.svg.96dpi.png new file mode 100644 index 0000000000..9a749806a1 Binary files /dev/null and b/Resources/Textures/Interface/VerbIcons/settings.svg.96dpi.png differ