aboutsummaryrefslogtreecommitdiff
path: root/game/src/Game/LoadingScreen.gd
diff options
context:
space:
mode:
author Joel Machens <ajmach6@gmail.com>2023-06-12 04:27:31 +0200
committer BrickPi <49528459+BrickPi@users.noreply.github.com>2023-06-13 19:53:03 +0200
commitacda3217349a0ebdb8b48a3787cb15d8eb250e7c (patch)
treec6703f8c2f7fe33cfd6a11bbcf4d0a6294046570 /game/src/Game/LoadingScreen.gd
parent6e26b948ea2a7632bcb7b795fe78f7169477eb6a (diff)
Add Loading Screen
Diffstat (limited to 'game/src/Game/LoadingScreen.gd')
-rw-r--r--game/src/Game/LoadingScreen.gd30
1 files changed, 30 insertions, 0 deletions
diff --git a/game/src/Game/LoadingScreen.gd b/game/src/Game/LoadingScreen.gd
new file mode 100644
index 0000000..14acbd7
--- /dev/null
+++ b/game/src/Game/LoadingScreen.gd
@@ -0,0 +1,30 @@
+extends Control
+class_name LoadingScreen
+
+@export var progress_bar: ProgressBar
+@export var quote_label: Label
+
+var loadthread: Thread
+var quotes: PackedStringArray = []
+
+func update_loading_screen(percent_complete: int, quote_should_change = false):
+ progress_bar.value = percent_complete
+ if quote_should_change:
+ quote_label.text = quotes[randi() % quotes.size()]
+
+func _on_splash_container_splash_end():
+ show()
+
+func _ready():
+ # FS-3, UI-30, UIFUN-35
+ loadthread = Thread.new()
+ loadthread.start(Events.load_events.bind(self))
+ var quotes_file = FileAccess.open("res://common/quotes.txt", FileAccess.READ).get_as_text()
+ quotes = quotes_file.split("\n",false)
+ if quotes.is_empty():
+ quotes = [""]
+ # set first quote
+ quote_label.text = quotes[randi() % quotes.size()]
+
+func _exit_tree():
+ loadthread.wait_to_finish()