diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-06-30 10:06:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-30 10:06:17 +0200 |
commit | fd3970f7625c39aa22be94a0fa5396bd0eeb6f06 (patch) | |
tree | 4ab532da98b120764971a401738c24fd7b2d39c7 | |
parent | ce6c4ab86a8b8b2f381f91dd8f91f36e37f4f799 (diff) | |
parent | 0e504e4191d4d535ff296befb3c281c44ae95d88 (diff) |
Merge pull request #62531 from Faless/fix/4.x_assetlib_is_available
-rw-r--r-- | editor/editor_node.cpp | 12 | ||||
-rw-r--r-- | editor/plugins/asset_library_editor_plugin.cpp | 11 | ||||
-rw-r--r-- | editor/plugins/asset_library_editor_plugin.h | 2 | ||||
-rw-r--r-- | editor/project_manager.cpp | 6 |
4 files changed, 19 insertions, 12 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index b196cadcb1..e3caaf93c6 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -460,7 +460,7 @@ void EditorNode::shortcut_input(const Ref<InputEvent> &p_event) { _editor_select(EDITOR_SCRIPT); } else if (ED_IS_SHORTCUT("editor/editor_help", p_event)) { emit_signal(SNAME("request_help_search"), ""); - } else if (ED_IS_SHORTCUT("editor/editor_assetlib", p_event) && StreamPeerSSL::is_available()) { + } else if (ED_IS_SHORTCUT("editor/editor_assetlib", p_event) && AssetLibraryEditorPlugin::is_available()) { _editor_select(EDITOR_ASSETLIB); } else if (ED_IS_SHORTCUT("editor/editor_next", p_event)) { _editor_select_next(); @@ -5752,12 +5752,12 @@ void EditorNode::_feature_profile_changed() { main_editor_buttons[EDITOR_3D]->set_visible(!profile->is_feature_disabled(EditorFeatureProfile::FEATURE_3D)); main_editor_buttons[EDITOR_SCRIPT]->set_visible(!profile->is_feature_disabled(EditorFeatureProfile::FEATURE_SCRIPT)); - if (StreamPeerSSL::is_available()) { + if (AssetLibraryEditorPlugin::is_available()) { main_editor_buttons[EDITOR_ASSETLIB]->set_visible(!profile->is_feature_disabled(EditorFeatureProfile::FEATURE_ASSET_LIB)); } if ((profile->is_feature_disabled(EditorFeatureProfile::FEATURE_3D) && singleton->main_editor_buttons[EDITOR_3D]->is_pressed()) || (profile->is_feature_disabled(EditorFeatureProfile::FEATURE_SCRIPT) && singleton->main_editor_buttons[EDITOR_SCRIPT]->is_pressed()) || - (StreamPeerSSL::is_available() && profile->is_feature_disabled(EditorFeatureProfile::FEATURE_ASSET_LIB) && singleton->main_editor_buttons[EDITOR_ASSETLIB]->is_pressed())) { + (AssetLibraryEditorPlugin::is_available() && profile->is_feature_disabled(EditorFeatureProfile::FEATURE_ASSET_LIB) && singleton->main_editor_buttons[EDITOR_ASSETLIB]->is_pressed())) { _editor_select(EDITOR_2D); } } else { @@ -5769,7 +5769,7 @@ void EditorNode::_feature_profile_changed() { FileSystemDock::get_singleton()->set_visible(true); main_editor_buttons[EDITOR_3D]->set_visible(true); main_editor_buttons[EDITOR_SCRIPT]->set_visible(true); - if (StreamPeerSSL::is_available()) { + if (AssetLibraryEditorPlugin::is_available()) { main_editor_buttons[EDITOR_ASSETLIB]->set_visible(true); } } @@ -7073,13 +7073,11 @@ EditorNode::EditorNode() { // Asset Library can't work on Web editor for now as most assets are sourced // directly from GitHub which does not set CORS. -#ifndef JAVASCRIPT_ENABLED - if (StreamPeerSSL::is_available()) { + if (AssetLibraryEditorPlugin::is_available()) { add_editor_plugin(memnew(AssetLibraryEditorPlugin)); } else { WARN_PRINT("Asset Library not available, as it requires SSL to work."); } -#endif // Add interface before adding plugins. diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 249b3a6d6a..e9435faae1 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -32,6 +32,7 @@ #include "core/input/input.h" #include "core/io/json.h" +#include "core/io/stream_peer_ssl.h" #include "core/os/keyboard.h" #include "core/version.h" #include "editor/editor_file_dialog.h" @@ -1588,6 +1589,16 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { /////// +bool AssetLibraryEditorPlugin::is_available() { +#ifdef JAVASCRIPT_ENABLED + // Asset Library can't work on Web editor for now as most assets are sourced + // directly from GitHub which does not set CORS. + return false; +#else + return StreamPeerSSL::is_available(); +#endif +} + void AssetLibraryEditorPlugin::make_visible(bool p_visible) { if (p_visible) { addon_library->show(); diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h index e09700b646..2b43719cdd 100644 --- a/editor/plugins/asset_library_editor_plugin.h +++ b/editor/plugins/asset_library_editor_plugin.h @@ -322,6 +322,8 @@ class AssetLibraryEditorPlugin : public EditorPlugin { EditorAssetLibrary *addon_library = nullptr; public: + static bool is_available(); + virtual String get_name() const override { return "AssetLib"; } bool has_main_screen() const override { return true; } virtual void edit(Object *p_object) override {} diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 2e7b6f7476..ef91128146 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -2792,10 +2792,7 @@ ProjectManager::ProjectManager() { center_box->add_child(settings_hb); } - // Asset Library can't work on Web editor for now as most assets are sourced - // directly from GitHub which does not set CORS. -#ifndef JAVASCRIPT_ENABLED - if (StreamPeerSSL::is_available()) { + if (AssetLibraryEditorPlugin::is_available()) { asset_library = memnew(EditorAssetLibrary(true)); asset_library->set_name(TTR("Asset Library Projects")); tabs->add_child(asset_library); @@ -2803,7 +2800,6 @@ ProjectManager::ProjectManager() { } else { WARN_PRINT("Asset Library not available, as it requires SSL to work."); } -#endif { // Dialogs |