Files
wwdpublic/Content.Client/Storage/StorageBoundUserInterface.cs
sleepyyapril 1e423cabf9 v245.0.0 (and Storage UI V2) (#1799)
Contains:

- Storage UI v2, required for removing DeferredClose.
- Stock market refactor (mostly some basic changes to stock market,
didn't want to make a whole other PR for it)
- Make guidebook remember where you left off
- Any other PRs are purely for fixing issues related to the above PRs or
the engine update.

🆑
- add: Ported Storage UI v2.
- tweak: The guidebook will now remember where you left off.

---------

Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Co-authored-by: DrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com>
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com>
Co-authored-by: 12rabbits <53499656+12rabbits@users.noreply.github.com>
Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
Co-authored-by: gluesniffler <159397573+gluesniffler@users.noreply.github.com>
Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com>
(cherry picked from commit 3c37ff1c48637d1cdf8bc3c6b1412dad338ea205)
2025-02-28 16:22:37 +03:00

81 lines
1.6 KiB
C#

using Content.Client.UserInterface.Systems.Storage;
using Content.Client.UserInterface.Systems.Storage.Controls;
using Content.Shared.Storage;
using JetBrains.Annotations;
using Robust.Client.UserInterface;
namespace Content.Client.Storage;
[UsedImplicitly]
public sealed class StorageBoundUserInterface : BoundUserInterface
{
private StorageWindow? _window;
public StorageBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = IoCManager.Resolve<IUserInterfaceManager>()
.GetUIController<StorageUIController>()
.CreateStorageWindow(Owner);
if (EntMan.TryGetComponent(Owner, out StorageComponent? storage))
{
_window.UpdateContainer((Owner, storage));
}
_window.OnClose += Close;
_window.FlagDirty();
}
public void Refresh()
{
_window?.FlagDirty();
}
public void Reclaim()
{
if (_window == null)
return;
_window.OnClose -= Close;
_window.Orphan();
_window = null;
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
Reclaim();
}
public void Hide()
{
if (_window == null)
return;
_window.Visible = false;
}
public void Show()
{
if (_window == null)
return;
_window.Visible = true;
}
public void ReOpen()
{
_window?.Orphan();
_window = null;
Open();
}
}