mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-05 11:16:01 +00:00
Debug menu
This commit is contained in:
parent
5b2b11545a
commit
778dc10d9a
7 changed files with 143 additions and 6 deletions
|
|
@ -66,7 +66,9 @@ public partial class GameManager : Node2D
|
|||
|
||||
GameState = GameState.Playing;
|
||||
|
||||
_ = DelayPlayerSpawn();
|
||||
//_ = DelayPlayerSpawn();
|
||||
|
||||
CallDeferred(nameof(DelayPlayerSpawn));
|
||||
}
|
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
|
|
@ -78,9 +80,9 @@ public partial class GameManager : Node2D
|
|||
}
|
||||
}
|
||||
|
||||
private async Task DelayPlayerSpawn()
|
||||
private void DelayPlayerSpawn()
|
||||
{
|
||||
await Task.Delay(500);
|
||||
//await Task.Delay(500);
|
||||
|
||||
if (PlayerSpawnMarker != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,6 +10,12 @@ public partial class MainMenu : Control
|
|||
[Export]
|
||||
public string MainMenuScene { get; set; }
|
||||
|
||||
[Export]
|
||||
public PackedScene DebugMenuTemplate { get; set; }
|
||||
|
||||
[Export]
|
||||
public Control DebugMenuHolder { get; set; }
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
|
|
@ -29,7 +35,26 @@ public partial class MainMenu : Control
|
|||
|
||||
private void _on_debug_button_pressed()
|
||||
{
|
||||
if (DebugMenuTemplate is not null && DebugMenuHolder is not null)
|
||||
{
|
||||
DebugMenuHolder.Visible = true;
|
||||
|
||||
var children = DebugMenuHolder.GetChildren();
|
||||
foreach (var child in children)
|
||||
{
|
||||
child.QueueFree();
|
||||
}
|
||||
|
||||
var menu = DebugMenuTemplate.Instantiate<DebugMenu>();
|
||||
|
||||
DebugMenuHolder.CallDeferred("add_child", menu);
|
||||
|
||||
menu.DebugMenuClosed += () =>
|
||||
{
|
||||
DebugMenuHolder.Visible = false;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void _on_mainmenu_button_pressed()
|
||||
|
|
|
|||
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