Moved Bar slot selection handling to inventory manager
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user