summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-11-01 23:12:28 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-11-01 23:13:27 -0300
commit79f81b77e2160fd4fb490b9e8e05636de70174bf (patch)
treee1596942656e0e6d9249e3f1921530edc40824fd
parent93a3d1714ee9b1535ac8f902bd7b2b3135712b90 (diff)
-Modules can now add custom version info (added it for Mono)
-Version string takes this version info -Ability to download templates from the interweb (listing does not work yet)
-rw-r--r--SConstruct20
-rw-r--r--core/version.h4
-rw-r--r--editor/export_template_manager.cpp226
-rw-r--r--editor/export_template_manager.h20
-rw-r--r--methods.py6
-rw-r--r--modules/mono/config.py1
-rw-r--r--scene/main/http_request.cpp1
-rw-r--r--version.py1
8 files changed, 268 insertions, 11 deletions
diff --git a/SConstruct b/SConstruct
index c05a4332ab..484368c9b5 100644
--- a/SConstruct
+++ b/SConstruct
@@ -11,7 +11,8 @@ import glob
import sys
import methods
-methods.update_version()
+# moved below to compensate with module version string
+# methods.update_version()
# scan possible build platforms
@@ -87,6 +88,7 @@ env_base.android_appattributes_chunk = ""
env_base.disabled_modules = []
env_base.use_ptrcall = False
env_base.split_drivers = False
+env_base.module_version_string = ""
# To decide whether to rebuild a file, use the MD5 sum only if the timestamp has changed.
# http://scons.org/doc/production/HTML/scons-user/ch06.html#idm139837621851792
@@ -111,6 +113,8 @@ env_base.__class__.android_add_gradle_plugin = methods.android_add_gradle_plugin
env_base.__class__.android_add_gradle_classpath = methods.android_add_gradle_classpath
env_base.__class__.disable_module = methods.disable_module
+env_base.__class__.add_module_version_string = methods.add_module_version_string
+
env_base.__class__.add_source_files = methods.add_source_files
env_base.__class__.use_windows_spawn_fix = methods.use_windows_spawn_fix
env_base.__class__.split_lib = methods.split_lib
@@ -358,11 +362,6 @@ if selected_platform in platform_list:
suffix += env.extra_suffix
- env["PROGSUFFIX"] = suffix + env["PROGSUFFIX"]
- env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"]
- env["LIBSUFFIX"] = suffix + env["LIBSUFFIX"]
- env["SHLIBSUFFIX"] = suffix + env["SHLIBSUFFIX"]
-
sys.path.remove("./platform/" + selected_platform)
sys.modules.pop('detect')
@@ -391,6 +390,15 @@ if selected_platform in platform_list:
sys.path.remove(tmppath)
sys.modules.pop('config')
+ methods.update_version(env.module_version_string)
+
+ suffix += env.module_version_string
+
+ env["PROGSUFFIX"] = suffix + env["PROGSUFFIX"]
+ env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"]
+ env["LIBSUFFIX"] = suffix + env["LIBSUFFIX"]
+ env["SHLIBSUFFIX"] = suffix + env["SHLIBSUFFIX"]
+
if (env.use_ptrcall):
env.Append(CPPFLAGS=['-DPTRCALL_ENABLED'])
diff --git a/core/version.h b/core/version.h
index 436f30ef01..7d2c47df6a 100644
--- a/core/version.h
+++ b/core/version.h
@@ -30,8 +30,8 @@
#include "version_generated.gen.h"
#ifdef VERSION_PATCH
-#define VERSION_MKSTRING "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." _MKSTR(VERSION_PATCH) "." _MKSTR(VERSION_STATUS) "." _MKSTR(VERSION_REVISION)
+#define VERSION_MKSTRING "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." _MKSTR(VERSION_PATCH) "." _MKSTR(VERSION_STATUS) "." _MKSTR(VERSION_REVISION) VERSION_MODULE_CONFIG
#else
-#define VERSION_MKSTRING "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." _MKSTR(VERSION_STATUS) "." _MKSTR(VERSION_REVISION)
+#define VERSION_MKSTRING "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." _MKSTR(VERSION_STATUS) "." _MKSTR(VERSION_REVISION) VERSION_MODULE_CONFIG
#endif // VERSION_PATCH
#define VERSION_FULL_NAME "" _MKSTR(VERSION_NAME) " v" VERSION_MKSTRING
diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp
index d867404f3d..164d02c580 100644
--- a/editor/export_template_manager.cpp
+++ b/editor/export_template_manager.cpp
@@ -31,10 +31,10 @@
#include "editor_node.h"
#include "editor_scale.h"
+#include "io/json.h"
#include "io/zip_io.h"
#include "os/dir_access.h"
#include "version.h"
-
void ExportTemplateManager::_update_template_list() {
while (current_hb->get_child_count()) {
@@ -66,7 +66,7 @@ void ExportTemplateManager::_update_template_list() {
memdelete(d);
- String current_version = itos(VERSION_MAJOR) + "." + itos(VERSION_MINOR) + "-" + _MKSTR(VERSION_STATUS);
+ String current_version = itos(VERSION_MAJOR) + "." + itos(VERSION_MINOR) + "-" + _MKSTR(VERSION_STATUS) + VERSION_MODULE_CONFIG;
Label *current = memnew(Label);
current->set_h_size_flags(SIZE_EXPAND_FILL);
@@ -120,6 +120,16 @@ void ExportTemplateManager::_update_template_list() {
void ExportTemplateManager::_download_template(const String &p_version) {
print_line("download " + p_version);
+ while (template_list->get_child_count()) {
+ memdelete(template_list->get_child(0));
+ }
+ template_downloader->popup_centered_minsize();
+ 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://www.godotengine.org/download_mirrors.php?version=" + p_version);
+ template_list_state->show();
+ template_download_progress->show();
}
void ExportTemplateManager::_uninstall_template(const String &p_version) {
@@ -307,12 +317,195 @@ void ExportTemplateManager::ok_pressed() {
template_open->popup_centered_ratio();
}
+void ExportTemplateManager::_http_download_mirror_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data) {
+
+ print_line("mirror complete");
+ String mirror_str = "{ \"mirrors\":[{\"name\":\"Official\",\"url\":\"http://op.godotengine.org:81/downloads/2.1.4/Godot_v2.1.4-stable_linux_server.64.zip\"}] }";
+
+ template_list_state->hide();
+ template_download_progress->hide();
+
+ Variant r;
+ String errs;
+ int errline;
+ Error err = JSON::parse(mirror_str, r, errs, errline);
+ if (err != OK) {
+ EditorNode::get_singleton()->show_warning("Error parsing JSON with mirror list. Please report this issue!");
+ return;
+ }
+
+ bool mirrors_found = false;
+
+ Dictionary d = r;
+ print_line(r);
+ if (d.has("mirrors")) {
+ Array mirrors = d["mirrors"];
+ for (int i = 0; i < mirrors.size(); i++) {
+ Dictionary m = mirrors[i];
+ ERR_CONTINUE(!m.has("url") || !m.has("name"));
+ LinkButton *lb = memnew(LinkButton);
+ lb->set_text(m["name"]);
+ lb->connect("pressed", this, "_begin_template_download", varray(m["url"]));
+ template_list->add_child(lb);
+ mirrors_found = true;
+ }
+ }
+
+ if (!mirrors_found) {
+ EditorNode::get_singleton()->show_warning(TTR("No download links found for this version. Direct download is only available for official releases."));
+ return;
+ }
+}
+void ExportTemplateManager::_http_download_templates_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data) {
+
+ switch (p_status) {
+
+ case HTTPRequest::RESULT_CANT_RESOLVE: {
+ template_list_state->set_text(TTR("Can't resolve."));
+ } break;
+ case HTTPRequest::RESULT_BODY_SIZE_LIMIT_EXCEEDED:
+ case HTTPRequest::RESULT_CONNECTION_ERROR:
+ case HTTPRequest::RESULT_CHUNKED_BODY_SIZE_MISMATCH: {
+ template_list_state->set_text(TTR("Can't connect."));
+ } break;
+ case HTTPRequest::RESULT_SSL_HANDSHAKE_ERROR:
+ case HTTPRequest::RESULT_CANT_CONNECT: {
+ template_list_state->set_text(TTR("Can't connect."));
+ } break;
+ case HTTPRequest::RESULT_NO_RESPONSE: {
+ template_list_state->set_text(TTR("No response."));
+ } break;
+ case HTTPRequest::RESULT_REQUEST_FAILED: {
+ template_list_state->set_text(TTR("Req. Failed."));
+ } break;
+ case HTTPRequest::RESULT_REDIRECT_LIMIT_REACHED: {
+ template_list_state->set_text(TTR("Redirect Loop."));
+ } break;
+ default: {
+ if (p_code != 200) {
+ template_list_state->set_text(TTR("Failed:") + " " + itos(p_code));
+ } else {
+ String path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp").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);
+ }
+ }
+ } break;
+ }
+
+ set_process(false);
+}
+
+void ExportTemplateManager::_begin_template_download(const String &p_url) {
+
+ for (int i = 0; i < template_list->get_child_count(); i++) {
+ BaseButton *b = Object::cast_to<BaseButton>(template_list->get_child(0));
+ if (b) {
+ b->set_disabled(true);
+ }
+ }
+
+ download_data.clear();
+
+ Error err = download_templates->request(p_url);
+ if (err != OK) {
+ EditorNode::get_singleton()->show_warning(TTR("Error requesting url: ") + p_url);
+ return;
+ }
+
+ set_process(true);
+
+ template_list_state->show();
+ 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.."));
+}
+
+void ExportTemplateManager::_notification(int p_what) {
+
+ if (p_what == NOTIFICATION_PROCESS) {
+
+ update_countdown -= get_process_delta_time();
+
+ if (update_countdown > 0) {
+ return;
+ }
+ update_countdown = 0.5;
+ String status;
+ bool errored = false;
+
+ switch (download_templates->get_http_client_status()) {
+ case HTTPClient::STATUS_DISCONNECTED:
+ status = TTR("Disconnected");
+ errored = true;
+ break;
+ case HTTPClient::STATUS_RESOLVING: status = TTR("Resolving"); break;
+ case HTTPClient::STATUS_CANT_RESOLVE:
+ status = TTR("Can't Resolve");
+ errored = true;
+ break;
+ case HTTPClient::STATUS_CONNECTING: status = TTR("Connecting.."); break;
+ case HTTPClient::STATUS_CANT_CONNECT:
+ status = TTR("Can't Conect");
+ errored = true;
+ break;
+ case HTTPClient::STATUS_CONNECTED: status = TTR("Connected"); break;
+ case HTTPClient::STATUS_REQUESTING: status = TTR("Requesting.."); break;
+ case HTTPClient::STATUS_BODY:
+ status = TTR("Downloading");
+ if (download_templates->get_body_size() > 0) {
+ status += " " + String::humanize_size(download_templates->get_downloaded_bytes()) + "/" + String::humanize_size(download_templates->get_body_size());
+ template_download_progress->set_max(download_templates->get_body_size());
+ template_download_progress->set_value(download_templates->get_downloaded_bytes());
+ } else {
+ status += " " + String::humanize_size(download_templates->get_downloaded_bytes());
+ }
+ break;
+ case HTTPClient::STATUS_CONNECTION_ERROR:
+ status = TTR("Connection Error");
+ errored = true;
+ break;
+ case HTTPClient::STATUS_SSL_HANDSHAKE_ERROR:
+ status = TTR("SSL Handshake Error");
+ errored = true;
+ break;
+ }
+
+ template_list_state->set_text(status);
+ if (errored) {
+ set_process(false);
+ ;
+ }
+ }
+
+ if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
+ if (!is_visible_in_tree()) {
+ print_line("closed");
+ download_templates->cancel_request();
+ set_process(false);
+ }
+ }
+}
+
void ExportTemplateManager::_bind_methods() {
ClassDB::bind_method("_download_template", &ExportTemplateManager::_download_template);
ClassDB::bind_method("_uninstall_template", &ExportTemplateManager::_uninstall_template);
ClassDB::bind_method("_uninstall_template_confirm", &ExportTemplateManager::_uninstall_template_confirm);
ClassDB::bind_method("_install_from_file", &ExportTemplateManager::_install_from_file);
+ ClassDB::bind_method("_http_download_mirror_completed", &ExportTemplateManager::_http_download_mirror_completed);
+ ClassDB::bind_method("_http_download_templates_completed", &ExportTemplateManager::_http_download_templates_completed);
+ ClassDB::bind_method("_begin_template_download", &ExportTemplateManager::_begin_template_download);
}
ExportTemplateManager::ExportTemplateManager() {
@@ -350,4 +543,33 @@ ExportTemplateManager::ExportTemplateManager() {
set_title(TTR("Export Template Manager"));
set_hide_on_ok(false);
+
+ request_mirror = memnew(HTTPRequest);
+ add_child(request_mirror);
+ request_mirror->connect("request_completed", this, "_http_download_mirror_completed");
+
+ download_templates = memnew(HTTPRequest);
+ add_child(download_templates);
+ download_templates->connect("request_completed", this, "_http_download_templates_completed");
+
+ template_downloader = memnew(AcceptDialog);
+ template_downloader->set_title(TTR("Download Templates"));
+ template_downloader->get_ok()->set_text(TTR("Close"));
+ add_child(template_downloader);
+
+ VBoxContainer *vbc = memnew(VBoxContainer);
+ 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);
+ template_list = memnew(VBoxContainer);
+ sc->add_child(template_list);
+ sc->set_enable_v_scroll(true);
+ sc->set_enable_h_scroll(false);
+ template_list_state = memnew(Label);
+ vbc->add_child(template_list_state);
+ template_download_progress = memnew(ProgressBar);
+ vbc->add_child(template_download_progress);
+
+ update_countdown = 0;
}
diff --git a/editor/export_template_manager.h b/editor/export_template_manager.h
index c77f85688f..644c6b466b 100644
--- a/editor/export_template_manager.h
+++ b/editor/export_template_manager.h
@@ -33,13 +33,20 @@
#include "editor/editor_settings.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/file_dialog.h"
+#include "scene/gui/progress_bar.h"
#include "scene/gui/scroll_container.h"
+#include "scene/main/http_request.h"
class ExportTemplateVersion;
class ExportTemplateManager : public ConfirmationDialog {
GDCLASS(ExportTemplateManager, ConfirmationDialog)
+ AcceptDialog *template_downloader;
+ VBoxContainer *template_list;
+ Label *template_list_state;
+ ProgressBar *template_download_progress;
+
ScrollContainer *installed_scroll;
VBoxContainer *installed_vb;
HBoxContainer *current_hb;
@@ -48,6 +55,13 @@ class ExportTemplateManager : public ConfirmationDialog {
ConfirmationDialog *remove_confirm;
String to_remove;
+ HTTPRequest *request_mirror;
+ HTTPRequest *download_templates;
+
+ Vector<uint8_t> download_data;
+
+ float update_countdown;
+
void _update_template_list();
void _download_template(const String &p_version);
@@ -57,7 +71,13 @@ class ExportTemplateManager : public ConfirmationDialog {
virtual void ok_pressed();
void _install_from_file(const String &p_file);
+ void _http_download_mirror_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data);
+ void _http_download_templates_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data);
+
+ void _begin_template_download(const String &p_url);
+
protected:
+ void _notification(int p_what);
static void _bind_methods();
public:
diff --git a/methods.py b/methods.py
index b62dfc6544..2f3dac7e42 100644
--- a/methods.py
+++ b/methods.py
@@ -1149,7 +1149,10 @@ def build_gles3_headers(target, source, env):
build_legacygl_header(str(x), include="drivers/gles3/shader_gles3.h", class_suffix="GLES3", output_attribs=True)
-def update_version():
+def add_module_version_string(self,s):
+ self.module_version_string+="."+s
+
+def update_version(module_version_string=""):
rev = "custom_build"
@@ -1167,6 +1170,7 @@ def update_version():
f.write("#define VERSION_PATCH " + str(version.patch) + "\n")
f.write("#define VERSION_REVISION " + str(rev) + "\n")
f.write("#define VERSION_STATUS " + str(version.status) + "\n")
+ f.write("#define VERSION_MODULE_CONFIG \"" + str(version.module_config) + module_version_string + "\"\n")
import datetime
f.write("#define VERSION_YEAR " + str(datetime.datetime.now().year) + "\n")
f.close()
diff --git a/modules/mono/config.py b/modules/mono/config.py
index 44eef45f76..7ad135e0b9 100644
--- a/modules/mono/config.py
+++ b/modules/mono/config.py
@@ -47,6 +47,7 @@ def copy_file_no_replace(src_dir, dst_dir, name):
def configure(env):
env.use_ptrcall = True
+ env.add_module_version_string("mono")
envvars = Variables()
envvars.Add(BoolVariable('mono_static', 'Statically link mono', False))
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index 1e1e4f2d5f..672e893f1b 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -579,6 +579,7 @@ HTTPRequest::HTTPRequest() {
client.instance();
use_threads = false;
thread_done = false;
+ downloaded = 0;
body_size_limit = -1;
file = NULL;
status = HTTPClient::STATUS_DISCONNECTED;
diff --git a/version.py b/version.py
index f0da206837..38847d68f5 100644
--- a/version.py
+++ b/version.py
@@ -3,3 +3,4 @@ name = "Godot Engine"
major = 3
minor = 0
status = "alpha"
+module_config = ""