diff --git a/editor/action_banner.cpp b/editor/action_banner.cpp index 312139b..a5769fe 100644 --- a/editor/action_banner.cpp +++ b/editor/action_banner.cpp @@ -11,7 +11,17 @@ #include "action_banner.h" +#ifdef LIMBOAI_MODULE #include "scene/gui/button.h" +#endif // LIMBOAI_MODULE + +#ifdef LIMBOAI_GDEXTENSION +#include "../util/limbo_def.h" +#include "../util/limbo_string_names.h" + +#include + +#endif // LIMBOAI_GDEXTENSION void ActionBanner::set_text(const String &p_text) { message->set_text(p_text); @@ -28,14 +38,20 @@ void ActionBanner::close() { void ActionBanner::add_action(const String &p_name, const Callable &p_action, bool p_auto_close) { Button *action_btn = memnew(Button); action_btn->set_text(p_name); - action_btn->connect(SNAME("pressed"), callable_mp(this, &ActionBanner::_execute_action).bind(p_action, p_auto_close)); + action_btn->connect(LSNAME(pressed), callable_mp(this, &ActionBanner::_execute_action).bind(p_action, p_auto_close)); hbox->add_child(action_btn); } void ActionBanner::_execute_action(const Callable &p_action, bool p_auto_close) { +#ifdef LIMBOAI_MODULE Callable::CallError ce; Variant ret; p_action.callp(nullptr, 0, ret, ce); +#endif // LIMBOAI_MODULE + +#ifdef LIMBOAI_GDEXTENSION + p_action.call(); +#endif // LIMBOAI_GDEXTENSION if (p_auto_close) { queue_free(); @@ -45,7 +61,7 @@ void ActionBanner::_execute_action(const Callable &p_action, bool p_auto_close) void ActionBanner::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { - icon->set_texture(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); + icon->set_texture(get_theme_icon(LSNAME(StatusWarning), LSNAME(EditorIcons))); } break; } } diff --git a/editor/action_banner.h b/editor/action_banner.h index a4a7ad0..cdb5c53 100644 --- a/editor/action_banner.h +++ b/editor/action_banner.h @@ -13,11 +13,21 @@ #ifndef ACTION_BANNER_H #define ACTION_BANNER_H -#include "scene/gui/margin_container.h" - +#ifdef LIMBOAI_MODULE #include "scene/gui/box_container.h" #include "scene/gui/label.h" +#include "scene/gui/margin_container.h" #include "scene/gui/texture_rect.h" +#endif // LIMBOAI_MODULE + +#ifdef LIMBOAI_GDEXTENSION +#include +#include +#include +#include + +using namespace godot; +#endif // LIMBOAI_GDEXTENSION class ActionBanner : public MarginContainer { GDCLASS(ActionBanner, MarginContainer); diff --git a/editor/editor_property_bb_param.cpp b/editor/editor_property_bb_param.cpp index 9d37ef6..d35fd94 100644 --- a/editor/editor_property_bb_param.cpp +++ b/editor/editor_property_bb_param.cpp @@ -9,6 +9,8 @@ * ============================================================================= */ +#ifdef LIMBOAI_MODULE + #include "editor_property_bb_param.h" #include "core/variant/variant.h" @@ -345,3 +347,5 @@ bool EditorInspectorPluginBBParam::parse_property(Object *p_object, const Varian } return false; } + +#endif // LIMBOAI_MODULE diff --git a/editor/editor_property_bb_param.h b/editor/editor_property_bb_param.h index e1c2d40..b882641 100644 --- a/editor/editor_property_bb_param.h +++ b/editor/editor_property_bb_param.h @@ -12,6 +12,8 @@ #ifndef EDITOR_PROPERTY_BB_PARAM_H #define EDITOR_PROPERTY_BB_PARAM_H +#ifdef LIMBOAI_MODULE + #include "editor/editor_inspector.h" #include "modules/limboai/blackboard/bb_param/bb_param.h" @@ -68,4 +70,6 @@ public: virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField p_usage, const bool p_wide = false) override; }; +#endif // LIMBOAI_MODULE + #endif // EDITOR_PROPERTY_BB_PARAM_H diff --git a/util/limbo_def.cpp b/util/limbo_def.cpp index a7ca51d..f0ac6e5 100644 --- a/util/limbo_def.cpp +++ b/util/limbo_def.cpp @@ -15,6 +15,7 @@ #ifdef LIMBOAI_GDEXTENSION #include +#include using namespace godot; @@ -24,4 +25,12 @@ Variant _EDITOR_GET(const String &p_setting) { return es->get(p_setting); } -#endif +String TTR(const String &p_text, const String &p_context) { + if (TranslationServer::get_singleton()) { + return TranslationServer::get_singleton()->translate(p_text, p_context); + } + + return p_text; +} + +#endif // LIMBOAI_GDEXTENSION diff --git a/util/limbo_def.h b/util/limbo_def.h index e2cdc61..c17fd9a 100644 --- a/util/limbo_def.h +++ b/util/limbo_def.h @@ -9,6 +9,9 @@ * ============================================================================= */ +#ifndef LIMBO_DEF_H +#define LIMBO_DEF_H + #ifdef LIMBOAI_MODULE #include "core/string/print_string.h" @@ -46,4 +49,8 @@ Variant _EDITOR_GET(const String &p_setting); #define EDSCALE ((int)EDITOR_GET("interface/editor/display_scale")) -#endif // LIMBOAI_GDEXTENSION \ No newline at end of file +String TTR(const String &p_text, const String &p_context = ""); + +#endif // LIMBOAI_GDEXTENSION + +#endif // LIMBO_DEF_H diff --git a/util/limbo_string_names.cpp b/util/limbo_string_names.cpp index 2c36bc9..91e90d8 100644 --- a/util/limbo_string_names.cpp +++ b/util/limbo_string_names.cpp @@ -51,6 +51,8 @@ LimboStringNames::LimboStringNames() { bold = SN("bold"); EditorFonts = SN("EditorFonts"); item_collapsed = SN("item_collapsed"); + pressed = SN("pressed"); + StatusWarning = SN("StatusWarning"); EVENT_FINISHED = "finished"; repeat_forever.parse_utf8("Repeat ∞"); diff --git a/util/limbo_string_names.h b/util/limbo_string_names.h index a879a97..7e3a48d 100644 --- a/util/limbo_string_names.h +++ b/util/limbo_string_names.h @@ -70,6 +70,8 @@ public: StringName bold; StringName EditorFonts; StringName item_collapsed; + StringName pressed; + StringName StatusWarning; String EVENT_FINISHED; String repeat_forever; diff --git a/util/limbo_utility.cpp b/util/limbo_utility.cpp index c48655c..0337bb8 100644 --- a/util/limbo_utility.cpp +++ b/util/limbo_utility.cpp @@ -105,6 +105,8 @@ Ref LimboUtility::get_task_icon(String p_class_or_script_path) const return theme->get_icon(SNAME("Resource"), SNAME("EditorIcons")); #endif // TOOLS_ENABLED + // TODO: GDExtension needs the icons too. + // * Class icons are not available at runtime as they are part of the editor theme. return nullptr; }