summaryrefslogtreecommitdiff
path: root/editor/export_template_manager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/export_template_manager.cpp')
-rw-r--r--editor/export_template_manager.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp
index 06c179e77c..4ca2e1fdbf 100644
--- a/editor/export_template_manager.cpp
+++ b/editor/export_template_manager.cpp
@@ -35,6 +35,7 @@
#include "core/io/json.h"
#include "core/io/zip_io.h"
#include "core/os/keyboard.h"
+#include "core/templates/rb_set.h"
#include "core/version.h"
#include "editor/editor_node.h"
#include "editor/editor_paths.h"
@@ -50,7 +51,7 @@ void ExportTemplateManager::_update_template_status() {
Error err = da->change_dir(templates_dir);
ERR_FAIL_COND_MSG(err != OK, "Could not access templates directory at '" + templates_dir + "'.");
- Set<String> templates;
+ RBSet<String> templates;
da->list_dir_begin();
if (err == OK) {
String c = da->get_next();
@@ -97,7 +98,7 @@ void ExportTemplateManager::_update_template_status() {
installed_table->clear();
TreeItem *installed_root = installed_table->create_item();
- for (Set<String>::Element *E = templates.back(); E; E = E->prev()) {
+ for (RBSet<String>::Element *E = templates.back(); E; E = E->prev()) {
String version_string = E->get();
if (version_string == current_version) {
continue;
@@ -128,7 +129,7 @@ void ExportTemplateManager::_download_current() {
}
_download_template(mirror_url, true);
- } else if (!mirrors_available && !is_refreshing_mirrors) {
+ } else if (!is_refreshing_mirrors) {
_set_current_progress_status(TTR("Retrieving the mirror list..."));
_refresh_mirrors();
}
@@ -374,7 +375,8 @@ void ExportTemplateManager::_install_file() {
}
bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_skip_progress) {
- zlib_filefunc_def io = zipio_create_io();
+ Ref<FileAccess> io_fa;
+ zlib_filefunc_def io = zipio_create_io(&io_fa);
unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io);
if (!pkg) {
@@ -404,9 +406,7 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_
// Read.
unzOpenCurrentFile(pkg);
ret = unzReadCurrentFile(pkg, data.ptrw(), data.size());
- if (ret != UNZ_OK) {
- break;
- }
+ ERR_BREAK_MSG(ret < 0, vformat("An error occurred while attempting to read from file: %s. This file will not be used.", file));
unzCloseCurrentFile(pkg);
String data_str;
@@ -478,9 +478,7 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_
// Read
unzOpenCurrentFile(pkg);
ret = unzReadCurrentFile(pkg, data.ptrw(), data.size());
- if (ret != UNZ_OK) {
- break;
- }
+ ERR_BREAK_MSG(ret < 0, vformat("An error occurred while attempting to read from file: %s. This file will not be used.", file));
unzCloseCurrentFile(pkg);
String base_dir = file_path.get_base_dir().trim_suffix("/");
@@ -595,7 +593,10 @@ void ExportTemplateManager::_mirror_options_button_cbk(int p_id) {
}
}
-void ExportTemplateManager::_installed_table_button_cbk(Object *p_item, int p_column, int p_id) {
+void ExportTemplateManager::_installed_table_button_cbk(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
if (!ti) {
return;
@@ -680,7 +681,8 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_
// Uncompress source template.
- zlib_filefunc_def io = zipio_create_io();
+ Ref<FileAccess> io_fa;
+ zlib_filefunc_def io = zipio_create_io(&io_fa);
unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io);
ERR_FAIL_COND_V_MSG(!pkg, ERR_CANT_OPEN, "Android sources not in ZIP format.");
@@ -696,7 +698,7 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_
ProgressDialog::get_singleton()->add_task("uncompress_src", TTR("Uncompressing Android Build Sources"), total_files);
- Set<String> dirs_tested;
+ HashSet<String> dirs_tested;
int idx = 0;
while (ret == UNZ_OK) {
// Get file path.
@@ -976,7 +978,7 @@ ExportTemplateManager::ExportTemplateManager() {
installed_table->set_custom_minimum_size(Size2(0, 100) * EDSCALE);
installed_table->set_v_size_flags(Control::SIZE_EXPAND_FILL);
main_vb->add_child(installed_table);
- installed_table->connect("button_pressed", callable_mp(this, &ExportTemplateManager::_installed_table_button_cbk));
+ installed_table->connect("button_clicked", callable_mp(this, &ExportTemplateManager::_installed_table_button_cbk));
// Dialogs.
uninstall_confirm = memnew(ConfirmationDialog);