Added inventory background and fixes
This commit is contained in:
@@ -17,7 +17,7 @@ public partial class InventoryManager : Node
|
||||
public override void _Ready()
|
||||
{
|
||||
playerInventory = new InventoryInstance();
|
||||
playerInventory.SlotAmount = 30;
|
||||
playerInventory.SlotAmount = 37;
|
||||
}
|
||||
|
||||
public InventoryActionResult CreateItem(
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Babushka.scripts.CSharp.Common.Inventory;
|
||||
|
||||
public partial class InventoryUi : Control
|
||||
{
|
||||
private GridContainer _slots;
|
||||
private Control _slots;
|
||||
private Control _slotsMover;
|
||||
private InventoryInstance _playerInventory;
|
||||
private Control _slotSelect;
|
||||
@@ -26,11 +26,12 @@ public partial class InventoryUi : Control
|
||||
public override void _Ready()
|
||||
{
|
||||
GD.Print("Ready inventory ui");
|
||||
_slots = GetNode<GridContainer>("SlotsContainer/SlotsMover/Slots");
|
||||
_slots = GetNode<Control>("SlotsContainer/SlotsMover/Slots");
|
||||
_slotsMover = GetNode<Control>("SlotsContainer/SlotsMover");
|
||||
_playerInventory = InventoryManager.Instance.playerInventory;
|
||||
_slotSelect = GetNode<Control>("SlotsContainer/SlotSelectContainer/Selector");
|
||||
PopulateSlots();
|
||||
//PopulateSlots();
|
||||
SubscribeSlots();
|
||||
SetSlotContent();
|
||||
SetSlotSelectPosition();
|
||||
InventoryManager.Instance.playerInventory.InventoryContentsChanged += SetSlotContent;
|
||||
@@ -76,6 +77,17 @@ public partial class InventoryUi : Control
|
||||
_slots.AddChild(slotInstance);
|
||||
}
|
||||
}
|
||||
|
||||
private void SubscribeSlots()
|
||||
{
|
||||
for (var index = 0; index < _playerInventory.Slots.Count; index++)
|
||||
{
|
||||
var slotInstance = _slots.GetChild<SlotUi>(index);
|
||||
slotInstance.index = index;
|
||||
slotInstance.Clicked += SlotClicked;
|
||||
_slots.AddChild(slotInstance);
|
||||
}
|
||||
}
|
||||
|
||||
private void UnsubscribeSlots()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user