BlackboardPlan: Update inspector upon mapping editing finished
This commit is contained in:
parent
d36f8f1122
commit
c6b1a40627
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
#include "blackboard_plan.h"
|
#include "blackboard_plan.h"
|
||||||
|
|
||||||
|
#include "../util/limbo_utility.h"
|
||||||
|
|
||||||
bool BlackboardPlan::_set(const StringName &p_name, const Variant &p_value) {
|
bool BlackboardPlan::_set(const StringName &p_name, const Variant &p_value) {
|
||||||
String name_str = p_name;
|
String name_str = p_name;
|
||||||
|
|
||||||
|
@ -34,6 +36,7 @@ bool BlackboardPlan::_set(const StringName &p_name, const Variant &p_value) {
|
||||||
} else {
|
} else {
|
||||||
parent_scope_mapping[mapped_var_name] = value;
|
parent_scope_mapping[mapped_var_name] = value;
|
||||||
}
|
}
|
||||||
|
notify_property_list_changed();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +72,7 @@ bool BlackboardPlan::_get(const StringName &p_name, Variant &r_ret) const {
|
||||||
// * Editor
|
// * Editor
|
||||||
if (var_map.has(p_name)) {
|
if (var_map.has(p_name)) {
|
||||||
if (has_mapping(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 {
|
} else {
|
||||||
r_ret = var_map[p_name].get_value();
|
r_ret = var_map[p_name].get_value();
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,15 +54,22 @@ 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) {
|
||||||
emit_changed(get_edited_property(), p_new_name);
|
emit_changed(get_edited_property(), p_new_name, StringName(), p_changing);
|
||||||
_update_status();
|
_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) {
|
void EditorPropertyVariableName::_variable_selected(int p_id) {
|
||||||
String var_name = plan->get_var_by_index(p_id).first;
|
String var_name = plan->get_var_by_index(p_id).first;
|
||||||
name_edit->set_text(var_name);
|
name_edit->set_text(var_name);
|
||||||
_name_changed(var_name);
|
_name_submitted();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPropertyVariableName::_update_status() {
|
void EditorPropertyVariableName::_update_status() {
|
||||||
|
@ -143,7 +150,9 @@ 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(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));
|
||||||
drop_btn->connect(LW_NAME(pressed), callable_mp(this, &EditorPropertyVariableName::_show_variables_popup));
|
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));
|
status_btn->connect(LW_NAME(pressed), callable_mp(this, &EditorPropertyVariableName::_status_pressed));
|
||||||
|
|
|
@ -55,7 +55,8 @@ private:
|
||||||
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 _variable_selected(int p_id);
|
void _variable_selected(int p_id);
|
||||||
void _update_status();
|
void _update_status();
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,7 @@ LimboStringNames::LimboStringNames() {
|
||||||
exited = SN("exited");
|
exited = SN("exited");
|
||||||
favorite_tasks_changed = SN("favorite_tasks_changed");
|
favorite_tasks_changed = SN("favorite_tasks_changed");
|
||||||
Favorites = SN("Favorites");
|
Favorites = SN("Favorites");
|
||||||
|
focus_exited = SN("focus_exited");
|
||||||
font = SN("font");
|
font = SN("font");
|
||||||
font_color = SN("font_color");
|
font_color = SN("font_color");
|
||||||
font_size = SN("font_size");
|
font_size = SN("font_size");
|
||||||
|
|
|
@ -101,6 +101,7 @@ public:
|
||||||
StringName exited;
|
StringName exited;
|
||||||
StringName favorite_tasks_changed;
|
StringName favorite_tasks_changed;
|
||||||
StringName Favorites;
|
StringName Favorites;
|
||||||
|
StringName focus_exited;
|
||||||
StringName font_color;
|
StringName font_color;
|
||||||
StringName font_size;
|
StringName font_size;
|
||||||
StringName font;
|
StringName font;
|
||||||
|
|
Loading…
Reference in New Issue