mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 05:59:03 +03:00
## Mirror of PR #26005: [Enable multiple Solution Editor windows](https://github.com/space-wizards/space-station-14/pull/26005) from <img src="https://avatars.githubusercontent.com/u/10567778?v=4" alt="space-wizards" width="22"/> [space-wizards](https://github.com/space-wizards)/[space-station-14](https://github.com/space-wizards/space-station-14) ###### `0da09db99ac556e0efdce40268e60eb5a06a0694` PR opened by <img src="https://avatars.githubusercontent.com/u/83650252?v=4" width="16"/><a href="https://github.com/SlamBamActionman"> SlamBamActionman</a> at 2024-03-11 17:16:10 UTC PR merged by <img src="https://avatars.githubusercontent.com/u/19864447?v=4" width="16"/><a href="https://github.com/web-flow"> web-flow</a> at 2024-03-12 12:10:10 UTC --- PR changed 2 files with 26 additions and 11 deletions. The PR had the following labels: - Status: Needs Review --- <details open="true"><summary><h1>Original Body</h1></summary> > <!-- Please read these guidelines before opening your PR: https://docs.spacestation14.io/en/getting-started/pr-guideline --> > <!-- The text between the arrows are comments - they will not be visible on your PR. --> > > ## About the PR > <!-- What did you change in this PR? --> > > Makes it so that you can have multiple debug Solution Editor/Add Reagent windows open at once. > > ## Why / Balance > <!-- Why was it changed? Link any discussions or issues here. Please discuss how this would affect game balance. --> > > Admin request. Useful if you want to multitask editing multiple solution containers and their contents. > > ## Technical details > <!-- If this is a code change, summarize at high level how your new code works. This makes it easier to review. --> > > Previously the open Solution Editor window was being tracked by a Dictionary which mapped the window entity to a session ID. That Dictionary instead uses a list of window entities mapped to the session ID, allowing for multiple windows. > > ## Media > <!-- > PRs which make ingame changes (adding clothing, items, new features, etc) are required to have media attached that showcase the changes. > Small fixes/refactors are exempt. > Any media may be used in SS14 progress reports, with clear credit given. > > If you're unsure whether your PR will require media, ask a maintainer. > > Check the box below to confirm that you have in fact seen this (put an X in the brackets, like [X]): > --> > >  > > - [x] I have added screenshots/videos to this PR showcasing its changes ingame, **or** this PR does not require an ingame showcase > > ## Breaking changes > <!-- > List any breaking changes, including namespace, public class/method/field changes, prototype renames; and provide instructions for fixing them. This will be pasted in #codebase-changes. > --> > > **Changelog** > <!-- > Make players aware of new features and changes that could affect how they play the game by adding a Changelog entry. Please read the Changelog guidelines located at: https://docs.spacestation14.io/en/getting-started/pr-guideline#changelog > --> > > no cl no fun </details> Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com>
64 lines
2.2 KiB
C#
64 lines
2.2 KiB
C#
using Content.Server.Administration.Systems;
|
|
using Content.Server.Chemistry.Containers.EntitySystems;
|
|
using Content.Server.EUI;
|
|
using Content.Shared.Administration;
|
|
using Content.Shared.Chemistry.Components.SolutionManager;
|
|
using Content.Shared.Eui;
|
|
using JetBrains.Annotations;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Server.Administration.UI
|
|
{
|
|
/// <summary>
|
|
/// Admin Eui for displaying and editing the reagents in a solution.
|
|
/// </summary>
|
|
[UsedImplicitly]
|
|
public sealed class EditSolutionsEui : BaseEui
|
|
{
|
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
|
private readonly SolutionContainerSystem _solutionContainerSystem = default!;
|
|
public readonly EntityUid Target;
|
|
|
|
public EditSolutionsEui(EntityUid entity)
|
|
{
|
|
IoCManager.InjectDependencies(this);
|
|
_solutionContainerSystem = _entityManager.System<SolutionContainerSystem>();
|
|
Target = entity;
|
|
}
|
|
|
|
public override void Opened()
|
|
{
|
|
base.Opened();
|
|
StateDirty();
|
|
}
|
|
|
|
public override void Closed()
|
|
{
|
|
base.Closed();
|
|
_entityManager.System<AdminVerbSystem>().OnEditSolutionsEuiClosed(Player, this);
|
|
}
|
|
|
|
public override EuiStateBase GetNewState()
|
|
{
|
|
List<(string Name, NetEntity Solution)>? netSolutions;
|
|
|
|
if (_entityManager.TryGetComponent(Target, out SolutionContainerManagerComponent? container) && container.Containers.Count > 0)
|
|
{
|
|
netSolutions = new();
|
|
foreach (var (name, solution) in _solutionContainerSystem.EnumerateSolutions((Target, container)))
|
|
{
|
|
if (name is null || !_entityManager.TryGetNetEntity(solution, out var netSolution))
|
|
continue;
|
|
|
|
netSolutions.Add((name, netSolution.Value));
|
|
}
|
|
}
|
|
else
|
|
netSolutions = null;
|
|
|
|
return new EditSolutionsEuiState(_entityManager.GetNetEntity(Target), netSolutions, _gameTiming.CurTick);
|
|
}
|
|
}
|
|
}
|