Map start system

This commit is contained in:
Marco 2025-02-21 11:39:22 +01:00
commit 7acc344986
11 changed files with 323 additions and 41 deletions

View file

@ -1,6 +1,9 @@
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 : Control
{
@ -9,7 +12,7 @@ public partial class DebugMenu : Control
public Theme ButtonTheme { get; private set; }
[Export]
public Array<string> Levels { get; set; }
public DebugMapSelectData Levels { get; set; }
[Export]
public Container ButtonsContainer { get; private set; }
@ -20,26 +23,25 @@ public partial class DebugMenu : Control
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
foreach (var level in Levels)
foreach (var level in Levels.Maps)
{
if (!level.Enabled) continue;
var button = new Button();
button.Text = level.Split("/")[^1].Split(".")[0];
//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(string scene)
private void ButtonOnPressed(DebugMapSelectResource scene)
{
GD.Print("Button was pressed, now what");
GlobalState.Instance.GotoScene(scene);
//GetTree().ChangeSceneToFile(scene);
GlobalState.Instance.GoToScene(scene.Path, scene.StartData);
}
private void _on_back_button_pressed()