diff --git a/Cirno.sln.DotSettings.user b/Cirno.sln.DotSettings.user index fb58ed39..b2b86807 100644 --- a/Cirno.sln.DotSettings.user +++ b/Cirno.sln.DotSettings.user @@ -10,5 +10,6 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded \ No newline at end of file diff --git a/Scenes/HUD/debug_menu.tscn b/Scenes/HUD/debug_menu.tscn new file mode 100644 index 00000000..9b8008a6 --- /dev/null +++ b/Scenes/HUD/debug_menu.tscn @@ -0,0 +1,45 @@ +[gd_scene load_steps=7 format=3 uid="uid://bemu3l6b1e84y"] + +[ext_resource type="Script" path="res://Scripts/UI/DebugMenu.cs" id="1_5vtnj"] +[ext_resource type="Theme" uid="uid://dnsadvmunm76k" path="res://Resources/Styles/MainMenuButtons.tres" id="2_wqb8e"] +[ext_resource type="PackedScene" uid="uid://bv451a8wgty4u" path="res://Scenes/test.tscn" id="3_nd4do"] +[ext_resource type="PackedScene" uid="uid://c4yvclwjr2g3s" path="res://Scenes/naviogation_test.tscn" id="4_sxmbn"] +[ext_resource type="PackedScene" uid="uid://bu5fvatj2j08j" path="res://Scenes/Maps/BossTestArena.tscn" id="5_jms4h"] +[ext_resource type="PackedScene" uid="uid://bx31ou6tw3kd1" path="res://Scenes/Maps/RebelBase.tscn" id="6_4c6m4"] + +[node name="DebugMenu" type="VBoxContainer" node_paths=PackedStringArray("ButtonsContainer")] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_5vtnj") +ButtonTheme = ExtResource("2_wqb8e") +Levels = Array[PackedScene]([ExtResource("3_nd4do"), ExtResource("4_sxmbn"), ExtResource("5_jms4h"), ExtResource("6_4c6m4")]) +ButtonsContainer = NodePath("Level Select") + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +layout_mode = 2 + +[node name="CheckBox" type="CheckBox" parent="HBoxContainer"] +layout_mode = 2 +theme = ExtResource("2_wqb8e") +theme_override_font_sizes/font_size = 14 +text = "Skip Dialogues" + +[node name="God Mode" type="CheckBox" parent="HBoxContainer"] +layout_mode = 2 +theme = ExtResource("2_wqb8e") +theme_override_font_sizes/font_size = 14 +text = "God Mode +" + +[node name="Level Select" type="FlowContainer" parent="."] +layout_mode = 2 + +[node name="BackButton" type="Button" parent="Level Select"] +layout_mode = 2 +theme = ExtResource("2_wqb8e") +text = "Back" + +[connection signal="pressed" from="Level Select/BackButton" to="." method="_on_back_button_pressed"] diff --git a/Scenes/MainMenu.tscn b/Scenes/MainMenu.tscn index 1354a20a..a3252574 100644 --- a/Scenes/MainMenu.tscn +++ b/Scenes/MainMenu.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=12 format=3 uid="uid://5xajclchk3my"] +[gd_scene load_steps=13 format=3 uid="uid://5xajclchk3my"] [ext_resource type="Script" path="res://Scripts/MainMenu.cs" id="1_702nk"] [ext_resource type="PackedScene" uid="uid://bv451a8wgty4u" path="res://Scenes/test.tscn" id="2_6rjfu"] @@ -8,6 +8,7 @@ [ext_resource type="FontFile" uid="uid://ccm3u37q1hvux" path="res://fonts/Xolonium-Regular.ttf" id="3_bl0se"] [ext_resource type="AudioStream" uid="uid://di416g5wgx6j0" path="res://Music/Title.mp3" id="4_i6ku4"] [ext_resource type="Theme" uid="uid://dnsadvmunm76k" path="res://Resources/Styles/MainMenuButtons.tres" id="4_nk7wn"] +[ext_resource type="PackedScene" uid="uid://bemu3l6b1e84y" path="res://Scenes/HUD/debug_menu.tscn" id="9_nwlsr"] [sub_resource type="Theme" id="Theme_c7h4d"] @@ -27,7 +28,7 @@ font_size = 12 outline_size = 4 outline_color = Color(0, 0, 0, 1) -[node name="Control" type="Control"] +[node name="Control" type="Control" node_paths=PackedStringArray("DebugMenuHolder")] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -39,6 +40,8 @@ grow_vertical = 2 script = ExtResource("1_702nk") GameScene = ExtResource("2_6rjfu") MainMenuScene = "res://Scenes/MainMenu.tscn" +DebugMenuTemplate = ExtResource("9_nwlsr") +DebugMenuHolder = NodePath("Panel") [node name="TextureRect2" type="TextureRect" parent="."] layout_mode = 0 @@ -134,6 +137,14 @@ text = "Options" stream = ExtResource("4_i6ku4") autoplay = true +[node name="Panel" type="PanelContainer" parent="."] +visible = false +layout_mode = 0 +offset_left = 66.0 +offset_top = 45.0 +offset_right = 259.0 +offset_bottom = 156.0 + [connection signal="pressed" from="MarginContainer/GridContainer/GameButtons/StartButton" to="." method="_on_start_button_pressed"] [connection signal="pressed" from="MarginContainer/GridContainer/GameButtons/DebugButton" to="." method="_on_debug_button_pressed"] [connection signal="pressed" from="MarginContainer/GridContainer/GameButtons/ExitButton" to="." method="_on_exit_button_pressed"] diff --git a/Scripts/GameManager.cs b/Scripts/GameManager.cs index 14b3374d..3b875d75 100644 --- a/Scripts/GameManager.cs +++ b/Scripts/GameManager.cs @@ -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) { diff --git a/Scripts/MainMenu.cs b/Scripts/MainMenu.cs index 54865d1d..f76c2492 100644 --- a/Scripts/MainMenu.cs +++ b/Scripts/MainMenu.cs @@ -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(); + + DebugMenuHolder.CallDeferred("add_child", menu); + menu.DebugMenuClosed += () => + { + DebugMenuHolder.Visible = false; + }; + + } } private void _on_mainmenu_button_pressed() diff --git a/Scripts/UI/DebugMenu.cs b/Scripts/UI/DebugMenu.cs new file mode 100644 index 00000000..32c81c01 --- /dev/null +++ b/Scripts/UI/DebugMenu.cs @@ -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 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) + { + } +} diff --git a/project.godot b/project.godot index c39c3254..85bc0118 100644 --- a/project.godot +++ b/project.godot @@ -21,7 +21,7 @@ Settings/temporaryLogLifetime=5.0 [application] config/name="Cirno" -run/main_scene="res://Scenes/test.tscn" +run/main_scene="res://Scenes/MainMenu.tscn" config/features=PackedStringArray("4.3", "C#", "GL Compatibility") config/icon="res://icon.svg"