aboutsummaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
Diffstat (limited to 'game')
-rw-r--r--game/common/quotes.txt2
-rw-r--r--game/src/Game/Autoload/Events.gd30
-rw-r--r--game/src/Game/Autoload/Events/GameDebug.gd1
-rw-r--r--game/src/Game/Autoload/Events/Localisation.gd1
-rw-r--r--game/src/Game/Autoload/Events/Options.gd1
-rw-r--r--game/src/Game/Autoload/Events/ShaderManager.gd1
-rw-r--r--game/src/Game/GameMenu.gd5
-rw-r--r--game/src/Game/GameStart.tscn6
-rw-r--r--game/src/Game/LoadingScreen.gd30
-rw-r--r--game/src/Game/LoadingScreen.tscn70
-rw-r--r--game/theme/assets/loading_screen.pngbin0 -> 1058949 bytes
-rw-r--r--game/theme/assets/loading_screen.png.import34
12 files changed, 165 insertions, 16 deletions
diff --git a/game/common/quotes.txt b/game/common/quotes.txt
new file mode 100644
index 0000000..f8d36a1
--- /dev/null
+++ b/game/common/quotes.txt
@@ -0,0 +1,2 @@
+"The great questions of the day will not be settled by means of speeches and majority decisions but by iron and blood." - Otto von Bismarck
+"BrickPi is cool" - BrickPi
diff --git a/game/src/Game/Autoload/Events.gd b/game/src/Game/Autoload/Events.gd
index 4387cc7..786ece4 100644
--- a/game/src/Game/Autoload/Events.gd
+++ b/game/src/Game/Autoload/Events.gd
@@ -1,9 +1,9 @@
extends Node
-var GameDebug = preload("Events/GameDebug.gd").new()
-var Options = preload("Events/Options.gd").new()
-var Localisation = preload("Events/Localisation.gd").new()
-var ShaderManager = preload("Events/ShaderManager.gd").new()
+var GameDebug: GameDebugSingleton
+var Options: OptionsSingleton
+var Localisation: LocalisationSingleton
+var ShaderManager: ShaderManagerSingleton
var _define_filepaths_dict : Dictionary = {
GameSingleton.get_province_identifier_file_key(): "res://common/map/provinces.json",
@@ -19,9 +19,10 @@ var _define_filepaths_dict : Dictionary = {
# REQUIREMENTS
# * FS-333, FS-334, FS-335, FS-341
-func _ready():
+func load_events(loading_screen: LoadingScreen):
GameSingleton.setup_logger()
-
+ loading_screen.update_loading_screen(5)
+
# Set this to your Vic2 install dir or a mod's dir to enable compatibility mode
# (this won't work for mods which rely on vanilla map assets, copy missing assets
# into the mod's dir for a temporary fix)
@@ -33,13 +34,26 @@ func _ready():
compatibility_mode_path = arg_dictionary.get(&"compatibility-mode", compatibility_mode_path)
var start := Time.get_ticks_usec()
-
+
+ GameDebug = GameDebugSingleton.new()
+ loading_screen.update_loading_screen(15)
+ Options = OptionsSingleton.new()
+ loading_screen.update_loading_screen(25)
+ Localisation = LocalisationSingleton.new()
+ loading_screen.update_loading_screen(45)
+ ShaderManager = ShaderManagerSingleton.new()
+ loading_screen.update_loading_screen(50, true)
+
if compatibility_mode_path:
if GameSingleton.load_defines_compatibility_mode(compatibility_mode_path) != OK:
push_error("Errors loading game defines!")
else:
if GameSingleton.load_defines(_define_filepaths_dict) != OK:
push_error("Errors loading game defines!")
-
+
+ loading_screen.update_loading_screen(100)
var end := Time.get_ticks_usec()
print("Loading took ", float(end - start) / 1000000, " seconds")
+
+ # change scene in a thread-safe way
+ get_tree().call_deferred("change_scene_to_file", "res://src/Game/GameMenu.tscn")
diff --git a/game/src/Game/Autoload/Events/GameDebug.gd b/game/src/Game/Autoload/Events/GameDebug.gd
index df7a23a..ea4a157 100644
--- a/game/src/Game/Autoload/Events/GameDebug.gd
+++ b/game/src/Game/Autoload/Events/GameDebug.gd
@@ -1,4 +1,5 @@
extends RefCounted
+class_name GameDebugSingleton
# REQUIREMENTS:
# * SS-56
diff --git a/game/src/Game/Autoload/Events/Localisation.gd b/game/src/Game/Autoload/Events/Localisation.gd
index eda7e51..91f9ca0 100644
--- a/game/src/Game/Autoload/Events/Localisation.gd
+++ b/game/src/Game/Autoload/Events/Localisation.gd
@@ -1,4 +1,5 @@
extends RefCounted
+class_name LocalisationSingleton
# REQUIREMENTS
# * SS-59, SS-60, SS-61
diff --git a/game/src/Game/Autoload/Events/Options.gd b/game/src/Game/Autoload/Events/Options.gd
index fbeccef..2e9b90b 100644
--- a/game/src/Game/Autoload/Events/Options.gd
+++ b/game/src/Game/Autoload/Events/Options.gd
@@ -1,4 +1,5 @@
extends RefCounted
+class_name OptionsSingleton
signal save_settings(save_file: ConfigFile)
signal load_settings(load_file: ConfigFile)
diff --git a/game/src/Game/Autoload/Events/ShaderManager.gd b/game/src/Game/Autoload/Events/ShaderManager.gd
index a503c52..731dc3c 100644
--- a/game/src/Game/Autoload/Events/ShaderManager.gd
+++ b/game/src/Game/Autoload/Events/ShaderManager.gd
@@ -1,4 +1,5 @@
extends RefCounted
+class_name ShaderManagerSingleton
const param_province_shape_tex : StringName = &"province_shape_tex"
const param_province_shape_subdivisions : StringName = &"province_shape_subdivisions"
diff --git a/game/src/Game/GameMenu.gd b/game/src/Game/GameMenu.gd
index 4b589f9..8e3239f 100644
--- a/game/src/Game/GameMenu.gd
+++ b/game/src/Game/GameMenu.gd
@@ -40,8 +40,3 @@ func _on_credits_back_button_pressed():
func _on_main_menu_credits_button_pressed():
_credits_menu.show()
_main_menu.hide()
-
-
-
-func _on_splash_container_splash_end():
- show()
diff --git a/game/src/Game/GameStart.tscn b/game/src/Game/GameStart.tscn
index dd683e8..6cc358d 100644
--- a/game/src/Game/GameStart.tscn
+++ b/game/src/Game/GameStart.tscn
@@ -1,6 +1,6 @@
[gd_scene load_steps=6 format=3 uid="uid://1udsn4mggep2"]
-[ext_resource type="PackedScene" uid="uid://o4u142w4qkln" path="res://src/Game/GameMenu.tscn" id="1_vadki"]
+[ext_resource type="PackedScene" uid="uid://3kktdpfnc0sn" path="res://src/Game/LoadingScreen.tscn" id="2_h0oiw"]
[ext_resource type="Script" path="res://src/Game/SplashContainer.gd" id="2_xmcgv"]
[ext_resource type="Texture2D" uid="uid://deef5hufq0j61" path="res://splash_assets/splash_end.png" id="3_qfv12"]
[ext_resource type="Texture2D" uid="uid://cgdnixsyh7bja" path="res://splash_assets/splash_image.png" id="4_5b6yq"]
@@ -14,7 +14,7 @@ anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
-[node name="GameMenu" parent="." instance=ExtResource("1_vadki")]
+[node name="LoadingScreen" parent="." instance=ExtResource("2_h0oiw")]
visible = false
layout_mode = 1
@@ -48,5 +48,5 @@ stream = ExtResource("5_8euyy")
autoplay = true
expand = true
-[connection signal="splash_end" from="SplashContainer" to="GameMenu" method="_on_splash_container_splash_end"]
+[connection signal="splash_end" from="SplashContainer" to="LoadingScreen" method="_on_splash_container_splash_end"]
[connection signal="finished" from="SplashContainer/SplashVideo" to="SplashContainer" method="_on_splash_startup_finished"]
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()
diff --git a/game/src/Game/LoadingScreen.tscn b/game/src/Game/LoadingScreen.tscn
new file mode 100644
index 0000000..d6068c8
--- /dev/null
+++ b/game/src/Game/LoadingScreen.tscn
@@ -0,0 +1,70 @@
+[gd_scene load_steps=6 format=3 uid="uid://3kktdpfnc0sn"]
+
+[ext_resource type="Script" path="res://src/Game/LoadingScreen.gd" id="1_b0p3w"]
+[ext_resource type="Texture2D" uid="uid://doji17mxxmikl" path="res://theme/assets/loading_screen.png" id="2_ny153"]
+
+[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_3fggo"]
+texture = ExtResource("2_ny153")
+
+[sub_resource type="Theme" id="Theme_f5c3e"]
+PanelContainer/styles/panel = SubResource("StyleBoxTexture_3fggo")
+
+[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_yaf7e"]
+content_margin_left = 16.0
+content_margin_top = 16.0
+content_margin_right = 16.0
+content_margin_bottom = 16.0
+bg_color = Color(0.129412, 0.129412, 0.129412, 1)
+corner_radius_top_left = 16
+corner_radius_top_right = 16
+corner_radius_bottom_right = 16
+corner_radius_bottom_left = 16
+
+[node name="LoadingScreen" type="Control" node_paths=PackedStringArray("progress_bar", "quote_label")]
+layout_mode = 3
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+script = ExtResource("1_b0p3w")
+progress_bar = NodePath("PanelContainer/MarginContainer/ProgressBar")
+quote_label = NodePath("PanelContainer/MarginContainer/PanelContainer/QuoteLabel")
+
+[node name="PanelContainer" type="PanelContainer" parent="."]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+grow_horizontal = 2
+grow_vertical = 2
+theme = SubResource("Theme_f5c3e")
+
+[node name="MarginContainer" type="MarginContainer" parent="PanelContainer"]
+layout_mode = 2
+theme_override_constants/margin_left = 16
+theme_override_constants/margin_top = 16
+theme_override_constants/margin_right = 16
+theme_override_constants/margin_bottom = 16
+
+[node name="ProgressBar" type="ProgressBar" parent="PanelContainer/MarginContainer"]
+layout_mode = 2
+size_flags_vertical = 8
+step = 1.0
+rounded = true
+
+[node name="PanelContainer" type="PanelContainer" parent="PanelContainer/MarginContainer"]
+layout_mode = 2
+size_flags_horizontal = 4
+size_flags_vertical = 0
+theme_override_styles/panel = SubResource("StyleBoxFlat_yaf7e")
+
+[node name="QuoteLabel" type="Label" parent="PanelContainer/MarginContainer/PanelContainer"]
+custom_minimum_size = Vector2(700, 80)
+layout_mode = 2
+size_flags_horizontal = 4
+size_flags_vertical = 0
+horizontal_alignment = 1
+vertical_alignment = 1
+autowrap_mode = 3
+text_overrun_behavior = 3
diff --git a/game/theme/assets/loading_screen.png b/game/theme/assets/loading_screen.png
new file mode 100644
index 0000000..03e6945
--- /dev/null
+++ b/game/theme/assets/loading_screen.png
Binary files differ
diff --git a/game/theme/assets/loading_screen.png.import b/game/theme/assets/loading_screen.png.import
new file mode 100644
index 0000000..4fded7a
--- /dev/null
+++ b/game/theme/assets/loading_screen.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://doji17mxxmikl"
+path="res://.godot/imported/loading_screen.png-0c00ad5005bd6e8f8d33b24c232d736d.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://theme/assets/loading_screen.png"
+dest_files=["res://.godot/imported/loading_screen.png-0c00ad5005bd6e8f8d33b24c232d736d.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1