diff --git a/core/os/os.cpp b/core/os/os.cpp index 385d1f44801..e2b6fb72fb0 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -254,7 +254,7 @@ String OS::get_safe_dir_name(const String &p_dir_name, bool p_allow_paths) const if (p_allow_paths) { // Dir separators are allowed, but disallow ".." to avoid going up the filesystem invalid_chars.push_back(".."); - safe_dir_name = safe_dir_name.replace("\\", "/").strip_edges(); + safe_dir_name = safe_dir_name.replace("\\", "/").replace("//", "/").strip_edges(); } else { invalid_chars.push_back("/"); invalid_chars.push_back("\\"); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 6e2789f559a..ba16a6c1fb5 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -5702,6 +5702,30 @@ bool EditorNode::ensure_main_scene(bool p_from_native) { return false; } + if (!EditorNode::validate_custom_directory()) { + current_menu_option = -1; + return false; + } + + return true; +} + +bool EditorNode::validate_custom_directory() { + bool use_custom_dir = GLOBAL_GET("application/config/use_custom_user_dir"); + + if (use_custom_dir) { + String data_dir = OS::get_singleton()->get_user_data_dir(); + Ref dir = DirAccess::create(DirAccess::ACCESS_USERDATA); + if (dir->change_dir(data_dir) != OK) { + dir->make_dir_recursive(data_dir); + if (dir->change_dir(data_dir) != OK) { + open_project_settings->set_text(vformat(TTR("User data dir '%s' is not valid. Change to a valid one?"), data_dir)); + open_project_settings->popup_centered(); + return false; + } + } + } + return true; } @@ -8262,6 +8286,11 @@ EditorNode::EditorNode() { select_current_scene_button = pick_main_scene->add_button(TTR("Select Current"), true, "select_current"); pick_main_scene->connect("custom_action", callable_mp(this, &EditorNode::_pick_main_scene_custom_action)); + open_project_settings = memnew(ConfirmationDialog); + gui_base->add_child(open_project_settings); + open_project_settings->set_ok_button_text(TTRC("Open Project Settings")); + open_project_settings->connect(SceneStringName(confirmed), callable_mp(this, &EditorNode::_menu_option).bind(PROJECT_OPEN_SETTINGS)); + for (int i = 0; i < _init_callbacks.size(); i++) { _init_callbacks[i](); } diff --git a/editor/editor_node.h b/editor/editor_node.h index 4c9a51eef8c..fd9d01f4d9b 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -356,6 +356,7 @@ private: ConfirmationDialog *save_confirmation = nullptr; ConfirmationDialog *import_confirmation = nullptr; ConfirmationDialog *pick_main_scene = nullptr; + ConfirmationDialog *open_project_settings = nullptr; Button *select_current_scene_button = nullptr; AcceptDialog *accept = nullptr; AcceptDialog *save_accept = nullptr; @@ -962,6 +963,7 @@ public: Vector> find_resource_conversion_plugin_for_type_name(const String &p_type); bool ensure_main_scene(bool p_from_native); + bool validate_custom_directory(); }; class EditorPluginList : public Object {