2016-06-18 12:46:12 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* editor_asset_installer.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2016-06-18 12:46:12 +00:00
|
|
|
/*************************************************************************/
|
2022-01-03 20:27:34 +00:00
|
|
|
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
2016-06-18 12:46:12 +00: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. */
|
|
|
|
/*************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2016-03-12 13:44:12 +00:00
|
|
|
#include "editor_asset_installer.h"
|
2017-01-16 07:04:19 +00:00
|
|
|
|
2021-06-11 12:51:48 +00:00
|
|
|
#include "core/io/dir_access.h"
|
|
|
|
#include "core/io/file_access.h"
|
2018-09-11 16:13:45 +00:00
|
|
|
#include "core/io/zip_io.h"
|
2022-02-12 01:46:22 +00:00
|
|
|
#include "editor/editor_file_system.h"
|
|
|
|
#include "editor/editor_node.h"
|
|
|
|
#include "editor/progress_dialog.h"
|
2016-03-12 13:44:12 +00:00
|
|
|
|
|
|
|
void EditorAssetInstaller::_item_edited() {
|
2020-05-14 14:41:43 +00:00
|
|
|
if (updating) {
|
2016-03-12 13:44:12 +00:00
|
|
|
return;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2016-03-12 13:44:12 +00:00
|
|
|
|
|
|
|
TreeItem *item = tree->get_edited();
|
2020-05-14 14:41:43 +00:00
|
|
|
if (!item) {
|
2016-03-12 13:44:12 +00:00
|
|
|
return;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2016-03-12 13:44:12 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
updating = true;
|
2021-09-17 15:50:24 +00:00
|
|
|
item->propagate_check(0);
|
|
|
|
updating = false;
|
|
|
|
}
|
2016-03-12 13:44:12 +00:00
|
|
|
|
2021-09-17 15:50:24 +00:00
|
|
|
void EditorAssetInstaller::_check_propagated_to_item(Object *p_obj, int column) {
|
|
|
|
TreeItem *affected_item = Object::cast_to<TreeItem>(p_obj);
|
|
|
|
if (affected_item && affected_item->get_custom_color(0) != Color()) {
|
|
|
|
affected_item->set_checked(0, false);
|
|
|
|
affected_item->propagate_check(0, false);
|
2016-03-12 13:44:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void EditorAssetInstaller::open(const String &p_path, int p_depth) {
|
|
|
|
package_path = p_path;
|
2022-05-19 15:00:06 +00:00
|
|
|
HashSet<String> files_sorted;
|
2016-03-12 13:44:12 +00:00
|
|
|
|
2022-05-11 12:15:58 +00:00
|
|
|
Ref<FileAccess> io_fa;
|
|
|
|
zlib_filefunc_def io = zipio_create_io(&io_fa);
|
2016-03-12 13:44:12 +00:00
|
|
|
|
|
|
|
unzFile pkg = unzOpen2(p_path.utf8().get_data(), &io);
|
|
|
|
if (!pkg) {
|
2021-04-06 15:37:55 +00:00
|
|
|
error->set_text(vformat(TTR("Error opening asset file for \"%s\" (not in ZIP format)."), asset_name));
|
2016-03-12 13:44:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ret = unzGoToFirstFile(pkg);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
while (ret == UNZ_OK) {
|
2016-03-12 13:44:12 +00:00
|
|
|
//get filename
|
|
|
|
unz_file_info info;
|
|
|
|
char fname[16384];
|
2020-04-01 23:20:12 +00:00
|
|
|
unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0);
|
2016-03-12 13:44:12 +00:00
|
|
|
|
2022-01-05 12:27:11 +00:00
|
|
|
String name = String::utf8(fname);
|
2016-03-12 13:44:12 +00:00
|
|
|
files_sorted.insert(name);
|
|
|
|
|
|
|
|
ret = unzGoToNextFile(pkg);
|
|
|
|
}
|
|
|
|
|
2022-05-13 13:04:37 +00:00
|
|
|
HashMap<String, Ref<Texture2D>> extension_guess;
|
2016-03-12 13:44:12 +00:00
|
|
|
{
|
2021-07-17 21:22:52 +00:00
|
|
|
extension_guess["bmp"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["dds"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["exr"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["hdr"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["jpg"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["jpeg"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["png"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["svg"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["tga"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["webp"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"));
|
|
|
|
|
|
|
|
extension_guess["wav"] = tree->get_theme_icon(SNAME("AudioStreamSample"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["ogg"] = tree->get_theme_icon(SNAME("AudioStreamOGGVorbis"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["mp3"] = tree->get_theme_icon(SNAME("AudioStreamMP3"), SNAME("EditorIcons"));
|
|
|
|
|
|
|
|
extension_guess["scn"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["tscn"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["escn"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["dae"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["gltf"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["glb"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons"));
|
|
|
|
|
|
|
|
extension_guess["gdshader"] = tree->get_theme_icon(SNAME("Shader"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["gd"] = tree->get_theme_icon(SNAME("GDScript"), SNAME("EditorIcons"));
|
2021-07-03 15:44:56 +00:00
|
|
|
if (Engine::get_singleton()->has_singleton("GodotSharp")) {
|
2021-07-17 21:22:52 +00:00
|
|
|
extension_guess["cs"] = tree->get_theme_icon(SNAME("CSharpScript"), SNAME("EditorIcons"));
|
2021-07-03 15:44:56 +00:00
|
|
|
} else {
|
|
|
|
// Mark C# support as unavailable.
|
2021-07-17 21:22:52 +00:00
|
|
|
extension_guess["cs"] = tree->get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons"));
|
2021-07-03 15:44:56 +00:00
|
|
|
}
|
2021-07-17 21:22:52 +00:00
|
|
|
extension_guess["vs"] = tree->get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons"));
|
2021-07-03 15:44:56 +00:00
|
|
|
|
2021-07-17 21:22:52 +00:00
|
|
|
extension_guess["res"] = tree->get_theme_icon(SNAME("Resource"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["tres"] = tree->get_theme_icon(SNAME("Resource"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["atlastex"] = tree->get_theme_icon(SNAME("AtlasTexture"), SNAME("EditorIcons"));
|
2021-07-03 15:44:56 +00:00
|
|
|
// By default, OBJ files are imported as Mesh resources rather than PackedScenes.
|
2021-07-17 21:22:52 +00:00
|
|
|
extension_guess["obj"] = tree->get_theme_icon(SNAME("Mesh"), SNAME("EditorIcons"));
|
|
|
|
|
|
|
|
extension_guess["txt"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["md"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["rst"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["json"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["yml"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["yaml"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["toml"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["cfg"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons"));
|
|
|
|
extension_guess["ini"] = tree->get_theme_icon(SNAME("TextFile"), SNAME("EditorIcons"));
|
2016-03-12 13:44:12 +00:00
|
|
|
}
|
|
|
|
|
2021-07-17 21:22:52 +00:00
|
|
|
Ref<Texture2D> generic_extension = tree->get_theme_icon(SNAME("Object"), SNAME("EditorIcons"));
|
2016-03-12 13:44:12 +00:00
|
|
|
|
|
|
|
unzClose(pkg);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
updating = true;
|
2016-03-12 13:44:12 +00:00
|
|
|
tree->clear();
|
2017-03-05 15:44:50 +00:00
|
|
|
TreeItem *root = tree->create_item();
|
|
|
|
root->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
|
|
|
|
root->set_checked(0, true);
|
2021-07-17 21:22:52 +00:00
|
|
|
root->set_icon(0, tree->get_theme_icon(SNAME("folder"), SNAME("FileDialog")));
|
2017-03-05 15:44:50 +00:00
|
|
|
root->set_text(0, "res://");
|
|
|
|
root->set_editable(0, true);
|
2022-05-13 13:04:37 +00:00
|
|
|
HashMap<String, TreeItem *> dir_map;
|
2016-03-12 13:44:12 +00:00
|
|
|
|
2021-04-06 15:37:55 +00:00
|
|
|
int num_file_conflicts = 0;
|
|
|
|
|
2022-05-18 23:43:40 +00:00
|
|
|
for (const String &E : files_sorted) {
|
|
|
|
String path = E;
|
2017-03-05 15:44:50 +00:00
|
|
|
int depth = p_depth;
|
|
|
|
bool skip = false;
|
|
|
|
while (depth > 0) {
|
2016-03-12 13:44:12 +00:00
|
|
|
int pp = path.find("/");
|
2017-03-05 15:44:50 +00:00
|
|
|
if (pp == -1) {
|
|
|
|
skip = true;
|
2016-03-12 13:44:12 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
path = path.substr(pp + 1, path.length());
|
2016-03-12 13:44:12 +00:00
|
|
|
depth--;
|
|
|
|
}
|
|
|
|
|
2021-12-09 09:42:46 +00:00
|
|
|
if (skip || path.is_empty()) {
|
2016-03-12 13:44:12 +00:00
|
|
|
continue;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2016-03-12 13:44:12 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
bool isdir = false;
|
2016-03-12 13:44:12 +00:00
|
|
|
|
|
|
|
if (path.ends_with("/")) {
|
|
|
|
//a directory
|
2017-03-05 15:44:50 +00:00
|
|
|
path = path.substr(0, path.length() - 1);
|
|
|
|
isdir = true;
|
2016-03-12 13:44:12 +00:00
|
|
|
}
|
|
|
|
|
2020-07-03 13:26:22 +00:00
|
|
|
int pp = path.rfind("/");
|
2016-03-12 13:44:12 +00:00
|
|
|
|
|
|
|
TreeItem *parent;
|
2017-03-05 15:44:50 +00:00
|
|
|
if (pp == -1) {
|
|
|
|
parent = root;
|
2016-03-12 13:44:12 +00:00
|
|
|
} else {
|
2017-03-05 15:44:50 +00:00
|
|
|
String ppath = path.substr(0, pp);
|
2016-03-12 13:44:12 +00:00
|
|
|
ERR_CONTINUE(!dir_map.has(ppath));
|
2017-03-05 15:44:50 +00:00
|
|
|
parent = dir_map[ppath];
|
2016-03-12 13:44:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TreeItem *ti = tree->create_item(parent);
|
2017-03-05 15:44:50 +00:00
|
|
|
ti->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
|
|
|
|
ti->set_checked(0, true);
|
|
|
|
ti->set_editable(0, true);
|
2016-03-12 13:44:12 +00:00
|
|
|
if (isdir) {
|
2017-03-05 15:44:50 +00:00
|
|
|
dir_map[path] = ti;
|
|
|
|
ti->set_text(0, path.get_file() + "/");
|
2021-07-17 21:22:52 +00:00
|
|
|
ti->set_icon(0, tree->get_theme_icon(SNAME("folder"), SNAME("FileDialog")));
|
2017-05-14 13:23:28 +00:00
|
|
|
ti->set_metadata(0, String());
|
2016-03-12 13:44:12 +00:00
|
|
|
} else {
|
|
|
|
String file = path.get_file();
|
2017-01-14 03:51:09 +00:00
|
|
|
String extension = file.get_extension().to_lower();
|
2016-03-12 13:44:12 +00:00
|
|
|
if (extension_guess.has(extension)) {
|
2017-03-05 15:44:50 +00:00
|
|
|
ti->set_icon(0, extension_guess[extension]);
|
2016-03-12 13:44:12 +00:00
|
|
|
} else {
|
2017-03-05 15:44:50 +00:00
|
|
|
ti->set_icon(0, generic_extension);
|
2016-03-12 13:44:12 +00:00
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
ti->set_text(0, file);
|
2016-03-12 13:44:12 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
String res_path = "res://" + path;
|
2016-03-12 13:44:12 +00:00
|
|
|
if (FileAccess::exists(res_path)) {
|
2021-04-06 15:37:55 +00:00
|
|
|
num_file_conflicts += 1;
|
2021-07-17 21:22:52 +00:00
|
|
|
ti->set_custom_color(0, tree->get_theme_color(SNAME("error_color"), SNAME("Editor")));
|
2021-04-06 15:37:55 +00:00
|
|
|
ti->set_tooltip(0, vformat(TTR("%s (already exists)"), res_path));
|
2017-03-05 15:44:50 +00:00
|
|
|
ti->set_checked(0, false);
|
2021-09-17 15:50:24 +00:00
|
|
|
ti->propagate_check(0);
|
2016-03-12 13:44:12 +00:00
|
|
|
} else {
|
2017-03-05 15:44:50 +00:00
|
|
|
ti->set_tooltip(0, res_path);
|
2016-03-12 13:44:12 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ti->set_metadata(0, res_path);
|
2016-03-12 13:44:12 +00:00
|
|
|
}
|
|
|
|
|
2022-05-18 23:43:40 +00:00
|
|
|
status_map[E] = ti;
|
2016-03-12 13:44:12 +00:00
|
|
|
}
|
2021-04-06 15:37:55 +00:00
|
|
|
|
|
|
|
if (num_file_conflicts >= 1) {
|
|
|
|
asset_contents->set_text(vformat(TTR("Contents of asset \"%s\" - %d file(s) conflict with your project:"), asset_name, num_file_conflicts));
|
|
|
|
} else {
|
|
|
|
asset_contents->set_text(vformat(TTR("Contents of asset \"%s\" - No files conflict with your project:"), asset_name));
|
|
|
|
}
|
|
|
|
|
2022-01-19 16:16:17 +00:00
|
|
|
popup_centered_ratio(0.5);
|
2017-03-05 15:44:50 +00:00
|
|
|
updating = false;
|
2016-03-12 13:44:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditorAssetInstaller::ok_pressed() {
|
2022-05-11 12:15:58 +00:00
|
|
|
Ref<FileAccess> io_fa;
|
|
|
|
zlib_filefunc_def io = zipio_create_io(&io_fa);
|
2016-03-12 13:44:12 +00:00
|
|
|
|
|
|
|
unzFile pkg = unzOpen2(package_path.utf8().get_data(), &io);
|
|
|
|
if (!pkg) {
|
2021-04-06 15:37:55 +00:00
|
|
|
error->set_text(vformat(TTR("Error opening asset file for \"%s\" (not in ZIP format)."), asset_name));
|
2016-03-12 13:44:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ret = unzGoToFirstFile(pkg);
|
|
|
|
|
|
|
|
Vector<String> failed_files;
|
|
|
|
|
2017-08-23 20:25:14 +00:00
|
|
|
ProgressDialog::get_singleton()->add_task("uncompress", TTR("Uncompressing Assets"), status_map.size());
|
2016-03-12 13:44:12 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
int idx = 0;
|
|
|
|
while (ret == UNZ_OK) {
|
2016-03-12 13:44:12 +00:00
|
|
|
//get filename
|
|
|
|
unz_file_info info;
|
|
|
|
char fname[16384];
|
2020-04-01 23:20:12 +00:00
|
|
|
ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, nullptr, 0, nullptr, 0);
|
2022-04-05 10:40:26 +00:00
|
|
|
if (ret != UNZ_OK) {
|
|
|
|
break;
|
|
|
|
}
|
2016-03-12 13:44:12 +00:00
|
|
|
|
2022-01-05 12:27:11 +00:00
|
|
|
String name = String::utf8(fname);
|
2016-03-12 13:44:12 +00:00
|
|
|
|
2021-09-17 15:50:24 +00:00
|
|
|
if (status_map.has(name) && (status_map[name]->is_checked(0) || status_map[name]->is_indeterminate(0))) {
|
2016-03-12 13:44:12 +00:00
|
|
|
String path = status_map[name]->get_metadata(0);
|
2021-12-09 09:42:46 +00:00
|
|
|
if (path.is_empty()) { // a dir
|
2016-03-12 13:44:12 +00:00
|
|
|
|
|
|
|
String dirpath;
|
|
|
|
TreeItem *t = status_map[name];
|
2017-03-05 15:44:50 +00:00
|
|
|
while (t) {
|
|
|
|
dirpath = t->get_text(0) + dirpath;
|
|
|
|
t = t->get_parent();
|
2016-03-12 13:44:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (dirpath.ends_with("/")) {
|
2017-03-05 15:44:50 +00:00
|
|
|
dirpath = dirpath.substr(0, dirpath.length() - 1);
|
2016-03-12 13:44:12 +00:00
|
|
|
}
|
|
|
|
|
2022-03-23 09:08:58 +00:00
|
|
|
Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
|
2016-03-12 13:44:12 +00:00
|
|
|
da->make_dir(dirpath);
|
|
|
|
} else {
|
|
|
|
Vector<uint8_t> data;
|
|
|
|
data.resize(info.uncompressed_size);
|
|
|
|
|
|
|
|
//read
|
|
|
|
unzOpenCurrentFile(pkg);
|
2017-11-25 03:07:54 +00:00
|
|
|
unzReadCurrentFile(pkg, data.ptrw(), data.size());
|
2016-03-12 13:44:12 +00:00
|
|
|
unzCloseCurrentFile(pkg);
|
|
|
|
|
2022-03-23 09:08:58 +00:00
|
|
|
Ref<FileAccess> f = FileAccess::open(path, FileAccess::WRITE);
|
|
|
|
if (f.is_valid()) {
|
2017-03-05 15:44:50 +00:00
|
|
|
f->store_buffer(data.ptr(), data.size());
|
2016-03-12 13:44:12 +00:00
|
|
|
} else {
|
|
|
|
failed_files.push_back(path);
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ProgressDialog::get_singleton()->task_step("uncompress", path, idx);
|
2016-03-12 13:44:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
idx++;
|
|
|
|
ret = unzGoToNextFile(pkg);
|
|
|
|
}
|
|
|
|
|
|
|
|
ProgressDialog::get_singleton()->end_task("uncompress");
|
|
|
|
unzClose(pkg);
|
|
|
|
|
|
|
|
if (failed_files.size()) {
|
2021-04-06 15:37:55 +00:00
|
|
|
String msg = vformat(TTR("The following files failed extraction from asset \"%s\":"), asset_name) + "\n\n";
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < failed_files.size(); i++) {
|
|
|
|
if (i > 15) {
|
2021-04-06 15:37:55 +00:00
|
|
|
msg += "\n" + vformat(TTR("(and %s more files)"), itos(failed_files.size() - i));
|
2016-03-12 13:44:12 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
msg += failed_files[i];
|
2016-03-12 13:44:12 +00:00
|
|
|
}
|
2020-05-14 14:41:43 +00:00
|
|
|
if (EditorNode::get_singleton() != nullptr) {
|
2016-07-10 20:19:19 +00:00
|
|
|
EditorNode::get_singleton()->show_warning(msg);
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2016-03-12 13:44:12 +00:00
|
|
|
} else {
|
2020-05-14 14:41:43 +00:00
|
|
|
if (EditorNode::get_singleton() != nullptr) {
|
2021-04-06 15:37:55 +00:00
|
|
|
EditorNode::get_singleton()->show_warning(vformat(TTR("Asset \"%s\" installed successfully!"), asset_name), TTR("Success!"));
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2016-03-12 13:44:12 +00:00
|
|
|
}
|
2017-05-14 13:23:28 +00:00
|
|
|
EditorFileSystem::get_singleton()->scan_changes();
|
2016-03-12 13:44:12 +00:00
|
|
|
}
|
|
|
|
|
2021-04-06 15:37:55 +00:00
|
|
|
void EditorAssetInstaller::set_asset_name(const String &p_asset_name) {
|
|
|
|
asset_name = p_asset_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
String EditorAssetInstaller::get_asset_name() const {
|
|
|
|
return asset_name;
|
|
|
|
}
|
|
|
|
|
2016-03-12 13:44:12 +00:00
|
|
|
void EditorAssetInstaller::_bind_methods() {
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorAssetInstaller::EditorAssetInstaller() {
|
2017-03-05 15:44:50 +00:00
|
|
|
VBoxContainer *vb = memnew(VBoxContainer);
|
2016-03-12 13:44:12 +00:00
|
|
|
add_child(vb);
|
2017-01-10 04:49:55 +00:00
|
|
|
|
2021-04-06 15:37:55 +00:00
|
|
|
asset_contents = memnew(Label);
|
|
|
|
vb->add_child(asset_contents);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
tree = memnew(Tree);
|
2021-04-06 15:37:55 +00:00
|
|
|
tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
2020-02-21 17:28:45 +00:00
|
|
|
tree->connect("item_edited", callable_mp(this, &EditorAssetInstaller::_item_edited));
|
2021-09-17 15:50:24 +00:00
|
|
|
tree->connect("check_propagated_to_item", callable_mp(this, &EditorAssetInstaller::_check_propagated_to_item));
|
2021-04-06 15:37:55 +00:00
|
|
|
vb->add_child(tree);
|
2016-03-12 13:44:12 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
error = memnew(AcceptDialog);
|
2016-03-12 13:44:12 +00:00
|
|
|
add_child(error);
|
2020-12-14 18:37:30 +00:00
|
|
|
get_ok_button()->set_text(TTR("Install"));
|
2021-04-06 15:37:55 +00:00
|
|
|
set_title(TTR("Asset Installer"));
|
2016-03-12 13:44:12 +00:00
|
|
|
|
|
|
|
set_hide_on_ok(true);
|
|
|
|
}
|