diff options
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 |
commit | 069f07a16daf04982677182caf39498e1539f3f0 (patch) | |
tree | bb8d68e013c3a815f1a1e418e564f03a9a2a451b /game/src/Game/GameStart.gd | |
parent | 0840fd621cf35201f1e5ef90ad09033a2242b181 (diff) | |
parent | 9bca5cf3206a54b2e587cefab80d9dbcbbd002af (diff) |
Merge pull request #198 from Spartan322/add/vic2-file-picker
Add Victoria 2 Folder Picker dialog
Diffstat (limited to 'game/src/Game/GameStart.gd')
-rw-r--r-- | game/src/Game/GameStart.gd | 39 |
1 files changed, 30 insertions, 9 deletions
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() |