From 899335d1fe53340b530a4cd46360491747623ccd Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Sat, 10 Feb 2024 12:29:04 +0100 Subject: [PATCH] Util: Function to decorate output variable --- bt/tasks/utility/bt_call_method.cpp | 2 +- doc_classes/BehaviorTreeData.xml | 10 +++++----- doc_classes/BehaviorTreeView.xml | 6 +++--- doc_classes/LimboUtility.xml | 7 +++++++ util/limbo_utility.cpp | 5 +++++ util/limbo_utility.h | 1 + 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/bt/tasks/utility/bt_call_method.cpp b/bt/tasks/utility/bt_call_method.cpp index 5a4e681..0477a85 100644 --- a/bt/tasks/utility/bt_call_method.cpp +++ b/bt/tasks/utility/bt_call_method.cpp @@ -77,7 +77,7 @@ String BTCallMethod::_generate_name() { method != StringName() ? method : "???", args_str, node_param.is_valid() && !node_param->to_string().is_empty() ? node_param->to_string() : "???", - result_var.is_empty() ? "" : LW_NAME(output_var_prefix) + LimboUtility::get_singleton()->decorate_var(result_var)); + result_var.is_empty() ? "" : LimboUtility::get_singleton()->decorate_output_var(result_var)); } BT::Status BTCallMethod::_tick(double p_delta) { diff --git a/doc_classes/BehaviorTreeData.xml b/doc_classes/BehaviorTreeData.xml index 67c5e6e..bd7d065 100644 --- a/doc_classes/BehaviorTreeData.xml +++ b/doc_classes/BehaviorTreeData.xml @@ -1,11 +1,11 @@ - Represents current state of a [BehaviorTree] instance. + Represents current state of a [BehaviorTree] instance. - This class is used by the LimboAI debugger for the serialization and deserialization of [BehaviorTree] instance data. - Additionally, it can be used with [BehaviorTreeView] to visualize the current state of a [BehaviorTree] instance. It is meant to be utilized in custom in-game tools. + This class is used by the LimboAI debugger for the serialization and deserialization of [BehaviorTree] instance data. + Additionally, it can be used with [BehaviorTreeView] to visualize the current state of a [BehaviorTree] instance. It is meant to be utilized in custom in-game tools. @@ -14,8 +14,8 @@ - Returns current state of the [param p_tree_instance] encoded as a [BehaviorTreeData], suitable for use with [BehaviorTreeView]. - Behavior tree instance can be acquired with [method BTPlayer.get_tree_instance]. + Returns current state of the [param p_tree_instance] encoded as a [BehaviorTreeData], suitable for use with [BehaviorTreeView]. + Behavior tree instance can be acquired with [method BTPlayer.get_tree_instance]. diff --git a/doc_classes/BehaviorTreeView.xml b/doc_classes/BehaviorTreeView.xml index 3afa8d0..e85d6d5 100644 --- a/doc_classes/BehaviorTreeView.xml +++ b/doc_classes/BehaviorTreeView.xml @@ -1,10 +1,10 @@ - Visualizes the current state of a [BehaviorTree] instance. + Visualizes the current state of a [BehaviorTree] instance. - Visualizes the current state of a [BehaviorTree] instance. See also [BehaviorTreeData]. + Visualizes the current state of a [BehaviorTree] instance. See also [BehaviorTreeData]. @@ -13,7 +13,7 @@ - Updates the representation of a [BehaviorTree] instance. See also [BehaviorTreeData]. + Updates the representation of a [BehaviorTree] instance. See also [BehaviorTreeData]. diff --git a/doc_classes/LimboUtility.xml b/doc_classes/LimboUtility.xml index 074dccf..cf77945 100644 --- a/doc_classes/LimboUtility.xml +++ b/doc_classes/LimboUtility.xml @@ -8,6 +8,13 @@ + + + + + Just like [method decorate_var], produces a string with a [Blackboard] variable name that is formatted for display, and also adds an additional symbol to indicate that the variable is used as an output. + + diff --git a/util/limbo_utility.cpp b/util/limbo_utility.cpp index edd1040..6f805e7 100644 --- a/util/limbo_utility.cpp +++ b/util/limbo_utility.cpp @@ -56,6 +56,10 @@ String LimboUtility::decorate_var(String p_variable) const { } } +String LimboUtility::decorate_output_var(String p_variable) const { + return LW_NAME(output_var_prefix) + decorate_var(p_variable); +} + String LimboUtility::get_status_name(int p_status) const { switch (p_status) { case BTTask::FRESH: @@ -606,6 +610,7 @@ void LimboUtility::open_doc_class(const String &p_class_name) { void LimboUtility::_bind_methods() { ClassDB::bind_method(D_METHOD("decorate_var", "p_variable"), &LimboUtility::decorate_var); + ClassDB::bind_method(D_METHOD("decorate_output_var", "p_variable"), &LimboUtility::decorate_output_var); ClassDB::bind_method(D_METHOD("get_status_name", "p_status"), &LimboUtility::get_status_name); ClassDB::bind_method(D_METHOD("get_task_icon", "p_class_or_script_path"), &LimboUtility::get_task_icon); diff --git a/util/limbo_utility.h b/util/limbo_utility.h index c778286..1786f5f 100644 --- a/util/limbo_utility.h +++ b/util/limbo_utility.h @@ -79,6 +79,7 @@ public: static LimboUtility *get_singleton(); String decorate_var(String p_variable) const; + String decorate_output_var(String p_variable) const; String get_status_name(int p_status) const; Ref get_task_icon(String p_class_or_script_path) const;