End of Chapter 3. Loading scene and new game button working!
This commit is contained in:
parent
3f7a3cf979
commit
e882e0e5fd
|
|
@ -11,11 +11,15 @@ config_version=5
|
||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="Legacy of the Ancient Questor"
|
config/name="Legacy of the Ancient Questor"
|
||||||
config/version="prototype 1"
|
config/version="prototype 2"
|
||||||
run/main_scene="uid://dm8aun68tgprd"
|
run/main_scene="uid://dm8aun68tgprd"
|
||||||
config/features=PackedStringArray("4.4", "GL Compatibility")
|
config/features=PackedStringArray("4.4", "GL Compatibility")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
[autoload]
|
||||||
|
|
||||||
|
Loader="*res://scripts/loader.gd"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
window/size/viewport_width=640
|
window/size/viewport_width=640
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
[gd_scene format=3 uid="uid://c0b5w48jk67qd"]
|
||||||
|
|
||||||
|
[node name="Game" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="Control" type="Control" parent="."]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_right = 640.0
|
||||||
|
offset_bottom = 360.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="CenterContainer" type="CenterContainer" parent="Control"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="Control/CenterContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Game!"
|
||||||
|
|
@ -1,16 +1,19 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://c8fyt7v0ksdyc"]
|
[gd_scene load_steps=5 format=3 uid="uid://c8fyt7v0ksdyc"]
|
||||||
|
|
||||||
[ext_resource type="Theme" uid="uid://dnxny0n7ti7eq" path="res://themes/default_theme.tres" id="1_5fj0j"]
|
[ext_resource type="Theme" uid="uid://dnxny0n7ti7eq" path="res://themes/default_theme.tres" id="1_5fj0j"]
|
||||||
|
[ext_resource type="Script" uid="uid://d1ag1ag2bbhtx" path="res://scripts/ui/loading_screen.gd" id="1_s2kth"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cyw8i4rnh8x5x" path="res://gfx/ui/loading_frame.png" id="2_s2kth"]
|
[ext_resource type="Texture2D" uid="uid://cyw8i4rnh8x5x" path="res://gfx/ui/loading_frame.png" id="2_s2kth"]
|
||||||
[ext_resource type="Texture2D" uid="uid://df4gfyht0d2r3" path="res://gfx/ui/loading_bar.png" id="3_s41fs"]
|
[ext_resource type="Texture2D" uid="uid://df4gfyht0d2r3" path="res://gfx/ui/loading_bar.png" id="3_s41fs"]
|
||||||
|
|
||||||
[node name="Loading Screen" type="Control"]
|
[node name="Loading Screen" type="Control" node_paths=PackedStringArray("loadingBar")]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
script = ExtResource("1_s2kth")
|
||||||
|
loadingBar = NodePath("CenterContainer/VBoxContainer/Loading Progress")
|
||||||
|
|
||||||
[node name="Background" type="ColorRect" parent="."]
|
[node name="Background" type="ColorRect" parent="."]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
[gd_scene load_steps=7 format=3 uid="uid://dm8aun68tgprd"]
|
[gd_scene load_steps=8 format=3 uid="uid://dm8aun68tgprd"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://cm8lciwc0iuq" path="res://gfx/title/tree-3094982_1280.jpg" id="1_eb34j"]
|
[ext_resource type="Texture2D" uid="uid://cm8lciwc0iuq" path="res://gfx/title/tree-3094982_1280.jpg" id="1_eb34j"]
|
||||||
|
[ext_resource type="Script" uid="uid://bklj1ua1qok02" path="res://scripts/title/title_screen.gd" id="1_r23qo"]
|
||||||
[ext_resource type="FontFile" uid="uid://1u28cjgctsn7" path="res://fonts/alagard_by_pix3m-d6awiwp.ttf" id="2_aqpy5"]
|
[ext_resource type="FontFile" uid="uid://1u28cjgctsn7" path="res://fonts/alagard_by_pix3m-d6awiwp.ttf" id="2_aqpy5"]
|
||||||
[ext_resource type="Theme" uid="uid://dnxny0n7ti7eq" path="res://themes/default_theme.tres" id="3_w8uqo"]
|
[ext_resource type="Theme" uid="uid://dnxny0n7ti7eq" path="res://themes/default_theme.tres" id="3_w8uqo"]
|
||||||
[ext_resource type="Script" uid="uid://bfc7ybsw6riri" path="res://scripts/title/version_number.gd" id="4_a4ium"]
|
[ext_resource type="Script" uid="uid://bfc7ybsw6riri" path="res://scripts/title/version_number.gd" id="4_a4ium"]
|
||||||
|
|
@ -25,6 +26,7 @@ anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
script = ExtResource("1_r23qo")
|
||||||
|
|
||||||
[node name="Background Image" type="TextureRect" parent="."]
|
[node name="Background Image" type="TextureRect" parent="."]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
|
@ -109,3 +111,5 @@ text = "Version: "
|
||||||
label_settings = SubResource("LabelSettings_r23qo")
|
label_settings = SubResource("LabelSettings_r23qo")
|
||||||
vertical_alignment = 1
|
vertical_alignment = 1
|
||||||
script = ExtResource("4_a4ium")
|
script = ExtResource("4_a4ium")
|
||||||
|
|
||||||
|
[connection signal="pressed" from="Content/VBoxContainer/HBoxContainer/Button Menu/New Game Button" to="." method="_on_new_game_button_pressed"]
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
signal LOADING_PROGRESS_UPDATED
|
||||||
|
@export var loadingScene: Node = preload("res://scenes/ui/loading_screen.tscn").instantiate()
|
||||||
|
|
||||||
|
var scenePath: String
|
||||||
|
|
||||||
|
func loadScene(caller: Node, path: String):
|
||||||
|
scenePath = path
|
||||||
|
|
||||||
|
get_tree().root.add_child(loadingScene)
|
||||||
|
|
||||||
|
ResourceLoader.load_threaded_request(scenePath)
|
||||||
|
print(scenePath)
|
||||||
|
caller.queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if scenePath:
|
||||||
|
var progress: Array = []
|
||||||
|
var loaderStatus: ResourceLoader.ThreadLoadStatus = ResourceLoader.load_threaded_get_status(scenePath, progress)
|
||||||
|
|
||||||
|
if loaderStatus == ResourceLoader.ThreadLoadStatus.THREAD_LOAD_LOADED:
|
||||||
|
var loadedScene = ResourceLoader.load_threaded_get(scenePath).instantiate()
|
||||||
|
get_tree().root.remove_child(loadingScene)
|
||||||
|
get_tree().root.add_child(loadedScene)
|
||||||
|
scenePath = ""
|
||||||
|
|
||||||
|
elif loaderStatus == ResourceLoader.ThreadLoadStatus.THREAD_LOAD_IN_PROGRESS:
|
||||||
|
LOADING_PROGRESS_UPDATED.emit(progress[0])
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
uid://b406e4rlci4u3
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
extends Control
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func _on_new_game_button_pressed() -> void:
|
||||||
|
Loader.loadScene(self, "res://scenes/game.tscn")
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
uid://bklj1ua1qok02
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
extends Control
|
||||||
|
|
||||||
|
@export var loadingBar: TextureProgressBar
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
Loader.LOADING_PROGRESS_UPDATED.connect(_on_progress_updated)
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func _on_progress_updated(percentage: float) -> void:
|
||||||
|
loadingBar.value = percentage
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
uid://d1ag1ag2bbhtx
|
||||||
Loading…
Reference in New Issue