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.cpp58
1 files changed, 24 insertions, 34 deletions
diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp
index 6cbca3f733..a39c8b2209 100644
--- a/editor/export_template_manager.cpp
+++ b/editor/export_template_manager.cpp
@@ -30,6 +30,8 @@
#include "export_template_manager.h"
+#include "core/os/input.h"
+#include "core/os/keyboard.h"
#include "editor_node.h"
#include "editor_scale.h"
#include "io/json.h"
@@ -68,7 +70,7 @@ void ExportTemplateManager::_update_template_list() {
memdelete(d);
- String current_version = itos(VERSION_MAJOR) + "." + itos(VERSION_MINOR) + "-" + VERSION_STATUS + VERSION_MODULE_CONFIG;
+ String current_version = VERSION_FULL_CONFIG;
Label *current = memnew(Label);
current->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -126,7 +128,7 @@ void ExportTemplateManager::_download_template(const String &p_version) {
memdelete(template_list->get_child(0));
}
template_downloader->popup_centered_minsize();
- template_list_state->set_text(TTR("Retrieving mirrors, please wait.."));
+ template_list_state->set_text(TTR("Retrieving mirrors, please wait..."));
template_download_progress->set_max(100);
template_download_progress->set_value(0);
request_mirror->request("https://godotengine.org/mirrorlist/" + p_version + ".json");
@@ -215,25 +217,15 @@ void ExportTemplateManager::_install_from_file(const String &p_file, bool p_use_
data_str.parse_utf8((const char *)data.ptr(), data.size());
data_str = data_str.strip_edges();
- if (data_str.get_slice_count("-") != 2 || data_str.get_slice_count(".") != 2) {
- EditorNode::get_singleton()->show_warning(TTR("Invalid version.txt format inside templates."));
+ // Version number should be of the form major.minor[.patch].status[.module_config]
+ // so it can in theory have 3 or more slices.
+ if (data_str.get_slice_count(".") < 3) {
+ EditorNode::get_singleton()->show_warning(vformat(TTR("Invalid version.txt format inside templates: %s."), data_str));
unzClose(pkg);
return;
}
- String ver = data_str.get_slice("-", 0);
-
- int major = ver.get_slice(".", 0).to_int();
- int minor = ver.get_slice(".", 1).to_int();
- String rev = data_str.get_slice("-", 1);
-
- if (!rev.is_valid_identifier()) {
- EditorNode::get_singleton()->show_warning(TTR("Invalid version.txt format inside templates. Revision is not a valid identifier."));
- unzClose(pkg);
- return;
- }
-
- version = itos(major) + "." + itos(minor) + "-" + rev;
+ version = data_str;
}
fc++;
@@ -400,19 +392,10 @@ void ExportTemplateManager::_http_download_templates_completed(int p_status, int
if (p_code != 200) {
template_list_state->set_text(TTR("Failed:") + " " + itos(p_code));
} else {
- String path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp_templates.tpz");
- FileAccess *f = FileAccess::open(path, FileAccess::WRITE);
- if (!f) {
- template_list_state->set_text(TTR("Can't write file."));
- } else {
- int size = p_data.size();
- PoolVector<uint8_t>::Read r = p_data.read();
- f->store_buffer(r.ptr(), size);
- memdelete(f);
- template_list_state->set_text(TTR("Download Complete."));
- template_downloader->hide();
- _install_from_file(path, false);
- }
+ String path = download_templates->get_download_file();
+ template_list_state->set_text(TTR("Download Complete."));
+ template_downloader->hide();
+ _install_from_file(path, false);
}
} break;
}
@@ -422,6 +405,11 @@ void ExportTemplateManager::_http_download_templates_completed(int p_status, int
void ExportTemplateManager::_begin_template_download(const String &p_url) {
+ if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
+ OS::get_singleton()->shell_open(p_url);
+ return;
+ }
+
for (int i = 0; i < template_list->get_child_count(); i++) {
BaseButton *b = Object::cast_to<BaseButton>(template_list->get_child(0));
if (b) {
@@ -430,6 +418,8 @@ void ExportTemplateManager::_begin_template_download(const String &p_url) {
}
download_data.clear();
+ download_templates->set_download_file(EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp_templates.tpz"));
+ download_templates->set_use_threads(true);
Error err = download_templates->request(p_url);
if (err != OK) {
@@ -443,7 +433,7 @@ void ExportTemplateManager::_begin_template_download(const String &p_url) {
template_download_progress->set_max(100);
template_download_progress->set_value(0);
template_download_progress->show();
- template_list_state->set_text(TTR("Connecting to Mirror.."));
+ template_list_state->set_text(TTR("Connecting to Mirror..."));
}
void ExportTemplateManager::_notification(int p_what) {
@@ -469,13 +459,13 @@ void ExportTemplateManager::_notification(int p_what) {
status = TTR("Can't Resolve");
errored = true;
break;
- case HTTPClient::STATUS_CONNECTING: status = TTR("Connecting.."); break;
+ case HTTPClient::STATUS_CONNECTING: status = TTR("Connecting..."); break;
case HTTPClient::STATUS_CANT_CONNECT:
status = TTR("Can't Connect");
errored = true;
break;
case HTTPClient::STATUS_CONNECTED: status = TTR("Connected"); break;
- case HTTPClient::STATUS_REQUESTING: status = TTR("Requesting.."); break;
+ case HTTPClient::STATUS_REQUESTING: status = TTR("Requesting..."); break;
case HTTPClient::STATUS_BODY:
status = TTR("Downloading");
if (download_templates->get_body_size() > 0) {
@@ -576,7 +566,7 @@ ExportTemplateManager::ExportTemplateManager() {
template_downloader->add_child(vbc);
ScrollContainer *sc = memnew(ScrollContainer);
sc->set_custom_minimum_size(Size2(400, 200) * EDSCALE);
- vbc->add_margin_child(TTR("Select mirror from list: "), sc);
+ vbc->add_margin_child(TTR("Select mirror from list: (Shift+Click: Open in Browser)"), sc);
template_list = memnew(VBoxContainer);
sc->add_child(template_list);
sc->set_enable_v_scroll(true);