aboutsummaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
author George L. Albany <Megacake1234@gmail.com>2024-01-22 11:36:03 +0100
committer GitHub <noreply@github.com>2024-01-22 11:36:03 +0100
commit069f07a16daf04982677182caf39498e1539f3f0 (patch)
treebb8d68e013c3a815f1a1e418e564f03a9a2a451b /game
parent0840fd621cf35201f1e5ef90ad09033a2242b181 (diff)
parent9bca5cf3206a54b2e587cefab80d9dbcbbd002af (diff)
Merge pull request #198 from Spartan322/add/vic2-file-picker
Add Victoria 2 Folder Picker dialog
Diffstat (limited to 'game')
-rw-r--r--game/assets/localisation/locales/en_GB/menus.csv4
-rw-r--r--game/src/Game/Autoload/Argument/ArgumentParser.gd8
-rw-r--r--game/src/Game/GameStart.gd39
-rw-r--r--game/src/Game/GameStart.tscn15
-rw-r--r--game/src/Game/Menu/OptionMenu/ControlsTab.tscn2
5 files changed, 53 insertions, 15 deletions
diff --git a/game/assets/localisation/locales/en_GB/menus.csv b/game/assets/localisation/locales/en_GB/menus.csv
index 08ac0fe..f329342 100644
--- a/game/assets/localisation/locales/en_GB/menus.csv
+++ b/game/assets/localisation/locales/en_GB/menus.csv
@@ -123,6 +123,10 @@ DIALOG_CANCEL;Cancel
DIALOG_SAVE_AND_RESIGN;Save and Resign
DIALOG_SAVE_AND_QUIT;Save and Quit
+VIC2_DIR_DIALOG_TITLE;Select your Victoria 2 Game Directory
+VIC2_DIR_DIALOG_SELECT;Select
+VIC2_DIR_DIALOG_CANCEL;Cancel
+
;; Province Overview Panel
province_MISSING;No Province
region_MISSING;No Region
diff --git a/game/src/Game/Autoload/Argument/ArgumentParser.gd b/game/src/Game/Autoload/Argument/ArgumentParser.gd
index 96b6631..1b68cad 100644
--- a/game/src/Game/Autoload/Argument/ArgumentParser.gd
+++ b/game/src/Game/Autoload/Argument/ArgumentParser.gd
@@ -82,7 +82,7 @@ func _set_argument_setting() -> void:
argument_dictionary[option.name] = option.default_value
_parse_argument_list(argument_dictionary, OS.get_cmdline_args())
- _parse_argument_list(argument_dictionary, OS.get_cmdline_user_args())
+ _parse_argument_list(argument_dictionary, OS.get_cmdline_user_args(), true)
ProjectSettings.set_setting(argument_setting_path, argument_dictionary)
@@ -207,7 +207,7 @@ func _add_argument(dictionary : Dictionary, option : ArgumentOption, argument :
dictionary[option.name] = argument
-func _parse_argument_list(dictionary : Dictionary, arg_list : PackedStringArray) -> Dictionary:
+func _parse_argument_list(dictionary : Dictionary, arg_list : PackedStringArray, is_game_args : bool = false) -> Dictionary:
var current_key : String = ""
var current_option : ArgumentOption = null
for arg in arg_list:
@@ -282,8 +282,8 @@ func _parse_argument_list(dictionary : Dictionary, arg_list : PackedStringArray)
dictionary[current_option.name] = true
else:
push_warning("Argument '%s' treated like a boolean but does not support a boolean value, skipping." % key)
- else:
- push_warning("Non argument '%s' found, skipping." % arg)
+ elif is_game_args:
+ push_warning("Non-argument '%s' found, skipping." % arg)
return dictionary
diff --git a/game/src/Game/GameStart.gd b/game/src/Game/GameStart.gd
index 857fea9..7a52846 100644
--- a/game/src/Game/GameStart.gd
+++ b/game/src/Game/GameStart.gd
@@ -6,13 +6,17 @@ const GameMenuScene := preload("res://src/Game/GameMenu.tscn")
@export_subgroup("Nodes")
@export var loading_screen : LoadingScreen
+@export var vic2_dir_dialog : FileDialog
@export_subgroup("")
@export var section_name : String = "general"
@export var setting_name : String = "base_defines_path"
+
var _settings_base_path : String = ""
+var _compatibility_path_list : PackedStringArray = []
func _ready() -> void:
+ Localisation.initialize()
if ArgumentParser.get_argument(&"help"):
ArgumentParser._print_help()
# For some reason this doesn't get freed properly
@@ -31,7 +35,8 @@ func _ready() -> void:
Events.Options.load_settings_from_file()
sound_tab.queue_free()
- loading_screen.start_loading_screen(_initialize_game)
+ await _setup_compatibility_mode_paths()
+ await loading_screen.start_loading_screen(_initialize_game)
func _load_setting(file : ConfigFile) -> void:
if file == null: return
@@ -41,7 +46,7 @@ func _save_setting(file : ConfigFile) -> void:
if file == null: return
file.set_value(section_name, setting_name, _settings_base_path)
-func _load_compatibility_mode() -> void:
+func _setup_compatibility_mode_paths() -> void:
# To test mods, set your base path to Victoria II and then pass mods in reverse order with --mod="mod" for each mod.
var arg_base_path : String = ArgumentParser.get_argument(&"base-path", "")
@@ -67,23 +72,40 @@ func _load_compatibility_mode() -> void:
# and if not also search for a Steam install
actual_base_path = GameSingleton.search_for_game_path("..")
if not actual_base_path:
- OS.alert(tr("ERROR_ASSET_PATH_NOT_FOUND_MESSAGE"), tr("ERROR_ASSET_PATH_NOT_FOUND"))
- get_tree().quit()
- return
+ get_tree().paused = true
+ vic2_dir_dialog.popup_centered_ratio()
+ # Remove with https://github.com/godotengine/godot/pull/81178
+ vic2_dir_dialog.ok_button_text = "VIC2_DIR_DIALOG_SELECT"
+ # WHY WON'T CANCEL AUTO-TRANSLATE WORK NOW?!?!?!?
+ var cancel_button := vic2_dir_dialog.get_cancel_button()
+ cancel_button.auto_translate = false
+ cancel_button.auto_translate = true
+ var failure_func := func() -> void:
+ get_window().mode = Window.MODE_WINDOWED
+ OS.alert(tr("ERROR_ASSET_PATH_NOT_FOUND_MESSAGE"), tr("ERROR_ASSET_PATH_NOT_FOUND"))
+ get_tree().quit()
+ vic2_dir_dialog.canceled.connect(failure_func)
+ await vic2_dir_dialog.dir_selected
+ get_tree().paused = false
+ actual_base_path = GameSingleton.search_for_game_path(vic2_dir_dialog.current_path)
+ if not actual_base_path:
+ failure_func.call()
+ return
if not _settings_base_path:
_settings_base_path = actual_base_path
# Save the path found in the search
Events.Options.save_settings_to_file()
- var paths : PackedStringArray = [actual_base_path]
+ _compatibility_path_list = [actual_base_path]
# Add mod paths
var settings_mod_names : PackedStringArray = ArgumentParser.get_argument(&"mod", "")
for mod_name : String in settings_mod_names:
- paths.push_back(actual_base_path + "/mod/" + mod_name)
+ _compatibility_path_list.push_back(actual_base_path + "/mod/" + mod_name)
- if GameSingleton.load_defines_compatibility_mode(paths) != OK:
+func _load_compatibility_mode() -> void:
+ if GameSingleton.load_defines_compatibility_mode(_compatibility_path_list) != OK:
push_error("Errors loading game defines!")
# REQUIREMENTS
@@ -93,7 +115,6 @@ func _initialize_game() -> void:
loading_screen.try_update_loading_screen(0)
GameSingleton.setup_logger()
- Localisation.initialize()
loading_screen.try_update_loading_screen(15, true)
_load_compatibility_mode()
diff --git a/game/src/Game/GameStart.tscn b/game/src/Game/GameStart.tscn
index eccddc9..3b3a41f 100644
--- a/game/src/Game/GameStart.tscn
+++ b/game/src/Game/GameStart.tscn
@@ -7,7 +7,7 @@
[ext_resource type="Texture2D" uid="uid://cgdnixsyh7bja" path="res://assets/graphics/splash_image.png" id="4_5b6yq"]
[ext_resource type="VideoStream" path="res://assets/graphics/splash_startup.ogv" id="5_8euyy"]
-[node name="GameStartup" type="Control" node_paths=PackedStringArray("loading_screen")]
+[node name="GameStartup" type="Control" node_paths=PackedStringArray("loading_screen", "vic2_dir_dialog")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
@@ -16,6 +16,7 @@ grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_e0cos")
loading_screen = NodePath("LoadingScreen")
+vic2_dir_dialog = NodePath("Vic2DirDialog")
[node name="LoadingScreen" parent="." instance=ExtResource("2_h0oiw")]
visible = false
@@ -51,5 +52,17 @@ stream = ExtResource("5_8euyy")
autoplay = true
expand = true
+[node name="Vic2DirDialog" type="FileDialog" parent="."]
+process_mode = 2
+disable_3d = true
+title = "VIC2_DIR_DIALOG_TITLE"
+size = Vector2i(935, 159)
+ok_button_text = "VIC2_DIR_DIALOG_SELECT"
+cancel_button_text = "VIC2_DIR_DIALOG_CANCEL"
+mode_overrides_title = false
+file_mode = 2
+access = 2
+show_hidden_files = true
+
[connection signal="splash_end" from="SplashContainer" to="." 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/Menu/OptionMenu/ControlsTab.tscn b/game/src/Game/Menu/OptionMenu/ControlsTab.tscn
index b84dc85..b1f4331 100644
--- a/game/src/Game/Menu/OptionMenu/ControlsTab.tscn
+++ b/game/src/Game/Menu/OptionMenu/ControlsTab.tscn
@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://cdwymd51i4b2f"]
-[ext_resource type="PackedScene" uid="uid://by4gggse2nsdx" path="res://addons/keychain/ShortcutEdit.tscn" id="1_fv8sh"]
+[ext_resource type="PackedScene" uid="uid://bq7ibhm0txl5p" path="res://addons/keychain/ShortcutEdit.tscn" id="1_fv8sh"]
[node name="Controls" type="Control"]
layout_mode = 3