diff --git a/client/Start.gd b/client/Start.gd new file mode 100644 index 0000000..27d9646 --- /dev/null +++ b/client/Start.gd @@ -0,0 +1,31 @@ +extends Node + +@export var scene_path: String +@export var progress_bar: ProgressBar +@export var modulate: CanvasModulate +@export var fade_duration: float +@export var use_sub_threads: bool + +var progress: Array + +func _ready(): + ResourceLoader.load_threaded_request(scene_path, "", use_sub_threads) + +func _process(_delta): + var status := ResourceLoader.load_threaded_get_status(scene_path, progress) + progress_bar.value = progress[0] * 100 + + if status == ResourceLoader.THREAD_LOAD_LOADED: + add_scene() + fade_out() + +func add_scene(): + var scene := ResourceLoader.load_threaded_get(scene_path) + var node := scene.instantiate() as Node + get_tree().root.add_child(node) + +func fade_out(): + progress_bar.hide() + var tween = get_tree().create_tween() + tween.tween_property(modulate, "color", Color(1.0, 1.0, 1.0, 0), fade_duration) + tween.tween_callback(queue_free) \ No newline at end of file diff --git a/client/Start.tscn b/client/Start.tscn new file mode 100644 index 0000000..3989b2e --- /dev/null +++ b/client/Start.tscn @@ -0,0 +1,37 @@ +[gd_scene load_steps=2 format=3 uid="uid://ds5dynfon316"] + +[ext_resource type="Script" path="res://Start.gd" id="1_8y1vx"] + +[node name="Start" type="CanvasLayer" node_paths=PackedStringArray("progress_bar", "modulate")] +script = ExtResource("1_8y1vx") +scene_path = "Main.tscn" +progress_bar = NodePath("MarginContainer/Progress") +modulate = NodePath("CanvasModulate") +fade_duration = 0.75 +use_sub_threads = true + +[node name="CanvasModulate" type="CanvasModulate" parent="."] + +[node name="Background" type="ColorRect" parent="."] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 1 +color = Color(0.12549, 0.12549, 0.12549, 1) + +[node name="MarginContainer" type="MarginContainer" parent="."] +anchors_preset = 12 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = -52.0 +offset_right = 28.0 +grow_horizontal = 2 +grow_vertical = 0 + +[node name="Progress" type="ProgressBar" parent="MarginContainer"] +unique_name_in_owner = true +layout_mode = 2 +mouse_filter = 1 diff --git a/client/project.godot b/client/project.godot index ba0af08..3eb335b 100644 --- a/client/project.godot +++ b/client/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="Client" -run/main_scene="res://Main.tscn" +run/main_scene="res://Start.tscn" config/features=PackedStringArray("4.2", "Forward Plus") config/icon="res://ui/icon.svg"