diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp index 069d7cef810..c678e4a6b0d 100644 --- a/tools/editor/project_manager.cpp +++ b/tools/editor/project_manager.cpp @@ -75,15 +75,22 @@ private: String zip_title; AcceptDialog *dialog_error; - bool _test_path() { + String _test_path() { error->set_text(""); get_ok()->set_disabled(true); DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - if (project_path->get_text() != "" && d->change_dir(project_path->get_text())!=OK) { + String valid_path; + if (d->change_dir(project_path->get_text())==OK){ + valid_path=project_path->get_text(); + } else if (d->change_dir(project_path->get_text().strip_edges())==OK) { + valid_path=project_path->get_text().strip_edges(); + } + + if (valid_path == "") { error->set_text(TTR("Invalid project path, the path must exist!")); memdelete(d); - return false; + return ""; } if (mode!=MODE_IMPORT) { @@ -92,30 +99,29 @@ private: error->set_text(TTR("Invalid project path, engine.cfg must not exist.")); memdelete(d); - return false; + return ""; } } else { - if (project_path->get_text() != "" && !d->file_exists("engine.cfg")) { + if (valid_path != "" && !d->file_exists("engine.cfg")) { error->set_text(TTR("Invalid project path, engine.cfg must exist.")); memdelete(d); - return false; + return ""; } } memdelete(d); get_ok()->set_disabled(false); - return true; + return valid_path; } void _path_text_changed(const String& p_path) { - if ( _test_path() ) { - - String sp=p_path; + String sp=_test_path(); + if ( sp!="" ) { sp=sp.replace("\\","/"); int lidx=sp.find_last("/"); @@ -173,27 +179,15 @@ private: void ok_pressed() { - if (!_test_path()) + String dir=_test_path(); + if (dir=="") { + error->set_text(TTR("Invalid project path (changed anything?).")); return; - - String dir; + } if (mode==MODE_IMPORT) { - dir=project_path->get_text(); - - + // nothing to do } else { - DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - - if (d->change_dir(project_path->get_text())!=OK) { - error->set_text(TTR("Invalid project path (changed anything?).")); - memdelete(d); - return; - } - - dir=d->get_current_dir(); - memdelete(d); - if (mode==MODE_NEW) { @@ -321,8 +315,6 @@ private: } - - } dir=dir.replace("\\","/"); @@ -402,7 +394,7 @@ public: popup_centered(Size2(500,125)*EDSCALE); } - + project_path->grab_focus(); _test_path(); }