2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* project_export.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* http://www.godotengine.org */
|
|
|
|
/*************************************************************************/
|
2017-01-01 22:01:57 +01:00
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2017-04-08 00:11:42 +02:00
|
|
|
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
|
2014-02-10 02:10:30 +01:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
|
|
|
#include "project_export.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "compressed_translation.h"
|
|
|
|
#include "editor_data.h"
|
|
|
|
#include "editor_node.h"
|
|
|
|
#include "editor_settings.h"
|
|
|
|
#include "io/image_loader.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "io/resource_loader.h"
|
|
|
|
#include "io/resource_saver.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "io_plugins/editor_texture_import_plugin.h"
|
|
|
|
#include "os/dir_access.h"
|
|
|
|
#include "os/file_access.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "os/os.h"
|
2017-07-30 22:53:40 +02:00
|
|
|
#include "project_settings.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "scene/gui/box_container.h"
|
2017-02-20 03:19:30 +01:00
|
|
|
#include "scene/gui/margin_container.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "scene/gui/scroll_container.h"
|
|
|
|
#include "scene/gui/tab_container.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
void ProjectExportDialog::_notification(int p_what) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-02 22:43:56 +01:00
|
|
|
switch (p_what) {
|
|
|
|
case NOTIFICATION_READY: {
|
2017-03-05 16:44:50 +01:00
|
|
|
delete_preset->set_icon(get_icon("Del", "EditorIcons"));
|
|
|
|
connect("confirmed", this, "_export_pck_zip");
|
2017-07-19 22:00:46 +02:00
|
|
|
custom_feature_display->get_parent_control()->add_style_override("panel", get_stylebox("bg", "Tree"));
|
2017-03-02 22:43:56 +01:00
|
|
|
} break;
|
|
|
|
case NOTIFICATION_POPUP_HIDE: {
|
|
|
|
EditorSettings::get_singleton()->set("interface/dialogs/export_bounds", get_rect());
|
|
|
|
} break;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-27 11:23:12 +01:00
|
|
|
void ProjectExportDialog::popup_export() {
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
add_preset->get_popup()->clear();
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<EditorExportPlatform> plat = EditorExport::get_singleton()->get_export_platform(i);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
add_preset->get_popup()->add_icon_item(plat->get_logo(), plat->get_name());
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
_update_presets();
|
2017-03-02 22:43:56 +01:00
|
|
|
|
|
|
|
// Restore valid window bounds or pop up at default size.
|
|
|
|
if (EditorSettings::get_singleton()->has("interface/dialogs/export_bounds")) {
|
|
|
|
popup(EditorSettings::get_singleton()->get("interface/dialogs/export_bounds"));
|
|
|
|
} else {
|
|
|
|
popup_centered_ratio();
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
void ProjectExportDialog::_add_preset(int p_platform) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_platform(p_platform)->create_preset();
|
|
|
|
ERR_FAIL_COND(!preset.is_valid());
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
String name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name();
|
2017-03-05 16:44:50 +01:00
|
|
|
bool make_runnable = true;
|
|
|
|
int attempt = 1;
|
|
|
|
while (true) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool valid = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<EditorExportPreset> p = EditorExport::get_singleton()->get_export_preset(i);
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p->get_platform() == preset->get_platform() && p->is_runnable()) {
|
|
|
|
make_runnable = false;
|
2017-02-20 03:19:30 +01:00
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p->get_name() == name) {
|
|
|
|
valid = false;
|
2017-02-20 03:19:30 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
if (valid)
|
|
|
|
break;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
attempt++;
|
2017-03-05 16:44:50 +01:00
|
|
|
name = EditorExport::get_singleton()->get_export_platform(p_platform)->get_name() + " " + itos(attempt);
|
2016-01-27 11:23:12 +01:00
|
|
|
}
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
preset->set_name(name);
|
|
|
|
if (make_runnable)
|
|
|
|
preset->set_runnable(make_runnable);
|
|
|
|
EditorExport::get_singleton()->add_export_preset(preset);
|
|
|
|
_update_presets();
|
2017-03-05 16:44:50 +01:00
|
|
|
_edit_preset(EditorExport::get_singleton()->get_export_preset_count() - 1);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
void ProjectExportDialog::_update_presets() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
updating = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<EditorExportPreset> current;
|
2017-03-05 16:44:50 +01:00
|
|
|
if (presets->get_current() >= 0 && presets->get_current() < presets->get_item_count())
|
2017-02-20 03:19:30 +01:00
|
|
|
current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
int current_idx = -1;
|
2017-02-20 03:19:30 +01:00
|
|
|
presets->clear();
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_preset(i);
|
2017-03-05 16:44:50 +01:00
|
|
|
if (preset == current) {
|
|
|
|
current_idx = i;
|
2017-02-20 03:19:30 +01:00
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
String name = preset->get_name();
|
|
|
|
if (preset->is_runnable())
|
2017-03-05 16:44:50 +01:00
|
|
|
name += " (" + TTR("Runnable") + ")";
|
|
|
|
presets->add_item(name, preset->get_platform()->get_logo());
|
2017-02-20 03:19:30 +01:00
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (current_idx != -1) {
|
2017-02-20 03:19:30 +01:00
|
|
|
presets->select(current_idx);
|
|
|
|
//_edit_preset(current_idx);
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
updating = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
void ProjectExportDialog::_edit_preset(int p_index) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p_index < 0 || p_index >= presets->get_item_count()) {
|
2017-02-20 03:19:30 +01:00
|
|
|
name->set_text("");
|
|
|
|
name->set_editable(false);
|
|
|
|
runnable->set_disabled(true);
|
|
|
|
parameters->edit(NULL);
|
|
|
|
delete_preset->set_disabled(true);
|
|
|
|
sections->hide();
|
|
|
|
patches->clear();
|
2017-03-21 03:31:41 +01:00
|
|
|
export_error->hide();
|
|
|
|
export_templates_error->hide();
|
2017-02-20 03:19:30 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(p_index);
|
|
|
|
ERR_FAIL_COND(current.is_null());
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
updating = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
presets->select(p_index);
|
|
|
|
sections->show();
|
|
|
|
|
|
|
|
name->set_editable(true);
|
|
|
|
delete_preset->set_disabled(false);
|
|
|
|
name->set_text(current->get_name());
|
|
|
|
runnable->set_disabled(false);
|
|
|
|
runnable->set_pressed(current->is_runnable());
|
|
|
|
parameters->edit(current.ptr());
|
|
|
|
|
|
|
|
export_filter->select(current->get_export_filter());
|
|
|
|
include_filters->set_text(current->get_include_filter());
|
|
|
|
exclude_filters->set_text(current->get_exclude_filter());
|
|
|
|
|
|
|
|
patches->clear();
|
|
|
|
TreeItem *patch_root = patches->create_item();
|
|
|
|
Vector<String> patchlist = current->get_patches();
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < patchlist.size(); i++) {
|
2017-02-20 03:19:30 +01:00
|
|
|
TreeItem *patch = patches->create_item(patch_root);
|
2017-03-05 16:44:50 +01:00
|
|
|
patch->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
|
2017-02-20 03:19:30 +01:00
|
|
|
String file = patchlist[i].get_file();
|
2017-03-05 16:44:50 +01:00
|
|
|
patch->set_editable(0, true);
|
|
|
|
patch->set_text(0, file.get_file().replace("*", ""));
|
2017-02-20 03:19:30 +01:00
|
|
|
if (file.ends_with("*"))
|
2017-03-05 16:44:50 +01:00
|
|
|
patch->set_checked(0, true);
|
|
|
|
patch->set_tooltip(0, patchlist[i]);
|
|
|
|
patch->set_metadata(0, i);
|
|
|
|
patch->add_button(0, get_icon("Del", "EditorIcons"), 0);
|
|
|
|
patch->add_button(0, get_icon("folder", "FileDialog"), 1);
|
2017-02-20 03:19:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TreeItem *patch_add = patches->create_item(patch_root);
|
2017-03-05 16:44:50 +01:00
|
|
|
patch_add->set_metadata(0, patchlist.size());
|
|
|
|
if (patchlist.size() == 0)
|
|
|
|
patch_add->set_text(0, "Add initial export..");
|
2017-02-20 03:19:30 +01:00
|
|
|
else
|
2017-03-05 16:44:50 +01:00
|
|
|
patch_add->set_text(0, "Add previous patches..");
|
2016-02-04 10:07:08 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
patch_add->add_button(0, get_icon("folder", "FileDialog"), 1);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
_fill_resource_tree();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-21 03:31:41 +01:00
|
|
|
bool needs_templates;
|
|
|
|
String error;
|
|
|
|
if (!current->get_platform()->can_export(current, error, needs_templates)) {
|
|
|
|
|
|
|
|
if (error != String()) {
|
|
|
|
|
|
|
|
Vector<String> items = error.split("\n");
|
|
|
|
error = "";
|
|
|
|
for (int i = 0; i < items.size(); i++) {
|
|
|
|
if (i > 0)
|
|
|
|
error += "\n";
|
|
|
|
error += " - " + items[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
export_error->set_text(error);
|
|
|
|
export_error->show();
|
|
|
|
} else {
|
|
|
|
export_error->hide();
|
|
|
|
}
|
|
|
|
if (needs_templates)
|
|
|
|
export_templates_error->show();
|
2017-04-22 01:15:42 +02:00
|
|
|
else
|
|
|
|
export_templates_error->hide();
|
2017-03-21 03:31:41 +01:00
|
|
|
|
2017-03-28 03:21:21 +02:00
|
|
|
export_button->set_disabled(true);
|
2017-03-21 23:34:26 +01:00
|
|
|
|
2017-03-21 03:31:41 +01:00
|
|
|
} else {
|
2017-06-21 11:11:38 +02:00
|
|
|
export_error->hide();
|
2017-03-21 03:31:41 +01:00
|
|
|
export_templates_error->hide();
|
2017-03-28 03:21:21 +02:00
|
|
|
export_button->set_disabled(false);
|
2017-03-21 03:31:41 +01:00
|
|
|
}
|
|
|
|
|
2017-07-19 22:00:46 +02:00
|
|
|
custom_features->set_text(current->get_custom_features());
|
|
|
|
_update_feature_list();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
updating = false;
|
2014-02-26 14:08:17 +01:00
|
|
|
}
|
|
|
|
|
2017-07-19 22:00:46 +02:00
|
|
|
void ProjectExportDialog::_update_feature_list() {
|
|
|
|
|
|
|
|
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
|
|
|
|
ERR_FAIL_COND(current.is_null());
|
|
|
|
|
|
|
|
Set<String> fset;
|
|
|
|
List<String> features;
|
|
|
|
|
|
|
|
current->get_platform()->get_platform_features(&features);
|
|
|
|
current->get_platform()->get_preset_features(current, &features);
|
|
|
|
|
|
|
|
String custom = current->get_custom_features();
|
|
|
|
Vector<String> custom_list = custom.split(",");
|
|
|
|
for (int i = 0; i < custom_list.size(); i++) {
|
|
|
|
String f = custom_list[i].strip_edges();
|
|
|
|
if (f != String()) {
|
|
|
|
features.push_back(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (List<String>::Element *E = features.front(); E; E = E->next()) {
|
|
|
|
fset.insert(E->get());
|
|
|
|
}
|
|
|
|
|
|
|
|
custom_feature_display->clear();
|
|
|
|
for (Set<String>::Element *E = fset.front(); E; E = E->next()) {
|
|
|
|
String f = E->get();
|
|
|
|
if (E->next()) {
|
|
|
|
f += ", ";
|
|
|
|
}
|
|
|
|
custom_feature_display->add_text(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_custom_features_changed(const String &p_text) {
|
|
|
|
|
|
|
|
if (updating)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
|
|
|
|
ERR_FAIL_COND(current.is_null());
|
|
|
|
|
|
|
|
current->set_custom_features(p_text);
|
|
|
|
_update_feature_list();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_tab_changed(int) {
|
|
|
|
_update_feature_list();
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void ProjectExportDialog::_patch_button_pressed(Object *p_item, int p_column, int p_id) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
TreeItem *ti = (TreeItem *)p_item;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
patch_index = ti->get_metadata(0);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
|
|
|
|
ERR_FAIL_COND(current.is_null());
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p_id == 0) {
|
2017-02-20 03:19:30 +01:00
|
|
|
Vector<String> patches = current->get_patches();
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_FAIL_INDEX(patch_index, patches.size());
|
|
|
|
patch_erase->set_text(vformat(TTR("Delete patch '" + patches[patch_index].get_file() + "' from list?")));
|
2017-02-20 03:19:30 +01:00
|
|
|
patch_erase->popup_centered_minsize();
|
|
|
|
} else {
|
|
|
|
patch_dialog->popup_centered_ratio();
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
void ProjectExportDialog::_patch_edited() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
TreeItem *item = patches->get_edited();
|
|
|
|
if (!item)
|
2014-06-11 15:41:03 +02:00
|
|
|
return;
|
2017-02-20 03:19:30 +01:00
|
|
|
int index = item->get_metadata(0);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
|
|
|
|
ERR_FAIL_COND(current.is_null());
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Vector<String> patches = current->get_patches();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_FAIL_INDEX(index, patches.size());
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
String patch = patches[index].replace("*", "");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
if (item->is_checked(0)) {
|
2017-03-05 16:44:50 +01:00
|
|
|
patch += "*";
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
current->set_patch(index, patch);
|
2017-02-20 03:19:30 +01:00
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void ProjectExportDialog::_patch_selected(const String &p_path) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
|
|
|
|
ERR_FAIL_COND(current.is_null());
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Vector<String> patches = current->get_patches();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (patch_index >= patches.size()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-07-19 22:00:46 +02:00
|
|
|
current->add_patch(ProjectSettings::get_singleton()->get_resource_path().path_to(p_path) + "*");
|
2017-02-20 03:19:30 +01:00
|
|
|
} else {
|
|
|
|
String enabled = patches[patch_index].ends_with("*") ? String("*") : String();
|
2017-07-19 22:00:46 +02:00
|
|
|
current->set_patch(patch_index, ProjectSettings::get_singleton()->get_resource_path().path_to(p_path) + enabled);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
_edit_preset(presets->get_current());
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
void ProjectExportDialog::_patch_deleted() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
|
|
|
|
ERR_FAIL_COND(current.is_null());
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Vector<String> patches = current->get_patches();
|
2017-03-05 16:44:50 +01:00
|
|
|
if (patch_index < patches.size()) {
|
2015-12-04 14:18:28 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
current->remove_patch(patch_index);
|
|
|
|
_edit_preset(presets->get_current());
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-28 03:21:21 +02:00
|
|
|
void ProjectExportDialog::_update_parameters(const String &p_edited_property) {
|
|
|
|
|
|
|
|
_edit_preset(presets->get_current());
|
|
|
|
parameters->update_tree();
|
|
|
|
}
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
void ProjectExportDialog::_runnable_pressed() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
if (updating)
|
|
|
|
return;
|
2014-02-15 06:01:39 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
|
|
|
|
ERR_FAIL_COND(current.is_null());
|
2014-02-15 06:01:39 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
if (runnable->is_pressed()) {
|
2014-02-15 06:01:39 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<EditorExportPreset> p = EditorExport::get_singleton()->get_export_preset(i);
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p->get_platform() == current->get_platform()) {
|
|
|
|
p->set_runnable(current == p);
|
2017-02-20 03:19:30 +01:00
|
|
|
}
|
2014-02-15 06:01:39 +01:00
|
|
|
}
|
2017-02-20 03:19:30 +01:00
|
|
|
} else {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
current->set_runnable(false);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
_update_presets();
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void ProjectExportDialog::_name_changed(const String &p_string) {
|
2014-02-13 22:03:28 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
if (updating)
|
2014-02-13 22:03:28 +01:00
|
|
|
return;
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
|
|
|
|
ERR_FAIL_COND(current.is_null());
|
2015-12-13 05:08:36 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
current->set_name(p_string);
|
|
|
|
_update_presets();
|
2014-02-13 22:03:28 +01:00
|
|
|
}
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
void ProjectExportDialog::_delete_preset() {
|
2014-02-13 22:03:28 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
|
|
|
|
if (current.is_null())
|
|
|
|
return;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
delete_confirm->set_text(vformat(TTR("Delete preset '%s'?"), current->get_name()));
|
2017-02-20 03:19:30 +01:00
|
|
|
delete_confirm->popup_centered_minsize();
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
void ProjectExportDialog::_delete_preset_confirm() {
|
2014-02-13 22:03:28 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
int idx = presets->get_current();
|
2017-03-05 16:44:50 +01:00
|
|
|
parameters->edit(NULL); //to avoid crash
|
2017-02-20 03:19:30 +01:00
|
|
|
EditorExport::get_singleton()->remove_export_preset(idx);
|
|
|
|
_update_presets();
|
|
|
|
_edit_preset(-1);
|
2014-02-13 22:03:28 +01:00
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
Variant ProjectExportDialog::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p_from == presets) {
|
|
|
|
int pos = presets->get_item_at_pos(p_point, true);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (pos >= 0) {
|
2017-02-20 03:19:30 +01:00
|
|
|
Dictionary d;
|
2017-03-05 16:44:50 +01:00
|
|
|
d["type"] = "export_preset";
|
|
|
|
d["preset"] = pos;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
HBoxContainer *drag = memnew(HBoxContainer);
|
2017-02-20 03:19:30 +01:00
|
|
|
TextureRect *tr = memnew(TextureRect);
|
|
|
|
tr->set_texture(presets->get_item_icon(pos));
|
|
|
|
drag->add_child(tr);
|
2017-03-05 16:44:50 +01:00
|
|
|
Label *label = memnew(Label);
|
2017-02-20 03:19:30 +01:00
|
|
|
label->set_text(presets->get_item_text(pos));
|
|
|
|
drag->add_child(label);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
set_drag_preview(drag);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
return d;
|
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (p_from == patches) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
TreeItem *item = patches->get_item_at_pos(p_point);
|
2016-11-26 15:30:46 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (item && item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK) {
|
2016-11-26 15:30:46 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
int metadata = item->get_metadata(0);
|
|
|
|
Dictionary d;
|
2017-03-05 16:44:50 +01:00
|
|
|
d["type"] = "export_patch";
|
|
|
|
d["patch"] = metadata;
|
2016-11-26 15:30:46 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
Label *label = memnew(Label);
|
2017-02-20 03:19:30 +01:00
|
|
|
label->set_text(item->get_text(0));
|
|
|
|
set_drag_preview(label);
|
2016-11-26 15:30:46 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
return d;
|
|
|
|
}
|
|
|
|
}
|
2016-11-26 15:30:46 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
return Variant();
|
2016-11-26 15:30:46 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool ProjectExportDialog::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
|
2016-11-26 15:30:46 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p_from == presets) {
|
2017-02-20 03:19:30 +01:00
|
|
|
Dictionary d = p_data;
|
2017-03-05 16:44:50 +01:00
|
|
|
if (!d.has("type") || String(d["type"]) != "export_preset")
|
2017-02-20 03:19:30 +01:00
|
|
|
return false;
|
2016-11-26 15:30:46 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (presets->get_item_at_pos(p_point, true) < 0 && !presets->is_pos_at_end_of_items(p_point))
|
2017-02-20 03:19:30 +01:00
|
|
|
return false;
|
2017-03-05 16:44:50 +01:00
|
|
|
} else if (p_from == patches) {
|
2016-11-26 15:30:46 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Dictionary d = p_data;
|
2017-03-05 16:44:50 +01:00
|
|
|
if (!d.has("type") || String(d["type"]) != "export_patch")
|
2017-02-20 03:19:30 +01:00
|
|
|
return false;
|
2016-11-26 15:30:46 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
patches->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM);
|
2016-11-26 15:30:46 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
TreeItem *item = patches->get_item_at_pos(p_point);
|
2016-11-26 15:30:46 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
if (!item) {
|
2016-11-26 15:30:46 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
return false;
|
|
|
|
}
|
2016-11-26 15:30:46 +01:00
|
|
|
}
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
return true;
|
2016-11-26 15:30:46 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void ProjectExportDialog::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
|
2016-11-26 15:30:46 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p_from == presets) {
|
|
|
|
Dictionary d = p_data;
|
2017-02-20 03:19:30 +01:00
|
|
|
int from_pos = d["preset"];
|
2016-11-26 15:30:46 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
int to_pos = -1;
|
2016-11-26 15:30:46 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (presets->get_item_at_pos(p_point, true) >= 0) {
|
|
|
|
to_pos = presets->get_item_at_pos(p_point, true);
|
2016-11-26 15:30:46 +01:00
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (to_pos == -1 && !presets->is_pos_at_end_of_items(p_point))
|
2017-02-20 03:19:30 +01:00
|
|
|
return;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (to_pos == from_pos)
|
2017-02-20 03:19:30 +01:00
|
|
|
return;
|
2017-03-05 16:44:50 +01:00
|
|
|
else if (to_pos > from_pos) {
|
2017-02-20 03:19:30 +01:00
|
|
|
to_pos--;
|
|
|
|
}
|
2014-10-23 12:04:21 +02:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_preset(from_pos);
|
|
|
|
EditorExport::get_singleton()->remove_export_preset(from_pos);
|
2017-03-05 16:44:50 +01:00
|
|
|
EditorExport::get_singleton()->add_export_preset(preset, to_pos);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
_update_presets();
|
2017-03-05 16:44:50 +01:00
|
|
|
if (to_pos >= 0)
|
2017-02-20 03:19:30 +01:00
|
|
|
_edit_preset(to_pos);
|
|
|
|
else
|
2017-03-05 16:44:50 +01:00
|
|
|
_edit_preset(presets->get_item_count() - 1);
|
|
|
|
} else if (p_from == patches) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Dictionary d = p_data;
|
2017-03-05 16:44:50 +01:00
|
|
|
if (!d.has("type") || String(d["type"]) != "export_patch")
|
2017-02-20 03:19:30 +01:00
|
|
|
return;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
int from_pos = d["patch"];
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
TreeItem *item = patches->get_item_at_pos(p_point);
|
|
|
|
if (!item)
|
|
|
|
return;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
int to_pos = item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK ? int(item->get_metadata(0)) : -1;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (to_pos == from_pos)
|
2017-02-20 03:19:30 +01:00
|
|
|
return;
|
2017-03-05 16:44:50 +01:00
|
|
|
else if (to_pos > from_pos) {
|
2017-02-20 03:19:30 +01:00
|
|
|
to_pos--;
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_export_preset(presets->get_current());
|
|
|
|
String patch = preset->get_patch(from_pos);
|
|
|
|
preset->remove_patch(from_pos);
|
2017-03-05 16:44:50 +01:00
|
|
|
preset->add_patch(patch, to_pos);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
_edit_preset(presets->get_current());
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
void ProjectExportDialog::_export_type_changed(int p_which) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
if (updating)
|
2014-02-10 02:10:30 +01:00
|
|
|
return;
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
|
|
|
|
if (current.is_null())
|
2014-02-10 02:10:30 +01:00
|
|
|
return;
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
current->set_export_filter(EditorExportPreset::ExportFilter(p_which));
|
2017-03-05 16:44:50 +01:00
|
|
|
updating = true;
|
2017-02-20 03:19:30 +01:00
|
|
|
_fill_resource_tree();
|
2017-03-05 16:44:50 +01:00
|
|
|
updating = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void ProjectExportDialog::_filter_changed(const String &p_filter) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
if (updating)
|
|
|
|
return;
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
|
|
|
|
if (current.is_null())
|
|
|
|
return;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
current->set_include_filter(include_filters->get_text());
|
|
|
|
current->set_exclude_filter(exclude_filters->get_text());
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
void ProjectExportDialog::_fill_resource_tree() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
include_files->clear();
|
|
|
|
include_label->hide();
|
|
|
|
include_margin->hide();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
|
|
|
|
if (current.is_null())
|
|
|
|
return;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
EditorExportPreset::ExportFilter f = current->get_export_filter();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
if (f == EditorExportPreset::EXPORT_ALL_RESOURCES) {
|
2017-02-20 03:19:30 +01:00
|
|
|
return;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
include_label->show();
|
|
|
|
include_margin->show();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
TreeItem *root = include_files->create_item();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
_fill_tree(EditorFileSystem::get_singleton()->get_filesystem(), root, current, f == EditorExportPreset::EXPORT_SELECTED_SCENES);
|
2017-02-20 03:19:30 +01:00
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir, TreeItem *p_item, Ref<EditorExportPreset> ¤t, bool p_only_scenes) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
p_item->set_icon(0, get_icon("folder", "FileDialog"));
|
|
|
|
p_item->set_text(0, p_dir->get_name() + "/");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool used = false;
|
|
|
|
for (int i = 0; i < p_dir->get_subdir_count(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
TreeItem *subdir = include_files->create_item(p_item);
|
2017-03-05 16:44:50 +01:00
|
|
|
if (_fill_tree(p_dir->get_subdir(i), subdir, current, p_only_scenes) == false) {
|
2017-02-20 03:19:30 +01:00
|
|
|
memdelete(subdir);
|
|
|
|
} else {
|
2017-03-05 16:44:50 +01:00
|
|
|
used = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
for (int i = 0; i < p_dir->get_file_count(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
String type = p_dir->get_file_type(i);
|
2017-03-05 16:44:50 +01:00
|
|
|
if (p_only_scenes && type != "PackedScene")
|
2017-02-20 03:19:30 +01:00
|
|
|
continue;
|
2014-06-11 15:41:03 +02:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
TreeItem *file = include_files->create_item(p_item);
|
2017-03-05 16:44:50 +01:00
|
|
|
file->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
|
|
|
|
file->set_text(0, p_dir->get_file(i));
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<Texture> tex;
|
2017-03-05 16:44:50 +01:00
|
|
|
if (has_icon(type, editor_icons)) {
|
|
|
|
tex = get_icon(type, editor_icons);
|
2017-02-20 03:19:30 +01:00
|
|
|
} else {
|
2017-03-05 16:44:50 +01:00
|
|
|
tex = get_icon("Object", editor_icons);
|
2017-02-20 03:19:30 +01:00
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
String path = p_dir->get_file_path(i);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
file->set_icon(0, tex);
|
|
|
|
file->set_editable(0, true);
|
|
|
|
file->set_checked(0, current->has_export_file(path));
|
|
|
|
file->set_metadata(0, path);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
used = true;
|
2017-02-20 03:19:30 +01:00
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
return used;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
void ProjectExportDialog::_tree_changed() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
if (updating)
|
|
|
|
return;
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
|
|
|
|
if (current.is_null())
|
|
|
|
return;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
TreeItem *item = include_files->get_edited();
|
2014-02-10 02:10:30 +01:00
|
|
|
if (!item)
|
|
|
|
return;
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
String path = item->get_metadata(0);
|
|
|
|
bool added = item->is_checked(0);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
if (added) {
|
|
|
|
current->add_export_file(path);
|
|
|
|
} else {
|
|
|
|
current->remove_export_file(path);
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-02-21 04:05:15 +01:00
|
|
|
void ProjectExportDialog::_export_pck_zip() {
|
|
|
|
|
|
|
|
export_pck_zip->popup_centered_ratio();
|
|
|
|
}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void ProjectExportDialog::_export_pck_zip_selected(const String &p_path) {
|
2017-02-21 04:05:15 +01:00
|
|
|
|
|
|
|
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_FAIL_COND(current.is_null());
|
2017-02-21 04:05:15 +01:00
|
|
|
Ref<EditorExportPlatform> platform = current->get_platform();
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_FAIL_COND(platform.is_null());
|
2017-02-21 04:05:15 +01:00
|
|
|
|
|
|
|
if (p_path.ends_with(".zip")) {
|
2017-03-05 16:44:50 +01:00
|
|
|
platform->save_zip(current, p_path);
|
2017-02-21 04:05:15 +01:00
|
|
|
} else if (p_path.ends_with(".pck")) {
|
2017-03-05 16:44:50 +01:00
|
|
|
platform->save_pack(current, p_path);
|
2017-02-21 04:05:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-21 03:31:41 +01:00
|
|
|
void ProjectExportDialog::_open_export_template_manager() {
|
|
|
|
|
|
|
|
EditorNode::get_singleton()->open_export_template_manager();
|
|
|
|
hide();
|
|
|
|
}
|
|
|
|
|
2017-03-21 23:34:26 +01:00
|
|
|
void ProjectExportDialog::_export_project() {
|
|
|
|
|
|
|
|
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
|
|
|
|
ERR_FAIL_COND(current.is_null());
|
|
|
|
Ref<EditorExportPlatform> platform = current->get_platform();
|
|
|
|
ERR_FAIL_COND(platform.is_null());
|
|
|
|
|
|
|
|
export_project->set_access(FileDialog::ACCESS_FILESYSTEM);
|
|
|
|
export_project->clear_filters();
|
|
|
|
String extension = platform->get_binary_extension();
|
|
|
|
if (extension != String()) {
|
|
|
|
export_project->add_filter("*." + extension + " ; " + platform->get_name() + " Export");
|
|
|
|
}
|
|
|
|
|
|
|
|
export_project->popup_centered_ratio();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_export_project_to_path(const String &p_path) {
|
|
|
|
|
|
|
|
Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current());
|
|
|
|
ERR_FAIL_COND(current.is_null());
|
|
|
|
Ref<EditorExportPlatform> platform = current->get_platform();
|
|
|
|
ERR_FAIL_COND(platform.is_null());
|
|
|
|
|
|
|
|
Error err = platform->export_project(current, export_debug->is_pressed(), p_path, 0);
|
|
|
|
}
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
void ProjectExportDialog::_bind_methods() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
ClassDB::bind_method("_add_preset", &ProjectExportDialog::_add_preset);
|
|
|
|
ClassDB::bind_method("_edit_preset", &ProjectExportDialog::_edit_preset);
|
2017-03-28 03:21:21 +02:00
|
|
|
ClassDB::bind_method("_update_parameters", &ProjectExportDialog::_update_parameters);
|
2017-03-05 16:44:50 +01:00
|
|
|
ClassDB::bind_method("_runnable_pressed", &ProjectExportDialog::_runnable_pressed);
|
|
|
|
ClassDB::bind_method("_name_changed", &ProjectExportDialog::_name_changed);
|
|
|
|
ClassDB::bind_method("_delete_preset", &ProjectExportDialog::_delete_preset);
|
|
|
|
ClassDB::bind_method("_delete_preset_confirm", &ProjectExportDialog::_delete_preset_confirm);
|
|
|
|
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);
|
|
|
|
ClassDB::bind_method("_export_type_changed", &ProjectExportDialog::_export_type_changed);
|
|
|
|
ClassDB::bind_method("_filter_changed", &ProjectExportDialog::_filter_changed);
|
|
|
|
ClassDB::bind_method("_tree_changed", &ProjectExportDialog::_tree_changed);
|
|
|
|
ClassDB::bind_method("_patch_button_pressed", &ProjectExportDialog::_patch_button_pressed);
|
|
|
|
ClassDB::bind_method("_patch_selected", &ProjectExportDialog::_patch_selected);
|
|
|
|
ClassDB::bind_method("_patch_deleted", &ProjectExportDialog::_patch_deleted);
|
|
|
|
ClassDB::bind_method("_patch_edited", &ProjectExportDialog::_patch_edited);
|
|
|
|
ClassDB::bind_method("_export_pck_zip", &ProjectExportDialog::_export_pck_zip);
|
|
|
|
ClassDB::bind_method("_export_pck_zip_selected", &ProjectExportDialog::_export_pck_zip_selected);
|
2017-03-21 03:31:41 +01:00
|
|
|
ClassDB::bind_method("_open_export_template_manager", &ProjectExportDialog::_open_export_template_manager);
|
2017-03-21 23:34:26 +01:00
|
|
|
ClassDB::bind_method("_export_project", &ProjectExportDialog::_export_project);
|
|
|
|
ClassDB::bind_method("_export_project_to_path", &ProjectExportDialog::_export_project_to_path);
|
2017-07-19 22:00:46 +02:00
|
|
|
ClassDB::bind_method("_custom_features_changed", &ProjectExportDialog::_custom_features_changed);
|
|
|
|
ClassDB::bind_method("_tab_changed", &ProjectExportDialog::_tab_changed);
|
2017-02-20 03:19:30 +01:00
|
|
|
}
|
|
|
|
ProjectExportDialog::ProjectExportDialog() {
|
|
|
|
|
2017-03-02 22:43:56 +01:00
|
|
|
set_title(TTR("Export"));
|
|
|
|
set_resizable(true);
|
|
|
|
|
2017-03-21 03:31:41 +01:00
|
|
|
VBoxContainer *main_vb = memnew(VBoxContainer);
|
|
|
|
add_child(main_vb);
|
2017-03-05 16:44:50 +01:00
|
|
|
HBoxContainer *hbox = memnew(HBoxContainer);
|
2017-03-21 03:31:41 +01:00
|
|
|
main_vb->add_child(hbox);
|
|
|
|
hbox->set_v_size_flags(SIZE_EXPAND_FILL);
|
2017-02-20 03:19:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VBoxContainer *preset_vb = memnew(VBoxContainer);
|
2017-02-20 03:19:30 +01:00
|
|
|
preset_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
|
|
|
hbox->add_child(preset_vb);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
HBoxContainer *preset_hb = memnew(HBoxContainer);
|
2017-02-20 03:19:30 +01:00
|
|
|
preset_hb->add_child(memnew(Label(TTR("Presets"))));
|
|
|
|
preset_hb->add_spacer();
|
|
|
|
preset_vb->add_child(preset_hb);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
add_preset = memnew(MenuButton);
|
2017-02-20 03:19:30 +01:00
|
|
|
add_preset->set_text(TTR("Add.."));
|
2017-03-05 16:44:50 +01:00
|
|
|
add_preset->get_popup()->connect("index_pressed", this, "_add_preset");
|
2017-02-20 03:19:30 +01:00
|
|
|
preset_hb->add_child(add_preset);
|
2017-03-05 16:44:50 +01:00
|
|
|
MarginContainer *mc = memnew(MarginContainer);
|
2017-02-20 03:19:30 +01:00
|
|
|
preset_vb->add_child(mc);
|
|
|
|
mc->set_v_size_flags(SIZE_EXPAND_FILL);
|
2017-03-05 16:44:50 +01:00
|
|
|
presets = memnew(ItemList);
|
2017-02-20 03:19:30 +01:00
|
|
|
presets->set_drag_forwarding(this);
|
|
|
|
mc->add_child(presets);
|
2017-03-05 16:44:50 +01:00
|
|
|
presets->connect("item_selected", this, "_edit_preset");
|
|
|
|
delete_preset = memnew(ToolButton);
|
2017-02-20 03:19:30 +01:00
|
|
|
preset_hb->add_child(delete_preset);
|
2017-03-05 16:44:50 +01:00
|
|
|
delete_preset->connect("pressed", this, "_delete_preset");
|
2017-02-20 03:19:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VBoxContainer *settings_vb = memnew(VBoxContainer);
|
2017-02-20 03:19:30 +01:00
|
|
|
settings_vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
|
|
|
hbox->add_child(settings_vb);
|
|
|
|
|
|
|
|
name = memnew(LineEdit);
|
2017-03-05 16:44:50 +01:00
|
|
|
settings_vb->add_margin_child(TTR("Name:"), name);
|
|
|
|
name->connect("text_changed", this, "_name_changed");
|
2017-02-20 03:19:30 +01:00
|
|
|
runnable = memnew(CheckButton);
|
|
|
|
runnable->set_text(TTR("Runnable"));
|
2017-03-05 16:44:50 +01:00
|
|
|
runnable->connect("pressed", this, "_runnable_pressed");
|
2017-02-20 03:19:30 +01:00
|
|
|
settings_vb->add_child(runnable);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
sections = memnew(TabContainer);
|
2017-05-02 22:13:12 +02:00
|
|
|
sections->set_tab_align(TabContainer::ALIGN_LEFT);
|
2017-02-20 03:19:30 +01:00
|
|
|
settings_vb->add_child(sections);
|
|
|
|
sections->set_v_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
parameters = memnew(PropertyEditor);
|
2017-02-20 03:19:30 +01:00
|
|
|
sections->add_child(parameters);
|
|
|
|
parameters->set_name(TTR("Options"));
|
|
|
|
parameters->hide_top_label();
|
|
|
|
parameters->set_v_size_flags(SIZE_EXPAND_FILL);
|
2017-07-18 02:05:38 +02:00
|
|
|
|
2017-03-28 03:21:21 +02:00
|
|
|
parameters->connect("property_edited", this, "_update_parameters");
|
2017-02-20 03:19:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VBoxContainer *resources_vb = memnew(VBoxContainer);
|
2017-02-20 03:19:30 +01:00
|
|
|
sections->add_child(resources_vb);
|
|
|
|
resources_vb->set_name(TTR("Resources"));
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
export_filter = memnew(OptionButton);
|
2017-02-20 03:19:30 +01:00
|
|
|
export_filter->add_item(TTR("Export all resources in the project"));
|
|
|
|
export_filter->add_item(TTR("Export selected scenes (and dependencies)"));
|
|
|
|
export_filter->add_item(TTR("Export selected resources (and dependencies)"));
|
2017-03-05 16:44:50 +01:00
|
|
|
resources_vb->add_margin_child(TTR("Export Mode:"), export_filter);
|
|
|
|
export_filter->connect("item_selected", this, "_export_type_changed");
|
2017-02-20 03:19:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
include_label = memnew(Label);
|
2017-02-20 03:19:30 +01:00
|
|
|
include_label->set_text(TTR("Resources to export:"));
|
|
|
|
resources_vb->add_child(include_label);
|
2017-03-05 16:44:50 +01:00
|
|
|
include_margin = memnew(MarginContainer);
|
2017-02-20 03:19:30 +01:00
|
|
|
include_margin->set_v_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
resources_vb->add_child(include_margin);
|
|
|
|
|
|
|
|
include_files = memnew(Tree);
|
|
|
|
include_margin->add_child(include_files);
|
2017-03-05 16:44:50 +01:00
|
|
|
include_files->connect("item_edited", this, "_tree_changed");
|
2017-02-20 03:19:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
include_filters = memnew(LineEdit);
|
|
|
|
resources_vb->add_margin_child(TTR("Filters to export non-resource files (comma separated, e.g: *.json, *.txt)"), include_filters);
|
|
|
|
include_filters->connect("text_changed", this, "_filter_changed");
|
2017-02-20 03:19:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
exclude_filters = memnew(LineEdit);
|
|
|
|
resources_vb->add_margin_child(TTR("Filters to exclude files from project (comma separated, e.g: *.json, *.txt)"), exclude_filters);
|
|
|
|
exclude_filters->connect("text_changed", this, "_filter_changed");
|
2017-02-20 03:19:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VBoxContainer *patch_vb = memnew(VBoxContainer);
|
2017-02-20 03:19:30 +01:00
|
|
|
sections->add_child(patch_vb);
|
|
|
|
patch_vb->set_name(TTR("Patches"));
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
patches = memnew(Tree);
|
2017-02-20 03:19:30 +01:00
|
|
|
patch_vb->add_child(patches);
|
|
|
|
patches->set_v_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
patches->set_hide_root(true);
|
2017-03-05 16:44:50 +01:00
|
|
|
patches->connect("button_pressed", this, "_patch_button_pressed");
|
|
|
|
patches->connect("item_edited", this, "_patch_edited");
|
2017-02-20 03:19:30 +01:00
|
|
|
patches->set_drag_forwarding(this);
|
|
|
|
patches->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
HBoxContainer *patches_hb = memnew(HBoxContainer);
|
2017-02-20 03:19:30 +01:00
|
|
|
patch_vb->add_child(patches_hb);
|
|
|
|
patches_hb->add_spacer();
|
2017-03-05 16:44:50 +01:00
|
|
|
patch_export = memnew(Button);
|
2017-02-20 03:19:30 +01:00
|
|
|
patch_export->set_text(TTR("Make Patch"));
|
|
|
|
patches_hb->add_child(patch_export);
|
|
|
|
patches_hb->add_spacer();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
patch_dialog = memnew(FileDialog);
|
2017-02-20 03:19:30 +01:00
|
|
|
patch_dialog->add_filter("*.pck ; Pack File");
|
|
|
|
patch_dialog->set_mode(FileDialog::MODE_OPEN_FILE);
|
2017-03-05 16:44:50 +01:00
|
|
|
patch_dialog->connect("file_selected", this, "_patch_selected");
|
2017-02-20 03:19:30 +01:00
|
|
|
add_child(patch_dialog);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
patch_erase = memnew(ConfirmationDialog);
|
2017-02-20 03:19:30 +01:00
|
|
|
patch_erase->get_ok()->set_text(TTR("Delete"));
|
2017-03-05 16:44:50 +01:00
|
|
|
patch_erase->connect("confirmed", this, "_patch_deleted");
|
2017-02-20 03:19:30 +01:00
|
|
|
add_child(patch_erase);
|
|
|
|
|
2017-07-19 22:00:46 +02:00
|
|
|
VBoxContainer *feature_vb = memnew(VBoxContainer);
|
|
|
|
feature_vb->set_name(TTR("Features"));
|
|
|
|
custom_features = memnew(LineEdit);
|
|
|
|
custom_features->connect("text_changed", this, "_custom_features_changed");
|
|
|
|
feature_vb->add_margin_child(TTR("Custom (comma-separated):"), custom_features);
|
|
|
|
Panel *features_panel = memnew(Panel);
|
|
|
|
custom_feature_display = memnew(RichTextLabel);
|
|
|
|
features_panel->add_child(custom_feature_display);
|
|
|
|
custom_feature_display->set_area_as_parent_rect(10 * EDSCALE);
|
|
|
|
custom_feature_display->set_v_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
feature_vb->add_margin_child(TTR("Feature List:"), features_panel, true);
|
|
|
|
sections->add_child(feature_vb);
|
|
|
|
|
|
|
|
sections->connect("tab_changed", this, "_tab_changed");
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
//disable by default
|
|
|
|
name->set_editable(false);
|
|
|
|
runnable->set_disabled(true);
|
|
|
|
delete_preset->set_disabled(true);
|
|
|
|
sections->hide();
|
|
|
|
parameters->edit(NULL);
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
delete_confirm = memnew(ConfirmationDialog);
|
2017-02-20 03:19:30 +01:00
|
|
|
add_child(delete_confirm);
|
|
|
|
delete_confirm->get_ok()->set_text(TTR("Delete"));
|
2017-03-05 16:44:50 +01:00
|
|
|
delete_confirm->connect("confirmed", this, "_delete_preset_confirm");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
updating = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
get_ok()->set_text("Export PCK/Zip");
|
2017-03-05 16:44:50 +01:00
|
|
|
export_button = add_button("Export Project", !OS::get_singleton()->get_swap_ok_cancel(), "export");
|
2017-02-21 04:05:15 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
export_pck_zip = memnew(FileDialog);
|
2017-02-21 04:05:15 +01:00
|
|
|
export_pck_zip->add_filter("*.zip ; ZIP File");
|
|
|
|
export_pck_zip->add_filter("*.pck ; Godot Game Pack");
|
|
|
|
export_pck_zip->set_access(FileDialog::ACCESS_FILESYSTEM);
|
|
|
|
export_pck_zip->set_mode(FileDialog::MODE_SAVE_FILE);
|
|
|
|
add_child(export_pck_zip);
|
2017-03-05 16:44:50 +01:00
|
|
|
export_pck_zip->connect("file_selected", this, "_export_pck_zip_selected");
|
2017-02-21 04:05:15 +01:00
|
|
|
|
2017-03-21 03:31:41 +01:00
|
|
|
export_error = memnew(Label);
|
|
|
|
main_vb->add_child(export_error);
|
|
|
|
export_error->hide();
|
|
|
|
export_error->add_color_override("font_color", Color(1, 0.5, 0.5));
|
|
|
|
|
|
|
|
export_templates_error = memnew(HBoxContainer);
|
|
|
|
main_vb->add_child(export_templates_error);
|
|
|
|
export_templates_error->hide();
|
|
|
|
|
|
|
|
Label *export_error2 = memnew(Label);
|
|
|
|
export_templates_error->add_child(export_error2);
|
|
|
|
export_error2->add_color_override("font_color", Color(1, 0.5, 0.5));
|
|
|
|
export_error2->set_text(" - " + TTR("Export templates for this platform are missing:") + " ");
|
|
|
|
|
|
|
|
LinkButton *download_templates = memnew(LinkButton);
|
|
|
|
download_templates->set_text(TTR("Manage Export Templates"));
|
|
|
|
export_templates_error->add_child(download_templates);
|
|
|
|
download_templates->connect("pressed", this, "_open_export_template_manager");
|
|
|
|
|
2017-03-21 23:34:26 +01:00
|
|
|
export_project = memnew(FileDialog);
|
|
|
|
export_project->set_access(FileDialog::ACCESS_FILESYSTEM);
|
|
|
|
add_child(export_project);
|
|
|
|
export_project->connect("file_selected", this, "_export_project_to_path");
|
|
|
|
export_button->connect("pressed", this, "_export_project");
|
|
|
|
|
|
|
|
export_debug = memnew(CheckButton);
|
|
|
|
export_debug->set_text(TTR("Export With Debug"));
|
|
|
|
export_debug->set_pressed(true);
|
|
|
|
export_project->get_vbox()->add_child(export_debug);
|
|
|
|
|
2017-02-21 04:05:15 +01:00
|
|
|
set_hide_on_ok(false);
|
|
|
|
|
2017-02-20 03:19:30 +01:00
|
|
|
editor_icons = "EditorIcons";
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ProjectExportDialog::~ProjectExportDialog() {
|
|
|
|
}
|