Fix & extend add reagent verb (#4954)
* AddReagentWindow * addReagent command * functional UI * fix networking * add comments & docstrings * Remove unecesary system * cleanup & close-eui * tweak default window size * fix EUI closing error * fix merge issues * fix merge
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Content.Server.Administration.Commands;
|
||||
using Content.Server.Administration.Managers;
|
||||
using Content.Server.Administration.UI;
|
||||
using Content.Server.Chemistry.Components.SolutionManager;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Server.Configurable;
|
||||
using Content.Server.Disposal.Tube.Components;
|
||||
using Content.Server.EUI;
|
||||
@@ -12,14 +14,15 @@ using Content.Server.Inventory.Components;
|
||||
using Content.Server.Mind.Commands;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.Players;
|
||||
using Content.Server.Verbs;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.Interaction.Helpers;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Server.Console;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
@@ -39,9 +42,13 @@ namespace Content.Server.Administration
|
||||
[Dependency] private readonly EuiManager _euiManager = default!;
|
||||
[Dependency] private readonly GhostRoleSystem _ghostRoleSystem = default!;
|
||||
|
||||
private readonly Dictionary<IPlayerSession, EditSolutionsEui> _openSolutionUis = new();
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<GetOtherVerbsEvent>(AddDebugVerbs);
|
||||
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
|
||||
SubscribeLocalEvent<SolutionContainerManagerComponent, SolutionChangedEvent>(OnSolutionChanged);
|
||||
}
|
||||
|
||||
private void AddDebugVerbs(GetOtherVerbsEvent args)
|
||||
@@ -186,24 +193,51 @@ namespace Content.Server.Administration
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
// Add reagent verb
|
||||
if (_adminManager.HasAdminFlag(player, AdminFlags.Fun) &&
|
||||
// Add verb to open Solution Editor
|
||||
if (_groupController.CanCommand(player, "addreagent") &&
|
||||
args.Target.HasComponent<SolutionContainerManagerComponent>())
|
||||
{
|
||||
Verb verb = new();
|
||||
verb.Text = Loc.GetString("admin-add-reagent-verb-get-data-text");
|
||||
verb.Text = Loc.GetString("edit-solutions-verb-get-data-text");
|
||||
verb.Category = VerbCategory.Debug;
|
||||
verb.IconTexture = "/Textures/Interface/VerbIcons/spill.svg.192dpi.png";
|
||||
verb.Act = () => _euiManager.OpenEui(new AdminAddReagentEui(args.Target), player);
|
||||
|
||||
// TODO CHEMISTRY
|
||||
// Add reagent ui broke after solution refactor. Needs fixing
|
||||
verb.Disabled = true;
|
||||
verb.Message = "Currently non functional after solution refactor.";
|
||||
verb.Priority = -2;
|
||||
|
||||
verb.Act = () => OpenEditSolutionsEui(player, args.Target.Uid);
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
}
|
||||
|
||||
#region SolutionsEui
|
||||
private void OnSolutionChanged(EntityUid uid, SolutionContainerManagerComponent component, SolutionChangedEvent args)
|
||||
{
|
||||
foreach (var eui in _openSolutionUis.Values)
|
||||
{
|
||||
if (eui.Target == uid)
|
||||
eui.StateDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenEditSolutionsEui(IPlayerSession session, EntityUid uid)
|
||||
{
|
||||
if (session.AttachedEntity == null)
|
||||
return;
|
||||
|
||||
if (_openSolutionUis.ContainsKey(session))
|
||||
_openSolutionUis[session].Close();
|
||||
|
||||
var eui = _openSolutionUis[session] = new EditSolutionsEui(uid);
|
||||
_euiManager.OpenEui(eui, session);
|
||||
eui.StateDirty();
|
||||
}
|
||||
|
||||
public void OnEditSolutionsEuiClosed(IPlayerSession session)
|
||||
{
|
||||
_openSolutionUis.Remove(session, out var eui);
|
||||
}
|
||||
|
||||
private void Reset(RoundRestartCleanupEvent ev)
|
||||
{
|
||||
_openSolutionUis.Clear();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user