summaryrefslogtreecommitdiff
path: root/editor/project_export.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/project_export.cpp')
-rw-r--r--editor/project_export.cpp186
1 files changed, 84 insertions, 102 deletions
diff --git a/editor/project_export.cpp b/editor/project_export.cpp
index 04ec5ae043..32a1cf2fa1 100644
--- a/editor/project_export.cpp
+++ b/editor/project_export.cpp
@@ -52,11 +52,12 @@ void ProjectExportDialog::_theme_changed() {
duplicate_preset->set_icon(presets->get_theme_icon("Duplicate", "EditorIcons"));
delete_preset->set_icon(presets->get_theme_icon("Remove", "EditorIcons"));
Control *panel = custom_feature_display->get_parent_control();
- if (panel)
+ if (panel) {
panel->add_theme_style_override("panel", patches->get_theme_stylebox("bg", "Tree"));
+ }
}
-void ProjectExportDialog::_notification(int p_what) {
+void ProjectExportDialog::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_VISIBILITY_CHANGED: {
if (!is_visible()) {
@@ -73,10 +74,8 @@ void ProjectExportDialog::_notification(int p_what) {
}
void ProjectExportDialog::popup_export() {
-
add_preset->get_popup()->clear();
for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) {
-
Ref<EditorExportPlatform> plat = EditorExport::get_singleton()->get_export_platform(i);
add_preset->get_popup()->add_icon_item(plat->get_logo(), plat->get_name());
@@ -97,7 +96,6 @@ void ProjectExportDialog::popup_export() {
}
void ProjectExportDialog::_add_preset(int p_platform) {
-
Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_platform(p_platform)->create_preset();
ERR_FAIL_COND(!preset.is_valid());
@@ -105,7 +103,6 @@ void ProjectExportDialog::_add_preset(int p_platform) {
bool make_runnable = true;
int attempt = 1;
while (true) {
-
bool valid = true;
for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
@@ -119,33 +116,34 @@ void ProjectExportDialog::_add_preset(int p_platform) {
}
}
- if (valid)
+ if (valid) {
break;
+ }
attempt++;
name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name() + " " + itos(attempt);
}
preset->set_name(name);
- if (make_runnable)
+ if (make_runnable) {
preset->set_runnable(make_runnable);
+ }
EditorExport::get_singleton()->add_export_preset(preset);
_update_presets();
_edit_preset(EditorExport::get_singleton()->get_export_preset_count() - 1);
}
void ProjectExportDialog::_update_current_preset() {
-
_edit_preset(presets->get_current());
}
void ProjectExportDialog::_update_presets() {
-
updating = true;
Ref<EditorExportPreset> current;
- if (presets->get_current() >= 0 && presets->get_current() < presets->get_item_count())
+ if (presets->get_current() >= 0 && presets->get_current() < presets->get_item_count()) {
current = get_current_preset();
+ }
int current_idx = -1;
presets->clear();
@@ -156,8 +154,9 @@ void ProjectExportDialog::_update_presets() {
}
String name = preset->get_name();
- if (preset->is_runnable())
+ if (preset->is_runnable()) {
name += " (" + TTR("Runnable") + ")";
+ }
presets->add_item(name, preset->get_platform()->get_logo());
}
@@ -169,7 +168,6 @@ void ProjectExportDialog::_update_presets() {
}
void ProjectExportDialog::_update_export_all() {
-
bool can_export = EditorExport::get_singleton()->get_export_preset_count() > 0;
for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
@@ -190,7 +188,6 @@ void ProjectExportDialog::_update_export_all() {
}
void ProjectExportDialog::_edit_preset(int p_index) {
-
if (p_index < 0 || p_index >= presets->get_item_count()) {
name->set_text("");
name->set_editable(false);
@@ -246,8 +243,9 @@ void ProjectExportDialog::_edit_preset(int p_index) {
String file = patchlist[i].get_file();
patch->set_editable(0, true);
patch->set_text(0, file.get_file().replace("*", ""));
- if (file.ends_with("*"))
+ if (file.ends_with("*")) {
patch->set_checked(0, true);
+ }
patch->set_tooltip(0, patchlist[i]);
patch->set_metadata(0, i);
patch->add_button(0, presets->get_theme_icon("Remove", "EditorIcons"), 0);
@@ -256,10 +254,11 @@ void ProjectExportDialog::_edit_preset(int p_index) {
TreeItem *patch_add = patches->create_item(patch_root);
patch_add->set_metadata(0, patchlist.size());
- if (patchlist.size() == 0)
+ if (patchlist.size() == 0) {
patch_add->set_text(0, TTR("Add initial export..."));
- else
+ } else {
patch_add->set_text(0, TTR("Add previous patches..."));
+ }
patch_add->add_button(0, presets->get_theme_icon("folder", "FileDialog"), 1);
@@ -268,14 +267,13 @@ void ProjectExportDialog::_edit_preset(int p_index) {
bool needs_templates;
String error;
if (!current->get_platform()->can_export(current, error, needs_templates)) {
-
if (error != String()) {
-
Vector<String> items = error.split("\n", false);
error = "";
for (int i = 0; i < items.size(); i++) {
- if (i > 0)
+ if (i > 0) {
error += "\n";
+ }
error += " - " + items[i];
}
@@ -284,10 +282,11 @@ void ProjectExportDialog::_edit_preset(int p_index) {
} else {
export_error->hide();
}
- if (needs_templates)
+ if (needs_templates) {
export_templates_error->show();
- else
+ } else {
export_templates_error->hide();
+ }
export_button->set_disabled(true);
get_ok()->set_disabled(true);
@@ -329,7 +328,6 @@ void ProjectExportDialog::_edit_preset(int p_index) {
}
void ProjectExportDialog::_update_feature_list() {
-
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
@@ -363,9 +361,9 @@ void ProjectExportDialog::_update_feature_list() {
}
void ProjectExportDialog::_custom_features_changed(const String &p_text) {
-
- if (updating)
+ if (updating) {
return;
+ }
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
@@ -379,7 +377,6 @@ void ProjectExportDialog::_tab_changed(int) {
}
void ProjectExportDialog::_patch_button_pressed(Object *p_item, int p_column, int p_id) {
-
TreeItem *ti = (TreeItem *)p_item;
patch_index = ti->get_metadata(0);
@@ -398,10 +395,10 @@ void ProjectExportDialog::_patch_button_pressed(Object *p_item, int p_column, in
}
void ProjectExportDialog::_patch_edited() {
-
TreeItem *item = patches->get_edited();
- if (!item)
+ if (!item) {
return;
+ }
int index = item->get_metadata(0);
Ref<EditorExportPreset> current = get_current_preset();
@@ -421,14 +418,12 @@ void ProjectExportDialog::_patch_edited() {
}
void ProjectExportDialog::_patch_selected(const String &p_path) {
-
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
Vector<String> patches = current->get_patches();
if (patch_index >= patches.size()) {
-
current->add_patch(ProjectSettings::get_singleton()->get_resource_path().path_to(p_path) + "*");
} else {
String enabled = patches[patch_index].ends_with("*") ? String("*") : String();
@@ -439,33 +434,29 @@ void ProjectExportDialog::_patch_selected(const String &p_path) {
}
void ProjectExportDialog::_patch_deleted() {
-
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
Vector<String> patches = current->get_patches();
if (patch_index < patches.size()) {
-
current->remove_patch(patch_index);
_update_current_preset();
}
}
void ProjectExportDialog::_update_parameters(const String &p_edited_property) {
-
_update_current_preset();
}
void ProjectExportDialog::_runnable_pressed() {
-
- if (updating)
+ if (updating) {
return;
+ }
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
if (runnable->is_pressed()) {
-
for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
Ref<EditorExportPreset> p = EditorExport::get_singleton()->get_export_preset(i);
if (p->get_platform() == current->get_platform()) {
@@ -473,7 +464,6 @@ void ProjectExportDialog::_runnable_pressed() {
}
}
} else {
-
current->set_runnable(false);
}
@@ -481,9 +471,9 @@ void ProjectExportDialog::_runnable_pressed() {
}
void ProjectExportDialog::_name_changed(const String &p_string) {
-
- if (updating)
+ if (updating) {
return;
+ }
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
@@ -507,14 +497,13 @@ String ProjectExportDialog::get_export_path() {
}
Ref<EditorExportPreset> ProjectExportDialog::get_current_preset() const {
-
return EditorExport::get_singleton()->get_export_preset(presets->get_current());
}
void ProjectExportDialog::_export_path_changed(const StringName &p_property, const Variant &p_value, const String &p_field, bool p_changing) {
-
- if (updating)
+ if (updating) {
return;
+ }
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
@@ -524,9 +513,9 @@ void ProjectExportDialog::_export_path_changed(const StringName &p_property, con
}
void ProjectExportDialog::_script_export_mode_changed(int p_mode) {
-
- if (updating)
+ if (updating) {
return;
+ }
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
@@ -537,9 +526,9 @@ void ProjectExportDialog::_script_export_mode_changed(int p_mode) {
}
void ProjectExportDialog::_script_encryption_key_changed(const String &p_key) {
-
- if (updating)
+ if (updating) {
return;
+ }
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
@@ -552,7 +541,6 @@ void ProjectExportDialog::_script_encryption_key_changed(const String &p_key) {
}
bool ProjectExportDialog::_validate_script_encryption_key(const String &p_key) {
-
bool is_valid = false;
if (!p_key.empty() && p_key.is_valid_hex_number(false) && p_key.length() == 64) {
@@ -562,10 +550,10 @@ bool ProjectExportDialog::_validate_script_encryption_key(const String &p_key) {
}
void ProjectExportDialog::_duplicate_preset() {
-
Ref<EditorExportPreset> current = get_current_preset();
- if (current.is_null())
+ if (current.is_null()) {
return;
+ }
Ref<EditorExportPreset> preset = current->get_platform()->create_preset();
ERR_FAIL_COND(!preset.is_valid());
@@ -573,7 +561,6 @@ void ProjectExportDialog::_duplicate_preset() {
String name = current->get_name() + " (copy)";
bool make_runnable = true;
while (true) {
-
bool valid = true;
for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
@@ -587,15 +574,17 @@ void ProjectExportDialog::_duplicate_preset() {
}
}
- if (valid)
+ if (valid) {
break;
+ }
name += " (copy)";
}
preset->set_name(name);
- if (make_runnable)
+ if (make_runnable) {
preset->set_runnable(make_runnable);
+ }
preset->set_export_filter(current->get_export_filter());
preset->set_include_filter(current->get_include_filter());
preset->set_exclude_filter(current->get_exclude_filter());
@@ -615,17 +604,16 @@ void ProjectExportDialog::_duplicate_preset() {
}
void ProjectExportDialog::_delete_preset() {
-
Ref<EditorExportPreset> current = get_current_preset();
- if (current.is_null())
+ if (current.is_null()) {
return;
+ }
delete_confirm->set_text(vformat(TTR("Delete preset '%s'?"), current->get_name()));
delete_confirm->popup_centered();
}
void ProjectExportDialog::_delete_preset_confirm() {
-
int idx = presets->get_current();
_edit_preset(-1);
export_button->set_disabled(true);
@@ -635,7 +623,6 @@ void ProjectExportDialog::_delete_preset_confirm() {
}
Variant ProjectExportDialog::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
-
if (p_from == presets) {
int pos = presets->get_item_at_position(p_point, true);
@@ -657,11 +644,9 @@ Variant ProjectExportDialog::get_drag_data_fw(const Point2 &p_point, Control *p_
return d;
}
} else if (p_from == patches) {
-
TreeItem *item = patches->get_item_at_position(p_point);
if (item && item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK) {
-
int metadata = item->get_metadata(0);
Dictionary d;
d["type"] = "export_patch";
@@ -679,26 +664,26 @@ Variant ProjectExportDialog::get_drag_data_fw(const Point2 &p_point, Control *p_
}
bool ProjectExportDialog::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
-
if (p_from == presets) {
Dictionary d = p_data;
- if (!d.has("type") || String(d["type"]) != "export_preset")
+ if (!d.has("type") || String(d["type"]) != "export_preset") {
return false;
+ }
- if (presets->get_item_at_position(p_point, true) < 0 && !presets->is_pos_at_end_of_items(p_point))
+ if (presets->get_item_at_position(p_point, true) < 0 && !presets->is_pos_at_end_of_items(p_point)) {
return false;
+ }
} else if (p_from == patches) {
-
Dictionary d = p_data;
- if (!d.has("type") || String(d["type"]) != "export_patch")
+ if (!d.has("type") || String(d["type"]) != "export_patch") {
return false;
+ }
patches->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM);
TreeItem *item = patches->get_item_at_position(p_point);
if (!item) {
-
return false;
}
}
@@ -707,7 +692,6 @@ bool ProjectExportDialog::can_drop_data_fw(const Point2 &p_point, const Variant
}
void ProjectExportDialog::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
-
if (p_from == presets) {
Dictionary d = p_data;
int from_pos = d["preset"];
@@ -718,12 +702,13 @@ void ProjectExportDialog::drop_data_fw(const Point2 &p_point, const Variant &p_d
to_pos = presets->get_item_at_position(p_point, true);
}
- if (to_pos == -1 && !presets->is_pos_at_end_of_items(p_point))
+ if (to_pos == -1 && !presets->is_pos_at_end_of_items(p_point)) {
return;
+ }
- if (to_pos == from_pos)
+ if (to_pos == from_pos) {
return;
- else if (to_pos > from_pos) {
+ } else if (to_pos > from_pos) {
to_pos--;
}
@@ -732,27 +717,29 @@ void ProjectExportDialog::drop_data_fw(const Point2 &p_point, const Variant &p_d
EditorExport::get_singleton()->add_export_preset(preset, to_pos);
_update_presets();
- if (to_pos >= 0)
+ if (to_pos >= 0) {
_edit_preset(to_pos);
- else
+ } else {
_edit_preset(presets->get_item_count() - 1);
+ }
} else if (p_from == patches) {
-
Dictionary d = p_data;
- if (!d.has("type") || String(d["type"]) != "export_patch")
+ if (!d.has("type") || String(d["type"]) != "export_patch") {
return;
+ }
int from_pos = d["patch"];
TreeItem *item = patches->get_item_at_position(p_point);
- if (!item)
+ if (!item) {
return;
+ }
int to_pos = item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK ? int(item->get_metadata(0)) : -1;
- if (to_pos == from_pos)
+ if (to_pos == from_pos) {
return;
- else if (to_pos > from_pos) {
+ } else if (to_pos > from_pos) {
to_pos--;
}
@@ -766,13 +753,14 @@ void ProjectExportDialog::drop_data_fw(const Point2 &p_point, const Variant &p_d
}
void ProjectExportDialog::_export_type_changed(int p_which) {
-
- if (updating)
+ if (updating) {
return;
+ }
Ref<EditorExportPreset> current = get_current_preset();
- if (current.is_null())
+ if (current.is_null()) {
return;
+ }
current->set_export_filter(EditorExportPreset::ExportFilter(p_which));
updating = true;
@@ -781,27 +769,28 @@ void ProjectExportDialog::_export_type_changed(int p_which) {
}
void ProjectExportDialog::_filter_changed(const String &p_filter) {
-
- if (updating)
+ if (updating) {
return;
+ }
Ref<EditorExportPreset> current = get_current_preset();
- if (current.is_null())
+ if (current.is_null()) {
return;
+ }
current->set_include_filter(include_filters->get_text());
current->set_exclude_filter(exclude_filters->get_text());
}
void ProjectExportDialog::_fill_resource_tree() {
-
include_files->clear();
include_label->hide();
include_margin->hide();
Ref<EditorExportPreset> current = get_current_preset();
- if (current.is_null())
+ if (current.is_null()) {
return;
+ }
EditorExportPreset::ExportFilter f = current->get_export_filter();
@@ -818,13 +807,11 @@ void ProjectExportDialog::_fill_resource_tree() {
}
bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir, TreeItem *p_item, Ref<EditorExportPreset> &current, bool p_only_scenes) {
-
p_item->set_icon(0, presets->get_theme_icon("folder", "FileDialog"));
p_item->set_text(0, p_dir->get_name() + "/");
bool used = false;
for (int i = 0; i < p_dir->get_subdir_count(); i++) {
-
TreeItem *subdir = include_files->create_item(p_item);
if (_fill_tree(p_dir->get_subdir(i), subdir, current, p_only_scenes)) {
used = true;
@@ -834,10 +821,10 @@ bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir, TreeItem
}
for (int i = 0; i < p_dir->get_file_count(); i++) {
-
String type = p_dir->get_file_type(i);
- if (p_only_scenes && type != "PackedScene")
+ if (p_only_scenes && type != "PackedScene") {
continue;
+ }
TreeItem *file = include_files->create_item(p_item);
file->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
@@ -857,17 +844,19 @@ bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir, TreeItem
}
void ProjectExportDialog::_tree_changed() {
-
- if (updating)
+ if (updating) {
return;
+ }
Ref<EditorExportPreset> current = get_current_preset();
- if (current.is_null())
+ if (current.is_null()) {
return;
+ }
TreeItem *item = include_files->get_edited();
- if (!item)
+ if (!item) {
return;
+ }
String path = item->get_metadata(0);
bool added = item->is_checked(0);
@@ -880,12 +869,10 @@ void ProjectExportDialog::_tree_changed() {
}
void ProjectExportDialog::_export_pck_zip() {
-
export_pck_zip->popup_centered_ratio();
}
void ProjectExportDialog::_export_pck_zip_selected(const String &p_path) {
-
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
Ref<EditorExportPlatform> platform = current->get_platform();
@@ -899,7 +886,6 @@ void ProjectExportDialog::_export_pck_zip_selected(const String &p_path) {
}
void ProjectExportDialog::_open_export_template_manager() {
-
EditorNode::get_singleton()->open_export_template_manager();
hide();
}
@@ -909,10 +895,12 @@ void ProjectExportDialog::_validate_export_path(const String &p_path) {
bool invalid_path = (p_path.get_file().get_basename() == "");
// Check if state change before needlessly messing with signals
- if (invalid_path && export_project->get_ok()->is_disabled())
+ if (invalid_path && export_project->get_ok()->is_disabled()) {
return;
- if (!invalid_path && !export_project->get_ok()->is_disabled())
+ }
+ if (!invalid_path && !export_project->get_ok()->is_disabled()) {
return;
+ }
if (invalid_path) {
export_project->get_ok()->set_disabled(true);
@@ -924,7 +912,6 @@ void ProjectExportDialog::_validate_export_path(const String &p_path) {
}
void ProjectExportDialog::_export_project() {
-
Ref<EditorExportPreset> current = get_current_preset();
ERR_FAIL_COND(current.is_null());
Ref<EditorExportPlatform> platform = current->get_platform();
@@ -987,20 +974,17 @@ void ProjectExportDialog::_export_project_to_path(const String &p_path) {
}
void ProjectExportDialog::_export_all_dialog() {
-
export_all_dialog->show();
export_all_dialog->popup_centered(Size2(300, 80));
}
void ProjectExportDialog::_export_all_dialog_action(const String &p_str) {
-
export_all_dialog->hide();
_export_all(p_str != "release");
}
void ProjectExportDialog::_export_all(bool p_debug) {
-
String mode = p_debug ? TTR("Debug") : TTR("Release");
EditorProgress ep("exportall", TTR("Exporting All") + " " + mode, EditorExport::get_singleton()->get_export_preset_count(), true);
@@ -1027,7 +1011,6 @@ void ProjectExportDialog::_export_all(bool p_debug) {
}
void ProjectExportDialog::_bind_methods() {
-
ClassDB::bind_method("get_drag_data_fw", &ProjectExportDialog::get_drag_data_fw);
ClassDB::bind_method("can_drop_data_fw", &ProjectExportDialog::can_drop_data_fw);
ClassDB::bind_method("drop_data_fw", &ProjectExportDialog::drop_data_fw);
@@ -1040,7 +1023,6 @@ void ProjectExportDialog::_bind_methods() {
}
ProjectExportDialog::ProjectExportDialog() {
-
set_title(TTR("Export"));
VBoxContainer *main_vb = memnew(VBoxContainer);