* 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 :)
85 lines
2.6 KiB
C#
85 lines
2.6 KiB
C#
using Content.Client.UserInterface.Systems.Gameplay;
|
|
using Content.Client.UserInterface.Systems.Hands;
|
|
using Content.Client.UserInterface.Systems.Hands.Controls;
|
|
using Content.Client.UserInterface.Systems.Hotbar.Widgets;
|
|
using Content.Client.UserInterface.Systems.Inventory;
|
|
using Content.Client.UserInterface.Systems.Inventory.Controls;
|
|
using Content.Client.UserInterface.Systems.Storage;
|
|
using Content.Client.UserInterface.Systems.Storage.Controls;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Client.UserInterface.Controllers;
|
|
|
|
namespace Content.Client.UserInterface.Systems.Hotbar;
|
|
|
|
public sealed class HotbarUIController : UIController
|
|
{
|
|
private InventoryUIController? _inventory;
|
|
private HandsUIController? _hands;
|
|
private StorageUIController? _storage;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
var gameplayStateLoad = UIManager.GetUIController<GameplayStateLoadController>();
|
|
gameplayStateLoad.OnScreenLoad += OnScreenLoad;
|
|
}
|
|
|
|
private void OnScreenLoad()
|
|
{
|
|
ReloadHotbar();
|
|
}
|
|
|
|
public void Setup(HandsContainer handsContainer, ItemSlotButtonContainer inventoryBar, ItemStatusPanel handStatus, StorageContainer storageContainer)
|
|
{
|
|
_inventory = UIManager.GetUIController<InventoryUIController>();
|
|
_hands = UIManager.GetUIController<HandsUIController>();
|
|
_storage = UIManager.GetUIController<StorageUIController>();
|
|
_hands.RegisterHandContainer(handsContainer);
|
|
_inventory.RegisterInventoryBarContainer(inventoryBar);
|
|
_storage.RegisterStorageContainer(storageContainer);
|
|
}
|
|
|
|
public void ReloadHotbar()
|
|
{
|
|
if (UIManager.ActiveScreen == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var hotbar = UIManager.ActiveScreen.GetWidget<HotbarGui>();
|
|
|
|
if (hotbar == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
foreach (var container in GetAllItemSlotContainers(hotbar))
|
|
{
|
|
// Yes, this is dirty.
|
|
container.SlotGroup = container.SlotGroup;
|
|
}
|
|
|
|
_hands?.ReloadHands();
|
|
_inventory?.ReloadSlots();
|
|
_inventory?.RegisterInventoryBarContainer(hotbar.InventoryHotbar);
|
|
}
|
|
|
|
private IEnumerable<ItemSlotButtonContainer> GetAllItemSlotContainers(Control gui)
|
|
{
|
|
var result = new List<ItemSlotButtonContainer>();
|
|
|
|
foreach (var child in gui.Children)
|
|
{
|
|
if (child is ItemSlotButtonContainer container)
|
|
{
|
|
result.Add(container);
|
|
}
|
|
|
|
result.AddRange(GetAllItemSlotContainers(child));
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|