cirnogodot/Scripts/UI/DebugMenu.cs
2025-03-12 15:47:57 +01:00

62 lines
1.5 KiB
C#

using Godot;
using System;
using Cirno.Scripts.Resources;
using Cirno.Scripts.Resources.DebugMenu;
using Godot.Collections;
using DebugMapSelectData = Cirno.Scripts.Resources.DebugMenu.DebugMapSelectData;
public partial class DebugMenu : MenuBase
{
[Export]
public Theme ButtonTheme { get; private set; }
[Export]
public DebugMapSelectData Levels { get; set; }
[Export]
public Container ButtonsContainer { get; private set; }
[Export]
public Button DefaultSelectedButton { get; private set; }
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
DefaultSelectedButton.GrabFocus();
foreach (var level in Levels.Maps)
{
if (!level.Enabled) continue;
var button = new Button();
//button.Text = level.Split("/")[^1].Split(".")[0];
button.Text = level.DisplayName;
button.Icon = level.Icon;
//button.Text = level;
button.Theme = ButtonTheme;
ButtonsContainer.CallDeferred("add_child", button);
button.Pressed += () => ButtonOnPressed(level);
}
}
private void ButtonOnPressed(DebugMapSelectResource scene)
{
if (GameManager.Instance is not null)
{
GameManager.Instance.Unpause();
}
GlobalState.Instance.GoToScene(scene.Path, scene.StartData);
}
private void _on_check_box_toggled(bool state)
{
GlobalState.Instance.SessionSettings.SkipDialogues = state;
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
}