mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
Debug menu
This commit is contained in:
parent
5b2b11545a
commit
778dc10d9a
7 changed files with 143 additions and 6 deletions
53
Scripts/UI/DebugMenu.cs
Normal file
53
Scripts/UI/DebugMenu.cs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using Godot.Collections;
|
||||
|
||||
public partial class DebugMenu : Control
|
||||
{
|
||||
|
||||
[Export]
|
||||
public Theme ButtonTheme { get; private set; }
|
||||
|
||||
[Export]
|
||||
public Array<PackedScene> Levels { get; private set; }
|
||||
|
||||
[Export]
|
||||
public Container ButtonsContainer { get; private set; }
|
||||
|
||||
[Signal]
|
||||
public delegate void DebugMenuClosedEventHandler();
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
foreach (var level in Levels)
|
||||
{
|
||||
var button = new Button();
|
||||
button.Text = level.ResourcePath.Split("/")[^1].Split(".")[0];
|
||||
button.Theme = ButtonTheme;
|
||||
|
||||
ButtonsContainer.CallDeferred("add_child", button);
|
||||
|
||||
button.Pressed += () => ButtonOnPressed(level);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonOnPressed(PackedScene scene)
|
||||
{
|
||||
GD.Print("Button was pressed, now what");
|
||||
GetTree().ChangeSceneToFile(scene.ResourcePath);
|
||||
}
|
||||
|
||||
private void _on_back_button_pressed()
|
||||
{
|
||||
this.QueueFree();
|
||||
|
||||
EmitSignal(SignalName.DebugMenuClosed);
|
||||
}
|
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue