diff options
Diffstat (limited to 'scripts/GUI/ItemMenuEntry.cs')
| -rw-r--r-- | scripts/GUI/ItemMenuEntry.cs | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/scripts/GUI/ItemMenuEntry.cs b/scripts/GUI/ItemMenuEntry.cs index 449c97b..7ee3fcd 100644 --- a/scripts/GUI/ItemMenuEntry.cs +++ b/scripts/GUI/ItemMenuEntry.cs @@ -1,41 +1,48 @@ using Godot; +using TheLegendOfGustav.Entities.Items; + +namespace TheLegendOfGustav.GUI; public partial class ItemMenuEntry : HBoxContainer { - private TextureRect icon; - private Label shortcutLabel; - private Label nameLabel; - private Button activateBtn; - private Button dropBtn; - [Signal] public delegate void ActivateEventHandler(ConsumableItem Item); [Signal] - public delegate void DropEventHandler(ConsumableItem item); - - private ConsumableItem item; + public delegate void DropEventHandler(ConsumableItem Item); - public void Initialize(ConsumableItem item, char? shortcut) { - this.item = item; - nameLabel.Text = item.DisplayName; - if (shortcut != null) { - shortcutLabel.Text = $"{shortcut}"; - } else { - shortcutLabel.Text = ""; - } - icon.Texture = item.Texture; - } + private TextureRect Icon { get; set; } + private Label ShortcutLabel { get; set; } + private Label NameLabel { get; set; } + private Button ActivateBtn { get; set; } + private Button DropBtn { get; set; } + private ConsumableItem Item { get; set; } - public override void _Ready() { + public override void _Ready() + { base._Ready(); - icon = GetNode<TextureRect>("Icon"); - shortcutLabel = GetNode<Label>("Shortcut"); - nameLabel = GetNode<Label>("ItemName"); - activateBtn = GetNode<Button>("ActivateBtn"); - dropBtn = GetNode<Button>("DropButton"); + Icon = GetNode<TextureRect>("Icon"); + ShortcutLabel = GetNode<Label>("Shortcut"); + NameLabel = GetNode<Label>("ItemName"); + ActivateBtn = GetNode<Button>("ActivateBtn"); + DropBtn = GetNode<Button>("DropButton"); - activateBtn.Pressed += () => EmitSignal(SignalName.Activate, item); - dropBtn.Pressed += () => EmitSignal(SignalName.Drop, item); + ActivateBtn.Pressed += () => EmitSignal(SignalName.Activate, Item); + DropBtn.Pressed += () => EmitSignal(SignalName.Drop, Item); + } + + public void Initialize(ConsumableItem item, char? shortcut) + { + Item = item; + NameLabel.Text = item.DisplayName; + if (shortcut != null) + { + ShortcutLabel.Text = $"{shortcut}"; + } + else + { + ShortcutLabel.Text = ""; + } + Icon.Texture = item.Texture; } } |
