cleaned Inventory ui

This commit is contained in:
cblech
2025-05-19 17:17:01 +02:00
parent 1b7c35879c
commit 2ab1c38de9
6 changed files with 58 additions and 32 deletions
+11 -3
View File
@@ -6,6 +6,7 @@ namespace Babushka.scripts.CSharp.Common.Inventory;
public partial class InventoryUi : Control
{
private GridContainer _slots;
private Control _slotsMover;
private InventoryInstance _playerInventory;
private Control _slotSelect;
@@ -16,10 +17,17 @@ public partial class InventoryUi : Control
private bool _inventoryExtended = false;
private Tween? _inventoryExtensionTween;
[Export]
private float _inventoryClosedOffset = 0f;
[Export]
private float _inventoryOpenedOffset = 200f;
public override void _Ready()
{
GD.Print("Ready inventory ui");
_slots = GetNode<GridContainer>("SlotsContainer/Slots");
_slots = GetNode<GridContainer>("SlotsContainer/SlotsMover/Slots");
_slotsMover = GetNode<Control>("SlotsContainer/SlotsMover");
_playerInventory = InventoryManager.Instance.playerInventory;
_slotSelect = GetNode<Control>("SlotsContainer/SlotSelectContainer/Selector");
PopulateSlots();
@@ -134,7 +142,7 @@ public partial class InventoryUi : Control
_inventoryExtensionTween = GetTree().CreateTween();
_slotSelect.Hide();
_inventoryExtensionTween
.TweenProperty(_slots, "offset_bottom", -100, 0.4)
.TweenProperty(_slotsMover, "offset_bottom", _inventoryOpenedOffset, 0.4)
.SetTrans(Tween.TransitionType.Quad)
.SetEase(Tween.EaseType.Out);
}
@@ -144,7 +152,7 @@ public partial class InventoryUi : Control
_inventoryExtensionTween = GetTree().CreateTween();
_slotSelect.Show();
_inventoryExtensionTween
.TweenProperty(_slots, "offset_bottom", 200, 0.4)
.TweenProperty(_slotsMover, "offset_bottom", _inventoryClosedOffset, 0.4)
.SetTrans(Tween.TransitionType.Quad)
.SetEase(Tween.EaseType.Out);