Parcourir la source

Merge pull request #28701 from SonerSound/master

Export paths are now saved as relative paths
Rémi Verschelde il y a 6 ans
Parent
commit
bbb725836d
2 fichiers modifiés avec 25 ajouts et 3 suppressions
  1. 14 1
      editor/editor_properties.cpp
  2. 11 2
      editor/project_export.cpp

+ 14 - 1
editor/editor_properties.cpp

@@ -208,7 +208,13 @@ EditorPropertyTextEnum::EditorPropertyTextEnum() {
 
 void EditorPropertyPath::_path_selected(const String &p_path) {
 
-	emit_changed(get_edited_property(), p_path);
+	String final_path = p_path;
+	if (final_path.is_abs_path()) {
+		String res_path = OS::get_singleton()->get_resource_dir() + "/";
+		final_path = res_path.path_to_file(final_path);
+	}
+
+	emit_changed(get_edited_property(), final_path);
 	update_property();
 }
 void EditorPropertyPath::_path_pressed() {
@@ -221,6 +227,13 @@ void EditorPropertyPath::_path_pressed() {
 	}
 
 	String full_path = get_edited_object()->get(get_edited_property());
+	if (full_path.is_rel_path()) {
+
+		if (!DirAccess::exists(full_path.get_base_dir())) {
+			DirAccessRef da(DirAccess::create(DirAccess::ACCESS_FILESYSTEM));
+			da->make_dir_recursive(full_path.get_base_dir());
+		}
+	}
 
 	dialog->clear_filters();
 

+ 11 - 2
editor/project_export.cpp

@@ -931,8 +931,17 @@ void ProjectExportDialog::_export_project() {
 		export_project->add_filter("*." + extension_list[i] + " ; " + platform->get_name() + " Export");
 	}
 
-	if (current->get_export_path() != "") {
-		export_project->set_current_path(current->get_export_path());
+	String current_preset_export_path = current->get_export_path();
+
+	if (current_preset_export_path != "") {
+
+		if (!DirAccess::exists(current_preset_export_path.get_base_dir())) {
+
+			DirAccessRef da(DirAccess::create(DirAccess::ACCESS_FILESYSTEM));
+			da->make_dir_recursive(current_preset_export_path.get_base_dir());
+		}
+
+		export_project->set_current_path(current_preset_export_path);
 	} else {
 		if (extension_list.size() >= 1) {
 			export_project->set_current_file(default_filename + "." + extension_list[0]);