Compare commits
1 Commits
2687de300b
...
134fbd5296
Author | SHA1 | Date |
---|---|---|
Serhii Snitsaruk | 134fbd5296 |
|
@ -31,21 +31,12 @@ bool BlackboardPlan::_set(const StringName &p_name, const Variant &p_value) {
|
||||||
if (name_str.begins_with("mapping/")) {
|
if (name_str.begins_with("mapping/")) {
|
||||||
StringName mapped_var_name = name_str.get_slicec('/', 1);
|
StringName mapped_var_name = name_str.get_slicec('/', 1);
|
||||||
StringName value = p_value;
|
StringName value = p_value;
|
||||||
bool properties_changed = false;
|
|
||||||
if (value == StringName()) {
|
if (value == StringName()) {
|
||||||
if (parent_scope_mapping.has(mapped_var_name)) {
|
parent_scope_mapping.erase(mapped_var_name);
|
||||||
properties_changed = true;
|
|
||||||
parent_scope_mapping.erase(mapped_var_name);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (!parent_scope_mapping.has(mapped_var_name)) {
|
|
||||||
properties_changed = true;
|
|
||||||
}
|
|
||||||
parent_scope_mapping[mapped_var_name] = value;
|
parent_scope_mapping[mapped_var_name] = value;
|
||||||
}
|
}
|
||||||
if (properties_changed) {
|
notify_property_list_changed();
|
||||||
notify_property_list_changed();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,6 @@
|
||||||
#include <godot_cpp/classes/h_box_container.hpp>
|
#include <godot_cpp/classes/h_box_container.hpp>
|
||||||
#endif // LIMBOAI_GDEXTENSION
|
#endif // LIMBOAI_GDEXTENSION
|
||||||
|
|
||||||
int EditorPropertyVariableName::last_caret_column = 0;
|
|
||||||
|
|
||||||
//***** EditorPropertyVariableName
|
//***** EditorPropertyVariableName
|
||||||
|
|
||||||
void EditorPropertyVariableName::_show_variables_popup() {
|
void EditorPropertyVariableName::_show_variables_popup() {
|
||||||
|
@ -56,18 +54,13 @@ void EditorPropertyVariableName::_show_variables_popup() {
|
||||||
variables_popup->popup(rect);
|
variables_popup->popup(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPropertyVariableName::_name_changed(const String &p_new_name) {
|
void EditorPropertyVariableName::_name_changed(const String &p_new_name, bool p_changing) {
|
||||||
if (updating) {
|
emit_changed(get_edited_property(), p_new_name, StringName(), p_changing);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit_changed(get_edited_property(), p_new_name);
|
|
||||||
last_caret_column = name_edit->get_caret_column();
|
|
||||||
_update_status();
|
_update_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPropertyVariableName::_name_submitted() {
|
void EditorPropertyVariableName::_name_submitted() {
|
||||||
_name_changed(name_edit->get_text());
|
_name_changed(name_edit->get_text(), false);
|
||||||
if (name_edit->has_focus()) {
|
if (name_edit->has_focus()) {
|
||||||
name_edit->release_focus();
|
name_edit->release_focus();
|
||||||
}
|
}
|
||||||
|
@ -138,18 +131,13 @@ void EditorPropertyVariableName::update_property() {
|
||||||
void EditorPropertyVariableName::_update_property() {
|
void EditorPropertyVariableName::_update_property() {
|
||||||
#endif // LIMBOAI_GDEXTENSION
|
#endif // LIMBOAI_GDEXTENSION
|
||||||
String s = get_edited_object()->get(get_edited_property());
|
String s = get_edited_object()->get(get_edited_property());
|
||||||
updating = true;
|
|
||||||
if (name_edit->get_text() != s) {
|
if (name_edit->get_text() != s) {
|
||||||
int caret = name_edit->get_caret_column();
|
int caret = name_edit->get_caret_column();
|
||||||
if (caret == 0) {
|
|
||||||
caret = last_caret_column;
|
|
||||||
}
|
|
||||||
name_edit->set_text(s);
|
name_edit->set_text(s);
|
||||||
name_edit->set_caret_column(caret);
|
name_edit->set_caret_column(caret);
|
||||||
}
|
}
|
||||||
name_edit->set_editable(!is_read_only());
|
name_edit->set_editable(!is_read_only());
|
||||||
_update_status();
|
_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) {
|
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) {
|
void EditorPropertyVariableName::_notification(int p_what) {
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
case NOTIFICATION_READY: {
|
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(text_submitted), callable_mp(this, &EditorPropertyVariableName::_name_submitted).unbind(1));
|
||||||
name_edit->connect(LW_NAME(focus_exited), callable_mp(this, &EditorPropertyVariableName::_name_submitted));
|
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));
|
variables_popup->connect(LW_NAME(id_pressed), callable_mp(this, &EditorPropertyVariableName::_variable_selected));
|
||||||
|
|
|
@ -31,9 +31,6 @@ using namespace godot;
|
||||||
class EditorPropertyVariableName : public EditorProperty {
|
class EditorPropertyVariableName : public EditorProperty {
|
||||||
GDCLASS(EditorPropertyVariableName, EditorProperty);
|
GDCLASS(EditorPropertyVariableName, EditorProperty);
|
||||||
|
|
||||||
private:
|
|
||||||
static int last_caret_column;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ThemeCache {
|
struct ThemeCache {
|
||||||
Ref<Texture2D> var_add_icon;
|
Ref<Texture2D> var_add_icon;
|
||||||
|
@ -53,15 +50,13 @@ private:
|
||||||
String default_hint_string;
|
String default_hint_string;
|
||||||
Variant default_value;
|
Variant default_value;
|
||||||
|
|
||||||
bool updating = false;
|
|
||||||
|
|
||||||
LineEdit *name_edit;
|
LineEdit *name_edit;
|
||||||
Button *drop_btn;
|
Button *drop_btn;
|
||||||
Button *status_btn;
|
Button *status_btn;
|
||||||
PopupMenu *variables_popup;
|
PopupMenu *variables_popup;
|
||||||
|
|
||||||
void _show_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 _name_submitted();
|
||||||
void _variable_selected(int p_id);
|
void _variable_selected(int p_id);
|
||||||
void _update_status();
|
void _update_status();
|
||||||
|
|
Loading…
Reference in New Issue