From 6fad9af2a225c95bbb1c9ff38427ec7812701a0e Mon Sep 17 00:00:00 2001 From: Rob Kelly Date: Wed, 18 Dec 2024 10:48:35 -0700 Subject: [PATCH] Fixed loading screen transition sequencing --- src/game/game.gd | 21 ++++++++++--------- src/game/game.tscn | 19 +++++++++++++++-- .../deathmatch_setup/deathmatch_setup.tscn | 12 +++++++++++ src/ui/menus/title_screen/title_screen.tscn | 2 +- 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/game/game.gd b/src/game/game.gd index fd46b50..8c92278 100644 --- a/src/game/game.gd +++ b/src/game/game.gd @@ -58,28 +58,26 @@ func _ready() -> void: ## ## The loading screen will be shown until the scene is loaded. func queue_scene(path: String) -> Promise: - if not loading_screen.visible: - loading_screen.show() - loading_screen.modulate = Color.WHITE - - for child: Node in content.get_children(): - child.queue_free() - - return queue_load(path, ScenePromise.new()).finally(_finish_scene_load) + return queue_load(path, ScenePromise.new(), "PackedScene").finally(_finish_scene_load) ## Queue a resource to be loaded in the background. ## ## Returns a `Promise` which can be used to attach callbacks ## which will be called with the resource after it is loaded. -func queue_load(path: String, promise: Promise = null) -> Promise: +func queue_load(path: String, promise: Promise = null, type_hint: String = "") -> Promise: if not promise: promise = Promise.new() _loading_resources[path] = promise - ResourceLoader.load_threaded_request(path) + ResourceLoader.load_threaded_request(path, type_hint) return promise +func _unload_content() -> void: + for child: Node in content.get_children(): + child.queue_free() + + func _finish_scene_load(instance: Node) -> void: content.add_child(instance) instance.reparent(content) @@ -89,6 +87,9 @@ func _process(_delta: float) -> void: if _loading_resources and not loading_screen.visible: loader_transition.play("fade_in") + if loader_transition.is_playing(): + return + for key: String in _loading_resources.keys(): match ResourceLoader.load_threaded_get_status(key): ResourceLoader.THREAD_LOAD_LOADED: diff --git a/src/game/game.tscn b/src/game/game.tscn index 293e9b4..f1d9c79 100644 --- a/src/game/game.tscn +++ b/src/game/game.tscn @@ -38,7 +38,7 @@ tracks/1/keys = { [sub_resource type="Animation" id="Animation_2c1ud"] resource_name = "fade_in" -length = 0.4 +length = 0.2 tracks/0/type = "value" tracks/0/imported = false tracks/0/enabled = true @@ -58,11 +58,25 @@ tracks/1/path = NodePath(".:modulate") tracks/1/interp = 2 tracks/1/loop_wrap = true tracks/1/keys = { -"times": PackedFloat32Array(0, 0.4), +"times": PackedFloat32Array(0, 0.2), "transitions": PackedFloat32Array(1, 1), "update": 0, "values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)] } +tracks/2/type = "method" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("%RootControl/..") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0.2), +"transitions": PackedFloat32Array(1), +"values": [{ +"args": [], +"method": &"_unload_content" +}] +} [sub_resource type="Animation" id="Animation_xbqy2"] resource_name = "fade_out" @@ -114,6 +128,7 @@ grow_vertical = 2 [node name="LoadingScreen" type="Control" parent="RootControl"] unique_name_in_owner = true +process_mode = 3 z_index = 128 layout_mode = 1 anchors_preset = 15 diff --git a/src/ui/menus/title_screen/deathmatch_setup/deathmatch_setup.tscn b/src/ui/menus/title_screen/deathmatch_setup/deathmatch_setup.tscn index d1fecbc..c0b9f6e 100644 --- a/src/ui/menus/title_screen/deathmatch_setup/deathmatch_setup.tscn +++ b/src/ui/menus/title_screen/deathmatch_setup/deathmatch_setup.tscn @@ -125,6 +125,18 @@ tracks/0/keys = { "update": 1, "values": [false] } +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath(".:modulate") +tracks/1/interp = 2 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(1, 1, 1, 1)] +} [sub_resource type="AnimationLibrary" id="AnimationLibrary_s1eyj"] _data = { diff --git a/src/ui/menus/title_screen/title_screen.tscn b/src/ui/menus/title_screen/title_screen.tscn index a4c0dca..4257ba9 100644 --- a/src/ui/menus/title_screen/title_screen.tscn +++ b/src/ui/menus/title_screen/title_screen.tscn @@ -1480,7 +1480,7 @@ grow_horizontal = 2 grow_vertical = 2 [node name="PressStart" type="Label" parent="Menu"] -modulate = Color(1, 1, 1, 0.997997) +modulate = Color(1, 1, 1, 0.0282702) layout_mode = 1 anchors_preset = 8 anchor_left = 0.5