Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor: Check if variable is of correct type for BBParam subtypes #110

Merged
merged 1 commit into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions blackboard/bb_param/bb_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
class BBNode : public BBParam {
GDCLASS(BBNode, BBParam);

protected:
virtual Variant::Type get_type() const override { return Variant::NODE_PATH; }

public:
virtual Variant::Type get_type() const override { return Variant::NODE_PATH; }
virtual Variant get_value(Node *p_scene_root, const Ref<Blackboard> &p_blackboard, const Variant &p_default = Variant()) override;
};

Expand Down
4 changes: 2 additions & 2 deletions blackboard/bb_param/bb_param.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ class BBParam : public Resource {
void _get_property_list(List<PropertyInfo> *p_list) const;

public:
virtual Variant::Type get_type() const { return Variant::NIL; }

void set_value_source(ValueSource p_value);
ValueSource get_value_source() const { return value_source; }

Expand All @@ -66,6 +64,8 @@ class BBParam : public Resource {
virtual String _to_string();
#endif

virtual Variant::Type get_type() const { return Variant::NIL; }
virtual Variant::Type get_variable_expected_type() const { return get_type(); }
virtual Variant get_value(Node *p_scene_root, const Ref<Blackboard> &p_blackboard, const Variant &p_default = Variant());

BBParam();
Expand Down
2 changes: 2 additions & 0 deletions blackboard/bb_param/bb_variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class BBVariant : public BBParam {
virtual Variant::Type get_type() const override;
void set_type(Variant::Type p_type);

virtual Variant::Type get_variable_expected_type() const override { return Variant::NIL; }

BBVariant(const Variant &p_value);
BBVariant();
};
Expand Down
3 changes: 2 additions & 1 deletion editor/editor_property_bb_param.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ void EditorPropertyBBParam::update_property() {
if (param->get_value_source() == BBParam::BLACKBOARD_VAR) {
_remove_value_editor();
variable_editor->set_object_and_property(param.ptr(), SNAME("variable"));
variable_editor->setup(plan, false, param->get_variable_expected_type());
variable_editor->update_property();
variable_editor->show();
bottom_container->hide();
Expand All @@ -300,7 +301,7 @@ void EditorPropertyBBParam::update_property() {
void EditorPropertyBBParam::setup(PropertyHint p_hint, const String &p_hint_text, const Ref<BlackboardPlan> &p_plan) {
param_type = p_hint_text;
property_hint = p_hint;
variable_editor->setup(p_plan, false);
plan = p_plan;
variable_editor->set_name_split_ratio(0.0);
}

Expand Down
1 change: 1 addition & 0 deletions editor/editor_property_bb_param.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class EditorPropertyBBParam : public EditorProperty {

bool initialized = false;

Ref<BlackboardPlan> plan;
StringName param_type;
PropertyHint property_hint = PROPERTY_HINT_NONE;

Expand Down
2 changes: 1 addition & 1 deletion editor/editor_property_variable_name.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void EditorPropertyVariableName::_update_status() {
} else {
BUTTON_SET_ICON(status_btn, theme_cache.var_error_icon);
status_btn->set_tooltip_text(TTR(vformat(
"The %s variable in the blackboard plan is not of the same type as this variable (expected %s).\nClick to open the blackboard plan and fix the variable type.",
"The %s variable in the blackboard plan should be of type %s.\nClick to open the blackboard plan.",
LimboUtility::get_singleton()->decorate_var(var_name),
Variant::get_type_name(expected_type))));
}
Expand Down
Loading