Skip to content

Commit 62578e8

Browse files
committed
improve loading screen
1 parent 6f28c83 commit 62578e8

File tree

2 files changed

+48
-5
lines changed

2 files changed

+48
-5
lines changed

client/assets/ui/loading/loading.gd

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,25 @@ extends Control
44
var path: String
55
var is_loading: bool
66

7-
func _process(delta):
7+
@export var tips: Array = [
8+
"Press shift to sprint",
9+
"Scroll your mousewheel to zoom",
10+
"Press spacebar to jump",
11+
"Add more tips to the tips array in loading.gd"]
12+
13+
func _process(_delta):
814
if is_loading:
915
var progress: Array = []
1016
var status = ResourceLoader.load_threaded_get_status(path, progress)
1117
if status == ResourceLoader.THREAD_LOAD_IN_PROGRESS:
12-
get_node("ProgressBar").value = progress[0] *100
13-
print("status: " + str(progress[0] *100))
18+
19+
#this should work in godot 4.1
20+
# get_node("ProgressBar").value = progress[0] * 100
21+
22+
#temporary workaround until fixed
23+
get_node("ProgressBar").value += 1
24+
25+
print("progress: " + str(progress[0] * 100))
1426
print("this should work in godot 4.1: https://github.com/godotengine/godot/pull/75644")
1527
elif status == ResourceLoader.THREAD_LOAD_LOADED:
1628
set_process(false)
@@ -27,9 +39,16 @@ func change_map(resource: PackedScene):
2739
queue_free()
2840

2941

30-
func load_map(path: String):
31-
self.path = path
42+
func load_map(res_path: String):
43+
path = res_path
3244
show()
45+
if tips != null and !tips.is_empty():
46+
$Control/VBoxContainer2/tip.text = tips[randi() % tips.size()]
47+
48+
var level_name_parts: Array = path.split("/")
49+
var level_name_without_extension = level_name_parts[-1].split(".")[0]
50+
$Control/VBoxContainer/map_name.text = level_name_without_extension
51+
3352
if ResourceLoader.has_cached(path):
3453
ResourceLoader.load_threaded_get(path)
3554
else:

client/assets/ui/loading/loading.tscn

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,30 @@ layout_mode = 2
6666
text = "level_name"
6767
horizontal_alignment = 1
6868

69+
[node name="VBoxContainer2" type="VBoxContainer" parent="Control"]
70+
layout_mode = 1
71+
anchors_preset = 8
72+
anchor_left = 0.5
73+
anchor_top = 0.5
74+
anchor_right = 0.5
75+
anchor_bottom = 0.5
76+
offset_left = -43.5
77+
offset_top = 110.0
78+
offset_right = 43.5
79+
offset_bottom = 177.0
80+
grow_horizontal = 2
81+
grow_vertical = 2
82+
83+
[node name="tip_label" type="Label" parent="Control/VBoxContainer2"]
84+
layout_mode = 2
85+
text = "Tip:"
86+
horizontal_alignment = 1
87+
88+
[node name="tip" type="Label" parent="Control/VBoxContainer2"]
89+
layout_mode = 2
90+
text = "tip"
91+
horizontal_alignment = 1
92+
6993
[node name="ProgressBar" type="ProgressBar" parent="."]
7094
layout_mode = 1
7195
anchors_preset = 12

0 commit comments

Comments
 (0)