Files
wwdpublic/Content.Client/Storage/StorageBoundUserInterface.cs
RadsammyT 2067191104 Cherry-Pick Storage V2 Fixes From wizden#34845 (#1868)
# Description

~~finally figured out how to cherry-pick across repos jfc~~
Cherry-picks
https://github.com/space-wizards/space-station-14/pull/34845.
Essentially fixes most of the issues with Storage V2 when it initially
got merged into EE, finally.

Or, TL;DR, fixes:
 - storage stars always being golden
- windows always resetting to its default position on reopening- now
saves its position instead
 - hotkeys not being ergonomic enough (which was really disrupting)
 - and some other things regarding 1-tick delays between containers
 -  and the back button being illegaly visible

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- **PDA Menu Improvement:** Streamlined the PDA menu display for more
consistent and intuitive access.
- **Enhanced Storage UI:** Storage windows now open at dynamic positions
for smoother transitions and easier navigation.
- **Nested Storage Management:** Improved handling of nested storage
interfaces reduces clutter and simplifies user interactions.
- **Improved Item Interaction:** Updated item selection displays and
automatic parent window adjustments for a more cohesive experience.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
(cherry picked from commit 3021de3ee6fd88d82b3f090ea4d17398a0c01f64)
2025-03-08 14:31:33 +03:00

104 lines
2.1 KiB
C#

using System.Numerics;
using Content.Client.UserInterface.Systems.Storage;
using Content.Client.UserInterface.Systems.Storage.Controls;
using Content.Shared.Storage;
using JetBrains.Annotations;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
namespace Content.Client.Storage;
[UsedImplicitly]
public sealed class StorageBoundUserInterface : BoundUserInterface
{
private StorageWindow? _window;
public Vector2? Position => _window?.Position;
public StorageBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = IoCManager.Resolve<IUserInterfaceManager>()
.GetUIController<StorageUIController>()
.CreateStorageWindow(this);
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 CloseWindow(Vector2 position)
{
if (_window == null)
return;
// Update its position before potentially saving.
// Listen it makes sense okay.
LayoutContainer.SetPosition(_window, position);
_window?.Close();
}
public void Hide()
{
if (_window == null)
return;
_window.Visible = false;
}
public void Show()
{
if (_window == null)
return;
_window.Visible = true;
}
public void Show(Vector2 position)
{
if (_window == null)
return;
Show();
LayoutContainer.SetPosition(_window, position);
}
public void ReOpen()
{
_window?.Orphan();
_window = null;
Open();
}
}