forked from Saplings-Projects/1M_sub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Global scene loader (map scene loader excluded) (Saplings-Projects#86)
* Add a scene manager singleton * Add new scenes to be accessed from main menu and make main menu the first launched scene * Add option menu, quit button * Add a script to the testing scene to properly init game state * Remove the init game call in the ready of phase manager * Add a draft of a BG for the main menu as placeholder
- Loading branch information
Showing
15 changed files
with
256 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://chw8kc2q4o3pi"] | ||
|
||
[ext_resource type="Script" path="res://#Scenes/SceneScripts/MainMenu.gd" id="1_mwp8y"] | ||
[ext_resource type="Texture2D" uid="uid://u5naod8gur3m" path="res://Art/Menus/main_menu_bg-1.png" id="2_v07no"] | ||
|
||
[node name="Main menu" type="Control"] | ||
layout_mode = 3 | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
script = ExtResource("1_mwp8y") | ||
|
||
[node name="TextureRect" type="TextureRect" parent="."] | ||
layout_mode = 2 | ||
offset_right = 1280.0 | ||
offset_bottom = 720.0 | ||
texture = ExtResource("2_v07no") | ||
expand_mode = 1 | ||
|
||
[node name="Label" type="Label" parent="."] | ||
layout_mode = 0 | ||
offset_right = 40.0 | ||
offset_bottom = 23.0 | ||
theme_override_font_sizes/font_size = 34 | ||
text = "This is the main menu" | ||
|
||
[node name="VBoxContainer" type="VBoxContainer" parent="."] | ||
layout_mode = 1 | ||
anchors_preset = 3 | ||
anchor_left = 1.0 | ||
anchor_top = 1.0 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
offset_left = -180.0 | ||
offset_top = -230.0 | ||
offset_right = -21.0 | ||
offset_bottom = -27.0 | ||
grow_horizontal = 0 | ||
grow_vertical = 0 | ||
theme_override_constants/separation = 7 | ||
|
||
[node name="Start" type="Button" parent="VBoxContainer"] | ||
layout_mode = 2 | ||
theme_override_font_sizes/font_size = 40 | ||
text = "Start" | ||
|
||
[node name="Options" type="Button" parent="VBoxContainer"] | ||
layout_mode = 2 | ||
theme_override_font_sizes/font_size = 40 | ||
text = "Options" | ||
|
||
[node name="Quit" type="Button" parent="VBoxContainer"] | ||
layout_mode = 2 | ||
theme_override_font_sizes/font_size = 40 | ||
text = "Quit" | ||
|
||
[connection signal="pressed" from="VBoxContainer/Start" to="." method="_on_start_pressed"] | ||
[connection signal="pressed" from="VBoxContainer/Options" to="." method="_on_options_pressed"] | ||
[connection signal="pressed" from="VBoxContainer/Quit" to="." method="_on_quit_pressed"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://m1u72kig8f0q"] | ||
|
||
[ext_resource type="Texture2D" uid="uid://dyquabho0a3me" path="res://Art/Menus/options_menu_back-1.png" id="1_a6abe"] | ||
[ext_resource type="Script" path="res://#Scenes/SceneScripts/OptionsMenu.gd" id="1_rms2r"] | ||
|
||
[node name="Options Menu" type="Control"] | ||
layout_mode = 3 | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
script = ExtResource("1_rms2r") | ||
|
||
[node name="Label" type="Label" parent="."] | ||
layout_mode = 0 | ||
offset_right = 40.0 | ||
offset_bottom = 23.0 | ||
theme_override_font_sizes/font_size = 70 | ||
text = "Woohoo so many options" | ||
|
||
[node name="Back" type="Button" parent="."] | ||
layout_mode = 1 | ||
anchors_preset = 8 | ||
anchor_left = 0.5 | ||
anchor_top = 0.5 | ||
anchor_right = 0.5 | ||
anchor_bottom = 0.5 | ||
offset_left = -159.0 | ||
offset_top = -159.0 | ||
offset_right = 159.0 | ||
offset_bottom = 159.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
icon = ExtResource("1_a6abe") | ||
|
||
[connection signal="pressed" from="Back" to="." method="_on_back_pressed"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
extends Control | ||
|
||
|
||
|
||
func _on_start_pressed() -> void: | ||
SceneManager.goto_scene("res://#Scenes/TestingScene.tscn") | ||
|
||
|
||
func _on_options_pressed() -> void: | ||
SceneManager.goto_scene("res://#Scenes/OptionsMenu.tscn") | ||
|
||
|
||
func _on_quit_pressed() -> void: | ||
get_tree().quit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
extends Control | ||
|
||
|
||
|
||
|
||
func _on_back_pressed() -> void: | ||
SceneManager.goto_scene("res://#Scenes/MainMenu.tscn") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
extends Node2D | ||
|
||
## * We do this to properly init the battle state | ||
## Before, the testing scene was the main scene so it was properly started by the phase manager | ||
## Now that the main scene is the main menu and we load the testing scene from there, we init to properly init the game state | ||
func _ready() -> void: | ||
PhaseManager.initialize_game() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
extends Control | ||
|
||
|
||
func _on_back_to_main_menu_pressed() -> void: | ||
SceneManager.goto_scene("res://#Scenes/MainMenu.tscn") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="CompressedTexture2D" | ||
uid="uid://u5naod8gur3m" | ||
path="res://.godot/imported/main_menu_bg-1.png-a5473e7c70856731414b60eba624e138.ctex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://Art/Menus/main_menu_bg-1.png" | ||
dest_files=["res://.godot/imported/main_menu_bg-1.png-a5473e7c70856731414b60eba624e138.ctex"] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/high_quality=false | ||
compress/lossy_quality=0.7 | ||
compress/hdr_compression=1 | ||
compress/normal_map=0 | ||
compress/channel_pack=0 | ||
mipmaps/generate=false | ||
mipmaps/limit=-1 | ||
roughness/mode=0 | ||
roughness/src_normal="" | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/normal_map_invert_y=false | ||
process/hdr_as_srgb=false | ||
process/hdr_clamp_exposure=false | ||
process/size_limit=0 | ||
detect_3d/compress_to=1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="CompressedTexture2D" | ||
uid="uid://dyquabho0a3me" | ||
path="res://.godot/imported/options_menu_back-1.png-cdb439064b4a6a52f0485f9a1e8ac346.ctex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://Art/Menus/options_menu_back-1.png" | ||
dest_files=["res://.godot/imported/options_menu_back-1.png-cdb439064b4a6a52f0485f9a1e8ac346.ctex"] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/high_quality=false | ||
compress/lossy_quality=0.7 | ||
compress/hdr_compression=1 | ||
compress/normal_map=0 | ||
compress/channel_pack=0 | ||
mipmaps/generate=false | ||
mipmaps/limit=-1 | ||
roughness/mode=0 | ||
roughness/src_normal="" | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/normal_map_invert_y=false | ||
process/hdr_as_srgb=false | ||
process/hdr_clamp_exposure=false | ||
process/size_limit=0 | ||
detect_3d/compress_to=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
extends Node | ||
|
||
var current_scene: Node = null | ||
|
||
func _ready() -> void: | ||
var root: Node = get_tree().root | ||
current_scene = root.get_child(root.get_child_count() - 1) | ||
|
||
func goto_scene(path: String) -> void: | ||
# This function will usually be called from a signal callback, | ||
# or some other function in the current scene. | ||
# Deleting the current scene at this point is | ||
# a bad idea, because it may still be executing code. | ||
# This will result in a crash or unexpected behavior. | ||
|
||
# The solution is to defer the load to a later time, when | ||
# we can be sure that no code from the current scene is running: | ||
|
||
call_deferred("_deferred_goto_scene", path) | ||
|
||
|
||
func _deferred_goto_scene(path: String) -> void: | ||
# It is now safe to remove the current scene. | ||
current_scene.free() | ||
|
||
# Load the new scene. | ||
var s: Resource = ResourceLoader.load(path) | ||
|
||
# Instance the new scene. | ||
current_scene = s.instantiate() | ||
|
||
# Add it to the active scene, as child of root. | ||
get_tree().root.add_child(current_scene) | ||
|
||
# Optionally, to make it compatible with the SceneTree.change_scene_to_file() API. | ||
get_tree().current_scene = current_scene |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters