fix: animation state changes for loading spinner.

This commit is contained in:
tiger tiger tiger 2025-12-19 20:04:41 +01:00
parent 8db1c0fab7
commit d09a930faa
9 changed files with 70 additions and 67 deletions

View File

@ -0,0 +1 @@
uid://bdrnh00pmyclj

View File

@ -6,22 +6,22 @@
[ext_resource type="Texture2D" uid="uid://b7breoabkyifr" path="res://addons/input_prompts/icons/xbox/A.png" id="3_g0dpf"] [ext_resource type="Texture2D" uid="uid://b7breoabkyifr" path="res://addons/input_prompts/icons/xbox/A.png" id="3_g0dpf"]
[ext_resource type="Texture2D" uid="uid://615hvpuiacvm" path="res://addons/input_prompts/icons/xbox/X.png" id="5_fk5x4"] [ext_resource type="Texture2D" uid="uid://615hvpuiacvm" path="res://addons/input_prompts/icons/xbox/X.png" id="5_fk5x4"]
[sub_resource type="InputEventMouseButton" id="InputEventMouseButton_fk5x4"] [sub_resource type="InputEventMouseButton" id="InputEventMouseButton_yg774"]
device = -1 device = -1
button_index = 1 button_index = 1
[sub_resource type="InputEventJoypadButton" id="InputEventJoypadButton_8vhsk"] [sub_resource type="InputEventJoypadButton" id="InputEventJoypadButton_vmmjr"]
device = -1 device = -1
[sub_resource type="InputEventKey" id="InputEventKey_t7f8v"] [sub_resource type="InputEventKey" id="InputEventKey_qqo47"]
device = -1 device = -1
physical_keycode = 4194309 physical_keycode = 4194309
[sub_resource type="InputEventMouseButton" id="InputEventMouseButton_6fedj"] [sub_resource type="InputEventMouseButton" id="InputEventMouseButton_axm2i"]
device = -1 device = -1
button_index = 2 button_index = 2
[sub_resource type="InputEventJoypadButton" id="InputEventJoypadButton_bnbqn"] [sub_resource type="InputEventJoypadButton" id="InputEventJoypadButton_762cl"]
device = -1 device = -1
button_index = 2 button_index = 2
@ -894,7 +894,7 @@ stretch_mode = 5
script = ExtResource("2_2apub") script = ExtResource("2_2apub")
action = "collect_memento_ui" action = "collect_memento_ui"
icon = 0 icon = 0
events = Array[InputEvent]([SubResource("InputEventMouseButton_fk5x4"), SubResource("InputEventJoypadButton_8vhsk"), SubResource("InputEventKey_t7f8v")]) events = Array[InputEvent]([SubResource("InputEventMouseButton_yg774"), SubResource("InputEventJoypadButton_vmmjr"), SubResource("InputEventKey_qqo47")])
metadata/_custom_type_script = "uid://bbs1u7ojno7xo" metadata/_custom_type_script = "uid://bbs1u7ojno7xo"
[node name="CollectLabel" type="Label" parent="VBoxContainer/HBoxContainer"] [node name="CollectLabel" type="Label" parent="VBoxContainer/HBoxContainer"]
@ -914,7 +914,7 @@ stretch_mode = 5
script = ExtResource("2_2apub") script = ExtResource("2_2apub")
action = "option_memento_ui" action = "option_memento_ui"
icon = 0 icon = 0
events = Array[InputEvent]([SubResource("InputEventMouseButton_6fedj"), SubResource("InputEventJoypadButton_bnbqn")]) events = Array[InputEvent]([SubResource("InputEventMouseButton_axm2i"), SubResource("InputEventJoypadButton_762cl")])
metadata/_custom_type_script = "uid://bbs1u7ojno7xo" metadata/_custom_type_script = "uid://bbs1u7ojno7xo"
[node name="OptionsLabel" type="Label" parent="VBoxContainer/HBoxContainer"] [node name="OptionsLabel" type="Label" parent="VBoxContainer/HBoxContainer"]

View File

