Skip to content

Commit

Permalink
Cherry-picked commit 0da09db from space-wizards/space-station-14/master
Browse files Browse the repository at this point in the history
  • Loading branch information
SlamBamActionman authored and SimpleStation14 committed Apr 21, 2024
1 parent 3bf08c7 commit 06ff7d7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
35 changes: 25 additions & 10 deletions Content.Server/Administration/Systems/AdminVerbSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public sealed partial class AdminVerbSystem : EntitySystem
[Dependency] private readonly StationSystem _stations = default!;
[Dependency] private readonly StationSpawningSystem _spawning = default!;

private readonly Dictionary<ICommonSession, EditSolutionsEui> _openSolutionUis = new();
private readonly Dictionary<ICommonSession, List<EditSolutionsEui>> _openSolutionUis = new();

public override void Initialize()
{
Expand Down Expand Up @@ -486,10 +486,13 @@ private void AddDebugVerbs(GetVerbsEvent<Verb> args)
#region SolutionsEui
private void OnSolutionChanged(Entity<SolutionContainerManagerComponent> entity, ref SolutionContainerChangedEvent args)
{
foreach (var eui in _openSolutionUis.Values)
foreach (var list in _openSolutionUis.Values)
{
if (eui.Target == entity.Owner)
eui.StateDirty();
foreach (var eui in list)
{
if (eui.Target == entity.Owner)
eui.StateDirty();
}
}
}

Expand All @@ -498,21 +501,33 @@ public void OpenEditSolutionsEui(ICommonSession session, EntityUid uid)
if (session.AttachedEntity == null)
return;

if (_openSolutionUis.ContainsKey(session))
_openSolutionUis[session].Close();

var eui = _openSolutionUis[session] = new EditSolutionsEui(uid);
var eui = new EditSolutionsEui(uid);
_euiManager.OpenEui(eui, session);
eui.StateDirty();

if (!_openSolutionUis.ContainsKey(session)) {
_openSolutionUis[session] = new List<EditSolutionsEui>();
}

_openSolutionUis[session].Add(eui);
}

public void OnEditSolutionsEuiClosed(ICommonSession session)
public void OnEditSolutionsEuiClosed(ICommonSession session, EditSolutionsEui eui)
{
_openSolutionUis.Remove(session, out var eui);
_openSolutionUis[session].Remove(eui);
if (_openSolutionUis[session].Count == 0)
_openSolutionUis.Remove(session);
}

private void Reset(RoundRestartCleanupEvent ev)
{
foreach (var euis in _openSolutionUis.Values)
{
foreach (var eui in euis.ToList())
{
eui.Close();
}
}
_openSolutionUis.Clear();
}
#endregion
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Administration/UI/EditSolutionsEui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public override void Opened()
public override void Closed()
{
base.Closed();
_entityManager.System<AdminVerbSystem>().OnEditSolutionsEuiClosed(Player);
_entityManager.System<AdminVerbSystem>().OnEditSolutionsEuiClosed(Player, this);
}

public override EuiStateBase GetNewState()
Expand Down

0 comments on commit 06ff7d7

Please sign in to comment.