Merge pull request #23673 from marcelofg55/export_path_3

Export Path now has a folder icon to select the path
This commit is contained in:
Rémi Verschelde 2018-12-06 15:33:04 +01:00 committed by GitHub
commit a0a9553cbe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 12 deletions

View file

@ -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 /////////////////////////

View file

@ -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();
};

View file

@ -192,7 +192,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();
@ -214,11 +214,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());
@ -458,7 +466,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;
@ -466,7 +488,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();
}
@ -955,6 +977,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() {
@ -1007,9 +1033,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);
@ -1101,7 +1130,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);

View file

@ -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();
};