@ -58,13 +58,16 @@ func _ready() -> void:
main_menu.continue_button.pressed.connect(func(): app_state = AppState.PLAY) main_menu.continue_button.pressed.connect(func(): app_state = AppState.PLAY)
main_menu.credits_button.pressed.connect(func(): app_state = AppState.CREDITS) main_menu.credits_button.pressed.connect(func(): app_state = AppState.CREDITS)
#TODO: Load the last savegame(?)
await %Loading.stop()
if normal_boot: if normal_boot:
print_debug("main.gd: normal boot (loading last save and showing main menu)") print_debug("main.gd: normal boot (loading last save and showing main menu)")
app_state = AppState.MENU app_state = AppState.MENU
else: else:
print_debug("main.gd: direct boot (hiding menus and entering main loop)") print_debug("main.gd: direct boot (hiding menus and entering main loop)")
app_state = AppState.PLAY app_state = AppState.PLAY
#await _mainloop() # Debug functionality
func load_game(save: SaveGame) -> void: func load_game(save: SaveGame) -> void:
print_debug("main.gd: _load_game()") print_debug("main.gd: _load_game()")
@ -76,6 +79,7 @@ func _load_room(next_path: String) -> bool:
State.room.unload() State.room.unload()
State.room = null State.room = null
await curtain.show() await curtain.show()
%Loading.play()
ResourceLoader.load_threaded_request(next_path, "PackedScene", true) ResourceLoader.load_threaded_request(next_path, "PackedScene", true)
while true: while true:
await get_tree().process_frame await get_tree().process_frame
@ -87,9 +91,10 @@ func _load_room(next_path: String) -> bool:
get_tree().root.add_child(State.room) get_tree().root.add_child(State.room)
await State.room.get_ready() await State.room.get_ready()
await curtain.hide() await curtain.hide()
%Loading.stop()
return true return true
ResourceLoader.THREAD_LOAD_FAILED: ResourceLoader.THREAD_LOAD_FAILED:
push_error("Failed to load youth room scene.") push_error("Failed to load room.")
break break
return false return false

View File

@ -101,7 +101,9 @@ unique_name_in_owner = true
layout_mode = 1 layout_mode = 1
[node name="Loading" parent="." instance=ExtResource("5_dxvjq")] [node name="Loading" parent="." instance=ExtResource("5_dxvjq")]
unique_name_in_owner = true
layout_mode = 1 layout_mode = 1
offset_bottom = 0.0
[node name="MainMenu" parent="." instance=ExtResource("3_ik73t")] [node name="MainMenu" parent="." instance=ExtResource("3_ik73t")]
unique_name_in_owner = true unique_name_in_owner = true

View File

