From bea25049a07fab486f57e2835f502e83cd3a861d Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Mon, 4 Mar 2024 17:58:53 +0100 Subject: [PATCH] Update plan editor utilizing `StringName` --- editor/blackboard_plan_editor.cpp | 16 ++++++++-------- editor/blackboard_plan_editor.h | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/editor/blackboard_plan_editor.cpp b/editor/blackboard_plan_editor.cpp index f02f6f7..7372fc7 100644 --- a/editor/blackboard_plan_editor.cpp +++ b/editor/blackboard_plan_editor.cpp @@ -48,25 +48,25 @@ void BlackboardPlanEditor::_add_var() { ERR_FAIL_NULL(plan); int suffix = 1; - String name = default_var_name; - while (plan->has_var(name)) { + StringName var_name = default_var_name; + while (plan->has_var(var_name)) { suffix += 1; - name = default_var_name + itos(suffix); + var_name = String(default_var_name) + itos(suffix); } BBVariable var(Variant::Type::FLOAT); - plan->add_var(name, var); + plan->add_var(var_name, var); _refresh(); } void BlackboardPlanEditor::_trash_var(int p_index) { ERR_FAIL_NULL(plan); - String var_name = plan->get_var_by_index(p_index).first; + StringName var_name = plan->get_var_by_index(p_index).first; plan->remove_var(var_name); _refresh(); } -void BlackboardPlanEditor::_rename_var(const String &p_new_name, int p_index) { +void BlackboardPlanEditor::_rename_var(const StringName &p_new_name, int p_index) { ERR_FAIL_NULL(plan); LineEdit *name_edit = _get_name_edit(p_index); @@ -127,8 +127,8 @@ void BlackboardPlanEditor::edit_plan(const Ref &p_plan) { _refresh(); } -void BlackboardPlanEditor::set_next_var_name(const String &p_name) { - if (p_name.is_valid_identifier()) { +void BlackboardPlanEditor::set_next_var_name(const StringName &p_name) { + if (String(p_name).is_valid_identifier()) { default_var_name = p_name; } } diff --git a/editor/blackboard_plan_editor.h b/editor/blackboard_plan_editor.h index 1c00276..882ac41 100644 --- a/editor/blackboard_plan_editor.h +++ b/editor/blackboard_plan_editor.h @@ -56,7 +56,7 @@ private: int drag_index = -1; Ref plan; - String default_var_name; + StringName default_var_name; VBoxContainer *rows_vbox; Button *add_var_tool; @@ -69,7 +69,7 @@ private: void _add_var(); void _trash_var(int p_index); - void _rename_var(const String &p_new_name, int p_index); + void _rename_var(const StringName &p_new_name, int p_index); void _change_var_type(Variant::Type p_new_type, int p_index); void _change_var_hint(PropertyHint p_new_hint, int p_index); void _change_var_hint_string(const String &p_new_hint_string, int p_index); @@ -95,7 +95,7 @@ public: _FORCE_INLINE_ static BlackboardPlanEditor *get_singleton() { return singleton; } void edit_plan(const Ref &p_plan); - void set_next_var_name(const String &p_name); + void set_next_var_name(const StringName &p_name); BlackboardPlanEditor(); };