Improve binding presentation within inspector, fix compilation issues
This commit is contained in:
parent
bc7f677810
commit
ea671dd54b
|
@ -13,6 +13,16 @@
|
|||
|
||||
#include "../util/limbo_utility.h"
|
||||
|
||||
#ifdef LIMBOAI_MODULE
|
||||
#include "editor/editor_inspector.h"
|
||||
#include "editor/editor_interface.h"
|
||||
#elif LIMBOAI_GDEXTENSION
|
||||
#include <godot_cpp/classes/editor_inspector.hpp>
|
||||
#include <godot_cpp/classes/editor_interface.hpp>
|
||||
#include <godot_cpp/classes/engine.hpp>
|
||||
#include <godot_cpp/classes/scene_tree.hpp>
|
||||
#endif
|
||||
|
||||
bool BlackboardPlan::_set(const StringName &p_name, const Variant &p_value) {
|
||||
String name_str = p_name;
|
||||
|
||||
|
@ -107,9 +117,22 @@ bool BlackboardPlan::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
r_ret = "Mapped to " + LimboUtility::get_singleton()->decorate_var(parent_scope_mapping[p_name]);
|
||||
} else if (has_property_binding(p_name)) {
|
||||
const NodePath &binding = property_bindings[p_name];
|
||||
String path_str = (String)binding.get_name(binding.get_name_count() - 1) +
|
||||
|
||||
Node *edited_node = Object::cast_to<Node>(EditorInterface::get_singleton()->get_inspector()->get_edited_object());
|
||||
if (!edited_node) {
|
||||
edited_node = SCENE_TREE()->get_edited_scene_root();
|
||||
}
|
||||
Node *bound_node = edited_node->get_node_or_null(binding);
|
||||
|
||||
String shortened_path;
|
||||
if (bound_node) {
|
||||
shortened_path = (String)bound_node->get_name() +
|
||||
":" + (String)binding.get_concatenated_subnames();
|
||||
r_ret = "Bound to " + path_str;
|
||||
} else {
|
||||
shortened_path = (String)binding.get_name(binding.get_name_count() - 1) +
|
||||
":" + (String)binding.get_concatenated_subnames();
|
||||
}
|
||||
r_ret = String::utf8("🔗 ") + shortened_path;
|
||||
} else {
|
||||
r_ret = var_map[p_name].get_value();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
#include "../util/limbo_compat.h"
|
||||
#include "../util/limbo_string_names.h"
|
||||
#include "core/variant/variant.h"
|
||||
|
||||
#ifdef LIMBOAI_MODULE
|
||||
#include "editor/editor_data.h"
|
||||
|
@ -135,8 +134,16 @@ void EditorPropertyPropertyPath::_update_property() {
|
|||
if (path.is_empty()) {
|
||||
assign_button->set_text(TTR("Bind..."));
|
||||
} else {
|
||||
String text = (String)path.get_name(path.get_name_count() - 1) +
|
||||
Node *base_node = _get_base_node(get_edited_object(), get_tree());
|
||||
ERR_FAIL_NULL(base_node);
|
||||
Node *selected_node = base_node->get_node_or_null(path);
|
||||
String text;
|
||||
if (selected_node) {
|
||||
text = (String)selected_node->get_name() +
|
||||
":" + (String)path.get_concatenated_subnames();
|
||||
} else {
|
||||
text = (String)path;
|
||||
}
|
||||
assign_button->set_text(text);
|
||||
assign_button->set_tooltip_text(path);
|
||||
}
|
||||
|
@ -211,9 +218,9 @@ bool EditorInspectorPluginPropertyPath::_parse_property(Object *p_object, const
|
|||
EditorPropertyPropertyPath *ed = memnew(EditorPropertyPropertyPath);
|
||||
|
||||
PackedInt32Array valid_types;
|
||||
Vector<String> type_specifiers = p_hint_text.split(",");
|
||||
PackedStringArray type_specifiers = p_hint_text.split(",");
|
||||
for (const String &t : type_specifiers) {
|
||||
if (t.is_numeric()) {
|
||||
if (t.is_valid_int()) {
|
||||
valid_types.append(t.to_int());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#ifndef EDITOR_PROPERTY_PROPERTY_PATH
|
||||
#define EDITOR_PROPERTY_PROPERTY_PATH
|
||||
|
||||
#include "core/variant/variant.h"
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
#ifdef LIMBOAI_MODULE
|
||||
|
|
Loading…
Reference in New Issue