diff --git a/doc/classes/EditorExportPlatformExtension.xml b/doc/classes/EditorExportPlatformExtension.xml index 73247e59665..13c8fc072c8 100644 --- a/doc/classes/EditorExportPlatformExtension.xml +++ b/doc/classes/EditorExportPlatformExtension.xml @@ -221,6 +221,12 @@ Returns [code]true[/code] if project configuration is valid. + + + + Initializes the plugin. Called by the editor when platform is registered. + + diff --git a/editor/export/editor_export.cpp b/editor/export/editor_export.cpp index 5e76c5950a3..e28304c4fca 100644 --- a/editor/export/editor_export.cpp +++ b/editor/export/editor_export.cpp @@ -127,6 +127,7 @@ void EditorExport::_bind_methods() { } void EditorExport::add_export_platform(const Ref &p_platform) { + p_platform->initialize(); export_platforms.push_back(p_platform); should_update_presets = true; diff --git a/editor/export/editor_export_platform.h b/editor/export/editor_export_platform.h index 7189f1ad81c..5200c108859 100644 --- a/editor/export/editor_export_platform.h +++ b/editor/export/editor_export_platform.h @@ -349,6 +349,8 @@ public: virtual void resolve_platform_feature_priorities(const Ref &p_preset, HashSet &p_features) {} virtual String get_debug_protocol() const { return "tcp://"; } virtual HashMap get_custom_project_settings(const Ref &p_preset) const { return HashMap(); } + + virtual void initialize() {} }; VARIANT_ENUM_CAST(EditorExportPlatform::ExportMessageType) diff --git a/editor/export/editor_export_platform_apple_embedded.cpp b/editor/export/editor_export_platform_apple_embedded.cpp index 4699d7a35ed..30334300862 100644 --- a/editor/export/editor_export_platform_apple_embedded.cpp +++ b/editor/export/editor_export_platform_apple_embedded.cpp @@ -2815,23 +2815,21 @@ Error EditorExportPlatformAppleEmbedded::run(const Ref &p_pr #endif } -EditorExportPlatformAppleEmbedded::EditorExportPlatformAppleEmbedded(const char *p_platform_logo_svg, const char *p_run_icon_svg) { - if (EditorNode::get_singleton()) { - Ref img = memnew(Image); - const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE); +void EditorExportPlatformAppleEmbedded::_initialize(const char *p_platform_logo_svg, const char *p_run_icon_svg) { + Ref img = memnew(Image); + const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE); - ImageLoaderSVG::create_image_from_string(img, p_platform_logo_svg, EDSCALE, upsample, false); - logo = ImageTexture::create_from_image(img); + ImageLoaderSVG::create_image_from_string(img, p_platform_logo_svg, EDSCALE, upsample, false); + logo = ImageTexture::create_from_image(img); - ImageLoaderSVG::create_image_from_string(img, p_run_icon_svg, EDSCALE, upsample, false); - run_icon = ImageTexture::create_from_image(img); + ImageLoaderSVG::create_image_from_string(img, p_run_icon_svg, EDSCALE, upsample, false); + run_icon = ImageTexture::create_from_image(img); - plugins_changed.set(); - devices_changed.set(); + plugins_changed.set(); + devices_changed.set(); #ifdef MACOS_ENABLED - _update_preset_status(); + _update_preset_status(); #endif - } } EditorExportPlatformAppleEmbedded::~EditorExportPlatformAppleEmbedded() { diff --git a/editor/export/editor_export_platform_apple_embedded.h b/editor/export/editor_export_platform_apple_embedded.h index 912ebf31aa2..283392cf8ae 100644 --- a/editor/export/editor_export_platform_apple_embedded.h +++ b/editor/export/editor_export_platform_apple_embedded.h @@ -229,6 +229,8 @@ protected: r_features->push_back("apple_embedded"); } + void _initialize(const char *p_platform_logo_svg, const char *p_run_icon_svg); + public: virtual Ref get_logo() const override { return logo; } virtual Ref get_run_icon() const override { return run_icon; } @@ -279,7 +281,6 @@ public: virtual void resolve_platform_feature_priorities(const Ref &p_preset, HashSet &p_features) override { } - EditorExportPlatformAppleEmbedded(const char *p_platform_logo_svg, const char *p_run_icon_svg); ~EditorExportPlatformAppleEmbedded(); /// List the gdip files in the directory specified by the p_path parameter. diff --git a/editor/export/editor_export_platform_extension.cpp b/editor/export/editor_export_platform_extension.cpp index a9aad4ffa44..b185fa4c93e 100644 --- a/editor/export/editor_export_platform_extension.cpp +++ b/editor/export/editor_export_platform_extension.cpp @@ -81,6 +81,8 @@ void EditorExportPlatformExtension::_bind_methods() { GDVIRTUAL_BIND(_get_platform_features); GDVIRTUAL_BIND(_get_debug_protocol); + + GDVIRTUAL_BIND(_initialize); } void EditorExportPlatformExtension::get_preset_features(const Ref &p_preset, List *r_features) const { @@ -358,6 +360,10 @@ String EditorExportPlatformExtension::get_debug_protocol() const { return EditorExportPlatform::get_debug_protocol(); } +void EditorExportPlatformExtension::initialize() { + GDVIRTUAL_CALL(_initialize); +} + EditorExportPlatformExtension::EditorExportPlatformExtension() { //NOP } diff --git a/editor/export/editor_export_platform_extension.h b/editor/export/editor_export_platform_extension.h index 08d560b04ea..fcce05015db 100644 --- a/editor/export/editor_export_platform_extension.h +++ b/editor/export/editor_export_platform_extension.h @@ -151,6 +151,9 @@ public: virtual String get_debug_protocol() const override; GDVIRTUAL0RC(String, _get_debug_protocol); + virtual void initialize() override; + GDVIRTUAL0(_initialize); + EditorExportPlatformExtension(); ~EditorExportPlatformExtension(); }; diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 4bb7263db45..1a80eb751cf 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -4250,7 +4250,7 @@ void EditorExportPlatformAndroid::get_platform_features(List *r_features void EditorExportPlatformAndroid::resolve_platform_feature_priorities(const Ref &p_preset, HashSet &p_features) { } -EditorExportPlatformAndroid::EditorExportPlatformAndroid() { +void EditorExportPlatformAndroid::initialize() { if (EditorNode::get_singleton()) { Ref img = memnew(Image); const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE); diff --git a/platform/android/export/export_plugin.h b/platform/android/export/export_plugin.h index c350472eeaf..4ffca5458f0 100644 --- a/platform/android/export/export_plugin.h +++ b/platform/android/export/export_plugin.h @@ -279,7 +279,7 @@ public: virtual void resolve_platform_feature_priorities(const Ref &p_preset, HashSet &p_features) override; - EditorExportPlatformAndroid(); + virtual void initialize() override; ~EditorExportPlatformAndroid(); }; diff --git a/platform/ios/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp index 58f49aea8b0..56e4ae10b3e 100644 --- a/platform/ios/export/export_plugin.cpp +++ b/platform/ios/export/export_plugin.cpp @@ -33,13 +33,17 @@ #include "logo_svg.gen.h" #include "run_icon_svg.gen.h" +#include "editor/editor_node.h" + Vector EditorExportPlatformIOS::device_types({ "iPhone", "iPad" }); -EditorExportPlatformIOS::EditorExportPlatformIOS() : - EditorExportPlatformAppleEmbedded(_ios_logo_svg, _ios_run_icon_svg) { +void EditorExportPlatformIOS::initialize() { + if (EditorNode::get_singleton()) { + EditorExportPlatformAppleEmbedded::_initialize(_ios_logo_svg, _ios_run_icon_svg); #ifdef MACOS_ENABLED - _start_remote_device_poller_thread(); + _start_remote_device_poller_thread(); #endif + } } EditorExportPlatformIOS::~EditorExportPlatformIOS() { diff --git a/platform/ios/export/export_plugin.h b/platform/ios/export/export_plugin.h index 7a352de584d..99a21e88299 100644 --- a/platform/ios/export/export_plugin.h +++ b/platform/ios/export/export_plugin.h @@ -63,6 +63,6 @@ public: r_features->push_back("ios"); } - EditorExportPlatformIOS(); + virtual void initialize() override; ~EditorExportPlatformIOS(); }; diff --git a/platform/linuxbsd/export/export_plugin.cpp b/platform/linuxbsd/export/export_plugin.cpp index 77f2c79c33e..7e6269ae55e 100644 --- a/platform/linuxbsd/export/export_plugin.cpp +++ b/platform/linuxbsd/export/export_plugin.cpp @@ -612,7 +612,7 @@ Error EditorExportPlatformLinuxBSD::run(const Ref &p_preset, #undef CLEANUP_AND_RETURN } -EditorExportPlatformLinuxBSD::EditorExportPlatformLinuxBSD() { +void EditorExportPlatformLinuxBSD::initialize() { if (EditorNode::get_singleton()) { Ref img = memnew(Image); const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE); diff --git a/platform/linuxbsd/export/export_plugin.h b/platform/linuxbsd/export/export_plugin.h index 494a54bc084..91f84f5a245 100644 --- a/platform/linuxbsd/export/export_plugin.h +++ b/platform/linuxbsd/export/export_plugin.h @@ -89,5 +89,5 @@ public: virtual Error run(const Ref &p_preset, int p_device, BitField p_debug_flags) override; virtual void cleanup() override; - EditorExportPlatformLinuxBSD(); + virtual void initialize() override; }; diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp index 0521639c0d5..4ef67878a0d 100644 --- a/platform/macos/export/export_plugin.cpp +++ b/platform/macos/export/export_plugin.cpp @@ -2814,7 +2814,7 @@ Error EditorExportPlatformMacOS::run(const Ref &p_preset, in #undef CLEANUP_AND_RETURN } -EditorExportPlatformMacOS::EditorExportPlatformMacOS() { +void EditorExportPlatformMacOS::initialize() { if (EditorNode::get_singleton()) { Ref img = memnew(Image); const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE); diff --git a/platform/macos/export/export_plugin.h b/platform/macos/export/export_plugin.h index 4eea8dc1906..d67daa459cf 100644 --- a/platform/macos/export/export_plugin.h +++ b/platform/macos/export/export_plugin.h @@ -170,5 +170,5 @@ public: virtual Error run(const Ref &p_preset, int p_device, BitField p_debug_flags) override; virtual void cleanup() override; - EditorExportPlatformMacOS(); + virtual void initialize() override; }; diff --git a/platform/visionos/export/export_plugin.cpp b/platform/visionos/export/export_plugin.cpp index d0e8aa5b462..8f48814fdce 100644 --- a/platform/visionos/export/export_plugin.cpp +++ b/platform/visionos/export/export_plugin.cpp @@ -33,13 +33,17 @@ #include "logo_svg.gen.h" #include "run_icon_svg.gen.h" +#include "editor/editor_node.h" + Vector EditorExportPlatformVisionOS::device_types({ "realityDevice" }); -EditorExportPlatformVisionOS::EditorExportPlatformVisionOS() : - EditorExportPlatformAppleEmbedded(_visionos_logo_svg, _visionos_run_icon_svg) { +void EditorExportPlatformVisionOS::initialize() { + if (EditorNode::get_singleton()) { + EditorExportPlatformAppleEmbedded::_initialize(_visionos_logo_svg, _visionos_run_icon_svg); #ifdef MACOS_ENABLED - _start_remote_device_poller_thread(); + _start_remote_device_poller_thread(); #endif + } } EditorExportPlatformVisionOS::~EditorExportPlatformVisionOS() { diff --git a/platform/visionos/export/export_plugin.h b/platform/visionos/export/export_plugin.h index 861a65beeef..da5fd1c098c 100644 --- a/platform/visionos/export/export_plugin.h +++ b/platform/visionos/export/export_plugin.h @@ -58,6 +58,6 @@ public: r_features->push_back("visionos"); } - EditorExportPlatformVisionOS(); + virtual void initialize() override; ~EditorExportPlatformVisionOS(); }; diff --git a/platform/web/export/export_plugin.cpp b/platform/web/export/export_plugin.cpp index 6316538808b..b8db6862067 100644 --- a/platform/web/export/export_plugin.cpp +++ b/platform/web/export/export_plugin.cpp @@ -916,7 +916,7 @@ Ref EditorExportPlatformWeb::get_run_icon() const { return run_icon; } -EditorExportPlatformWeb::EditorExportPlatformWeb() { +void EditorExportPlatformWeb::initialize() { if (EditorNode::get_singleton()) { server.instantiate(); diff --git a/platform/web/export/export_plugin.h b/platform/web/export/export_plugin.h index ff63afce428..36828f0defd 100644 --- a/platform/web/export/export_plugin.h +++ b/platform/web/export/export_plugin.h @@ -148,6 +148,6 @@ public: String get_debug_protocol() const override { return "ws://"; } - EditorExportPlatformWeb(); + virtual void initialize() override; ~EditorExportPlatformWeb(); }; diff --git a/platform/windows/export/export_plugin.cpp b/platform/windows/export/export_plugin.cpp index 25bf13c832c..a558fa2da39 100644 --- a/platform/windows/export/export_plugin.cpp +++ b/platform/windows/export/export_plugin.cpp @@ -1094,7 +1094,7 @@ Error EditorExportPlatformWindows::run(const Ref &p_preset, #undef CLEANUP_AND_RETURN } -EditorExportPlatformWindows::EditorExportPlatformWindows() { +void EditorExportPlatformWindows::initialize() { if (EditorNode::get_singleton()) { Ref img = memnew(Image); const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE); diff --git a/platform/windows/export/export_plugin.h b/platform/windows/export/export_plugin.h index c92626b52f0..976e87312f5 100644 --- a/platform/windows/export/export_plugin.h +++ b/platform/windows/export/export_plugin.h @@ -97,5 +97,5 @@ public: virtual Error run(const Ref &p_preset, int p_device, BitField p_debug_flags) override; virtual void cleanup() override; - EditorExportPlatformWindows(); + virtual void initialize() override; };