summaryrefslogtreecommitdiff
path: root/scripts/GUI/InventoryMenu.cs
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-09-09 19:09:34 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-09-09 19:09:34 -0300
commitc6bbb834f7758027c0df338f1520f34fad3befea (patch)
tree1818cd23c24be16fbe19b16dd0a510874d440d83 /scripts/GUI/InventoryMenu.cs
parentf1b51bed52ffbd90b5b7cc8dcfc6f0484bbbeb3c (diff)
Organização
Diffstat (limited to 'scripts/GUI/InventoryMenu.cs')
-rw-r--r--scripts/GUI/InventoryMenu.cs47
1 files changed, 29 insertions, 18 deletions
diff --git a/scripts/GUI/InventoryMenu.cs b/scripts/GUI/InventoryMenu.cs
index bfb1795..5bac62b 100644
--- a/scripts/GUI/InventoryMenu.cs
+++ b/scripts/GUI/InventoryMenu.cs
@@ -1,52 +1,63 @@
using Godot;
-using System;
+using TheLegendOfGustav.Entities.Items;
+using TheLegendOfGustav.Entities.Actors;
+
+namespace TheLegendOfGustav.GUI;
public partial class InventoryMenu : CanvasLayer
{
private static readonly PackedScene itemMenuEntryScene = GD.Load<PackedScene>("res://scenes/GUI/item_menu_entry.tscn");
+
[Signal]
public delegate void ItemSelectedEventHandler(ConsumableItem item);
[Signal]
public delegate void ItemDropEventHandler(ConsumableItem item);
- private VBoxContainer itemsNode;
+ private VBoxContainer ItemsNode { get; set; }
- public override void _Ready() {
+ public override void _Ready()
+ {
base._Ready();
- itemsNode = GetNode<VBoxContainer>("CenterContainer/PanelContainer/VBoxContainer/Items");
+ ItemsNode = GetNode<VBoxContainer>("CenterContainer/PanelContainer/VBoxContainer/Items");
Hide();
}
- public void OnActivate(ConsumableItem item) {
+ public void OnActivate(ConsumableItem item)
+ {
EmitSignal(SignalName.ItemSelected, item);
}
-
- public void OnDrop(ConsumableItem item) {
+
+ public void OnDrop(ConsumableItem item)
+ {
EmitSignal(SignalName.ItemDrop, item);
}
- private void RegisterItem(int index, ConsumableItem item) {
+ public void Initialize(Inventory inventory)
+ {
+ for (int i = 0; i < inventory.Items.Count; i++)
+ {
+ RegisterItem(i, inventory.Items[i]);
+ }
+
+ Show();
+ }
+
+ private void RegisterItem(int index, ConsumableItem item)
+ {
char? shortcut = null;
// Só terá atalho para as letras do alfabeto.
- if (index < 26) {
+ if (index < 26)
+ {
shortcut = (char)('a' + index);
}
ItemMenuEntry itemEntry = itemMenuEntryScene.Instantiate<ItemMenuEntry>();
- itemsNode.AddChild(itemEntry);
+ ItemsNode.AddChild(itemEntry);
itemEntry.Initialize(item, shortcut);
itemEntry.Activate += OnActivate;
itemEntry.Drop += OnDrop;
}
-
- public void Initialize(Inventory inventory) {
- for (int i = 0; i < inventory.Items.Count; i++) {
- RegisterItem(i, inventory.Items[i]);
- }
-
- Show();
- }
}