From 92367968e7f1416f33eebfa06c60cacf5c757f65 Mon Sep 17 00:00:00 2001 From: "L. Krause" Date: Thu, 25 May 2017 20:57:13 +0200 Subject: [PATCH] Use custom native-run icons for Android and HTML5 --- editor/editor_export.h | 1 + editor/editor_run_native.cpp | 2 +- methods.py | 31 ++++++++++++++------------ platform/android/export/export.cpp | 12 +++++++++- platform/android/run_icon.png | Bin 0 -> 636 bytes platform/javascript/export/export.cpp | 12 ++++++++++ platform/javascript/run_icon.png | Bin 0 -> 471 bytes 7 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 platform/android/run_icon.png create mode 100644 platform/javascript/run_icon.png diff --git a/editor/editor_export.h b/editor/editor_export.h index 740f05174b6..64381fbb35f 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -197,6 +197,7 @@ public: }; virtual Error run(const Ref &p_preset, int p_device, int p_debug_flags) { return OK; } + virtual Ref get_run_icon() const { return get_logo(); } virtual bool can_export(const Ref &p_preset, String &r_error, bool &r_missing_templates) const = 0; diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp index 4a767621ef8..52b7e6992de 100644 --- a/editor/editor_run_native.cpp +++ b/editor/editor_run_native.cpp @@ -41,7 +41,7 @@ void EditorRunNative::_notification(int p_what) { Ref eep = EditorExport::get_singleton()->get_export_platform(i); if (eep.is_null()) continue; - Ref icon = eep->get_logo(); + Ref icon = eep->get_run_icon(); if (!icon.is_null()) { Ref im = icon->get_data(); im = im->duplicate(); diff --git a/methods.py b/methods.py index 2f9d45897eb..4d3d5ae3432 100644 --- a/methods.py +++ b/methods.py @@ -1513,23 +1513,26 @@ def split_lib(self, libname): def save_active_platforms(apnames, ap): for x in ap: - pth = x + "/logo.png" -# print("open path: "+pth) - pngf = open(pth, "rb") - b = pngf.read(1) - str = " /* AUTOGENERATED FILE, DO NOT EDIT */ \n" - str += " static const unsigned char _" + x[9:] + "_logo[]={" - while(len(b) == 1): - str += hex(ord(b)) + names = ['logo'] + if os.path.isfile(x + "/run_icon.png"): + names.append('run_icon') + + for name in names: + pngf = open(x + "/" + name + ".png", "rb") b = pngf.read(1) - if (len(b) == 1): - str += "," + str = " /* AUTOGENERATED FILE, DO NOT EDIT */ \n" + str += " static const unsigned char _" + x[9:] + "_" + name + "[]={" + while(len(b) == 1): + str += hex(ord(b)) + b = pngf.read(1) + if (len(b) == 1): + str += "," - str += "};\n" + str += "};\n" - wf = x + "/logo.gen.h" - logow = open(wf, "wb") - logow.write(str) + wf = x + "/" + name + ".gen.h" + pngw = open(wf, "wb") + pngw.write(str) def no_verbose(sys, env): diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index d6ed2346693..a72e8aa90e2 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -37,6 +37,7 @@ #include "os/file_access.h" #include "os/os.h" #include "platform/android/logo.gen.h" +#include "platform/android/run_icon.gen.h" #include "version.h" #include #if 0 @@ -2042,6 +2043,7 @@ class EditorExportAndroid : public EditorExportPlatform { GDCLASS(EditorExportAndroid, EditorExportPlatform) Ref logo; + Ref run_icon; struct Device { @@ -3036,6 +3038,10 @@ public: return OK; } + virtual Ref get_run_icon() const { + return run_icon; + } + virtual bool can_export(const Ref &p_preset, String &r_error, bool &r_missing_templates) const { r_missing_templates = find_export_template("android_debug.apk") == String() || find_export_template("android_release.apk") == String(); @@ -3524,9 +3530,13 @@ public: EditorExportAndroid() { Ref img = memnew(Image(_android_logo)); - logo = Ref(memnew(ImageTexture)); + logo.instance(); logo->create_from_image(img); + img = Ref(memnew(Image(_android_run_icon))); + run_icon.instance(); + run_icon->create_from_image(img); + device_lock = Mutex::create(); device_thread = Thread::create(_device_poll_thread, this); devices_changed = true; diff --git a/platform/android/run_icon.png b/platform/android/run_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..e53f8e9da5ac47b03b3c6390677e9c098bff937e GIT binary patch literal 636 zcmV-?0)zdDP)004R>004l5008;`004mK004C`008P>0026e000+ooVrmw00009 za7bBm000XT000XT0n*)m`~Uy|2XskIMF-#p77{BJB&{M{0000PbVXQnQ*UN;cVTj6 z0B~VxZgehgWpp4kE-)@JHbiN!^#A|?x=BPqR5(w4Q@=|BVHiFuD3=I~28W8Ef1s(s zmcYR!XfcOFgq#Zwmn1~QmL>@yax!rckwVl#jKozia&V|aZ4x}h;W!#Xxt>?e$OnC)h>`67y logo; + Ref run_icon; void _fix_html(Vector &p_html, const Ref &p_preset, const String &p_name, bool p_debug); void _fix_fsloader_js(Vector &p_js, const String &p_pack_name, uint64_t p_pack_size); @@ -68,6 +70,7 @@ public: virtual String get_device_name(int p_device) const { return TTR("Run in Browser"); } virtual String get_device_info(int p_device) const { return TTR("Run exported HTML in the system's default browser."); } virtual Error run(const Ref &p_preset, int p_device, int p_debug_flags); + virtual Ref get_run_icon() const; EditorExportPlatformJavaScript(); }; @@ -314,11 +317,20 @@ Error EditorExportPlatformJavaScript::run(const Ref &p_prese return OK; } +Ref EditorExportPlatformJavaScript::get_run_icon() const { + + return run_icon; +} + EditorExportPlatformJavaScript::EditorExportPlatformJavaScript() { Ref img = memnew(Image(_javascript_logo)); logo.instance(); logo->create_from_image(img); + + img = Ref(memnew(Image(_javascript_run_icon))); + run_icon.instance(); + run_icon->create_from_image(img); } void register_javascript_exporter() { diff --git a/platform/javascript/run_icon.png b/platform/javascript/run_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..dedee6f479e2e7648d35af1c8cb235f248db98ff GIT binary patch literal 471 zcmV;|0Vw{7P)9cj1Q zuJVjSX5Po@C2Kb#;$XZO_pml3@xuV$L+qj_@cn`>O%L$>ZfY8VZ&mOa{#N#0b-so- zxYN`OBIw`*vsF<|)5YXDf{5s5W(QNag&SBeMW6fdJLp72wdECYyY!P7|YD(rT^>0X3${G;8i&vW#$*$E%r${ z_gbh4_OR{z7S7-wzG4E4_@Ua)k^bwPnK$tmPq19v@9_>FBjUKu{|~sET#IdM5f}gf N002ovPDHLkV1jDe&}#qy literal 0 HcmV?d00001