mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-11 08:35:54 +00:00
Debug menu items spawn buttons
This commit is contained in:
parent
6bf12a021f
commit
4c58436a74
9 changed files with 216 additions and 33 deletions
25
Scripts/UI/DebugItemButton.cs
Normal file
25
Scripts/UI/DebugItemButton.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.UI;
|
||||
|
||||
[Tool]
|
||||
public partial class DebugItemButton : Button
|
||||
{
|
||||
[Export] public LootItem Item { get; set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
if (Item is null) return;
|
||||
this.Icon = Item.InventorySprite;
|
||||
|
||||
if (Engine.IsEditorHint()) return;
|
||||
this.Pressed += OnPressed;
|
||||
}
|
||||
|
||||
private void OnPressed()
|
||||
{
|
||||
if (Engine.IsEditorHint()) return;
|
||||
InventoryManager.Instance.AddItem(Item);
|
||||
}
|
||||
}
|
||||
1
Scripts/UI/DebugItemButton.cs.uid
Normal file
1
Scripts/UI/DebugItemButton.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://v6tkgo5mwi1w
|
||||
|
|
@ -25,6 +25,8 @@ public partial class DebugMenu : MenuBase
|
|||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
GameManager.Instance.GameStateChange += OnGameStateChange;
|
||||
|
||||
DefaultSelectedButton.GrabFocus();
|
||||
|
||||
foreach (var level in Levels.Maps)
|
||||
|
|
@ -53,6 +55,16 @@ public partial class DebugMenu : MenuBase
|
|||
|
||||
}
|
||||
|
||||
private void OnGameStateChange(GameState state)
|
||||
{
|
||||
if (state is not GameState.Paused)
|
||||
{
|
||||
GameManager.Instance.GameStateChange -= OnGameStateChange;
|
||||
CloseMenu();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void RefillHealthButtonOnPressed()
|
||||
{
|
||||
GameManager.Instance?.Player?.RefillHealth();
|
||||
|
|
|
|||
|
|
@ -11,6 +11,11 @@ public partial class MenuBase : Control
|
|||
public delegate void MenuClosedEventHandler();
|
||||
|
||||
protected virtual void _on_back_button_pressed()
|
||||
{
|
||||
CloseMenu();
|
||||
}
|
||||
|
||||
protected void CloseMenu()
|
||||
{
|
||||
this.QueueFree();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue