Grid Inventory (#21931)

* Grid Inventory

* oh boy we keep cracking on

* auto insertion is kinda working? gross, too!

* pieces and proper layouts

* fix the sprites

* mousing over grid pieces... finally

* dragging deez nuts all over the screen

* eek!

* dragging is 90% less horrendous

* auto-rotating

* flatten

* Rotation at last

* fix rotation and change keybind for removing items.

* rebinding and keybinding

* wow! look at that! configurable with a button! cool!

* dragging is a bit cooler, eh?

* hover insert, my beloved

* add some grids for storage, fix 1x1 storages, fix multiple inputs at once

* el navigation

* oh yeah some stuff i forgor

* more fixes and QOL stuff

* the griddening

* the last of it (yippee)

* sloth review :)
This commit is contained in:
Nemanja
2023-12-04 18:04:39 -05:00
committed by GitHub
parent 4221ed2d4b
commit cc8984d096
99 changed files with 2014 additions and 619 deletions

View File

@@ -1,129 +1,37 @@
using Content.Client.Examine;
using Content.Client.Storage.UI;
using Content.Client.UserInterface.Controls;
using Content.Client.Verbs.UI;
using Content.Shared.Input;
using Content.Shared.Interaction;
using Content.Client.Storage.Systems;
using Content.Shared.Storage;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Input;
using static Content.Shared.Storage.StorageComponent;
namespace Content.Client.Storage
namespace Content.Client.Storage;
[UsedImplicitly]
public sealed class StorageBoundUserInterface : BoundUserInterface
{
[UsedImplicitly]
public sealed class StorageBoundUserInterface : BoundUserInterface
[Dependency] private readonly IEntityManager _entManager = default!;
private readonly StorageSystem _storage;
public StorageBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
[ViewVariables]
private StorageWindow? _window;
IoCManager.InjectDependencies(this);
_storage = _entManager.System<StorageSystem>();
}
[Dependency] private readonly IEntityManager _entManager = default!;
protected override void Open()
{
base.Open();
public StorageBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
IoCManager.InjectDependencies(this);
}
if (_entManager.TryGetComponent<StorageComponent>(Owner, out var comp))
_storage.OpenStorageUI(Owner, comp);
}
protected override void Open()
{
base.Open();
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;
if (_window == null)
{
// TODO: This is a bit of a mess but storagecomponent got moved to shared and cleaned up a bit.
var controller = IoCManager.Resolve<IUserInterfaceManager>().GetUIController<StorageUIController>();
_window = controller.EnsureStorageWindow(Owner);
_window.Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName;
_window.EntityList.GenerateItem += _window.GenerateButton;
_window.EntityList.ItemPressed += InteractWithItem;
_window.StorageContainerButton.OnPressed += TouchedContainerButton;
_window.OnClose += Close;
if (EntMan.TryGetComponent<StorageComponent>(Owner, out var storageComp))
{
BuildEntityList(Owner, storageComp);
}
}
else
{
_window.Open();
}
}
public void BuildEntityList(EntityUid uid, StorageComponent component)
{
_window?.BuildEntityList(uid, component);
}
public void InteractWithItem(BaseButton.ButtonEventArgs? args, ListData? cData)
{
if (args == null || cData is not EntityListData { Uid: var entity })
return;
if (args.Event.Function == EngineKeyFunctions.UIClick)
{
SendPredictedMessage(new StorageInteractWithItemEvent(_entManager.GetNetEntity(entity)));
}
else if (EntMan.EntityExists(entity))
{
OnButtonPressed(args.Event, entity);
}
}
private void OnButtonPressed(GUIBoundKeyEventArgs args, EntityUid entity)
{
if (args.Function == ContentKeyFunctions.ExamineEntity)
{
EntMan.System<ExamineSystem>()
.DoExamine(entity);
}
else if (args.Function == EngineKeyFunctions.UseSecondary)
{
IoCManager.Resolve<IUserInterfaceManager>().GetUIController<VerbMenuUIController>().OpenVerbMenu(entity);
}
else if (args.Function == ContentKeyFunctions.ActivateItemInWorld)
{
EntMan.EntityNetManager?.SendSystemNetworkMessage(
new InteractInventorySlotEvent(EntMan.GetNetEntity(entity), altInteract: false));
}
else if (args.Function == ContentKeyFunctions.AltActivateItemInWorld)
{
EntMan.RaisePredictiveEvent(new InteractInventorySlotEvent(EntMan.GetNetEntity(entity), altInteract: true));
}
else
{
return;
}
args.Handle();
}
public void TouchedContainerButton(BaseButton.ButtonEventArgs args)
{
SendPredictedMessage(new StorageInsertItemMessage());
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;
if (_window != null)
{
_window.Orphan();
_window.EntityList.GenerateItem -= _window.GenerateButton;
_window.EntityList.ItemPressed -= InteractWithItem;
_window.StorageContainerButton.OnPressed -= TouchedContainerButton;
_window.OnClose -= Close;
_window = null;
}
}
_storage.CloseStorageUI(Owner);
}
}