Compare commits
2 Commits
134fbd5296
...
2687de300b
Author | SHA1 | Date |
---|---|---|
Serhii Snitsaruk | 2687de300b | |
Serhii Snitsaruk | 7ab7a9d098 |
|
@ -31,12 +31,21 @@ 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()) {
|
||||
parent_scope_mapping.erase(mapped_var_name);
|
||||
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;
|
||||
}
|
||||
notify_property_list_changed();
|
||||
if (properties_changed) {
|
||||
notify_property_list_changed();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include <godot_cpp/classes/h_box_container.hpp>
|
||||
#endif // LIMBOAI_GDEXTENSION
|
||||
|
||||
int EditorPropertyVariableName::last_caret_column = 0;
|
||||
|
||||
//***** EditorPropertyVariableName
|
||||
|
||||
void EditorPropertyVariableName::_show_variables_popup() {
|
||||
|
@ -54,13 +56,18 @@ void EditorPropertyVariableName::_show_variables_popup() {
|
|||
variables_popup->popup(rect);
|
||||
}
|
||||
|
||||
void EditorPropertyVariableName::_name_changed(const String &p_new_name, bool p_changing) {
|
||||
emit_changed(get_edited_property(), p_new_name, StringName(), p_changing);
|
||||
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();
|
||||
_update_status();
|
||||
}
|
||||
|
||||
void EditorPropertyVariableName::_name_submitted() {
|
||||
_name_changed(name_edit->get_text(), false);
|
||||
_name_changed(name_edit->get_text());
|
||||
if (name_edit->has_focus()) {
|
||||
name_edit->release_focus();
|
||||
}
|
||||
|
@ -131,13 +138,18 @@ 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) {
|
||||
|
@ -153,7 +165,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).bind(true));
|
||||
name_edit->connect(LW_NAME(text_changed), callable_mp(this, &EditorPropertyVariableName::_name_changed));
|
||||
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));
|
||||
|
|
|
@ -31,6 +31,9 @@ using namespace godot;
|
|||
class EditorPropertyVariableName : public EditorProperty {
|
||||
GDCLASS(EditorPropertyVariableName, EditorProperty);
|
||||
|
||||
private:
|
||||
static int last_caret_column;
|
||||
|
||||
private:
|
||||
struct ThemeCache {
|
||||
Ref<Texture2D> var_add_icon;
|
||||
|
@ -50,13 +53,15 @@ 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, bool p_changing);
|
||||
void _name_changed(const String &p_new_name);
|
||||
void _name_submitted();
|
||||
void _variable_selected(int p_id);
|
||||
void _update_status();
|
||||
|
|
Loading…
Reference in New Issue