Enable multiple Solution Editor windows (#26005)
* More solution edit windows * Fix error when closing euis after round restart --------- Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
This commit is contained in:
@@ -67,7 +67,7 @@ namespace Content.Server.Administration.Systems
|
|||||||
[Dependency] private readonly StationSystem _stations = default!;
|
[Dependency] private readonly StationSystem _stations = default!;
|
||||||
[Dependency] private readonly StationSpawningSystem _spawning = 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()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -486,10 +486,13 @@ namespace Content.Server.Administration.Systems
|
|||||||
#region SolutionsEui
|
#region SolutionsEui
|
||||||
private void OnSolutionChanged(Entity<SolutionContainerManagerComponent> entity, ref SolutionContainerChangedEvent args)
|
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)
|
foreach (var eui in list)
|
||||||
eui.StateDirty();
|
{
|
||||||
|
if (eui.Target == entity.Owner)
|
||||||
|
eui.StateDirty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,21 +501,33 @@ namespace Content.Server.Administration.Systems
|
|||||||
if (session.AttachedEntity == null)
|
if (session.AttachedEntity == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_openSolutionUis.ContainsKey(session))
|
var eui = new EditSolutionsEui(uid);
|
||||||
_openSolutionUis[session].Close();
|
|
||||||
|
|
||||||
var eui = _openSolutionUis[session] = new EditSolutionsEui(uid);
|
|
||||||
_euiManager.OpenEui(eui, session);
|
_euiManager.OpenEui(eui, session);
|
||||||
eui.StateDirty();
|
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)
|
private void Reset(RoundRestartCleanupEvent ev)
|
||||||
{
|
{
|
||||||
|
foreach (var euis in _openSolutionUis.Values)
|
||||||
|
{
|
||||||
|
foreach (var eui in euis.ToList())
|
||||||
|
{
|
||||||
|
eui.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
_openSolutionUis.Clear();
|
_openSolutionUis.Clear();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace Content.Server.Administration.UI
|
|||||||
public override void Closed()
|
public override void Closed()
|
||||||
{
|
{
|
||||||
base.Closed();
|
base.Closed();
|
||||||
_entityManager.System<AdminVerbSystem>().OnEditSolutionsEuiClosed(Player);
|
_entityManager.System<AdminVerbSystem>().OnEditSolutionsEuiClosed(Player, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override EuiStateBase GetNewState()
|
public override EuiStateBase GetNewState()
|
||||||
|
|||||||
Reference in New Issue
Block a user