Util: Function to decorate output variable

This commit is contained in:
Serhii Snitsaruk 2024-02-10 12:29:04 +01:00
parent 95c2496adf
commit 899335d1fe
6 changed files with 22 additions and 9 deletions

View File

@ -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) {

View File

@ -8,6 +8,13 @@
<tutorials>
</tutorials>
<methods>
<method name="decorate_output_var" qualifiers="const">
<return type="String" />
<param index="0" name="p_variable" type="String" />
<description>
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.
</description>
</method>
<method name="decorate_var" qualifiers="const">
<return type="String" />
<param index="0" name="p_variable" type="String" />

View File

@ -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);

View File

@ -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<Texture2D> get_task_icon(String p_class_or_script_path) const;