@@ -64,6 +64,18 @@ func _ready() -> void:
6464 await _setup_compatibility_mode_paths ()
6565 await loading_screen .start_loading_screen (_initialize_game )
6666
67+ func _on_vic2_dir_dialog_failed () -> void :
68+ get_window ().mode = Window .MODE_WINDOWED
69+ OS .alert (tr ("ERROR_ASSET_PATH_NOT_FOUND_MESSAGE" ), tr ("ERROR_ASSET_PATH_NOT_FOUND" ))
70+ get_tree ().root .propagate_notification (NOTIFICATION_WM_CLOSE_REQUEST )
71+ get_tree ().quit ()
72+
73+ var _selected_base_path : String
74+ func _on_vic2_dir_dialog_dir_selected (dir : String ) -> void :
75+ _selected_base_path = GameSingleton .search_for_game_path (dir )
76+ if not _selected_base_path :
77+ OS .alert (tr ("ERROR_ASSET_PATH_NOT_FOUND_MESSAGE" ), tr ("ERROR_ASSET_PATH_NOT_FOUND" ))
78+
6779func _setup_compatibility_mode_paths () -> void :
6880 # To test mods, set your base path to Victoria II and then pass mods in reverse order with --mod="mod" for each mod.
6981
@@ -91,28 +103,22 @@ func _setup_compatibility_mode_paths() -> void:
91103 actual_base_path = GameSingleton .search_for_game_path ("." )
92104 if not actual_base_path :
93105 get_tree ().paused = true
94- vic2_dir_dialog .popup_centered_ratio ()
95- # Remove with https://github.com/godotengine/godot/pull/81178
96- vic2_dir_dialog .ok_button_text = "VIC2_DIR_DIALOG_SELECT"
106+ var ok_button := vic2_dir_dialog .get_ok_button ()
107+ ok_button .auto_translate = true
97108 # WHY WON'T CANCEL AUTO-TRANSLATE WORK NOW?!?!?!?
98109 var cancel_button := vic2_dir_dialog .get_cancel_button ()
99- cancel_button .auto_translate = false
100110 cancel_button .auto_translate = true
101- var failure_func := func () -> void :
102- get_window ().mode = Window .MODE_WINDOWED
103- OS .alert (tr ("ERROR_ASSET_PATH_NOT_FOUND_MESSAGE" ), tr ("ERROR_ASSET_PATH_NOT_FOUND" ))
104- get_tree ().root .propagate_notification (NOTIFICATION_WM_CLOSE_REQUEST )
105- get_tree ().quit ()
106- vic2_dir_dialog .canceled .connect (failure_func )
107- await vic2_dir_dialog .dir_selected
111+ vic2_dir_dialog .canceled .connect (_on_vic2_dir_dialog_failed , CONNECT_ONE_SHOT )
112+ vic2_dir_dialog .dir_selected .connect (_on_vic2_dir_dialog_dir_selected )
113+ while not _selected_base_path :
114+ vic2_dir_dialog .popup_centered_ratio ()
115+ await vic2_dir_dialog .dir_selected
116+ actual_base_path = _selected_base_path
108117 get_tree ().paused = false
109- actual_base_path = GameSingleton .search_for_game_path (vic2_dir_dialog .current_path )
110- if not actual_base_path :
111- failure_func .call ()
112- return
113118
114119 if not _settings_base_path :
115- _vic2_settings .set_value (section_name , setting_name , actual_base_path )
120+ _settings_base_path = actual_base_path
121+ _vic2_settings .set_value (section_name , setting_name , _settings_base_path )
116122 _vic2_settings .emit_changed ()
117123
118124 # Add mod paths
@@ -154,6 +160,9 @@ func setup_title_theme() -> void:
154160# REQUIREMENTS
155161# * FS-333, FS-334, FS-335, FS-341
156162func _initialize_game () -> void :
163+ if not _settings_base_path :
164+ return
165+
157166 var start := Time .get_ticks_usec ()
158167 loading_screen .try_update_loading_screen (0 )
159168 GameSingleton .setup_logger ()
0 commit comments