summaryrefslogtreecommitdiff
path: root/scripts/GUI/SpellMenuEntry.cs
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-09-14 10:41:08 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-09-14 10:41:08 -0300
commit1e17a31e3eeed8ccf76982534002513cee6593f1 (patch)
tree74d8e4fbf706b1008edcd699b0ba7af2d6bb34ea /scripts/GUI/SpellMenuEntry.cs
parent5958d9c071915ab71aea5a5c08d79e88024f6c58 (diff)
Magicas
Diffstat (limited to 'scripts/GUI/SpellMenuEntry.cs')
-rw-r--r--scripts/GUI/SpellMenuEntry.cs43
1 files changed, 43 insertions, 0 deletions
diff --git a/scripts/GUI/SpellMenuEntry.cs b/scripts/GUI/SpellMenuEntry.cs
new file mode 100644
index 0000000..2be0fcc
--- /dev/null
+++ b/scripts/GUI/SpellMenuEntry.cs
@@ -0,0 +1,43 @@
+using Godot;
+using System;
+using TheLegendOfGustav.Magic;
+
+namespace TheLegendOfGustav.GUI;
+
+public partial class SpellMenuEntry : HBoxContainer
+{
+ private TextureRect icon;
+ private Label shortcutLabel;
+ private Label nameLabel;
+ private Button castBtn;
+ private SpellResource spell;
+
+ [Signal]
+ public delegate void CastEventHandler(SpellResource Item);
+
+ public override void _Ready()
+ {
+ base._Ready();
+ icon = GetNode<TextureRect>("Icon");
+ shortcutLabel = GetNode<Label>("Shortcut");
+ nameLabel = GetNode<Label>("SpellName");
+ castBtn = GetNode<Button>("CastButton");
+
+ castBtn.Pressed += () => EmitSignal(SignalName.Cast, spell);
+ }
+
+ public void Initialize(SpellResource spell, char? shortcut)
+ {
+ this.spell = spell;
+ nameLabel.Text = spell.SpellName;
+ if (shortcut != null)
+ {
+ shortcutLabel.Text = $"{shortcut}";
+ }
+ else
+ {
+ shortcutLabel.Text = "";
+ }
+ icon.Texture = spell.Icon;
+ }
+}