BlackboardPlan: Update inspector upon mapping editing finished

This commit is contained in:
Serhii Snitsaruk 2024-05-15 12:50:33 +02:00
parent d36f8f1122
commit c6b1a40627
No known key found for this signature in database
GPG Key ID: A965EF8799FFEC2D
5 changed files with 21 additions and 6 deletions

View File

@ -11,6 +11,8 @@
#include "blackboard_plan.h"
#include "../util/limbo_utility.h"
bool BlackboardPlan::_set(const StringName &p_name, const Variant &p_value) {
String name_str = p_name;
@ -34,6 +36,7 @@ bool BlackboardPlan::_set(const StringName &p_name, const Variant &p_value) {
} else {
parent_scope_mapping[mapped_var_name] = value;
}
notify_property_list_changed();
return true;
}
@ -69,7 +72,7 @@ bool BlackboardPlan::_get(const StringName &p_name, Variant &r_ret) const {
// * Editor
if (var_map.has(p_name)) {
if (has_mapping(p_name)) {
r_ret = "Mapped to $" + parent_scope_mapping[p_name];
r_ret = "Mapped to " + LimboUtility::get_singleton()->decorate_var(parent_scope_mapping[p_name]);
} else {
r_ret = var_map[p_name].get_value();
}

View File

@ -54,15 +54,22 @@ void EditorPropertyVariableName::_show_variables_popup() {
variables_popup->popup(rect);
}
void EditorPropertyVariableName::_name_changed(const String &p_new_name) {
emit_changed(get_edited_property(), p_new_name);
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(), false);
if (name_edit->has_focus()) {
name_edit->release_focus();
}
}
void EditorPropertyVariableName::_variable_selected(int p_id) {
String var_name = plan->get_var_by_index(p_id).first;
name_edit->set_text(var_name);
_name_changed(var_name);
_name_submitted();
}
void EditorPropertyVariableName::_update_status() {
@ -143,7 +150,9 @@ 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));
drop_btn->connect(LW_NAME(pressed), callable_mp(this, &EditorPropertyVariableName::_show_variables_popup));
status_btn->connect(LW_NAME(pressed), callable_mp(this, &EditorPropertyVariableName::_status_pressed));

View File

@ -55,7 +55,8 @@ private:
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();

View File

@ -85,6 +85,7 @@ LimboStringNames::LimboStringNames() {
exited = SN("exited");
favorite_tasks_changed = SN("favorite_tasks_changed");
Favorites = SN("Favorites");
focus_exited = SN("focus_exited");
font = SN("font");
font_color = SN("font_color");
font_size = SN("font_size");

View File

@ -101,6 +101,7 @@ public:
StringName exited;
StringName favorite_tasks_changed;
StringName Favorites;
StringName focus_exited;
StringName font_color;
StringName font_size;
StringName font;