@ -6,7 +6,7 @@ length = 1.5
tracks/0/type = "value" tracks/0/type = "value"
tracks/0/imported = false tracks/0/imported = false
tracks/0/enabled = true tracks/0/enabled = true
tracks/0/path = NodePath("mask/frame/deco:rotation") tracks/0/path = NodePath("CanvasLayer/mask/frame/deco:rotation")
tracks/0/interp = 1 tracks/0/interp = 1
tracks/0/loop_wrap = true tracks/0/loop_wrap = true
tracks/0/keys = { tracks/0/keys = {
@ -30,7 +30,7 @@ tracks/1/keys = {
tracks/2/type = "value" tracks/2/type = "value"
tracks/2/imported = false tracks/2/imported = false
tracks/2/enabled = true tracks/2/enabled = true
tracks/2/path = NodePath("LoadingLabel:visible") tracks/2/path = NodePath("CanvasLayer/LoadingLabel:visible")
tracks/2/interp = 1 tracks/2/interp = 1
tracks/2/loop_wrap = true tracks/2/loop_wrap = true
tracks/2/keys = { tracks/2/keys = {
@ -42,7 +42,7 @@ tracks/2/keys = {
tracks/3/type = "value" tracks/3/type = "value"
tracks/3/imported = false tracks/3/imported = false
tracks/3/enabled = true tracks/3/enabled = true
tracks/3/path = NodePath("LoadingLabel:modulate") tracks/3/path = NodePath("CanvasLayer/LoadingLabel:modulate")
tracks/3/interp = 1 tracks/3/interp = 1
tracks/3/loop_wrap = true tracks/3/loop_wrap = true
tracks/3/keys = { tracks/3/keys = {
@ -51,15 +51,3 @@ tracks/3/keys = {
"update": 0, "update": 0,
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)] "values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
} }
tracks/4/type = "value"
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/path = NodePath("LoadingLabel:position")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/keys = {
"times": PackedFloat32Array(0.93333334, 1.5),
"transitions": PackedFloat32Array(1.6788809, 1),
"update": 0,
"values": [Vector2(170, -37), Vector2(100, -37)]
}

View File

@ -7,7 +7,7 @@ loop_mode = 1
tracks/0/type = "value" tracks/0/type = "value"
tracks/0/imported = false tracks/0/imported = false
tracks/0/enabled = true tracks/0/enabled = true
tracks/0/path = NodePath("mask:modulate") tracks/0/path = NodePath("CanvasLayer/mask:modulate")
tracks/0/interp = 1 tracks/0/interp = 1
tracks/0/loop_wrap = true tracks/0/loop_wrap = true
tracks/0/keys = { tracks/0/keys = {
@ -19,7 +19,7 @@ tracks/0/keys = {
tracks/1/type = "value" tracks/1/type = "value"
tracks/1/imported = false tracks/1/imported = false
tracks/1/enabled = true tracks/1/enabled = true
tracks/1/path = NodePath("mask:rotation") tracks/1/path = NodePath("CanvasLayer/mask:rotation")
tracks/1/interp = 1 tracks/1/interp = 1
tracks/1/loop_wrap = true tracks/1/loop_wrap = true
tracks/1/keys = { tracks/1/keys = {
@ -31,7 +31,7 @@ tracks/1/keys = {
tracks/2/type = "value" tracks/2/type = "value"
tracks/2/imported = false tracks/2/imported = false
tracks/2/enabled = true tracks/2/enabled = true
tracks/2/path = NodePath("mask/frame/deco:rotation") tracks/2/path = NodePath("CanvasLayer/mask/frame/deco:rotation")
tracks/2/interp = 1 tracks/2/interp = 1
tracks/2/loop_wrap = true tracks/2/loop_wrap = true
tracks/2/keys = { tracks/2/keys = {
@ -43,7 +43,7 @@ tracks/2/keys = {
tracks/3/type = "value" tracks/3/type = "value"
tracks/3/imported = false tracks/3/imported = false
tracks/3/enabled = true tracks/3/enabled = true
tracks/3/path = NodePath("mask/frame/deco:modulate") tracks/3/path = NodePath("CanvasLayer/mask/frame/deco:modulate")
tracks/3/interp = 1 tracks/3/interp = 1
tracks/3/loop_wrap = true tracks/3/loop_wrap = true
tracks/3/keys = { tracks/3/keys = {
@ -55,48 +55,24 @@ tracks/3/keys = {
tracks/4/type = "value" tracks/4/type = "value"
tracks/4/imported = false tracks/4/imported = false
tracks/4/enabled = true tracks/4/enabled = true
tracks/4/path = NodePath("../../MainMenu:modulate") tracks/4/path = NodePath("CanvasLayer/LoadingLabel:visible")
tracks/4/interp = 1 tracks/4/interp = 1
tracks/4/loop_wrap = true tracks/4/loop_wrap = true
tracks/4/keys = { tracks/4/keys = {
"times": PackedFloat32Array(0), "times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1), "transitions": PackedFloat32Array(1),
"update": 0, "update": 1,
"values": [Color(1, 1, 1, 0)] "values": [true]
} }
tracks/5/type = "value" tracks/5/type = "value"
tracks/5/imported = false tracks/5/imported = false
tracks/5/enabled = true tracks/5/enabled = true
tracks/5/path = NodePath("LoadingLabel:visible") tracks/5/path = NodePath("CanvasLayer/LoadingLabel:modulate")
tracks/5/interp = 1 tracks/5/interp = 1
tracks/5/loop_wrap = true tracks/5/loop_wrap = true
tracks/5/keys = { tracks/5/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
tracks/6/type = "value"
tracks/6/imported = false
tracks/6/enabled = true
tracks/6/path = NodePath("LoadingLabel:modulate")
tracks/6/interp = 1
tracks/6/loop_wrap = true
tracks/6/keys = {
"times": PackedFloat32Array(0.06666672, 1.1666666), "times": PackedFloat32Array(0.06666672, 1.1666666),
"transitions": PackedFloat32Array(1, 1), "transitions": PackedFloat32Array(1, 1),
"update": 0, "update": 0,
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)] "values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
} }
tracks/7/type = "value"
tracks/7/imported = false
tracks/7/enabled = true
tracks/7/path = NodePath("LoadingLabel:position")
tracks/7/interp = 1
tracks/7/loop_wrap = true
tracks/7/keys = {
"times": PackedFloat32Array(0.93333334),
"transitions": PackedFloat32Array(1.6788809),
"update": 0,
"values": [Vector2(170, -37)]
}

16
src/ui/loading/loading.gd Normal file
View File

@ -0,0 +1,16 @@
extends Control
class_name Loading
@onready var animation: AnimationPlayer = %AnimationPlayer
@onready var label: Label = %LoadingLabel
func _ready() -> void:
play()
func play() -> void:
animation.play("LoadingSpinner/anim_loading_game")
func stop() -> void:
if animation.is_playing():
animation.stop()
animation.play("LoadingSpinner/anim_loading_done")

View File

@ -0,0 +1 @@
uid://dc46me7xd5pbc

View File

@ -1,5 +1,6 @@
[gd_scene load_steps=8 format=3 uid="uid://d38f0a333kki1"] [gd_scene load_steps=9 format=3 uid="uid://d38f0a333kki1"]
[ext_resource type="Script" uid="uid://dc46me7xd5pbc" path="res://ui/loading/loading.gd" id="1_aeyqy"]
[ext_resource type="Texture2D" uid="uid://d031kxe5m4ihh" path="res://import/interface-elements/loading_rect_clip.png" id="1_dbd3p"] [ext_resource type="Texture2D" uid="uid://d031kxe5m4ihh" path="res://import/interface-elements/loading_rect_clip.png" id="1_dbd3p"]
[ext_resource type="Texture2D" uid="uid://bqf82f8dk4yun" path="res://import/interface-elements/loading_rect_frame.png" id="2_6oitr"] [ext_resource type="Texture2D" uid="uid://bqf82f8dk4yun" path="res://import/interface-elements/loading_rect_frame.png" id="2_6oitr"]
[ext_resource type="Texture2D" uid="uid://dpftqdvtrkioh" path="res://import/interface-elements/loading_rect_deco.png" id="3_jqdbn"] [ext_resource type="Texture2D" uid="uid://dpftqdvtrkioh" path="res://import/interface-elements/loading_rect_deco.png" id="3_jqdbn"]
@ -18,6 +19,7 @@ func _ready() -> void:
var _accumulate_delta: float = 0 var _accumulate_delta: float = 0
var _frame: int = 0 var _frame: int = 0
func _process(delta: float) -> void: func _process(delta: float) -> void:
_accumulate_delta += delta _accumulate_delta += delta
if _accumulate_delta > animation_speed: if _accumulate_delta > animation_speed:
@ -43,29 +45,41 @@ layout_mode = 3
anchors_preset = 2 anchors_preset = 2
anchor_top = 1.0 anchor_top = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
offset_top = -80.16669
offset_right = 500.0
offset_bottom = 0.00036621094
grow_vertical = 0 grow_vertical = 0
script = ExtResource("1_aeyqy")
[node name="mask" type="Sprite2D" parent="."] [node name="CanvasLayer" type="CanvasLayer" parent="."]
layer = 100
[node name="mask" type="Sprite2D" parent="CanvasLayer"]
modulate = Color(1, 1, 1, 0) modulate = Color(1, 1, 1, 0)
clip_children = 1 clip_children = 1
position = Vector2(101.4607, -58.539307) position = Vector2(73.00001, 980.00006)
scale = Vector2(0.99999994, 0.99999994)
texture = ExtResource("1_dbd3p") texture = ExtResource("1_dbd3p")
[node name="frame" type="Sprite2D" parent="mask"] [node name="frame" type="Sprite2D" parent="CanvasLayer/mask"]
texture = ExtResource("2_6oitr") texture = ExtResource("2_6oitr")
[node name="deco" type="Sprite2D" parent="mask/frame"] [node name="deco" type="Sprite2D" parent="CanvasLayer/mask/frame"]
modulate = Color(1, 1, 1, 0) modulate = Color(1, 1, 1, 0)
rotation = -0.261799 rotation = -0.261799
texture = ExtResource("3_jqdbn") texture = ExtResource("3_jqdbn")
[node name="LoadingLabel" type="Label" parent="."] [node name="LoadingLabel" type="Label" parent="CanvasLayer"]
layout_mode = 0 unique_name_in_owner = true
offset_left = 170.0 anchors_preset = 2
offset_top = -37.0 anchor_top = 1.0
offset_right = 310.00003 anchor_bottom = 1.0
offset_bottom = 9.0 offset_top = -38.16626
offset_right = 89.0
offset_bottom = 0.00036621094
grow_vertical = 0
text = "loading" text = "loading"
vertical_alignment = 2
script = SubResource("GDScript_cegan") script = SubResource("GDScript_cegan")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."] [node name="AnimationPlayer" type="AnimationPlayer" parent="."]