From dc8dcf9d71cc96a4302293c0c33fa23b26ff79bd Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Wed, 17 Jan 2024 14:49:43 +0100 Subject: [PATCH] Add action banner if native method override warning is set to Error --- editor/limbo_ai_editor_plugin.cpp | 11 +++++++++++ editor/limbo_ai_editor_plugin.h | 4 ++++ util/limbo_utility.cpp | 5 +++++ util/limbo_utility.h | 1 + 4 files changed, 21 insertions(+) diff --git a/editor/limbo_ai_editor_plugin.cpp b/editor/limbo_ai_editor_plugin.cpp index 56b568b..061269c 100644 --- a/editor/limbo_ai_editor_plugin.cpp +++ b/editor/limbo_ai_editor_plugin.cpp @@ -992,6 +992,17 @@ void LimboAIEditor::_update_banners() { banners->call_deferred(LW_NAME(add_child), banner); } } + +#ifdef LIMBOAI_GDEXTENSION + if (!limitations_banner_shown && GLOBAL_GET("debug/gdscript/warnings/native_method_override") == Variant(2)) { + ActionBanner *banner = memnew(ActionBanner); + banner->set_text(vformat(TTR("In Project Settings, \"debug/gdscript/warnings/native_method_override\" is set to \"Error\""))); + banner->add_action(TTR("Instructions"), callable_mp(LimboUtility::get_singleton(), &LimboUtility::open_doc_gdextension_limitations)); + banner->add_action(TTR("Dismiss"), callable_mp(banner, &ActionBanner::close)); + banners->call_deferred(LW_NAME(add_child), banner); + limitations_banner_shown = true; + } +#endif // LIMBOAI_GDEXTENSION } void LimboAIEditor::_do_update_theme_item_cache() { diff --git a/editor/limbo_ai_editor_plugin.h b/editor/limbo_ai_editor_plugin.h index 1fe3f7d..3758445 100644 --- a/editor/limbo_ai_editor_plugin.h +++ b/editor/limbo_ai_editor_plugin.h @@ -107,6 +107,10 @@ private: Ref behavior_tree_icon; } theme_cache; +#ifdef LIMBOAI_GDEXTENSION + bool limitations_banner_shown = false; +#endif // LIMBOAI_GDEXTENSION + EditorPlugin *plugin; Vector> history; int idx_history; diff --git a/util/limbo_utility.cpp b/util/limbo_utility.cpp index 8d0739d..eb24290 100644 --- a/util/limbo_utility.cpp +++ b/util/limbo_utility.cpp @@ -343,6 +343,11 @@ void LimboUtility::open_doc_online() { LIMBO_DOC_VERSION)); } +void LimboUtility::open_doc_gdextension_limitations() { + OS::get_singleton()->shell_open(vformat("https://limboai.readthedocs.io/en/%s/getting-started/gdextension.html#limitations-of-the-gdextension-version", + LIMBO_DOC_VERSION)); +} + void LimboUtility::open_doc_class(const String &p_class_name) { if (p_class_name.begins_with("res://")) { SHOW_DOC(vformat("class_name:\"%s\"", p_class_name)); diff --git a/util/limbo_utility.h b/util/limbo_utility.h index 10c10e1..a1afca1 100644 --- a/util/limbo_utility.h +++ b/util/limbo_utility.h @@ -95,6 +95,7 @@ public: void open_doc_introduction(); void open_doc_online(); + void open_doc_gdextension_limitations(); void open_doc_class(const String &p_class_name); #endif // TOOLS_ENABLED