2025-02-19 13:34:15 +01:00
|
|
|
using Godot;
|
|
|
|
|
using System;
|
|
|
|
|
using Godot.Collections;
|
|
|
|
|
|
|
|
|
|
public partial class DebugMenu : Control
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
|
public Theme ButtonTheme { get; private set; }
|
|
|
|
|
|
|
|
|
|
[Export]
|
2025-02-19 15:45:21 +01:00
|
|
|
public Array<string> Levels { get; set; }
|
2025-02-19 13:34:15 +01:00
|
|
|
|
|
|
|
|
[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();
|
2025-02-19 15:45:21 +01:00
|
|
|
button.Text = level.Split("/")[^1].Split(".")[0];
|
|
|
|
|
//button.Text = level;
|
2025-02-19 13:34:15 +01:00
|
|
|
button.Theme = ButtonTheme;
|
|
|
|
|
|
|
|
|
|
ButtonsContainer.CallDeferred("add_child", button);
|
|
|
|
|
|
|
|
|
|
button.Pressed += () => ButtonOnPressed(level);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-19 15:45:21 +01:00
|
|
|
private void ButtonOnPressed(string scene)
|
2025-02-19 13:34:15 +01:00
|
|
|
{
|
|
|
|
|
GD.Print("Button was pressed, now what");
|
2025-02-20 21:26:51 +01:00
|
|
|
GlobalState.Instance.GotoScene(scene);
|
|
|
|
|
//GetTree().ChangeSceneToFile(scene);
|
2025-02-19 15:45:21 +01:00
|
|
|
|
2025-02-19 13:34:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|