2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* project_export.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 14:11:45 +02:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
2017-01-01 22:01:57 +01:00
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2017-04-08 00:45:00 +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-19 00:36:26 +01:00
|
|
|
#include "globals.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "os/dir_access.h"
|
|
|
|
#include "os/file_access.h"
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "io/resource_loader.h"
|
|
|
|
#include "io/resource_saver.h"
|
|
|
|
#include "os/os.h"
|
|
|
|
#include "scene/gui/box_container.h"
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "compressed_translation.h"
|
2017-03-19 00:36:26 +01:00
|
|
|
#include "editor_data.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "editor_node.h"
|
|
|
|
#include "editor_settings.h"
|
2017-03-19 00:36:26 +01:00
|
|
|
#include "io/image_loader.h"
|
|
|
|
#include "io_plugins/editor_texture_import_plugin.h"
|
|
|
|
#include "scene/gui/scroll_container.h"
|
|
|
|
#include "scene/gui/tab_container.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
const char *ProjectExportDialog::da_string[ProjectExportDialog::ACTION_MAX] = {
|
2014-02-10 02:10:30 +01:00
|
|
|
"",
|
|
|
|
"Copy",
|
|
|
|
"Bundle"
|
|
|
|
};
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
bool ProjectExportDialog::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
TreeItem *item = tree->create_item(p_parent);
|
2017-03-19 00:36:26 +01:00
|
|
|
item->set_text(0, p_dir->get_name() + "/");
|
|
|
|
item->set_icon(0, get_icon("Folder", "EditorIcons"));
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
bool has_items = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < p_dir->get_subdir_count(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (_create_tree(item, p_dir->get_subdir(i)))
|
|
|
|
has_items = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
// int cc = p_options.get_slice_count(",");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < p_dir->get_file_count(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
TreeItem *fitem = tree->create_item(item);
|
|
|
|
//fitem->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
|
|
|
|
//fitem->set_editable(0,true);
|
2017-03-19 00:36:26 +01:00
|
|
|
// fitem->set_checked(0,isfave);
|
|
|
|
fitem->set_text(0, p_dir->get_file(i));
|
2014-02-10 02:10:30 +01:00
|
|
|
String path = p_dir->get_file_path(i);
|
2017-03-19 00:36:26 +01:00
|
|
|
fitem->set_tooltip(0, path);
|
|
|
|
fitem->set_metadata(0, path);
|
|
|
|
Ref<Texture> icon = get_icon((has_icon(p_dir->get_file_type(i), ei) ? p_dir->get_file_type(i) : ot), ei);
|
|
|
|
fitem->set_icon(0, icon);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
fitem->set_cell_mode(1, TreeItem::CELL_MODE_RANGE);
|
|
|
|
fitem->set_range_config(1, 0, 2, 1);
|
|
|
|
fitem->set_text(1, expopt);
|
|
|
|
fitem->set_editable(1, true);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
EditorImportExport::FileAction fa = EditorImportExport::get_singleton()->get_export_file_action(path);
|
2017-03-19 00:36:26 +01:00
|
|
|
fitem->set_range(1, fa);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
has_items = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!has_items) {
|
|
|
|
|
|
|
|
memdelete(item);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_tree_changed() {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
TreeItem *t = tree->get_selected();
|
2014-02-10 02:10:30 +01:00
|
|
|
if (!t)
|
|
|
|
return;
|
|
|
|
|
|
|
|
String selected = t->get_metadata(0);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorImportExport::get_singleton()->set_export_file_action(selected, EditorImportExport::FileAction(int(t->get_range(1))));
|
2014-02-10 02:10:30 +01:00
|
|
|
_save_export_cfg();
|
|
|
|
|
|
|
|
//editor->save_import_export(true);
|
|
|
|
//EditorImportDB::get_singleton()->save_settings();
|
|
|
|
}
|
|
|
|
|
2016-01-27 11:23:12 +01:00
|
|
|
void ProjectExportDialog::popup_export() {
|
|
|
|
popup_centered_ratio();
|
|
|
|
if (pending_update_tree) {
|
|
|
|
_update_tree();
|
|
|
|
_update_group_tree();
|
2017-03-19 00:36:26 +01:00
|
|
|
pending_update_tree = false;
|
2016-01-27 11:23:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void ProjectExportDialog::_update_tree() {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
updating_tree = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
tree->clear();
|
|
|
|
EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem();
|
|
|
|
|
|
|
|
if (efsd) {
|
2017-03-19 00:36:26 +01:00
|
|
|
_create_tree(NULL, efsd);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
updating_tree = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_update_platform() {
|
|
|
|
|
|
|
|
_validate_platform();
|
|
|
|
TreeItem *selected = platforms->get_selected();
|
|
|
|
if (!selected)
|
|
|
|
return;
|
|
|
|
|
|
|
|
String platform = selected->get_metadata(0);
|
|
|
|
Ref<EditorExportPlatform> exporter = EditorImportExport::get_singleton()->get_export_platform(platform);
|
2017-03-19 00:36:26 +01:00
|
|
|
platform_options->edit(exporter.ptr());
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_platform_selected() {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
String p = platforms->get_selected()->get_metadata(0);
|
2014-02-10 02:10:30 +01:00
|
|
|
_update_platform();
|
2017-03-19 00:36:26 +01:00
|
|
|
// editor->save_import_export();
|
|
|
|
// EditorFileSystem::get_singleton()->scan();
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_scan_finished() {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
/* print_line("**********SCAN DONEEE********");
|
2014-02-10 02:10:30 +01:00
|
|
|
print_line("**********SCAN DONEEE********");
|
|
|
|
print_line("**********SCAN DONEEE********");
|
|
|
|
print_line("**********SCAN DONEEE********");*/
|
|
|
|
|
2016-01-27 11:23:12 +01:00
|
|
|
if (!is_visible()) {
|
2017-03-19 00:36:26 +01:00
|
|
|
pending_update_tree = true;
|
2016-01-27 11:23:12 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
_update_tree();
|
|
|
|
_update_group_tree();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_rescan() {
|
|
|
|
|
|
|
|
EditorFileSystem::get_singleton()->scan();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_update_exporter() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_save_export_cfg() {
|
|
|
|
|
|
|
|
EditorImportExport::get_singleton()->save_config();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_prop_edited(String what) {
|
|
|
|
|
|
|
|
_save_export_cfg();
|
|
|
|
|
2015-07-22 18:51:17 +02:00
|
|
|
_validate_platform();
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_filters_edited(String what) {
|
|
|
|
|
|
|
|
EditorImportExport::get_singleton()->set_export_custom_filter(what);
|
|
|
|
_save_export_cfg();
|
|
|
|
}
|
|
|
|
|
2016-02-04 10:07:08 +01:00
|
|
|
void ProjectExportDialog::_filters_exclude_edited(String what) {
|
|
|
|
EditorImportExport::get_singleton()->set_export_custom_filter_exclude(what);
|
|
|
|
_save_export_cfg();
|
|
|
|
}
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void ProjectExportDialog::_quality_edited(float what) {
|
|
|
|
|
|
|
|
EditorImportExport::get_singleton()->set_export_image_quality(what);
|
|
|
|
_save_export_cfg();
|
|
|
|
}
|
|
|
|
|
2014-02-26 14:08:17 +01:00
|
|
|
void ProjectExportDialog::_shrink_edited(float what) {
|
|
|
|
|
|
|
|
EditorImportExport::get_singleton()->set_export_image_shrink(what);
|
|
|
|
_save_export_cfg();
|
|
|
|
}
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void ProjectExportDialog::_image_export_edited(int what) {
|
|
|
|
|
|
|
|
EditorImportExport::get_singleton()->set_export_image_action(EditorImportExport::ImageAction(what));
|
|
|
|
_save_export_cfg();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_format_toggled() {
|
|
|
|
|
|
|
|
EditorImportExport::get_singleton()->get_image_formats().clear();
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < formats.size(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
if (formats[i]->is_checked(0))
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorImportExport::get_singleton()->get_image_formats().insert(formats[i]->get_text(0));
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
_save_export_cfg();
|
|
|
|
}
|
|
|
|
|
2014-06-11 15:41:03 +02:00
|
|
|
void ProjectExportDialog::_script_edited(Variant v) {
|
|
|
|
|
|
|
|
if (updating_script)
|
|
|
|
return;
|
2017-03-19 00:36:26 +01:00
|
|
|
updating_script = true;
|
2016-05-04 03:25:37 +02:00
|
|
|
EditorNode::get_undo_redo()->create_action(TTR("Edit Script Options"));
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(), "script_set_action", script_mode->get_selected());
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(), "script_set_action", EditorImportExport::get_singleton()->script_get_action());
|
|
|
|
EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(), "script_set_encryption_key", script_key->get_text());
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(), "script_set_encryption_key", EditorImportExport::get_singleton()->script_get_encryption_key());
|
|
|
|
EditorNode::get_undo_redo()->add_do_method(this, "_update_script");
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(this, "_update_script");
|
|
|
|
EditorNode::get_undo_redo()->add_do_method(this, "_save_export_cfg");
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(this, "_save_export_cfg");
|
2014-06-11 15:41:03 +02:00
|
|
|
EditorNode::get_undo_redo()->commit_action();
|
2017-03-19 00:36:26 +01:00
|
|
|
updating_script = false;
|
2014-06-11 15:41:03 +02:00
|
|
|
}
|
|
|
|
|
2015-11-09 04:49:18 +01:00
|
|
|
void ProjectExportDialog::_sample_convert_edited(int what) {
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorImportExport::get_singleton()->sample_set_action(EditorImportExport::SampleAction(sample_mode->get_selected()));
|
|
|
|
EditorImportExport::get_singleton()->sample_set_max_hz(sample_max_hz->get_val());
|
|
|
|
EditorImportExport::get_singleton()->sample_set_trim(sample_trim->is_pressed());
|
2016-01-14 13:09:08 +01:00
|
|
|
_save_export_cfg();
|
2015-11-09 04:49:18 +01:00
|
|
|
}
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void ProjectExportDialog::_notification(int p_what) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
switch (p_what) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2014-11-06 01:20:42 +01:00
|
|
|
case NOTIFICATION_ENTER_TREE: {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CenterContainer *cc = memnew(CenterContainer);
|
|
|
|
TextureFrame *tf = memnew(TextureFrame);
|
|
|
|
tf->set_texture(get_icon("ErrorSign", "EditorIcons"));
|
2014-02-10 02:10:30 +01:00
|
|
|
cc->add_child(tf);
|
|
|
|
plat_errors->add_child(cc);
|
|
|
|
platform_error_string->raise();
|
|
|
|
|
|
|
|
TreeItem *root = platforms->create_item(NULL);
|
|
|
|
List<StringName> ep;
|
|
|
|
EditorImportExport::get_singleton()->get_export_platforms(&ep);
|
|
|
|
ep.sort_custom<StringName::AlphCompare>();
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (List<StringName>::Element *E = ep.front(); E; E = E->next()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
Ref<EditorExportPlatform> eep = EditorImportExport::get_singleton()->get_export_platform(E->get());
|
|
|
|
TreeItem *p = platforms->create_item(root);
|
2017-03-19 00:36:26 +01:00
|
|
|
p->set_text(0, eep->get_name());
|
|
|
|
p->set_icon(0, eep->get_logo());
|
|
|
|
p->set_metadata(0, eep->get_name());
|
|
|
|
if (eep->get_name() == OS::get_singleton()->get_name())
|
2014-02-10 02:10:30 +01:00
|
|
|
p->select(0);
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorFileSystem::get_singleton()->connect("filesystem_changed", this, "_scan_finished");
|
|
|
|
// _rescan();
|
2014-02-10 02:10:30 +01:00
|
|
|
_update_platform();
|
2017-03-19 00:36:26 +01:00
|
|
|
export_mode->select(EditorImportExport::get_singleton()->get_export_filter());
|
|
|
|
convert_text_scenes->set_pressed(EditorImportExport::get_singleton()->get_convert_text_scenes());
|
|
|
|
filters->set_text(EditorImportExport::get_singleton()->get_export_custom_filter());
|
|
|
|
filters_exclude->set_text(EditorImportExport::get_singleton()->get_export_custom_filter_exclude());
|
|
|
|
if (EditorImportExport::get_singleton()->get_export_filter() != EditorImportExport::EXPORT_SELECTED)
|
2014-02-10 02:10:30 +01:00
|
|
|
tree_vb->hide();
|
|
|
|
else
|
|
|
|
tree_vb->show();
|
|
|
|
|
|
|
|
image_action->select(EditorImportExport::get_singleton()->get_export_image_action());
|
|
|
|
image_quality->set_val(EditorImportExport::get_singleton()->get_export_image_quality());
|
2014-03-14 02:57:24 +01:00
|
|
|
image_shrink->set_val(EditorImportExport::get_singleton()->get_export_image_shrink());
|
2014-06-11 15:41:03 +02:00
|
|
|
_update_script();
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
image_quality->connect("value_changed", this, "_quality_edited");
|
|
|
|
image_shrink->connect("value_changed", this, "_shrink_edited");
|
|
|
|
image_action->connect("item_selected", this, "_image_export_edited");
|
2014-06-11 15:41:03 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
script_mode->connect("item_selected", this, "_script_edited");
|
|
|
|
script_key->connect("text_changed", this, "_script_edited");
|
2014-06-11 15:41:03 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < formats.size(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
if (EditorImportExport::get_singleton()->get_image_formats().has(formats[i]->get_text(0)))
|
2017-03-19 00:36:26 +01:00
|
|
|
formats[i]->set_checked(0, true);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
image_formats->connect("item_edited", this, "_format_toggled");
|
|
|
|
group_add->set_icon(get_icon("Add", "EditorIcons"));
|
|
|
|
// group_del->set_icon(get_icon("Del","EditorIcons"));
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
_update_group_list();
|
|
|
|
_update_group();
|
|
|
|
_update_group_tree();
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
sample_mode->select(EditorImportExport::get_singleton()->sample_get_action());
|
|
|
|
sample_max_hz->set_val(EditorImportExport::get_singleton()->sample_get_max_hz());
|
|
|
|
sample_trim->set_pressed(EditorImportExport::get_singleton()->sample_get_trim());
|
2015-11-09 04:49:18 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
sample_mode->connect("item_selected", this, "_sample_convert_edited");
|
|
|
|
sample_max_hz->connect("value_changed", this, "_sample_convert_edited");
|
|
|
|
sample_trim->connect("toggled", this, "_sample_convert_edited");
|
2015-11-09 04:49:18 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
} break;
|
2014-11-06 01:20:42 +01:00
|
|
|
case NOTIFICATION_EXIT_TREE: {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
} break;
|
|
|
|
case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
|
|
|
|
//something may have changed
|
|
|
|
_validate_platform();
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case NOTIFICATION_VISIBILITY_CHANGED: {
|
|
|
|
if (is_visible())
|
|
|
|
_validate_platform();
|
|
|
|
|
|
|
|
} break;
|
|
|
|
case NOTIFICATION_PROCESS: {
|
|
|
|
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_validate_platform() {
|
|
|
|
|
2014-02-13 22:03:28 +01:00
|
|
|
button_export->set_disabled(true);
|
2014-02-10 02:10:30 +01:00
|
|
|
TreeItem *selected = platforms->get_selected();
|
|
|
|
plat_errors->hide();
|
|
|
|
if (!selected) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
String platform = selected->get_metadata(0);
|
|
|
|
Ref<EditorExportPlatform> exporter = EditorImportExport::get_singleton()->get_export_platform(platform);
|
|
|
|
if (!exporter.is_valid()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
String err;
|
|
|
|
if (!exporter->can_export(&err)) {
|
|
|
|
Vector<String> items = err.strip_edges().split("\n");
|
2017-03-19 00:36:26 +01:00
|
|
|
err = "";
|
|
|
|
for (int i = 0; i < items.size(); i++) {
|
|
|
|
if (i != 0)
|
|
|
|
err += "\n";
|
|
|
|
err += " -" + items[i];
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
platform_error_string->set_text(err);
|
|
|
|
plat_errors->show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
List<String> pl;
|
|
|
|
EditorFileSystem::get_singleton()->get_changed_sources(&pl);
|
|
|
|
|
2014-03-14 02:57:24 +01:00
|
|
|
if (false && pl.size()) {
|
2017-03-19 00:36:26 +01:00
|
|
|
if (pl.size() == 1)
|
2014-02-10 02:10:30 +01:00
|
|
|
platform_error_string->set_text(" -One Resource is pending re-import.");
|
|
|
|
else
|
2017-03-19 00:36:26 +01:00
|
|
|
platform_error_string->set_text(" " + itos(pl.size()) + " Resources are pending re-import.");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
plat_errors->show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-13 22:03:28 +01:00
|
|
|
button_export->set_disabled(false);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_export_mode_changed(int p_idx) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (EditorImportExport::get_singleton()->get_export_filter() == p_idx)
|
2014-02-10 02:10:30 +01:00
|
|
|
return;
|
|
|
|
EditorImportExport::get_singleton()->set_export_filter(EditorImportExport::ExportFilter(p_idx));
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (p_idx != EditorImportExport::EXPORT_SELECTED)
|
2014-02-10 02:10:30 +01:00
|
|
|
tree_vb->hide();
|
|
|
|
else
|
|
|
|
tree_vb->show();
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorImportExport::get_singleton()->set_convert_text_scenes(convert_text_scenes->is_pressed());
|
2015-12-04 14:18:28 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
_save_export_cfg();
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void ProjectExportDialog::_export_action(const String &p_file) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
String location = Globals::get_singleton()->globalize_path(p_file).get_base_dir().replace("\\", "/");
|
2014-02-15 06:01:39 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
while (true) {
|
2014-02-15 06:01:39 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
print_line("TESTING: " + location.plus_file("engine.cfg"));
|
2014-02-15 06:01:39 +01:00
|
|
|
if (FileAccess::exists(location.plus_file("engine.cfg"))) {
|
|
|
|
|
2016-05-04 03:25:37 +02:00
|
|
|
error->set_text(TTR("Please export outside the project folder!"));
|
2015-04-08 19:02:13 +02:00
|
|
|
error->popup_centered_minsize();
|
2014-02-15 06:01:39 +01:00
|
|
|
return;
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
String nl = (location + "/..").simplify_path();
|
|
|
|
if (nl.find("/") == location.find_last("/"))
|
2014-02-15 06:01:39 +01:00
|
|
|
break;
|
2017-03-19 00:36:26 +01:00
|
|
|
location = nl;
|
2014-02-15 06:01:39 +01:00
|
|
|
}
|
|
|
|
|
2016-03-18 23:37:31 +01:00
|
|
|
/* Checked if the export location is outside the project directory,
|
|
|
|
* now will check if a file name has been entered */
|
|
|
|
if (p_file.ends_with("/")) {
|
2016-05-21 15:29:25 +02:00
|
|
|
|
2016-03-18 23:37:31 +01:00
|
|
|
error->set_text("Please enter a file name!");
|
|
|
|
error->popup_centered_minsize();
|
|
|
|
return;
|
|
|
|
}
|
2014-02-15 06:01:39 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
TreeItem *selected = platforms->get_selected();
|
|
|
|
if (!selected)
|
|
|
|
return;
|
|
|
|
|
|
|
|
String platform = selected->get_metadata(0);
|
2016-04-28 02:39:52 +02:00
|
|
|
bool debugging_enabled = EditorImportExport::get_singleton()->get_export_platform(platform)->is_debugging_enabled();
|
2017-03-19 00:36:26 +01:00
|
|
|
Error err = export_platform(platform, p_file, debugging_enabled, file_export_password->get_text(), false);
|
|
|
|
if (err != OK) {
|
2016-05-04 03:25:37 +02:00
|
|
|
error->set_text(TTR("Error exporting project!"));
|
2015-04-08 19:02:13 +02:00
|
|
|
error->popup_centered_minsize();
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void ProjectExportDialog::_export_action_pck(const String &p_file) {
|
2014-02-13 22:03:28 +01:00
|
|
|
|
2017-10-11 20:25:02 +02:00
|
|
|
// we need a valid platform to get a functional platform exporter
|
|
|
|
TreeItem *platform = platforms->get_last_item();
|
|
|
|
if (!platform)
|
2014-02-13 22:03:28 +01:00
|
|
|
return;
|
|
|
|
|
2017-10-11 20:25:02 +02:00
|
|
|
Ref<EditorExportPlatform> exporter = EditorImportExport::get_singleton()->get_export_platform(platform->get_metadata(0));
|
2014-02-13 22:03:28 +01:00
|
|
|
if (exporter.is_null()) {
|
|
|
|
ERR_PRINT("Invalid platform for export of PCK");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-12-13 05:08:36 +01:00
|
|
|
if (p_file.ends_with(".pck")) {
|
2017-03-19 00:36:26 +01:00
|
|
|
FileAccess *f = FileAccess::open(p_file, FileAccess::WRITE);
|
2015-12-13 05:08:36 +01:00
|
|
|
if (!f) {
|
2016-05-19 00:08:12 +02:00
|
|
|
error->set_text(TTR("Error writing the project PCK!"));
|
2015-12-13 05:08:36 +01:00
|
|
|
error->popup_centered_minsize();
|
|
|
|
}
|
|
|
|
ERR_FAIL_COND(!f);
|
2014-02-13 22:03:28 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
Error err = exporter->save_pack(f, false);
|
2015-12-13 05:08:36 +01:00
|
|
|
memdelete(f);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (err != OK) {
|
2016-05-04 03:25:37 +02:00
|
|
|
error->set_text(TTR("Error exporting project!"));
|
2015-12-13 05:08:36 +01:00
|
|
|
error->popup_centered_minsize();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else if (p_file.ends_with(".zip")) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
Error err = exporter->save_zip(p_file, false);
|
2015-12-13 05:08:36 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (err != OK) {
|
2016-05-04 03:25:37 +02:00
|
|
|
error->set_text(TTR("Error exporting project!"));
|
2015-12-13 05:08:36 +01:00
|
|
|
error->popup_centered_minsize();
|
|
|
|
return;
|
|
|
|
}
|
2014-02-13 22:03:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
Error ProjectExportDialog::export_platform(const String &p_platform, const String &p_path, bool p_debug, const String &p_password, bool p_quit_after) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
Ref<EditorExportPlatform> exporter = EditorImportExport::get_singleton()->get_export_platform(p_platform);
|
|
|
|
if (exporter.is_null()) {
|
|
|
|
ERR_PRINT("Invalid platform for export");
|
2015-11-25 06:28:51 +01:00
|
|
|
|
|
|
|
List<StringName> platforms;
|
|
|
|
EditorImportExport::get_singleton()->get_export_platforms(&platforms);
|
2016-05-04 15:28:37 +02:00
|
|
|
print_line("Valid export plaftorms are:");
|
2017-03-19 00:36:26 +01:00
|
|
|
for (List<StringName>::Element *E = platforms.front(); E; E = E->next())
|
|
|
|
print_line(" \"" + E->get() + "\"");
|
2015-11-25 06:28:51 +01:00
|
|
|
|
|
|
|
if (p_quit_after) {
|
|
|
|
OS::get_singleton()->set_exit_code(255);
|
|
|
|
get_tree()->quit();
|
|
|
|
}
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
return ERR_INVALID_PARAMETER;
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
Error err = exporter->export_project(p_path, p_debug);
|
|
|
|
if (err != OK) {
|
2016-05-04 03:25:37 +02:00
|
|
|
error->set_text(TTR("Error exporting project!"));
|
2015-04-08 19:02:13 +02:00
|
|
|
error->popup_centered_minsize();
|
2015-04-29 02:50:05 +02:00
|
|
|
ERR_PRINT("Exporting failed!");
|
|
|
|
if (p_quit_after) {
|
|
|
|
OS::get_singleton()->set_exit_code(255);
|
|
|
|
get_tree()->quit();
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
return ERR_CANT_CREATE;
|
|
|
|
} else {
|
|
|
|
if (p_quit_after) {
|
2014-11-06 01:20:42 +01:00
|
|
|
get_tree()->quit();
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::ok_pressed() {
|
2014-02-13 22:03:28 +01:00
|
|
|
//export pck
|
|
|
|
pck_export->popup_centered_ratio();
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
void ProjectExportDialog::custom_action(const String &) {
|
2014-02-13 22:03:28 +01:00
|
|
|
//real export
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
TreeItem *selected = platforms->get_selected();
|
|
|
|
if (!selected)
|
|
|
|
return;
|
|
|
|
|
|
|
|
String platform = selected->get_metadata(0);
|
|
|
|
Ref<EditorExportPlatform> exporter = EditorImportExport::get_singleton()->get_export_platform(platform);
|
|
|
|
|
|
|
|
if (exporter.is_null()) {
|
2017-03-19 00:36:26 +01:00
|
|
|
error->set_text(vformat(TTR("No exporter for platform '%s' yet."), platform));
|
2015-04-08 19:02:13 +02:00
|
|
|
error->popup_centered_minsize();
|
2014-02-10 02:10:30 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (platform.to_lower() == "android" && _check_android_setting(exporter) == false) {
|
2016-11-26 15:30:46 +01:00
|
|
|
// not filled all field for Android release
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
String extension = exporter->get_binary_extension();
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
file_export_password->set_editable(exporter->requires_password(exporter->is_debugging_enabled()));
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
file_export->clear_filters();
|
2017-03-19 00:36:26 +01:00
|
|
|
if (extension != "") {
|
|
|
|
file_export->add_filter("*." + extension);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
file_export->popup_centered_ratio();
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
LineEdit *ProjectExportDialog::_create_keystore_input(Control *container, const String &p_label, const String &name) {
|
2016-11-26 15:30:46 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
HBoxContainer *hb = memnew(HBoxContainer);
|
|
|
|
Label *lb = memnew(Label);
|
|
|
|
LineEdit *input = memnew(LineEdit);
|
2016-11-26 15:30:46 +01:00
|
|
|
|
|
|
|
lb->set_text(p_label);
|
2017-03-19 00:36:26 +01:00
|
|
|
lb->set_custom_minimum_size(Size2(140 * EDSCALE, 0));
|
2016-11-26 15:30:46 +01:00
|
|
|
lb->set_align(Label::ALIGN_RIGHT);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
input->set_custom_minimum_size(Size2(170 * EDSCALE, 0));
|
2016-11-26 15:30:46 +01:00
|
|
|
input->set_name(name);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
hb->add_constant_override("separation", 10 * EDSCALE);
|
2016-11-26 15:30:46 +01:00
|
|
|
hb->add_child(lb);
|
|
|
|
hb->add_child(input);
|
|
|
|
container->add_child(hb);
|
|
|
|
|
|
|
|
return input;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_create_android_keystore_window() {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
keystore_file_dialog = memnew(EditorFileDialog);
|
2016-11-26 15:30:46 +01:00
|
|
|
add_child(keystore_file_dialog);
|
|
|
|
keystore_file_dialog->set_mode(EditorFileDialog::MODE_OPEN_DIR);
|
|
|
|
keystore_file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
|
2017-03-19 00:36:26 +01:00
|
|
|
keystore_file_dialog->set_current_dir("res://");
|
2016-11-26 15:30:46 +01:00
|
|
|
|
|
|
|
keystore_file_dialog->set_title(TTR("Target Path:"));
|
2017-03-19 00:36:26 +01:00
|
|
|
keystore_file_dialog->connect("dir_selected", this, "_keystore_dir_selected");
|
2016-11-26 15:30:46 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
keystore_create_dialog = memnew(ConfirmationDialog);
|
|
|
|
VBoxContainer *vb = memnew(VBoxContainer);
|
|
|
|
vb->set_size(Size2(340 * EDSCALE, 0));
|
2016-11-26 15:30:46 +01:00
|
|
|
keystore_create_dialog->set_title(TTR("Create Android keystore"));
|
|
|
|
|
|
|
|
_create_keystore_input(vb, TTR("Full name"), "name");
|
|
|
|
_create_keystore_input(vb, TTR("Organizational unit"), "unit");
|
|
|
|
_create_keystore_input(vb, TTR("Organization"), "org");
|
|
|
|
_create_keystore_input(vb, TTR("City"), "city");
|
|
|
|
_create_keystore_input(vb, TTR("State"), "state");
|
|
|
|
_create_keystore_input(vb, TTR("2 letter country code"), "code");
|
|
|
|
_create_keystore_input(vb, TTR("User alias"), "alias");
|
2017-03-19 00:36:26 +01:00
|
|
|
LineEdit *pass = _create_keystore_input(vb, TTR("Password"), "pass");
|
2016-11-26 15:30:46 +01:00
|
|
|
pass->set_placeholder(TTR("at least 6 characters"));
|
|
|
|
_create_keystore_input(vb, TTR("File name"), "file");
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
Label *lb_path = memnew(Label);
|
|
|
|
LineEdit *path = memnew(LineEdit);
|
|
|
|
Button *btn = memnew(Button);
|
|
|
|
HBoxContainer *hb = memnew(HBoxContainer);
|
2016-11-26 15:30:46 +01:00
|
|
|
|
|
|
|
lb_path->set_text(TTR("Path : (better to save outside of project)"));
|
|
|
|
path->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
path->set_name("path");
|
|
|
|
btn->set_text(" .. ");
|
|
|
|
btn->connect("pressed", keystore_file_dialog, "popup_centered_ratio");
|
|
|
|
|
|
|
|
vb->add_spacer();
|
|
|
|
vb->add_child(lb_path);
|
|
|
|
hb->add_child(path);
|
|
|
|
hb->add_child(btn);
|
|
|
|
vb->add_child(hb);
|
|
|
|
|
|
|
|
keystore_create_dialog->add_child(vb);
|
|
|
|
keystore_create_dialog->set_child_rect(vb);
|
|
|
|
add_child(keystore_create_dialog);
|
|
|
|
|
|
|
|
keystore_create_dialog->connect("confirmed", this, "_create_android_keystore");
|
|
|
|
path->connect("text_changed", this, "_check_keystore_path");
|
|
|
|
|
|
|
|
confirm_keystore = memnew(ConfirmationDialog);
|
|
|
|
confirm_keystore->connect("confirmed", keystore_create_dialog, "popup_centered_minsize");
|
|
|
|
add_child(confirm_keystore);
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void ProjectExportDialog::_keystore_dir_selected(const String &path) {
|
2016-11-26 15:30:46 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
LineEdit *edit = keystore_create_dialog->find_node("path", true, false)->cast_to<LineEdit>();
|
2016-11-26 15:30:46 +01:00
|
|
|
edit->set_text(path.simplify_path());
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_keystore_created() {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (error->is_connected("popup_hide", this, "_keystore_created")) {
|
2016-11-26 15:30:46 +01:00
|
|
|
error->disconnect("popup_hide", this, "_keystore_created");
|
|
|
|
}
|
|
|
|
custom_action("export_pck");
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void ProjectExportDialog::_check_keystore_path(const String &path) {
|
2016-11-26 15:30:46 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
LineEdit *edit = keystore_create_dialog->find_node("path", true, false)->cast_to<LineEdit>();
|
2016-11-26 15:30:46 +01:00
|
|
|
bool exists = DirAccess::exists(path);
|
|
|
|
if (!exists) {
|
2017-03-19 00:36:26 +01:00
|
|
|
edit->add_color_override("font_color", Color(1, 0, 0, 1));
|
2016-11-26 15:30:46 +01:00
|
|
|
} else {
|
2017-03-19 00:36:26 +01:00
|
|
|
edit->add_color_override("font_color", Color(0, 1, 0, 1));
|
2016-11-26 15:30:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_create_android_keystore() {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
Vector<String> names = String("name,unit,org,city,state,code,alias,pass").split(",");
|
|
|
|
String path = keystore_create_dialog->find_node("path", true, false)->cast_to<LineEdit>()->get_text();
|
|
|
|
String file = keystore_create_dialog->find_node("file", true, false)->cast_to<LineEdit>()->get_text();
|
2016-11-26 15:30:46 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (file.ends_with(".keystore") == false) {
|
|
|
|
file += ".keystore";
|
2016-11-26 15:30:46 +01:00
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
String fullpath = path.plus_file(file);
|
|
|
|
String info = "CN=$name, OU=$unit, O=$org, L=$city, S=$state, C=$code";
|
2016-11-26 15:30:46 +01:00
|
|
|
Dictionary dic;
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < names.size(); i++) {
|
|
|
|
LineEdit *edit = keystore_create_dialog->find_node(names[i], true, false)->cast_to<LineEdit>();
|
|
|
|
dic[names[i]] = edit->get_text();
|
|
|
|
info = info.replace("$" + names[i], edit->get_text());
|
2016-11-26 15:30:46 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
String jarsigner = EditorSettings::get_singleton()->get("android/jarsigner");
|
|
|
|
String keytool = jarsigner.get_base_dir().plus_file("keytool");
|
|
|
|
String os_name = OS::get_singleton()->get_name();
|
|
|
|
if (os_name.to_lower() == "windows") {
|
|
|
|
keytool += ".exe";
|
2016-11-26 15:30:46 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
bool exist = FileAccess::exists(keytool);
|
2016-11-26 15:30:46 +01:00
|
|
|
if (!exist) {
|
|
|
|
error->set_text("Can't find 'keytool'");
|
|
|
|
error->popup_centered_minsize();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
List<String> args;
|
|
|
|
args.push_back("-genkey");
|
|
|
|
args.push_back("-v");
|
|
|
|
args.push_back("-keystore");
|
|
|
|
args.push_back(fullpath);
|
|
|
|
args.push_back("-alias");
|
|
|
|
args.push_back(dic["alias"]);
|
|
|
|
args.push_back("-storepass");
|
|
|
|
args.push_back(dic["pass"]);
|
|
|
|
args.push_back("-keypass");
|
|
|
|
args.push_back(dic["pass"]);
|
|
|
|
args.push_back("-keyalg");
|
|
|
|
args.push_back("RSA");
|
|
|
|
args.push_back("-keysize");
|
|
|
|
args.push_back("2048");
|
|
|
|
args.push_back("-validity");
|
|
|
|
args.push_back("10000");
|
|
|
|
args.push_back("-dname");
|
|
|
|
args.push_back(info);
|
|
|
|
int retval;
|
2017-03-19 00:36:26 +01:00
|
|
|
OS::get_singleton()->execute(keytool, args, true, NULL, NULL, &retval);
|
2016-11-26 15:30:46 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (retval == 0) { // success
|
2016-11-26 15:30:46 +01:00
|
|
|
platform_options->_edit_set("keystore/release", fullpath);
|
|
|
|
platform_options->_edit_set("keystore/release_user", dic["alias"]);
|
|
|
|
platform_options->_edit_set("keystore/release_password", dic["pass"]);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
error->set_text("Android keystore created at \n" + fullpath);
|
2016-11-26 15:30:46 +01:00
|
|
|
error->connect("popup_hide", this, "_keystore_created");
|
|
|
|
error->popup_centered_minsize();
|
|
|
|
} else { // fail
|
2017-03-19 00:36:26 +01:00
|
|
|
error->set_text("Fail to create android keystore at \n" + fullpath);
|
2016-11-26 15:30:46 +01:00
|
|
|
error->popup_centered_minsize();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
bool ProjectExportDialog::_check_android_setting(const Ref<EditorExportPlatform> &exporter) {
|
2016-11-26 15:30:46 +01:00
|
|
|
|
|
|
|
bool is_debugging = exporter->get("debug/debugging_enabled");
|
|
|
|
String release = exporter->get("keystore/release");
|
|
|
|
String user = exporter->get("keystore/release_user");
|
|
|
|
String password = exporter->get("keystore/release_password");
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (!is_debugging && (release == "" || user == "" || password == "")) {
|
|
|
|
if (release == "") {
|
2016-11-26 15:30:46 +01:00
|
|
|
confirm_keystore->set_text(TTR("Release keystore is not set.\nDo you want to create one?"));
|
|
|
|
confirm_keystore->popup_centered_minsize();
|
|
|
|
} else {
|
|
|
|
error->set_text(TTR("Fill Keystore/Release User and Release Password"));
|
|
|
|
error->popup_centered_minsize();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
void ProjectExportDialog::_group_selected() {
|
|
|
|
|
|
|
|
_update_group(); //?
|
2014-10-23 12:04:21 +02:00
|
|
|
|
|
|
|
_update_group_tree();
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
String ProjectExportDialog::_get_selected_group() {
|
|
|
|
|
|
|
|
TreeItem *sel = groups->get_selected();
|
|
|
|
if (!sel)
|
|
|
|
return String();
|
|
|
|
|
|
|
|
return sel->get_text(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_update_group_list() {
|
|
|
|
|
|
|
|
String current = _get_selected_group();
|
|
|
|
|
|
|
|
groups->clear();
|
|
|
|
List<StringName> grouplist;
|
|
|
|
EditorImportExport::get_singleton()->image_export_get_groups(&grouplist);
|
|
|
|
grouplist.sort_custom<StringName::AlphCompare>();
|
|
|
|
|
|
|
|
TreeItem *r = groups->create_item();
|
2017-03-19 00:36:26 +01:00
|
|
|
for (List<StringName>::Element *E = grouplist.front(); E; E = E->next()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
TreeItem *ti = groups->create_item(r);
|
2017-03-19 00:36:26 +01:00
|
|
|
ti->set_text(0, E->get());
|
|
|
|
ti->add_button(0, get_icon("Remove", "EditorIcons"));
|
|
|
|
if (E->get() == current) {
|
2014-02-10 02:10:30 +01:00
|
|
|
ti->select(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_update_group();
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void ProjectExportDialog::_select_group(const String &p_by_name) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
TreeItem *c = groups->get_root();
|
|
|
|
if (!c)
|
|
|
|
return;
|
2017-03-19 00:36:26 +01:00
|
|
|
c = c->get_children();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
if (!c)
|
|
|
|
return;
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
while (c) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (c->get_text(0) == p_by_name) {
|
2014-02-10 02:10:30 +01:00
|
|
|
c->select(0);
|
|
|
|
_update_group();
|
|
|
|
return;
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
c = c->get_next();
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_update_group() {
|
|
|
|
|
|
|
|
if (updating)
|
|
|
|
return;
|
2017-03-19 00:36:26 +01:00
|
|
|
updating = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (_get_selected_group() == "") {
|
2014-02-10 02:10:30 +01:00
|
|
|
group_options->hide();
|
|
|
|
//group_del->set_disabled(true);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
group_options->show();
|
|
|
|
//group_del->set_disabled(false);
|
|
|
|
StringName name = _get_selected_group();
|
|
|
|
group_image_action->select(EditorImportExport::get_singleton()->image_export_group_get_image_action(name));
|
|
|
|
group_atlas->set_pressed(EditorImportExport::get_singleton()->image_export_group_get_make_atlas(name));
|
|
|
|
group_shrink->set_val(EditorImportExport::get_singleton()->image_export_group_get_shrink(name));
|
|
|
|
group_lossy_quality->set_val(EditorImportExport::get_singleton()->image_export_group_get_lossy_quality(name));
|
|
|
|
if (group_atlas->is_pressed())
|
|
|
|
atlas_preview->show();
|
|
|
|
else
|
|
|
|
atlas_preview->hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
_update_group_tree();
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
updating = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
bool ProjectExportDialog::_update_group_treef(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, const Set<String> &p_extensions, const String &p_groups, const Map<StringName, int> &p_group_index) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
TreeItem *ti = group_images->create_item(p_parent);
|
2017-03-19 00:36:26 +01:00
|
|
|
ti->set_text(0, p_dir->get_name() + "/");
|
|
|
|
bool has_child = false;
|
|
|
|
for (int i = 0; i < p_dir->get_subdir_count(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (_update_group_treef(ti, p_dir->get_subdir(i), p_extensions, p_groups, p_group_index)) {
|
|
|
|
has_child = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
String filter = group_images_filter->get_text();
|
2014-02-10 02:10:30 +01:00
|
|
|
StringName current_group = _get_selected_group();
|
2017-03-19 00:36:26 +01:00
|
|
|
String check_text = TTR("Include");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < p_dir->get_file_count(); i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
String fname = p_dir->get_file(i);
|
|
|
|
if (p_extensions.has(fname.to_lower().extension())) {
|
|
|
|
String path = p_dir->get_file_path(i);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (filter != String() && path.find(filter) == -1)
|
2014-02-10 02:10:30 +01:00
|
|
|
continue;
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
has_child = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
TreeItem *file = group_images->create_item(ti);
|
2017-03-19 00:36:26 +01:00
|
|
|
file->set_text(0, fname);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
StringName g = EditorImportExport::get_singleton()->image_get_export_group(path);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (current_group == g || g == StringName()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
file->set_cell_mode(1, TreeItem::CELL_MODE_CHECK);
|
|
|
|
file->set_text(1, check_text);
|
|
|
|
file->set_editable(1, true);
|
|
|
|
file->set_checked(1, current_group == g);
|
2014-02-10 02:10:30 +01:00
|
|
|
} else {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
file->set_text(1, g);
|
|
|
|
file->set_editable(1, false);
|
|
|
|
file->set_selectable(1, false);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
file->set_metadata(0, path);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!has_child) {
|
|
|
|
memdelete(ti);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
void ProjectExportDialog::_update_group_tree() {
|
|
|
|
|
2014-06-11 15:41:03 +02:00
|
|
|
if (updating)
|
|
|
|
return;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
group_images->clear();
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (_get_selected_group() == "")
|
2014-02-10 02:10:30 +01:00
|
|
|
return;
|
2014-06-11 15:41:03 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
updating = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
print_line("****UGT");
|
|
|
|
List<String> img_extensions;
|
|
|
|
ImageLoader::get_recognized_extensions(&img_extensions);
|
|
|
|
Set<String> extensions;
|
2017-03-19 00:36:26 +01:00
|
|
|
for (List<String>::Element *E = img_extensions.front(); E; E = E->next()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
extensions.insert(E->get());
|
|
|
|
}
|
|
|
|
|
|
|
|
List<StringName> grouplist;
|
|
|
|
EditorImportExport::get_singleton()->image_export_get_groups(&grouplist);
|
|
|
|
grouplist.sort_custom<StringName::AlphCompare>();
|
2017-03-19 00:36:26 +01:00
|
|
|
Map<StringName, int> group_index;
|
|
|
|
group_index[StringName()] = 0;
|
|
|
|
int idx = 1;
|
|
|
|
String groupenum = "--";
|
|
|
|
for (List<StringName>::Element *E = grouplist.front(); E; E = E->next()) {
|
|
|
|
|
|
|
|
group_index[E->get()] = idx++;
|
|
|
|
groupenum += "," + String(E->get());
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
updating = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
_update_group_treef(NULL, EditorFileSystem::get_singleton()->get_filesystem(), extensions, groupenum, group_index);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_group_changed(Variant v) {
|
|
|
|
|
|
|
|
if (updating)
|
|
|
|
return;
|
2017-03-19 00:36:26 +01:00
|
|
|
if (_get_selected_group() == "")
|
2014-02-10 02:10:30 +01:00
|
|
|
return;
|
2017-03-19 00:36:26 +01:00
|
|
|
updating = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
StringName name = _get_selected_group();
|
2016-05-04 03:25:37 +02:00
|
|
|
EditorNode::get_undo_redo()->create_action(TTR("Change Image Group"));
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(), "image_export_group_set_image_action", name, group_image_action->get_selected());
|
|
|
|
EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(), "image_export_group_set_make_atlas", name, group_atlas->is_pressed());
|
|
|
|
EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(), "image_export_group_set_shrink", name, group_shrink->get_val());
|
|
|
|
EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(), "image_export_group_set_lossy_quality", name, group_lossy_quality->get_val());
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(), "image_export_group_set_image_action", name, EditorImportExport::get_singleton()->image_export_group_get_image_action(name));
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(), "image_export_group_set_make_atlas", name, EditorImportExport::get_singleton()->image_export_group_get_make_atlas(name));
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(), "image_export_group_set_shrink", name, EditorImportExport::get_singleton()->image_export_group_get_shrink(name));
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(), "image_export_group_set_lossy_quality", name, EditorImportExport::get_singleton()->image_export_group_get_lossy_quality(name));
|
|
|
|
EditorNode::get_undo_redo()->add_do_method(this, "_update_group");
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(this, "_update_group");
|
|
|
|
EditorNode::get_undo_redo()->add_do_method(this, "_save_export_cfg");
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(this, "_save_export_cfg");
|
2014-02-10 02:10:30 +01:00
|
|
|
EditorNode::get_undo_redo()->commit_action();
|
2017-03-19 00:36:26 +01:00
|
|
|
updating = false;
|
2014-10-23 12:04:21 +02:00
|
|
|
// update atlas preview button
|
|
|
|
_update_group();
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_group_item_edited() {
|
|
|
|
|
|
|
|
TreeItem *item = group_images->get_edited();
|
|
|
|
if (!item)
|
|
|
|
return;
|
2017-03-19 00:36:26 +01:00
|
|
|
if (_get_selected_group() == String())
|
2014-02-10 02:10:30 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
StringName path = item->get_metadata(0);
|
|
|
|
String group;
|
|
|
|
if (item->is_checked(1)) {
|
2017-03-19 00:36:26 +01:00
|
|
|
group = _get_selected_group();
|
2014-02-10 02:10:30 +01:00
|
|
|
} else {
|
2017-03-19 00:36:26 +01:00
|
|
|
group = String();
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
print_line("changed " + path + " to group: " + group);
|
2016-05-04 03:25:37 +02:00
|
|
|
EditorNode::get_undo_redo()->create_action(TTR("Change Image Group"));
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(), "image_add_to_export_group", path, group);
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(), "image_add_to_export_group", path, EditorImportExport::get_singleton()->image_get_export_group(path));
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(this, "_update_group_tree");
|
|
|
|
EditorNode::get_undo_redo()->add_do_method(this, "_update_group_tree");
|
|
|
|
EditorNode::get_undo_redo()->add_do_method(this, "_save_export_cfg");
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(this, "_save_export_cfg");
|
2014-02-10 02:10:30 +01:00
|
|
|
EditorNode::get_undo_redo()->commit_action();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_group_add() {
|
|
|
|
|
|
|
|
String name = group_new_name->get_text();
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (name == "") {
|
2014-02-10 02:10:30 +01:00
|
|
|
group_new_name_error->show();
|
2016-05-19 00:08:12 +02:00
|
|
|
group_new_name_error->set_text(TTR("Group name can't be empty!"));
|
2014-02-10 02:10:30 +01:00
|
|
|
return;
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
if (name.find("/") != -1 || name.find(":") != -1 || name.find(",") != -1 || name.find("-") != -1) {
|
2016-05-19 00:08:12 +02:00
|
|
|
group_new_name_error->set_text(TTR("Invalid character in group name!"));
|
2014-02-10 02:10:30 +01:00
|
|
|
group_new_name_error->show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (EditorImportExport::get_singleton()->image_export_has_group(name)) {
|
2016-05-19 00:08:12 +02:00
|
|
|
group_new_name_error->set_text(TTR("Group name already exists!"));
|
2014-02-10 02:10:30 +01:00
|
|
|
group_new_name_error->show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
group_new_name_error->hide();
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
String current = _get_selected_group();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-05-04 03:25:37 +02:00
|
|
|
EditorNode::get_undo_redo()->create_action(TTR("Add Image Group"));
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(), "image_export_group_create", name);
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(), "image_export_group_remove", name);
|
|
|
|
EditorNode::get_undo_redo()->add_do_method(this, "_update_group_list");
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(this, "_update_group_list");
|
|
|
|
EditorNode::get_undo_redo()->add_do_method(this, "_select_group", name);
|
|
|
|
if (current != "")
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(this, "_select_group", current);
|
|
|
|
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(this, "_update_group_tree");
|
|
|
|
EditorNode::get_undo_redo()->add_do_method(this, "_update_group_tree");
|
|
|
|
EditorNode::get_undo_redo()->add_do_method(this, "_save_export_cfg");
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(this, "_save_export_cfg");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
EditorNode::get_undo_redo()->commit_action();
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void ProjectExportDialog::_group_del(Object *p_item, int p_column, int p_button) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
TreeItem *item = p_item->cast_to<TreeItem>();
|
|
|
|
if (!item)
|
|
|
|
return;
|
|
|
|
String name = item->get_text(0);
|
|
|
|
|
2016-05-04 03:25:37 +02:00
|
|
|
EditorNode::get_undo_redo()->create_action(TTR("Delete Image Group"));
|
2014-02-10 02:10:30 +01:00
|
|
|
List<StringName> images_used;
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorImportExport::get_singleton()->image_export_get_images_in_group(name, &images_used);
|
|
|
|
for (List<StringName>::Element *E = images_used.front(); E; E = E->next()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(), "image_add_to_export_group", E->get(), StringName());
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(), "image_export_group_remove", name);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(), "image_export_group_create", name);
|
|
|
|
for (List<StringName>::Element *E = images_used.front(); E; E = E->next()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(), "image_add_to_export_group", E->get(), name);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(), "image_export_group_set_image_action", name, EditorImportExport::get_singleton()->image_export_group_get_image_action(name));
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(), "image_export_group_set_make_atlas", name, EditorImportExport::get_singleton()->image_export_group_get_make_atlas(name));
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(), "image_export_group_set_shrink", name, EditorImportExport::get_singleton()->image_export_group_get_shrink(name));
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(), "image_export_group_set_lossy_quality", name, EditorImportExport::get_singleton()->image_export_group_get_lossy_quality(name));
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorNode::get_undo_redo()->add_do_method(this, "_update_group_list");
|
|
|
|
EditorNode::get_undo_redo()->add_do_method(this, "_update_group");
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(this, "_update_group_list");
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(this, "_select_group", name);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorNode::get_undo_redo()->add_do_method(this, "_update_group_tree");
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(this, "_update_group_tree");
|
|
|
|
EditorNode::get_undo_redo()->add_do_method(this, "_save_export_cfg");
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(this, "_save_export_cfg");
|
2014-02-10 02:10:30 +01:00
|
|
|
EditorNode::get_undo_redo()->commit_action();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_group_select_all() {
|
|
|
|
|
|
|
|
String group = _get_selected_group();
|
2017-03-19 00:36:26 +01:00
|
|
|
if (group == "")
|
2014-02-10 02:10:30 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
TreeItem *item = group_images->get_root();
|
|
|
|
if (!item)
|
|
|
|
return;
|
|
|
|
|
|
|
|
List<StringName> items;
|
2017-03-19 00:36:26 +01:00
|
|
|
while (item) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (item->get_cell_mode(1) == TreeItem::CELL_MODE_CHECK && !item->is_checked(1))
|
2014-02-10 02:10:30 +01:00
|
|
|
items.push_back(item->get_metadata(0));
|
2017-03-19 00:36:26 +01:00
|
|
|
item = item->get_next_visible();
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (items.size() == 0)
|
2014-02-10 02:10:30 +01:00
|
|
|
return;
|
|
|
|
|
2016-05-04 03:25:37 +02:00
|
|
|
EditorNode::get_undo_redo()->create_action(TTR("Select All"));
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (List<StringName>::Element *E = items.front(); E; E = E->next()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(), "image_add_to_export_group", E->get(), group);
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(), "image_add_to_export_group", E->get(), String());
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorNode::get_undo_redo()->add_do_method(this, "_update_group_tree");
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(this, "_update_group_tree");
|
|
|
|
EditorNode::get_undo_redo()->add_do_method(this, "_save_export_cfg");
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(this, "_save_export_cfg");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
EditorNode::get_undo_redo()->commit_action();
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void ProjectExportDialog::_group_select_none() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
String group = _get_selected_group();
|
2017-03-19 00:36:26 +01:00
|
|
|
if (group == "")
|
2014-02-10 02:10:30 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
TreeItem *item = group_images->get_root();
|
|
|
|
if (!item)
|
|
|
|
return;
|
|
|
|
|
|
|
|
List<StringName> items;
|
2017-03-19 00:36:26 +01:00
|
|
|
while (item) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (item->get_cell_mode(1) == TreeItem::CELL_MODE_CHECK && item->is_checked(1))
|
2014-02-10 02:10:30 +01:00
|
|
|
items.push_back(item->get_metadata(0));
|
2017-03-19 00:36:26 +01:00
|
|
|
item = item->get_next_visible();
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (items.size() == 0)
|
2014-02-10 02:10:30 +01:00
|
|
|
return;
|
|
|
|
|
2016-05-04 03:25:37 +02:00
|
|
|
EditorNode::get_undo_redo()->create_action(TTR("Select All"));
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (List<StringName>::Element *E = items.front(); E; E = E->next()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorNode::get_undo_redo()->add_do_method(EditorImportExport::get_singleton(), "image_add_to_export_group", E->get(), String());
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(EditorImportExport::get_singleton(), "image_add_to_export_group", E->get(), group);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorNode::get_undo_redo()->add_do_method(this, "_update_group_tree");
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(this, "_update_group_tree");
|
|
|
|
EditorNode::get_undo_redo()->add_do_method(this, "_save_export_cfg");
|
|
|
|
EditorNode::get_undo_redo()->add_undo_method(this, "_save_export_cfg");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
EditorNode::get_undo_redo()->commit_action();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_group_atlas_preview() {
|
|
|
|
|
|
|
|
StringName group = _get_selected_group();
|
|
|
|
if (!group)
|
|
|
|
return;
|
|
|
|
|
|
|
|
atlas_preview_frame->set_texture(Ref<Texture>()); //clear previous
|
|
|
|
|
|
|
|
List<StringName> images;
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorImportExport::get_singleton()->image_export_get_images_in_group(group, &images);
|
2014-02-10 02:10:30 +01:00
|
|
|
images.sort_custom<StringName::AlphCompare>();
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
String dst_file = EditorSettings::get_singleton()->get_settings_path() + "/tmp/atlas-preview.tex";
|
|
|
|
Ref<ResourceImportMetadata> imd = memnew(ResourceImportMetadata);
|
2014-02-10 02:10:30 +01:00
|
|
|
//imd->set_editor();
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (List<StringName>::Element *F = images.front(); F; F = F->next()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
imd->add_source(EditorImportPlugin::validate_source_path(F->get()));
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
int flags = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2014-06-11 15:41:03 +02:00
|
|
|
if (Globals::get_singleton()->get("image_loader/filter"))
|
2017-03-19 00:36:26 +01:00
|
|
|
flags |= EditorTextureImportPlugin::IMAGE_FLAG_FILTER;
|
2014-06-11 15:41:03 +02:00
|
|
|
if (!Globals::get_singleton()->get("image_loader/gen_mipmaps"))
|
2017-03-19 00:36:26 +01:00
|
|
|
flags |= EditorTextureImportPlugin::IMAGE_FLAG_NO_MIPMAPS;
|
2014-06-11 15:41:03 +02:00
|
|
|
if (!Globals::get_singleton()->get("image_loader/repeat"))
|
2017-03-19 00:36:26 +01:00
|
|
|
flags |= EditorTextureImportPlugin::IMAGE_FLAG_REPEAT;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
flags |= EditorTextureImportPlugin::IMAGE_FLAG_FIX_BORDER_ALPHA;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
imd->set_option("format", EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSLESS);
|
|
|
|
imd->set_option("flags", flags);
|
|
|
|
imd->set_option("quality", 0.7);
|
|
|
|
imd->set_option("atlas", true);
|
|
|
|
imd->set_option("crop", true);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-06-02 15:03:58 +02:00
|
|
|
Ref<EditorTextureImportPlugin> plugin = EditorImportExport::get_singleton()->get_import_plugin_by_name("texture");
|
2017-03-19 00:36:26 +01:00
|
|
|
Error err = plugin->import2(dst_file, imd, EditorExportPlatform::IMAGE_COMPRESSION_NONE, true);
|
2014-02-10 02:10:30 +01:00
|
|
|
if (err) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
EditorNode::add_io_error(TTR("Error saving atlas:") + " " + dst_file.get_file());
|
2014-02-10 02:10:30 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ref<Texture> tex = ResourceLoader::load(dst_file);
|
|
|
|
atlas_preview_frame->set_texture(tex); //clear previous
|
2017-03-19 00:36:26 +01:00
|
|
|
atlas_preview_dialog->set_title(TTR("Atlas Preview") + " (" + itos(tex->get_width()) + "x" + itos(tex->get_height()) + ")");
|
2014-02-10 02:10:30 +01:00
|
|
|
atlas_preview_dialog->popup_centered_ratio(0.9);
|
|
|
|
}
|
|
|
|
|
2014-06-11 15:41:03 +02:00
|
|
|
void ProjectExportDialog::_update_script() {
|
|
|
|
|
|
|
|
if (updating_script)
|
|
|
|
return;
|
2017-03-19 00:36:26 +01:00
|
|
|
updating_script = true;
|
2014-06-11 15:41:03 +02:00
|
|
|
script_mode->select(EditorImportExport::get_singleton()->script_get_action());
|
|
|
|
script_key->set_text(EditorImportExport::get_singleton()->script_get_encryption_key());
|
2017-03-19 00:36:26 +01:00
|
|
|
updating_script = false;
|
2014-06-11 15:41:03 +02:00
|
|
|
}
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void ProjectExportDialog::_image_filter_changed(String) {
|
|
|
|
|
|
|
|
_update_group_tree();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExportDialog::_bind_methods() {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ObjectTypeDB::bind_method(_MD("_rescan"), &ProjectExportDialog::_rescan);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_tree_changed"), &ProjectExportDialog::_tree_changed);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_scan_finished"), &ProjectExportDialog::_scan_finished);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_platform_selected"), &ProjectExportDialog::_platform_selected);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_prop_edited"), &ProjectExportDialog::_prop_edited);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_export_mode_changed"), &ProjectExportDialog::_export_mode_changed);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_filters_edited"), &ProjectExportDialog::_filters_edited);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_filters_exclude_edited"), &ProjectExportDialog::_filters_exclude_edited);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_export_action"), &ProjectExportDialog::_export_action);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_export_action_pck"), &ProjectExportDialog::_export_action_pck);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_quality_edited"), &ProjectExportDialog::_quality_edited);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_shrink_edited"), &ProjectExportDialog::_shrink_edited);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_image_export_edited"), &ProjectExportDialog::_image_export_edited);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_format_toggled"), &ProjectExportDialog::_format_toggled);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_group_changed"), &ProjectExportDialog::_group_changed);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_group_add"), &ProjectExportDialog::_group_add);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_group_del"), &ProjectExportDialog::_group_del);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_group_selected"), &ProjectExportDialog::_group_selected);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_update_group"), &ProjectExportDialog::_update_group);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_update_group_list"), &ProjectExportDialog::_update_group_list);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_select_group"), &ProjectExportDialog::_select_group);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_update_group_tree"), &ProjectExportDialog::_update_group_tree);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_group_item_edited"), &ProjectExportDialog::_group_item_edited);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_save_export_cfg"), &ProjectExportDialog::_save_export_cfg);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_image_filter_changed"), &ProjectExportDialog::_image_filter_changed);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_group_atlas_preview"), &ProjectExportDialog::_group_atlas_preview);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_group_select_all"), &ProjectExportDialog::_group_select_all);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_group_select_none"), &ProjectExportDialog::_group_select_none);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_script_edited"), &ProjectExportDialog::_script_edited);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_update_script"), &ProjectExportDialog::_update_script);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_sample_convert_edited"), &ProjectExportDialog::_sample_convert_edited);
|
|
|
|
|
|
|
|
ObjectTypeDB::bind_method(_MD("export_platform"), &ProjectExportDialog::export_platform);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_create_android_keystore"), &ProjectExportDialog::_create_android_keystore);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_check_keystore_path"), &ProjectExportDialog::_check_keystore_path);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_keystore_dir_selected"), &ProjectExportDialog::_keystore_dir_selected);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_keystore_created"), &ProjectExportDialog::_keystore_created);
|
|
|
|
|
|
|
|
// ADD_SIGNAL(MethodInfo("instance"));
|
|
|
|
// ADD_SIGNAL(MethodInfo("open"));
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ProjectExportDialog::ProjectExportDialog(EditorNode *p_editor) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
editor = p_editor;
|
2016-05-04 03:25:37 +02:00
|
|
|
set_title(TTR("Project Export Settings"));
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
sections = memnew(TabContainer);
|
2014-02-10 02:10:30 +01:00
|
|
|
add_child(sections);
|
|
|
|
set_child_rect(sections);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
VBoxContainer *pvbox = memnew(VBoxContainer);
|
2014-02-10 02:10:30 +01:00
|
|
|
sections->add_child(pvbox);
|
2016-05-04 03:25:37 +02:00
|
|
|
pvbox->set_name(TTR("Target"));
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
HBoxContainer *phbox = memnew(HBoxContainer);
|
2014-02-10 02:10:30 +01:00
|
|
|
pvbox->add_child(phbox);
|
|
|
|
phbox->set_v_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
plat_errors = memnew(HBoxContainer);
|
2014-02-10 02:10:30 +01:00
|
|
|
pvbox->add_child(plat_errors);
|
2017-03-19 00:36:26 +01:00
|
|
|
platform_error_string = memnew(Label);
|
2014-02-10 02:10:30 +01:00
|
|
|
platform_error_string->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
plat_errors->add_child(platform_error_string);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
VBoxContainer *vb = memnew(VBoxContainer);
|
2014-02-10 02:10:30 +01:00
|
|
|
vb->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
vb->set_v_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
phbox->add_child(vb);
|
2017-03-19 00:36:26 +01:00
|
|
|
platforms = memnew(Tree);
|
2014-02-10 02:10:30 +01:00
|
|
|
platforms->set_hide_root(true);
|
2017-03-19 00:36:26 +01:00
|
|
|
vb->add_margin_child(TTR("Export to Platform"), platforms, true);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
platforms->connect("cell_selected", this, "_platform_selected");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
vb = memnew(VBoxContainer);
|
2014-02-10 02:10:30 +01:00
|
|
|
phbox->add_child(vb);
|
|
|
|
vb->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
vb->set_v_size_flags(SIZE_EXPAND_FILL);
|
2017-03-19 00:36:26 +01:00
|
|
|
platform_options = memnew(PropertyEditor());
|
2014-02-10 02:10:30 +01:00
|
|
|
platform_options->hide_top_label();
|
2017-03-19 00:36:26 +01:00
|
|
|
vb->add_margin_child(TTR("Options"), platform_options, true);
|
|
|
|
platform_options->connect("property_edited", this, "_prop_edited");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
//////////////////
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
vb = memnew(VBoxContainer);
|
2016-05-04 03:25:37 +02:00
|
|
|
vb->set_name(TTR("Resources"));
|
2014-02-10 02:10:30 +01:00
|
|
|
sections->add_child(vb);
|
2015-12-04 14:18:28 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
export_mode = memnew(OptionButton);
|
2016-05-04 03:25:37 +02:00
|
|
|
export_mode->add_item(TTR("Export selected resources (including dependencies)."));
|
|
|
|
export_mode->add_item(TTR("Export all resources in the project."));
|
|
|
|
export_mode->add_item(TTR("Export all files in the project directory."));
|
2017-03-19 00:36:26 +01:00
|
|
|
export_mode->connect("item_selected", this, "_export_mode_changed");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
vb->add_margin_child(TTR("Export Mode:"), export_mode);
|
2015-12-04 14:18:28 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
tree_vb = memnew(VBoxContainer);
|
2014-02-10 02:10:30 +01:00
|
|
|
vb->add_child(tree_vb);
|
|
|
|
tree_vb->set_v_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
tree = memnew(Tree);
|
|
|
|
tree_vb->add_margin_child(TTR("Resources to Export:"), tree, true);
|
2014-02-17 20:43:22 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
tree->set_v_size_flags(SIZE_EXPAND_FILL);
|
2017-03-19 00:36:26 +01:00
|
|
|
tree->connect("item_edited", this, "_tree_changed");
|
2014-02-10 02:10:30 +01:00
|
|
|
tree->set_columns(2);
|
|
|
|
tree->set_column_titles_visible(true);
|
2017-03-19 00:36:26 +01:00
|
|
|
tree->set_column_title(0, TTR("File"));
|
|
|
|
tree->set_column_title(1, TTR("Action"));
|
|
|
|
tree->set_column_expand(1, false);
|
|
|
|
tree->set_column_min_width(1, 90);
|
|
|
|
|
|
|
|
filters = memnew(LineEdit);
|
|
|
|
vb->add_margin_child(TTR("Filters to export non-resource files (comma-separated, e.g.: *.json, *.txt):"), filters);
|
|
|
|
filters->connect("text_changed", this, "_filters_edited");
|
|
|
|
filters_exclude = memnew(LineEdit);
|
|
|
|
vb->add_margin_child(TTR("Filters to exclude from export (comma-separated, e.g.: *.json, *.txt):"), filters_exclude);
|
|
|
|
filters_exclude->connect("text_changed", this, "_filters_exclude_edited");
|
|
|
|
|
|
|
|
convert_text_scenes = memnew(CheckButton);
|
2016-05-21 01:18:35 +02:00
|
|
|
convert_text_scenes->set_text(TTR("Convert text scenes to binary on export."));
|
2015-12-04 14:18:28 +01:00
|
|
|
vb->add_child(convert_text_scenes);
|
2017-03-19 00:36:26 +01:00
|
|
|
convert_text_scenes->connect("toggled", this, "_export_mode_changed");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
image_vb = memnew(VBoxContainer);
|
2016-05-04 03:25:37 +02:00
|
|
|
image_vb->set_name(TTR("Images"));
|
2017-03-19 00:36:26 +01:00
|
|
|
image_action = memnew(OptionButton);
|
2016-05-04 03:25:37 +02:00
|
|
|
image_action->add_item(TTR("Keep Original"));
|
|
|
|
image_action->add_item(TTR("Compress for Disk (Lossy, WebP)"));
|
|
|
|
image_action->add_item(TTR("Compress for RAM (BC/PVRTC/ETC)"));
|
2017-03-19 00:36:26 +01:00
|
|
|
image_vb->add_margin_child(TTR("Convert Images (*.png):"), image_action);
|
|
|
|
HBoxContainer *qhb = memnew(HBoxContainer);
|
|
|
|
image_quality = memnew(HSlider);
|
2014-02-10 02:10:30 +01:00
|
|
|
qhb->add_child(image_quality);
|
|
|
|
image_quality->set_h_size_flags(SIZE_EXPAND_FILL);
|
2017-03-19 00:36:26 +01:00
|
|
|
SpinBox *qspin = memnew(SpinBox);
|
2014-02-10 02:10:30 +01:00
|
|
|
image_quality->share(qspin);
|
|
|
|
qhb->add_child(qspin);
|
|
|
|
image_quality->set_min(0);
|
|
|
|
image_quality->set_max(1);
|
|
|
|
image_quality->set_step(0.01);
|
2017-03-19 00:36:26 +01:00
|
|
|
image_vb->add_margin_child(TTR("Compress for Disk (Lossy) Quality:"), qhb);
|
|
|
|
image_shrink = memnew(SpinBox);
|
2014-02-26 14:08:17 +01:00
|
|
|
image_shrink->set_min(1);
|
|
|
|
image_shrink->set_max(8);
|
2015-10-01 21:25:36 +02:00
|
|
|
image_shrink->set_step(0.1);
|
2017-03-19 00:36:26 +01:00
|
|
|
image_vb->add_margin_child(TTR("Shrink All Images:"), image_shrink);
|
2014-02-10 02:10:30 +01:00
|
|
|
sections->add_child(image_vb);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
image_formats = memnew(Tree);
|
2014-02-10 02:10:30 +01:00
|
|
|
image_formats->set_hide_root(true);
|
|
|
|
TreeItem *root = image_formats->create_item(NULL);
|
|
|
|
List<String> fmts;
|
|
|
|
ImageLoader::get_recognized_extensions(&fmts);
|
2017-03-19 00:36:26 +01:00
|
|
|
for (List<String>::Element *E = fmts.front(); E; E = E->next()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
TreeItem *fmt = image_formats->create_item(root);
|
2017-03-19 00:36:26 +01:00
|
|
|
fmt->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
|
|
|
|
fmt->set_text(0, E->get());
|
|
|
|
fmt->set_editable(0, true);
|
2014-02-10 02:10:30 +01:00
|
|
|
formats.push_back(fmt);
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
image_vb->add_margin_child(TTR("Compress Formats:") + " ", image_formats, true);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
/// groups
|
2017-03-19 00:36:26 +01:00
|
|
|
HBoxContainer *group_hb = memnew(HBoxContainer);
|
2016-05-04 03:25:37 +02:00
|
|
|
group_hb->set_name(TTR("Image Groups"));
|
2014-02-10 02:10:30 +01:00
|
|
|
sections->add_child(group_hb);
|
2017-03-19 00:36:26 +01:00
|
|
|
VBoxContainer *group_vb_left = memnew(VBoxContainer);
|
2014-02-10 02:10:30 +01:00
|
|
|
group_hb->add_child(group_vb_left);
|
|
|
|
|
|
|
|
VBoxContainer *gvb = memnew(VBoxContainer);
|
|
|
|
HBoxContainer *ghb = memnew(HBoxContainer);
|
|
|
|
gvb->add_child(ghb);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
group_new_name = memnew(LineEdit);
|
2014-02-10 02:10:30 +01:00
|
|
|
group_new_name->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
ghb->add_child(group_new_name);
|
|
|
|
|
|
|
|
group_add = memnew(ToolButton);
|
2017-03-19 00:36:26 +01:00
|
|
|
group_add->connect("pressed", this, "_group_add");
|
2014-02-10 02:10:30 +01:00
|
|
|
ghb->add_child(group_add);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
group_new_name_error = memnew(Label);
|
|
|
|
group_new_name_error->add_color_override("font_color", Color(1, 0.4, 0.4));
|
2014-02-10 02:10:30 +01:00
|
|
|
gvb->add_child(group_new_name_error);
|
|
|
|
group_new_name_error->hide();
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
groups = memnew(Tree);
|
2014-02-10 02:10:30 +01:00
|
|
|
groups->set_v_size_flags(SIZE_EXPAND_FILL);
|
2017-03-19 00:36:26 +01:00
|
|
|
groups->connect("cell_selected", this, "_group_selected", varray(), CONNECT_DEFERRED);
|
|
|
|
groups->connect("button_pressed", this, "_group_del", varray(), CONNECT_DEFERRED);
|
2014-02-10 02:10:30 +01:00
|
|
|
groups->set_hide_root(true);
|
|
|
|
gvb->add_child(groups);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
group_vb_left->add_margin_child(TTR("Groups:"), gvb, true);
|
2014-02-10 02:10:30 +01:00
|
|
|
//group_vb_left->add_child( memnew( HSeparator));
|
|
|
|
group_options = memnew(VBoxContainer);
|
|
|
|
group_vb_left->add_child(group_options);
|
|
|
|
|
|
|
|
group_image_action = memnew(OptionButton);
|
2016-05-04 03:25:37 +02:00
|
|
|
group_image_action->add_item(TTR("Default"));
|
|
|
|
group_image_action->add_item(TTR("Compress Disk"));
|
|
|
|
group_image_action->add_item(TTR("Compress RAM"));
|
|
|
|
group_image_action->add_item(TTR("Keep Original"));
|
2017-03-19 00:36:26 +01:00
|
|
|
group_options->add_margin_child(TTR("Compress Mode:"), group_image_action);
|
|
|
|
group_image_action->connect("item_selected", this, "_group_changed");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
group_lossy_quality = memnew(HSlider);
|
2014-02-10 02:10:30 +01:00
|
|
|
group_lossy_quality->set_min(0.1);
|
|
|
|
group_lossy_quality->set_max(1.0);
|
2016-05-13 14:39:29 +02:00
|
|
|
group_lossy_quality->set_step(0.01);
|
2014-02-10 02:10:30 +01:00
|
|
|
group_lossy_quality->set_val(0.7);
|
2017-03-19 00:36:26 +01:00
|
|
|
group_lossy_quality->connect("value_changed", this, "_quality_edited");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
HBoxContainer *gqhb = memnew(HBoxContainer);
|
|
|
|
SpinBox *gqspin = memnew(SpinBox);
|
2016-05-13 14:39:29 +02:00
|
|
|
group_lossy_quality->share(gqspin);
|
|
|
|
group_lossy_quality->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
gqhb->add_child(group_lossy_quality);
|
|
|
|
gqhb->add_child(gqspin);
|
2017-03-19 00:36:26 +01:00
|
|
|
group_options->add_margin_child(TTR("Lossy Quality:"), gqhb);
|
2016-05-13 14:39:29 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
group_atlas = memnew(CheckButton);
|
2016-05-04 03:25:37 +02:00
|
|
|
group_atlas->set_pressed(true);
|
2017-03-19 00:36:26 +01:00
|
|
|
group_options->add_margin_child(TTR("Atlas:"), group_atlas);
|
|
|
|
group_atlas->connect("toggled", this, "_group_changed");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
group_shrink = memnew(SpinBox);
|
|
|
|
group_shrink->set_min(1);
|
|
|
|
group_shrink->set_max(8);
|
|
|
|
group_shrink->set_val(1);
|
2015-10-01 21:25:36 +02:00
|
|
|
group_shrink->set_step(0.001);
|
2017-03-19 00:36:26 +01:00
|
|
|
group_options->add_margin_child(TTR("Shrink By:"), group_shrink);
|
|
|
|
group_shrink->connect("value_changed", this, "_group_changed");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
atlas_preview = memnew(Button);
|
2016-05-04 03:25:37 +02:00
|
|
|
atlas_preview->set_text(TTR("Preview Atlas"));
|
2014-02-10 02:10:30 +01:00
|
|
|
group_options->add_child(atlas_preview);
|
|
|
|
atlas_preview->show();
|
2017-03-19 00:36:26 +01:00
|
|
|
atlas_preview->connect("pressed", this, "_group_atlas_preview");
|
|
|
|
Control *ec = memnew(Control);
|
|
|
|
ec->set_custom_minimum_size(Size2(150, 1));
|
2014-02-10 02:10:30 +01:00
|
|
|
gvb->add_child(ec);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
VBoxContainer *group_vb_right = memnew(VBoxContainer);
|
2014-02-10 02:10:30 +01:00
|
|
|
group_hb->add_child(group_vb_right);
|
|
|
|
group_vb_right->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
HBoxContainer *filter_hb = memnew(HBoxContainer);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
group_images_filter = memnew(LineEdit);
|
|
|
|
group_vb_right->add_margin_child(TTR("Image Filter:"), filter_hb);
|
2014-02-10 02:10:30 +01:00
|
|
|
filter_hb->add_child(group_images_filter);
|
|
|
|
group_images_filter->set_h_size_flags(SIZE_EXPAND_FILL);
|
2017-03-19 00:36:26 +01:00
|
|
|
group_images_filter->connect("text_changed", this, "_image_filter_changed");
|
|
|
|
group_images = memnew(Tree);
|
2014-02-10 02:10:30 +01:00
|
|
|
group_images->set_v_size_flags(SIZE_EXPAND_FILL);
|
2017-03-19 00:36:26 +01:00
|
|
|
group_vb_right->add_margin_child(TTR("Images:"), group_images, true);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
Button *filt_select_all = memnew(Button);
|
2016-05-04 03:25:37 +02:00
|
|
|
filt_select_all->set_text(TTR("Select All"));
|
2014-02-10 02:10:30 +01:00
|
|
|
filter_hb->add_child(filt_select_all);
|
2017-03-19 00:36:26 +01:00
|
|
|
filt_select_all->connect("pressed", this, "_group_select_all");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
Button *filt_select_none = memnew(Button);
|
2016-05-04 03:25:37 +02:00
|
|
|
filt_select_none->set_text(TTR("Select None"));
|
2014-02-10 02:10:30 +01:00
|
|
|
filter_hb->add_child(filt_select_none);
|
2017-03-19 00:36:26 +01:00
|
|
|
filt_select_none->connect("pressed", this, "_group_select_none");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
atlas_preview_dialog = memnew(AcceptDialog);
|
|
|
|
ScrollContainer *scroll = memnew(ScrollContainer);
|
2014-02-10 02:10:30 +01:00
|
|
|
atlas_preview_dialog->add_child(scroll);
|
|
|
|
atlas_preview_dialog->set_child_rect(scroll);
|
2017-03-19 00:36:26 +01:00
|
|
|
atlas_preview_frame = memnew(TextureFrame);
|
2014-02-10 02:10:30 +01:00
|
|
|
scroll->add_child(atlas_preview_frame);
|
|
|
|
add_child(atlas_preview_dialog);
|
|
|
|
|
|
|
|
group_images->set_hide_root(true);
|
|
|
|
group_images->set_columns(2);
|
2017-03-19 00:36:26 +01:00
|
|
|
group_images->set_column_expand(0, true);
|
|
|
|
group_images->set_column_expand(1, false);
|
|
|
|
group_images->set_column_min_width(1, 100);
|
2014-02-10 02:10:30 +01:00
|
|
|
group_images->set_column_titles_visible(true);
|
2017-03-19 00:36:26 +01:00
|
|
|
group_images->set_column_title(0, TTR("Images"));
|
|
|
|
group_images->set_column_title(1, TTR("Group"));
|
|
|
|
group_images->connect("item_edited", this, "_group_item_edited", varray(), CONNECT_DEFERRED);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
/* SpinBox *group_shrink;
|
2014-02-10 02:10:30 +01:00
|
|
|
CheckButton *group_atlas;
|
|
|
|
OptionButton *group_image_action;*/
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
/* progress = memnew( Label );
|
2014-02-10 02:10:30 +01:00
|
|
|
add_child(progress);
|
|
|
|
progress->set_area_as_parent_rect();
|
|
|
|
progress->set_anchor_and_margin(MARGIN_TOP,Control::ANCHOR_BEGIN,25);
|
|
|
|
progress->hide();
|
|
|
|
progress->set_align(Label::ALIGN_CENTER);*/
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
/*
|
2014-02-10 02:10:30 +01:00
|
|
|
button_reload = memnew( Button );
|
|
|
|
button_reload->set_pos(Point2(3,2));
|
|
|
|
button_reload->set_size(Point2(20,5));
|
|
|
|
button_reload->set_flat(true);
|
|
|
|
//add_child(button_reload);
|
|
|
|
button_reload->connect("pressed",this,"_rescan");
|
|
|
|
hbc->add_child(button_reload);
|
|
|
|
*/
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
sample_vbox = memnew(VBoxContainer);
|
2016-05-04 03:25:37 +02:00
|
|
|
sample_vbox->set_name(TTR("Samples"));
|
2015-11-09 04:49:18 +01:00
|
|
|
sections->add_child(sample_vbox);
|
2017-03-19 00:36:26 +01:00
|
|
|
sample_mode = memnew(OptionButton);
|
|
|
|
sample_vbox->add_margin_child(TTR("Sample Conversion Mode: (.wav files):"), sample_mode);
|
2016-05-04 03:25:37 +02:00
|
|
|
sample_mode->add_item(TTR("Keep"));
|
|
|
|
sample_mode->add_item(TTR("Compress (RAM - IMA-ADPCM)"));
|
2017-03-19 00:36:26 +01:00
|
|
|
sample_max_hz = memnew(SpinBox);
|
2015-11-09 04:49:18 +01:00
|
|
|
sample_max_hz->set_max(192000);
|
|
|
|
sample_max_hz->set_min(8000);
|
2017-03-19 00:36:26 +01:00
|
|
|
sample_vbox->add_margin_child(TTR("Sampling Rate Limit (Hz):"), sample_max_hz);
|
|
|
|
sample_trim = memnew(CheckButton);
|
2016-05-04 03:25:37 +02:00
|
|
|
sample_trim->set_text(TTR("Trim"));
|
2017-03-19 00:36:26 +01:00
|
|
|
sample_vbox->add_margin_child(TTR("Trailing Silence:"), sample_trim);
|
2015-11-09 04:49:18 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
script_vbox = memnew(VBoxContainer);
|
2016-05-29 10:10:23 +02:00
|
|
|
script_vbox->set_name(TTR("Script"));
|
2014-06-11 15:41:03 +02:00
|
|
|
sections->add_child(script_vbox);
|
2017-03-19 00:36:26 +01:00
|
|
|
script_mode = memnew(OptionButton);
|
|
|
|
script_vbox->add_margin_child(TTR("Script Export Mode:"), script_mode);
|
2016-05-04 03:25:37 +02:00
|
|
|
script_mode->add_item(TTR("Text"));
|
|
|
|
script_mode->add_item(TTR("Compiled"));
|
|
|
|
script_mode->add_item(TTR("Encrypted (Provide Key Below)"));
|
2017-03-19 00:36:26 +01:00
|
|
|
script_key = memnew(LineEdit);
|
|
|
|
script_vbox->add_margin_child(TTR("Script Encryption Key (256-bits as hex):"), script_key);
|
2014-06-11 15:41:03 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
updating = false;
|
2014-06-11 15:41:03 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
error = memnew(AcceptDialog);
|
2014-02-10 02:10:30 +01:00
|
|
|
add_child(error);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
confirm = memnew(ConfirmationDialog);
|
2014-02-10 02:10:30 +01:00
|
|
|
add_child(confirm);
|
2017-03-19 00:36:26 +01:00
|
|
|
confirm->connect("confirmed", this, "_confirmed");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-05-04 03:25:37 +02:00
|
|
|
get_ok()->set_text(TTR("Export PCK/Zip"));
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
expopt = "--,Export,Bundle";
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
file_export = memnew(EditorFileDialog);
|
2014-02-10 02:10:30 +01:00
|
|
|
add_child(file_export);
|
2015-06-06 14:44:38 +02:00
|
|
|
file_export->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
|
2017-03-19 00:36:26 +01:00
|
|
|
file_export->set_current_dir(EditorSettings::get_singleton()->get("global/default_project_export_path"));
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2016-05-04 03:25:37 +02:00
|
|
|
file_export->set_title(TTR("Export Project"));
|
2017-03-19 00:36:26 +01:00
|
|
|
file_export->connect("file_selected", this, "_export_action");
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
file_export_password = memnew(LineEdit);
|
2014-02-10 02:10:30 +01:00
|
|
|
file_export_password->set_secret(true);
|
|
|
|
file_export_password->set_editable(false);
|
2017-03-19 00:36:26 +01:00
|
|
|
file_export->get_vbox()->add_margin_child(TTR("Password:"), file_export_password);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
pck_export = memnew(EditorFileDialog);
|
2015-06-06 14:44:38 +02:00
|
|
|
pck_export->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
|
2017-03-19 00:36:26 +01:00
|
|
|
pck_export->set_current_dir(EditorSettings::get_singleton()->get("global/default_project_export_path"));
|
2016-05-04 03:25:37 +02:00
|
|
|
pck_export->set_title(TTR("Export Project PCK"));
|
2017-03-19 00:36:26 +01:00
|
|
|
pck_export->connect("file_selected", this, "_export_action_pck");
|
2014-02-13 22:03:28 +01:00
|
|
|
pck_export->add_filter("*.pck ; Data Pack");
|
2015-12-13 05:08:36 +01:00
|
|
|
pck_export->add_filter("*.zip ; Zip");
|
2014-02-13 22:03:28 +01:00
|
|
|
add_child(pck_export);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
button_export = add_button(TTR("Export.."), !OS::get_singleton()->get_swap_ok_cancel(), "export_pck");
|
|
|
|
updating_script = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ei = "EditorIcons";
|
|
|
|
ot = "Object";
|
|
|
|
pending_update_tree = true;
|
2016-11-26 15:30:46 +01:00
|
|
|
|
|
|
|
_create_android_keystore_window();
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ProjectExportDialog::~ProjectExportDialog() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectExport::popup_export() {
|
|
|
|
|
|
|
|
Set<String> presets;
|
|
|
|
presets.insert("default");
|
|
|
|
|
|
|
|
List<PropertyInfo> pi;
|
|
|
|
Globals::get_singleton()->get_property_list(&pi);
|
|
|
|
export_preset->clear();
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
if (!E->get().name.begins_with("export_presets/"))
|
|
|
|
continue;
|
2017-03-19 00:36:26 +01:00
|
|
|
presets.insert(E->get().name.get_slice("/", 1));
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (Set<String>::Element *E = presets.front(); E; E = E->next()) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
export_preset->add_item(E->get());
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
popup_centered(Size2(300, 100));
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
Error ProjectExport::export_project(const String &p_preset) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
return OK;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
String selected=p_preset;
|
|
|
|
|
|
|
|
DVector<String> preset_settings = Globals::get_singleton()->get("export_presets/"+selected);
|
|
|
|
String preset_path=Globals::get_singleton()->get("export_presets_path/"+selected);
|
|
|
|
if (preset_path=="") {
|
|
|
|
|
2016-05-19 00:08:12 +02:00
|
|
|
error->set_text("Export path empty, see export options");
|
2014-02-10 02:10:30 +01:00
|
|
|
error->popup_centered_minsize(Size2(300,100));
|
|
|
|
ERR_FAIL_V(ERR_INVALID_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
int pc=preset_settings.size();
|
|
|
|
|
|
|
|
DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
|
|
|
if (d->change_dir(preset_path)!=OK) {
|
|
|
|
|
|
|
|
memdelete(d);
|
|
|
|
error->set_text("Can't access to export path:\n "+preset_path);
|
|
|
|
error->popup_centered_minsize(Size2(300,100));
|
|
|
|
ERR_FAIL_V(ERR_INVALID_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pc==0) {
|
|
|
|
memdelete(d);
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
if (pc%3 != 0 ) {
|
|
|
|
memdelete(d);
|
2016-05-19 00:08:12 +02:00
|
|
|
error->set_text("Corrupted export data..");
|
2014-02-10 02:10:30 +01:00
|
|
|
error->popup_centered_minsize(Size2(300,100));
|
2016-05-19 00:08:12 +02:00
|
|
|
ERR_EXPLAIN("Corrupted export data...");
|
2014-02-10 02:10:30 +01:00
|
|
|
ERR_FAIL_V(ERR_INVALID_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
Map<String,ProjectExportSettings::ItemData> export_action;
|
|
|
|
|
|
|
|
|
|
|
|
Map<String,Map<String,String> > remapped_paths;
|
|
|
|
|
|
|
|
Set<String> scene_extensions;
|
|
|
|
Set<String> resource_extensions;
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
List<String> l;
|
|
|
|
// SceneLoader::get_recognized_extensions(&l);
|
|
|
|
// for(List<String>::Element *E=l.front();E;E=E->next()) {
|
|
|
|
//
|
|
|
|
// scene_extensions.insert(E->get());
|
|
|
|
// }
|
|
|
|
ResourceLoader::get_recognized_extensions_for_type("",&l);
|
|
|
|
for(List<String>::Element *E=l.front();E;E=E->next()) {
|
|
|
|
|
|
|
|
resource_extensions.insert(E->get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector<String> names = Globals::get_singleton()->get_optimizer_presets();
|
|
|
|
|
|
|
|
//prepare base paths
|
|
|
|
|
|
|
|
for(int i=0;i<pc;i+=3) {
|
|
|
|
|
|
|
|
|
|
|
|
String name = preset_settings[i+0];
|
|
|
|
String pname=preset_settings[i+1];
|
|
|
|
String deps=preset_settings[i+2];
|
|
|
|
int idx=1;
|
|
|
|
if (pname=="") {
|
|
|
|
pname="copy";
|
|
|
|
} else {
|
|
|
|
|
|
|
|
for(int j=0;j<names.size();j++) {
|
|
|
|
if (pname==names[j]) {
|
|
|
|
idx=j+2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int dep_idx=0;
|
|
|
|
|
|
|
|
for(int j=0;j<ProjectExportSettings::DA_MAX;j++) {
|
|
|
|
if (ProjectExportSettings::da_string[j]==deps) {
|
|
|
|
dep_idx=j;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (idx>=0) {
|
|
|
|
export_action[name].action=idx;
|
|
|
|
export_action[name].depaction=dep_idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Set<String> bundle_exceptions;
|
|
|
|
for (Map<String,ProjectExportSettings::ItemData>::Element *E=export_action.front();E;E=E->next()) {
|
|
|
|
bundle_exceptions.insert(E->key());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// find dependencies and add them to export
|
|
|
|
|
|
|
|
Map<String,ProjectExportSettings::ItemData> dependencies;
|
|
|
|
|
|
|
|
for (Map<String,ProjectExportSettings::ItemData>::Element *E=export_action.front();E;E=E->next()) {
|
|
|
|
|
|
|
|
ProjectExportSettings::ItemData &id=E->get();
|
|
|
|
|
|
|
|
if (id.depaction!=ProjectExportSettings::DA_COPY && id.depaction!=ProjectExportSettings::DA_OPTIMIZE)
|
|
|
|
continue; //no copy or optimize, go on
|
|
|
|
List<String> deplist;
|
|
|
|
ResourceLoader::get_dependencies(E->key(),&deplist);
|
|
|
|
|
|
|
|
while (deplist.size()) {
|
|
|
|
|
|
|
|
String dependency = deplist.front()->get();
|
|
|
|
deplist.pop_front();
|
|
|
|
if (export_action.has(dependency))
|
|
|
|
continue; //taged to export, will not override
|
|
|
|
if (dependencies.has(dependency)) {
|
|
|
|
|
|
|
|
if (id.action <= dependencies[dependency].action )
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProjectExportSettings::ItemData depid;
|
|
|
|
if (id.depaction==ProjectExportSettings::DA_COPY || id.action==ProjectExportSettings::DA_COPY)
|
|
|
|
depid.action=ProjectExportSettings::DA_COPY;
|
|
|
|
else if (id.depaction==ProjectExportSettings::DA_OPTIMIZE)
|
|
|
|
depid.action=id.action;
|
|
|
|
depid.depaction=0;
|
|
|
|
|
|
|
|
dependencies[dependency]=depid;
|
|
|
|
|
|
|
|
ResourceLoader::get_dependencies(dependency,&deplist);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Map<String,ProjectExportSettings::ItemData>::Element *E=dependencies.front();E;E=E->next()) {
|
|
|
|
export_action[E->key()]=E->get();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int idx=0;
|
|
|
|
for (Map<String,ProjectExportSettings::ItemData>::Element *E=export_action.front();E;E=E->next(),idx++) {
|
|
|
|
|
|
|
|
|
|
|
|
String path=E->key();
|
|
|
|
if (E->get().action==0)
|
|
|
|
continue; //nothing to do here
|
|
|
|
String preset;
|
|
|
|
if (E->get().action==1)
|
|
|
|
preset="";
|
|
|
|
else
|
|
|
|
preset=names[E->get().action-2];
|
|
|
|
|
2016-05-04 15:28:37 +02:00
|
|
|
print_line("Exporting "+itos(idx)+"/"+itos(export_action.size())+": "+path);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
String base_dir = Globals::get_singleton()->localize_path(path.get_base_dir()).replace("\\","/").replace("res://","");
|
|
|
|
DirAccess *da=DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
|
|
|
|
String cwd = d->get_current_dir();
|
|
|
|
da->change_dir(cwd);
|
|
|
|
print_line("base dir: "+base_dir);
|
|
|
|
String remap_platform="all";
|
|
|
|
|
|
|
|
for(int j=0;j<base_dir.get_slice_count("/");j++) {
|
|
|
|
|
|
|
|
String p = base_dir.get_slice("/",j);
|
|
|
|
if (da->change_dir(p)!=OK) {
|
|
|
|
|
|
|
|
Error err = da->make_dir(p);
|
|
|
|
if (err!=OK) {
|
|
|
|
memdelete(da);
|
|
|
|
memdelete(d);
|
2016-05-19 00:08:12 +02:00
|
|
|
ERR_EXPLAIN("Cannot make dir: "+cwd+"/"+p);
|
2014-02-10 02:10:30 +01:00
|
|
|
ERR_FAIL_V(ERR_CANT_CREATE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (da->change_dir(p)!=OK) {
|
|
|
|
|
|
|
|
memdelete(da);
|
|
|
|
memdelete(d);
|
2016-05-19 00:08:12 +02:00
|
|
|
ERR_EXPLAIN("Cannot change to dir: "+cwd+"/"+p);
|
2014-02-10 02:10:30 +01:00
|
|
|
ERR_FAIL_V(ERR_CANT_CREATE);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
cwd=da->get_current_dir();
|
|
|
|
}
|
|
|
|
|
|
|
|
memdelete(da);
|
|
|
|
//cwd is the target dir
|
|
|
|
|
|
|
|
String source_file;
|
|
|
|
|
2016-05-04 15:28:37 +02:00
|
|
|
print_line("Exporting: "+source_file);
|
2014-02-10 02:10:30 +01:00
|
|
|
bool delete_source=false;
|
|
|
|
if (preset=="") {
|
|
|
|
//just copy!
|
|
|
|
|
|
|
|
source_file=path;
|
|
|
|
delete_source=false;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
delete_source=true;
|
|
|
|
//create an optimized source file
|
|
|
|
|
|
|
|
if (!Globals::get_singleton()->has("optimizer_presets/"+preset)) {
|
|
|
|
memdelete(d);
|
2016-05-19 00:08:12 +02:00
|
|
|
ERR_EXPLAIN("Unknown optimizer preset: "+preset);
|
2014-02-10 02:10:30 +01:00
|
|
|
ERR_FAIL_V(ERR_INVALID_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Dictionary dc = Globals::get_singleton()->get("optimizer_presets/"+preset);
|
|
|
|
|
|
|
|
ERR_FAIL_COND_V(!dc.has("__type__"),ERR_INVALID_DATA);
|
|
|
|
String type=dc["__type__"];
|
|
|
|
|
|
|
|
Ref<EditorOptimizedSaver> saver;
|
|
|
|
|
|
|
|
for(int i=0;i<editor_data->get_optimized_saver_count();i++) {
|
|
|
|
|
|
|
|
if (editor_data->get_optimized_saver(i)->get_target_name()==type) {
|
|
|
|
saver=editor_data->get_optimized_saver(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (saver.is_null()) {
|
|
|
|
memdelete(d);
|
2016-05-19 00:08:12 +02:00
|
|
|
ERR_EXPLAIN("Preset '"+preset+"' references nonexistent saver: "+type);
|
2014-02-10 02:10:30 +01:00
|
|
|
ERR_FAIL_COND_V(saver.is_null(),ERR_INVALID_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Variant> keys;
|
|
|
|
dc.get_key_list(&keys);
|
|
|
|
|
|
|
|
saver->clear();
|
|
|
|
|
|
|
|
for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
|
|
|
|
|
|
|
|
saver->set(E->get(),dc[E->get()]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
remap_platform=saver->get_target_platform();
|
|
|
|
if (remap_platform=="")
|
|
|
|
remap_platform="all";
|
|
|
|
|
|
|
|
|
|
|
|
if (resource_extensions.has(path.extension().to_lower())) {
|
|
|
|
|
|
|
|
uint32_t flags=0;
|
|
|
|
|
|
|
|
// if (saver->is_bundle_scenes_enabled())
|
|
|
|
// flags|=Reso::FLAG_BUNDLE_INSTANCED_SCENES;
|
|
|
|
saver->set_bundle_exceptions(NULL);
|
|
|
|
if (E->get().depaction>=ProjectExportSettings::DA_BUNDLE) {
|
|
|
|
flags|=ResourceSaver::FLAG_BUNDLE_RESOURCES;
|
|
|
|
if (E->get().depaction==ProjectExportSettings::DA_BUNDLE)
|
|
|
|
saver->set_bundle_exceptions(&bundle_exceptions);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (saver->is_remove_editor_data_enabled())
|
|
|
|
flags|=ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES;
|
|
|
|
if (saver->is_big_endian_data_enabled())
|
|
|
|
flags|=ResourceSaver::FLAG_SAVE_BIG_ENDIAN;
|
|
|
|
|
|
|
|
RES res = ResourceLoader::load(path);
|
|
|
|
|
|
|
|
if (res.is_null()) {
|
|
|
|
|
|
|
|
memdelete(d);
|
2016-05-19 00:08:12 +02:00
|
|
|
ERR_EXPLAIN("Error loading resource to optimize: "+path);
|
2014-02-10 02:10:30 +01:00
|
|
|
ERR_FAIL_V(ERR_INVALID_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (saver->is_compress_translations_enabled() && res->get_type()=="Translation") {
|
|
|
|
|
|
|
|
Ref<PHashTranslation> ct = Ref<PHashTranslation>( memnew( PHashTranslation ) );
|
|
|
|
ct->generate(res);
|
|
|
|
res=ct;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//dst_file=path.get_file();
|
|
|
|
//dst_file = cwd+"/"+dst_file.substr(0,dst_file.length()-dst_file.extension().length())+"opt.scn";
|
|
|
|
|
|
|
|
//String write_file = path.substr(0,path.length()-path.extension().length())+"optimized.res";
|
|
|
|
String write_file = path+".opt.res";
|
|
|
|
|
|
|
|
|
2016-05-04 15:28:37 +02:00
|
|
|
print_line("DST RES FILE: "+write_file);
|
2014-02-10 02:10:30 +01:00
|
|
|
Error err = ResourceSaver::save(write_file,res,flags,saver);
|
|
|
|
if (err) {
|
|
|
|
memdelete(d);
|
2016-05-19 00:08:12 +02:00
|
|
|
ERR_EXPLAIN("Error saving optimized resource: "+write_file);
|
2014-02-10 02:10:30 +01:00
|
|
|
ERR_FAIL_COND_V(err,ERR_CANT_OPEN);
|
|
|
|
}
|
|
|
|
source_file=write_file;
|
|
|
|
// project_settings->add_remapped_path(src_scene,path,platform);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String dst_file;
|
|
|
|
dst_file=cwd+"/"+source_file.get_file();
|
|
|
|
print_line("copying from: "+source_file);
|
|
|
|
print_line("copying to: "+dst_file);
|
|
|
|
Error err = d->copy(source_file,dst_file);
|
|
|
|
|
|
|
|
if (delete_source)
|
|
|
|
d->remove(source_file);
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
|
2016-05-19 00:08:12 +02:00
|
|
|
ERR_EXPLAIN("Error copying from: "+source_file+" to "+dst_file+".");
|
2014-02-10 02:10:30 +01:00
|
|
|
ERR_FAIL_COND_V(err,err);
|
|
|
|
}
|
|
|
|
|
|
|
|
String src_remap=path;
|
|
|
|
String dst_remap=source_file;
|
|
|
|
print_line("remap from: "+src_remap);
|
|
|
|
print_line("remap to: "+dst_remap);
|
|
|
|
if (src_remap!=dst_remap) {
|
|
|
|
|
|
|
|
|
|
|
|
remapped_paths[remap_platform][src_remap]=dst_remap;
|
|
|
|
}
|
|
|
|
|
|
|
|
//do the copy man...
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Map<String,Variant> added_settings;
|
|
|
|
|
|
|
|
|
|
|
|
for (Map<String,Map<String,String> >::Element *E=remapped_paths.front();E;E=E->next()) {
|
|
|
|
|
|
|
|
String platform=E->key();
|
|
|
|
DVector<String> remaps;
|
|
|
|
for(Map<String,String>::Element *F=E->get().front();F;F=F->next() ) {
|
|
|
|
|
|
|
|
remaps.push_back(F->key());
|
|
|
|
remaps.push_back(F->get());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// added_settings["remap/"+platform]=remaps;`
|
|
|
|
added_settings["remap/"+platform]=Variant(remaps).operator Array();
|
|
|
|
}
|
|
|
|
|
|
|
|
String engine_cfg_path=d->get_current_dir()+"/engine.cfg";
|
|
|
|
print_line("enginecfg: "+engine_cfg_path);
|
|
|
|
Globals::get_singleton()->save_custom(engine_cfg_path,added_settings);
|
|
|
|
|
|
|
|
memdelete(d);
|
|
|
|
return OK;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ProjectExport::ProjectExport(EditorData *p_data) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
editor_data = p_data;
|
|
|
|
VBoxContainer *vbc = memnew(VBoxContainer);
|
2014-02-10 02:10:30 +01:00
|
|
|
add_child(vbc);
|
|
|
|
set_child_rect(vbc);
|
2016-05-04 03:25:37 +02:00
|
|
|
set_title(TTR("Project Export"));
|
2017-03-19 00:36:26 +01:00
|
|
|
label = memnew(Label);
|
2016-05-04 03:25:37 +02:00
|
|
|
label->set_text(TTR("Export Preset:"));
|
2014-02-10 02:10:30 +01:00
|
|
|
vbc->add_child(label);
|
2017-03-19 00:36:26 +01:00
|
|
|
export_preset = memnew(OptionButton);
|
2014-02-10 02:10:30 +01:00
|
|
|
vbc->add_child(export_preset);
|
2016-05-04 03:25:37 +02:00
|
|
|
get_ok()->set_text(TTR("Export"));
|
2014-02-10 02:10:30 +01:00
|
|
|
set_hide_on_ok(false);
|
2017-03-19 00:36:26 +01:00
|
|
|
error = memnew(AcceptDialog);
|
2014-02-10 02:10:30 +01:00
|
|
|
add_child(error);
|
|
|
|
}
|