Compare commits

..

1 Commits

Author SHA1 Message Date
Serhii Snitsaruk 134fbd5296
Merge b54f3696ff into 00396dce61 2024-05-17 09:09:05 +00:00
3 changed files with 7 additions and 33 deletions

View File

@ -31,21 +31,12 @@ bool BlackboardPlan::_set(const StringName &p_name, const Variant &p_value) {
if (name_str.begins_with("mapping/")) {
StringName mapped_var_name = name_str.get_slicec('/', 1);
StringName value = p_value;
bool properties_changed = false;
if (value == StringName()) {
if (parent_scope_mapping.has(mapped_var_name)) {
properties_changed = true;
parent_scope_mapping.erase(mapped_var_name);
}
} else {
if (!parent_scope_mapping.has(mapped_var_name)) {
properties_changed = true;
}
parent_scope_mapping[mapped_var_name] = value;
}
if (properties_changed) {
notify_property_list_changed();
}
return true;
}

View File

@ -31,8 +31,6 @@
#include <godot_cpp/classes/h_box_container.hpp>
#endif // LIMBOAI_GDEXTENSION
int EditorPropertyVariableName::last_caret_column = 0;
//***** EditorPropertyVariableName
void EditorPropertyVariableName::_show_variables_popup() {
@ -56,18 +54,13 @@ void EditorPropertyVariableName::_show_variables_popup() {
variables_popup->popup(rect);
}
void EditorPropertyVariableName::_name_changed(const String &p_new_name) {
if (updating) {
return;
}
emit_changed(get_edited_property(), p_new_name);
last_caret_column = name_edit->get_caret_column();
void EditorPropertyVariableName::_name_changed(const String &p_new_name, bool p_changing) {
emit_changed(get_edited_property(), p_new_name, StringName(), p_changing);
_update_status();
}
void EditorPropertyVariableName::_name_submitted() {
_name_changed(name_edit->get_text());
_name_changed(name_edit->get_text(), false);
if (name_edit->has_focus()) {
name_edit->release_focus();
}
@ -138,18 +131,13 @@ void EditorPropertyVariableName::update_property() {
void EditorPropertyVariableName::_update_property() {
#endif // LIMBOAI_GDEXTENSION
String s = get_edited_object()->get(get_edited_property());
updating = true;
if (name_edit->get_text() != s) {
int caret = name_edit->get_caret_column();
if (caret == 0) {
caret = last_caret_column;
}
name_edit->set_text(s);
name_edit->set_caret_column(caret);
}
name_edit->set_editable(!is_read_only());
_update_status();
updating = false;
}
void EditorPropertyVariableName::setup(const Ref<BlackboardPlan> &p_plan, bool p_allow_empty, Variant::Type p_type, PropertyHint p_hint, String p_hint_string, Variant p_default_value) {
@ -165,7 +153,7 @@ void EditorPropertyVariableName::setup(const Ref<BlackboardPlan> &p_plan, bool p
void EditorPropertyVariableName::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
name_edit->connect(LW_NAME(text_changed), callable_mp(this, &EditorPropertyVariableName::_name_changed));
name_edit->connect(LW_NAME(text_changed), callable_mp(this, &EditorPropertyVariableName::_name_changed).bind(true));
name_edit->connect(LW_NAME(text_submitted), callable_mp(this, &EditorPropertyVariableName::_name_submitted).unbind(1));
name_edit->connect(LW_NAME(focus_exited), callable_mp(this, &EditorPropertyVariableName::_name_submitted));
variables_popup->connect(LW_NAME(id_pressed), callable_mp(this, &EditorPropertyVariableName::_variable_selected));

View File

@ -31,9 +31,6 @@ using namespace godot;
class EditorPropertyVariableName : public EditorProperty {
GDCLASS(EditorPropertyVariableName, EditorProperty);
private:
static int last_caret_column;
private:
struct ThemeCache {
Ref<Texture2D> var_add_icon;
@ -53,15 +50,13 @@ private:
String default_hint_string;
Variant default_value;
bool updating = false;
LineEdit *name_edit;
Button *drop_btn;
Button *status_btn;
PopupMenu *variables_popup;
void _show_variables_popup();
void _name_changed(const String &p_new_name);
void _name_changed(const String &p_new_name, bool p_changing);
void _name_submitted();
void _variable_selected(int p_id);
void _update_status();