diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-06-28 07:51:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-28 07:51:36 +0200 |
commit | f59430beef2fa0d34670b4533167f03018454b00 (patch) | |
tree | a15ad2c9dd78cf3d00cbe55ae187d9e12924f1d3 /platform | |
parent | 7fad30fb9ab0ea19d67b2640668cbb88ebb1747c (diff) | |
parent | a2fd89bbe20d95bffe57c331bd43aff947c55d5e (diff) |
Merge pull request #9419 from eska014/native-run
Subtle native-run buttons
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/export/export.cpp | 12 | ||||
-rw-r--r-- | platform/android/run_icon.png | bin | 0 -> 636 bytes | |||
-rw-r--r-- | platform/javascript/export/export.cpp | 41 | ||||
-rw-r--r-- | platform/javascript/run_icon.png | bin | 0 -> 471 bytes |
4 files changed, 51 insertions, 2 deletions
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index d6ed234669..a72e8aa90e 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 <string.h> #if 0 @@ -2042,6 +2043,7 @@ class EditorExportAndroid : public EditorExportPlatform { GDCLASS(EditorExportAndroid, EditorExportPlatform) Ref<ImageTexture> logo; + Ref<ImageTexture> run_icon; struct Device { @@ -3036,6 +3038,10 @@ public: return OK; } + virtual Ref<Texture> get_run_icon() const { + return run_icon; + } + virtual bool can_export(const Ref<EditorExportPreset> &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<Image> img = memnew(Image(_android_logo)); - logo = Ref<ImageTexture>(memnew(ImageTexture)); + logo.instance(); logo->create_from_image(img); + img = Ref<Image>(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 Binary files differnew file mode 100644 index 0000000000..e53f8e9da5 --- /dev/null +++ b/platform/android/run_icon.png diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index 8b04deabd7..4bdfdae39e 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -31,6 +31,7 @@ #include "editor_export.h" #include "io/zip_io.h" #include "platform/javascript/logo.gen.h" +#include "platform/javascript/run_icon.gen.h" #define EXPORT_TEMPLATE_WEBASSEMBLY_RELEASE "webassembly_release.zip" #define EXPORT_TEMPLATE_WEBASSEMBLY_DEBUG "webassembly_debug.zip" @@ -42,6 +43,8 @@ class EditorExportPlatformJavaScript : public EditorExportPlatform { GDCLASS(EditorExportPlatformJavaScript, EditorExportPlatform) Ref<ImageTexture> logo; + Ref<ImageTexture> run_icon; + bool runnable_when_last_polled; void _fix_html(Vector<uint8_t> &p_html, const Ref<EditorExportPreset> &p_preset, const String &p_name, bool p_debug); void _fix_fsloader_js(Vector<uint8_t> &p_js, const String &p_pack_name, uint64_t p_pack_size); @@ -64,10 +67,12 @@ public: virtual String get_binary_extension() const; virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0); - virtual int get_device_count() const { return 1; } + virtual bool poll_devices(); + virtual int get_device_count() const; 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<EditorExportPreset> &p_preset, int p_device, int p_debug_flags); + virtual Ref<Texture> get_run_icon() const; EditorExportPlatformJavaScript(); }; @@ -303,6 +308,29 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese return OK; } +bool EditorExportPlatformJavaScript::poll_devices() { + + Ref<EditorExportPreset> preset; + + for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) { + + Ref<EditorExportPreset> ep = EditorExport::get_singleton()->get_export_preset(i); + if (ep->is_runnable() && ep->get_platform() == this) { + preset = ep; + break; + } + } + + bool prev = runnable_when_last_polled; + runnable_when_last_polled = preset.is_valid(); + return runnable_when_last_polled != prev; +} + +int EditorExportPlatformJavaScript::get_device_count() const { + + return runnable_when_last_polled; +} + Error EditorExportPlatformJavaScript::run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) { String path = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmp_export.html"; @@ -314,11 +342,22 @@ Error EditorExportPlatformJavaScript::run(const Ref<EditorExportPreset> &p_prese return OK; } +Ref<Texture> EditorExportPlatformJavaScript::get_run_icon() const { + + return run_icon; +} + EditorExportPlatformJavaScript::EditorExportPlatformJavaScript() { Ref<Image> img = memnew(Image(_javascript_logo)); logo.instance(); logo->create_from_image(img); + + img = Ref<Image>(memnew(Image(_javascript_run_icon))); + run_icon.instance(); + run_icon->create_from_image(img); + + runnable_when_last_polled = false; } void register_javascript_exporter() { diff --git a/platform/javascript/run_icon.png b/platform/javascript/run_icon.png Binary files differnew file mode 100644 index 0000000000..dedee6f479 --- /dev/null +++ b/platform/javascript/run_icon.png |