diff options
Diffstat (limited to 'scripts/GUI/SpellMenuEntry.cs')
| -rw-r--r-- | scripts/GUI/SpellMenuEntry.cs | 43 |
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; + } +} |
