Moved Bar slot selection handling to inventory manager

This commit is contained in:
cblech
2025-05-19 22:07:55 +02:00
parent ae4f7d9c58
commit d76218f88f
4 changed files with 41 additions and 15 deletions
+7 -10
View File
@@ -1,4 +1,3 @@
#nullable enable
using Godot;
namespace Babushka.scripts.CSharp.Common.Inventory;
@@ -12,8 +11,6 @@ public partial class InventoryUi : Control
private int? _slotOnMouse;
private int _selectedSlot = 0;
private bool _inventoryExtended = false;
private Tween? _inventoryExtensionTween;
@@ -63,7 +60,7 @@ public partial class InventoryUi : Control
private void SetSlotSelectPosition()
{
_slotSelect.Position = new Vector2(_selectedSlot * 100, 0);
_slotSelect.Position = new Vector2(InventoryManager.Instance.CurrentSelectedSlotIndex * 100, 0);
}
private void PopulateSlots()
@@ -128,17 +125,17 @@ public partial class InventoryUi : Control
if (Input.IsActionJustPressed("ui_inventory_disadvance"))
{
_selectedSlot++;
if (_selectedSlot > 9)
_selectedSlot = 0;
InventoryManager.Instance.CurrentSelectedSlotIndex++;
if (InventoryManager.Instance.CurrentSelectedSlotIndex > 8)
InventoryManager.Instance.CurrentSelectedSlotIndex = 0;
SetSlotSelectPosition();
}
if (Input.IsActionJustPressed("ui_inventory_advance"))
{
_selectedSlot--;
if (_selectedSlot < 0)
_selectedSlot = 9;
InventoryManager.Instance.CurrentSelectedSlotIndex--;
if (InventoryManager.Instance.CurrentSelectedSlotIndex < 0)
InventoryManager.Instance.CurrentSelectedSlotIndex = 8;
SetSlotSelectPosition();
}
}