mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-03-23 12:47:33 +01:00
Removed the visual script module.
This commit is contained in:
parent
e1349c85fa
commit
5604a12c68
@ -1,8 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
Import("env")
|
||||
Import("env_modules")
|
||||
|
||||
env_vs = env_modules.Clone()
|
||||
|
||||
env_vs.add_source_files(env.modules_sources, "*.cpp")
|
@ -1,62 +0,0 @@
|
||||
def can_build(env, platform):
|
||||
return True
|
||||
|
||||
|
||||
def configure(env):
|
||||
pass
|
||||
|
||||
|
||||
def get_doc_classes():
|
||||
return [
|
||||
"VisualScriptBasicTypeConstant",
|
||||
"VisualScriptBuiltinFunc",
|
||||
"VisualScriptClassConstant",
|
||||
"VisualScriptComment",
|
||||
"VisualScriptComposeArray",
|
||||
"VisualScriptCondition",
|
||||
"VisualScriptConstant",
|
||||
"VisualScriptConstructor",
|
||||
"VisualScriptCustomNode",
|
||||
"VisualScriptDeconstruct",
|
||||
"VisualScriptEditor",
|
||||
"VisualScriptEmitSignal",
|
||||
"VisualScriptEngineSingleton",
|
||||
"VisualScriptExpression",
|
||||
"VisualScriptFunctionCall",
|
||||
"VisualScriptFunctionState",
|
||||
"VisualScriptFunction",
|
||||
"VisualScriptGlobalConstant",
|
||||
"VisualScriptIndexGet",
|
||||
"VisualScriptIndexSet",
|
||||
"VisualScriptInputAction",
|
||||
"VisualScriptIterator",
|
||||
"VisualScriptLists",
|
||||
"VisualScriptLocalVarSet",
|
||||
"VisualScriptLocalVar",
|
||||
"VisualScriptMathConstant",
|
||||
"VisualScriptNode",
|
||||
"VisualScriptOperator",
|
||||
"VisualScriptPreload",
|
||||
"VisualScriptPropertyGet",
|
||||
"VisualScriptPropertySet",
|
||||
"VisualScriptResourcePath",
|
||||
"VisualScriptReturn",
|
||||
"VisualScriptSceneNode",
|
||||
"VisualScriptSceneTree",
|
||||
"VisualScriptSelect",
|
||||
"VisualScriptSelf",
|
||||
"VisualScriptSequence",
|
||||
"VisualScriptSubCall",
|
||||
"VisualScriptSwitch",
|
||||
"VisualScriptTypeCast",
|
||||
"VisualScriptVariableGet",
|
||||
"VisualScriptVariableSet",
|
||||
"VisualScriptWhile",
|
||||
"VisualScript",
|
||||
"VisualScriptYieldSignal",
|
||||
"VisualScriptYield",
|
||||
]
|
||||
|
||||
|
||||
def get_doc_path():
|
||||
return "doc_classes"
|
@ -1,373 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScript" inherits="Script" version="3.5">
|
||||
<brief_description>
|
||||
A script implemented in the Visual Script programming environment.
|
||||
</brief_description>
|
||||
<description>
|
||||
A script implemented in the Visual Script programming environment. The script extends the functionality of all objects that instance it.
|
||||
[method Object.set_script] extends an existing object, if that object's class matches one of the script's base classes.
|
||||
You are most likely to use this class via the Visual Script editor or when writing plugins for it.
|
||||
</description>
|
||||
<tutorials>
|
||||
<link>$DOCS_URL/tutorials/scripting/visual_script/index.html</link>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="add_custom_signal">
|
||||
<return type="void" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<description>
|
||||
Add a custom signal with the specified name to the VisualScript.
|
||||
</description>
|
||||
</method>
|
||||
<method name="add_function">
|
||||
<return type="void" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<description>
|
||||
Add a function with the specified name to the VisualScript.
|
||||
</description>
|
||||
</method>
|
||||
<method name="add_node">
|
||||
<return type="void" />
|
||||
<argument index="0" name="func" type="String" />
|
||||
<argument index="1" name="id" type="int" />
|
||||
<argument index="2" name="node" type="VisualScriptNode" />
|
||||
<argument index="3" name="position" type="Vector2" default="Vector2( 0, 0 )" />
|
||||
<description>
|
||||
Add a node to a function of the VisualScript.
|
||||
</description>
|
||||
</method>
|
||||
<method name="add_variable">
|
||||
<return type="void" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<argument index="1" name="default_value" type="Variant" default="null" />
|
||||
<argument index="2" name="export" type="bool" default="false" />
|
||||
<description>
|
||||
Add a variable to the VisualScript, optionally giving it a default value or marking it as exported.
|
||||
</description>
|
||||
</method>
|
||||
<method name="custom_signal_add_argument">
|
||||
<return type="void" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<argument index="1" name="type" type="int" enum="Variant.Type" />
|
||||
<argument index="2" name="argname" type="String" />
|
||||
<argument index="3" name="index" type="int" default="-1" />
|
||||
<description>
|
||||
Add an argument to a custom signal added with [method add_custom_signal].
|
||||
</description>
|
||||
</method>
|
||||
<method name="custom_signal_get_argument_count" qualifiers="const">
|
||||
<return type="int" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<description>
|
||||
Get the count of a custom signal's arguments.
|
||||
</description>
|
||||
</method>
|
||||
<method name="custom_signal_get_argument_name" qualifiers="const">
|
||||
<return type="String" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<argument index="1" name="argidx" type="int" />
|
||||
<description>
|
||||
Get the name of a custom signal's argument.
|
||||
</description>
|
||||
</method>
|
||||
<method name="custom_signal_get_argument_type" qualifiers="const">
|
||||
<return type="int" enum="Variant.Type" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<argument index="1" name="argidx" type="int" />
|
||||
<description>
|
||||
Get the type of a custom signal's argument.
|
||||
</description>
|
||||
</method>
|
||||
<method name="custom_signal_remove_argument">
|
||||
<return type="void" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<argument index="1" name="argidx" type="int" />
|
||||
<description>
|
||||
Remove a specific custom signal's argument.
|
||||
</description>
|
||||
</method>
|
||||
<method name="custom_signal_set_argument_name">
|
||||
<return type="void" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<argument index="1" name="argidx" type="int" />
|
||||
<argument index="2" name="argname" type="String" />
|
||||
<description>
|
||||
Rename a custom signal's argument.
|
||||
</description>
|
||||
</method>
|
||||
<method name="custom_signal_set_argument_type">
|
||||
<return type="void" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<argument index="1" name="argidx" type="int" />
|
||||
<argument index="2" name="type" type="int" enum="Variant.Type" />
|
||||
<description>
|
||||
Change the type of a custom signal's argument.
|
||||
</description>
|
||||
</method>
|
||||
<method name="custom_signal_swap_argument">
|
||||
<return type="void" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<argument index="1" name="argidx" type="int" />
|
||||
<argument index="2" name="withidx" type="int" />
|
||||
<description>
|
||||
Swap two of the arguments of a custom signal.
|
||||
</description>
|
||||
</method>
|
||||
<method name="data_connect">
|
||||
<return type="void" />
|
||||
<argument index="0" name="func" type="String" />
|
||||
<argument index="1" name="from_node" type="int" />
|
||||
<argument index="2" name="from_port" type="int" />
|
||||
<argument index="3" name="to_node" type="int" />
|
||||
<argument index="4" name="to_port" type="int" />
|
||||
<description>
|
||||
Connect two data ports. The value of [code]from_node[/code]'s [code]from_port[/code] would be fed into [code]to_node[/code]'s [code]to_port[/code].
|
||||
</description>
|
||||
</method>
|
||||
<method name="data_disconnect">
|
||||
<return type="void" />
|
||||
<argument index="0" name="func" type="String" />
|
||||
<argument index="1" name="from_node" type="int" />
|
||||
<argument index="2" name="from_port" type="int" />
|
||||
<argument index="3" name="to_node" type="int" />
|
||||
<argument index="4" name="to_port" type="int" />
|
||||
<description>
|
||||
Disconnect two data ports previously connected with [method data_connect].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_function_node_id" qualifiers="const">
|
||||
<return type="int" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<description>
|
||||
Returns the id of a function's entry point node.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_function_scroll" qualifiers="const">
|
||||
<return type="Vector2" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<description>
|
||||
Returns the position of the center of the screen for a given function.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_node" qualifiers="const">
|
||||
<return type="VisualScriptNode" />
|
||||
<argument index="0" name="func" type="String" />
|
||||
<argument index="1" name="id" type="int" />
|
||||
<description>
|
||||
Returns a node given its id and its function.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_node_position" qualifiers="const">
|
||||
<return type="Vector2" />
|
||||
<argument index="0" name="func" type="String" />
|
||||
<argument index="1" name="id" type="int" />
|
||||
<description>
|
||||
Returns a node's position in pixels.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_variable_default_value" qualifiers="const">
|
||||
<return type="Variant" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<description>
|
||||
Returns the default (initial) value of a variable.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_variable_export" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<description>
|
||||
Returns whether a variable is exported.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_variable_info" qualifiers="const">
|
||||
<return type="Dictionary" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<description>
|
||||
Returns the information for a given variable as a dictionary. The information includes its name, type, hint and usage.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_custom_signal" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<description>
|
||||
Returns whether a signal exists with the specified name.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_data_connection" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="func" type="String" />
|
||||
<argument index="1" name="from_node" type="int" />
|
||||
<argument index="2" name="from_port" type="int" />
|
||||
<argument index="3" name="to_node" type="int" />
|
||||
<argument index="4" name="to_port" type="int" />
|
||||
<description>
|
||||
Returns whether the specified data ports are connected.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_function" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<description>
|
||||
Returns whether a function exists with the specified name.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_node" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="func" type="String" />
|
||||
<argument index="1" name="id" type="int" />
|
||||
<description>
|
||||
Returns whether a node exists with the given id.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_sequence_connection" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="func" type="String" />
|
||||
<argument index="1" name="from_node" type="int" />
|
||||
<argument index="2" name="from_output" type="int" />
|
||||
<argument index="3" name="to_node" type="int" />
|
||||
<description>
|
||||
Returns whether the specified sequence ports are connected.
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_variable" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<description>
|
||||
Returns whether a variable exists with the specified name.
|
||||
</description>
|
||||
</method>
|
||||
<method name="remove_custom_signal">
|
||||
<return type="void" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<description>
|
||||
Remove a custom signal with the given name.
|
||||
</description>
|
||||
</method>
|
||||
<method name="remove_function">
|
||||
<return type="void" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<description>
|
||||
Remove a specific function and its nodes from the script.
|
||||
</description>
|
||||
</method>
|
||||
<method name="remove_node">
|
||||
<return type="void" />
|
||||
<argument index="0" name="func" type="String" />
|
||||
<argument index="1" name="id" type="int" />
|
||||
<description>
|
||||
Remove a specific node.
|
||||
</description>
|
||||
</method>
|
||||
<method name="remove_variable">
|
||||
<return type="void" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<description>
|
||||
Remove a variable with the given name.
|
||||
</description>
|
||||
</method>
|
||||
<method name="rename_custom_signal">
|
||||
<return type="void" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<argument index="1" name="new_name" type="String" />
|
||||
<description>
|
||||
Change the name of a custom signal.
|
||||
</description>
|
||||
</method>
|
||||
<method name="rename_function">
|
||||
<return type="void" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<argument index="1" name="new_name" type="String" />
|
||||
<description>
|
||||
Change the name of a function.
|
||||
</description>
|
||||
</method>
|
||||
<method name="rename_variable">
|
||||
<return type="void" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<argument index="1" name="new_name" type="String" />
|
||||
<description>
|
||||
Change the name of a variable.
|
||||
</description>
|
||||
</method>
|
||||
<method name="sequence_connect">
|
||||
<return type="void" />
|
||||
<argument index="0" name="func" type="String" />
|
||||
<argument index="1" name="from_node" type="int" />
|
||||
<argument index="2" name="from_output" type="int" />
|
||||
<argument index="3" name="to_node" type="int" />
|
||||
<description>
|
||||
Connect two sequence ports. The execution will flow from of [code]from_node[/code]'s [code]from_output[/code] into [code]to_node[/code].
|
||||
Unlike [method data_connect], there isn't a [code]to_port[/code], since the target node can have only one sequence port.
|
||||
</description>
|
||||
</method>
|
||||
<method name="sequence_disconnect">
|
||||
<return type="void" />
|
||||
<argument index="0" name="func" type="String" />
|
||||
<argument index="1" name="from_node" type="int" />
|
||||
<argument index="2" name="from_output" type="int" />
|
||||
<argument index="3" name="to_node" type="int" />
|
||||
<description>
|
||||
Disconnect two sequence ports previously connected with [method sequence_connect].
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_function_scroll">
|
||||
<return type="void" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<argument index="1" name="ofs" type="Vector2" />
|
||||
<description>
|
||||
Position the center of the screen for a function.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_instance_base_type">
|
||||
<return type="void" />
|
||||
<argument index="0" name="type" type="String" />
|
||||
<description>
|
||||
Set the base type of the script.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_node_position">
|
||||
<return type="void" />
|
||||
<argument index="0" name="func" type="String" />
|
||||
<argument index="1" name="id" type="int" />
|
||||
<argument index="2" name="position" type="Vector2" />
|
||||
<description>
|
||||
Position a node on the screen.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_variable_default_value">
|
||||
<return type="void" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<argument index="1" name="value" type="Variant" />
|
||||
<description>
|
||||
Change the default (initial) value of a variable.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_variable_export">
|
||||
<return type="void" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<argument index="1" name="enable" type="bool" />
|
||||
<description>
|
||||
Change whether a variable is exported.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_variable_info">
|
||||
<return type="void" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<argument index="1" name="value" type="Dictionary" />
|
||||
<description>
|
||||
Set a variable's info, using the same format as [method get_variable_info].
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<signals>
|
||||
<signal name="node_ports_changed">
|
||||
<argument index="0" name="function" type="String" />
|
||||
<argument index="1" name="id" type="int" />
|
||||
<description>
|
||||
Emitted when the ports of a node are changed.
|
||||
</description>
|
||||
</signal>
|
||||
</signals>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptBasicTypeConstant" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node representing a constant from the base types.
|
||||
</brief_description>
|
||||
<description>
|
||||
A Visual Script node representing a constant from base types, such as [constant Vector3.AXIS_X].
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="basic_type" type="int" setter="set_basic_type" getter="get_basic_type" enum="Variant.Type" default="0">
|
||||
The type to get the constant from.
|
||||
</member>
|
||||
<member name="constant" type="String" setter="set_basic_type_constant" getter="get_basic_type_constant">
|
||||
The name of the constant to return.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,226 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptBuiltinFunc" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node used to call built-in functions.
|
||||
</brief_description>
|
||||
<description>
|
||||
A built-in function used inside a [VisualScript]. It is usually a math function or an utility function.
|
||||
See also [@GDScript], for the same functions in the GDScript language.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="function" type="int" setter="set_func" getter="get_func" enum="VisualScriptBuiltinFunc.BuiltinFunc" default="0">
|
||||
The function to be executed.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
<constant name="MATH_SIN" value="0" enum="BuiltinFunc">
|
||||
Return the sine of the input.
|
||||
</constant>
|
||||
<constant name="MATH_COS" value="1" enum="BuiltinFunc">
|
||||
Return the cosine of the input.
|
||||
</constant>
|
||||
<constant name="MATH_TAN" value="2" enum="BuiltinFunc">
|
||||
Return the tangent of the input.
|
||||
</constant>
|
||||
<constant name="MATH_SINH" value="3" enum="BuiltinFunc">
|
||||
Return the hyperbolic sine of the input.
|
||||
</constant>
|
||||
<constant name="MATH_COSH" value="4" enum="BuiltinFunc">
|
||||
Return the hyperbolic cosine of the input.
|
||||
</constant>
|
||||
<constant name="MATH_TANH" value="5" enum="BuiltinFunc">
|
||||
Return the hyperbolic tangent of the input.
|
||||
</constant>
|
||||
<constant name="MATH_ASIN" value="6" enum="BuiltinFunc">
|
||||
Return the arc sine of the input.
|
||||
</constant>
|
||||
<constant name="MATH_ACOS" value="7" enum="BuiltinFunc">
|
||||
Return the arc cosine of the input.
|
||||
</constant>
|
||||
<constant name="MATH_ATAN" value="8" enum="BuiltinFunc">
|
||||
Return the arc tangent of the input.
|
||||
</constant>
|
||||
<constant name="MATH_ATAN2" value="9" enum="BuiltinFunc">
|
||||
Return the arc tangent of the input, using the signs of both parameters to determine the exact angle.
|
||||
</constant>
|
||||
<constant name="MATH_SQRT" value="10" enum="BuiltinFunc">
|
||||
Return the square root of the input.
|
||||
</constant>
|
||||
<constant name="MATH_FMOD" value="11" enum="BuiltinFunc">
|
||||
Return the remainder of one input divided by the other, using floating-point numbers.
|
||||
</constant>
|
||||
<constant name="MATH_FPOSMOD" value="12" enum="BuiltinFunc">
|
||||
Return the positive remainder of one input divided by the other, using floating-point numbers.
|
||||
</constant>
|
||||
<constant name="MATH_FLOOR" value="13" enum="BuiltinFunc">
|
||||
Return the input rounded down.
|
||||
</constant>
|
||||
<constant name="MATH_CEIL" value="14" enum="BuiltinFunc">
|
||||
Return the input rounded up.
|
||||
</constant>
|
||||
<constant name="MATH_ROUND" value="15" enum="BuiltinFunc">
|
||||
Return the input rounded to the nearest integer.
|
||||
</constant>
|
||||
<constant name="MATH_ABS" value="16" enum="BuiltinFunc">
|
||||
Return the absolute value of the input.
|
||||
</constant>
|
||||
<constant name="MATH_SIGN" value="17" enum="BuiltinFunc">
|
||||
Return the sign of the input, turning it into 1, -1, or 0. Useful to determine if the input is positive or negative.
|
||||
</constant>
|
||||
<constant name="MATH_POW" value="18" enum="BuiltinFunc">
|
||||
Return the input raised to a given power.
|
||||
</constant>
|
||||
<constant name="MATH_LOG" value="19" enum="BuiltinFunc">
|
||||
Return the natural logarithm of the input. Note that this is not the typical base-10 logarithm function calculators use.
|
||||
</constant>
|
||||
<constant name="MATH_EXP" value="20" enum="BuiltinFunc">
|
||||
Return the mathematical constant [b]e[/b] raised to the specified power of the input. [b]e[/b] has an approximate value of 2.71828.
|
||||
</constant>
|
||||
<constant name="MATH_ISNAN" value="21" enum="BuiltinFunc">
|
||||
Return whether the input is NaN (Not a Number) or not. NaN is usually produced by dividing 0 by 0, though other ways exist.
|
||||
</constant>
|
||||
<constant name="MATH_ISINF" value="22" enum="BuiltinFunc">
|
||||
Return whether the input is an infinite floating-point number or not. Infinity is usually produced by dividing a number by 0, though other ways exist.
|
||||
</constant>
|
||||
<constant name="MATH_EASE" value="23" enum="BuiltinFunc">
|
||||
Easing function, based on exponent. 0 is constant, 1 is linear, 0 to 1 is ease-in, 1+ is ease out. Negative values are in-out/out in.
|
||||
</constant>
|
||||
<constant name="MATH_DECIMALS" value="24" enum="BuiltinFunc">
|
||||
Return the number of digit places after the decimal that the first non-zero digit occurs.
|
||||
</constant>
|
||||
<constant name="MATH_STEPIFY" value="25" enum="BuiltinFunc">
|
||||
Return the input snapped to a given step.
|
||||
</constant>
|
||||
<constant name="MATH_LERP" value="26" enum="BuiltinFunc">
|
||||
Return a number linearly interpolated between the first two inputs, based on the third input. Uses the formula [code]a + (a - b) * t[/code].
|
||||
</constant>
|
||||
<constant name="MATH_INVERSE_LERP" value="27" enum="BuiltinFunc">
|
||||
</constant>
|
||||
<constant name="MATH_RANGE_LERP" value="28" enum="BuiltinFunc">
|
||||
</constant>
|
||||
<constant name="MATH_MOVE_TOWARD" value="29" enum="BuiltinFunc">
|
||||
Moves the number toward a value, based on the third input.
|
||||
</constant>
|
||||
<constant name="MATH_DECTIME" value="30" enum="BuiltinFunc">
|
||||
Return the result of [code]value[/code] decreased by [code]step[/code] * [code]amount[/code].
|
||||
</constant>
|
||||
<constant name="MATH_RANDOMIZE" value="31" enum="BuiltinFunc">
|
||||
Randomize the seed (or the internal state) of the random number generator. Current implementation reseeds using a number based on time.
|
||||
</constant>
|
||||
<constant name="MATH_RAND" value="32" enum="BuiltinFunc">
|
||||
Return a random 32 bits integer value. To obtain a random value between 0 to N (where N is smaller than 2^32 - 1), you can use it with the remainder function.
|
||||
</constant>
|
||||
<constant name="MATH_RANDF" value="33" enum="BuiltinFunc">
|
||||
Return a random floating-point value between 0 and 1. To obtain a random value between 0 to N, you can use it with multiplication.
|
||||
</constant>
|
||||
<constant name="MATH_RANDOM" value="34" enum="BuiltinFunc">
|
||||
Return a random floating-point value between the two inputs.
|
||||
</constant>
|
||||
<constant name="MATH_SEED" value="35" enum="BuiltinFunc">
|
||||
Set the seed for the random number generator.
|
||||
</constant>
|
||||
<constant name="MATH_RANDSEED" value="36" enum="BuiltinFunc">
|
||||
Return a random value from the given seed, along with the new seed.
|
||||
</constant>
|
||||
<constant name="MATH_DEG2RAD" value="37" enum="BuiltinFunc">
|
||||
Convert the input from degrees to radians.
|
||||
</constant>
|
||||
<constant name="MATH_RAD2DEG" value="38" enum="BuiltinFunc">
|
||||
Convert the input from radians to degrees.
|
||||
</constant>
|
||||
<constant name="MATH_LINEAR2DB" value="39" enum="BuiltinFunc">
|
||||
Convert the input from linear volume to decibel volume.
|
||||
</constant>
|
||||
<constant name="MATH_DB2LINEAR" value="40" enum="BuiltinFunc">
|
||||
Convert the input from decibel volume to linear volume.
|
||||
</constant>
|
||||
<constant name="MATH_POLAR2CARTESIAN" value="41" enum="BuiltinFunc">
|
||||
Converts a 2D point expressed in the polar coordinate system (a distance from the origin [code]r[/code] and an angle [code]th[/code]) to the cartesian coordinate system (X and Y axis).
|
||||
</constant>
|
||||
<constant name="MATH_CARTESIAN2POLAR" value="42" enum="BuiltinFunc">
|
||||
Converts a 2D point expressed in the cartesian coordinate system (X and Y axis) to the polar coordinate system (a distance from the origin and an angle).
|
||||
</constant>
|
||||
<constant name="MATH_WRAP" value="43" enum="BuiltinFunc">
|
||||
</constant>
|
||||
<constant name="MATH_WRAPF" value="44" enum="BuiltinFunc">
|
||||
</constant>
|
||||
<constant name="LOGIC_MAX" value="45" enum="BuiltinFunc">
|
||||
Return the greater of the two numbers, also known as their maximum.
|
||||
</constant>
|
||||
<constant name="LOGIC_MIN" value="46" enum="BuiltinFunc">
|
||||
Return the lesser of the two numbers, also known as their minimum.
|
||||
</constant>
|
||||
<constant name="LOGIC_CLAMP" value="47" enum="BuiltinFunc">
|
||||
Return the input clamped inside the given range, ensuring the result is never outside it. Equivalent to [code]min(max(input, range_low), range_high)[/code].
|
||||
</constant>
|
||||
<constant name="LOGIC_NEAREST_PO2" value="48" enum="BuiltinFunc">
|
||||
Return the nearest power of 2 to the input.
|
||||
</constant>
|
||||
<constant name="OBJ_WEAKREF" value="49" enum="BuiltinFunc">
|
||||
Create a [WeakRef] from the input.
|
||||
</constant>
|
||||
<constant name="FUNC_FUNCREF" value="50" enum="BuiltinFunc">
|
||||
Create a [FuncRef] from the input.
|
||||
</constant>
|
||||
<constant name="TYPE_CONVERT" value="51" enum="BuiltinFunc">
|
||||
Convert between types.
|
||||
</constant>
|
||||
<constant name="TYPE_OF" value="52" enum="BuiltinFunc">
|
||||
Return the type of the input as an integer. Check [enum Variant.Type] for the integers that might be returned.
|
||||
</constant>
|
||||
<constant name="TYPE_EXISTS" value="53" enum="BuiltinFunc">
|
||||
Checks if a type is registered in the [ClassDB].
|
||||
</constant>
|
||||
<constant name="TEXT_CHAR" value="54" enum="BuiltinFunc">
|
||||
Return a character with the given ascii value.
|
||||
</constant>
|
||||
<constant name="TEXT_STR" value="55" enum="BuiltinFunc">
|
||||
Convert the input to a string.
|
||||
</constant>
|
||||
<constant name="TEXT_PRINT" value="56" enum="BuiltinFunc">
|
||||
Print the given string to the output window.
|
||||
</constant>
|
||||
<constant name="TEXT_PRINTERR" value="57" enum="BuiltinFunc">
|
||||
Print the given string to the standard error output.
|
||||
</constant>
|
||||
<constant name="TEXT_PRINTRAW" value="58" enum="BuiltinFunc">
|
||||
Print the given string to the standard output, without adding a newline.
|
||||
</constant>
|
||||
<constant name="VAR_TO_STR" value="59" enum="BuiltinFunc">
|
||||
Serialize a [Variant] to a string.
|
||||
</constant>
|
||||
<constant name="STR_TO_VAR" value="60" enum="BuiltinFunc">
|
||||
Deserialize a [Variant] from a string serialized using [constant VAR_TO_STR].
|
||||
</constant>
|
||||
<constant name="VAR_TO_BYTES" value="61" enum="BuiltinFunc">
|
||||
Serialize a [Variant] to a [PoolByteArray].
|
||||
</constant>
|
||||
<constant name="BYTES_TO_VAR" value="62" enum="BuiltinFunc">
|
||||
Deserialize a [Variant] from a [PoolByteArray] serialized using [constant VAR_TO_BYTES].
|
||||
</constant>
|
||||
<constant name="COLORN" value="63" enum="BuiltinFunc">
|
||||
Return the [Color] with the given name and alpha ranging from 0 to 1.
|
||||
[b]Note:[/b] Names are defined in [code]color_names.inc[/code].
|
||||
</constant>
|
||||
<constant name="MATH_SMOOTHSTEP" value="64" enum="BuiltinFunc">
|
||||
Return a number smoothly interpolated between the first two inputs, based on the third input. Similar to [constant MATH_LERP], but interpolates faster at the beginning and slower at the end. Using Hermite interpolation formula:
|
||||
[codeblock]
|
||||
var t = clamp((weight - from) / (to - from), 0.0, 1.0)
|
||||
return t * t * (3.0 - 2.0 * t)
|
||||
[/codeblock]
|
||||
</constant>
|
||||
<constant name="MATH_POSMOD" value="65" enum="BuiltinFunc">
|
||||
</constant>
|
||||
<constant name="MATH_LERP_ANGLE" value="66" enum="BuiltinFunc">
|
||||
</constant>
|
||||
<constant name="TEXT_ORD" value="67" enum="BuiltinFunc">
|
||||
</constant>
|
||||
<constant name="FUNC_MAX" value="68" enum="BuiltinFunc">
|
||||
Represents the size of the [enum BuiltinFunc] enum.
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptClassConstant" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
Gets a constant from a given class.
|
||||
</brief_description>
|
||||
<description>
|
||||
This node returns a constant from a given class, such as [constant TYPE_INT]. See the given class' documentation for available constants.
|
||||
[b]Input Ports:[/b]
|
||||
none
|
||||
[b]Output Ports:[/b]
|
||||
- Data (variant): [code]value[/code]
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="base_type" type="String" setter="set_base_type" getter="get_base_type" default=""Object"">
|
||||
The constant's parent class.
|
||||
</member>
|
||||
<member name="constant" type="String" setter="set_class_constant" getter="get_class_constant" default="""">
|
||||
The constant to return. See the given class for its available constants.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptComment" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node used to annotate the script.
|
||||
</brief_description>
|
||||
<description>
|
||||
A Visual Script node used to display annotations in the script, so that code may be documented.
|
||||
Comment nodes can be resized so they encompass a group of nodes.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="description" type="String" setter="set_description" getter="get_description" default="""">
|
||||
The text inside the comment node.
|
||||
</member>
|
||||
<member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2( 150, 150 )">
|
||||
The comment node's size (in pixels).
|
||||
</member>
|
||||
<member name="title" type="String" setter="set_title" getter="get_title" default=""Comment"">
|
||||
The comment node's title.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptComposeArray" inherits="VisualScriptLists" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script Node used to create array from a list of items.
|
||||
</brief_description>
|
||||
<description>
|
||||
A Visual Script Node used to compose array from the list of elements provided with custom in-graph UI hard coded in the VisualScript Editor.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptCondition" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node which branches the flow.
|
||||
</brief_description>
|
||||
<description>
|
||||
A Visual Script node that checks a [bool] input port. If [code]true[/code], it will exit via the "true" sequence port. If [code]false[/code], it will exit via the "false" sequence port. After exiting either, it exits via the "done" port. Sequence ports may be left disconnected.
|
||||
[b]Input Ports:[/b]
|
||||
- Sequence: [code]if (cond) is[/code]
|
||||
- Data (boolean): [code]cond[/code]
|
||||
[b]Output Ports:[/b]
|
||||
- Sequence: [code]true[/code]
|
||||
- Sequence: [code]false[/code]
|
||||
- Sequence: [code]done[/code]
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptConstant" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
Gets a contant's value.
|
||||
</brief_description>
|
||||
<description>
|
||||
This node returns a constant's value.
|
||||
[b]Input Ports:[/b]
|
||||
none
|
||||
[b]Output Ports:[/b]
|
||||
- Data (variant): [code]get[/code]
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="type" type="int" setter="set_constant_type" getter="get_constant_type" enum="Variant.Type" default="0">
|
||||
The constant's type.
|
||||
</member>
|
||||
<member name="value" type="Variant" setter="set_constant_value" getter="get_constant_value">
|
||||
The constant's value.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,37 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptConstructor" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node which calls a base type constructor.
|
||||
</brief_description>
|
||||
<description>
|
||||
A Visual Script node which calls a base type constructor. It can be used for type conversion as well.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="get_constructor" qualifiers="const">
|
||||
<return type="Dictionary" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_constructor_type" qualifiers="const">
|
||||
<return type="int" enum="Variant.Type" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_constructor">
|
||||
<return type="void" />
|
||||
<argument index="0" name="constructor" type="Dictionary" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_constructor_type">
|
||||
<return type="void" />
|
||||
<argument index="0" name="type" type="int" enum="Variant.Type" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,166 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptCustomNode" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A scripted Visual Script node.
|
||||
</brief_description>
|
||||
<description>
|
||||
A custom Visual Script node which can be scripted in powerful ways.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="_get_caption" qualifiers="virtual">
|
||||
<return type="String" />
|
||||
<description>
|
||||
Return the node's title.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_category" qualifiers="virtual">
|
||||
<return type="String" />
|
||||
<description>
|
||||
Return the node's category.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_input_value_port_count" qualifiers="virtual">
|
||||
<return type="int" />
|
||||
<description>
|
||||
Return the count of input value ports.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_input_value_port_hint" qualifiers="virtual">
|
||||
<return type="int" />
|
||||
<argument index="0" name="idx" type="int" />
|
||||
<description>
|
||||
Return the specified input port's hint. See the [enum @GlobalScope.PropertyHint] hints.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_input_value_port_hint_string" qualifiers="virtual">
|
||||
<return type="String" />
|
||||
<argument index="0" name="idx" type="int" />
|
||||
<description>
|
||||
Return the specified input port's hint string.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_input_value_port_name" qualifiers="virtual">
|
||||
<return type="String" />
|
||||
<argument index="0" name="idx" type="int" />
|
||||
<description>
|
||||
Return the specified input port's name.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_input_value_port_type" qualifiers="virtual">
|
||||
<return type="int" />
|
||||
<argument index="0" name="idx" type="int" />
|
||||
<description>
|
||||
Return the specified input port's type. See the [enum Variant.Type] values.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_output_sequence_port_count" qualifiers="virtual">
|
||||
<return type="int" />
|
||||
<description>
|
||||
Return the amount of output [b]sequence[/b] ports.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_output_sequence_port_text" qualifiers="virtual">
|
||||
<return type="String" />
|
||||
<argument index="0" name="idx" type="int" />
|
||||
<description>
|
||||
Return the specified [b]sequence[/b] output's name.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_output_value_port_count" qualifiers="virtual">
|
||||
<return type="int" />
|
||||
<description>
|
||||
Return the amount of output value ports.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_output_value_port_hint" qualifiers="virtual">
|
||||
<return type="int" />
|
||||
<argument index="0" name="idx" type="int" />
|
||||
<description>
|
||||
Return the specified output port's hint. See the [enum @GlobalScope.PropertyHint] hints.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_output_value_port_hint_string" qualifiers="virtual">
|
||||
<return type="String" />
|
||||
<argument index="0" name="idx" type="int" />
|
||||
<description>
|
||||
Return the specified output port's hint string.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_output_value_port_name" qualifiers="virtual">
|
||||
<return type="String" />
|
||||
<argument index="0" name="idx" type="int" />
|
||||
<description>
|
||||
Return the specified output port's name.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_output_value_port_type" qualifiers="virtual">
|
||||
<return type="int" />
|
||||
<argument index="0" name="idx" type="int" />
|
||||
<description>
|
||||
Return the specified output port's type. See the [enum Variant.Type] values.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_text" qualifiers="virtual">
|
||||
<return type="String" />
|
||||
<description>
|
||||
Return the custom node's text, which is shown right next to the input [b]sequence[/b] port (if there is none, on the place that is usually taken by it).
|
||||
</description>
|
||||
</method>
|
||||
<method name="_get_working_memory_size" qualifiers="virtual">
|
||||
<return type="int" />
|
||||
<description>
|
||||
Return the size of the custom node's working memory. See [method _step] for more details.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_has_input_sequence_port" qualifiers="virtual">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Return whether the custom node has an input [b]sequence[/b] port.
|
||||
</description>
|
||||
</method>
|
||||
<method name="_step" qualifiers="virtual">
|
||||
<return type="Variant" />
|
||||
<argument index="0" name="inputs" type="Array" />
|
||||
<argument index="1" name="outputs" type="Array" />
|
||||
<argument index="2" name="start_mode" type="int" />
|
||||
<argument index="3" name="working_mem" type="Array" />
|
||||
<description>
|
||||
Execute the custom node's logic, returning the index of the output sequence port to use or a [String] when there is an error.
|
||||
The [code]inputs[/code] array contains the values of the input ports.
|
||||
[code]outputs[/code] is an array whose indices should be set to the respective outputs.
|
||||
The [code]start_mode[/code] is usually [constant START_MODE_BEGIN_SEQUENCE], unless you have used the [code]STEP_*[/code] constants.
|
||||
[code]working_mem[/code] is an array which can be used to persist information between runs of the custom node. The size needs to be predefined using [method _get_working_memory_size].
|
||||
When returning, you can mask the returned value with one of the [code]STEP_*[/code] constants.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<constants>
|
||||
<constant name="START_MODE_BEGIN_SEQUENCE" value="0" enum="StartMode">
|
||||
The start mode used the first time when [method _step] is called.
|
||||
</constant>
|
||||
<constant name="START_MODE_CONTINUE_SEQUENCE" value="1" enum="StartMode">
|
||||
The start mode used when [method _step] is called after coming back from a [constant STEP_PUSH_STACK_BIT].
|
||||
</constant>
|
||||
<constant name="START_MODE_RESUME_YIELD" value="2" enum="StartMode">
|
||||
The start mode used when [method _step] is called after resuming from [constant STEP_YIELD_BIT].
|
||||
</constant>
|
||||
<constant name="STEP_PUSH_STACK_BIT" value="16777216">
|
||||
Hint used by [method _step] to tell that control should return to it when there is no other node left to execute.
|
||||
This is used by [VisualScriptCondition] to redirect the sequence to the "Done" port after the [code]true[/code]/[code]false[/code] branch has finished execution.
|
||||
</constant>
|
||||
<constant name="STEP_GO_BACK_BIT" value="33554432">
|
||||
Hint used by [method _step] to tell that control should return back, either hitting a previous [constant STEP_PUSH_STACK_BIT] or exiting the function.
|
||||
</constant>
|
||||
<constant name="STEP_NO_ADVANCE_BIT" value="67108864">
|
||||
</constant>
|
||||
<constant name="STEP_EXIT_FUNCTION_BIT" value="134217728">
|
||||
Hint used by [method _step] to tell that control should stop and exit the function.
|
||||
</constant>
|
||||
<constant name="STEP_YIELD_BIT" value="268435456">
|
||||
Hint used by [method _step] to tell that the function should be yielded.
|
||||
Using this requires you to have at least one working memory slot, which is used for the [VisualScriptFunctionState].
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptDeconstruct" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node which deconstructs a base type instance into its parts.
|
||||
</brief_description>
|
||||
<description>
|
||||
A Visual Script node which deconstructs a base type instance into its parts.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="type" type="int" setter="set_deconstruct_type" getter="get_deconstruct_type" enum="Variant.Type" default="0">
|
||||
The type to deconstruct.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,37 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptEditor" inherits="Object" version="3.5">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="add_custom_node">
|
||||
<return type="void" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<argument index="1" name="category" type="String" />
|
||||
<argument index="2" name="script" type="Script" />
|
||||
<description>
|
||||
Add a custom Visual Script node to the editor. It'll be placed under "Custom Nodes" with the [code]category[/code] as the parameter.
|
||||
</description>
|
||||
</method>
|
||||
<method name="remove_custom_node">
|
||||
<return type="void" />
|
||||
<argument index="0" name="name" type="String" />
|
||||
<argument index="1" name="category" type="String" />
|
||||
<description>
|
||||
Remove a custom Visual Script node from the editor. Custom nodes already placed on scripts won't be removed.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<signals>
|
||||
<signal name="custom_nodes_updated">
|
||||
<description>
|
||||
Emitted when a custom Visual Script node is added or removed.
|
||||
</description>
|
||||
</signal>
|
||||
</signals>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptEmitSignal" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
Emits a specified signal.
|
||||
</brief_description>
|
||||
<description>
|
||||
Emits a specified signal when it is executed.
|
||||
[b]Input Ports:[/b]
|
||||
- Sequence: [code]emit[/code]
|
||||
[b]Output Ports:[/b]
|
||||
- Sequence
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="signal" type="String" setter="set_signal" getter="get_signal" default="""">
|
||||
The signal to emit.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptEngineSingleton" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node returning a singleton from [@GlobalScope].
|
||||
</brief_description>
|
||||
<description>
|
||||
A Visual Script node returning a singleton from [@GlobalScope].
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="constant" type="String" setter="set_singleton" getter="get_singleton" default="""">
|
||||
The singleton's name.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptExpression" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node that can execute a custom expression.
|
||||
</brief_description>
|
||||
<description>
|
||||
A Visual Script node that can execute a custom expression. Values can be provided for the input and the expression result can be retrieved from the output.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptFunction" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node representing a function.
|
||||
</brief_description>
|
||||
<description>
|
||||
[VisualScriptFunction] represents a function header. It is the starting point for the function body and can be used to tweak the function's properties (e.g. RPC mode).
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,77 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptFunctionCall" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node for calling a function.
|
||||
</brief_description>
|
||||
<description>
|
||||
[VisualScriptFunctionCall] is created when you add or drag and drop a function onto the Visual Script graph. It allows to tweak parameters of the call, e.g. what object the function is called on.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="base_script" type="String" setter="set_base_script" getter="get_base_script">
|
||||
The script to be used when [member call_mode] is set to [constant CALL_MODE_INSTANCE].
|
||||
</member>
|
||||
<member name="base_type" type="String" setter="set_base_type" getter="get_base_type" default=""Object"">
|
||||
The base type to be used when [member call_mode] is set to [constant CALL_MODE_INSTANCE].
|
||||
</member>
|
||||
<member name="basic_type" type="int" setter="set_basic_type" getter="get_basic_type" enum="Variant.Type">
|
||||
The type to be used when [member call_mode] is set to [constant CALL_MODE_BASIC_TYPE].
|
||||
</member>
|
||||
<member name="call_mode" type="int" setter="set_call_mode" getter="get_call_mode" enum="VisualScriptFunctionCall.CallMode" default="0">
|
||||
[code]call_mode[/code] determines the target object on which the method will be called. See [enum CallMode] for options.
|
||||
</member>
|
||||
<member name="function" type="String" setter="set_function" getter="get_function" default="""">
|
||||
The name of the function to be called.
|
||||
</member>
|
||||
<member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path">
|
||||
The node path to use when [member call_mode] is set to [constant CALL_MODE_NODE_PATH].
|
||||
</member>
|
||||
<member name="rpc_call_mode" type="int" setter="set_rpc_call_mode" getter="get_rpc_call_mode" enum="VisualScriptFunctionCall.RPCCallMode" default="0">
|
||||
The mode for RPC calls. See [method Node.rpc] for more details and [enum RPCCallMode] for available options.
|
||||
</member>
|
||||
<member name="singleton" type="String" setter="set_singleton" getter="get_singleton">
|
||||
The singleton to call the method on. Used when [member call_mode] is set to [constant CALL_MODE_SINGLETON].
|
||||
</member>
|
||||
<member name="use_default_args" type="int" setter="set_use_default_args" getter="get_use_default_args">
|
||||
Number of default arguments that will be used when calling the function. Can't be higher than the number of available default arguments in the method's declaration.
|
||||
</member>
|
||||
<member name="validate" type="bool" setter="set_validate" getter="get_validate" default="true">
|
||||
If [code]false[/code], call errors (e.g. wrong number of arguments) will be ignored.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
<constant name="CALL_MODE_SELF" value="0" enum="CallMode">
|
||||
The method will be called on this [Object].
|
||||
</constant>
|
||||
<constant name="CALL_MODE_NODE_PATH" value="1" enum="CallMode">
|
||||
The method will be called on the given [Node] in the scene tree.
|
||||
</constant>
|
||||
<constant name="CALL_MODE_INSTANCE" value="2" enum="CallMode">
|
||||
The method will be called on an instanced node with the given type and script.
|
||||
</constant>
|
||||
<constant name="CALL_MODE_BASIC_TYPE" value="3" enum="CallMode">
|
||||
The method will be called on a GDScript basic type (e.g. [Vector2]).
|
||||
</constant>
|
||||
<constant name="CALL_MODE_SINGLETON" value="4" enum="CallMode">
|
||||
The method will be called on a singleton.
|
||||
</constant>
|
||||
<constant name="RPC_DISABLED" value="0" enum="RPCCallMode">
|
||||
The method will be called locally.
|
||||
</constant>
|
||||
<constant name="RPC_RELIABLE" value="1" enum="RPCCallMode">
|
||||
The method will be called remotely.
|
||||
</constant>
|
||||
<constant name="RPC_UNRELIABLE" value="2" enum="RPCCallMode">
|
||||
The method will be called remotely using an unreliable protocol.
|
||||
</constant>
|
||||
<constant name="RPC_RELIABLE_TO_ID" value="3" enum="RPCCallMode">
|
||||
The method will be called remotely for the given peer.
|
||||
</constant>
|
||||
<constant name="RPC_UNRELIABLE_TO_ID" value="4" enum="RPCCallMode">
|
||||
The method will be called remotely for the given peer, using an unreliable protocol.
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
@ -1,37 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptFunctionState" inherits="Reference" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node representing a function state.
|
||||
</brief_description>
|
||||
<description>
|
||||
[VisualScriptFunctionState] is returned from [VisualScriptYield] and can be used to resume a paused function call.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="connect_to_signal">
|
||||
<return type="void" />
|
||||
<argument index="0" name="obj" type="Object" />
|
||||
<argument index="1" name="signals" type="String" />
|
||||
<argument index="2" name="args" type="Array" />
|
||||
<description>
|
||||
Connects this [VisualScriptFunctionState] to a signal in the given object to automatically resume when it's emitted.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_valid" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns whether the function state is valid.
|
||||
</description>
|
||||
</method>
|
||||
<method name="resume">
|
||||
<return type="Variant" />
|
||||
<argument index="0" name="args" type="Array" default="null" />
|
||||
<description>
|
||||
Resumes the function to run from the point it was yielded.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptGlobalConstant" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node returning a constant from [@GlobalScope].
|
||||
</brief_description>
|
||||
<description>
|
||||
A Visual Script node returning a constant from [@GlobalScope].
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="constant" type="int" setter="set_global_constant" getter="get_global_constant" default="0">
|
||||
The constant to be used.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptIndexGet" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node for getting a value from an array or a dictionary.
|
||||
</brief_description>
|
||||
<description>
|
||||
[VisualScriptIndexGet] will return the value stored in an array or a dictionary under the given index.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptIndexSet" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node for setting a value in an array or a dictionary.
|
||||
</brief_description>
|
||||
<description>
|
||||
[VisualScriptIndexSet] will set the value stored in an array or a dictionary under the given index to the provided new value.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,35 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptInputAction" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node returning a state of an action.
|
||||
</brief_description>
|
||||
<description>
|
||||
[VisualScriptInputAction] can be used to check if an action is pressed or released.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="action" type="String" setter="set_action_name" getter="get_action_name" default="""">
|
||||
Name of the action.
|
||||
</member>
|
||||
<member name="mode" type="int" setter="set_action_mode" getter="get_action_mode" enum="VisualScriptInputAction.Mode" default="0">
|
||||
State of the action to check. See [enum Mode] for options.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
<constant name="MODE_PRESSED" value="0" enum="Mode">
|
||||
[code]True[/code] if action is pressed.
|
||||
</constant>
|
||||
<constant name="MODE_RELEASED" value="1" enum="Mode">
|
||||
[code]True[/code] if action is released (i.e. not pressed).
|
||||
</constant>
|
||||
<constant name="MODE_JUST_PRESSED" value="2" enum="Mode">
|
||||
[code]True[/code] on the frame the action was pressed.
|
||||
</constant>
|
||||
<constant name="MODE_JUST_RELEASED" value="3" enum="Mode">
|
||||
[code]True[/code] on the frame the action was released.
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptIterator" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
Steps through items in a given input.
|
||||
</brief_description>
|
||||
<description>
|
||||
This node steps through each item in a given input. Input can be any sequence data type, such as an [Array] or [String]. When each item has been processed, execution passed out the [code]exit[/code] Sequence port.
|
||||
[b]Input Ports:[/b]
|
||||
- Sequence: [code]for (elem) in (input)[/code]
|
||||
- Data (variant): [code]input[/code]
|
||||
[b]Output Ports:[/b]
|
||||
- Sequence: [code]each[/code]
|
||||
- Sequence: [code]exit[/code]
|
||||
- Data (variant): [code]elem[/code]
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,79 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptLists" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script virtual class for in-graph editable nodes.
|
||||
</brief_description>
|
||||
<description>
|
||||
A Visual Script virtual class that defines the shape and the default behavior of the nodes that have to be in-graph editable nodes.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="add_input_data_port">
|
||||
<return type="void" />
|
||||
<argument index="0" name="type" type="int" enum="Variant.Type" />
|
||||
<argument index="1" name="name" type="String" />
|
||||
<argument index="2" name="index" type="int" />
|
||||
<description>
|
||||
Adds an input port to the Visual Script node.
|
||||
</description>
|
||||
</method>
|
||||
<method name="add_output_data_port">
|
||||
<return type="void" />
|
||||
<argument index="0" name="type" type="int" enum="Variant.Type" />
|
||||
<argument index="1" name="name" type="String" />
|
||||
<argument index="2" name="index" type="int" />
|
||||
<description>
|
||||
Adds an output port to the Visual Script node.
|
||||
</description>
|
||||
</method>
|
||||
<method name="remove_input_data_port">
|
||||
<return type="void" />
|
||||
<argument index="0" name="index" type="int" />
|
||||
<description>
|
||||
Removes an input port from the Visual Script node.
|
||||
</description>
|
||||
</method>
|
||||
<method name="remove_output_data_port">
|
||||
<return type="void" />
|
||||
<argument index="0" name="index" type="int" />
|
||||
<description>
|
||||
Removes an output port from the Visual Script node.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_input_data_port_name">
|
||||
<return type="void" />
|
||||
<argument index="0" name="index" type="int" />
|
||||
<argument index="1" name="name" type="String" />
|
||||
<description>
|
||||
Sets the name of an input port.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_input_data_port_type">
|
||||
<return type="void" />
|
||||
<argument index="0" name="index" type="int" />
|
||||
<argument index="1" name="type" type="int" enum="Variant.Type" />
|
||||
<description>
|
||||
Sets the type of an input port.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_output_data_port_name">
|
||||
<return type="void" />
|
||||
<argument index="0" name="index" type="int" />
|
||||
<argument index="1" name="name" type="String" />
|
||||
<description>
|
||||
Sets the name of an output port.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_output_data_port_type">
|
||||
<return type="void" />
|
||||
<argument index="0" name="index" type="int" />
|
||||
<argument index="1" name="type" type="int" enum="Variant.Type" />
|
||||
<description>
|
||||
Sets the type of an output port.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptLocalVar" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
Gets a local variable's value.
|
||||
</brief_description>
|
||||
<description>
|
||||
Returns a local variable's value. "Var Name" must be supplied, with an optional type.
|
||||
[b]Input Ports:[/b]
|
||||
none
|
||||
[b]Output Ports:[/b]
|
||||
- Data (variant): [code]get[/code]
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="type" type="int" setter="set_var_type" getter="get_var_type" enum="Variant.Type" default="0">
|
||||
The local variable's type.
|
||||
</member>
|
||||
<member name="var_name" type="String" setter="set_var_name" getter="get_var_name" default=""new_local"">
|
||||
The local variable's name.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptLocalVarSet" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
Changes a local variable's value.
|
||||
</brief_description>
|
||||
<description>
|
||||
Changes a local variable's value to the given input. The new value is also provided on an output Data port.
|
||||
[b]Input Ports:[/b]
|
||||
- Sequence
|
||||
- Data (variant): [code]set[/code]
|
||||
[b]Output Ports:[/b]
|
||||
- Sequence
|
||||
- Data (variant): [code]get[/code]
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="type" type="int" setter="set_var_type" getter="get_var_type" enum="Variant.Type" default="0">
|
||||
The local variable's type.
|
||||
</member>
|
||||
<member name="var_name" type="String" setter="set_var_name" getter="get_var_name" default=""new_local"">
|
||||
The local variable's name.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,51 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptMathConstant" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
Commonly used mathematical constants.
|
||||
</brief_description>
|
||||
<description>
|
||||
Provides common math constants, such as Pi, on an output Data port.
|
||||
[b]Input Ports:[/b]
|
||||
none
|
||||
[b]Output Ports:[/b]
|
||||
- Data (variant): [code]get[/code]
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="constant" type="int" setter="set_math_constant" getter="get_math_constant" enum="VisualScriptMathConstant.MathConstant" default="0">
|
||||
The math constant.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
<constant name="MATH_CONSTANT_ONE" value="0" enum="MathConstant">
|
||||
Unity: [code]1[/code].
|
||||
</constant>
|
||||
<constant name="MATH_CONSTANT_PI" value="1" enum="MathConstant">
|
||||
Pi: [code]3.141593[/code].
|
||||
</constant>
|
||||
<constant name="MATH_CONSTANT_HALF_PI" value="2" enum="MathConstant">
|
||||
Pi divided by two: [code]1.570796[/code].
|
||||
</constant>
|
||||
<constant name="MATH_CONSTANT_TAU" value="3" enum="MathConstant">
|
||||
Tau: [code]6.283185[/code].
|
||||
</constant>
|
||||
<constant name="MATH_CONSTANT_E" value="4" enum="MathConstant">
|
||||
Mathematical constant [code]e[/code], the natural log base: [code]2.718282[/code].
|
||||
</constant>
|
||||
<constant name="MATH_CONSTANT_SQRT2" value="5" enum="MathConstant">
|
||||
Square root of two: [code]1.414214[/code].
|
||||
</constant>
|
||||
<constant name="MATH_CONSTANT_INF" value="6" enum="MathConstant">
|
||||
Infinity: [code]inf[/code].
|
||||
</constant>
|
||||
<constant name="MATH_CONSTANT_NAN" value="7" enum="MathConstant">
|
||||
Not a number: [code]nan[/code].
|
||||
</constant>
|
||||
<constant name="MATH_CONSTANT_MAX" value="8" enum="MathConstant">
|
||||
Represents the size of the [enum MathConstant] enum.
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
@ -1,49 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptNode" inherits="Resource" version="3.5">
|
||||
<brief_description>
|
||||
A node which is part of a [VisualScript].
|
||||
</brief_description>
|
||||
<description>
|
||||
A node which is part of a [VisualScript]. Not to be confused with [Node], which is a part of a [SceneTree].
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="get_default_input_value" qualifiers="const">
|
||||
<return type="Variant" />
|
||||
<argument index="0" name="port_idx" type="int" />
|
||||
<description>
|
||||
Returns the default value of a given port. The default value is used when nothing is connected to the port.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_visual_script" qualifiers="const">
|
||||
<return type="VisualScript" />
|
||||
<description>
|
||||
Returns the [VisualScript] instance the node is bound to.
|
||||
</description>
|
||||
</method>
|
||||
<method name="ports_changed_notify">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Notify that the node's ports have changed. Usually used in conjunction with [VisualScriptCustomNode] .
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_default_input_value">
|
||||
<return type="void" />
|
||||
<argument index="0" name="port_idx" type="int" />
|
||||
<argument index="1" name="value" type="Variant" />
|
||||
<description>
|
||||
Change the default value of a given port.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<signals>
|
||||
<signal name="ports_changed">
|
||||
<description>
|
||||
Emitted when the available input/output ports are changed.
|
||||
</description>
|
||||
</signal>
|
||||
</signals>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptOperator" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node that performs an operation on two values.
|
||||
</brief_description>
|
||||
<description>
|
||||
[b]Input Ports:[/b]
|
||||
- Data (variant): [code]A[/code]
|
||||
- Data (variant): [code]B[/code]
|
||||
[b]Output Ports:[/b]
|
||||
- Data (variant): [code]result[/code]
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="operator" type="int" setter="set_operator" getter="get_operator" enum="Variant.Operator" default="6">
|
||||
The operation to be performed. See [enum Variant.Operator] for available options.
|
||||
</member>
|
||||
<member name="type" type="int" setter="set_typed" getter="get_typed" enum="Variant.Type" default="0">
|
||||
The type of the values for this operation. See [enum Variant.Type] for available options.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptPreload" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
Creates a new [Resource] or loads one from the filesystem.
|
||||
</brief_description>
|
||||
<description>
|
||||
Creates a new [Resource] or loads one from the filesystem.
|
||||
[b]Input Ports:[/b]
|
||||
none
|
||||
[b]Output Ports:[/b]
|
||||
- Data (object): [code]res[/code]
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="resource" type="Resource" setter="set_preload" getter="get_preload">
|
||||
The [Resource] to load.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,50 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptPropertyGet" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node returning a value of a property from an [Object].
|
||||
</brief_description>
|
||||
<description>
|
||||
[VisualScriptPropertyGet] can return a value of any property from the current object or other objects.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="base_script" type="String" setter="set_base_script" getter="get_base_script">
|
||||
The script to be used when [member set_mode] is set to [constant CALL_MODE_INSTANCE].
|
||||
</member>
|
||||
<member name="base_type" type="String" setter="set_base_type" getter="get_base_type" default=""Object"">
|
||||
The base type to be used when [member set_mode] is set to [constant CALL_MODE_INSTANCE].
|
||||
</member>
|
||||
<member name="basic_type" type="int" setter="set_basic_type" getter="get_basic_type" enum="Variant.Type">
|
||||
The type to be used when [member set_mode] is set to [constant CALL_MODE_BASIC_TYPE].
|
||||
</member>
|
||||
<member name="index" type="String" setter="set_index" getter="get_index">
|
||||
The indexed name of the property to retrieve. See [method Object.get_indexed] for details.
|
||||
</member>
|
||||
<member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path">
|
||||
The node path to use when [member set_mode] is set to [constant CALL_MODE_NODE_PATH].
|
||||
</member>
|
||||
<member name="property" type="String" setter="set_property" getter="get_property" default="""">
|
||||
The name of the property to retrieve. Changing this will clear [member index].
|
||||
</member>
|
||||
<member name="set_mode" type="int" setter="set_call_mode" getter="get_call_mode" enum="VisualScriptPropertyGet.CallMode" default="0">
|
||||
[code]set_mode[/code] determines the target object from which the property will be retrieved. See [enum CallMode] for options.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
<constant name="CALL_MODE_SELF" value="0" enum="CallMode">
|
||||
The property will be retrieved from this [Object].
|
||||
</constant>
|
||||
<constant name="CALL_MODE_NODE_PATH" value="1" enum="CallMode">
|
||||
The property will be retrieved from the given [Node] in the scene tree.
|
||||
</constant>
|
||||
<constant name="CALL_MODE_INSTANCE" value="2" enum="CallMode">
|
||||
The property will be retrieved from an instanced node with the given type and script.
|
||||
</constant>
|
||||
<constant name="CALL_MODE_BASIC_TYPE" value="3" enum="CallMode">
|
||||
The property will be retrieved from a GDScript basic type (e.g. [Vector2]).
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
@ -1,86 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptPropertySet" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node that sets a property of an [Object].
|
||||
</brief_description>
|
||||
<description>
|
||||
[VisualScriptPropertySet] can set the value of any property from the current object or other objects.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="assign_op" type="int" setter="set_assign_op" getter="get_assign_op" enum="VisualScriptPropertySet.AssignOp" default="0">
|
||||
The additional operation to perform when assigning. See [enum AssignOp] for options.
|
||||
</member>
|
||||
<member name="base_script" type="String" setter="set_base_script" getter="get_base_script">
|
||||
The script to be used when [member set_mode] is set to [constant CALL_MODE_INSTANCE].
|
||||
</member>
|
||||
<member name="base_type" type="String" setter="set_base_type" getter="get_base_type" default=""Object"">
|
||||
The base type to be used when [member set_mode] is set to [constant CALL_MODE_INSTANCE].
|
||||
</member>
|
||||
<member name="basic_type" type="int" setter="set_basic_type" getter="get_basic_type" enum="Variant.Type">
|
||||
The type to be used when [member set_mode] is set to [constant CALL_MODE_BASIC_TYPE].
|
||||
</member>
|
||||
<member name="index" type="String" setter="set_index" getter="get_index">
|
||||
The indexed name of the property to set. See [method Object.set_indexed] for details.
|
||||
</member>
|
||||
<member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path">
|
||||
The node path to use when [member set_mode] is set to [constant CALL_MODE_NODE_PATH].
|
||||
</member>
|
||||
<member name="property" type="String" setter="set_property" getter="get_property" default="""">
|
||||
The name of the property to set. Changing this will clear [member index].
|
||||
</member>
|
||||
<member name="set_mode" type="int" setter="set_call_mode" getter="get_call_mode" enum="VisualScriptPropertySet.CallMode" default="0">
|
||||
[code]set_mode[/code] determines the target object on which the property will be set. See [enum CallMode] for options.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
<constant name="CALL_MODE_SELF" value="0" enum="CallMode">
|
||||
The property will be set on this [Object].
|
||||
</constant>
|
||||
<constant name="CALL_MODE_NODE_PATH" value="1" enum="CallMode">
|
||||
The property will be set on the given [Node] in the scene tree.
|
||||
</constant>
|
||||
<constant name="CALL_MODE_INSTANCE" value="2" enum="CallMode">
|
||||
The property will be set on an instanced node with the given type and script.
|
||||
</constant>
|
||||
<constant name="CALL_MODE_BASIC_TYPE" value="3" enum="CallMode">
|
||||
The property will be set on a GDScript basic type (e.g. [Vector2]).
|
||||
</constant>
|
||||
<constant name="ASSIGN_OP_NONE" value="0" enum="AssignOp">
|
||||
The property will be assigned regularly.
|
||||
</constant>
|
||||
<constant name="ASSIGN_OP_ADD" value="1" enum="AssignOp">
|
||||
The value will be added to the property. Equivalent of doing [code]+=[/code].
|
||||
</constant>
|
||||
<constant name="ASSIGN_OP_SUB" value="2" enum="AssignOp">
|
||||
The value will be subtracted from the property. Equivalent of doing [code]-=[/code].
|
||||
</constant>
|
||||
<constant name="ASSIGN_OP_MUL" value="3" enum="AssignOp">
|
||||
The property will be multiplied by the value. Equivalent of doing [code]*=[/code].
|
||||
</constant>
|
||||
<constant name="ASSIGN_OP_DIV" value="4" enum="AssignOp">
|
||||
The property will be divided by the value. Equivalent of doing [code]/=[/code].
|
||||
</constant>
|
||||
<constant name="ASSIGN_OP_MOD" value="5" enum="AssignOp">
|
||||
A modulo operation will be performed on the property and the value. Equivalent of doing [code]%=[/code].
|
||||
</constant>
|
||||
<constant name="ASSIGN_OP_SHIFT_LEFT" value="6" enum="AssignOp">
|
||||
The property will be binarly shifted to the left by the given value. Equivalent of doing [code]<<[/code].
|
||||
</constant>
|
||||
<constant name="ASSIGN_OP_SHIFT_RIGHT" value="7" enum="AssignOp">
|
||||
The property will be binarly shifted to the right by the given value. Equivalent of doing [code]>>[/code].
|
||||
</constant>
|
||||
<constant name="ASSIGN_OP_BIT_AND" value="8" enum="AssignOp">
|
||||
A binary [code]AND[/code] operation will be performed on the property. Equivalent of doing [code]&=[/code].
|
||||
</constant>
|
||||
<constant name="ASSIGN_OP_BIT_OR" value="9" enum="AssignOp">
|
||||
A binary [code]OR[/code] operation will be performed on the property. Equivalent of doing [code]|=[/code].
|
||||
</constant>
|
||||
<constant name="ASSIGN_OP_BIT_XOR" value="10" enum="AssignOp">
|
||||
A binary [code]XOR[/code] operation will be performed on the property. Equivalent of doing [code]^=[/code].
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptResourcePath" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="path" type="String" setter="set_resource_path" getter="get_resource_path" default="""">
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptReturn" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
Exits a function and returns an optional value.
|
||||
</brief_description>
|
||||
<description>
|
||||
Ends the execution of a function and returns control to the calling function. Optionally, it can return a [Variant] value.
|
||||
[b]Input Ports:[/b]
|
||||
- Sequence
|
||||
- Data (variant): [code]result[/code] (optional)
|
||||
[b]Output Ports:[/b]
|
||||
none
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="return_enabled" type="bool" setter="set_enable_return_value" getter="is_return_value_enabled" default="false">
|
||||
If [code]true[/code], the [code]return[/code] input port is available.
|
||||
</member>
|
||||
<member name="return_type" type="int" setter="set_return_type" getter="get_return_type" enum="Variant.Type" default="0">
|
||||
The return value's data type.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptSceneNode" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
Node reference.
|
||||
</brief_description>
|
||||
<description>
|
||||
A direct reference to a node.
|
||||
[b]Input Ports:[/b]
|
||||
none
|
||||
[b]Output Ports:[/b]
|
||||
- Data: [code]node[/code] (obj)
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="node_path" type="NodePath" setter="set_node_path" getter="get_node_path" default="NodePath(".")">
|
||||
The node's path in the scene tree.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptSceneTree" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node for accessing [SceneTree] methods.
|
||||
</brief_description>
|
||||
<description>
|
||||
A Visual Script node for accessing [SceneTree] methods.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptSelect" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
Chooses between two input values.
|
||||
</brief_description>
|
||||
<description>
|
||||
Chooses between two input values based on a Boolean condition.
|
||||
[b]Input Ports:[/b]
|
||||
- Data (boolean): [code]cond[/code]
|
||||
- Data (variant): [code]a[/code]
|
||||
- Data (variant): [code]b[/code]
|
||||
[b]Output Ports:[/b]
|
||||
- Data (variant): [code]out[/code]
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="type" type="int" setter="set_typed" getter="get_typed" enum="Variant.Type" default="0">
|
||||
The input variables' type.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,19 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptSelf" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
Outputs a reference to the current instance.
|
||||
</brief_description>
|
||||
<description>
|
||||
Provides a reference to the node running the visual script.
|
||||
[b]Input Ports:[/b]
|
||||
none
|
||||
[b]Output Ports:[/b]
|
||||
- Data (object): [code]instance[/code]
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptSequence" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
Executes a series of Sequence ports.
|
||||
</brief_description>
|
||||
<description>
|
||||
Steps through a series of one or more output Sequence ports. The [code]current[/code] data port outputs the currently executing item.
|
||||
[b]Input Ports:[/b]
|
||||
- Sequence: [code]in order[/code]
|
||||
[b]Output Ports:[/b]
|
||||
- Sequence: [code]1[/code]
|
||||
- Sequence: [code]2 - n[/code] (optional)
|
||||
- Data (int): [code]current[/code]
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="steps" type="int" setter="set_steps" getter="get_steps" default="1">
|
||||
The number of steps in the sequence.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptSubCall" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
Calls a method called [code]_subcall[/code] in this object.
|
||||
</brief_description>
|
||||
<description>
|
||||
[VisualScriptSubCall] will call method named [code]_subcall[/code] in the current script. It will fail if the method doesn't exist or the provided arguments are wrong.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="_subcall" qualifiers="virtual">
|
||||
<return type="Variant" />
|
||||
<argument index="0" name="arguments" type="Variant" />
|
||||
<description>
|
||||
Called by this node.
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptSwitch" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
Branches program flow based on a given input's value.
|
||||
</brief_description>
|
||||
<description>
|
||||
Branches the flow based on an input's value. Use [b]Case Count[/b] in the Inspector to set the number of branches and each comparison's optional type.
|
||||
[b]Input Ports:[/b]
|
||||
- Sequence: [code]'input' is[/code]
|
||||
- Data (variant): [code]=[/code]
|
||||
- Data (variant): [code]=[/code] (optional)
|
||||
- Data (variant): [code]input[/code]
|
||||
[b]Output Ports:[/b]
|
||||
- Sequence
|
||||
- Sequence (optional)
|
||||
- Sequence: [code]done[/code]
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptTypeCast" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node that casts the given value to another type.
|
||||
</brief_description>
|
||||
<description>
|
||||
[VisualScriptTypeCast] will perform a type conversion to an [Object]-derived type.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="base_script" type="String" setter="set_base_script" getter="get_base_script" default="""">
|
||||
The target script class to be converted to. If none, only the [member base_type] will be used.
|
||||
</member>
|
||||
<member name="base_type" type="String" setter="set_base_type" getter="get_base_type" default=""Object"">
|
||||
The target type to be converted to.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptVariableGet" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
Gets a variable's value.
|
||||
</brief_description>
|
||||
<description>
|
||||
Returns a variable's value. "Var Name" must be supplied, with an optional type.
|
||||
[b]Input Ports:[/b]
|
||||
none
|
||||
[b]Output Ports:[/b]
|
||||
- Data (variant): [code]value[/code]
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="var_name" type="String" setter="set_variable" getter="get_variable" default="""">
|
||||
The variable's name.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptVariableSet" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
Changes a variable's value.
|
||||
</brief_description>
|
||||
<description>
|
||||
Changes a variable's value to the given input.
|
||||
[b]Input Ports:[/b]
|
||||
- Sequence
|
||||
- Data (variant): [code]set[/code]
|
||||
[b]Output Ports:[/b]
|
||||
- Sequence
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="var_name" type="String" setter="set_variable" getter="get_variable" default="""">
|
||||
The variable's name.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptWhile" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
Conditional loop.
|
||||
</brief_description>
|
||||
<description>
|
||||
Loops while a condition is [code]true[/code]. Execution continues out the [code]exit[/code] Sequence port when the loop terminates.
|
||||
[b]Input Ports:[/b]
|
||||
- Sequence: [code]while(cond)[/code]
|
||||
- Data (bool): [code]cond[/code]
|
||||
[b]Output Ports:[/b]
|
||||
- Sequence: [code]repeat[/code]
|
||||
- Sequence: [code]exit[/code]
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptYield" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node used to pause a function execution.
|
||||
</brief_description>
|
||||
<description>
|
||||
[VisualScriptYield] will pause the function call and return [VisualScriptFunctionState], which can be used to resume the function.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="mode" type="int" setter="set_yield_mode" getter="get_yield_mode" enum="VisualScriptYield.YieldMode" default="1">
|
||||
The mode to use for yielding. See [enum YieldMode] for available options.
|
||||
</member>
|
||||
<member name="wait_time" type="float" setter="set_wait_time" getter="get_wait_time">
|
||||
The time to wait when [member mode] is set to [constant YIELD_WAIT].
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
<constant name="YIELD_FRAME" value="1" enum="YieldMode">
|
||||
Yields during an idle frame.
|
||||
</constant>
|
||||
<constant name="YIELD_PHYSICS_FRAME" value="2" enum="YieldMode">
|
||||
Yields during a physics frame.
|
||||
</constant>
|
||||
<constant name="YIELD_WAIT" value="3" enum="YieldMode">
|
||||
Yields a function and waits the given time.
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
@ -1,38 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualScriptYieldSignal" inherits="VisualScriptNode" version="3.5">
|
||||
<brief_description>
|
||||
A Visual Script node yielding for a signal.
|
||||
</brief_description>
|
||||
<description>
|
||||
[VisualScriptYieldSignal] will pause the function execution until the provided signal is emitted.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="base_type" type="String" setter="set_base_type" getter="get_base_type" default=""Object"">
|
||||
The base type to be used when [member call_mode] is set to [constant CALL_MODE_INSTANCE].
|
||||
</member>
|
||||
<member name="call_mode" type="int" setter="set_call_mode" getter="get_call_mode" enum="VisualScriptYieldSignal.CallMode" default="0">
|
||||
[code]call_mode[/code] determines the target object to wait for the signal emission. See [enum CallMode] for options.
|
||||
</member>
|
||||
<member name="node_path" type="NodePath" setter="set_base_path" getter="get_base_path">
|
||||
The node path to use when [member call_mode] is set to [constant CALL_MODE_NODE_PATH].
|
||||
</member>
|
||||
<member name="signal" type="String" setter="set_signal" getter="get_signal" default="""">
|
||||
The signal name to be waited for.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
<constant name="CALL_MODE_SELF" value="0" enum="CallMode">
|
||||
A signal from this [Object] will be used.
|
||||
</constant>
|
||||
<constant name="CALL_MODE_NODE_PATH" value="1" enum="CallMode">
|
||||
A signal from the given [Node] in the scene tree will be used.
|
||||
</constant>
|
||||
<constant name="CALL_MODE_INSTANCE" value="2" enum="CallMode">
|
||||
A signal from an instanced node with the given type will be used.
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
@ -1,6 +0,0 @@
|
||||
<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
||||
<g transform="translate(0 -1036.4)">
|
||||
<ellipse cx="3" cy="1039.4" r="2" fill="#6e6e6e"/>
|
||||
<path transform="translate(0 1036.4)" d="m7 1l-0.56445 2.2578a5 5 0 0 0 -0.68945 0.2793l-1.9883-1.1934-1.4141 1.4141 1.1953 1.9941a5 5 0 0 0 -0.28516 0.68555l-2.2539 0.5625v2h5.2715a2 2 0 0 1 -0.27148 -1 2 2 0 0 1 2 -2 2 2 0 0 1 2 2 2 2 0 0 1 -0.26953 1h5.2695v-2l-2.2578-0.56445a5 5 0 0 0 -0.2793 -0.6875l1.1934-1.9902-1.4141-1.4141-1.9941 1.1953a5 5 0 0 0 -0.68555 -0.28516l-0.5625-2.2539h-2zm-4 9v6h2a3 3 0 0 0 3 -3v-3h-2v3a1 1 0 0 1 -1 1v-4h-2zm8 0a2 2 0 0 0 -1.7324 1 2 2 0 0 0 0 2 2 2 0 0 0 1.7324 1h-2v2h2a2 2 0 0 0 1.7324 -1 2 2 0 0 0 0 -2 2 2 0 0 0 -1.7324 -1h2v-2h-2z" fill="#e0e0e0"/>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 794 B |
@ -1,140 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* register_types.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "register_types.h"
|
||||
|
||||
#include "core/engine.h"
|
||||
#include "core/io/resource_loader.h"
|
||||
#include "visual_script.h"
|
||||
#include "visual_script_builtin_funcs.h"
|
||||
#include "visual_script_editor.h"
|
||||
#include "visual_script_expression.h"
|
||||
#include "visual_script_flow_control.h"
|
||||
#include "visual_script_func_nodes.h"
|
||||
#include "visual_script_nodes.h"
|
||||
#include "visual_script_yield_nodes.h"
|
||||
|
||||
VisualScriptLanguage *visual_script_language = nullptr;
|
||||
#ifdef TOOLS_ENABLED
|
||||
static _VisualScriptEditor *vs_editor_singleton = nullptr;
|
||||
#endif
|
||||
|
||||
void register_visual_script_types() {
|
||||
visual_script_language = memnew(VisualScriptLanguage);
|
||||
//script_language_gd->init();
|
||||
ScriptServer::register_language(visual_script_language);
|
||||
|
||||
ClassDB::register_class<VisualScript>();
|
||||
ClassDB::register_virtual_class<VisualScriptNode>();
|
||||
ClassDB::register_class<VisualScriptFunctionState>();
|
||||
ClassDB::register_class<VisualScriptFunction>();
|
||||
ClassDB::register_virtual_class<VisualScriptLists>();
|
||||
ClassDB::register_class<VisualScriptComposeArray>();
|
||||
ClassDB::register_class<VisualScriptOperator>();
|
||||
ClassDB::register_class<VisualScriptVariableSet>();
|
||||
ClassDB::register_class<VisualScriptVariableGet>();
|
||||
ClassDB::register_class<VisualScriptConstant>();
|
||||
ClassDB::register_class<VisualScriptIndexGet>();
|
||||
ClassDB::register_class<VisualScriptIndexSet>();
|
||||
ClassDB::register_class<VisualScriptGlobalConstant>();
|
||||
ClassDB::register_class<VisualScriptClassConstant>();
|
||||
ClassDB::register_class<VisualScriptMathConstant>();
|
||||
ClassDB::register_class<VisualScriptBasicTypeConstant>();
|
||||
ClassDB::register_class<VisualScriptEngineSingleton>();
|
||||
ClassDB::register_class<VisualScriptSceneNode>();
|
||||
ClassDB::register_class<VisualScriptSceneTree>();
|
||||
ClassDB::register_class<VisualScriptResourcePath>();
|
||||
ClassDB::register_class<VisualScriptSelf>();
|
||||
ClassDB::register_class<VisualScriptCustomNode>();
|
||||
ClassDB::register_class<VisualScriptSubCall>();
|
||||
ClassDB::register_class<VisualScriptComment>();
|
||||
ClassDB::register_class<VisualScriptConstructor>();
|
||||
ClassDB::register_class<VisualScriptLocalVar>();
|
||||
ClassDB::register_class<VisualScriptLocalVarSet>();
|
||||
ClassDB::register_class<VisualScriptInputAction>();
|
||||
ClassDB::register_class<VisualScriptDeconstruct>();
|
||||
ClassDB::register_class<VisualScriptPreload>();
|
||||
ClassDB::register_class<VisualScriptTypeCast>();
|
||||
|
||||
ClassDB::register_class<VisualScriptFunctionCall>();
|
||||
ClassDB::register_class<VisualScriptPropertySet>();
|
||||
ClassDB::register_class<VisualScriptPropertyGet>();
|
||||
//ClassDB::register_type<VisualScriptScriptCall>();
|
||||
ClassDB::register_class<VisualScriptEmitSignal>();
|
||||
|
||||
ClassDB::register_class<VisualScriptReturn>();
|
||||
ClassDB::register_class<VisualScriptCondition>();
|
||||
ClassDB::register_class<VisualScriptWhile>();
|
||||
ClassDB::register_class<VisualScriptIterator>();
|
||||
ClassDB::register_class<VisualScriptSequence>();
|
||||
//ClassDB::register_class<VisualScriptInputFilter>();
|
||||
ClassDB::register_class<VisualScriptSwitch>();
|
||||
ClassDB::register_class<VisualScriptSelect>();
|
||||
|
||||
ClassDB::register_class<VisualScriptYield>();
|
||||
ClassDB::register_class<VisualScriptYieldSignal>();
|
||||
|
||||
ClassDB::register_class<VisualScriptBuiltinFunc>();
|
||||
|
||||
ClassDB::register_class<VisualScriptExpression>();
|
||||
|
||||
register_visual_script_nodes();
|
||||
register_visual_script_func_nodes();
|
||||
register_visual_script_builtin_func_node();
|
||||
register_visual_script_flow_control_nodes();
|
||||
register_visual_script_yield_nodes();
|
||||
register_visual_script_expression_node();
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
ClassDB::set_current_api(ClassDB::API_EDITOR);
|
||||
ClassDB::register_class<_VisualScriptEditor>();
|
||||
ClassDB::set_current_api(ClassDB::API_CORE);
|
||||
vs_editor_singleton = memnew(_VisualScriptEditor);
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("VisualScriptEditor", _VisualScriptEditor::get_singleton()));
|
||||
|
||||
VisualScriptEditor::register_editor();
|
||||
#endif
|
||||
}
|
||||
|
||||
void unregister_visual_script_types() {
|
||||
unregister_visual_script_nodes();
|
||||
|
||||
ScriptServer::unregister_language(visual_script_language);
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
VisualScriptEditor::free_clipboard();
|
||||
if (vs_editor_singleton) {
|
||||
memdelete(vs_editor_singleton);
|
||||
}
|
||||
#endif
|
||||
if (visual_script_language) {
|
||||
memdelete(visual_script_language);
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* register_types.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef VISUAL_SCRIPT_REGISTER_TYPES_H
|
||||
#define VISUAL_SCRIPT_REGISTER_TYPES_H
|
||||
|
||||
void register_visual_script_types();
|
||||
void unregister_visual_script_types();
|
||||
|
||||
#endif // VISUAL_SCRIPT_REGISTER_TYPES_H
|
File diff suppressed because it is too large
Load Diff
@ -1,619 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* visual_script.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef VISUAL_SCRIPT_H
|
||||
#define VISUAL_SCRIPT_H
|
||||
|
||||
#include "core/os/thread.h"
|
||||
#include "core/script_language.h"
|
||||
|
||||
class VisualScriptInstance;
|
||||
class VisualScriptNodeInstance;
|
||||
class VisualScript;
|
||||
|
||||
class VisualScriptNode : public Resource {
|
||||
GDCLASS(VisualScriptNode, Resource);
|
||||
|
||||
friend class VisualScript;
|
||||
|
||||
Set<VisualScript *> scripts_used;
|
||||
|
||||
Array default_input_values;
|
||||
bool breakpoint;
|
||||
|
||||
void _set_default_input_values(Array p_values);
|
||||
Array _get_default_input_values() const;
|
||||
|
||||
void validate_input_default_values();
|
||||
|
||||
protected:
|
||||
void ports_changed_notify();
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
Ref<VisualScript> get_visual_script() const;
|
||||
|
||||
virtual int get_output_sequence_port_count() const = 0;
|
||||
virtual bool has_input_sequence_port() const = 0;
|
||||
|
||||
virtual String get_output_sequence_port_text(int p_port) const = 0;
|
||||
|
||||
virtual bool has_mixed_input_and_sequence_ports() const { return false; }
|
||||
|
||||
virtual int get_input_value_port_count() const = 0;
|
||||
virtual int get_output_value_port_count() const = 0;
|
||||
|
||||
virtual PropertyInfo get_input_value_port_info(int p_idx) const = 0;
|
||||
virtual PropertyInfo get_output_value_port_info(int p_idx) const = 0;
|
||||
|
||||
void set_default_input_value(int p_port, const Variant &p_value);
|
||||
Variant get_default_input_value(int p_port) const;
|
||||
|
||||
virtual String get_caption() const = 0;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const = 0;
|
||||
|
||||
//used by editor, this is not really saved
|
||||
void set_breakpoint(bool p_breakpoint);
|
||||
bool is_breakpoint() const;
|
||||
|
||||
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance) = 0;
|
||||
|
||||
struct TypeGuess {
|
||||
Variant::Type type;
|
||||
StringName gdclass;
|
||||
Ref<Script> script;
|
||||
|
||||
TypeGuess() {
|
||||
type = Variant::NIL;
|
||||
}
|
||||
};
|
||||
|
||||
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const;
|
||||
|
||||
VisualScriptNode();
|
||||
};
|
||||
|
||||
class VisualScriptNodeInstance {
|
||||
friend class VisualScriptInstance;
|
||||
friend class VisualScriptLanguage; //for debugger
|
||||
|
||||
enum { //input argument addressing
|
||||
INPUT_SHIFT = 1 << 24,
|
||||
INPUT_MASK = INPUT_SHIFT - 1,
|
||||
INPUT_DEFAULT_VALUE_BIT = INPUT_SHIFT, // from unassigned input port, using default value (edited by user)
|
||||
};
|
||||
|
||||
int id;
|
||||
int sequence_index;
|
||||
VisualScriptNodeInstance **sequence_outputs;
|
||||
int sequence_output_count;
|
||||
Vector<VisualScriptNodeInstance *> dependencies;
|
||||
int *input_ports;
|
||||
int input_port_count;
|
||||
int *output_ports;
|
||||
int output_port_count;
|
||||
int working_mem_idx;
|
||||
int pass_idx;
|
||||
|
||||
VisualScriptNode *base;
|
||||
|
||||
public:
|
||||
enum StartMode {
|
||||
START_MODE_BEGIN_SEQUENCE,
|
||||
START_MODE_CONTINUE_SEQUENCE,
|
||||
START_MODE_RESUME_YIELD
|
||||
};
|
||||
|
||||
enum {
|
||||
STEP_SHIFT = 1 << 24,
|
||||
STEP_MASK = STEP_SHIFT - 1,
|
||||
STEP_FLAG_PUSH_STACK_BIT = STEP_SHIFT, //push bit to stack
|
||||
STEP_FLAG_GO_BACK_BIT = STEP_SHIFT << 1, //go back to previous node
|
||||
STEP_NO_ADVANCE_BIT = STEP_SHIFT << 2, //do not advance past this node
|
||||
STEP_EXIT_FUNCTION_BIT = STEP_SHIFT << 3, //return from function
|
||||
STEP_YIELD_BIT = STEP_SHIFT << 4, //yield (will find VisualScriptFunctionState state in first working memory)
|
||||
|
||||
FLOW_STACK_PUSHED_BIT = 1 << 30, //in flow stack, means bit was pushed (must go back here if end of sequence)
|
||||
FLOW_STACK_MASK = FLOW_STACK_PUSHED_BIT - 1
|
||||
|
||||
};
|
||||
|
||||
_FORCE_INLINE_ int get_input_port_count() const { return input_port_count; }
|
||||
_FORCE_INLINE_ int get_output_port_count() const { return output_port_count; }
|
||||
_FORCE_INLINE_ int get_sequence_output_count() const { return sequence_output_count; }
|
||||
|
||||
_FORCE_INLINE_ int get_id() const { return id; }
|
||||
|
||||
virtual int get_working_memory_size() const { return 0; }
|
||||
|
||||
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) = 0; //do a step, return which sequence port to go out
|
||||
|
||||
Ref<VisualScriptNode> get_base_node() { return Ref<VisualScriptNode>(base); }
|
||||
|
||||
VisualScriptNodeInstance();
|
||||
virtual ~VisualScriptNodeInstance();
|
||||
};
|
||||
|
||||
class VisualScript : public Script {
|
||||
GDCLASS(VisualScript, Script);
|
||||
|
||||
RES_BASE_EXTENSION("vs");
|
||||
|
||||
public:
|
||||
struct SequenceConnection {
|
||||
union {
|
||||
struct {
|
||||
uint64_t from_node : 24;
|
||||
uint64_t from_output : 16;
|
||||
uint64_t to_node : 24;
|
||||
};
|
||||
uint64_t id;
|
||||
};
|
||||
|
||||
bool operator<(const SequenceConnection &p_connection) const {
|
||||
return id < p_connection.id;
|
||||
}
|
||||
};
|
||||
|
||||
struct DataConnection {
|
||||
union {
|
||||
struct {
|
||||
uint64_t from_node : 24;
|
||||
uint64_t from_port : 8;
|
||||
uint64_t to_node : 24;
|
||||
uint64_t to_port : 8;
|
||||
};
|
||||
uint64_t id;
|
||||
};
|
||||
|
||||
bool operator<(const DataConnection &p_connection) const {
|
||||
return id < p_connection.id;
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
friend class VisualScriptInstance;
|
||||
|
||||
StringName base_type;
|
||||
struct Argument {
|
||||
String name;
|
||||
Variant::Type type;
|
||||
};
|
||||
|
||||
struct Function {
|
||||
struct NodeData {
|
||||
Point2 pos;
|
||||
Ref<VisualScriptNode> node;
|
||||
};
|
||||
|
||||
Map<int, NodeData> nodes;
|
||||
|
||||
Set<SequenceConnection> sequence_connections;
|
||||
|
||||
Set<DataConnection> data_connections;
|
||||
|
||||
int function_id;
|
||||
|
||||
Vector2 scroll;
|
||||
|
||||
Function() { function_id = -1; }
|
||||
};
|
||||
|
||||
struct Variable {
|
||||
PropertyInfo info;
|
||||
Variant default_value;
|
||||
bool _export;
|
||||
// add getter & setter options here
|
||||
};
|
||||
|
||||
Map<StringName, Function> functions;
|
||||
Map<StringName, Variable> variables;
|
||||
Map<StringName, Vector<Argument>> custom_signals;
|
||||
|
||||
Map<Object *, VisualScriptInstance *> instances;
|
||||
|
||||
bool is_tool_script;
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
Set<PlaceHolderScriptInstance *> placeholders;
|
||||
//void _update_placeholder(PlaceHolderScriptInstance *p_placeholder);
|
||||
virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder);
|
||||
void _update_placeholders();
|
||||
#endif
|
||||
|
||||
void _set_variable_info(const StringName &p_name, const Dictionary &p_info);
|
||||
Dictionary _get_variable_info(const StringName &p_name) const;
|
||||
|
||||
void _set_data(const Dictionary &p_data);
|
||||
Dictionary _get_data() const;
|
||||
|
||||
protected:
|
||||
void _node_ports_changed(int p_id);
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
bool inherits_script(const Ref<Script> &p_script) const;
|
||||
|
||||
// TODO: Remove it in future when breaking changes are acceptable
|
||||
StringName get_default_func() const;
|
||||
void add_function(const StringName &p_name);
|
||||
bool has_function(const StringName &p_name) const;
|
||||
void remove_function(const StringName &p_name);
|
||||
void rename_function(const StringName &p_name, const StringName &p_new_name);
|
||||
void set_function_scroll(const StringName &p_name, const Vector2 &p_scroll);
|
||||
Vector2 get_function_scroll(const StringName &p_name) const;
|
||||
void get_function_list(List<StringName> *r_functions) const;
|
||||
int get_function_node_id(const StringName &p_name) const;
|
||||
void set_tool_enabled(bool p_enabled);
|
||||
|
||||
void add_node(const StringName &p_func, int p_id, const Ref<VisualScriptNode> &p_node, const Point2 &p_pos = Point2());
|
||||
void remove_node(const StringName &p_func, int p_id);
|
||||
bool has_node(const StringName &p_func, int p_id) const;
|
||||
Ref<VisualScriptNode> get_node(const StringName &p_func, int p_id) const;
|
||||
void set_node_position(const StringName &p_func, int p_id, const Point2 &p_pos);
|
||||
Point2 get_node_position(const StringName &p_func, int p_id) const;
|
||||
void get_node_list(const StringName &p_func, List<int> *r_nodes) const;
|
||||
|
||||
void sequence_connect(const StringName &p_func, int p_from_node, int p_from_output, int p_to_node);
|
||||
void sequence_disconnect(const StringName &p_func, int p_from_node, int p_from_output, int p_to_node);
|
||||
bool has_sequence_connection(const StringName &p_func, int p_from_node, int p_from_output, int p_to_node) const;
|
||||
void get_sequence_connection_list(const StringName &p_func, List<SequenceConnection> *r_connection) const;
|
||||
|
||||
void data_connect(const StringName &p_func, int p_from_node, int p_from_port, int p_to_node, int p_to_port);
|
||||
void data_disconnect(const StringName &p_func, int p_from_node, int p_from_port, int p_to_node, int p_to_port);
|
||||
bool has_data_connection(const StringName &p_func, int p_from_node, int p_from_port, int p_to_node, int p_to_port) const;
|
||||
void get_data_connection_list(const StringName &p_func, List<DataConnection> *r_connection) const;
|
||||
bool is_input_value_port_connected(const StringName &p_func, int p_node, int p_port) const;
|
||||
bool get_input_value_port_connection_source(const StringName &p_func, int p_node, int p_port, int *r_node, int *r_port) const;
|
||||
|
||||
void add_variable(const StringName &p_name, const Variant &p_default_value = Variant(), bool p_export = false);
|
||||
bool has_variable(const StringName &p_name) const;
|
||||
void remove_variable(const StringName &p_name);
|
||||
void set_variable_default_value(const StringName &p_name, const Variant &p_value);
|
||||
Variant get_variable_default_value(const StringName &p_name) const;
|
||||
void set_variable_info(const StringName &p_name, const PropertyInfo &p_info);
|
||||
PropertyInfo get_variable_info(const StringName &p_name) const;
|
||||
void set_variable_export(const StringName &p_name, bool p_export);
|
||||
bool get_variable_export(const StringName &p_name) const;
|
||||
void get_variable_list(List<StringName> *r_variables) const;
|
||||
void rename_variable(const StringName &p_name, const StringName &p_new_name);
|
||||
|
||||
void add_custom_signal(const StringName &p_name);
|
||||
bool has_custom_signal(const StringName &p_name) const;
|
||||
void custom_signal_add_argument(const StringName &p_func, Variant::Type p_type, const String &p_name, int p_index = -1);
|
||||
void custom_signal_set_argument_type(const StringName &p_func, int p_argidx, Variant::Type p_type);
|
||||
Variant::Type custom_signal_get_argument_type(const StringName &p_func, int p_argidx) const;
|
||||
void custom_signal_set_argument_name(const StringName &p_func, int p_argidx, const String &p_name);
|
||||
String custom_signal_get_argument_name(const StringName &p_func, int p_argidx) const;
|
||||
void custom_signal_remove_argument(const StringName &p_func, int p_argidx);
|
||||
int custom_signal_get_argument_count(const StringName &p_func) const;
|
||||
void custom_signal_swap_argument(const StringName &p_func, int p_argidx, int p_with_argidx);
|
||||
void remove_custom_signal(const StringName &p_name);
|
||||
void rename_custom_signal(const StringName &p_name, const StringName &p_new_name);
|
||||
Set<int> get_output_sequence_ports_connected(const String &edited_func, int from_node);
|
||||
|
||||
void get_custom_signal_list(List<StringName> *r_custom_signals) const;
|
||||
|
||||
int get_available_id() const;
|
||||
|
||||
void set_instance_base_type(const StringName &p_type);
|
||||
|
||||
virtual bool can_instance() const;
|
||||
|
||||
virtual Ref<Script> get_base_script() const;
|
||||
virtual StringName get_instance_base_type() const;
|
||||
virtual ScriptInstance *instance_create(Object *p_this);
|
||||
virtual bool instance_has(const Object *p_this) const;
|
||||
|
||||
virtual bool has_source_code() const;
|
||||
virtual String get_source_code() const;
|
||||
virtual void set_source_code(const String &p_code);
|
||||
virtual Error reload(bool p_keep_state = false);
|
||||
|
||||
virtual bool is_tool() const;
|
||||
virtual bool is_valid() const;
|
||||
|
||||
virtual ScriptLanguage *get_language() const;
|
||||
|
||||
virtual bool has_script_signal(const StringName &p_signal) const;
|
||||
virtual void get_script_signal_list(List<MethodInfo> *r_signals) const;
|
||||
|
||||
virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const;
|
||||
virtual void get_script_method_list(List<MethodInfo> *p_list) const;
|
||||
|
||||
virtual bool has_method(const StringName &p_method) const;
|
||||
virtual MethodInfo get_method_info(const StringName &p_method) const;
|
||||
|
||||
virtual void get_script_property_list(List<PropertyInfo> *p_list) const;
|
||||
|
||||
virtual int get_member_line(const StringName &p_member) const;
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
virtual bool are_subnodes_edited() const;
|
||||
#endif
|
||||
|
||||
VisualScript();
|
||||
~VisualScript();
|
||||
};
|
||||
|
||||
class VisualScriptInstance : public ScriptInstance {
|
||||
Object *owner;
|
||||
Ref<VisualScript> script;
|
||||
|
||||
Map<StringName, Variant> variables; //using variable path, not script
|
||||
Map<int, VisualScriptNodeInstance *> instances;
|
||||
|
||||
struct Function {
|
||||
int node;
|
||||
int max_stack;
|
||||
int trash_pos;
|
||||
int flow_stack_size;
|
||||
int pass_stack_size;
|
||||
int node_count;
|
||||
int argument_count;
|
||||
};
|
||||
|
||||
Map<StringName, Function> functions;
|
||||
|
||||
Vector<Variant> default_values;
|
||||
int max_input_args, max_output_args;
|
||||
|
||||
StringName source;
|
||||
|
||||
void _dependency_step(VisualScriptNodeInstance *node, int p_pass, int *pass_stack, const Variant **input_args, Variant **output_args, Variant *variant_stack, Variant::CallError &r_error, String &error_str, VisualScriptNodeInstance **r_error_node);
|
||||
Variant _call_internal(const StringName &p_method, void *p_stack, int p_stack_size, VisualScriptNodeInstance *p_node, int p_flow_stack_pos, int p_pass, bool p_resuming_yield, Variant::CallError &r_error);
|
||||
|
||||
//Map<StringName,Function> functions;
|
||||
friend class VisualScriptFunctionState; //for yield
|
||||
friend class VisualScriptLanguage; //for debugger
|
||||
public:
|
||||
virtual bool set(const StringName &p_name, const Variant &p_value);
|
||||
virtual bool get(const StringName &p_name, Variant &r_ret) const;
|
||||
virtual void get_property_list(List<PropertyInfo> *p_properties) const;
|
||||
virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const;
|
||||
|
||||
virtual void get_method_list(List<MethodInfo> *p_list) const;
|
||||
virtual bool has_method(const StringName &p_method) const;
|
||||
virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error);
|
||||
virtual void notification(int p_notification);
|
||||
String to_string(bool *r_valid);
|
||||
|
||||
bool set_variable(const StringName &p_variable, const Variant &p_value) {
|
||||
Map<StringName, Variant>::Element *E = variables.find(p_variable);
|
||||
if (!E) {
|
||||
return false;
|
||||
}
|
||||
|
||||
E->get() = p_value;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool get_variable(const StringName &p_variable, Variant *r_variable) const {
|
||||
const Map<StringName, Variant>::Element *E = variables.find(p_variable);
|
||||
if (!E) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*r_variable = E->get();
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual Ref<Script> get_script() const;
|
||||
|
||||
_FORCE_INLINE_ VisualScript *get_script_ptr() { return script.ptr(); }
|
||||
_FORCE_INLINE_ Object *get_owner_ptr() { return owner; }
|
||||
|
||||
void create(const Ref<VisualScript> &p_script, Object *p_owner);
|
||||
|
||||
virtual ScriptLanguage *get_language();
|
||||
|
||||
virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
|
||||
virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
|
||||
|
||||
VisualScriptInstance();
|
||||
~VisualScriptInstance();
|
||||
};
|
||||
|
||||
class VisualScriptFunctionState : public Reference {
|
||||
GDCLASS(VisualScriptFunctionState, Reference);
|
||||
friend class VisualScriptInstance;
|
||||
|
||||
ObjectID instance_id;
|
||||
ObjectID script_id;
|
||||
VisualScriptInstance *instance;
|
||||
StringName function;
|
||||
Vector<uint8_t> stack;
|
||||
int working_mem_index;
|
||||
int variant_stack_size;
|
||||
VisualScriptNodeInstance *node;
|
||||
int flow_stack_pos;
|
||||
int pass;
|
||||
|
||||
Variant _signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void connect_to_signal(Object *p_obj, const String &p_signal, Array p_binds);
|
||||
bool is_valid() const;
|
||||
Variant resume(Array p_args);
|
||||
VisualScriptFunctionState();
|
||||
~VisualScriptFunctionState();
|
||||
};
|
||||
|
||||
typedef Ref<VisualScriptNode> (*VisualScriptNodeRegisterFunc)(const String &p_type);
|
||||
|
||||
class VisualScriptLanguage : public ScriptLanguage {
|
||||
Map<String, VisualScriptNodeRegisterFunc> register_funcs;
|
||||
|
||||
struct CallLevel {
|
||||
Variant *stack;
|
||||
Variant **work_mem;
|
||||
const StringName *function;
|
||||
VisualScriptInstance *instance;
|
||||
int *current_id;
|
||||
};
|
||||
|
||||
int _debug_parse_err_node;
|
||||
String _debug_parse_err_file;
|
||||
String _debug_error;
|
||||
int _debug_call_stack_pos;
|
||||
int _debug_max_call_stack;
|
||||
CallLevel *_call_stack;
|
||||
|
||||
public:
|
||||
StringName notification;
|
||||
StringName _get_output_port_unsequenced;
|
||||
StringName _step;
|
||||
StringName _subcall;
|
||||
|
||||
static VisualScriptLanguage *singleton;
|
||||
|
||||
Mutex lock;
|
||||
|
||||
bool debug_break(const String &p_error, bool p_allow_continue = true);
|
||||
bool debug_break_parse(const String &p_file, int p_node, const String &p_error);
|
||||
|
||||
_FORCE_INLINE_ void enter_function(VisualScriptInstance *p_instance, const StringName *p_function, Variant *p_stack, Variant **p_work_mem, int *current_id) {
|
||||
if (Thread::get_main_id() != Thread::get_caller_id()) {
|
||||
return; //no support for other threads than main for now
|
||||
}
|
||||
|
||||
if (ScriptDebugger::get_singleton()->get_lines_left() > 0 && ScriptDebugger::get_singleton()->get_depth() >= 0) {
|
||||
ScriptDebugger::get_singleton()->set_depth(ScriptDebugger::get_singleton()->get_depth() + 1);
|
||||
}
|
||||
|
||||
if (_debug_call_stack_pos >= _debug_max_call_stack) {
|
||||
//stack overflow
|
||||
_debug_error = "Stack Overflow (Stack Size: " + itos(_debug_max_call_stack) + ")";
|
||||
ScriptDebugger::get_singleton()->debug(this);
|
||||
return;
|
||||
}
|
||||
|
||||
_call_stack[_debug_call_stack_pos].stack = p_stack;
|
||||
_call_stack[_debug_call_stack_pos].instance = p_instance;
|
||||
_call_stack[_debug_call_stack_pos].function = p_function;
|
||||
_call_stack[_debug_call_stack_pos].work_mem = p_work_mem;
|
||||
_call_stack[_debug_call_stack_pos].current_id = current_id;
|
||||
_debug_call_stack_pos++;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void exit_function() {
|
||||
if (Thread::get_main_id() != Thread::get_caller_id()) {
|
||||
return; //no support for other threads than main for now
|
||||
}
|
||||
|
||||
if (ScriptDebugger::get_singleton()->get_lines_left() > 0 && ScriptDebugger::get_singleton()->get_depth() >= 0) {
|
||||
ScriptDebugger::get_singleton()->set_depth(ScriptDebugger::get_singleton()->get_depth() - 1);
|
||||
}
|
||||
|
||||
if (_debug_call_stack_pos == 0) {
|
||||
_debug_error = "Stack Underflow (Engine Bug)";
|
||||
ScriptDebugger::get_singleton()->debug(this);
|
||||
return;
|
||||
}
|
||||
|
||||
_debug_call_stack_pos--;
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual String get_name() const;
|
||||
|
||||
/* LANGUAGE FUNCTIONS */
|
||||
virtual void init();
|
||||
virtual String get_type() const;
|
||||
virtual String get_extension() const;
|
||||
virtual Error execute_file(const String &p_path);
|
||||
virtual void finish();
|
||||
|
||||
/* EDITOR FUNCTIONS */
|
||||
virtual void get_reserved_words(List<String> *p_words) const;
|
||||
virtual bool is_control_flow_keyword(String p_keyword) const;
|
||||
virtual void get_comment_delimiters(List<String> *p_delimiters) const;
|
||||
virtual void get_string_delimiters(List<String> *p_delimiters) const;
|
||||
virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
|
||||
virtual bool is_using_templates();
|
||||
virtual void make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script);
|
||||
virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
|
||||
virtual Script *create_script() const;
|
||||
virtual bool has_named_classes() const;
|
||||
virtual bool supports_builtin_mode() const;
|
||||
virtual int find_function(const String &p_function, const String &p_code) const;
|
||||
virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
|
||||
virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const;
|
||||
virtual void add_global_constant(const StringName &p_variable, const Variant &p_value);
|
||||
|
||||
/* DEBUGGER FUNCTIONS */
|
||||
|
||||
virtual String debug_get_error() const;
|
||||
virtual int debug_get_stack_level_count() const;
|
||||
virtual int debug_get_stack_level_line(int p_level) const;
|
||||
virtual String debug_get_stack_level_function(int p_level) const;
|
||||
virtual String debug_get_stack_level_source(int p_level) const;
|
||||
virtual void debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1);
|
||||
virtual void debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1);
|
||||
virtual void debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1);
|
||||
virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems = -1, int p_max_depth = -1);
|
||||
|
||||
virtual void reload_all_scripts();
|
||||
virtual void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload);
|
||||
/* LOADER FUNCTIONS */
|
||||
|
||||
virtual void get_recognized_extensions(List<String> *p_extensions) const;
|
||||
virtual void get_public_functions(List<MethodInfo> *p_functions) const;
|
||||
virtual void get_public_constants(List<Pair<String, Variant>> *p_constants) const;
|
||||
|
||||
virtual void profiling_start();
|
||||
virtual void profiling_stop();
|
||||
|
||||
virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max);
|
||||
virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max);
|
||||
|
||||
void add_register_func(const String &p_name, VisualScriptNodeRegisterFunc p_func);
|
||||
void remove_register_func(const String &p_name);
|
||||
Ref<VisualScriptNode> create_node_from_name(const String &p_name);
|
||||
void get_registered_node_names(List<String> *r_names);
|
||||
|
||||
VisualScriptLanguage();
|
||||
~VisualScriptLanguage();
|
||||
};
|
||||
|
||||
//aid for registering
|
||||
template <class T>
|
||||
static Ref<VisualScriptNode> create_node_generic(const String &p_name) {
|
||||
Ref<T> node;
|
||||
node.instance();
|
||||
return node;
|
||||
}
|
||||
|
||||
#endif // VISUAL_SCRIPT_H
|
File diff suppressed because it is too large
Load Diff
@ -1,153 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* visual_script_builtin_funcs.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef VISUAL_SCRIPT_BUILTIN_FUNCS_H
|
||||
#define VISUAL_SCRIPT_BUILTIN_FUNCS_H
|
||||
|
||||
#include "visual_script.h"
|
||||
|
||||
class VisualScriptBuiltinFunc : public VisualScriptNode {
|
||||
GDCLASS(VisualScriptBuiltinFunc, VisualScriptNode);
|
||||
|
||||
public:
|
||||
enum BuiltinFunc {
|
||||
MATH_SIN,
|
||||
MATH_COS,
|
||||
MATH_TAN,
|
||||
MATH_SINH,
|
||||
MATH_COSH,
|
||||
MATH_TANH,
|
||||
MATH_ASIN,
|
||||
MATH_ACOS,
|
||||
MATH_ATAN,
|
||||
MATH_ATAN2,
|
||||
MATH_SQRT,
|
||||
MATH_FMOD,
|
||||
MATH_FPOSMOD,
|
||||
MATH_FLOOR,
|
||||
MATH_CEIL,
|
||||
MATH_ROUND,
|
||||
MATH_ABS,
|
||||
MATH_SIGN,
|
||||
MATH_POW,
|
||||
MATH_LOG,
|
||||
MATH_EXP,
|
||||
MATH_ISNAN,
|
||||
MATH_ISINF,
|
||||
MATH_EASE,
|
||||
MATH_DECIMALS,
|
||||
MATH_STEPIFY,
|
||||
MATH_LERP,
|
||||
MATH_INVERSE_LERP,
|
||||
MATH_RANGE_LERP,
|
||||
MATH_MOVE_TOWARD,
|
||||
MATH_DECTIME,
|
||||
MATH_RANDOMIZE,
|
||||
MATH_RAND,
|
||||
MATH_RANDF,
|
||||
MATH_RANDOM,
|
||||
MATH_SEED,
|
||||
MATH_RANDSEED,
|
||||
MATH_DEG2RAD,
|
||||
MATH_RAD2DEG,
|
||||
MATH_LINEAR2DB,
|
||||
MATH_DB2LINEAR,
|
||||
MATH_POLAR2CARTESIAN,
|
||||
MATH_CARTESIAN2POLAR,
|
||||
MATH_WRAP,
|
||||
MATH_WRAPF,
|
||||
LOGIC_MAX,
|
||||
LOGIC_MIN,
|
||||
LOGIC_CLAMP,
|
||||
LOGIC_NEAREST_PO2,
|
||||
OBJ_WEAKREF,
|
||||
FUNC_FUNCREF,
|
||||
TYPE_CONVERT,
|
||||
TYPE_OF,
|
||||
TYPE_EXISTS,
|
||||
TEXT_CHAR,
|
||||
TEXT_STR,
|
||||
TEXT_PRINT,
|
||||
TEXT_PRINTERR,
|
||||
TEXT_PRINTRAW,
|
||||
VAR_TO_STR,
|
||||
STR_TO_VAR,
|
||||
VAR_TO_BYTES,
|
||||
BYTES_TO_VAR,
|
||||
COLORN,
|
||||
MATH_SMOOTHSTEP,
|
||||
MATH_POSMOD,
|
||||
MATH_LERP_ANGLE,
|
||||
TEXT_ORD,
|
||||
FUNC_MAX
|
||||
};
|
||||
|
||||
static int get_func_argument_count(BuiltinFunc p_func);
|
||||
static String get_func_name(BuiltinFunc p_func);
|
||||
static void exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant *r_return, Variant::CallError &r_error, String &r_error_str);
|
||||
static BuiltinFunc find_function(const String &p_string);
|
||||
|
||||
private:
|
||||
static const char *func_name[FUNC_MAX];
|
||||
BuiltinFunc func;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual int get_output_sequence_port_count() const;
|
||||
virtual bool has_input_sequence_port() const;
|
||||
|
||||
virtual String get_output_sequence_port_text(int p_port) const;
|
||||
|
||||
virtual int get_input_value_port_count() const;
|
||||
virtual int get_output_value_port_count() const;
|
||||
|
||||
virtual PropertyInfo get_input_value_port_info(int p_idx) const;
|
||||
virtual PropertyInfo get_output_value_port_info(int p_idx) const;
|
||||
|
||||
virtual String get_caption() const;
|
||||
//virtual String get_text() const;
|
||||
virtual String get_category() const { return "functions"; }
|
||||
|
||||
void set_func(BuiltinFunc p_which);
|
||||
BuiltinFunc get_func();
|
||||
|
||||
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
|
||||
|
||||
VisualScriptBuiltinFunc(VisualScriptBuiltinFunc::BuiltinFunc func);
|
||||
VisualScriptBuiltinFunc();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(VisualScriptBuiltinFunc::BuiltinFunc)
|
||||
|
||||
void register_visual_script_builtin_func_node();
|
||||
|
||||
#endif // VISUAL_SCRIPT_BUILTIN_FUNCS_H
|
File diff suppressed because it is too large
Load Diff
@ -1,363 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* visual_script_editor.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef VISUALSCRIPT_EDITOR_H
|
||||
#define VISUALSCRIPT_EDITOR_H
|
||||
|
||||
#include "editor/create_dialog.h"
|
||||
#include "editor/plugins/script_editor_plugin.h"
|
||||
#include "editor/property_editor.h"
|
||||
#include "scene/gui/graph_edit.h"
|
||||
#include "visual_script.h"
|
||||
#include "visual_script_property_selector.h"
|
||||
|
||||
class VisualScriptEditorSignalEdit;
|
||||
class VisualScriptEditorVariableEdit;
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
class VisualScriptEditor : public ScriptEditorBase {
|
||||
GDCLASS(VisualScriptEditor, ScriptEditorBase);
|
||||
|
||||
enum {
|
||||
TYPE_SEQUENCE = 1000,
|
||||
INDEX_BASE_SEQUENCE = 1024
|
||||
|
||||
};
|
||||
|
||||
enum {
|
||||
EDIT_DELETE_NODES,
|
||||
EDIT_TOGGLE_BREAKPOINT,
|
||||
EDIT_FIND_NODE_TYPE,
|
||||
EDIT_COPY_NODES,
|
||||
EDIT_CUT_NODES,
|
||||
EDIT_PASTE_NODES,
|
||||
EDIT_CREATE_FUNCTION,
|
||||
REFRESH_GRAPH
|
||||
};
|
||||
|
||||
enum PortAction {
|
||||
|
||||
CREATE_CALL_SET_GET,
|
||||
CREATE_ACTION,
|
||||
};
|
||||
|
||||
enum MemberAction {
|
||||
MEMBER_EDIT,
|
||||
MEMBER_REMOVE
|
||||
|
||||
};
|
||||
|
||||
enum MemberType {
|
||||
MEMBER_FUNCTION,
|
||||
MEMBER_VARIABLE,
|
||||
MEMBER_SIGNAL
|
||||
};
|
||||
|
||||
VBoxContainer *members_section;
|
||||
MenuButton *edit_menu;
|
||||
|
||||
Ref<VisualScript> script;
|
||||
|
||||
Button *base_type_select;
|
||||
|
||||
LineEdit *func_name_box;
|
||||
ScrollContainer *func_input_scroll;
|
||||
VBoxContainer *func_input_vbox;
|
||||
ConfirmationDialog *function_create_dialog;
|
||||
|
||||
GraphEdit *graph;
|
||||
|
||||
VisualScriptEditorSignalEdit *signal_editor;
|
||||
|
||||
AcceptDialog *edit_signal_dialog;
|
||||
EditorInspector *edit_signal_edit;
|
||||
|
||||
VisualScriptPropertySelector *method_select;
|
||||
VisualScriptPropertySelector *new_connect_node_select;
|
||||
VisualScriptPropertySelector *new_virtual_method_select;
|
||||
|
||||
VisualScriptEditorVariableEdit *variable_editor;
|
||||
|
||||
AcceptDialog *edit_variable_dialog;
|
||||
EditorInspector *edit_variable_edit;
|
||||
|
||||
CustomPropertyEditor *default_value_edit;
|
||||
|
||||
UndoRedo *undo_redo;
|
||||
|
||||
Tree *members;
|
||||
PopupDialog *function_name_edit;
|
||||
LineEdit *function_name_box;
|
||||
|
||||
Label *hint_text;
|
||||
Timer *hint_text_timer;
|
||||
|
||||
Label *select_func_text;
|
||||
|
||||
bool updating_graph;
|
||||
|
||||
void _show_hint(const String &p_hint);
|
||||
void _hide_timer();
|
||||
|
||||
CreateDialog *select_base_type;
|
||||
|
||||
struct VirtualInMenu {
|
||||
String name;
|
||||
Variant::Type ret;
|
||||
bool ret_variant;
|
||||
Vector<Pair<Variant::Type, String>> args;
|
||||
};
|
||||
|
||||
HashMap<StringName, Ref<StyleBox>> node_styles;
|
||||
StringName edited_func;
|
||||
StringName default_func;
|
||||
|
||||
void _update_graph_connections();
|
||||
void _update_graph(int p_only_id = -1);
|
||||
|
||||
bool updating_members;
|
||||
|
||||
void _update_members();
|
||||
String _sanitized_variant_text(const StringName &property_name);
|
||||
|
||||
StringName selected;
|
||||
|
||||
String _validate_name(const String &p_name) const;
|
||||
|
||||
struct Clipboard {
|
||||
Map<int, Ref<VisualScriptNode>> nodes;
|
||||
Map<int, Vector2> nodes_positions;
|
||||
|
||||
Set<VisualScript::SequenceConnection> sequence_connections;
|
||||
Set<VisualScript::DataConnection> data_connections;
|
||||
};
|
||||
|
||||
static Clipboard *clipboard;
|
||||
|
||||
PopupMenu *member_popup;
|
||||
MemberType member_type;
|
||||
String member_name;
|
||||
|
||||
PortAction port_action;
|
||||
int port_action_node;
|
||||
int port_action_output;
|
||||
Vector2 port_action_pos;
|
||||
int port_action_new_node;
|
||||
|
||||
bool saved_pos_dirty;
|
||||
Vector2 saved_position;
|
||||
|
||||
Vector2 mouse_up_position;
|
||||
|
||||
void _port_action_menu(int p_option, const StringName &p_func);
|
||||
|
||||
NodePath drop_path;
|
||||
Node *drop_node = nullptr;
|
||||
Vector2 drop_position;
|
||||
void connect_data(Ref<VisualScriptNode> vnode_old, Ref<VisualScriptNode> vnode, int new_id);
|
||||
|
||||
void _selected_connect_node(const String &p_text, const String &p_category, const bool p_connecting = true);
|
||||
void connect_seq(Ref<VisualScriptNode> vnode_old, Ref<VisualScriptNode> vnode_new, int new_id);
|
||||
|
||||
void _cancel_connect_node();
|
||||
int _create_new_node_from_name(const String &p_text, const Vector2 &p_point, const StringName &p_func = StringName());
|
||||
void _selected_new_virtual_method(const String &p_text, const String &p_category, const bool p_connecting);
|
||||
|
||||
int error_line;
|
||||
|
||||
void _node_selected(Node *p_node);
|
||||
void _center_on_node(const StringName &p_func, int p_id);
|
||||
|
||||
void _node_filter_changed(const String &p_text);
|
||||
void _change_base_type_callback();
|
||||
void _change_base_type();
|
||||
void _toggle_tool_script();
|
||||
void _member_selected();
|
||||
void _member_edited();
|
||||
|
||||
void _begin_node_move();
|
||||
void _end_node_move();
|
||||
void _move_node(const StringName &p_func, int p_id, const Vector2 &p_to);
|
||||
|
||||
void _get_ends(int p_node, const List<VisualScript::SequenceConnection> &p_seqs, const Set<int> &p_selected, Set<int> &r_end_nodes);
|
||||
|
||||
void _node_moved(Vector2 p_from, Vector2 p_to, int p_id);
|
||||
void _remove_node(int p_id);
|
||||
void _graph_connected(const String &p_from, int p_from_slot, const String &p_to, int p_to_slot);
|
||||
void _graph_disconnected(const String &p_from, int p_from_slot, const String &p_to, int p_to_slot);
|
||||
void _graph_connect_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_pos);
|
||||
|
||||
void _node_ports_changed(const String &p_func, int p_id);
|
||||
void _node_create();
|
||||
|
||||
void _update_available_nodes();
|
||||
|
||||
void _member_button(Object *p_item, int p_column, int p_button);
|
||||
|
||||
void _expression_text_changed(const String &p_text, int p_id);
|
||||
void _add_input_port(int p_id);
|
||||
void _add_output_port(int p_id);
|
||||
void _remove_input_port(int p_id, int p_port);
|
||||
void _remove_output_port(int p_id, int p_port);
|
||||
void _change_port_type(int p_select, int p_id, int p_port, bool is_input);
|
||||
void _update_node_size(int p_id);
|
||||
void _port_name_focus_out(const Node *p_name_box, int p_id, int p_port, bool is_input);
|
||||
|
||||
Vector2 _get_pos_in_graph(Vector2 p_point) const;
|
||||
Vector2 _get_available_pos(bool p_centered = true, Vector2 p_pos = Vector2()) const;
|
||||
StringName _get_function_of_node(int p_id) const;
|
||||
|
||||
void _move_nodes_with_rescan(const StringName &p_func_from, const StringName &p_func_to, int p_id);
|
||||
bool node_has_sequence_connections(const StringName &p_func, int p_id);
|
||||
|
||||
void _generic_search(String p_base_type = "", Vector2 pos = Vector2(), bool node_centered = false);
|
||||
|
||||
void _input(const Ref<InputEvent> &p_event);
|
||||
void _graph_gui_input(const Ref<InputEvent> &p_event);
|
||||
void _members_gui_input(const Ref<InputEvent> &p_event);
|
||||
void _fn_name_box_input(const Ref<InputEvent> &p_event);
|
||||
void _rename_function(const String &p_name, const String &p_new_name);
|
||||
|
||||
void _create_function_dialog();
|
||||
void _create_function();
|
||||
void _add_func_input();
|
||||
void _remove_func_input(Node *p_node);
|
||||
void _deselect_input_names();
|
||||
void _add_node_dialog();
|
||||
void _node_item_selected();
|
||||
void _node_item_unselected();
|
||||
|
||||
void _on_nodes_delete();
|
||||
void _on_nodes_duplicate();
|
||||
|
||||
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
|
||||
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
|
||||
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
|
||||
|
||||
int editing_id;
|
||||
int editing_input;
|
||||
|
||||
bool can_swap;
|
||||
int data_disconnect_node;
|
||||
int data_disconnect_port;
|
||||
|
||||
void _default_value_changed();
|
||||
void _default_value_edited(Node *p_button, int p_id, int p_input_port);
|
||||
|
||||
void _menu_option(int p_what);
|
||||
|
||||
void _graph_ofs_changed(const Vector2 &p_ofs);
|
||||
void _comment_node_resized(const Vector2 &p_new_size, int p_node);
|
||||
|
||||
int selecting_method_id;
|
||||
void _selected_method(const String &p_method, const String &p_type, const bool p_connecting);
|
||||
|
||||
void _draw_color_over_button(Object *obj, Color p_color);
|
||||
void _button_resource_previewed(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, Variant p_ud);
|
||||
|
||||
VisualScriptNode::TypeGuess _guess_output_type(int p_port_action_node, int p_port_action_output, Set<int> &p_visited_nodes);
|
||||
|
||||
void _member_rmb_selected(const Vector2 &p_pos);
|
||||
void _member_option(int p_option);
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual void add_syntax_highlighter(SyntaxHighlighter *p_highlighter);
|
||||
virtual void set_syntax_highlighter(SyntaxHighlighter *p_highlighter);
|
||||
|
||||
virtual void apply_code();
|
||||
virtual RES get_edited_resource() const;
|
||||
virtual void set_edited_resource(const RES &p_res);
|
||||
virtual void enable_editor();
|
||||
virtual Vector<String> get_functions();
|
||||
virtual void reload_text();
|
||||
virtual String get_name();
|
||||
virtual Ref<Texture> get_icon();
|
||||
virtual bool is_unsaved();
|
||||
virtual Variant get_edit_state();
|
||||
virtual void set_edit_state(const Variant &p_state);
|
||||
virtual void goto_line(int p_line, bool p_with_error = false);
|
||||
virtual void set_executing_line(int p_line);
|
||||
virtual void clear_executing_line();
|
||||
virtual void trim_trailing_whitespace();
|
||||
virtual void insert_final_newline();
|
||||
virtual void convert_indent_to_spaces();
|
||||
virtual void convert_indent_to_tabs();
|
||||
virtual void ensure_focus();
|
||||
virtual void tag_saved_version();
|
||||
virtual void reload(bool p_soft);
|
||||
virtual void get_breakpoints(List<int> *p_breakpoints);
|
||||
virtual void add_callback(const String &p_function, PoolStringArray p_args);
|
||||
virtual void update_settings();
|
||||
virtual bool show_members_overview();
|
||||
virtual void set_debugger_active(bool p_active);
|
||||
virtual void set_tooltip_request_func(String p_method, Object *p_obj);
|
||||
virtual Control *get_edit_menu();
|
||||
virtual void clear_edit_menu();
|
||||
virtual bool can_lose_focus_on_node_selection() { return false; }
|
||||
virtual void validate();
|
||||
|
||||
static void register_editor();
|
||||
|
||||
static void free_clipboard();
|
||||
|
||||
VisualScriptEditor();
|
||||
~VisualScriptEditor();
|
||||
};
|
||||
|
||||
// Singleton
|
||||
class _VisualScriptEditor : public Object {
|
||||
GDCLASS(_VisualScriptEditor, Object);
|
||||
|
||||
friend class VisualScriptLanguage;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
static _VisualScriptEditor *singleton;
|
||||
|
||||
static Map<String, RefPtr> custom_nodes;
|
||||
static Ref<VisualScriptNode> create_node_custom(const String &p_name);
|
||||
|
||||
public:
|
||||
static _VisualScriptEditor *get_singleton() { return singleton; }
|
||||
|
||||
void add_custom_node(const String &p_name, const String &p_category, const Ref<Script> &p_script);
|
||||
void remove_custom_node(const String &p_name, const String &p_category);
|
||||
|
||||
_VisualScriptEditor();
|
||||
~_VisualScriptEditor();
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // VISUALSCRIPT_EDITOR_H
|
File diff suppressed because it is too large
Load Diff
@ -1,285 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* visual_script_expression.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef VISUALSCRIPTEXPRESSION_H
|
||||
#define VISUALSCRIPTEXPRESSION_H
|
||||
|
||||
#include "visual_script.h"
|
||||
#include "visual_script_builtin_funcs.h"
|
||||
|
||||
class VisualScriptExpression : public VisualScriptNode {
|
||||
GDCLASS(VisualScriptExpression, VisualScriptNode);
|
||||
friend class VisualScriptNodeInstanceExpression;
|
||||
|
||||
struct Input {
|
||||
Variant::Type type;
|
||||
String name;
|
||||
|
||||
Input() { type = Variant::NIL; }
|
||||
};
|
||||
|
||||
Vector<Input> inputs;
|
||||
Variant::Type output_type;
|
||||
|
||||
String expression;
|
||||
|
||||
bool sequenced;
|
||||
int str_ofs;
|
||||
bool expression_dirty;
|
||||
|
||||
bool _compile_expression();
|
||||
|
||||
enum TokenType {
|
||||
TK_CURLY_BRACKET_OPEN,
|
||||
TK_CURLY_BRACKET_CLOSE,
|
||||
TK_BRACKET_OPEN,
|
||||
TK_BRACKET_CLOSE,
|
||||
TK_PARENTHESIS_OPEN,
|
||||
TK_PARENTHESIS_CLOSE,
|
||||
TK_IDENTIFIER,
|
||||
TK_BUILTIN_FUNC,
|
||||
TK_SELF,
|
||||
TK_CONSTANT,
|
||||
TK_BASIC_TYPE,
|
||||
TK_COLON,
|
||||
TK_COMMA,
|
||||
TK_PERIOD,
|
||||
TK_OP_IN,
|
||||
TK_OP_EQUAL,
|
||||
TK_OP_NOT_EQUAL,
|
||||
TK_OP_LESS,
|
||||
TK_OP_LESS_EQUAL,
|
||||
TK_OP_GREATER,
|
||||
TK_OP_GREATER_EQUAL,
|
||||
TK_OP_AND,
|
||||
TK_OP_OR,
|
||||
TK_OP_NOT,
|
||||
TK_OP_ADD,
|
||||
TK_OP_SUB,
|
||||
TK_OP_MUL,
|
||||
TK_OP_DIV,
|
||||
TK_OP_MOD,
|
||||
TK_OP_SHIFT_LEFT,
|
||||
TK_OP_SHIFT_RIGHT,
|
||||
TK_OP_BIT_AND,
|
||||
TK_OP_BIT_OR,
|
||||
TK_OP_BIT_XOR,
|
||||
TK_OP_BIT_INVERT,
|
||||
TK_EOF,
|
||||
TK_ERROR,
|
||||
TK_MAX
|
||||
};
|
||||
|
||||
static const char *token_name[TK_MAX];
|
||||
struct Token {
|
||||
TokenType type;
|
||||
Variant value;
|
||||
};
|
||||
|
||||
void _set_error(const String &p_err) {
|
||||
if (error_set) {
|
||||
return;
|
||||
}
|
||||
error_str = p_err;
|
||||
error_set = true;
|
||||
}
|
||||
|
||||
Error _get_token(Token &r_token);
|
||||
|
||||
String error_str;
|
||||
bool error_set;
|
||||
|
||||
struct ENode {
|
||||
enum Type {
|
||||
TYPE_INPUT,
|
||||
TYPE_CONSTANT,
|
||||
TYPE_SELF,
|
||||
TYPE_OPERATOR,
|
||||
TYPE_INDEX,
|
||||
TYPE_NAMED_INDEX,
|
||||
TYPE_ARRAY,
|
||||
TYPE_DICTIONARY,
|
||||
TYPE_CONSTRUCTOR,
|
||||
TYPE_BUILTIN_FUNC,
|
||||
TYPE_CALL
|
||||
};
|
||||
|
||||
ENode *next;
|
||||
|
||||
Type type;
|
||||
|
||||
ENode() { next = nullptr; }
|
||||
virtual ~ENode() {
|
||||
if (next) {
|
||||
memdelete(next);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct Expression {
|
||||
bool is_op;
|
||||
union {
|
||||
Variant::Operator op;
|
||||
ENode *node;
|
||||
};
|
||||
};
|
||||
|
||||
ENode *_parse_expression();
|
||||
|
||||
struct InputNode : public ENode {
|
||||
int index;
|
||||
InputNode() {
|
||||
type = TYPE_INPUT;
|
||||
}
|
||||
};
|
||||
|
||||
struct ConstantNode : public ENode {
|
||||
Variant value;
|
||||
ConstantNode() {
|
||||
type = TYPE_CONSTANT;
|
||||
}
|
||||
};
|
||||
|
||||
struct OperatorNode : public ENode {
|
||||
Variant::Operator op;
|
||||
|
||||
ENode *nodes[2];
|
||||
|
||||
OperatorNode() {
|
||||
type = TYPE_OPERATOR;
|
||||
}
|
||||
};
|
||||
|
||||
struct SelfNode : public ENode {
|
||||
SelfNode() {
|
||||
type = TYPE_SELF;
|
||||
}
|
||||
};
|
||||
|
||||
struct IndexNode : public ENode {
|
||||
ENode *base;
|
||||
ENode *index;
|
||||
|
||||
IndexNode() {
|
||||
type = TYPE_INDEX;
|
||||
}
|
||||
};
|
||||
|
||||
struct NamedIndexNode : public ENode {
|
||||
ENode *base;
|
||||
StringName name;
|
||||
|
||||
NamedIndexNode() {
|
||||
type = TYPE_NAMED_INDEX;
|
||||
}
|
||||
};
|
||||
|
||||
struct ConstructorNode : public ENode {
|
||||
Variant::Type data_type;
|
||||
Vector<ENode *> arguments;
|
||||
|
||||
ConstructorNode() {
|
||||
type = TYPE_CONSTRUCTOR;
|
||||
}
|
||||
};
|
||||
|
||||
struct CallNode : public ENode {
|
||||
ENode *base;
|
||||
StringName method;
|
||||
Vector<ENode *> arguments;
|
||||
|
||||
CallNode() {
|
||||
type = TYPE_CALL;
|
||||
}
|
||||
};
|
||||
|
||||
struct ArrayNode : public ENode {
|
||||
Vector<ENode *> array;
|
||||
ArrayNode() {
|
||||
type = TYPE_ARRAY;
|
||||
}
|
||||
};
|
||||
|
||||
struct DictionaryNode : public ENode {
|
||||
Vector<ENode *> dict;
|
||||
DictionaryNode() {
|
||||
type = TYPE_DICTIONARY;
|
||||
}
|
||||
};
|
||||
|
||||
struct BuiltinFuncNode : public ENode {
|
||||
VisualScriptBuiltinFunc::BuiltinFunc func;
|
||||
Vector<ENode *> arguments;
|
||||
BuiltinFuncNode() {
|
||||
type = TYPE_BUILTIN_FUNC;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
T *alloc_node() {
|
||||
T *node = memnew(T);
|
||||
node->next = nodes;
|
||||
nodes = node;
|
||||
return node;
|
||||
}
|
||||
|
||||
ENode *root;
|
||||
ENode *nodes;
|
||||
|
||||
protected:
|
||||
bool _set(const StringName &p_name, const Variant &p_value);
|
||||
bool _get(const StringName &p_name, Variant &r_ret) const;
|
||||
void _get_property_list(List<PropertyInfo> *p_list) const;
|
||||
|
||||
public:
|
||||
virtual int get_output_sequence_port_count() const;
|
||||
virtual bool has_input_sequence_port() const;
|
||||
|
||||
virtual String get_output_sequence_port_text(int p_port) const;
|
||||
|
||||
virtual int get_input_value_port_count() const;
|
||||
virtual int get_output_value_port_count() const;
|
||||
|
||||
virtual PropertyInfo get_input_value_port_info(int p_idx) const;
|
||||
virtual PropertyInfo get_output_value_port_info(int p_idx) const;
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "operators"; }
|
||||
|
||||
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
|
||||
|
||||
VisualScriptExpression();
|
||||
~VisualScriptExpression();
|
||||
};
|
||||
|
||||
void register_visual_script_expression_node();
|
||||
|
||||
#endif // VISUALSCRIPTEXPRESSION_H
|
@ -1,858 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* visual_script_flow_control.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "visual_script_flow_control.h"
|
||||
|
||||
#include "core/io/resource_loader.h"
|
||||
#include "core/os/keyboard.h"
|
||||
#include "core/project_settings.h"
|
||||
|
||||
//////////////////////////////////////////
|
||||
////////////////RETURN////////////////////
|
||||
//////////////////////////////////////////
|
||||
|
||||
int VisualScriptReturn::get_output_sequence_port_count() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool VisualScriptReturn::has_input_sequence_port() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
int VisualScriptReturn::get_input_value_port_count() const {
|
||||
return with_value ? 1 : 0;
|
||||
}
|
||||
int VisualScriptReturn::get_output_value_port_count() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
String VisualScriptReturn::get_output_sequence_port_text(int p_port) const {
|
||||
return String();
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptReturn::get_input_value_port_info(int p_idx) const {
|
||||
PropertyInfo pinfo;
|
||||
pinfo.name = "result";
|
||||
pinfo.type = type;
|
||||
return pinfo;
|
||||
}
|
||||
PropertyInfo VisualScriptReturn::get_output_value_port_info(int p_idx) const {
|
||||
return PropertyInfo();
|
||||
}
|
||||
|
||||
String VisualScriptReturn::get_caption() const {
|
||||
return RTR("Return");
|
||||
}
|
||||
|
||||
String VisualScriptReturn::get_text() const {
|
||||
return get_name();
|
||||
}
|
||||
|
||||
void VisualScriptReturn::set_return_type(Variant::Type p_type) {
|
||||
if (type == p_type) {
|
||||
return;
|
||||
}
|
||||
type = p_type;
|
||||
ports_changed_notify();
|
||||
}
|
||||
|
||||
Variant::Type VisualScriptReturn::get_return_type() const {
|
||||
return type;
|
||||
}
|
||||
|
||||
void VisualScriptReturn::set_enable_return_value(bool p_enable) {
|
||||
if (with_value == p_enable) {
|
||||
return;
|
||||
}
|
||||
|
||||
with_value = p_enable;
|
||||
ports_changed_notify();
|
||||
}
|
||||
|
||||
bool VisualScriptReturn::is_return_value_enabled() const {
|
||||
return with_value;
|
||||
}
|
||||
|
||||
void VisualScriptReturn::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_return_type", "type"), &VisualScriptReturn::set_return_type);
|
||||
ClassDB::bind_method(D_METHOD("get_return_type"), &VisualScriptReturn::get_return_type);
|
||||
ClassDB::bind_method(D_METHOD("set_enable_return_value", "enable"), &VisualScriptReturn::set_enable_return_value);
|
||||
ClassDB::bind_method(D_METHOD("is_return_value_enabled"), &VisualScriptReturn::is_return_value_enabled);
|
||||
|
||||
String argt = "Any";
|
||||
for (int i = 1; i < Variant::VARIANT_MAX; i++) {
|
||||
argt += "," + Variant::get_type_name(Variant::Type(i));
|
||||
}
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "return_enabled"), "set_enable_return_value", "is_return_value_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "return_type", PROPERTY_HINT_ENUM, argt), "set_return_type", "get_return_type");
|
||||
}
|
||||
|
||||
class VisualScriptNodeInstanceReturn : public VisualScriptNodeInstance {
|
||||
public:
|
||||
VisualScriptReturn *node;
|
||||
VisualScriptInstance *instance;
|
||||
bool with_value;
|
||||
|
||||
virtual int get_working_memory_size() const { return 1; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
||||
|
||||
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
|
||||
if (with_value) {
|
||||
*p_working_mem = *p_inputs[0];
|
||||
return STEP_EXIT_FUNCTION_BIT;
|
||||
} else {
|
||||
*p_working_mem = Variant();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance *VisualScriptReturn::instance(VisualScriptInstance *p_instance) {
|
||||
VisualScriptNodeInstanceReturn *instance = memnew(VisualScriptNodeInstanceReturn);
|
||||
instance->node = this;
|
||||
instance->instance = p_instance;
|
||||
instance->with_value = with_value;
|
||||
return instance;
|
||||
}
|
||||
|
||||
VisualScriptReturn::VisualScriptReturn() {
|
||||
with_value = false;
|
||||
type = Variant::NIL;
|
||||
}
|
||||
|
||||
template <bool with_value>
|
||||
static Ref<VisualScriptNode> create_return_node(const String &p_name) {
|
||||
Ref<VisualScriptReturn> node;
|
||||
node.instance();
|
||||
node->set_enable_return_value(with_value);
|
||||
return node;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
////////////////CONDITION/////////////////
|
||||
//////////////////////////////////////////
|
||||
|
||||
int VisualScriptCondition::get_output_sequence_port_count() const {
|
||||
return 3;
|
||||
}
|
||||
|
||||
bool VisualScriptCondition::has_input_sequence_port() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
int VisualScriptCondition::get_input_value_port_count() const {
|
||||
return 1;
|
||||
}
|
||||
int VisualScriptCondition::get_output_value_port_count() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
String VisualScriptCondition::get_output_sequence_port_text(int p_port) const {
|
||||
if (p_port == 0) {
|
||||
return "true";
|
||||
} else if (p_port == 1) {
|
||||
return "false";
|
||||
} else {
|
||||
return "done";
|
||||
}
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptCondition::get_input_value_port_info(int p_idx) const {
|
||||
PropertyInfo pinfo;
|
||||
pinfo.name = "cond";
|
||||
pinfo.type = Variant::BOOL;
|
||||
return pinfo;
|
||||
}
|
||||
PropertyInfo VisualScriptCondition::get_output_value_port_info(int p_idx) const {
|
||||
return PropertyInfo();
|
||||
}
|
||||
|
||||
String VisualScriptCondition::get_caption() const {
|
||||
return RTR("Condition");
|
||||
}
|
||||
|
||||
String VisualScriptCondition::get_text() const {
|
||||
return RTR("if (cond) is:");
|
||||
}
|
||||
|
||||
void VisualScriptCondition::_bind_methods() {
|
||||
}
|
||||
|
||||
class VisualScriptNodeInstanceCondition : public VisualScriptNodeInstance {
|
||||
public:
|
||||
VisualScriptCondition *node;
|
||||
VisualScriptInstance *instance;
|
||||
|
||||
//virtual int get_working_memory_size() const { return 1; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
||||
|
||||
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
|
||||
if (p_start_mode == START_MODE_CONTINUE_SEQUENCE) {
|
||||
return 2;
|
||||
} else if (p_inputs[0]->operator bool()) {
|
||||
return 0 | STEP_FLAG_PUSH_STACK_BIT;
|
||||
} else {
|
||||
return 1 | STEP_FLAG_PUSH_STACK_BIT;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance *VisualScriptCondition::instance(VisualScriptInstance *p_instance) {
|
||||
VisualScriptNodeInstanceCondition *instance = memnew(VisualScriptNodeInstanceCondition);
|
||||
instance->node = this;
|
||||
instance->instance = p_instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
VisualScriptCondition::VisualScriptCondition() {
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
////////////////WHILE/////////////////
|
||||
//////////////////////////////////////////
|
||||
|
||||
int VisualScriptWhile::get_output_sequence_port_count() const {
|
||||
return 2;
|
||||
}
|
||||
|
||||
bool VisualScriptWhile::has_input_sequence_port() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
int VisualScriptWhile::get_input_value_port_count() const {
|
||||
return 1;
|
||||
}
|
||||
int VisualScriptWhile::get_output_value_port_count() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
String VisualScriptWhile::get_output_sequence_port_text(int p_port) const {
|
||||
if (p_port == 0) {
|
||||
return "repeat";
|
||||
} else {
|
||||
return "exit";
|
||||
}
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptWhile::get_input_value_port_info(int p_idx) const {
|
||||
PropertyInfo pinfo;
|
||||
pinfo.name = "cond";
|
||||
pinfo.type = Variant::BOOL;
|
||||
return pinfo;
|
||||
}
|
||||
PropertyInfo VisualScriptWhile::get_output_value_port_info(int p_idx) const {
|
||||
return PropertyInfo();
|
||||
}
|
||||
|
||||
String VisualScriptWhile::get_caption() const {
|
||||
return RTR("While");
|
||||
}
|
||||
|
||||
String VisualScriptWhile::get_text() const {
|
||||
return RTR("while (cond):");
|
||||
}
|
||||
|
||||
void VisualScriptWhile::_bind_methods() {
|
||||
}
|
||||
|
||||
class VisualScriptNodeInstanceWhile : public VisualScriptNodeInstance {
|
||||
public:
|
||||
VisualScriptWhile *node;
|
||||
VisualScriptInstance *instance;
|
||||
|
||||
//virtual int get_working_memory_size() const { return 1; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
||||
|
||||
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
|
||||
bool keep_going = p_inputs[0]->operator bool();
|
||||
|
||||
if (keep_going) {
|
||||
return 0 | STEP_FLAG_PUSH_STACK_BIT;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance *VisualScriptWhile::instance(VisualScriptInstance *p_instance) {
|
||||
VisualScriptNodeInstanceWhile *instance = memnew(VisualScriptNodeInstanceWhile);
|
||||
instance->node = this;
|
||||
instance->instance = p_instance;
|
||||
return instance;
|
||||
}
|
||||
VisualScriptWhile::VisualScriptWhile() {
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
////////////////ITERATOR/////////////////
|
||||
//////////////////////////////////////////
|
||||
|
||||
int VisualScriptIterator::get_output_sequence_port_count() const {
|
||||
return 2;
|
||||
}
|
||||
|
||||
bool VisualScriptIterator::has_input_sequence_port() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
int VisualScriptIterator::get_input_value_port_count() const {
|
||||
return 1;
|
||||
}
|
||||
int VisualScriptIterator::get_output_value_port_count() const {
|
||||
return 1;
|
||||
}
|
||||
|
||||
String VisualScriptIterator::get_output_sequence_port_text(int p_port) const {
|
||||
if (p_port == 0) {
|
||||
return "each";
|
||||
} else {
|
||||
return "exit";
|
||||
}
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptIterator::get_input_value_port_info(int p_idx) const {
|
||||
PropertyInfo pinfo;
|
||||
pinfo.name = "input";
|
||||
pinfo.type = Variant::NIL;
|
||||
return pinfo;
|
||||
}
|
||||
PropertyInfo VisualScriptIterator::get_output_value_port_info(int p_idx) const {
|
||||
PropertyInfo pinfo;
|
||||
pinfo.name = "elem";
|
||||
pinfo.type = Variant::NIL;
|
||||
return pinfo;
|
||||
}
|
||||
String VisualScriptIterator::get_caption() const {
|
||||
return RTR("Iterator");
|
||||
}
|
||||
|
||||
String VisualScriptIterator::get_text() const {
|
||||
return RTR("for (elem) in (input):");
|
||||
}
|
||||
|
||||
void VisualScriptIterator::_bind_methods() {
|
||||
}
|
||||
|
||||
class VisualScriptNodeInstanceIterator : public VisualScriptNodeInstance {
|
||||
public:
|
||||
VisualScriptIterator *node;
|
||||
VisualScriptInstance *instance;
|
||||
|
||||
virtual int get_working_memory_size() const { return 2; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
||||
|
||||
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
|
||||
if (p_start_mode == START_MODE_BEGIN_SEQUENCE) {
|
||||
p_working_mem[0] = *p_inputs[0];
|
||||
bool valid;
|
||||
bool can_iter = p_inputs[0]->iter_init(p_working_mem[1], valid);
|
||||
|
||||
if (!valid) {
|
||||
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str = RTR("Input type not iterable: ") + Variant::get_type_name(p_inputs[0]->get_type());
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!can_iter) {
|
||||
return 1; //nothing to iterate
|
||||
}
|
||||
|
||||
*p_outputs[0] = p_working_mem[0].iter_get(p_working_mem[1], valid);
|
||||
|
||||
if (!valid) {
|
||||
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str = RTR("Iterator became invalid");
|
||||
return 0;
|
||||
}
|
||||
|
||||
} else { //continue sequence
|
||||
|
||||
bool valid;
|
||||
bool can_iter = p_working_mem[0].iter_next(p_working_mem[1], valid);
|
||||
|
||||
if (!valid) {
|
||||
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str = RTR("Iterator became invalid: ") + Variant::get_type_name(p_inputs[0]->get_type());
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!can_iter) {
|
||||
return 1; //nothing to iterate
|
||||
}
|
||||
|
||||
*p_outputs[0] = p_working_mem[0].iter_get(p_working_mem[1], valid);
|
||||
|
||||
if (!valid) {
|
||||
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str = RTR("Iterator became invalid");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0 | STEP_FLAG_PUSH_STACK_BIT; //go around
|
||||
}
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance *VisualScriptIterator::instance(VisualScriptInstance *p_instance) {
|
||||
VisualScriptNodeInstanceIterator *instance = memnew(VisualScriptNodeInstanceIterator);
|
||||
instance->node = this;
|
||||
instance->instance = p_instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
VisualScriptIterator::VisualScriptIterator() {
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
////////////////SEQUENCE/////////////////
|
||||
//////////////////////////////////////////
|
||||
|
||||
int VisualScriptSequence::get_output_sequence_port_count() const {
|
||||
return steps;
|
||||
}
|
||||
|
||||
bool VisualScriptSequence::has_input_sequence_port() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
int VisualScriptSequence::get_input_value_port_count() const {
|
||||
return 0;
|
||||
}
|
||||
int VisualScriptSequence::get_output_value_port_count() const {
|
||||
return 1;
|
||||
}
|
||||
|
||||
String VisualScriptSequence::get_output_sequence_port_text(int p_port) const {
|
||||
return itos(p_port + 1);
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptSequence::get_input_value_port_info(int p_idx) const {
|
||||
return PropertyInfo();
|
||||
}
|
||||
PropertyInfo VisualScriptSequence::get_output_value_port_info(int p_idx) const {
|
||||
return PropertyInfo(Variant::INT, "current");
|
||||
}
|
||||
String VisualScriptSequence::get_caption() const {
|
||||
return RTR("Sequence");
|
||||
}
|
||||
|
||||
String VisualScriptSequence::get_text() const {
|
||||
return RTR("in order:");
|
||||
}
|
||||
|
||||
void VisualScriptSequence::set_steps(int p_steps) {
|
||||
ERR_FAIL_COND(p_steps < 1);
|
||||
if (steps == p_steps) {
|
||||
return;
|
||||
}
|
||||
|
||||
steps = p_steps;
|
||||
ports_changed_notify();
|
||||
}
|
||||
|
||||
int VisualScriptSequence::get_steps() const {
|
||||
return steps;
|
||||
}
|
||||
|
||||
void VisualScriptSequence::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_steps", "steps"), &VisualScriptSequence::set_steps);
|
||||
ClassDB::bind_method(D_METHOD("get_steps"), &VisualScriptSequence::get_steps);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "steps", PROPERTY_HINT_RANGE, "1,64,1"), "set_steps", "get_steps");
|
||||
}
|
||||
|
||||
class VisualScriptNodeInstanceSequence : public VisualScriptNodeInstance {
|
||||
public:
|
||||
VisualScriptSequence *node;
|
||||
VisualScriptInstance *instance;
|
||||
int steps;
|
||||
|
||||
virtual int get_working_memory_size() const { return 1; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
||||
|
||||
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
|
||||
if (p_start_mode == START_MODE_BEGIN_SEQUENCE) {
|
||||
p_working_mem[0] = 0;
|
||||
}
|
||||
|
||||
int step = p_working_mem[0];
|
||||
|
||||
*p_outputs[0] = step;
|
||||
|
||||
if (step + 1 == steps) {
|
||||
return step;
|
||||
} else {
|
||||
p_working_mem[0] = step + 1;
|
||||
return step | STEP_FLAG_PUSH_STACK_BIT;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance *VisualScriptSequence::instance(VisualScriptInstance *p_instance) {
|
||||
VisualScriptNodeInstanceSequence *instance = memnew(VisualScriptNodeInstanceSequence);
|
||||
instance->node = this;
|
||||
instance->instance = p_instance;
|
||||
instance->steps = steps;
|
||||
return instance;
|
||||
}
|
||||
VisualScriptSequence::VisualScriptSequence() {
|
||||
steps = 1;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
////////////////EVENT TYPE FILTER///////////
|
||||
//////////////////////////////////////////
|
||||
|
||||
int VisualScriptSwitch::get_output_sequence_port_count() const {
|
||||
return case_values.size() + 1;
|
||||
}
|
||||
|
||||
bool VisualScriptSwitch::has_input_sequence_port() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
int VisualScriptSwitch::get_input_value_port_count() const {
|
||||
return case_values.size() + 1;
|
||||
}
|
||||
int VisualScriptSwitch::get_output_value_port_count() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
String VisualScriptSwitch::get_output_sequence_port_text(int p_port) const {
|
||||
if (p_port == case_values.size()) {
|
||||
return "done";
|
||||
}
|
||||
|
||||
return String();
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptSwitch::get_input_value_port_info(int p_idx) const {
|
||||
if (p_idx < case_values.size()) {
|
||||
return PropertyInfo(case_values[p_idx].type, " =");
|
||||
} else {
|
||||
return PropertyInfo(Variant::NIL, "input");
|
||||
}
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptSwitch::get_output_value_port_info(int p_idx) const {
|
||||
return PropertyInfo();
|
||||
}
|
||||
|
||||
String VisualScriptSwitch::get_caption() const {
|
||||
return RTR("Switch");
|
||||
}
|
||||
|
||||
String VisualScriptSwitch::get_text() const {
|
||||
return RTR("'input' is:");
|
||||
}
|
||||
|
||||
class VisualScriptNodeInstanceSwitch : public VisualScriptNodeInstance {
|
||||
public:
|
||||
VisualScriptInstance *instance;
|
||||
int case_count;
|
||||
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return false; }
|
||||
|
||||
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
|
||||
if (p_start_mode == START_MODE_CONTINUE_SEQUENCE) {
|
||||
return case_count; //exit
|
||||
}
|
||||
|
||||
for (int i = 0; i < case_count; i++) {
|
||||
if (*p_inputs[i] == *p_inputs[case_count]) {
|
||||
return i | STEP_FLAG_PUSH_STACK_BIT;
|
||||
}
|
||||
}
|
||||
|
||||
return case_count;
|
||||
}
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance *VisualScriptSwitch::instance(VisualScriptInstance *p_instance) {
|
||||
VisualScriptNodeInstanceSwitch *instance = memnew(VisualScriptNodeInstanceSwitch);
|
||||
instance->instance = p_instance;
|
||||
instance->case_count = case_values.size();
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool VisualScriptSwitch::_set(const StringName &p_name, const Variant &p_value) {
|
||||
if (String(p_name) == "case_count") {
|
||||
case_values.resize(p_value);
|
||||
_change_notify();
|
||||
ports_changed_notify();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (String(p_name).begins_with("case/")) {
|
||||
int idx = String(p_name).get_slice("/", 1).to_int();
|
||||
ERR_FAIL_INDEX_V(idx, case_values.size(), false);
|
||||
|
||||
case_values.write[idx].type = Variant::Type(int(p_value));
|
||||
_change_notify();
|
||||
ports_changed_notify();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VisualScriptSwitch::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
if (String(p_name) == "case_count") {
|
||||
r_ret = case_values.size();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (String(p_name).begins_with("case/")) {
|
||||
int idx = String(p_name).get_slice("/", 1).to_int();
|
||||
ERR_FAIL_INDEX_V(idx, case_values.size(), false);
|
||||
|
||||
r_ret = case_values[idx].type;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
void VisualScriptSwitch::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
p_list->push_back(PropertyInfo(Variant::INT, "case_count", PROPERTY_HINT_RANGE, "0,128"));
|
||||
|
||||
String argt = "Any";
|
||||
for (int i = 1; i < Variant::VARIANT_MAX; i++) {
|
||||
argt += "," + Variant::get_type_name(Variant::Type(i));
|
||||
}
|
||||
|
||||
for (int i = 0; i < case_values.size(); i++) {
|
||||
p_list->push_back(PropertyInfo(Variant::INT, "case/" + itos(i), PROPERTY_HINT_ENUM, argt));
|
||||
}
|
||||
}
|
||||
|
||||
void VisualScriptSwitch::_bind_methods() {
|
||||
}
|
||||
|
||||
VisualScriptSwitch::VisualScriptSwitch() {
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
////////////////TYPE CAST///////////
|
||||
//////////////////////////////////////////
|
||||
|
||||
int VisualScriptTypeCast::get_output_sequence_port_count() const {
|
||||
return 2;
|
||||
}
|
||||
|
||||
bool VisualScriptTypeCast::has_input_sequence_port() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
int VisualScriptTypeCast::get_input_value_port_count() const {
|
||||
return 1;
|
||||
}
|
||||
int VisualScriptTypeCast::get_output_value_port_count() const {
|
||||
return 1;
|
||||
}
|
||||
|
||||
String VisualScriptTypeCast::get_output_sequence_port_text(int p_port) const {
|
||||
return p_port == 0 ? "yes" : "no";
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptTypeCast::get_input_value_port_info(int p_idx) const {
|
||||
return PropertyInfo(Variant::OBJECT, "instance");
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptTypeCast::get_output_value_port_info(int p_idx) const {
|
||||
return PropertyInfo(Variant::OBJECT, "", PROPERTY_HINT_TYPE_STRING, get_base_type());
|
||||
}
|
||||
|
||||
String VisualScriptTypeCast::get_caption() const {
|
||||
return RTR("Type Cast");
|
||||
}
|
||||
|
||||
String VisualScriptTypeCast::get_text() const {
|
||||
if (script != String()) {
|
||||
return vformat(RTR("Is %s?"), script.get_file());
|
||||
} else {
|
||||
return vformat(RTR("Is %s?"), base_type);
|
||||
}
|
||||
}
|
||||
|
||||
void VisualScriptTypeCast::set_base_type(const StringName &p_type) {
|
||||
if (base_type == p_type) {
|
||||
return;
|
||||
}
|
||||
|
||||
base_type = p_type;
|
||||
_change_notify();
|
||||
ports_changed_notify();
|
||||
}
|
||||
|
||||
StringName VisualScriptTypeCast::get_base_type() const {
|
||||
return base_type;
|
||||
}
|
||||
|
||||
void VisualScriptTypeCast::set_base_script(const String &p_path) {
|
||||
if (script == p_path) {
|
||||
return;
|
||||
}
|
||||
|
||||
script = p_path;
|
||||
_change_notify();
|
||||
ports_changed_notify();
|
||||
}
|
||||
String VisualScriptTypeCast::get_base_script() const {
|
||||
return script;
|
||||
}
|
||||
|
||||
VisualScriptTypeCast::TypeGuess VisualScriptTypeCast::guess_output_type(TypeGuess *p_inputs, int p_output) const {
|
||||
TypeGuess tg;
|
||||
tg.type = Variant::OBJECT;
|
||||
if (script != String()) {
|
||||
tg.script = ResourceLoader::load(script);
|
||||
}
|
||||
//if (!tg.script.is_valid()) {
|
||||
// tg.gdclass = base_type;
|
||||
//}
|
||||
|
||||
return tg;
|
||||
}
|
||||
|
||||
class VisualScriptNodeInstanceTypeCast : public VisualScriptNodeInstance {
|
||||
public:
|
||||
VisualScriptInstance *instance;
|
||||
StringName base_type;
|
||||
String script;
|
||||
|
||||
//virtual int get_working_memory_size() const { return 0; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return false; }
|
||||
|
||||
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
|
||||
Object *obj = *p_inputs[0];
|
||||
|
||||
*p_outputs[0] = Variant();
|
||||
|
||||
if (!obj) {
|
||||
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str = "Instance is null";
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (script != String()) {
|
||||
Ref<Script> obj_script = obj->get_script();
|
||||
if (!obj_script.is_valid()) {
|
||||
return 1; //well, definitely not the script because object we got has no script.
|
||||
}
|
||||
|
||||
if (!ResourceCache::has(script)) {
|
||||
//if the script is not in use by anyone, we can safely assume whatever we got is not casting to it.
|
||||
return 1;
|
||||
}
|
||||
Ref<Script> cast_script = Ref<Resource>(ResourceCache::get(script));
|
||||
if (!cast_script.is_valid()) {
|
||||
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str = "Script path is not a script: " + script;
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (obj_script.is_valid()) {
|
||||
if (cast_script == obj_script) {
|
||||
*p_outputs[0] = *p_inputs[0]; //copy
|
||||
return 0; // it is the script, yey
|
||||
}
|
||||
|
||||
obj_script = obj_script->get_base_script();
|
||||
}
|
||||
|
||||
return 1; //not found sorry
|
||||
}
|
||||
|
||||
if (ClassDB::is_parent_class(obj->get_class_name(), base_type)) {
|
||||
*p_outputs[0] = *p_inputs[0]; //copy
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance *VisualScriptTypeCast::instance(VisualScriptInstance *p_instance) {
|
||||
VisualScriptNodeInstanceTypeCast *instance = memnew(VisualScriptNodeInstanceTypeCast);
|
||||
instance->instance = p_instance;
|
||||
instance->base_type = base_type;
|
||||
instance->script = script;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void VisualScriptTypeCast::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_base_type", "type"), &VisualScriptTypeCast::set_base_type);
|
||||
ClassDB::bind_method(D_METHOD("get_base_type"), &VisualScriptTypeCast::get_base_type);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_base_script", "path"), &VisualScriptTypeCast::set_base_script);
|
||||
ClassDB::bind_method(D_METHOD("get_base_script"), &VisualScriptTypeCast::get_base_script);
|
||||
|
||||
List<String> script_extensions;
|
||||
for (int i = 0; i > ScriptServer::get_language_count(); i++) {
|
||||
ScriptServer::get_language(i)->get_recognized_extensions(&script_extensions);
|
||||
}
|
||||
|
||||
String script_ext_hint;
|
||||
for (List<String>::Element *E = script_extensions.front(); E; E = E->next()) {
|
||||
if (script_ext_hint != String()) {
|
||||
script_ext_hint += ",";
|
||||
}
|
||||
script_ext_hint += "*." + E->get();
|
||||
}
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_script", PROPERTY_HINT_FILE, script_ext_hint), "set_base_script", "get_base_script");
|
||||
}
|
||||
|
||||
VisualScriptTypeCast::VisualScriptTypeCast() {
|
||||
base_type = "Object";
|
||||
}
|
||||
|
||||
void register_visual_script_flow_control_nodes() {
|
||||
VisualScriptLanguage::singleton->add_register_func("flow_control/return", create_return_node<false>);
|
||||
VisualScriptLanguage::singleton->add_register_func("flow_control/return_with_value", create_return_node<true>);
|
||||
VisualScriptLanguage::singleton->add_register_func("flow_control/condition", create_node_generic<VisualScriptCondition>);
|
||||
VisualScriptLanguage::singleton->add_register_func("flow_control/while", create_node_generic<VisualScriptWhile>);
|
||||
VisualScriptLanguage::singleton->add_register_func("flow_control/iterator", create_node_generic<VisualScriptIterator>);
|
||||
VisualScriptLanguage::singleton->add_register_func("flow_control/sequence", create_node_generic<VisualScriptSequence>);
|
||||
VisualScriptLanguage::singleton->add_register_func("flow_control/switch", create_node_generic<VisualScriptSwitch>);
|
||||
//VisualScriptLanguage::singleton->add_register_func("flow_control/input_filter", create_node_generic<VisualScriptInputFilter>);
|
||||
VisualScriptLanguage::singleton->add_register_func("flow_control/type_cast", create_node_generic<VisualScriptTypeCast>);
|
||||
}
|
@ -1,266 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* visual_script_flow_control.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef VISUAL_SCRIPT_FLOW_CONTROL_H
|
||||
#define VISUAL_SCRIPT_FLOW_CONTROL_H
|
||||
|
||||
#include "visual_script.h"
|
||||
|
||||
class VisualScriptReturn : public VisualScriptNode {
|
||||
GDCLASS(VisualScriptReturn, VisualScriptNode);
|
||||
|
||||
Variant::Type type;
|
||||
bool with_value;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual int get_output_sequence_port_count() const;
|
||||
virtual bool has_input_sequence_port() const;
|
||||
|
||||
virtual String get_output_sequence_port_text(int p_port) const;
|
||||
|
||||
virtual int get_input_value_port_count() const;
|
||||
virtual int get_output_value_port_count() const;
|
||||
|
||||
virtual PropertyInfo get_input_value_port_info(int p_idx) const;
|
||||
virtual PropertyInfo get_output_value_port_info(int p_idx) const;
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "flow_control"; }
|
||||
|
||||
void set_return_type(Variant::Type);
|
||||
Variant::Type get_return_type() const;
|
||||
|
||||
void set_enable_return_value(bool p_enable);
|
||||
bool is_return_value_enabled() const;
|
||||
|
||||
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
|
||||
|
||||
VisualScriptReturn();
|
||||
};
|
||||
|
||||
class VisualScriptCondition : public VisualScriptNode {
|
||||
GDCLASS(VisualScriptCondition, VisualScriptNode);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual int get_output_sequence_port_count() const;
|
||||
virtual bool has_input_sequence_port() const;
|
||||
|
||||
virtual String get_output_sequence_port_text(int p_port) const;
|
||||
|
||||
virtual int get_input_value_port_count() const;
|
||||
virtual int get_output_value_port_count() const;
|
||||
|
||||
virtual PropertyInfo get_input_value_port_info(int p_idx) const;
|
||||
virtual PropertyInfo get_output_value_port_info(int p_idx) const;
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "flow_control"; }
|
||||
|
||||
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
|
||||
|
||||
VisualScriptCondition();
|
||||
};
|
||||
|
||||
class VisualScriptWhile : public VisualScriptNode {
|
||||
GDCLASS(VisualScriptWhile, VisualScriptNode);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual int get_output_sequence_port_count() const;
|
||||
virtual bool has_input_sequence_port() const;
|
||||
|
||||
virtual String get_output_sequence_port_text(int p_port) const;
|
||||
|
||||
virtual int get_input_value_port_count() const;
|
||||
virtual int get_output_value_port_count() const;
|
||||
|
||||
virtual PropertyInfo get_input_value_port_info(int p_idx) const;
|
||||
virtual PropertyInfo get_output_value_port_info(int p_idx) const;
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "flow_control"; }
|
||||
|
||||
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
|
||||
|
||||
VisualScriptWhile();
|
||||
};
|
||||
|
||||
class VisualScriptIterator : public VisualScriptNode {
|
||||
GDCLASS(VisualScriptIterator, VisualScriptNode);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual int get_output_sequence_port_count() const;
|
||||
virtual bool has_input_sequence_port() const;
|
||||
|
||||
virtual String get_output_sequence_port_text(int p_port) const;
|
||||
|
||||
virtual int get_input_value_port_count() const;
|
||||
virtual int get_output_value_port_count() const;
|
||||
|
||||
virtual PropertyInfo get_input_value_port_info(int p_idx) const;
|
||||
virtual PropertyInfo get_output_value_port_info(int p_idx) const;
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "flow_control"; }
|
||||
|
||||
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
|
||||
|
||||
VisualScriptIterator();
|
||||
};
|
||||
|
||||
class VisualScriptSequence : public VisualScriptNode {
|
||||
GDCLASS(VisualScriptSequence, VisualScriptNode);
|
||||
|
||||
int steps;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual int get_output_sequence_port_count() const;
|
||||
virtual bool has_input_sequence_port() const;
|
||||
|
||||
virtual String get_output_sequence_port_text(int p_port) const;
|
||||
|
||||
virtual int get_input_value_port_count() const;
|
||||
virtual int get_output_value_port_count() const;
|
||||
|
||||
virtual PropertyInfo get_input_value_port_info(int p_idx) const;
|
||||
virtual PropertyInfo get_output_value_port_info(int p_idx) const;
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "flow_control"; }
|
||||
|
||||
void set_steps(int p_steps);
|
||||
int get_steps() const;
|
||||
|
||||
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
|
||||
|
||||
VisualScriptSequence();
|
||||
};
|
||||
|
||||
class VisualScriptSwitch : public VisualScriptNode {
|
||||
GDCLASS(VisualScriptSwitch, VisualScriptNode);
|
||||
|
||||
struct Case {
|
||||
Variant::Type type;
|
||||
Case() { type = Variant::NIL; }
|
||||
};
|
||||
|
||||
Vector<Case> case_values;
|
||||
|
||||
friend class VisualScriptNodeInstanceSwitch;
|
||||
|
||||
protected:
|
||||
bool _set(const StringName &p_name, const Variant &p_value);
|
||||
bool _get(const StringName &p_name, Variant &r_ret) const;
|
||||
void _get_property_list(List<PropertyInfo> *p_list) const;
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual int get_output_sequence_port_count() const;
|
||||
virtual bool has_input_sequence_port() const;
|
||||
|
||||
virtual String get_output_sequence_port_text(int p_port) const;
|
||||
virtual bool has_mixed_input_and_sequence_ports() const { return true; }
|
||||
|
||||
virtual int get_input_value_port_count() const;
|
||||
virtual int get_output_value_port_count() const;
|
||||
|
||||
virtual PropertyInfo get_input_value_port_info(int p_idx) const;
|
||||
virtual PropertyInfo get_output_value_port_info(int p_idx) const;
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "flow_control"; }
|
||||
|
||||
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
|
||||
|
||||
VisualScriptSwitch();
|
||||
};
|
||||
|
||||
class VisualScriptTypeCast : public VisualScriptNode {
|
||||
GDCLASS(VisualScriptTypeCast, VisualScriptNode);
|
||||
|
||||
StringName base_type;
|
||||
String script;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual int get_output_sequence_port_count() const;
|
||||
virtual bool has_input_sequence_port() const;
|
||||
|
||||
virtual String get_output_sequence_port_text(int p_port) const;
|
||||
|
||||
virtual int get_input_value_port_count() const;
|
||||
virtual int get_output_value_port_count() const;
|
||||
|
||||
virtual PropertyInfo get_input_value_port_info(int p_idx) const;
|
||||
virtual PropertyInfo get_output_value_port_info(int p_idx) const;
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "flow_control"; }
|
||||
|
||||
void set_base_type(const StringName &p_type);
|
||||
StringName get_base_type() const;
|
||||
|
||||
void set_base_script(const String &p_path);
|
||||
String get_base_script() const;
|
||||
|
||||
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const;
|
||||
|
||||
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
|
||||
|
||||
VisualScriptTypeCast();
|
||||
};
|
||||
|
||||
void register_visual_script_flow_control_nodes();
|
||||
|
||||
#endif // VISUAL_SCRIPT_FLOW_CONTROL_H
|
File diff suppressed because it is too large
Load Diff
@ -1,363 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* visual_script_func_nodes.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef VISUAL_SCRIPT_FUNC_NODES_H
|
||||
#define VISUAL_SCRIPT_FUNC_NODES_H
|
||||
|
||||
#include "visual_script.h"
|
||||
|
||||
class VisualScriptFunctionCall : public VisualScriptNode {
|
||||
GDCLASS(VisualScriptFunctionCall, VisualScriptNode);
|
||||
|
||||
public:
|
||||
enum CallMode {
|
||||
CALL_MODE_SELF,
|
||||
CALL_MODE_NODE_PATH,
|
||||
CALL_MODE_INSTANCE,
|
||||
CALL_MODE_BASIC_TYPE,
|
||||
CALL_MODE_SINGLETON,
|
||||
};
|
||||
|
||||
enum RPCCallMode {
|
||||
RPC_DISABLED,
|
||||
RPC_RELIABLE,
|
||||
RPC_UNRELIABLE,
|
||||
RPC_RELIABLE_TO_ID,
|
||||
RPC_UNRELIABLE_TO_ID
|
||||
};
|
||||
|
||||
private:
|
||||
CallMode call_mode;
|
||||
StringName base_type;
|
||||
String base_script;
|
||||
Variant::Type basic_type;
|
||||
NodePath base_path;
|
||||
StringName function;
|
||||
int use_default_args;
|
||||
RPCCallMode rpc_call_mode;
|
||||
StringName singleton;
|
||||
bool validate;
|
||||
|
||||
Node *_get_base_node() const;
|
||||
StringName _get_base_type() const;
|
||||
|
||||
MethodInfo method_cache;
|
||||
void _update_method_cache();
|
||||
|
||||
void _set_argument_cache(const Dictionary &p_cache);
|
||||
Dictionary _get_argument_cache() const;
|
||||
|
||||
protected:
|
||||
virtual void _validate_property(PropertyInfo &property) const;
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual int get_output_sequence_port_count() const;
|
||||
virtual bool has_input_sequence_port() const;
|
||||
|
||||
virtual String get_output_sequence_port_text(int p_port) const;
|
||||
|
||||
virtual int get_input_value_port_count() const;
|
||||
virtual int get_output_value_port_count() const;
|
||||
|
||||
virtual PropertyInfo get_input_value_port_info(int p_idx) const;
|
||||
virtual PropertyInfo get_output_value_port_info(int p_idx) const;
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "functions"; }
|
||||
|
||||
void set_basic_type(Variant::Type p_type);
|
||||
Variant::Type get_basic_type() const;
|
||||
|
||||
void set_base_type(const StringName &p_type);
|
||||
StringName get_base_type() const;
|
||||
|
||||
void set_base_script(const String &p_path);
|
||||
String get_base_script() const;
|
||||
|
||||
void set_singleton(const StringName &p_type);
|
||||
StringName get_singleton() const;
|
||||
|
||||
void set_function(const StringName &p_type);
|
||||
StringName get_function() const;
|
||||
|
||||
void set_base_path(const NodePath &p_type);
|
||||
NodePath get_base_path() const;
|
||||
|
||||
void set_call_mode(CallMode p_mode);
|
||||
CallMode get_call_mode() const;
|
||||
|
||||
void set_use_default_args(int p_amount);
|
||||
int get_use_default_args() const;
|
||||
|
||||
void set_validate(bool p_amount);
|
||||
bool get_validate() const;
|
||||
|
||||
void set_rpc_call_mode(RPCCallMode p_mode);
|
||||
RPCCallMode get_rpc_call_mode() const;
|
||||
|
||||
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
|
||||
|
||||
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const;
|
||||
|
||||
VisualScriptFunctionCall();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(VisualScriptFunctionCall::CallMode);
|
||||
VARIANT_ENUM_CAST(VisualScriptFunctionCall::RPCCallMode);
|
||||
|
||||
class VisualScriptPropertySet : public VisualScriptNode {
|
||||
GDCLASS(VisualScriptPropertySet, VisualScriptNode);
|
||||
|
||||
public:
|
||||
enum CallMode {
|
||||
CALL_MODE_SELF,
|
||||
CALL_MODE_NODE_PATH,
|
||||
CALL_MODE_INSTANCE,
|
||||
CALL_MODE_BASIC_TYPE,
|
||||
|
||||
};
|
||||
|
||||
enum AssignOp {
|
||||
ASSIGN_OP_NONE,
|
||||
ASSIGN_OP_ADD,
|
||||
ASSIGN_OP_SUB,
|
||||
ASSIGN_OP_MUL,
|
||||
ASSIGN_OP_DIV,
|
||||
ASSIGN_OP_MOD,
|
||||
ASSIGN_OP_SHIFT_LEFT,
|
||||
ASSIGN_OP_SHIFT_RIGHT,
|
||||
ASSIGN_OP_BIT_AND,
|
||||
ASSIGN_OP_BIT_OR,
|
||||
ASSIGN_OP_BIT_XOR,
|
||||
ASSIGN_OP_MAX
|
||||
};
|
||||
|
||||
private:
|
||||
PropertyInfo type_cache;
|
||||
|
||||
CallMode call_mode;
|
||||
Variant::Type basic_type;
|
||||
StringName base_type;
|
||||
String base_script;
|
||||
NodePath base_path;
|
||||
StringName property;
|
||||
StringName index;
|
||||
AssignOp assign_op;
|
||||
|
||||
Node *_get_base_node() const;
|
||||
StringName _get_base_type() const;
|
||||
|
||||
void _update_base_type();
|
||||
|
||||
void _update_cache();
|
||||
|
||||
void _set_type_cache(const Dictionary &p_type);
|
||||
Dictionary _get_type_cache() const;
|
||||
|
||||
void _adjust_input_index(PropertyInfo &pinfo) const;
|
||||
|
||||
protected:
|
||||
virtual void _validate_property(PropertyInfo &property) const;
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual int get_output_sequence_port_count() const;
|
||||
virtual bool has_input_sequence_port() const;
|
||||
|
||||
virtual String get_output_sequence_port_text(int p_port) const;
|
||||
|
||||
virtual int get_input_value_port_count() const;
|
||||
virtual int get_output_value_port_count() const;
|
||||
|
||||
virtual PropertyInfo get_input_value_port_info(int p_idx) const;
|
||||
virtual PropertyInfo get_output_value_port_info(int p_idx) const;
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "functions"; }
|
||||
|
||||
void set_base_type(const StringName &p_type);
|
||||
StringName get_base_type() const;
|
||||
|
||||
void set_base_script(const String &p_path);
|
||||
String get_base_script() const;
|
||||
|
||||
void set_basic_type(Variant::Type p_type);
|
||||
Variant::Type get_basic_type() const;
|
||||
|
||||
void set_property(const StringName &p_type);
|
||||
StringName get_property() const;
|
||||
|
||||
void set_base_path(const NodePath &p_type);
|
||||
NodePath get_base_path() const;
|
||||
|
||||
void set_call_mode(CallMode p_mode);
|
||||
CallMode get_call_mode() const;
|
||||
|
||||
void set_index(const StringName &p_type);
|
||||
StringName get_index() const;
|
||||
|
||||
void set_assign_op(AssignOp p_op);
|
||||
AssignOp get_assign_op() const;
|
||||
|
||||
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
|
||||
virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const;
|
||||
|
||||
VisualScriptPropertySet();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(VisualScriptPropertySet::CallMode);
|
||||
VARIANT_ENUM_CAST(VisualScriptPropertySet::AssignOp);
|
||||
|
||||
class VisualScriptPropertyGet : public VisualScriptNode {
|
||||
GDCLASS(VisualScriptPropertyGet, VisualScriptNode);
|
||||
|
||||
public:
|
||||
enum CallMode {
|
||||
CALL_MODE_SELF,
|
||||
CALL_MODE_NODE_PATH,
|
||||
CALL_MODE_INSTANCE,
|
||||
CALL_MODE_BASIC_TYPE,
|
||||
|
||||
};
|
||||
|
||||
private:
|
||||
Variant::Type type_cache;
|
||||
|
||||
CallMode call_mode;
|
||||
Variant::Type basic_type;
|
||||
StringName base_type;
|
||||
String base_script;
|
||||
NodePath base_path;
|
||||
StringName property;
|
||||
StringName index;
|
||||
|
||||
void _update_base_type();
|
||||
Node *_get_base_node() const;
|
||||
StringName _get_base_type() const;
|
||||
|
||||
void _update_cache();
|
||||
|
||||
void _set_type_cache(Variant::Type p_type);
|
||||
Variant::Type _get_type_cache() const;
|
||||
|
||||
void _adjust_input_index(PropertyInfo &pinfo) const;
|
||||
|
||||
protected:
|
||||
virtual void _validate_property(PropertyInfo &property) const;
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual int get_output_sequence_port_count() const;
|
||||
virtual bool has_input_sequence_port() const;
|
||||
|
||||
virtual String get_output_sequence_port_text(int p_port) const;
|
||||
|
||||
virtual int get_input_value_port_count() const;
|
||||
virtual int get_output_value_port_count() const;
|
||||
|
||||
virtual PropertyInfo get_input_value_port_info(int p_idx) const;
|
||||
virtual PropertyInfo get_output_value_port_info(int p_idx) const;
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "functions"; }
|
||||
|
||||
void set_base_type(const StringName &p_type);
|
||||
StringName get_base_type() const;
|
||||
|
||||
void set_base_script(const String &p_path);
|
||||
String get_base_script() const;
|
||||
|
||||
void set_basic_type(Variant::Type p_type);
|
||||
Variant::Type get_basic_type() const;
|
||||
|
||||
void set_property(const StringName &p_type);
|
||||
StringName get_property() const;
|
||||
|
||||
void set_base_path(const NodePath &p_type);
|
||||
NodePath get_base_path() const;
|
||||
|
||||
void set_call_mode(CallMode p_mode);
|
||||
CallMode get_call_mode() const;
|
||||
|
||||
void set_index(const StringName &p_type);
|
||||
StringName get_index() const;
|
||||
|
||||
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
|
||||
|
||||
VisualScriptPropertyGet();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(VisualScriptPropertyGet::CallMode);
|
||||
|
||||
class VisualScriptEmitSignal : public VisualScriptNode {
|
||||
GDCLASS(VisualScriptEmitSignal, VisualScriptNode);
|
||||
|
||||
private:
|
||||
StringName name;
|
||||
|
||||
protected:
|
||||
virtual void _validate_property(PropertyInfo &property) const;
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual int get_output_sequence_port_count() const;
|
||||
virtual bool has_input_sequence_port() const;
|
||||
|
||||
virtual String get_output_sequence_port_text(int p_port) const;
|
||||
|
||||
virtual int get_input_value_port_count() const;
|
||||
virtual int get_output_value_port_count() const;
|
||||
|
||||
virtual PropertyInfo get_input_value_port_info(int p_idx) const;
|
||||
virtual PropertyInfo get_output_value_port_info(int p_idx) const;
|
||||
|
||||
virtual String get_caption() const;
|
||||
//virtual String get_text() const;
|
||||
virtual String get_category() const { return "functions"; }
|
||||
|
||||
void set_signal(const StringName &p_type);
|
||||
StringName get_signal() const;
|
||||
|
||||
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
|
||||
|
||||
VisualScriptEmitSignal();
|
||||
};
|
||||
|
||||
void register_visual_script_func_nodes();
|
||||
|
||||
#endif // VISUAL_SCRIPT_FUNC_NODES_H
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,734 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* visual_script_property_selector.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "visual_script_property_selector.h"
|
||||
|
||||
#include "core/os/keyboard.h"
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_scale.h"
|
||||
#include "modules/visual_script/visual_script.h"
|
||||
#include "modules/visual_script/visual_script_builtin_funcs.h"
|
||||
#include "modules/visual_script/visual_script_flow_control.h"
|
||||
#include "modules/visual_script/visual_script_func_nodes.h"
|
||||
#include "modules/visual_script/visual_script_nodes.h"
|
||||
#include "scene/main/node.h"
|
||||
#include "scene/main/viewport.h"
|
||||
|
||||
void VisualScriptPropertySelector::_text_changed(const String &p_newtext) {
|
||||
_update_search();
|
||||
}
|
||||
|
||||
void VisualScriptPropertySelector::_sbox_input(const Ref<InputEvent> &p_ie) {
|
||||
Ref<InputEventKey> k = p_ie;
|
||||
|
||||
if (k.is_valid()) {
|
||||
switch (k->get_scancode()) {
|
||||
case KEY_UP:
|
||||
case KEY_DOWN:
|
||||
case KEY_PAGEUP:
|
||||
case KEY_PAGEDOWN: {
|
||||
search_options->call("_gui_input", k);
|
||||
search_box->accept_event();
|
||||
|
||||
TreeItem *root = search_options->get_root();
|
||||
if (!root->get_children()) {
|
||||
break;
|
||||
}
|
||||
|
||||
TreeItem *current = search_options->get_selected();
|
||||
|
||||
TreeItem *item = search_options->get_next_selected(root);
|
||||
while (item) {
|
||||
item->deselect(0);
|
||||
item = search_options->get_next_selected(item);
|
||||
}
|
||||
|
||||
current->select(0);
|
||||
|
||||
} break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VisualScriptPropertySelector::_update_search() {
|
||||
set_title(TTR("Search VisualScript"));
|
||||
|
||||
search_options->clear();
|
||||
help_bit->set_text("");
|
||||
|
||||
TreeItem *root = search_options->create_item();
|
||||
bool found = false;
|
||||
StringName base = base_type;
|
||||
List<StringName> base_list;
|
||||
while (base) {
|
||||
base_list.push_back(base);
|
||||
base = ClassDB::get_parent_class_nocheck(base);
|
||||
}
|
||||
|
||||
for (List<StringName>::Element *E = base_list.front(); E; E = E->next()) {
|
||||
List<MethodInfo> methods;
|
||||
List<PropertyInfo> props;
|
||||
TreeItem *category = nullptr;
|
||||
Ref<Texture> type_icons[Variant::VARIANT_MAX] = {
|
||||
Control::get_icon("Variant", "EditorIcons"),
|
||||
Control::get_icon("bool", "EditorIcons"),
|
||||
Control::get_icon("int", "EditorIcons"),
|
||||
Control::get_icon("float", "EditorIcons"),
|
||||
Control::get_icon("String", "EditorIcons"),
|
||||
Control::get_icon("Vector2", "EditorIcons"),
|
||||
Control::get_icon("Rect2", "EditorIcons"),
|
||||
Control::get_icon("Vector3", "EditorIcons"),
|
||||
Control::get_icon("Transform2D", "EditorIcons"),
|
||||
Control::get_icon("Plane", "EditorIcons"),
|
||||
Control::get_icon("Quat", "EditorIcons"),
|
||||
Control::get_icon("AABB", "EditorIcons"),
|
||||
Control::get_icon("Basis", "EditorIcons"),
|
||||
Control::get_icon("Transform", "EditorIcons"),
|
||||
Control::get_icon("Color", "EditorIcons"),
|
||||
Control::get_icon("Path", "EditorIcons"),
|
||||
Control::get_icon("RID", "EditorIcons"),
|
||||
Control::get_icon("Object", "EditorIcons"),
|
||||
Control::get_icon("Dictionary", "EditorIcons"),
|
||||
Control::get_icon("Array", "EditorIcons"),
|
||||
Control::get_icon("PoolByteArray", "EditorIcons"),
|
||||
Control::get_icon("PoolIntArray", "EditorIcons"),
|
||||
Control::get_icon("PoolRealArray", "EditorIcons"),
|
||||
Control::get_icon("PoolStringArray", "EditorIcons"),
|
||||
Control::get_icon("PoolVector2Array", "EditorIcons"),
|
||||
Control::get_icon("PoolVector3Array", "EditorIcons"),
|
||||
Control::get_icon("PoolColorArray", "EditorIcons")
|
||||
};
|
||||
{
|
||||
String b = String(E->get());
|
||||
category = search_options->create_item(root);
|
||||
if (category) {
|
||||
category->set_text(0, b.replace_first("*", ""));
|
||||
category->set_selectable(0, false);
|
||||
Ref<Texture> icon;
|
||||
String rep = b.replace("*", "");
|
||||
icon = EditorNode::get_singleton()->get_class_icon(rep);
|
||||
category->set_icon(0, icon);
|
||||
}
|
||||
}
|
||||
if (properties || seq_connect) {
|
||||
if (instance) {
|
||||
instance->get_property_list(&props, true);
|
||||
} else {
|
||||
Object *obj = ObjectDB::get_instance(script);
|
||||
if (Object::cast_to<Script>(obj)) {
|
||||
Object::cast_to<Script>(obj)->get_script_property_list(&props);
|
||||
} else {
|
||||
ClassDB::get_property_list(E->get(), &props, true);
|
||||
}
|
||||
}
|
||||
for (List<PropertyInfo>::Element *F = props.front(); F; F = F->next()) {
|
||||
if (!(F->get().usage & PROPERTY_USAGE_EDITOR) && !(F->get().usage & PROPERTY_USAGE_SCRIPT_VARIABLE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type_filter.size() && type_filter.find(F->get().type) == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// capitalize() also converts underscore to space, we'll match again both possible styles
|
||||
String get_text_raw = String(vformat(TTR("Get %s"), F->get().name));
|
||||
String get_text = get_text_raw.capitalize();
|
||||
String set_text_raw = String(vformat(TTR("Set %s"), F->get().name));
|
||||
String set_text = set_text_raw.capitalize();
|
||||
String input = search_box->get_text().capitalize();
|
||||
|
||||
if (input == String() || get_text_raw.findn(input) != -1 || get_text.findn(input) != -1) {
|
||||
TreeItem *item = search_options->create_item(category ? category : root);
|
||||
item->set_text(0, get_text);
|
||||
item->set_metadata(0, F->get().name);
|
||||
item->set_icon(0, type_icons[F->get().type]);
|
||||
item->set_metadata(1, "get");
|
||||
item->set_collapsed(true);
|
||||
item->set_selectable(0, true);
|
||||
item->set_selectable(1, false);
|
||||
item->set_selectable(2, false);
|
||||
item->set_metadata(2, connecting);
|
||||
}
|
||||
|
||||
if (input == String() || set_text_raw.findn(input) != -1 || set_text.findn(input) != -1) {
|
||||
TreeItem *item = search_options->create_item(category ? category : root);
|
||||
item->set_text(0, set_text);
|
||||
item->set_metadata(0, F->get().name);
|
||||
item->set_icon(0, type_icons[F->get().type]);
|
||||
item->set_metadata(1, "set");
|
||||
item->set_selectable(0, true);
|
||||
item->set_selectable(1, false);
|
||||
item->set_selectable(2, false);
|
||||
item->set_metadata(2, connecting);
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
if (type != Variant::NIL) {
|
||||
Variant v;
|
||||
Variant::CallError ce;
|
||||
v = Variant::construct(type, nullptr, 0, ce);
|
||||
v.get_method_list(&methods);
|
||||
} else {
|
||||
Object *obj = ObjectDB::get_instance(script);
|
||||
if (Object::cast_to<Script>(obj)) {
|
||||
Object::cast_to<Script>(obj)->get_script_method_list(&methods);
|
||||
}
|
||||
|
||||
ClassDB::get_method_list(E->get(), &methods, true, true);
|
||||
}
|
||||
}
|
||||
for (List<MethodInfo>::Element *M = methods.front(); M; M = M->next()) {
|
||||
String name = M->get().name.get_slice(":", 0);
|
||||
if (name.begins_with("_") && !(M->get().flags & METHOD_FLAG_VIRTUAL)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (virtuals_only && !(M->get().flags & METHOD_FLAG_VIRTUAL)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!virtuals_only && (M->get().flags & METHOD_FLAG_VIRTUAL)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MethodInfo mi = M->get();
|
||||
String desc_arguments;
|
||||
if (mi.arguments.size() > 0) {
|
||||
desc_arguments = "(";
|
||||
for (int i = 0; i < mi.arguments.size(); i++) {
|
||||
if (i > 0) {
|
||||
desc_arguments += ", ";
|
||||
}
|
||||
if (mi.arguments[i].type == Variant::NIL) {
|
||||
desc_arguments += "var";
|
||||
} else if (mi.arguments[i].name.find(":") != -1) {
|
||||
desc_arguments += mi.arguments[i].name.get_slice(":", 1);
|
||||
mi.arguments[i].name = mi.arguments[i].name.get_slice(":", 0);
|
||||
} else {
|
||||
desc_arguments += Variant::get_type_name(mi.arguments[i].type);
|
||||
}
|
||||
}
|
||||
desc_arguments += ")";
|
||||
}
|
||||
String desc_raw = mi.name + desc_arguments;
|
||||
String desc = desc_raw.capitalize().replace("( ", "(");
|
||||
|
||||
if (search_box->get_text() != String() &&
|
||||
name.findn(search_box->get_text()) == -1 &&
|
||||
desc.findn(search_box->get_text()) == -1 &&
|
||||
desc_raw.findn(search_box->get_text()) == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TreeItem *item = search_options->create_item(category ? category : root);
|
||||
item->set_text(0, desc);
|
||||
item->set_icon(0, get_icon("MemberMethod", "EditorIcons"));
|
||||
item->set_metadata(0, name);
|
||||
item->set_selectable(0, true);
|
||||
|
||||
item->set_metadata(1, "method");
|
||||
item->set_collapsed(true);
|
||||
item->set_selectable(1, false);
|
||||
|
||||
item->set_selectable(2, false);
|
||||
item->set_metadata(2, connecting);
|
||||
}
|
||||
|
||||
if (category && category->get_children() == nullptr) {
|
||||
memdelete(category); //old category was unused
|
||||
}
|
||||
}
|
||||
if (properties) {
|
||||
if (!seq_connect && !visual_script_generic) {
|
||||
get_visual_node_names("flow_control/type_cast", Set<String>(), found, root, search_box);
|
||||
get_visual_node_names("functions/built_in/print", Set<String>(), found, root, search_box);
|
||||
get_visual_node_names("functions/by_type/" + Variant::get_type_name(type), Set<String>(), found, root, search_box);
|
||||
get_visual_node_names("functions/deconstruct/" + Variant::get_type_name(type), Set<String>(), found, root, search_box);
|
||||
get_visual_node_names("operators/compare/", Set<String>(), found, root, search_box);
|
||||
if (type == Variant::INT) {
|
||||
get_visual_node_names("operators/bitwise/", Set<String>(), found, root, search_box);
|
||||
}
|
||||
if (type == Variant::BOOL) {
|
||||
get_visual_node_names("operators/logic/", Set<String>(), found, root, search_box);
|
||||
}
|
||||
if (type == Variant::BOOL || type == Variant::INT || type == Variant::REAL || type == Variant::VECTOR2 || type == Variant::VECTOR3) {
|
||||
get_visual_node_names("operators/math/", Set<String>(), found, root, search_box);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (seq_connect && !visual_script_generic) {
|
||||
String text = search_box->get_text();
|
||||
create_visualscript_item(String("VisualScriptCondition"), root, text, String("Condition"));
|
||||
create_visualscript_item(String("VisualScriptSwitch"), root, text, String("Switch"));
|
||||
create_visualscript_item(String("VisualScriptSequence"), root, text, String("Sequence"));
|
||||
create_visualscript_item(String("VisualScriptIterator"), root, text, String("Iterator"));
|
||||
create_visualscript_item(String("VisualScriptWhile"), root, text, String("While"));
|
||||
create_visualscript_item(String("VisualScriptReturn"), root, text, String("Return"));
|
||||
get_visual_node_names("flow_control/type_cast", Set<String>(), found, root, search_box);
|
||||
get_visual_node_names("functions/built_in/print", Set<String>(), found, root, search_box);
|
||||
}
|
||||
|
||||
if ((properties || seq_connect) && visual_script_generic) {
|
||||
get_visual_node_names("", Set<String>(), found, root, search_box);
|
||||
}
|
||||
|
||||
TreeItem *selected_item = search_options->search_item_text(search_box->get_text());
|
||||
if (!found && selected_item != nullptr) {
|
||||
selected_item->select(0);
|
||||
found = true;
|
||||
}
|
||||
|
||||
get_ok()->set_disabled(root->get_children() == nullptr);
|
||||
}
|
||||
|
||||
void VisualScriptPropertySelector::create_visualscript_item(const String &name, TreeItem *const root, const String &search_input, const String &text) {
|
||||
if (search_input == String() || text.findn(search_input) != -1) {
|
||||
TreeItem *item = search_options->create_item(root);
|
||||
item->set_text(0, text);
|
||||
item->set_icon(0, get_icon("VisualScript", "EditorIcons"));
|
||||
item->set_metadata(0, name);
|
||||
item->set_metadata(1, "action");
|
||||
item->set_selectable(0, true);
|
||||
item->set_collapsed(true);
|
||||
item->set_selectable(1, false);
|
||||
item->set_selectable(2, false);
|
||||
item->set_metadata(2, connecting);
|
||||
}
|
||||
}
|
||||
|
||||
void VisualScriptPropertySelector::get_visual_node_names(const String &root_filter, const Set<String> &p_modifiers, bool &found, TreeItem *const root, LineEdit *const search_box) {
|
||||
Map<String, TreeItem *> path_cache;
|
||||
|
||||
List<String> fnodes;
|
||||
VisualScriptLanguage::singleton->get_registered_node_names(&fnodes);
|
||||
|
||||
for (List<String>::Element *E = fnodes.front(); E; E = E->next()) {
|
||||
if (!E->get().begins_with(root_filter)) {
|
||||
continue;
|
||||
}
|
||||
Vector<String> path = E->get().split("/");
|
||||
|
||||
// check if the name has the filter
|
||||
bool in_filter = false;
|
||||
Vector<String> tx_filters = search_box->get_text().split(" ");
|
||||
for (int i = 0; i < tx_filters.size(); i++) {
|
||||
if (tx_filters[i] == "") {
|
||||
in_filter = true;
|
||||
} else {
|
||||
in_filter = false;
|
||||
}
|
||||
if (E->get().findn(tx_filters[i]) != -1) {
|
||||
in_filter = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!in_filter) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bool in_modifier = p_modifiers.empty();
|
||||
for (Set<String>::Element *F = p_modifiers.front(); F && in_modifier; F = F->next()) {
|
||||
if (E->get().findn(F->get()) != -1) {
|
||||
in_modifier = true;
|
||||
}
|
||||
}
|
||||
if (!in_modifier) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TreeItem *item = search_options->create_item(root);
|
||||
Ref<VisualScriptNode> vnode = VisualScriptLanguage::singleton->create_node_from_name(E->get());
|
||||
Ref<VisualScriptOperator> vnode_operator = vnode;
|
||||
String type_name;
|
||||
if (vnode_operator.is_valid()) {
|
||||
String type;
|
||||
if (path.size() >= 2) {
|
||||
type = path[1];
|
||||
}
|
||||
type_name = type.capitalize() + " ";
|
||||
}
|
||||
Ref<VisualScriptFunctionCall> vnode_function_call = vnode;
|
||||
if (vnode_function_call.is_valid()) {
|
||||
String basic_type = Variant::get_type_name(vnode_function_call->get_basic_type());
|
||||
type_name = basic_type.capitalize() + " ";
|
||||
}
|
||||
Ref<VisualScriptConstructor> vnode_constructor = vnode;
|
||||
if (vnode_constructor.is_valid()) {
|
||||
type_name = "Construct ";
|
||||
}
|
||||
Ref<VisualScriptDeconstruct> vnode_deconstruct = vnode;
|
||||
if (vnode_deconstruct.is_valid()) {
|
||||
type_name = "Deconstruct ";
|
||||
}
|
||||
Vector<String> desc = path[path.size() - 1].replace("(", " ").replace(")", " ").replace(",", " ").split(" ");
|
||||
for (int i = 0; i < desc.size(); i++) {
|
||||
desc.write[i] = desc[i].capitalize();
|
||||
if (desc[i].ends_with(",")) {
|
||||
desc.write[i] = desc[i].replace(",", ", ");
|
||||
}
|
||||
}
|
||||
|
||||
item->set_text(0, type_name + String("").join(desc));
|
||||
item->set_icon(0, get_icon("VisualScript", "EditorIcons"));
|
||||
item->set_selectable(0, true);
|
||||
item->set_metadata(0, E->get());
|
||||
item->set_selectable(0, true);
|
||||
item->set_metadata(1, "visualscript");
|
||||
item->set_selectable(1, false);
|
||||
item->set_selectable(2, false);
|
||||
item->set_metadata(2, connecting);
|
||||
}
|
||||
}
|
||||
|
||||
void VisualScriptPropertySelector::_confirmed() {
|
||||
TreeItem *ti = search_options->get_selected();
|
||||
if (!ti) {
|
||||
return;
|
||||
}
|
||||
emit_signal("selected", ti->get_metadata(0), ti->get_metadata(1), ti->get_metadata(2));
|
||||
hide();
|
||||
}
|
||||
|
||||
void VisualScriptPropertySelector::_item_selected() {
|
||||
help_bit->set_text("");
|
||||
|
||||
TreeItem *item = search_options->get_selected();
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
String name = item->get_metadata(0);
|
||||
|
||||
String class_type;
|
||||
if (type != Variant::NIL) {
|
||||
class_type = Variant::get_type_name(type);
|
||||
|
||||
} else {
|
||||
class_type = base_type;
|
||||
}
|
||||
|
||||
DocData *dd = EditorHelp::get_doc_data();
|
||||
String text;
|
||||
|
||||
String at_class = class_type;
|
||||
|
||||
while (at_class != String()) {
|
||||
Map<String, DocData::ClassDoc>::Element *E = dd->class_list.find(at_class);
|
||||
if (E) {
|
||||
for (int i = 0; i < E->get().properties.size(); i++) {
|
||||
if (E->get().properties[i].name == name) {
|
||||
text = DTR(E->get().properties[i].description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
at_class = ClassDB::get_parent_class_nocheck(at_class);
|
||||
}
|
||||
at_class = class_type;
|
||||
|
||||
while (at_class != String()) {
|
||||
Map<String, DocData::ClassDoc>::Element *C = dd->class_list.find(at_class);
|
||||
if (C) {
|
||||
for (int i = 0; i < C->get().methods.size(); i++) {
|
||||
if (C->get().methods[i].name == name) {
|
||||
text = DTR(C->get().methods[i].description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
at_class = ClassDB::get_parent_class_nocheck(at_class);
|
||||
}
|
||||
Vector<String> functions = name.rsplit("/", false);
|
||||
at_class = functions.size() > 3 ? functions[functions.size() - 2] : class_type;
|
||||
Map<String, DocData::ClassDoc>::Element *T = dd->class_list.find(at_class);
|
||||
if (T) {
|
||||
for (int i = 0; i < T->get().methods.size(); i++) {
|
||||
if (T->get().methods[i].name == functions[functions.size() - 1]) {
|
||||
text = DTR(T->get().methods[i].description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<String> *names = memnew(List<String>);
|
||||
VisualScriptLanguage::singleton->get_registered_node_names(names);
|
||||
if (names->find(name) != nullptr) {
|
||||
Ref<VisualScriptOperator> operator_node = VisualScriptLanguage::singleton->create_node_from_name(name);
|
||||
if (operator_node.is_valid()) {
|
||||
Map<String, DocData::ClassDoc>::Element *F = dd->class_list.find(operator_node->get_class_name());
|
||||
if (F) {
|
||||
text = Variant::get_operator_name(operator_node->get_operator());
|
||||
}
|
||||
}
|
||||
Ref<VisualScriptTypeCast> typecast_node = VisualScriptLanguage::singleton->create_node_from_name(name);
|
||||
if (typecast_node.is_valid()) {
|
||||
Map<String, DocData::ClassDoc>::Element *F = dd->class_list.find(typecast_node->get_class_name());
|
||||
if (F) {
|
||||
text = DTR(F->get().description);
|
||||
}
|
||||
}
|
||||
|
||||
Ref<VisualScriptBuiltinFunc> builtin_node = VisualScriptLanguage::singleton->create_node_from_name(name);
|
||||
if (builtin_node.is_valid()) {
|
||||
Map<String, DocData::ClassDoc>::Element *F = dd->class_list.find(builtin_node->get_class_name());
|
||||
if (F) {
|
||||
for (int i = 0; i < F->get().constants.size(); i++) {
|
||||
if (F->get().constants[i].value.to_int() == int(builtin_node->get_func())) {
|
||||
text = DTR(F->get().constants[i].description);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
memdelete(names);
|
||||
|
||||
if (text == String()) {
|
||||
return;
|
||||
}
|
||||
|
||||
help_bit->set_text(text);
|
||||
}
|
||||
|
||||
void VisualScriptPropertySelector::_notification(int p_what) {
|
||||
if (p_what == NOTIFICATION_ENTER_TREE) {
|
||||
connect("confirmed", this, "_confirmed");
|
||||
}
|
||||
}
|
||||
|
||||
void VisualScriptPropertySelector::select_method_from_base_type(const String &p_base, const String &p_current, const bool p_virtuals_only, const bool p_connecting, bool clear_text) {
|
||||
base_type = p_base;
|
||||
selected = p_current;
|
||||
type = Variant::NIL;
|
||||
script = 0;
|
||||
properties = false;
|
||||
instance = nullptr;
|
||||
virtuals_only = p_virtuals_only;
|
||||
|
||||
show_window(.5f);
|
||||
if (clear_text) {
|
||||
search_box->set_text("");
|
||||
} else {
|
||||
search_box->select_all();
|
||||
}
|
||||
search_box->grab_focus();
|
||||
connecting = p_connecting;
|
||||
|
||||
_update_search();
|
||||
}
|
||||
|
||||
void VisualScriptPropertySelector::set_type_filter(const Vector<Variant::Type> &p_type_filter) {
|
||||
type_filter = p_type_filter;
|
||||
}
|
||||
|
||||
void VisualScriptPropertySelector::select_from_base_type(const String &p_base, const String &p_current, bool p_virtuals_only, bool p_seq_connect, const bool p_connecting, bool clear_text) {
|
||||
base_type = p_base;
|
||||
selected = p_current;
|
||||
type = Variant::NIL;
|
||||
script = 0;
|
||||
properties = true;
|
||||
visual_script_generic = false;
|
||||
instance = nullptr;
|
||||
virtuals_only = p_virtuals_only;
|
||||
|
||||
show_window(.5f);
|
||||
if (clear_text) {
|
||||
search_box->set_text("");
|
||||
} else {
|
||||
search_box->select_all();
|
||||
}
|
||||
search_box->grab_focus();
|
||||
seq_connect = p_seq_connect;
|
||||
connecting = p_connecting;
|
||||
|
||||
_update_search();
|
||||
}
|
||||
|
||||
void VisualScriptPropertySelector::select_from_script(const Ref<Script> &p_script, const String &p_current, const bool p_connecting, bool clear_text) {
|
||||
ERR_FAIL_COND(p_script.is_null());
|
||||
|
||||
base_type = p_script->get_instance_base_type();
|
||||
selected = p_current;
|
||||
type = Variant::NIL;
|
||||
script = p_script->get_instance_id();
|
||||
properties = true;
|
||||
visual_script_generic = false;
|
||||
instance = nullptr;
|
||||
virtuals_only = false;
|
||||
|
||||
show_window(.5f);
|
||||
if (clear_text) {
|
||||
search_box->set_text("");
|
||||
} else {
|
||||
search_box->select_all();
|
||||
}
|
||||
search_box->grab_focus();
|
||||
seq_connect = false;
|
||||
connecting = p_connecting;
|
||||
|
||||
_update_search();
|
||||
}
|
||||
|
||||
void VisualScriptPropertySelector::select_from_basic_type(Variant::Type p_type, const String &p_current, const bool p_connecting, bool clear_text) {
|
||||
ERR_FAIL_COND(p_type == Variant::NIL);
|
||||
base_type = "";
|
||||
selected = p_current;
|
||||
type = p_type;
|
||||
script = 0;
|
||||
properties = true;
|
||||
visual_script_generic = false;
|
||||
instance = nullptr;
|
||||
virtuals_only = false;
|
||||
|
||||
show_window(.5f);
|
||||
if (clear_text) {
|
||||
search_box->set_text("");
|
||||
} else {
|
||||
search_box->select_all();
|
||||
}
|
||||
search_box->grab_focus();
|
||||
seq_connect = false;
|
||||
connecting = p_connecting;
|
||||
|
||||
_update_search();
|
||||
}
|
||||
|
||||
void VisualScriptPropertySelector::select_from_action(const String &p_type, const String &p_current, const bool p_connecting, bool clear_text) {
|
||||
base_type = p_type;
|
||||
selected = p_current;
|
||||
type = Variant::NIL;
|
||||
script = 0;
|
||||
properties = false;
|
||||
visual_script_generic = false;
|
||||
instance = nullptr;
|
||||
virtuals_only = false;
|
||||
|
||||
show_window(.5f);
|
||||
if (clear_text) {
|
||||
search_box->set_text("");
|
||||
} else {
|
||||
search_box->select_all();
|
||||
}
|
||||
search_box->grab_focus();
|
||||
seq_connect = true;
|
||||
connecting = p_connecting;
|
||||
|
||||
_update_search();
|
||||
}
|
||||
|
||||
void VisualScriptPropertySelector::select_from_instance(Object *p_instance, const String &p_current, const bool p_connecting, const String &p_basetype, bool clear_text) {
|
||||
base_type = p_basetype;
|
||||
selected = p_current;
|
||||
type = Variant::NIL;
|
||||
script = 0;
|
||||
properties = true;
|
||||
visual_script_generic = false;
|
||||
instance = p_instance;
|
||||
virtuals_only = false;
|
||||
|
||||
show_window(.5f);
|
||||
if (clear_text) {
|
||||
search_box->set_text("");
|
||||
} else {
|
||||
search_box->select_all();
|
||||
}
|
||||
search_box->grab_focus();
|
||||
seq_connect = false;
|
||||
connecting = p_connecting;
|
||||
|
||||
_update_search();
|
||||
}
|
||||
|
||||
void VisualScriptPropertySelector::select_from_visual_script(const String &p_base, const bool p_connecting, bool clear_text) {
|
||||
base_type = p_base;
|
||||
selected = "";
|
||||
type = Variant::NIL;
|
||||
script = 0;
|
||||
properties = true;
|
||||
visual_script_generic = true;
|
||||
instance = nullptr;
|
||||
virtuals_only = false;
|
||||
show_window(.5f);
|
||||
if (clear_text) {
|
||||
search_box->set_text("");
|
||||
} else {
|
||||
search_box->select_all();
|
||||
}
|
||||
search_box->grab_focus();
|
||||
connecting = p_connecting;
|
||||
|
||||
_update_search();
|
||||
}
|
||||
|
||||
void VisualScriptPropertySelector::show_window(float p_screen_ratio) {
|
||||
Rect2 rect;
|
||||
Point2 window_size = get_viewport_rect().size;
|
||||
rect.size = (window_size * p_screen_ratio).floor();
|
||||
rect.size.x = rect.size.x / 2.2f;
|
||||
rect.position = ((window_size - rect.size) / 2.0f).floor();
|
||||
popup(rect);
|
||||
}
|
||||
|
||||
void VisualScriptPropertySelector::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_text_changed"), &VisualScriptPropertySelector::_text_changed);
|
||||
ClassDB::bind_method(D_METHOD("_confirmed"), &VisualScriptPropertySelector::_confirmed);
|
||||
ClassDB::bind_method(D_METHOD("_sbox_input"), &VisualScriptPropertySelector::_sbox_input);
|
||||
ClassDB::bind_method(D_METHOD("_item_selected"), &VisualScriptPropertySelector::_item_selected);
|
||||
|
||||
ADD_SIGNAL(MethodInfo("selected", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::STRING, "category"), PropertyInfo(Variant::BOOL, "connecting")));
|
||||
}
|
||||
|
||||
VisualScriptPropertySelector::VisualScriptPropertySelector() {
|
||||
VBoxContainer *vbc = memnew(VBoxContainer);
|
||||
add_child(vbc);
|
||||
//set_child_rect(vbc);
|
||||
search_box = memnew(LineEdit);
|
||||
vbc->add_margin_child(TTR("Search:"), search_box);
|
||||
search_box->connect("text_changed", this, "_text_changed");
|
||||
search_box->connect("gui_input", this, "_sbox_input");
|
||||
search_options = memnew(Tree);
|
||||
vbc->add_margin_child(TTR("Matches:"), search_options, true);
|
||||
get_ok()->set_text(TTR("Open"));
|
||||
get_ok()->set_disabled(true);
|
||||
register_text_enter(search_box);
|
||||
set_hide_on_ok(false);
|
||||
search_options->connect("item_activated", this, "_confirmed");
|
||||
search_options->connect("cell_selected", this, "_item_selected");
|
||||
search_options->set_hide_root(true);
|
||||
search_options->set_hide_folding(true);
|
||||
virtuals_only = false;
|
||||
seq_connect = false;
|
||||
help_bit = memnew(EditorHelpBit);
|
||||
vbc->add_margin_child(TTR("Description:"), help_bit);
|
||||
help_bit->connect("request_hide", this, "_closed");
|
||||
search_options->set_columns(3);
|
||||
search_options->set_column_expand(1, false);
|
||||
search_options->set_column_expand(2, false);
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* visual_script_property_selector.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef VISUALSCRIPT_PROPERTYSELECTOR_H
|
||||
#define VISUALSCRIPT_PROPERTYSELECTOR_H
|
||||
|
||||
#include "editor/editor_help.h"
|
||||
#include "editor/property_editor.h"
|
||||
#include "scene/gui/rich_text_label.h"
|
||||
|
||||
class VisualScriptPropertySelector : public ConfirmationDialog {
|
||||
GDCLASS(VisualScriptPropertySelector, ConfirmationDialog);
|
||||
|
||||
LineEdit *search_box;
|
||||
Tree *search_options;
|
||||
|
||||
void _update_search();
|
||||
|
||||
void create_visualscript_item(const String &name, TreeItem *const root, const String &search_input, const String &text);
|
||||
|
||||
void get_visual_node_names(const String &root_filter, const Set<String> &p_modifiers, bool &found, TreeItem *const root, LineEdit *const search_box);
|
||||
|
||||
void _sbox_input(const Ref<InputEvent> &p_ie);
|
||||
|
||||
void _confirmed();
|
||||
void _text_changed(const String &p_newtext);
|
||||
|
||||
EditorHelpBit *help_bit;
|
||||
|
||||
bool properties;
|
||||
bool visual_script_generic;
|
||||
bool connecting;
|
||||
String selected;
|
||||
Variant::Type type;
|
||||
String base_type;
|
||||
ObjectID script;
|
||||
Object *instance;
|
||||
bool virtuals_only;
|
||||
bool seq_connect;
|
||||
|
||||
void _item_selected();
|
||||
|
||||
Vector<Variant::Type> type_filter;
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void select_method_from_base_type(const String &p_base, const String &p_current = "", const bool p_virtuals_only = false, const bool p_connecting = true, bool clear_text = true);
|
||||
void select_from_base_type(const String &p_base, const String &p_current = "", bool p_virtuals_only = false, bool p_seq_connect = false, const bool p_connecting = true, bool clear_text = true);
|
||||
void select_from_script(const Ref<Script> &p_script, const String &p_current = "", const bool p_connecting = true, bool clear_text = true);
|
||||
void select_from_basic_type(Variant::Type p_type, const String &p_current = "", const bool p_connecting = true, bool clear_text = true);
|
||||
void select_from_action(const String &p_type, const String &p_current = "", const bool p_connecting = true, bool clear_text = true);
|
||||
void select_from_instance(Object *p_instance, const String &p_current = "", const bool p_connecting = true, const String &p_basetype = "", bool clear_text = true);
|
||||
void select_from_visual_script(const String &p_base, const bool p_connecting = true, bool clear_text = true);
|
||||
|
||||
void show_window(float p_screen_ratio);
|
||||
|
||||
void set_type_filter(const Vector<Variant::Type> &p_type_filter);
|
||||
|
||||
VisualScriptPropertySelector();
|
||||
};
|
||||
|
||||
#endif // VISUALSCRIPT_PROPERTYSELECTOR_H
|
@ -1,594 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* visual_script_yield_nodes.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "visual_script_yield_nodes.h"
|
||||
|
||||
#include "core/os/os.h"
|
||||
#include "scene/main/node.h"
|
||||
#include "scene/main/scene_tree.h"
|
||||
#include "visual_script_nodes.h"
|
||||
|
||||
//////////////////////////////////////////
|
||||
////////////////YIELD///////////
|
||||
//////////////////////////////////////////
|
||||
|
||||
int VisualScriptYield::get_output_sequence_port_count() const {
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool VisualScriptYield::has_input_sequence_port() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
int VisualScriptYield::get_input_value_port_count() const {
|
||||
return 0;
|
||||
}
|
||||
int VisualScriptYield::get_output_value_port_count() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
String VisualScriptYield::get_output_sequence_port_text(int p_port) const {
|
||||
return String();
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptYield::get_input_value_port_info(int p_idx) const {
|
||||
return PropertyInfo();
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptYield::get_output_value_port_info(int p_idx) const {
|
||||
return PropertyInfo();
|
||||
}
|
||||
|
||||
String VisualScriptYield::get_caption() const {
|
||||
return yield_mode == YIELD_RETURN ? RTR("Yield") : RTR("Wait");
|
||||
}
|
||||
|
||||
String VisualScriptYield::get_text() const {
|
||||
switch (yield_mode) {
|
||||
case YIELD_RETURN:
|
||||
return "";
|
||||
break;
|
||||
case YIELD_FRAME:
|
||||
return RTR("Next Frame");
|
||||
break;
|
||||
case YIELD_PHYSICS_FRAME:
|
||||
return RTR("Next Physics Frame");
|
||||
break;
|
||||
case YIELD_WAIT:
|
||||
return vformat(RTR("%s sec(s)"), rtos(wait_time));
|
||||
break;
|
||||
}
|
||||
|
||||
return String();
|
||||
}
|
||||
|
||||
class VisualScriptNodeInstanceYield : public VisualScriptNodeInstance {
|
||||
public:
|
||||
VisualScriptYield::YieldMode mode;
|
||||
float wait_time;
|
||||
|
||||
virtual int get_working_memory_size() const { return 1; } //yield needs at least 1
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return false; }
|
||||
|
||||
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
|
||||
if (p_start_mode == START_MODE_RESUME_YIELD) {
|
||||
return 0; //resuming yield
|
||||
} else {
|
||||
//yield
|
||||
|
||||
SceneTree *tree = Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop());
|
||||
if (!tree) {
|
||||
r_error_str = "Main Loop is not SceneTree";
|
||||
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Ref<VisualScriptFunctionState> state;
|
||||
state.instance();
|
||||
|
||||
int ret = STEP_YIELD_BIT;
|
||||
switch (mode) {
|
||||
case VisualScriptYield::YIELD_RETURN:
|
||||
ret = STEP_EXIT_FUNCTION_BIT;
|
||||
break; //return the yield
|
||||
case VisualScriptYield::YIELD_FRAME:
|
||||
state->connect_to_signal(tree, "idle_frame", Array());
|
||||
break;
|
||||
case VisualScriptYield::YIELD_PHYSICS_FRAME:
|
||||
state->connect_to_signal(tree, "physics_frame", Array());
|
||||
break;
|
||||
case VisualScriptYield::YIELD_WAIT:
|
||||
state->connect_to_signal(tree->create_timer(wait_time).ptr(), "timeout", Array());
|
||||
break;
|
||||
}
|
||||
|
||||
*p_working_mem = state;
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance *VisualScriptYield::instance(VisualScriptInstance *p_instance) {
|
||||
VisualScriptNodeInstanceYield *instance = memnew(VisualScriptNodeInstanceYield);
|
||||
//instance->instance=p_instance;
|
||||
instance->mode = yield_mode;
|
||||
instance->wait_time = wait_time;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void VisualScriptYield::set_yield_mode(YieldMode p_mode) {
|
||||
if (yield_mode == p_mode) {
|
||||
return;
|
||||
}
|
||||
yield_mode = p_mode;
|
||||
ports_changed_notify();
|
||||
_change_notify();
|
||||
}
|
||||
|
||||
VisualScriptYield::YieldMode VisualScriptYield::get_yield_mode() {
|
||||
return yield_mode;
|
||||
}
|
||||
|
||||
void VisualScriptYield::set_wait_time(float p_time) {
|
||||
if (wait_time == p_time) {
|
||||
return;
|
||||
}
|
||||
wait_time = p_time;
|
||||
ports_changed_notify();
|
||||
}
|
||||
|
||||
float VisualScriptYield::get_wait_time() {
|
||||
return wait_time;
|
||||
}
|
||||
|
||||
void VisualScriptYield::_validate_property(PropertyInfo &property) const {
|
||||
if (property.name == "wait_time") {
|
||||
if (yield_mode != YIELD_WAIT) {
|
||||
property.usage = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VisualScriptYield::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_yield_mode", "mode"), &VisualScriptYield::set_yield_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_yield_mode"), &VisualScriptYield::get_yield_mode);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_wait_time", "sec"), &VisualScriptYield::set_wait_time);
|
||||
ClassDB::bind_method(D_METHOD("get_wait_time"), &VisualScriptYield::get_wait_time);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Frame,Physics Frame,Time", PROPERTY_USAGE_NOEDITOR), "set_yield_mode", "get_yield_mode");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "wait_time"), "set_wait_time", "get_wait_time");
|
||||
|
||||
BIND_ENUM_CONSTANT(YIELD_FRAME);
|
||||
BIND_ENUM_CONSTANT(YIELD_PHYSICS_FRAME);
|
||||
BIND_ENUM_CONSTANT(YIELD_WAIT);
|
||||
}
|
||||
|
||||
VisualScriptYield::VisualScriptYield() {
|
||||
yield_mode = YIELD_FRAME;
|
||||
wait_time = 1;
|
||||
}
|
||||
|
||||
template <VisualScriptYield::YieldMode MODE>
|
||||
static Ref<VisualScriptNode> create_yield_node(const String &p_name) {
|
||||
Ref<VisualScriptYield> node;
|
||||
node.instance();
|
||||
node->set_yield_mode(MODE);
|
||||
return node;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
////////////////YIELD SIGNAL//////////////////////
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
int VisualScriptYieldSignal::get_output_sequence_port_count() const {
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool VisualScriptYieldSignal::has_input_sequence_port() const {
|
||||
return true;
|
||||
}
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) {
|
||||
if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Ref<Script> scr = p_current_node->get_script();
|
||||
|
||||
if (scr.is_valid() && scr == script) {
|
||||
return p_current_node;
|
||||
}
|
||||
|
||||
for (int i = 0; i < p_current_node->get_child_count(); i++) {
|
||||
Node *n = _find_script_node(p_edited_scene, p_current_node->get_child(i), script);
|
||||
if (n) {
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
Node *VisualScriptYieldSignal::_get_base_node() const {
|
||||
#ifdef TOOLS_ENABLED
|
||||
Ref<Script> script = get_visual_script();
|
||||
if (!script.is_valid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MainLoop *main_loop = OS::get_singleton()->get_main_loop();
|
||||
SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop);
|
||||
|
||||
if (!scene_tree) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Node *edited_scene = scene_tree->get_edited_scene_root();
|
||||
|
||||
if (!edited_scene) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Node *script_node = _find_script_node(edited_scene, edited_scene, script);
|
||||
|
||||
if (!script_node) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!script_node->has_node(base_path)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Node *path_to = script_node->get_node(base_path);
|
||||
|
||||
return path_to;
|
||||
#else
|
||||
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
StringName VisualScriptYieldSignal::_get_base_type() const {
|
||||
if (call_mode == CALL_MODE_SELF && get_visual_script().is_valid()) {
|
||||
return get_visual_script()->get_instance_base_type();
|
||||
} else if (call_mode == CALL_MODE_NODE_PATH && get_visual_script().is_valid()) {
|
||||
Node *path = _get_base_node();
|
||||
if (path) {
|
||||
return path->get_class();
|
||||
}
|
||||
}
|
||||
|
||||
return base_type;
|
||||
}
|
||||
|
||||
int VisualScriptYieldSignal::get_input_value_port_count() const {
|
||||
if (call_mode == CALL_MODE_INSTANCE) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
int VisualScriptYieldSignal::get_output_value_port_count() const {
|
||||
MethodInfo sr;
|
||||
|
||||
if (!ClassDB::get_signal(_get_base_type(), signal, &sr)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return sr.arguments.size();
|
||||
}
|
||||
|
||||
String VisualScriptYieldSignal::get_output_sequence_port_text(int p_port) const {
|
||||
return String();
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptYieldSignal::get_input_value_port_info(int p_idx) const {
|
||||
if (call_mode == CALL_MODE_INSTANCE) {
|
||||
return PropertyInfo(Variant::OBJECT, "instance");
|
||||
} else {
|
||||
return PropertyInfo();
|
||||
}
|
||||
}
|
||||
|
||||
PropertyInfo VisualScriptYieldSignal::get_output_value_port_info(int p_idx) const {
|
||||
MethodInfo sr;
|
||||
|
||||
if (!ClassDB::get_signal(_get_base_type(), signal, &sr)) {
|
||||
return PropertyInfo(); //no signal
|
||||
}
|
||||
ERR_FAIL_INDEX_V(p_idx, sr.arguments.size(), PropertyInfo());
|
||||
return sr.arguments[p_idx];
|
||||
}
|
||||
|
||||
String VisualScriptYieldSignal::get_caption() const {
|
||||
switch (call_mode) {
|
||||
case CALL_MODE_SELF: {
|
||||
return RTR("WaitSignal");
|
||||
} break;
|
||||
case CALL_MODE_NODE_PATH: {
|
||||
return RTR("WaitNodeSignal");
|
||||
} break;
|
||||
case CALL_MODE_INSTANCE: {
|
||||
return RTR("WaitInstanceSignal");
|
||||
} break;
|
||||
}
|
||||
return String();
|
||||
}
|
||||
|
||||
String VisualScriptYieldSignal::get_text() const {
|
||||
if (call_mode == CALL_MODE_SELF) {
|
||||
return " " + String(signal) + "()";
|
||||
} else {
|
||||
return " " + _get_base_type() + "." + String(signal) + "()";
|
||||
}
|
||||
}
|
||||
|
||||
void VisualScriptYieldSignal::set_base_type(const StringName &p_type) {
|
||||
if (base_type == p_type) {
|
||||
return;
|
||||
}
|
||||
|
||||
base_type = p_type;
|
||||
|
||||
_change_notify();
|
||||
ports_changed_notify();
|
||||
}
|
||||
|
||||
StringName VisualScriptYieldSignal::get_base_type() const {
|
||||
return base_type;
|
||||
}
|
||||
|
||||
void VisualScriptYieldSignal::set_signal(const StringName &p_type) {
|
||||
if (signal == p_type) {
|
||||
return;
|
||||
}
|
||||
|
||||
signal = p_type;
|
||||
|
||||
_change_notify();
|
||||
ports_changed_notify();
|
||||
}
|
||||
StringName VisualScriptYieldSignal::get_signal() const {
|
||||
return signal;
|
||||
}
|
||||
|
||||
void VisualScriptYieldSignal::set_base_path(const NodePath &p_type) {
|
||||
if (base_path == p_type) {
|
||||
return;
|
||||
}
|
||||
|
||||
base_path = p_type;
|
||||
|
||||
_change_notify();
|
||||
ports_changed_notify();
|
||||
}
|
||||
|
||||
NodePath VisualScriptYieldSignal::get_base_path() const {
|
||||
return base_path;
|
||||
}
|
||||
|
||||
void VisualScriptYieldSignal::set_call_mode(CallMode p_mode) {
|
||||
if (call_mode == p_mode) {
|
||||
return;
|
||||
}
|
||||
|
||||
call_mode = p_mode;
|
||||
|
||||
_change_notify();
|
||||
ports_changed_notify();
|
||||
}
|
||||
|
||||
VisualScriptYieldSignal::CallMode VisualScriptYieldSignal::get_call_mode() const {
|
||||
return call_mode;
|
||||
}
|
||||
|
||||
void VisualScriptYieldSignal::_validate_property(PropertyInfo &property) const {
|
||||
if (property.name == "base_type") {
|
||||
if (call_mode != CALL_MODE_INSTANCE) {
|
||||
property.usage = PROPERTY_USAGE_NOEDITOR;
|
||||
}
|
||||
}
|
||||
|
||||
if (property.name == "node_path") {
|
||||
if (call_mode != CALL_MODE_NODE_PATH) {
|
||||
property.usage = 0;
|
||||
} else {
|
||||
Node *bnode = _get_base_node();
|
||||
if (bnode) {
|
||||
property.hint_string = bnode->get_path(); //convert to loong string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (property.name == "signal") {
|
||||
property.hint = PROPERTY_HINT_ENUM;
|
||||
|
||||
List<MethodInfo> methods;
|
||||
|
||||
ClassDB::get_signal_list(_get_base_type(), &methods);
|
||||
|
||||
List<String> mstring;
|
||||
for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) {
|
||||
if (E->get().name.begins_with("_")) {
|
||||
continue;
|
||||
}
|
||||
mstring.push_back(E->get().name.get_slice(":", 0));
|
||||
}
|
||||
|
||||
mstring.sort();
|
||||
|
||||
String ml;
|
||||
for (List<String>::Element *E = mstring.front(); E; E = E->next()) {
|
||||
if (ml != String()) {
|
||||
ml += ",";
|
||||
}
|
||||
ml += E->get();
|
||||
}
|
||||
|
||||
property.hint_string = ml;
|
||||
}
|
||||
}
|
||||
|
||||
void VisualScriptYieldSignal::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_base_type", "base_type"), &VisualScriptYieldSignal::set_base_type);
|
||||
ClassDB::bind_method(D_METHOD("get_base_type"), &VisualScriptYieldSignal::get_base_type);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_signal", "signal"), &VisualScriptYieldSignal::set_signal);
|
||||
ClassDB::bind_method(D_METHOD("get_signal"), &VisualScriptYieldSignal::get_signal);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_call_mode", "mode"), &VisualScriptYieldSignal::set_call_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_call_mode"), &VisualScriptYieldSignal::get_call_mode);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_base_path", "base_path"), &VisualScriptYieldSignal::set_base_path);
|
||||
ClassDB::bind_method(D_METHOD("get_base_path"), &VisualScriptYieldSignal::get_base_path);
|
||||
|
||||
String bt;
|
||||
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
|
||||
if (i > 0) {
|
||||
bt += ",";
|
||||
}
|
||||
|
||||
bt += Variant::get_type_name(Variant::Type(i));
|
||||
}
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "call_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance"), "set_call_mode", "get_call_mode");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "signal"), "set_signal", "get_signal");
|
||||
|
||||
BIND_ENUM_CONSTANT(CALL_MODE_SELF);
|
||||
BIND_ENUM_CONSTANT(CALL_MODE_NODE_PATH);
|
||||
BIND_ENUM_CONSTANT(CALL_MODE_INSTANCE);
|
||||
}
|
||||
|
||||
class VisualScriptNodeInstanceYieldSignal : public VisualScriptNodeInstance {
|
||||
public:
|
||||
VisualScriptYieldSignal::CallMode call_mode;
|
||||
NodePath node_path;
|
||||
int output_args;
|
||||
StringName signal;
|
||||
|
||||
VisualScriptYieldSignal *node;
|
||||
VisualScriptInstance *instance;
|
||||
|
||||
virtual int get_working_memory_size() const { return 1; }
|
||||
//virtual bool is_output_port_unsequenced(int p_idx) const { return false; }
|
||||
//virtual bool get_output_port_unsequenced(int p_idx,Variant* r_value,Variant* p_working_mem,String &r_error) const { return true; }
|
||||
|
||||
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
|
||||
if (p_start_mode == START_MODE_RESUME_YIELD) {
|
||||
return 0; //resuming yield
|
||||
} else {
|
||||
//yield
|
||||
|
||||
Object *object = nullptr;
|
||||
|
||||
switch (call_mode) {
|
||||
case VisualScriptYieldSignal::CALL_MODE_SELF: {
|
||||
object = instance->get_owner_ptr();
|
||||
|
||||
} break;
|
||||
case VisualScriptYieldSignal::CALL_MODE_NODE_PATH: {
|
||||
Node *node = Object::cast_to<Node>(instance->get_owner_ptr());
|
||||
if (!node) {
|
||||
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str = "Base object is not a Node!";
|
||||
return 0;
|
||||
}
|
||||
|
||||
Node *another = node->get_node(node_path);
|
||||
if (!another) {
|
||||
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str = "Path does not lead Node!";
|
||||
return 0;
|
||||
}
|
||||
|
||||
object = another;
|
||||
|
||||
} break;
|
||||
case VisualScriptYieldSignal::CALL_MODE_INSTANCE: {
|
||||
object = *p_inputs[0];
|
||||
if (!object) {
|
||||
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
r_error_str = "Supplied instance input is null.";
|
||||
return 0;
|
||||
}
|
||||
|
||||
} break;
|
||||
}
|
||||
|
||||
Ref<VisualScriptFunctionState> state;
|
||||
state.instance();
|
||||
|
||||
state->connect_to_signal(object, signal, Array());
|
||||
|
||||
*p_working_mem = state;
|
||||
|
||||
return STEP_YIELD_BIT;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
VisualScriptNodeInstance *VisualScriptYieldSignal::instance(VisualScriptInstance *p_instance) {
|
||||
VisualScriptNodeInstanceYieldSignal *instance = memnew(VisualScriptNodeInstanceYieldSignal);
|
||||
instance->node = this;
|
||||
instance->instance = p_instance;
|
||||
instance->signal = signal;
|
||||
instance->call_mode = call_mode;
|
||||
instance->node_path = base_path;
|
||||
instance->output_args = get_output_value_port_count();
|
||||
return instance;
|
||||
}
|
||||
VisualScriptYieldSignal::VisualScriptYieldSignal() {
|
||||
call_mode = CALL_MODE_SELF;
|
||||
base_type = "Object";
|
||||
}
|
||||
|
||||
template <VisualScriptYieldSignal::CallMode cmode>
|
||||
static Ref<VisualScriptNode> create_yield_signal_node(const String &p_name) {
|
||||
Ref<VisualScriptYieldSignal> node;
|
||||
node.instance();
|
||||
node->set_call_mode(cmode);
|
||||
return node;
|
||||
}
|
||||
|
||||
void register_visual_script_yield_nodes() {
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/wait/wait_frame", create_yield_node<VisualScriptYield::YIELD_FRAME>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/wait/wait_physics_frame", create_yield_node<VisualScriptYield::YIELD_PHYSICS_FRAME>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/wait/wait_time", create_yield_node<VisualScriptYield::YIELD_WAIT>);
|
||||
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/yield", create_yield_node<VisualScriptYield::YIELD_RETURN>);
|
||||
VisualScriptLanguage::singleton->add_register_func("functions/yield_signal", create_node_generic<VisualScriptYieldSignal>);
|
||||
}
|
@ -1,147 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* visual_script_yield_nodes.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef VISUAL_SCRIPT_YIELD_NODES_H
|
||||
#define VISUAL_SCRIPT_YIELD_NODES_H
|
||||
|
||||
#include "visual_script.h"
|
||||
|
||||
class VisualScriptYield : public VisualScriptNode {
|
||||
GDCLASS(VisualScriptYield, VisualScriptNode);
|
||||
|
||||
public:
|
||||
enum YieldMode {
|
||||
YIELD_RETURN,
|
||||
YIELD_FRAME,
|
||||
YIELD_PHYSICS_FRAME,
|
||||
YIELD_WAIT
|
||||
|
||||
};
|
||||
|
||||
private:
|
||||
YieldMode yield_mode;
|
||||
float wait_time;
|
||||
|
||||
protected:
|
||||
virtual void _validate_property(PropertyInfo &property) const;
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual int get_output_sequence_port_count() const;
|
||||
virtual bool has_input_sequence_port() const;
|
||||
|
||||
virtual String get_output_sequence_port_text(int p_port) const;
|
||||
|
||||
virtual int get_input_value_port_count() const;
|
||||
virtual int get_output_value_port_count() const;
|
||||
|
||||
virtual PropertyInfo get_input_value_port_info(int p_idx) const;
|
||||
virtual PropertyInfo get_output_value_port_info(int p_idx) const;
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "functions"; }
|
||||
|
||||
void set_yield_mode(YieldMode p_mode);
|
||||
YieldMode get_yield_mode();
|
||||
|
||||
void set_wait_time(float p_time);
|
||||
float get_wait_time();
|
||||
|
||||
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
|
||||
|
||||
VisualScriptYield();
|
||||
};
|
||||
VARIANT_ENUM_CAST(VisualScriptYield::YieldMode)
|
||||
|
||||
class VisualScriptYieldSignal : public VisualScriptNode {
|
||||
GDCLASS(VisualScriptYieldSignal, VisualScriptNode);
|
||||
|
||||
public:
|
||||
enum CallMode {
|
||||
CALL_MODE_SELF,
|
||||
CALL_MODE_NODE_PATH,
|
||||
CALL_MODE_INSTANCE,
|
||||
|
||||
};
|
||||
|
||||
private:
|
||||
CallMode call_mode;
|
||||
StringName base_type;
|
||||
NodePath base_path;
|
||||
StringName signal;
|
||||
|
||||
Node *_get_base_node() const;
|
||||
StringName _get_base_type() const;
|
||||
|
||||
protected:
|
||||
virtual void _validate_property(PropertyInfo &property) const;
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual int get_output_sequence_port_count() const;
|
||||
virtual bool has_input_sequence_port() const;
|
||||
|
||||
virtual String get_output_sequence_port_text(int p_port) const;
|
||||
|
||||
virtual int get_input_value_port_count() const;
|
||||
virtual int get_output_value_port_count() const;
|
||||
|
||||
virtual PropertyInfo get_input_value_port_info(int p_idx) const;
|
||||
virtual PropertyInfo get_output_value_port_info(int p_idx) const;
|
||||
|
||||
virtual String get_caption() const;
|
||||
virtual String get_text() const;
|
||||
virtual String get_category() const { return "functions"; }
|
||||
|
||||
void set_base_type(const StringName &p_type);
|
||||
StringName get_base_type() const;
|
||||
|
||||
void set_signal(const StringName &p_type);
|
||||
StringName get_signal() const;
|
||||
|
||||
void set_base_path(const NodePath &p_type);
|
||||
NodePath get_base_path() const;
|
||||
|
||||
void set_call_mode(CallMode p_mode);
|
||||
CallMode get_call_mode() const;
|
||||
|
||||
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
|
||||
|
||||
VisualScriptYieldSignal();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(VisualScriptYieldSignal::CallMode);
|
||||
|
||||
void register_visual_script_yield_nodes();
|
||||
|
||||
#endif // VISUAL_SCRIPT_YIELD_NODES_H
|
Loading…
Reference in New Issue
Block a user