summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSonerSound <mario.shadic.esteves@hotmail.com>2019-04-29 22:27:07 +0100
committerSonerSound <mario.shadic.esteves@hotmail.com>2019-06-30 19:13:49 +0100
commit90b2415343287f67586956c798d4b7a63544158f (patch)
treeba9e9d198d1922f1879d446a4a256675a31827a9
parent96d3270c344c7fe9a463b87006b0c56004128f6d (diff)
Export path may now be written as a relative path
If the target directory does not exist, it will be recursively created. Export paths are now saved as a relative to the projects base directory Renamed relative_to function to final_path_from_relative which takes a relative path and outputs the final path from a string that represents a directory. Added relative_path_from_final which takes in a final path and outputs a relative path if possible. If not possible it outputs the relative path that represents the current directory. If the target directory does not exist when exporting the project, then it is recursively created. Removed final_path_from_relative function Changed DirAccess into DirAccessRef for automatic object destruction
-rw-r--r--editor/editor_properties.cpp15
-rw-r--r--editor/project_export.cpp13
2 files changed, 25 insertions, 3 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 659893a1b6..a8ef563368 100644
--- a/editor/editor_properties.cpp
+++ b/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();
diff --git a/editor/project_export.cpp b/editor/project_export.cpp
index 956da92c35..c78a81dbe0 100644
--- a/editor/project_export.cpp
+++ b/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]);