Expose checks and operations in `LimboUtility`

This commit is contained in:
Serhii Snitsaruk 2024-03-20 12:13:32 +01:00
parent 705f4d7415
commit 06ea008105
No known key found for this signature in database
GPG Key ID: A965EF8799FFEC2D
3 changed files with 101 additions and 9 deletions

View File

@ -22,15 +22,23 @@ Methods
.. table:: .. table::
:widths: auto :widths: auto
+-----------+---------------------------------------------------------------------------------------------------------------+ +-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| String | :ref:`decorate_output_var<class_LimboUtility_method_decorate_output_var>` **(** String variable **)** |const| | | String | :ref:`decorate_output_var<class_LimboUtility_method_decorate_output_var>` **(** String variable **)** |const| |
+-----------+---------------------------------------------------------------------------------------------------------------+ +-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| String | :ref:`decorate_var<class_LimboUtility_method_decorate_var>` **(** String variable **)** |const| | | String | :ref:`decorate_var<class_LimboUtility_method_decorate_var>` **(** String variable **)** |const| |
+-----------+---------------------------------------------------------------------------------------------------------------+ +-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| String | :ref:`get_check_operator_string<class_LimboUtility_method_get_check_operator_string>` **(** :ref:`CheckType<enum_LimboUtility_CheckType>` check **)** |const| |
+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| String | :ref:`get_operation_string<class_LimboUtility_method_get_operation_string>` **(** :ref:`Operation<enum_LimboUtility_Operation>` operation **)** |const| |
+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| String | :ref:`get_status_name<class_LimboUtility_method_get_status_name>` **(** int status **)** |const| | | String | :ref:`get_status_name<class_LimboUtility_method_get_status_name>` **(** int status **)** |const| |
+-----------+---------------------------------------------------------------------------------------------------------------+ +-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Texture2D | :ref:`get_task_icon<class_LimboUtility_method_get_task_icon>` **(** String class_or_script_path **)** |const| | | Texture2D | :ref:`get_task_icon<class_LimboUtility_method_get_task_icon>` **(** String class_or_script_path **)** |const| |
+-----------+---------------------------------------------------------------------------------------------------------------+ +-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| bool | :ref:`perform_check<class_LimboUtility_method_perform_check>` **(** :ref:`CheckType<enum_LimboUtility_CheckType>` check, Variant a, Variant b **)** |
+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Variant | :ref:`perform_operation<class_LimboUtility_method_perform_operation>` **(** :ref:`Operation<enum_LimboUtility_Operation>` operation, Variant a, Variant b **)** |
+-----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator .. rst-class:: classref-section-separator
@ -234,6 +242,30 @@ Produces a string with a :ref:`Blackboard<class_Blackboard>` variable name that
---- ----
.. _class_LimboUtility_method_get_check_operator_string:
.. rst-class:: classref-method
String **get_check_operator_string** **(** :ref:`CheckType<enum_LimboUtility_CheckType>` check **)** |const|
Returns an operator string for a :ref:`CheckType<enum_LimboUtility_CheckType>` enum value. For example, :ref:`CHECK_EQUAL<class_LimboUtility_constant_CHECK_EQUAL>` returns "==".
.. rst-class:: classref-item-separator
----
.. _class_LimboUtility_method_get_operation_string:
.. rst-class:: classref-method
String **get_operation_string** **(** :ref:`Operation<enum_LimboUtility_Operation>` operation **)** |const|
Returns a string representation of an :ref:`Operation<enum_LimboUtility_Operation>` enum value.
.. rst-class:: classref-item-separator
----
.. _class_LimboUtility_method_get_status_name: .. _class_LimboUtility_method_get_status_name:
.. rst-class:: classref-method .. rst-class:: classref-method
@ -254,6 +286,30 @@ Texture2D **get_task_icon** **(** String class_or_script_path **)** |const|
Returns the icon texture associated with a task based on its class name or script resource path. Returns the icon texture associated with a task based on its class name or script resource path.
.. rst-class:: classref-item-separator
----
.. _class_LimboUtility_method_perform_check:
.. rst-class:: classref-method
bool **perform_check** **(** :ref:`CheckType<enum_LimboUtility_CheckType>` check, Variant a, Variant b **)**
Performs a ``check`` on two values, ``a`` and ``b``, and returns ``true`` if the check passes.
.. rst-class:: classref-item-separator
----
.. _class_LimboUtility_method_perform_operation:
.. rst-class:: classref-method
Variant **perform_operation** **(** :ref:`Operation<enum_LimboUtility_Operation>` operation, Variant a, Variant b **)**
Performs an ``operation`` on two values, ``a`` and ``b``, and returns the result.
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`

View File

@ -22,6 +22,20 @@
Produces a string with a [Blackboard] variable name that is formatted for display or console output. Produces a string with a [Blackboard] variable name that is formatted for display or console output.
</description> </description>
</method> </method>
<method name="get_check_operator_string" qualifiers="const">
<return type="String" />
<param index="0" name="check" type="int" enum="LimboUtility.CheckType" />
<description>
Returns an operator string for a [enum CheckType] enum value. For example, [constant CHECK_EQUAL] returns "==".
</description>
</method>
<method name="get_operation_string" qualifiers="const">
<return type="String" />
<param index="0" name="operation" type="int" enum="LimboUtility.Operation" />
<description>
Returns a string representation of an [enum Operation] enum value.
</description>
</method>
<method name="get_status_name" qualifiers="const"> <method name="get_status_name" qualifiers="const">
<return type="String" /> <return type="String" />
<param index="0" name="status" type="int" /> <param index="0" name="status" type="int" />
@ -36,6 +50,24 @@
Returns the icon texture associated with a task based on its class name or script resource path. Returns the icon texture associated with a task based on its class name or script resource path.
</description> </description>
</method> </method>
<method name="perform_check">
<return type="bool" />
<param index="0" name="check" type="int" enum="LimboUtility.CheckType" />
<param index="1" name="a" type="Variant" />
<param index="2" name="b" type="Variant" />
<description>
Performs a [param check] on two values, [param a] and [param b], and returns [code]true[/code] if the check passes.
</description>
</method>
<method name="perform_operation">
<return type="Variant" />
<param index="0" name="operation" type="int" enum="LimboUtility.Operation" />
<param index="1" name="a" type="Variant" />
<param index="2" name="b" type="Variant" />
<description>
Performs an [param operation] on two values, [param a] and [param b], and returns the result.
</description>
</method>
</methods> </methods>
<constants> <constants>
<constant name="CHECK_EQUAL" value="0" enum="CheckType"> <constant name="CHECK_EQUAL" value="0" enum="CheckType">

View File

@ -608,6 +608,10 @@ void LimboUtility::_bind_methods() {
ClassDB::bind_method(D_METHOD("decorate_output_var", "variable"), &LimboUtility::decorate_output_var); ClassDB::bind_method(D_METHOD("decorate_output_var", "variable"), &LimboUtility::decorate_output_var);
ClassDB::bind_method(D_METHOD("get_status_name", "status"), &LimboUtility::get_status_name); ClassDB::bind_method(D_METHOD("get_status_name", "status"), &LimboUtility::get_status_name);
ClassDB::bind_method(D_METHOD("get_task_icon", "class_or_script_path"), &LimboUtility::get_task_icon); ClassDB::bind_method(D_METHOD("get_task_icon", "class_or_script_path"), &LimboUtility::get_task_icon);
ClassDB::bind_method(D_METHOD("get_check_operator_string", "check"), &LimboUtility::get_check_operator_string);
ClassDB::bind_method(D_METHOD("perform_check", "check", "a", "b"), &LimboUtility::perform_check);
ClassDB::bind_method(D_METHOD("get_operation_string", "operation"), &LimboUtility::get_operation_string);
ClassDB::bind_method(D_METHOD("perform_operation", "operation", "a", "b"), &LimboUtility::perform_operation);
BIND_ENUM_CONSTANT(CHECK_EQUAL); BIND_ENUM_CONSTANT(CHECK_EQUAL);
BIND_ENUM_CONSTANT(CHECK_LESS_THAN); BIND_ENUM_CONSTANT(CHECK_LESS_THAN);