diff options
author | Marcelo Fernandez <marcelofg55@gmail.com> | 2018-11-12 16:04:58 -0300 |
---|---|---|
committer | Marcelo Fernandez <marcelofg55@gmail.com> | 2018-11-12 16:04:58 -0300 |
commit | e49a090919fbebb6bc9098ae2b366a5a858d3293 (patch) | |
tree | 3e0abca79d5041343d2e49f31fcae4fb7139fd9c | |
parent | a2e4eb7533480ee27ceac5998ed2db5d1ee6a2a1 (diff) |
Export Path now has a folder icon to select the path
-rw-r--r-- | editor/editor_properties.cpp | 8 | ||||
-rw-r--r-- | editor/editor_properties.h | 2 | ||||
-rw-r--r-- | editor/project_export.cpp | 47 | ||||
-rw-r--r-- | editor/project_export.h | 8 |
4 files changed, 53 insertions, 12 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index b68ec97406..8eeb949d48 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -233,7 +233,7 @@ void EditorPropertyPath::_path_pressed() { dialog->set_mode(EditorFileDialog::MODE_OPEN_DIR); dialog->set_current_dir(full_path); } else { - dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); + dialog->set_mode(save_mode ? EditorFileDialog::MODE_SAVE_FILE : EditorFileDialog::MODE_OPEN_FILE); for (int i = 0; i < extensions.size(); i++) { String e = extensions[i].strip_edges(); if (e != String()) { @@ -260,6 +260,11 @@ void EditorPropertyPath::setup(const Vector<String> &p_extensions, bool p_folder global = p_global; } +void EditorPropertyPath::set_save_mode() { + + save_mode = true; +} + void EditorPropertyPath::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { @@ -296,6 +301,7 @@ EditorPropertyPath::EditorPropertyPath() { path_edit->connect("pressed", this, "_path_pressed"); folder = false; global = false; + save_mode = false; } ///////////////////// CLASS NAME ///////////////////////// diff --git a/editor/editor_properties.h b/editor/editor_properties.h index 35d8f4d306..cf90323325 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -106,6 +106,7 @@ class EditorPropertyPath : public EditorProperty { Vector<String> extensions; bool folder; bool global; + bool save_mode; EditorFileDialog *dialog; LineEdit *path; Button *path_edit; @@ -120,6 +121,7 @@ protected: public: void setup(const Vector<String> &p_extensions, bool p_folder, bool p_global); + void set_save_mode(); virtual void update_property(); EditorPropertyPath(); }; diff --git a/editor/project_export.cpp b/editor/project_export.cpp index f8ba6fd4e3..30dd99bc17 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -191,7 +191,7 @@ void ProjectExportDialog::_edit_preset(int p_index) { if (p_index < 0 || p_index >= presets->get_item_count()) { name->set_text(""); name->set_editable(false); - export_path->set_editable(false); + export_path->hide(); runnable->set_disabled(true); parameters->edit(NULL); presets->unselect_all(); @@ -213,11 +213,19 @@ void ProjectExportDialog::_edit_preset(int p_index) { sections->show(); name->set_editable(true); - export_path->set_editable(true); + export_path->show(); duplicate_preset->set_disabled(false); delete_preset->set_disabled(false); name->set_text(current->get_name()); - export_path->set_text(current->get_export_path()); + + List<String> extension_list = current->get_platform()->get_binary_extensions(current); + Vector<String> extension_vector; + for (int i = 0; i < extension_list.size(); i++) { + extension_vector.push_back("*." + extension_list[i]); + } + + export_path->setup(extension_vector, false, true); + export_path->update_property(); runnable->set_disabled(false); runnable->set_pressed(current->is_runnable()); parameters->edit(current.ptr()); @@ -457,7 +465,21 @@ void ProjectExportDialog::_name_changed(const String &p_string) { _update_presets(); } -void ProjectExportDialog::_export_path_changed(const String &p_string) { +void ProjectExportDialog::set_export_path(const String &p_value) { + Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current()); + ERR_FAIL_COND(current.is_null()); + + current->set_export_path(p_value); +} + +String ProjectExportDialog::get_export_path() { + Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current()); + ERR_FAIL_COND_V(current.is_null(), String("")); + + return current->get_export_path(); +} + +void ProjectExportDialog::_export_path_changed(const StringName &p_property, const Variant &p_value) { if (updating) return; @@ -465,7 +487,7 @@ void ProjectExportDialog::_export_path_changed(const String &p_string) { Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current()); ERR_FAIL_COND(current.is_null()); - current->set_export_path(p_string); + current->set_export_path(p_value); _update_presets(); } @@ -954,6 +976,10 @@ void ProjectExportDialog::_bind_methods() { ClassDB::bind_method("_export_all_dialog_action", &ProjectExportDialog::_export_all_dialog_action); ClassDB::bind_method("_custom_features_changed", &ProjectExportDialog::_custom_features_changed); ClassDB::bind_method("_tab_changed", &ProjectExportDialog::_tab_changed); + ClassDB::bind_method("set_export_path", &ProjectExportDialog::set_export_path); + ClassDB::bind_method("get_export_path", &ProjectExportDialog::get_export_path); + + ADD_PROPERTY(PropertyInfo(Variant::STRING, "export_path"), "set_export_path", "get_export_path"); } ProjectExportDialog::ProjectExportDialog() { @@ -1006,9 +1032,12 @@ ProjectExportDialog::ProjectExportDialog() { runnable->connect("pressed", this, "_runnable_pressed"); settings_vb->add_child(runnable); - export_path = memnew(LineEdit); - settings_vb->add_margin_child(TTR("Export Path:"), export_path); - export_path->connect("text_changed", this, "_export_path_changed"); + export_path = memnew(EditorPropertyPath); + settings_vb->add_child(export_path); + export_path->set_label(TTR("Export Path")); + export_path->set_object_and_property(this, "export_path"); + export_path->set_save_mode(); + export_path->connect("property_changed", this, "_export_path_changed"); sections = memnew(TabContainer); sections->set_tab_align(TabContainer::ALIGN_LEFT); @@ -1100,7 +1129,7 @@ ProjectExportDialog::ProjectExportDialog() { //disable by default name->set_editable(false); - export_path->set_editable(false); + export_path->hide(); runnable->set_disabled(true); duplicate_preset->set_disabled(true); delete_preset->set_disabled(true); diff --git a/editor/project_export.h b/editor/project_export.h index 7009968138..b43dd9a392 100644 --- a/editor/project_export.h +++ b/editor/project_export.h @@ -37,6 +37,7 @@ #include "editor/editor_file_dialog.h" #include "editor/editor_file_system.h" #include "editor/editor_inspector.h" +#include "editor/editor_properties.h" #include "scene/gui/button.h" #include "scene/gui/check_button.h" #include "scene/gui/control.h" @@ -66,7 +67,7 @@ private: ItemList *presets; LineEdit *name; - LineEdit *export_path; + EditorPropertyPath *export_path; EditorInspector *parameters; CheckButton *runnable; @@ -110,7 +111,7 @@ private: void _runnable_pressed(); void _update_parameters(const String &p_edited_property); void _name_changed(const String &p_string); - void _export_path_changed(const String &p_string); + void _export_path_changed(const StringName &p_property, const Variant &p_value); void _add_preset(int p_platform); void _edit_preset(int p_index); void _duplicate_preset(); @@ -162,6 +163,9 @@ protected: public: void popup_export(); + void set_export_path(const String &p_value); + String get_export_path(); + ProjectExportDialog(); ~ProjectExportDialog(); }; |