summaryrefslogtreecommitdiff
path: root/modules/visual_script
diff options
context:
space:
mode:
Diffstat (limited to 'modules/visual_script')
-rw-r--r--modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml78
-rw-r--r--modules/visual_script/doc_classes/VisualScriptCustomNode.xml34
-rw-r--r--modules/visual_script/editor/visual_script_editor.cpp474
-rw-r--r--modules/visual_script/editor/visual_script_editor.h103
-rw-r--r--modules/visual_script/editor/visual_script_property_selector.cpp1632
-rw-r--r--modules/visual_script/editor/visual_script_property_selector.h178
-rw-r--r--modules/visual_script/icons/VisualScript.svg2
-rw-r--r--modules/visual_script/icons/VisualScriptInternal.svg1
-rw-r--r--modules/visual_script/register_types.cpp4
-rw-r--r--modules/visual_script/register_types.h4
-rw-r--r--modules/visual_script/visual_script.cpp22
-rw-r--r--modules/visual_script/visual_script.h83
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.cpp6
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.h4
-rw-r--r--modules/visual_script/visual_script_expression.cpp65
-rw-r--r--modules/visual_script/visual_script_expression.h4
-rw-r--r--modules/visual_script/visual_script_flow_control.cpp32
-rw-r--r--modules/visual_script/visual_script_flow_control.h4
-rw-r--r--modules/visual_script/visual_script_func_nodes.cpp54
-rw-r--r--modules/visual_script/visual_script_func_nodes.h4
-rw-r--r--modules/visual_script/visual_script_nodes.cpp66
-rw-r--r--modules/visual_script/visual_script_nodes.h4
-rw-r--r--modules/visual_script/visual_script_yield_nodes.cpp20
-rw-r--r--modules/visual_script/visual_script_yield_nodes.h4
24 files changed, 1890 insertions, 992 deletions
diff --git a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml
index b3fd678379..1ac5768755 100644
--- a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml
+++ b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml
@@ -16,85 +16,85 @@
</members>
<constants>
<constant name="MATH_SIN" value="0" enum="BuiltinFunc">
- Return the sine of the input.
+ Returns the sine of the input.
</constant>
<constant name="MATH_COS" value="1" enum="BuiltinFunc">
- Return the cosine of the input.
+ Returns the cosine of the input.
</constant>
<constant name="MATH_TAN" value="2" enum="BuiltinFunc">
- Return the tangent of the input.
+ Returns the tangent of the input.
</constant>
<constant name="MATH_SINH" value="3" enum="BuiltinFunc">
- Return the hyperbolic sine of the input.
+ Returns the hyperbolic sine of the input.
</constant>
<constant name="MATH_COSH" value="4" enum="BuiltinFunc">
- Return the hyperbolic cosine of the input.
+ Returns the hyperbolic cosine of the input.
</constant>
<constant name="MATH_TANH" value="5" enum="BuiltinFunc">
- Return the hyperbolic tangent of the input.
+ Returns the hyperbolic tangent of the input.
</constant>
<constant name="MATH_ASIN" value="6" enum="BuiltinFunc">
- Return the arc sine of the input.
+ Returns the arc sine of the input.
</constant>
<constant name="MATH_ACOS" value="7" enum="BuiltinFunc">
- Return the arc cosine of the input.
+ Returns the arc cosine of the input.
</constant>
<constant name="MATH_ATAN" value="8" enum="BuiltinFunc">
- Return the arc tangent of the input.
+ Returns 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.
+ Returns 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.
+ Returns 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.
+ Returns 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.
+ Returns 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.
+ Returns the input rounded down.
</constant>
<constant name="MATH_CEIL" value="14" enum="BuiltinFunc">
- Return the input rounded up.
+ Returns the input rounded up.
</constant>
<constant name="MATH_ROUND" value="15" enum="BuiltinFunc">
- Return the input rounded to the nearest integer.
+ Returns the input rounded to the nearest integer.
</constant>
<constant name="MATH_ABS" value="16" enum="BuiltinFunc">
- Return the absolute value of the input.
+ Returns 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.
+ Returns 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.
+ Returns 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.
+ Returns 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.
+ Returns 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.
+ Returns 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.
+ Returns 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_STEP_DECIMALS" value="24" enum="BuiltinFunc">
- Return the number of digit places after the decimal that the first non-zero digit occurs.
+ Returns the number of digit places after the decimal that the first non-zero digit occurs.
</constant>
<constant name="MATH_SNAPPED" value="25" enum="BuiltinFunc">
- Return the input snapped to a given step.
+ Returns 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].
+ Returns 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>
@@ -107,16 +107,16 @@
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_RANDI" value="31" 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.
+ Returns 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="32" 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.
+ Returns 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_RANDI_RANGE" value="33" enum="BuiltinFunc">
- Return a random 32-bit integer value between the two inputs.
+ Returns a random 32-bit integer value between the two inputs.
</constant>
<constant name="MATH_RANDF_RANGE" value="34" enum="BuiltinFunc">
- Return a random floating-point value between the two inputs.
+ Returns a random floating-point value between the two inputs.
</constant>
<constant name="MATH_RANDFN" value="35" enum="BuiltinFunc">
Returns a normally-distributed pseudo-random number, using Box-Muller transform with the specified mean and a standard deviation. This is also called Gaussian distribution.
@@ -125,7 +125,7 @@
Set the seed for the random number generator.
</constant>
<constant name="MATH_RANDSEED" value="37" enum="BuiltinFunc">
- Return a random value from the given seed, along with the new seed.
+ Returns a random value from the given seed, along with the new seed.
</constant>
<constant name="MATH_DEG2RAD" value="38" enum="BuiltinFunc">
Convert the input from degrees to radians.
@@ -144,19 +144,19 @@
<constant name="MATH_WRAPF" value="43" enum="BuiltinFunc">
</constant>
<constant name="MATH_PINGPONG" value="44" enum="BuiltinFunc">
- Return the [code]value[/code] wrapped between [code]0[/code] and the [code]length[/code]. If the limit is reached, the next value the function returned is decreased to the [code]0[/code] side or increased to the [code]length[/code] side (like a triangle wave). If [code]length[/code] is less than zero, it becomes positive.
+ Returns the [code]value[/code] wrapped between [code]0[/code] and the [code]length[/code]. If the limit is reached, the next value the function returned is decreased to the [code]0[/code] side or increased to the [code]length[/code] side (like a triangle wave). If [code]length[/code] is less than zero, it becomes positive.
</constant>
<constant name="LOGIC_MAX" value="45" enum="BuiltinFunc">
- Return the greater of the two numbers, also known as their maximum.
+ Returns 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.
+ Returns 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].
+ Returns 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.
+ Returns the nearest power of 2 to the input.
</constant>
<constant name="OBJ_WEAKREF" value="49" enum="BuiltinFunc">
Create a [WeakRef] from the input.
@@ -165,13 +165,13 @@
Convert between types.
</constant>
<constant name="TYPE_OF" value="51" enum="BuiltinFunc">
- Return the type of the input as an integer. Check [enum Variant.Type] for the integers that might be returned.
+ Returns 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="52" enum="BuiltinFunc">
Checks if a type is registered in the [ClassDB].
</constant>
<constant name="TEXT_CHAR" value="53" enum="BuiltinFunc">
- Return a character with the given ascii value.
+ Returns a character with the given ascii value.
</constant>
<constant name="TEXT_STR" value="54" enum="BuiltinFunc">
Convert the input to a string.
@@ -200,7 +200,7 @@
Deserialize a [Variant] from a [PackedByteArray] serialized using [constant VAR_TO_BYTES].
</constant>
<constant name="MATH_SMOOTHSTEP" value="63" 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:
+ Returns 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)
diff --git a/modules/visual_script/doc_classes/VisualScriptCustomNode.xml b/modules/visual_script/doc_classes/VisualScriptCustomNode.xml
index 2c6313c80a..486f60400a 100644
--- a/modules/visual_script/doc_classes/VisualScriptCustomNode.xml
+++ b/modules/visual_script/doc_classes/VisualScriptCustomNode.xml
@@ -12,112 +12,112 @@
<method name="_get_caption" qualifiers="virtual const">
<return type="String" />
<description>
- Return the node's title.
+ Returns the node's title.
</description>
</method>
<method name="_get_category" qualifiers="virtual const">
<return type="String" />
<description>
- Return the node's category.
+ Returns the node's category.
</description>
</method>
<method name="_get_input_value_port_count" qualifiers="virtual const">
<return type="int" />
<description>
- Return the count of input value ports.
+ Returns the count of input value ports.
</description>
</method>
<method name="_get_input_value_port_hint" qualifiers="virtual const">
<return type="int" />
<argument index="0" name="input_idx" type="int" />
<description>
- Return the specified input port's hint. See the [enum @GlobalScope.PropertyHint] hints.
+ Returns the specified input port's hint. See the [enum @GlobalScope.PropertyHint] hints.
</description>
</method>
<method name="_get_input_value_port_hint_string" qualifiers="virtual const">
<return type="String" />
<argument index="0" name="input_idx" type="int" />
<description>
- Return the specified input port's hint string.
+ Returns the specified input port's hint string.
</description>
</method>
<method name="_get_input_value_port_name" qualifiers="virtual const">
<return type="String" />
<argument index="0" name="input_idx" type="int" />
<description>
- Return the specified input port's name.
+ Returns the specified input port's name.
</description>
</method>
<method name="_get_input_value_port_type" qualifiers="virtual const">
<return type="int" />
<argument index="0" name="input_idx" type="int" />
<description>
- Return the specified input port's type. See the [enum Variant.Type] values.
+ Returns the specified input port's type. See the [enum Variant.Type] values.
</description>
</method>
<method name="_get_output_sequence_port_count" qualifiers="virtual const">
<return type="int" />
<description>
- Return the amount of output [b]sequence[/b] ports.
+ Returns the amount of output [b]sequence[/b] ports.
</description>
</method>
<method name="_get_output_sequence_port_text" qualifiers="virtual const">
<return type="String" />
<argument index="0" name="seq_idx" type="int" />
<description>
- Return the specified [b]sequence[/b] output's name.
+ Returns the specified [b]sequence[/b] output's name.
</description>
</method>
<method name="_get_output_value_port_count" qualifiers="virtual const">
<return type="int" />
<description>
- Return the amount of output value ports.
+ Returns the amount of output value ports.
</description>
</method>
<method name="_get_output_value_port_hint" qualifiers="virtual const">
<return type="int" />
<argument index="0" name="output_idx" type="int" />
<description>
- Return the specified output port's hint. See the [enum @GlobalScope.PropertyHint] hints.
+ Returns the specified output port's hint. See the [enum @GlobalScope.PropertyHint] hints.
</description>
</method>
<method name="_get_output_value_port_hint_string" qualifiers="virtual const">
<return type="String" />
<argument index="0" name="output_idx" type="int" />
<description>
- Return the specified output port's hint string.
+ Returns the specified output port's hint string.
</description>
</method>
<method name="_get_output_value_port_name" qualifiers="virtual const">
<return type="String" />
<argument index="0" name="output_idx" type="int" />
<description>
- Return the specified output port's name.
+ Returns the specified output port's name.
</description>
</method>
<method name="_get_output_value_port_type" qualifiers="virtual const">
<return type="int" />
<argument index="0" name="output_idx" type="int" />
<description>
- Return the specified output port's type. See the [enum Variant.Type] values.
+ Returns the specified output port's type. See the [enum Variant.Type] values.
</description>
</method>
<method name="_get_text" qualifiers="virtual const">
<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).
+ Returns 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 const">
<return type="int" />
<description>
- Return the size of the custom node's working memory. See [method _step] for more details.
+ Returns 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 const">
<return type="bool" />
<description>
- Return whether the custom node has an input [b]sequence[/b] port.
+ Returns whether the custom node has an input [b]sequence[/b] port.
</description>
</method>
<method name="_step" qualifiers="virtual const">
diff --git a/modules/visual_script/editor/visual_script_editor.cpp b/modules/visual_script/editor/visual_script_editor.cpp
index 9deea79ea6..5ea8eaff00 100644
--- a/modules/visual_script/editor/visual_script_editor.cpp
+++ b/modules/visual_script/editor/visual_script_editor.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -42,6 +42,7 @@
#include "editor/editor_node.h"
#include "editor/editor_resource_preview.h"
#include "editor/editor_scale.h"
+#include "scene/gui/view_panner.h"
#include "scene/main/window.h"
#ifdef TOOLS_ENABLED
@@ -271,7 +272,7 @@ protected:
if (String(p_name) == "export") {
script->set_variable_export(var, p_value);
- EditorNode::get_singleton()->get_inspector()->update_tree();
+ InspectorDock::get_inspector_singleton()->update_tree();
return true;
}
@@ -652,7 +653,6 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
List<int> ids;
script->get_node_list(&ids);
- StringName editor_icons = "EditorIcons";
for (int &E : ids) {
if (p_only_id >= 0 && p_only_id != E) {
@@ -1366,7 +1366,7 @@ void VisualScriptEditor::_create_function() {
}
void VisualScriptEditor::_add_node_dialog() {
- _generic_search(script->get_instance_base_type(), graph->get_global_position() + Vector2(55, 80), true);
+ _generic_search(graph->get_global_position() + Vector2(55, 80), true);
}
void VisualScriptEditor::_add_func_input() {
@@ -1442,7 +1442,7 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
if (p_button == 1) {
// Ensure script base exists otherwise use custom base type.
ERR_FAIL_COND(script.is_null());
- new_virtual_method_select->select_method_from_base_type(script->get_instance_base_type(), String(), true);
+ new_virtual_method_select->select_method_from_base_type(script->get_instance_base_type(), true);
return;
} else if (p_button == 0) {
String name = _validate_name("new_function");
@@ -1948,14 +1948,14 @@ void VisualScriptEditor::_on_nodes_duplicate() {
}
}
-void VisualScriptEditor::_generic_search(String p_base_type, Vector2 pos, bool node_centered) {
+void VisualScriptEditor::_generic_search(Vector2 pos, bool node_centered) {
if (node_centered) {
port_action_pos = graph->get_size() / 2.0f;
} else {
port_action_pos = graph->get_viewport()->get_mouse_position() - graph->get_global_position();
}
- new_connect_node_select->select_from_visual_script(p_base_type, false, false); // neither connecting nor reset text
+ new_connect_node_select->select_from_visual_script(script, false); // do not reset text
// Ensure that the dialog fits inside the graph.
Size2 bounds = graph->get_global_position() + graph->get_size() - new_connect_node_select->get_size();
@@ -1973,7 +1973,7 @@ void VisualScriptEditor::input(const Ref<InputEvent> &p_event) {
// GUI input for VS Editor Plugin
Ref<InputEventMouseButton> key = p_event;
- if (key.is_valid() && !key->is_pressed()) {
+ if (key.is_valid() && key->is_pressed()) {
mouse_up_position = get_screen_position() + get_local_mouse_position();
}
}
@@ -1982,10 +1982,28 @@ void VisualScriptEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> key = p_event;
if (key.is_valid() && key->is_pressed() && key->get_button_mask() == MouseButton::RIGHT) {
- saved_position = graph->get_local_mouse_position();
+ bool is_empty_selection = true;
- Point2 gpos = get_screen_position() + get_local_mouse_position();
- _generic_search(script->get_instance_base_type(), gpos);
+ for (int i = 0; i < graph->get_child_count(); i++) {
+ GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
+ if (gn && gn->is_selected()) {
+ is_empty_selection = false;
+ break;
+ }
+ }
+ if (is_empty_selection && clipboard->nodes.is_empty()) {
+ _generic_search();
+ } else {
+ popup_menu->set_item_disabled(int(EDIT_CUT_NODES), is_empty_selection);
+ popup_menu->set_item_disabled(int(EDIT_COPY_NODES), is_empty_selection);
+ popup_menu->set_item_disabled(int(EDIT_PASTE_NODES), clipboard->nodes.is_empty());
+ popup_menu->set_item_disabled(int(EDIT_DELETE_NODES), is_empty_selection);
+ popup_menu->set_item_disabled(int(EDIT_DUPLICATE_NODES), is_empty_selection);
+ popup_menu->set_item_disabled(int(EDIT_CLEAR_COPY_BUFFER), clipboard->nodes.is_empty());
+
+ popup_menu->set_position(mouse_up_position);
+ popup_menu->popup();
+ }
}
}
@@ -2428,7 +2446,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
drop_position = pos;
drop_node = node;
drop_path = sn->get_path_to(node);
- new_connect_node_select->select_from_instance(node, "", false, node->get_class());
+ new_connect_node_select->select_from_instance(node, false);
}
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
@@ -2637,6 +2655,15 @@ String VisualScriptEditor::get_name() {
}
Ref<Texture2D> VisualScriptEditor::get_theme_icon() {
+ String icon_name = "VisualScript";
+ if (script->is_built_in()) {
+ icon_name += "Internal";
+ }
+
+ if (Control::has_theme_icon(icon_name, "EditorIcons")) {
+ return Control::get_theme_icon(icon_name, SNAME("EditorIcons"));
+ }
+
return Control::get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons"));
}
@@ -2775,7 +2802,7 @@ void VisualScriptEditor::add_callback(const String &p_function, PackedStringArra
String name = p_args[i];
Variant::Type type = Variant::NIL;
- if (name.find(":") != -1) {
+ if (name.contains(":")) {
String tt = name.get_slice(":", 1);
name = name.get_slice(":", 0);
for (int j = 0; j < Variant::VARIANT_MAX; j++) {
@@ -2819,7 +2846,7 @@ Control *VisualScriptEditor::get_base_editor() const {
return graph;
}
-void VisualScriptEditor::set_tooltip_request_func(String p_method, Object *p_obj) {
+void VisualScriptEditor::set_tooltip_request_func(const Callable &p_toolip_callback) {
}
Control *VisualScriptEditor::get_edit_menu() {
@@ -3207,19 +3234,34 @@ void VisualScriptEditor::_port_action_menu(int p_option) {
n->set_base_type("Object");
}
String type_string;
+ String base_script = "";
if (script->get_node(port_action_node)->get_output_value_port_count() > 0) {
type_string = script->get_node(port_action_node)->get_output_value_port_info(port_action_output).hint_string;
+ VisualScriptFunctionCall *vsfc = Object::cast_to<VisualScriptFunctionCall>(*script->get_node(port_action_node));
+ if (vsfc) {
+ base_script = vsfc->get_base_script();
+ } else {
+ VisualScriptPropertyGet *vspg = Object::cast_to<VisualScriptPropertyGet>(*script->get_node(port_action_node));
+ if (vspg) {
+ base_script = vspg->get_base_script();
+ } else {
+ VisualScriptPropertySet *vsps = Object::cast_to<VisualScriptPropertySet>(*script->get_node(port_action_node));
+ if (vsps) {
+ base_script = vsps->get_base_script();
+ }
+ }
+ }
}
if (tg.type == Variant::OBJECT) {
if (tg.script.is_valid()) {
- new_connect_node_select->select_from_script(tg.script, "");
- } else if (!type_string.is_empty()) {
- new_connect_node_select->select_from_base_type(type_string);
+ new_connect_node_select->select_from_script(tg.script);
+ } else if (type_string != String()) {
+ new_connect_node_select->select_from_base_type(type_string, base_script);
} else {
- new_connect_node_select->select_from_base_type(n->get_base_type());
+ new_connect_node_select->select_from_base_type(n->get_base_type(), base_script);
}
} else if (tg.type == Variant::NIL) {
- new_connect_node_select->select_from_base_type("");
+ new_connect_node_select->select_from_base_type("", base_script);
} else {
new_connect_node_select->select_from_basic_type(tg.type);
}
@@ -3282,66 +3324,54 @@ void VisualScriptEditor::connect_data(Ref<VisualScriptNode> vnode_old, Ref<Visua
}
void VisualScriptEditor::_selected_connect_node(const String &p_text, const String &p_category, const bool p_connecting) {
+#ifdef OSX_ENABLED
+ bool held_ctrl = Input::get_singleton()->is_key_pressed(Key::META);
+#else
+ bool held_ctrl = Input::get_singleton()->is_key_pressed(Key::CTRL);
+#endif
Vector2 pos = _get_pos_in_graph(port_action_pos);
Set<int> vn;
+ bool port_node_exists = true;
if (drop_position != Vector2()) {
pos = drop_position;
}
drop_position = Vector2();
- bool port_node_exists = true;
-
- // if (func == StringName()) {
- // func = default_func;
- // port_node_exists = false;
- // }
-
- if (p_category == "visualscript") {
- Ref<VisualScriptNode> vnode_new = VisualScriptLanguage::singleton->create_node_from_name(p_text);
- Ref<VisualScriptNode> vnode_old;
- if (port_node_exists && p_connecting) {
- vnode_old = script->get_node(port_action_node);
- }
- int new_id = script->get_available_id();
+ Ref<VisualScriptNode> vnode;
+ Ref<VisualScriptNode> vnode_old;
+ if (port_node_exists && p_connecting) {
+ vnode_old = script->get_node(port_action_node);
+ }
- if (Object::cast_to<VisualScriptOperator>(vnode_new.ptr()) && vnode_old.is_valid()) {
- Variant::Type type = vnode_old->get_output_value_port_info(port_action_output).type;
- Object::cast_to<VisualScriptOperator>(vnode_new.ptr())->set_typed(type);
- }
+ if (p_category.begins_with("VisualScriptNode")) {
+ Ref<VisualScriptNode> n = VisualScriptLanguage::singleton->create_node_from_name(p_text);
- if (Object::cast_to<VisualScriptTypeCast>(vnode_new.ptr()) && vnode_old.is_valid()) {
+ if (Object::cast_to<VisualScriptTypeCast>(n.ptr()) && vnode_old.is_valid()) {
Variant::Type type = vnode_old->get_output_value_port_info(port_action_output).type;
String hint_name = vnode_old->get_output_value_port_info(port_action_output).hint_string;
if (type == Variant::OBJECT) {
- Object::cast_to<VisualScriptTypeCast>(vnode_new.ptr())->set_base_type(hint_name);
+ Object::cast_to<VisualScriptTypeCast>(n.ptr())->set_base_type(hint_name);
} else if (type == Variant::NIL) {
- Object::cast_to<VisualScriptTypeCast>(vnode_new.ptr())->set_base_type("");
+ Object::cast_to<VisualScriptTypeCast>(n.ptr())->set_base_type("");
} else {
- Object::cast_to<VisualScriptTypeCast>(vnode_new.ptr())->set_base_type(Variant::get_type_name(type));
+ Object::cast_to<VisualScriptTypeCast>(n.ptr())->set_base_type(Variant::get_type_name(type));
}
}
-
- undo_redo->create_action(TTR("Add Node"));
- undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode_new, pos);
- if (vnode_old.is_valid() && p_connecting) {
- connect_seq(vnode_old, vnode_new, new_id);
- connect_data(vnode_old, vnode_new, new_id);
- }
-
- undo_redo->add_undo_method(script.ptr(), "remove_node", new_id);
- undo_redo->add_do_method(this, "_update_graph");
- undo_redo->add_undo_method(this, "_update_graph");
- undo_redo->commit_action();
- return;
+ vnode = n;
}
- Ref<VisualScriptNode> vnode;
- Ref<VisualScriptPropertySet> script_prop_set;
-
- if (p_category == String("method")) {
+ if (p_category == String("Class") && !p_connecting) {
+ Ref<VisualScriptFunctionCall> n;
+ n.instantiate();
+ n->set_call_mode(VisualScriptFunctionCall::CALL_MODE_SINGLETON);
+ n->set_singleton("ClassDB");
+ n->set_function("instantiate");
+ // Did not find a way to edit the input port value
+ vnode = n;
+ } else if (p_category == String("class_method")) {
Ref<VisualScriptFunctionCall> n;
n.instantiate();
if (!drop_path.is_empty()) {
@@ -3359,96 +3389,151 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
}
}
vnode = n;
- } else if (p_category == String("set")) {
- Ref<VisualScriptPropertySet> n;
- n.instantiate();
- if (!drop_path.is_empty()) {
- if (drop_path == ".") {
- n->set_call_mode(VisualScriptPropertySet::CALL_MODE_SELF);
- } else {
- n->set_call_mode(VisualScriptPropertySet::CALL_MODE_NODE_PATH);
- n->set_base_path(drop_path);
+ } else if (p_category == String("class_property")) {
+ Vector<String> property_path = p_text.split(":");
+ if (held_ctrl) {
+ Ref<VisualScriptPropertySet> n;
+ n.instantiate();
+ n->set_property(property_path[1]);
+ if (!drop_path.is_empty()) {
+ if (drop_path == ".") {
+ n->set_call_mode(VisualScriptPropertySet::CALL_MODE_SELF);
+ } else {
+ n->set_call_mode(VisualScriptPropertySet::CALL_MODE_NODE_PATH);
+ n->set_base_path(drop_path);
+ }
}
- }
- if (drop_node) {
- n->set_base_type(drop_node->get_class());
- if (drop_node->get_script_instance()) {
- n->set_base_script(drop_node->get_script_instance()->get_script()->get_path());
+ if (drop_node) {
+ n->set_base_type(drop_node->get_class());
+ if (drop_node->get_script_instance()) {
+ n->set_base_script(drop_node->get_script_instance()->get_script()->get_path());
+ }
}
- }
- vnode = n;
- script_prop_set = n;
- } else if (p_category == String("get")) {
- Ref<VisualScriptPropertyGet> n;
- n.instantiate();
- n->set_property(p_text);
- if (!drop_path.is_empty()) {
- if (drop_path == ".") {
- n->set_call_mode(VisualScriptPropertyGet::CALL_MODE_SELF);
- } else {
- n->set_call_mode(VisualScriptPropertyGet::CALL_MODE_NODE_PATH);
- n->set_base_path(drop_path);
+ vnode = n;
+ } else {
+ Ref<VisualScriptPropertyGet> n;
+ n.instantiate();
+ n->set_property(property_path[1]);
+ if (!drop_path.is_empty()) {
+ if (drop_path == ".") {
+ n->set_call_mode(VisualScriptPropertyGet::CALL_MODE_SELF);
+ } else {
+ n->set_call_mode(VisualScriptPropertyGet::CALL_MODE_NODE_PATH);
+ n->set_base_path(drop_path);
+ }
}
- }
- if (drop_node) {
- n->set_base_type(drop_node->get_class());
- if (drop_node->get_script_instance()) {
- n->set_base_script(drop_node->get_script_instance()->get_script()->get_path());
+ if (drop_node) {
+ n->set_base_type(drop_node->get_class());
+ if (drop_node->get_script_instance()) {
+ n->set_base_script(drop_node->get_script_instance()->get_script()->get_path());
+ }
}
- }
- vnode = n;
- }
- drop_path = String();
- drop_node = nullptr;
-
- if (p_category == String("action")) {
- if (p_text == "VisualScriptCondition") {
- Ref<VisualScriptCondition> n;
- n.instantiate();
vnode = n;
}
- if (p_text == "VisualScriptSwitch") {
- Ref<VisualScriptSwitch> n;
- n.instantiate();
- vnode = n;
- } else if (p_text == "VisualScriptSequence") {
- Ref<VisualScriptSequence> n;
- n.instantiate();
- vnode = n;
- } else if (p_text == "VisualScriptIterator") {
- Ref<VisualScriptIterator> n;
+ } else if (p_category == String("class_constant")) {
+ Vector<String> property_path = p_text.split(":");
+ if (ClassDB::class_exists(property_path[0])) {
+ Ref<VisualScriptClassConstant> n;
n.instantiate();
+ n->set_base_type(property_path[0]);
+ n->set_class_constant(property_path[1]);
vnode = n;
- } else if (p_text == "VisualScriptWhile") {
- Ref<VisualScriptWhile> n;
- n.instantiate();
- vnode = n;
- } else if (p_text == "VisualScriptReturn") {
- Ref<VisualScriptReturn> n;
+ } else {
+ Ref<VisualScriptBasicTypeConstant> n;
n.instantiate();
+ if (property_path[0] == "Nil") {
+ n->set_basic_type(Variant::NIL);
+ } else if (property_path[0] == "bool") {
+ n->set_basic_type(Variant::BOOL);
+ } else if (property_path[0] == "int") {
+ n->set_basic_type(Variant::INT);
+ } else if (property_path[0] == "float") {
+ n->set_basic_type(Variant::FLOAT);
+ } else if (property_path[0] == "String") {
+ n->set_basic_type(Variant::STRING);
+ } else if (property_path[0] == "Vector2") {
+ n->set_basic_type(Variant::VECTOR2);
+ } else if (property_path[0] == "Vector2i") {
+ n->set_basic_type(Variant::VECTOR2I);
+ } else if (property_path[0] == "Rect2") {
+ n->set_basic_type(Variant::RECT2);
+ } else if (property_path[0] == "Rect2i") {
+ n->set_basic_type(Variant::RECT2I);
+ } else if (property_path[0] == "Transform2D") {
+ n->set_basic_type(Variant::TRANSFORM2D);
+ } else if (property_path[0] == "Vector3") {
+ n->set_basic_type(Variant::VECTOR3);
+ } else if (property_path[0] == "Vector3i") {
+ n->set_basic_type(Variant::VECTOR3I);
+ } else if (property_path[0] == "Plane") {
+ n->set_basic_type(Variant::PLANE);
+ } else if (property_path[0] == "ABB") {
+ n->set_basic_type(Variant::AABB);
+ } else if (property_path[0] == "Quaternion") {
+ n->set_basic_type(Variant::QUATERNION);
+ } else if (property_path[0] == "Basis") {
+ n->set_basic_type(Variant::BASIS);
+ } else if (property_path[0] == "Transform3D") {
+ n->set_basic_type(Variant::TRANSFORM3D);
+ } else if (property_path[0] == "Color") {
+ n->set_basic_type(Variant::COLOR);
+ } else if (property_path[0] == "RID") {
+ n->set_basic_type(Variant::RID);
+ } else if (property_path[0] == "Object") {
+ n->set_basic_type(Variant::OBJECT);
+ } else if (property_path[0] == "Callable") {
+ n->set_basic_type(Variant::CALLABLE);
+ } else if (property_path[0] == "Signal") {
+ n->set_basic_type(Variant::SIGNAL);
+ } else if (property_path[0] == "StringName") {
+ n->set_basic_type(Variant::STRING_NAME);
+ } else if (property_path[0] == "NodePath") {
+ n->set_basic_type(Variant::NODE_PATH);
+ } else if (property_path[0] == "Dictionary") {
+ n->set_basic_type(Variant::DICTIONARY);
+ } else if (property_path[0] == "Array") {
+ n->set_basic_type(Variant::ARRAY);
+ } else if (property_path[0] == "PackedByteArray") {
+ n->set_basic_type(Variant::PACKED_BYTE_ARRAY);
+ } else if (property_path[0] == "PackedInt32Array") {
+ n->set_basic_type(Variant::PACKED_INT32_ARRAY);
+ } else if (property_path[0] == "PackedInt64Array") {
+ n->set_basic_type(Variant::PACKED_INT64_ARRAY);
+ } else if (property_path[0] == "PackedFloat32Array") {
+ n->set_basic_type(Variant::PACKED_FLOAT32_ARRAY);
+ } else if (property_path[0] == "PackedStringArray") {
+ n->set_basic_type(Variant::PACKED_STRING_ARRAY);
+ } else if (property_path[0] == "PackedVector2Array") {
+ n->set_basic_type(Variant::PACKED_VECTOR2_ARRAY);
+ } else if (property_path[0] == "PackedVector3Array") {
+ n->set_basic_type(Variant::PACKED_VECTOR3_ARRAY);
+ } else if (property_path[0] == "PackedColorArray") {
+ n->set_basic_type(Variant::PACKED_COLOR_ARRAY);
+ }
+ n->set_basic_type_constant(property_path[1]);
vnode = n;
}
- }
- int new_id = script->get_available_id();
- undo_redo->create_action(TTR("Add Node"));
- undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, pos);
- undo_redo->add_undo_method(script.ptr(), "remove_node", new_id);
- undo_redo->add_do_method(this, "_update_graph", new_id);
- undo_redo->add_undo_method(this, "_update_graph", new_id);
- undo_redo->commit_action();
+ } else if (p_category == String("class_signal")) {
+ Vector<String> property_path = p_text.split(":");
+ ERR_FAIL_COND(!(script->has_custom_signal(property_path[1]) || ClassDB::has_signal(script->get_instance_base_type(), property_path[1])));
- if (script_prop_set.is_valid()) {
- script_prop_set->set_property(p_text);
+ Ref<VisualScriptEmitSignal> n;
+ n.instantiate();
+ n->set_signal(property_path[1]);
+ vnode = n;
+ }
+ if (vnode == nullptr) {
+ print_error("Category not handled: " + p_category.quote());
}
- port_action_new_node = new_id;
-
- Ref<VisualScriptNode> vsn = script->get_node(port_action_new_node);
+ if (Object::cast_to<VisualScriptFunctionCall>(vnode.ptr()) && p_category != "Class") {
+ Vector<String> property_path = p_text.split(":");
+ String class_of_method = property_path[0];
+ String method_name = property_path[1];
- if (Object::cast_to<VisualScriptFunctionCall>(vsn.ptr())) {
- Ref<VisualScriptFunctionCall> vsfc = vsn;
- vsfc->set_function(p_text);
+ Ref<VisualScriptFunctionCall> vsfc = vnode;
+ vsfc->set_function(method_name);
if (port_node_exists && p_connecting) {
VisualScriptNode::TypeGuess tg = _guess_output_type(port_action_node, port_action_output, vn);
@@ -3465,7 +3550,7 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
if (!base_type.is_empty() && hint == PROPERTY_HINT_TYPE_STRING) {
vsfc->set_base_type(base_type);
}
- if (p_text == "call" || p_text == "call_deferred") {
+ if (method_name == "call" || method_name == "call_deferred") {
vsfc->set_function(String(""));
}
}
@@ -3483,8 +3568,8 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
}
if (port_node_exists && p_connecting) {
- if (Object::cast_to<VisualScriptPropertySet>(vsn.ptr())) {
- Ref<VisualScriptPropertySet> vsp = vsn;
+ if (Object::cast_to<VisualScriptPropertySet>(vnode.ptr())) {
+ Ref<VisualScriptPropertySet> vsp = vnode;
VisualScriptNode::TypeGuess tg = _guess_output_type(port_action_node, port_action_output, vn);
if (tg.type == Variant::OBJECT) {
@@ -3513,8 +3598,8 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
}
}
- if (Object::cast_to<VisualScriptPropertyGet>(vsn.ptr())) {
- Ref<VisualScriptPropertyGet> vsp = vsn;
+ if (Object::cast_to<VisualScriptPropertyGet>(vnode.ptr())) {
+ Ref<VisualScriptPropertyGet> vsp = vnode;
VisualScriptNode::TypeGuess tg = _guess_output_type(port_action_node, port_action_output, vn);
if (tg.type == Variant::OBJECT) {
@@ -3542,13 +3627,85 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
}
}
}
+ if (vnode == nullptr) {
+ print_error("Not able to create node from category: \"" + p_category + "\" and text \"" + p_text + "\" Not created");
+ return;
+ }
+
+ int new_id = script->get_available_id();
+ undo_redo->create_action(TTR("Add Node"));
+ undo_redo->add_do_method(script.ptr(), "add_node", new_id, vnode, pos);
+ undo_redo->add_undo_method(script.ptr(), "remove_node", new_id);
+ undo_redo->add_do_method(this, "_update_graph", new_id);
+ undo_redo->add_undo_method(this, "_update_graph", new_id);
+ undo_redo->commit_action();
+
+ port_action_new_node = new_id;
+
+ String base_script = "";
+ String base_type = "";
if (port_node_exists) {
- Ref<VisualScriptNode> vnode_old = script->get_node(port_action_node);
+ if (vnode_old.is_valid()) {
+ if (Object::cast_to<VisualScriptTypeCast>(vnode_old.ptr())) {
+ base_type = Object::cast_to<VisualScriptTypeCast>(vnode_old.ptr())->get_base_type();
+ base_script = Object::cast_to<VisualScriptTypeCast>(vnode_old.ptr())->get_base_script();
+ } else if (Object::cast_to<VisualScriptFunctionCall>(vnode_old.ptr())) {
+ base_type = Object::cast_to<VisualScriptFunctionCall>(vnode_old.ptr())->get_base_type();
+ base_script = Object::cast_to<VisualScriptFunctionCall>(vnode_old.ptr())->get_base_script();
+ } else if (Object::cast_to<VisualScriptPropertySet>(vnode_old.ptr())) {
+ base_type = Object::cast_to<VisualScriptPropertySet>(vnode_old.ptr())->get_base_type();
+ base_script = Object::cast_to<VisualScriptPropertySet>(vnode_old.ptr())->get_base_script();
+ } else if (Object::cast_to<VisualScriptPropertyGet>(vnode_old.ptr())) {
+ base_type = Object::cast_to<VisualScriptPropertyGet>(vnode_old.ptr())->get_base_type();
+ base_script = Object::cast_to<VisualScriptPropertyGet>(vnode_old.ptr())->get_base_script();
+ }
+ }
+
+ Vector<String> property_path = p_text.split(":");
+ if (ClassDB::is_parent_class(script->get_instance_base_type(), property_path[0]) || script->get_path().ends_with(property_path[0].unquote())) {
+ if (!p_connecting) {
+ base_type = script->get_instance_base_type();
+ base_script = script->get_path();
+ }
+ } else {
+ base_type = property_path[0];
+ base_script = "";
+ }
+
+ if (drop_node) {
+ Ref<Script> script = drop_node->get_script();
+ if (script != nullptr) {
+ base_script = script->get_path();
+ }
+ }
+
if (vnode_old.is_valid() && p_connecting) {
+ if (base_type == "") {
+ base_type = property_path[0];
+ } else if (ClassDB::is_parent_class(property_path[0], base_type)) {
+ base_type = property_path[0];
+ }
connect_seq(vnode_old, vnode, port_action_new_node);
connect_data(vnode_old, vnode, port_action_new_node);
}
}
+ if (Object::cast_to<VisualScriptTypeCast>(vnode.ptr())) {
+ Object::cast_to<VisualScriptTypeCast>(vnode.ptr())->set_base_type(base_type);
+ Object::cast_to<VisualScriptTypeCast>(vnode.ptr())->set_base_script(base_script);
+ } else if (Object::cast_to<VisualScriptFunctionCall>(vnode.ptr())) {
+ Object::cast_to<VisualScriptFunctionCall>(vnode.ptr())->set_base_type(base_type);
+ Object::cast_to<VisualScriptFunctionCall>(vnode.ptr())->set_base_script(base_script);
+ } else if (Object::cast_to<VisualScriptPropertySet>(vnode.ptr())) {
+ Object::cast_to<VisualScriptPropertySet>(vnode.ptr())->set_base_type(base_type);
+ Object::cast_to<VisualScriptPropertySet>(vnode.ptr())->set_base_script(base_script);
+ } else if (Object::cast_to<VisualScriptPropertyGet>(vnode.ptr())) {
+ Object::cast_to<VisualScriptPropertyGet>(vnode.ptr())->set_base_type(base_type);
+ Object::cast_to<VisualScriptPropertyGet>(vnode.ptr())->set_base_script(base_script);
+ }
+
+ drop_path = String();
+ drop_node = nullptr;
+
_update_graph(port_action_new_node);
}
@@ -3598,7 +3755,7 @@ void VisualScriptEditor::connect_seq(Ref<VisualScriptNode> vnode_old, Ref<Visual
}
void VisualScriptEditor::_selected_new_virtual_method(const String &p_text, const String &p_category, const bool p_connecting) {
- String name = p_text;
+ String name = p_text.substr(p_text.find_char(':') + 1);
if (script->has_function(name)) {
EditorNode::get_singleton()->show_warning(vformat(TTR("Script already has function '%s'"), name));
return;
@@ -3704,7 +3861,7 @@ void VisualScriptEditor::_default_value_edited(Node *p_button, int p_id, int p_i
Variant::construct(pinfo.type, existing, &existingp, 1, ce);
}
- default_value_edit->set_position(Object::cast_to<Control>(p_button)->get_screen_position() + Vector2(0, Object::cast_to<Control>(p_button)->get_size().y));
+ default_value_edit->set_position(Object::cast_to<Control>(p_button)->get_screen_position() + Vector2(0, Object::cast_to<Control>(p_button)->get_size().y) * graph->get_zoom());
default_value_edit->reset_size();
if (pinfo.type == Variant::NODE_PATH) {
@@ -3753,6 +3910,12 @@ void VisualScriptEditor::_toggle_scripts_pressed() {
void VisualScriptEditor::_notification(int p_what) {
switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+ graph->get_panner()->setup((ViewPanner::ControlScheme)EDITOR_GET("editors/panning/sub_editors_panning_scheme").operator int(), ED_GET_SHORTCUT("canvas_item_editor/pan_view"), bool(EditorSettings::get_singleton()->get("editors/panning/simple_panning")));
+ graph->set_warped_panning(bool(EditorSettings::get_singleton()->get("editors/panning/warped_mouse_panning")));
+ } break;
+
case NOTIFICATION_READY: {
variable_editor->connect("changed", callable_mp(this, &VisualScriptEditor::_update_members));
variable_editor->connect("changed", callable_mp(this, &VisualScriptEditor::_update_graph), varray(-1), CONNECT_DEFERRED);
@@ -3868,6 +4031,9 @@ void VisualScriptEditor::_comment_node_resized(const Vector2 &p_new_size, int p_
void VisualScriptEditor::_menu_option(int p_what) {
switch (p_what) {
+ case EDIT_ADD_NODE: {
+ _generic_search();
+ } break;
case EDIT_DELETE_NODES: {
_on_nodes_delete();
} break;
@@ -3896,7 +4062,7 @@ void VisualScriptEditor::_menu_option(int p_what) {
} break;
case EDIT_FIND_NODE_TYPE: {
- _generic_search(script->get_instance_base_type());
+ _generic_search();
} break;
case EDIT_COPY_NODES: {
_on_nodes_copy();
@@ -3908,6 +4074,9 @@ void VisualScriptEditor::_menu_option(int p_what) {
case EDIT_PASTE_NODES: {
_on_nodes_paste();
} break;
+ case EDIT_DUPLICATE_NODES: {
+ _on_nodes_duplicate();
+ } break;
case EDIT_CREATE_FUNCTION: {
// Create Function.
Map<int, Ref<VisualScriptNode>> nodes;
@@ -4135,6 +4304,12 @@ void VisualScriptEditor::_menu_option(int p_what) {
case REFRESH_GRAPH: {
_update_graph();
} break;
+ case EDIT_CLEAR_COPY_BUFFER: {
+ clipboard->nodes.clear();
+ clipboard->nodes_positions.clear();
+ clipboard->data_connections.clear();
+ clipboard->sequence_connections.clear();
+ } break;
}
}
@@ -4322,9 +4497,6 @@ VisualScriptEditor::VisualScriptEditor() {
if (!clipboard) {
clipboard = memnew(Clipboard);
}
- updating_graph = false;
- saved_pos_dirty = false;
- saved_position = Vector2(0, 0);
edit_menu = memnew(MenuButton);
edit_menu->set_shortcut_context(this);
@@ -4556,6 +4728,18 @@ VisualScriptEditor::VisualScriptEditor() {
new_virtual_method_select = memnew(VisualScriptPropertySelector);
add_child(new_virtual_method_select);
new_virtual_method_select->connect("selected", callable_mp(this, &VisualScriptEditor::_selected_new_virtual_method));
+
+ popup_menu = memnew(PopupMenu);
+ add_child(popup_menu);
+ popup_menu->add_item(TTR("Add Node"), EDIT_ADD_NODE);
+ popup_menu->add_separator();
+ popup_menu->add_item(TTR("Cut"), EDIT_CUT_NODES);
+ popup_menu->add_item(TTR("Copy"), EDIT_COPY_NODES);
+ popup_menu->add_item(TTR("Paste"), EDIT_PASTE_NODES);
+ popup_menu->add_item(TTR("Delete"), EDIT_DELETE_NODES);
+ popup_menu->add_item(TTR("Duplicate"), EDIT_DUPLICATE_NODES);
+ popup_menu->add_item(TTR("Clear Copy Buffer"), EDIT_CLEAR_COPY_BUFFER);
+ popup_menu->connect("id_pressed", callable_mp(this, &VisualScriptEditor::_menu_option));
}
VisualScriptEditor::~VisualScriptEditor() {
diff --git a/modules/visual_script/editor/visual_script_editor.h b/modules/visual_script/editor/visual_script_editor.h
index fd1db2bc43..b01732b2fd 100644
--- a/modules/visual_script/editor/visual_script_editor.h
+++ b/modules/visual_script/editor/visual_script_editor.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -54,13 +54,18 @@ class VisualScriptEditor : public ScriptEditorBase {
};
enum {
- EDIT_DELETE_NODES,
- EDIT_TOGGLE_BREAKPOINT,
- EDIT_FIND_NODE_TYPE,
- EDIT_COPY_NODES,
+ EDIT_ADD_NODE,
+ EDIT_SEPARATOR, // popup menu separator - ignored
EDIT_CUT_NODES,
+ EDIT_COPY_NODES,
EDIT_PASTE_NODES,
+ EDIT_DELETE_NODES,
+ EDIT_DUPLICATE_NODES,
+ EDIT_CLEAR_COPY_BUFFER,
+
EDIT_CREATE_FUNCTION,
+ EDIT_TOGGLE_BREAKPOINT,
+ EDIT_FIND_NODE_TYPE,
REFRESH_GRAPH,
};
@@ -80,55 +85,55 @@ class VisualScriptEditor : public ScriptEditorBase {
MEMBER_SIGNAL
};
- VBoxContainer *members_section;
- MenuButton *edit_menu;
+ VBoxContainer *members_section = nullptr;
+ MenuButton *edit_menu = nullptr;
Ref<VisualScript> script;
- Button *base_type_select;
+ Button *base_type_select = nullptr;
- LineEdit *func_name_box;
- ScrollContainer *func_input_scroll;
- VBoxContainer *func_input_vbox;
- ConfirmationDialog *function_create_dialog;
+ LineEdit *func_name_box = nullptr;
+ ScrollContainer *func_input_scroll = nullptr;
+ VBoxContainer *func_input_vbox = nullptr;
+ ConfirmationDialog *function_create_dialog = nullptr;
- GraphEdit *graph;
- HBoxContainer *status_bar;
- Button *toggle_scripts_button;
+ GraphEdit *graph = nullptr;
+ HBoxContainer *status_bar = nullptr;
+ Button *toggle_scripts_button = nullptr;
- VisualScriptEditorSignalEdit *signal_editor;
+ VisualScriptEditorSignalEdit *signal_editor = nullptr;
- AcceptDialog *edit_signal_dialog;
- EditorInspector *edit_signal_edit;
+ AcceptDialog *edit_signal_dialog = nullptr;
+ EditorInspector *edit_signal_edit = nullptr;
- VisualScriptPropertySelector *method_select;
- VisualScriptPropertySelector *new_connect_node_select;
- VisualScriptPropertySelector *new_virtual_method_select;
+ VisualScriptPropertySelector *method_select = nullptr;
+ VisualScriptPropertySelector *new_connect_node_select = nullptr;
+ VisualScriptPropertySelector *new_virtual_method_select = nullptr;
- VisualScriptEditorVariableEdit *variable_editor;
+ VisualScriptEditorVariableEdit *variable_editor = nullptr;
- AcceptDialog *edit_variable_dialog;
- EditorInspector *edit_variable_edit;
+ AcceptDialog *edit_variable_dialog = nullptr;
+ EditorInspector *edit_variable_edit = nullptr;
- CustomPropertyEditor *default_value_edit;
+ CustomPropertyEditor *default_value_edit = nullptr;
- UndoRedo *undo_redo;
+ UndoRedo *undo_redo = nullptr;
- Tree *members;
- AcceptDialog *function_name_edit;
- LineEdit *function_name_box;
+ Tree *members = nullptr;
+ AcceptDialog *function_name_edit = nullptr;
+ LineEdit *function_name_box = nullptr;
- Label *hint_text;
- Timer *hint_text_timer;
+ Label *hint_text = nullptr;
+ Timer *hint_text_timer = nullptr;
- Label *select_func_text;
+ Label *select_func_text = nullptr;
- bool updating_graph;
+ bool updating_graph = false;
void _show_hint(const String &p_hint);
void _hide_timer();
- CreateDialog *select_base_type;
+ CreateDialog *select_base_type = nullptr;
struct VirtualInMenu {
String name;
@@ -162,18 +167,18 @@ class VisualScriptEditor : public ScriptEditorBase {
static Clipboard *clipboard;
- PopupMenu *member_popup;
+ PopupMenu *popup_menu = nullptr;
+ PopupMenu *member_popup = nullptr;
MemberType member_type;
String member_name;
PortAction port_action;
- int port_action_node;
- int port_action_output;
+ int port_action_node = 0;
+ int port_action_output = 0;
Vector2 port_action_pos;
- int port_action_new_node;
+ int port_action_new_node = 0;
- bool saved_pos_dirty;
- Vector2 saved_position;
+ bool saved_pos_dirty = false;
Vector2 mouse_up_position;
@@ -191,7 +196,7 @@ class VisualScriptEditor : public ScriptEditorBase {
int _create_new_node_from_name(const String &p_text, const Vector2 &p_point);
void _selected_new_virtual_method(const String &p_text, const String &p_category, const bool p_connecting);
- int error_line;
+ int error_line = -1;
void _node_selected(Node *p_node);
void _center_on_node(int p_id);
@@ -236,7 +241,7 @@ class VisualScriptEditor : public ScriptEditorBase {
bool node_has_sequence_connections(int p_id);
- void _generic_search(String p_base_type = "", Vector2 pos = Vector2(), bool node_centered = false);
+ void _generic_search(Vector2 pos = Vector2(), bool node_centered = false);
virtual void input(const Ref<InputEvent> &p_event) override;
void _graph_gui_input(const Ref<InputEvent> &p_event);
@@ -262,12 +267,12 @@ class VisualScriptEditor : public ScriptEditorBase {
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;
+ int editing_id = 0;
+ int editing_input = 0;
- bool can_swap;
- int data_disconnect_node;
- int data_disconnect_port;
+ bool can_swap = false;
+ int data_disconnect_node = 0;
+ int data_disconnect_port = 0;
void _default_value_changed();
void _default_value_edited(Node *p_button, int p_id, int p_input_port);
@@ -323,7 +328,7 @@ public:
virtual void update_settings() override;
virtual bool show_members_overview() override;
virtual void set_debugger_active(bool p_active) override;
- virtual void set_tooltip_request_func(String p_method, Object *p_obj) override;
+ virtual void set_tooltip_request_func(const Callable &p_toolip_callback) override;
virtual Control *get_edit_menu() override;
virtual void clear_edit_menu() override;
virtual void set_find_replace_bar(FindReplaceBar *p_bar) override { p_bar->hide(); }; // Not needed here.
diff --git a/modules/visual_script/editor/visual_script_property_selector.cpp b/modules/visual_script/editor/visual_script_property_selector.cpp
index 9fa35d4453..bba5410629 100644
--- a/modules/visual_script/editor/visual_script_property_selector.cpp
+++ b/modules/visual_script/editor/visual_script_property_selector.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -37,13 +37,28 @@
#include "../visual_script_nodes.h"
#include "core/os/keyboard.h"
#include "editor/doc_tools.h"
+#include "editor/editor_feature_profile.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "scene/main/node.h"
#include "scene/main/window.h"
-void VisualScriptPropertySelector::_text_changed(const String &p_newtext) {
- _update_search();
+void VisualScriptPropertySelector::_update_icons() {
+ search_box->set_right_icon(results_tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
+ search_box->set_clear_button_enabled(true);
+ search_box->add_theme_icon_override("right_icon", results_tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons")));
+
+ search_visual_script_nodes->set_icon(results_tree->get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons")));
+ search_classes->set_icon(results_tree->get_theme_icon(SNAME("Object"), SNAME("EditorIcons")));
+ search_methods->set_icon(results_tree->get_theme_icon(SNAME("MemberMethod"), SNAME("EditorIcons")));
+ search_operators->set_icon(results_tree->get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
+ search_signals->set_icon(results_tree->get_theme_icon(SNAME("MemberSignal"), SNAME("EditorIcons")));
+ search_constants->set_icon(results_tree->get_theme_icon(SNAME("MemberConstant"), SNAME("EditorIcons")));
+ search_properties->set_icon(results_tree->get_theme_icon(SNAME("MemberProperty"), SNAME("EditorIcons")));
+ search_theme_items->set_icon(results_tree->get_theme_icon(SNAME("MemberTheme"), SNAME("EditorIcons")));
+
+ case_sensitive_button->set_icon(results_tree->get_theme_icon(SNAME("MatchCase"), SNAME("EditorIcons")));
+ hierarchy_button->set_icon(results_tree->get_theme_icon(SNAME("ClassList"), SNAME("EditorIcons")));
}
void VisualScriptPropertySelector::_sbox_input(const Ref<InputEvent> &p_ie) {
@@ -55,24 +70,8 @@ void VisualScriptPropertySelector::_sbox_input(const Ref<InputEvent> &p_ie) {
case Key::DOWN:
case Key::PAGEUP:
case Key::PAGEDOWN: {
- search_options->gui_input(k);
+ results_tree->gui_input(k);
search_box->accept_event();
-
- TreeItem *root = search_options->get_root();
- if (!root->get_first_child()) {
- 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;
default:
break;
@@ -80,654 +79,1189 @@ void VisualScriptPropertySelector::_sbox_input(const Ref<InputEvent> &p_ie) {
}
}
-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 (const StringName &E : base_list) {
- List<MethodInfo> methods;
- List<PropertyInfo> props;
- TreeItem *category = nullptr;
- Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = {
- vbc->get_theme_icon(SNAME("Variant"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("bool"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("int"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("float"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("String"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("Vector2i"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("Rect2"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("Rect2i"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("Vector3i"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("Transform2D"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("Plane"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("Quaternion"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("AABB"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("Basis"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("Color"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("StringName"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("NodePath"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("RID"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("MiniObject"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("Callable"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("Signal"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("Dictionary"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("Array"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("PackedByteArray"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("PackedInt32Array"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("PackedInt64Array"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("PackedFloat32Array"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("PackedFloat64Array"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("PackedStringArray"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("PackedVector2Array"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("PackedVector3Array"), SNAME("EditorIcons")),
- vbc->get_theme_icon(SNAME("PackedColorArray"), SNAME("EditorIcons"))
- };
- {
- String b = String(E);
- category = search_options->create_item(root);
- if (category) {
- category->set_text(0, b.replace_first("*", ""));
- category->set_selectable(0, false);
- Ref<Texture2D> 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, &props, true);
- }
- }
- for (const PropertyInfo &F : props) {
- if (!(F.usage & PROPERTY_USAGE_EDITOR) && !(F.usage & PROPERTY_USAGE_SCRIPT_VARIABLE)) {
- continue;
- }
+void VisualScriptPropertySelector::_update_results_i(int p_int) {
+ _update_results();
+}
- if (type_filter.size() && type_filter.find(F.type) == -1) {
- continue;
- }
+void VisualScriptPropertySelector::_update_results_s(String p_string) {
+ _update_results();
+}
- // capitalize() also converts underscore to space, we'll match again both possible styles
- String get_text_raw = String(vformat(TTR("Get %s"), F.name));
- String get_text = get_text_raw.capitalize();
- String set_text_raw = String(vformat(TTR("Set %s"), F.name));
- String set_text = set_text_raw.capitalize();
- String input = search_box->get_text().capitalize();
-
- if (input.is_empty() || 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.name);
- item->set_icon(0, type_icons[F.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);
- }
+void VisualScriptPropertySelector::_update_results() {
+ _update_icons();
+ search_runner = Ref<SearchRunner>(memnew(SearchRunner(this, results_tree)));
+ set_process(true);
+}
+
+void VisualScriptPropertySelector::_confirmed() {
+ TreeItem *ti = results_tree->get_selected();
+ if (!ti) {
+ return;
+ }
+ emit_signal(SNAME("selected"), ti->get_metadata(0), ti->get_metadata(1), connecting);
+ set_visible(false);
+}
+
+void VisualScriptPropertySelector::_item_selected() {
+ if (results_tree->get_selected()->has_meta("description")) {
+ help_bit->set_text(results_tree->get_selected()->get_meta("description"));
+ } else {
+ help_bit->set_text("No description available");
+ }
+}
- if (input.is_empty() || 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.name);
- item->set_icon(0, type_icons[F.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);
+void VisualScriptPropertySelector::_hide_requested() {
+ _cancel_pressed(); // From AcceptDialog.
+}
+
+void VisualScriptPropertySelector::_notification(int p_what) {
+ switch (p_what) {
+ case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
+ _update_icons();
+ } break;
+ case NOTIFICATION_ENTER_TREE: {
+ connect("confirmed", callable_mp(this, &VisualScriptPropertySelector::_confirmed));
+ } break;
+ case NOTIFICATION_PROCESS: {
+ // Update background search.
+ if (search_runner.is_valid()) {
+ if (search_runner->work()) {
+ // Search done.
+ get_ok_button()->set_disabled(!results_tree->get_selected());
+
+ search_runner = Ref<SearchRunner>();
+ set_process(false);
}
- }
- }
- {
- if (type != Variant::NIL) {
- Variant v;
- Callable::CallError ce;
- Variant::construct(type, v, 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, &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 one is valid
+ set_process(false);
}
+ } break;
+ }
+}
- if (virtuals_only && !(M->get().flags & METHOD_FLAG_VIRTUAL)) {
- continue;
- }
+void VisualScriptPropertySelector::select_method_from_base_type(const String &p_base, const bool p_virtuals_only, const bool p_connecting, bool clear_text) {
+ set_title(TTR("Select method from base type"));
+ base_type = p_base;
+ base_script = "";
+ type = Variant::NIL;
+ connecting = p_connecting;
- if (!virtuals_only && (M->get().flags & METHOD_FLAG_VIRTUAL)) {
- continue;
- }
+ if (clear_text) {
+ if (p_virtuals_only) {
+ search_box->set_text("._"); // show all _methods
+ search_box->set_caret_column(2);
+ } else {
+ search_box->set_text("."); // show all methods
+ search_box->set_caret_column(1);
+ }
+ }
- 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("( ", "(");
+ search_visual_script_nodes->set_pressed(false);
+ search_classes->set_pressed(false);
+ search_methods->set_pressed(true);
+ search_operators->set_pressed(false);
+ search_signals->set_pressed(false);
+ search_constants->set_pressed(false);
+ search_properties->set_pressed(false);
+ search_theme_items->set_pressed(false);
- if (!search_box->get_text().is_empty() &&
- name.findn(search_box->get_text()) == -1 &&
- desc.findn(search_box->get_text()) == -1 &&
- desc_raw.findn(search_box->get_text()) == -1) {
- continue;
- }
+ scope_combo->select(2); //id0 = "Search Related" //id2 = "Search Base" //id3 = "Search Inheriters" //id4 = "Search Unrelated"
- TreeItem *item = search_options->create_item(category ? category : root);
- item->set_text(0, desc);
- item->set_icon(0, vbc->get_theme_icon(SNAME("MemberMethod"), SNAME("EditorIcons")));
- item->set_metadata(0, name);
- item->set_selectable(0, true);
+ results_tree->clear();
+ show_window(.5f);
+ search_box->grab_focus();
- item->set_metadata(1, "method");
- item->set_collapsed(true);
- item->set_selectable(1, false);
+ _update_results();
+}
- item->set_selectable(2, false);
- item->set_metadata(2, connecting);
- }
+void VisualScriptPropertySelector::select_from_base_type(const String &p_base, const String &p_base_script, bool p_virtuals_only, const bool p_connecting, bool clear_text) {
+ set_title(TTR("Select from base type"));
+ base_type = p_base;
+ base_script = p_base_script.lstrip("res://").quote(); // filepath to EditorHelp::get_doc_data().name
+ type = Variant::NIL;
+ connecting = p_connecting;
- if (category && category->get_first_child() == nullptr) {
- memdelete(category); //old category was unused
+ if (clear_text) {
+ if (p_virtuals_only) {
+ search_box->set_text("_");
+ } else {
+ search_box->set_text(" ");
}
}
- 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::FLOAT || type == Variant::VECTOR2 || type == Variant::VECTOR3) {
- get_visual_node_names("operators/math/", Set<String>(), found, root, search_box);
- }
- }
+ search_box->select_all();
+
+ search_visual_script_nodes->set_pressed(false);
+ search_classes->set_pressed(false);
+ search_methods->set_pressed(true);
+ search_operators->set_pressed(false);
+ search_signals->set_pressed(true);
+ search_constants->set_pressed(false);
+ search_properties->set_pressed(true);
+ search_theme_items->set_pressed(false);
+
+ // When class is Input only show inheritors
+ scope_combo->select(0); //id0 = "Search Related" //id2 = "Search Base" //id3 = "Search Inheriters" //id4 = "Search Unrelated"
+
+ results_tree->clear();
+ show_window(.5f);
+ search_box->grab_focus();
+ _update_results();
+}
+
+void VisualScriptPropertySelector::select_from_script(const Ref<Script> &p_script, const bool p_connecting, bool clear_text) {
+ set_title(TTR("Select from script"));
+ ERR_FAIL_COND(p_script.is_null());
+
+ base_type = p_script->get_instance_base_type();
+ base_script = p_script->get_path().lstrip("res://").quote(); // filepath to EditorHelp::get_doc_data().name
+ type = Variant::NIL;
+ script = p_script->get_instance_id();
+ connecting = p_connecting;
+
+ if (clear_text) {
+ search_box->set_text("");
}
+ search_box->select_all();
+
+ search_visual_script_nodes->set_pressed(false);
+ search_classes->set_pressed(true);
+ search_methods->set_pressed(true);
+ search_operators->set_pressed(true);
+ search_signals->set_pressed(true);
+ search_constants->set_pressed(true);
+ search_properties->set_pressed(true);
+ search_theme_items->set_pressed(false);
+
+ scope_combo->select(2); //id0 = "Search Related" //id2 = "Search Base" //id3 = "Search Inheriters" //id4 = "Search Unrelated"
- 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);
+ results_tree->clear();
+ show_window(.5f);
+ search_box->grab_focus();
+ _update_results();
+}
+
+void VisualScriptPropertySelector::select_from_basic_type(Variant::Type p_type, const bool p_connecting, bool clear_text) {
+ set_title(TTR("Select from basic type"));
+ ERR_FAIL_COND(p_type == Variant::NIL);
+ base_type = Variant::get_type_name(p_type);
+ base_script = "";
+ type = p_type;
+ connecting = p_connecting;
+
+ if (clear_text) {
+ search_box->set_text(" ");
}
+ search_box->select_all();
+
+ search_visual_script_nodes->set_pressed(false);
+ search_classes->set_pressed(false);
+ search_methods->set_pressed(true);
+ search_operators->set_pressed(true);
+ search_signals->set_pressed(false);
+ search_constants->set_pressed(true);
+ search_properties->set_pressed(true);
+ search_theme_items->set_pressed(false);
+
+ scope_combo->select(2); //id0 = "Search Related" //id2 = "Search Base" //id3 = "Search Inheriters" //id4 = "Search Unrelated" //id5 "Search All"
+
+ results_tree->clear();
+ show_window(.5f);
+ search_box->grab_focus();
+
+ _update_results();
+}
+
+void VisualScriptPropertySelector::select_from_action(const String &p_type, const bool p_connecting, bool clear_text) {
+ set_title(TTR("Select from action"));
+ base_type = p_type;
+ base_script = "";
+ type = Variant::NIL;
+ connecting = p_connecting;
- if ((properties || seq_connect) && visual_script_generic) {
- get_visual_node_names("", Set<String>(), found, root, search_box);
+ if (clear_text) {
+ search_box->set_text("");
}
+ search_box->select_all();
+
+ search_visual_script_nodes->set_pressed(true);
+ search_classes->set_pressed(false);
+ search_methods->set_pressed(false);
+ search_operators->set_pressed(false);
+ search_signals->set_pressed(false);
+ search_constants->set_pressed(false);
+ search_properties->set_pressed(false);
+ search_theme_items->set_pressed(false);
+
+ scope_combo->select(0); //id0 = "Search Related" //id2 = "Search Base" //id3 = "Search Inheriters" //id4 = "Search Unrelated" //id5 "Search All"
+
+ results_tree->clear();
+ show_window(.5f);
+ search_box->grab_focus();
+ _update_results();
+}
+
+void VisualScriptPropertySelector::select_from_instance(Object *p_instance, const bool p_connecting, bool clear_text) {
+ set_title(TTR("Select from instance"));
+ base_type = p_instance->get_class();
- TreeItem *selected_item = search_options->search_item_text(search_box->get_text());
- if (!found && selected_item != nullptr) {
- selected_item->select(0);
- found = true;
+ const Ref<Script> &p_script = p_instance->get_script();
+ if (p_script == nullptr) {
+ base_script = "";
+ } else {
+ base_script = p_script->get_path().lstrip("res://").quote(); // filepath to EditorHelp::get_doc_data().name
+ }
+
+ type = Variant::NIL;
+ connecting = p_connecting;
+
+ if (clear_text) {
+ search_box->set_text(" ");
}
+ search_box->select_all();
+
+ search_visual_script_nodes->set_pressed(false);
+ search_classes->set_pressed(false);
+ search_methods->set_pressed(true);
+ search_operators->set_pressed(false);
+ search_signals->set_pressed(true);
+ search_constants->set_pressed(true);
+ search_properties->set_pressed(true);
+ search_theme_items->set_pressed(false);
+
+ scope_combo->select(2); //id0 = "Search Related" //id2 = "Search Base" //id3 = "Search Inheriters" //id4 = "Search Unrelated" //id5 "Search All"
- get_ok_button()->set_disabled(root->get_first_child() == nullptr);
+ results_tree->clear();
+ show_window(.5f);
+ search_box->grab_focus();
+ _update_results();
}
-void VisualScriptPropertySelector::create_visualscript_item(const String &name, TreeItem *const root, const String &search_input, const String &text) {
- if (search_input.is_empty() || text.findn(search_input) != -1) {
- TreeItem *item = search_options->create_item(root);
- item->set_text(0, text);
- item->set_icon(0, vbc->get_theme_icon(SNAME("VisualScript"), SNAME("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::select_from_visual_script(const Ref<Script> &p_script, bool clear_text) {
+ set_title(TTR("Select from visual script"));
+ base_type = p_script->get_instance_base_type();
+ if (p_script == nullptr) {
+ base_script = "";
+ } else {
+ base_script = p_script->get_path().lstrip("res://").quote(); // filepath to EditorHelp::get_doc_data().name
+ }
+ type = Variant::NIL;
+ connecting = false;
+
+ if (clear_text) {
+ search_box->set_text(" ");
}
+ search_box->select_all();
+
+ search_visual_script_nodes->set_pressed(true);
+ search_classes->set_pressed(false);
+ search_methods->set_pressed(true);
+ search_operators->set_pressed(false);
+ search_signals->set_pressed(true);
+ search_constants->set_pressed(true);
+ search_properties->set_pressed(true);
+ search_theme_items->set_pressed(false);
+
+ scope_combo->select(2); //id0 = "Search Related" //id2 = "Search Base" //id3 = "Search Inheriters" //id4 = "Search Unrelated" //id5 "Search All"
+
+ results_tree->clear();
+ show_window(.5f);
+ search_box->grab_focus();
+ _update_results();
+}
+
+void VisualScriptPropertySelector::show_window(float p_screen_ratio) {
+ popup_centered_ratio(p_screen_ratio);
}
-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;
+void VisualScriptPropertySelector::_bind_methods() {
+ ADD_SIGNAL(MethodInfo("selected", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::STRING, "category"), PropertyInfo(Variant::BOOL, "connecting")));
+}
- List<String> fnodes;
- VisualScriptLanguage::singleton->get_registered_node_names(&fnodes);
+VisualScriptPropertySelector::VisualScriptPropertySelector() {
+ vbox = memnew(VBoxContainer);
+ add_child(vbox);
+
+ HBoxContainer *hbox = memnew(HBoxContainer);
+ hbox->set_alignment(hbox->ALIGNMENT_CENTER);
+ vbox->add_child(hbox);
+
+ case_sensitive_button = memnew(Button);
+ case_sensitive_button->set_flat(true);
+ case_sensitive_button->set_tooltip(TTR("Case Sensitive"));
+ case_sensitive_button->connect("pressed", callable_mp(this, &VisualScriptPropertySelector::_update_results));
+ case_sensitive_button->set_toggle_mode(true);
+ case_sensitive_button->set_focus_mode(Control::FOCUS_NONE);
+ hbox->add_child(case_sensitive_button);
+
+ hierarchy_button = memnew(Button);
+ hierarchy_button->set_flat(true);
+ hierarchy_button->set_tooltip(TTR("Show Hierarchy"));
+ hierarchy_button->connect("pressed", callable_mp(this, &VisualScriptPropertySelector::_update_results));
+ hierarchy_button->set_toggle_mode(true);
+ hierarchy_button->set_pressed(true);
+ hierarchy_button->set_focus_mode(Control::FOCUS_NONE);
+ hbox->add_child(hierarchy_button);
+
+ hbox->add_child(memnew(VSeparator));
+
+ search_visual_script_nodes = memnew(Button);
+ search_visual_script_nodes->set_flat(true);
+ search_visual_script_nodes->set_tooltip(TTR("Search Visual Script Nodes"));
+ search_visual_script_nodes->connect("pressed", callable_mp(this, &VisualScriptPropertySelector::_update_results));
+ search_visual_script_nodes->set_toggle_mode(true);
+ search_visual_script_nodes->set_pressed(true);
+ search_visual_script_nodes->set_focus_mode(Control::FOCUS_NONE);
+ hbox->add_child(search_visual_script_nodes);
+
+ search_classes = memnew(Button);
+ search_classes->set_flat(true);
+ search_classes->set_tooltip(TTR("Search Classes"));
+ search_classes->connect("pressed", callable_mp(this, &VisualScriptPropertySelector::_update_results));
+ search_classes->set_toggle_mode(true);
+ search_classes->set_pressed(true);
+ search_classes->set_focus_mode(Control::FOCUS_NONE);
+ hbox->add_child(search_classes);
+
+ search_operators = memnew(Button);
+ search_operators->set_flat(true);
+ search_operators->set_tooltip(TTR("Search Operators"));
+ search_operators->connect("pressed", callable_mp(this, &VisualScriptPropertySelector::_update_results));
+ search_operators->set_toggle_mode(true);
+ search_operators->set_pressed(true);
+ search_operators->set_focus_mode(Control::FOCUS_NONE);
+ hbox->add_child(search_operators);
+
+ hbox->add_child(memnew(VSeparator));
+
+ search_methods = memnew(Button);
+ search_methods->set_flat(true);
+ search_methods->set_tooltip(TTR("Search Methods"));
+ search_methods->connect("pressed", callable_mp(this, &VisualScriptPropertySelector::_update_results));
+ search_methods->set_toggle_mode(true);
+ search_methods->set_pressed(true);
+ search_methods->set_focus_mode(Control::FOCUS_NONE);
+ hbox->add_child(search_methods);
+
+ search_signals = memnew(Button);
+ search_signals->set_flat(true);
+ search_signals->set_tooltip(TTR("Search Signals"));
+ search_signals->connect("pressed", callable_mp(this, &VisualScriptPropertySelector::_update_results));
+ search_signals->set_toggle_mode(true);
+ search_signals->set_pressed(true);
+ search_signals->set_focus_mode(Control::FOCUS_NONE);
+ hbox->add_child(search_signals);
+
+ search_constants = memnew(Button);
+ search_constants->set_flat(true);
+ search_constants->set_tooltip(TTR("Search Constants"));
+ search_constants->connect("pressed", callable_mp(this, &VisualScriptPropertySelector::_update_results));
+ search_constants->set_toggle_mode(true);
+ search_constants->set_pressed(true);
+ search_constants->set_focus_mode(Control::FOCUS_NONE);
+ hbox->add_child(search_constants);
+
+ search_properties = memnew(Button);
+ search_properties->set_flat(true);
+ search_properties->set_tooltip(TTR("Search Properties"));
+ search_properties->connect("pressed", callable_mp(this, &VisualScriptPropertySelector::_update_results));
+ search_properties->set_toggle_mode(true);
+ search_properties->set_pressed(true);
+ search_properties->set_focus_mode(Control::FOCUS_NONE);
+ hbox->add_child(search_properties);
+
+ search_theme_items = memnew(Button);
+ search_theme_items->set_flat(true);
+ search_theme_items->set_tooltip(TTR("Search Theme Items"));
+ search_theme_items->connect("pressed", callable_mp(this, &VisualScriptPropertySelector::_update_results));
+ search_theme_items->set_toggle_mode(true);
+ search_theme_items->set_pressed(true);
+ search_theme_items->set_focus_mode(Control::FOCUS_NONE);
+ hbox->add_child(search_theme_items);
+
+ scope_combo = memnew(OptionButton);
+ scope_combo->set_custom_minimum_size(Size2(200, 0) * EDSCALE);
+ scope_combo->set_tooltip(TTR("Select the search limits"));
+ scope_combo->set_stretch_ratio(0); // Fixed width.
+ scope_combo->add_item(TTR("Search Related"), SCOPE_RELATED);
+ scope_combo->add_separator();
+ scope_combo->add_item(TTR("Search Base"), SCOPE_BASE);
+ scope_combo->add_item(TTR("Search Inheriters"), SCOPE_INHERITERS);
+ scope_combo->add_item(TTR("Search Unrelated"), SCOPE_UNRELATED);
+ scope_combo->add_item(TTR("Search All"), SCOPE_ALL);
+ scope_combo->connect("item_selected", callable_mp(this, &VisualScriptPropertySelector::_update_results_i));
+ hbox->add_child(scope_combo);
- for (const String &E : fnodes) {
- if (!E.begins_with(root_filter)) {
- continue;
- }
- Vector<String> path = E.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].is_empty()) {
- in_filter = true;
- } else {
- in_filter = false;
- }
- if (E.findn(tx_filters[i]) != -1) {
- in_filter = true;
- break;
- }
- }
- if (!in_filter) {
- continue;
- }
+ search_box = memnew(LineEdit);
+ search_box->set_tooltip(TTR("Enter \" \" to show all filterd options\nEnter \".\" to show all filterd methods, operators and constructors\nUse CTRL_KEY to drop property setters"));
+ search_box->set_custom_minimum_size(Size2(200, 0) * EDSCALE);
+ search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ search_box->connect("text_changed", callable_mp(this, &VisualScriptPropertySelector::_update_results_s));
+ search_box->connect("gui_input", callable_mp(this, &VisualScriptPropertySelector::_sbox_input));
+ register_text_enter(search_box);
+ vbox->add_child(search_box);
+
+ results_tree = memnew(Tree);
+ results_tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ results_tree->set_hide_root(true);
+ results_tree->set_hide_folding(false);
+ results_tree->set_columns(2);
+ results_tree->set_column_title(0, TTR("Name"));
+ results_tree->set_column_clip_content(0, true);
+ results_tree->set_column_title(1, TTR("Member Type"));
+ results_tree->set_column_expand(1, false);
+ results_tree->set_column_custom_minimum_width(1, 150 * EDSCALE);
+ results_tree->set_column_clip_content(1, true);
+ results_tree->set_custom_minimum_size(Size2(0, 100) * EDSCALE);
+ results_tree->set_select_mode(Tree::SELECT_ROW);
+ results_tree->connect("item_activated", callable_mp(this, &VisualScriptPropertySelector::_confirmed));
+ results_tree->connect("item_selected", callable_mp(this, &VisualScriptPropertySelector::_item_selected));
+ vbox->add_child(results_tree);
- bool in_modifier = p_modifiers.is_empty();
- for (Set<String>::Element *F = p_modifiers.front(); F && in_modifier; F = F->next()) {
- if (E.findn(F->get()) != -1) {
- in_modifier = true;
- }
- }
- if (!in_modifier) {
- continue;
- }
+ help_bit = memnew(EditorHelpBit);
+ vbox->add_child(help_bit);
+ help_bit->connect("request_hide", callable_mp(this, &VisualScriptPropertySelector::_hide_requested));
+ get_ok_button()->set_text(TTR("Open"));
+ get_ok_button()->set_disabled(true);
+ set_hide_on_ok(false);
+}
- TreeItem *item = search_options->create_item(root);
- Ref<VisualScriptNode> vnode = VisualScriptLanguage::singleton->create_node_from_name(E);
- 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() + " ";
+bool VisualScriptPropertySelector::SearchRunner::_is_class_disabled_by_feature_profile(const StringName &p_class) {
+ Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile();
+ if (profile.is_null()) {
+ return false;
+ }
+
+ StringName class_name = p_class;
+ while (class_name != StringName()) {
+ if (!ClassDB::class_exists(class_name)) {
+ return false;
}
- 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() + " ";
+
+ if (profile->is_class_disabled(class_name)) {
+ return true;
}
- Ref<VisualScriptConstructor> vnode_constructor = vnode;
- if (vnode_constructor.is_valid()) {
- type_name = "Construct ";
+ class_name = ClassDB::get_parent_class(class_name);
+ }
+
+ return false;
+}
+
+bool VisualScriptPropertySelector::SearchRunner::_is_class_disabled_by_scope(const StringName &p_class) {
+ bool is_base_script = false;
+ if (p_class == selector_ui->base_script) {
+ is_base_script = true;
+ }
+ bool is_base = false;
+ if (selector_ui->base_type == p_class) {
+ is_base = true;
+ }
+ bool is_parent = false;
+ if ((ClassDB::is_parent_class(selector_ui->base_type, p_class)) && !is_base) {
+ is_parent = true;
+ }
+
+ bool is_inheriter = false;
+ List<StringName> inheriters;
+ ClassDB::get_inheriters_from_class(selector_ui->base_type, &inheriters);
+ if (inheriters.find(p_class)) {
+ is_inheriter = true;
+ }
+
+ if (scope_flags & SCOPE_BASE) {
+ if (is_base_script || is_base || is_parent) {
+ return false;
}
- Ref<VisualScriptDeconstruct> vnode_deconstruct = vnode;
- if (vnode_deconstruct.is_valid()) {
- type_name = "Deconstruct ";
+ }
+ if (scope_flags & SCOPE_INHERITERS) {
+ if (is_base_script || is_base || is_inheriter) {
+ return false;
}
- 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(",", ", ");
- }
+ }
+ // if (scope_flags & SCOPE_RELATED) {
+ // /* code */
+ // }
+ if (scope_flags & SCOPE_UNRELATED) {
+ if (!is_base_script && !is_base && !is_inheriter) {
+ return false;
}
-
- item->set_text(0, type_name + String("").join(desc));
- item->set_icon(0, vbc->get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons")));
- item->set_selectable(0, true);
- item->set_metadata(0, E);
- 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);
}
+ return true;
}
-void VisualScriptPropertySelector::_confirmed() {
- TreeItem *ti = search_options->get_selected();
- if (!ti) {
- return;
+bool VisualScriptPropertySelector::SearchRunner::_slice() {
+ bool phase_done = false;
+ switch (phase) {
+ case PHASE_INIT:
+ phase_done = _phase_init();
+ break;
+ case PHASE_MATCH_CLASSES_INIT:
+ phase_done = _phase_match_classes_init();
+ break;
+ case PHASE_NODE_CLASSES_INIT:
+ phase_done = _phase_node_classes_init();
+ break;
+ case PHASE_NODE_CLASSES_BUILD:
+ phase_done = _phase_node_classes_build();
+ break;
+ case PHASE_MATCH_CLASSES:
+ phase_done = _phase_match_classes();
+ break;
+ case PHASE_CLASS_ITEMS_INIT:
+ phase_done = _phase_class_items_init();
+ break;
+ case PHASE_CLASS_ITEMS:
+ phase_done = _phase_class_items();
+ break;
+ case PHASE_MEMBER_ITEMS_INIT:
+ phase_done = _phase_member_items_init();
+ break;
+ case PHASE_MEMBER_ITEMS:
+ phase_done = _phase_member_items();
+ break;
+ case PHASE_SELECT_MATCH:
+ phase_done = _phase_select_match();
+ break;
+ case PHASE_MAX:
+ return true;
+ default:
+ WARN_PRINT("Invalid or unhandled phase in EditorHelpSearch::Runner, aborting search.");
+ return true;
+ };
+
+ if (phase_done) {
+ phase++;
}
- emit_signal(SNAME("selected"), ti->get_metadata(0), ti->get_metadata(1), ti->get_metadata(2));
- set_visible(false);
+ return false;
}
-void VisualScriptPropertySelector::_item_selected() {
- help_bit->set_text("");
-
- TreeItem *item = search_options->get_selected();
- if (!item) {
- return;
+bool VisualScriptPropertySelector::SearchRunner::_phase_init() {
+ search_flags = 0; // selector_ui->filter_combo->get_selected_id();
+ if (selector_ui->search_visual_script_nodes->is_pressed()) {
+ search_flags |= SEARCH_VISUAL_SCRIPT_NODES;
}
- 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;
+ if (selector_ui->search_classes->is_pressed()) {
+ search_flags |= SEARCH_CLASSES;
}
+ // if (selector_ui->search_constructors->is_pressed()) {
+ search_flags |= SEARCH_CONSTRUCTORS;
+ // }
+ if (selector_ui->search_methods->is_pressed()) {
+ search_flags |= SEARCH_METHODS;
+ }
+ if (selector_ui->search_operators->is_pressed()) {
+ search_flags |= SEARCH_OPERATORS;
+ }
+ if (selector_ui->search_signals->is_pressed()) {
+ search_flags |= SEARCH_SIGNALS;
+ }
+ if (selector_ui->search_constants->is_pressed()) {
+ search_flags |= SEARCH_CONSTANTS;
+ }
+ if (selector_ui->search_properties->is_pressed()) {
+ search_flags |= SEARCH_PROPERTIES;
+ }
+ if (selector_ui->search_theme_items->is_pressed()) {
+ search_flags |= SEARCH_THEME_ITEMS;
+ }
+ if (selector_ui->case_sensitive_button->is_pressed()) {
+ search_flags |= SEARCH_CASE_SENSITIVE;
+ }
+ if (selector_ui->hierarchy_button->is_pressed()) {
+ search_flags |= SEARCH_SHOW_HIERARCHY;
+ }
+ scope_flags = selector_ui->scope_combo->get_selected_id();
- DocTools *dd = EditorHelp::get_doc_data();
- String text;
-
- String at_class = class_type;
+ return true;
+}
- while (!at_class.is_empty()) {
- 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);
+bool VisualScriptPropertySelector::SearchRunner::_phase_match_classes_init() {
+ combined_docs = EditorHelp::get_doc_data()->class_list;
+ matches.clear();
+ matched_item = nullptr;
+ match_highest_score = 0;
+
+ if (
+ (selector_ui->base_script.unquote() != "") &&
+ (selector_ui->base_script.unquote() != ".") &&
+ !combined_docs.has(selector_ui->base_script)) {
+ String file_path = "res://" + selector_ui->base_script.unquote(); // EditorHelp::get_doc_data().name to filepath
+ Ref<Script> script;
+ script = ResourceLoader::load(file_path);
+ if (!script.is_null()) {
+ DocData::ClassDoc class_doc = DocData::ClassDoc();
+
+ class_doc.name = selector_ui->base_script;
+
+ class_doc.inherits = script->get_instance_base_type();
+ class_doc.brief_description = ".vs files not suported by EditorHelp::get_doc_data()";
+ class_doc.description = "";
+
+ Object *obj = ObjectDB::get_instance(script->get_instance_id());
+ if (Object::cast_to<Script>(obj)) {
+ List<MethodInfo> methods;
+ Object::cast_to<Script>(obj)->get_script_method_list(&methods);
+ for (List<MethodInfo>::Element *M = methods.front(); M; M = M->next()) {
+ class_doc.methods.push_back(_get_method_doc(M->get()));
}
- }
- }
- at_class = ClassDB::get_parent_class_nocheck(at_class);
- }
- at_class = class_type;
+ List<MethodInfo> signals;
+ Object::cast_to<Script>(obj)->get_script_signal_list(&signals);
+ for (List<MethodInfo>::Element *S = signals.front(); S; S = S->next()) {
+ class_doc.signals.push_back(_get_method_doc(S->get()));
+ }
- while (!at_class.is_empty()) {
- 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);
+ List<PropertyInfo> propertys;
+ Object::cast_to<Script>(obj)->get_script_property_list(&propertys);
+ for (List<PropertyInfo>::Element *P = propertys.front(); P; P = P->next()) {
+ DocData::PropertyDoc pd = DocData::PropertyDoc();
+ pd.name = P->get().name;
+ pd.type = Variant::get_type_name(P->get().type);
+ class_doc.properties.push_back(pd);
}
}
+ combined_docs.insert(class_doc.name, class_doc);
}
+ }
+ iterator_doc = combined_docs.front();
+ return true;
+}
- at_class = ClassDB::get_parent_class_nocheck(at_class);
+bool VisualScriptPropertySelector::SearchRunner::_phase_node_classes_init() {
+ VisualScriptLanguage::singleton->get_registered_node_names(&vs_nodes);
+ _add_class_doc("functions", "", "");
+ _add_class_doc("operators", "", "");
+ return true;
+}
+
+bool VisualScriptPropertySelector::SearchRunner::_phase_node_classes_build() {
+ if (vs_nodes.is_empty()) {
+ return true;
}
- 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);
+ String registerd_node_name = vs_nodes[0];
+ vs_nodes.pop_front();
+
+ Vector<String> path = registerd_node_name.split("/");
+ if (path[0] == "constants") {
+ _add_class_doc(registerd_node_name, "", "constants");
+ } else if (path[0] == "custom") {
+ _add_class_doc(registerd_node_name, "", "custom");
+ } else if (path[0] == "data") {
+ _add_class_doc(registerd_node_name, "", "data");
+ } else if (path[0] == "flow_control") {
+ _add_class_doc(registerd_node_name, "", "flow_control");
+ } else if (path[0] == "functions") {
+ if (path[1] == "built_in") {
+ _add_class_doc(registerd_node_name, "functions", "built_in");
+ } else if (path[1] == "by_type") {
+ if (search_flags & SEARCH_CLASSES) {
+ _add_class_doc(registerd_node_name, path[2], "by_type_class");
+ }
+ } else if (path[1] == "constructors") {
+ if (search_flags & SEARCH_CLASSES) {
+ _add_class_doc(registerd_node_name, path[2].substr(0, path[2].find_char('(')), "constructors_class");
}
+ } else if (path[1] == "deconstruct") {
+ _add_class_doc(registerd_node_name, "", "deconstruct");
+ } else if (path[1] == "wait") {
+ _add_class_doc(registerd_node_name, "functions", "yield");
+ } else {
+ _add_class_doc(registerd_node_name, "functions", "");
+ }
+ } else if (path[0] == "index") {
+ _add_class_doc(registerd_node_name, "", "index");
+ } else if (path[0] == "operators") {
+ if (path[1] == "bitwise") {
+ _add_class_doc(registerd_node_name, "operators", "bitwise");
+ } else if (path[1] == "compare") {
+ _add_class_doc(registerd_node_name, "operators", "compare");
+ } else if (path[1] == "logic") {
+ _add_class_doc(registerd_node_name, "operators", "logic");
+ } else if (path[1] == "math") {
+ _add_class_doc(registerd_node_name, "operators", "math");
+ } else {
+ _add_class_doc(registerd_node_name, "operators", "");
}
}
+ return false;
+}
- 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());
+bool VisualScriptPropertySelector::SearchRunner::_phase_match_classes() {
+ DocData::ClassDoc &class_doc = iterator_doc->value();
+ if (
+ (!_is_class_disabled_by_feature_profile(class_doc.name) && !_is_class_disabled_by_scope(class_doc.name)) ||
+ _match_visual_script(class_doc)) {
+ if (class_doc.inherits == "VisualScriptCustomNode") {
+ class_doc.script_path = "res://" + class_doc.name.unquote();
+ Ref<Script> script = ResourceLoader::load(class_doc.script_path);
+ Ref<VisualScriptCustomNode> vsn;
+ vsn.instantiate();
+ vsn->set_script(script);
+ class_doc.name = vsn->get_caption();
+ if (combined_docs.has(vsn->get_category())) {
+ class_doc.inherits = vsn->get_category();
+ } else if (combined_docs.has("VisualScriptNode/" + vsn->get_category())) {
+ class_doc.inherits = "VisualScriptNode/" + vsn->get_category();
+ } else if (combined_docs.has("VisualScriptCustomNode/" + vsn->get_category())) {
+ class_doc.inherits = "VisualScriptCustomNode/" + vsn->get_category();
+ } else {
+ class_doc.inherits = "";
}
+ class_doc.category = "VisualScriptCustomNode/" + vsn->get_category();
+ class_doc.brief_description = "";
+ class_doc.constructors.clear();
+ class_doc.methods.clear();
+ class_doc.operators.clear();
+ class_doc.signals.clear();
+ class_doc.constants.clear();
+ class_doc.enums.clear();
+ class_doc.properties.clear();
+ class_doc.theme_properties.clear();
}
- 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);
+
+ matches[class_doc.name] = ClassMatch();
+ ClassMatch &match = matches[class_doc.name];
+
+ match.category = class_doc.category;
+ match.doc = &class_doc;
+ // Match class name.
+ if (search_flags & SEARCH_CLASSES || _match_visual_script(class_doc)) {
+ if (term == "") {
+ match.name = !_match_is_hidden(class_doc);
+ } else {
+ match.name = _match_string(term, class_doc.name);
}
+ // match.name = term == "" || _match_string(term, class_doc.name);
}
- 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);
+ // Match members if the term is long enough.
+ if (term.length() >= 0) {
+ if (search_flags & SEARCH_CONSTRUCTORS) {
+ for (int i = 0; i < class_doc.constructors.size(); i++) {
+ String method_name = (search_flags & SEARCH_CASE_SENSITIVE) ? class_doc.constructors[i].name : class_doc.constructors[i].name.to_lower();
+ if (method_name.find(term) > -1 ||
+ term == " " ||
+ (term.begins_with(".") && method_name.begins_with(term.substr(1))) ||
+ (term.ends_with("(") && method_name.ends_with(term.left(term.length() - 1).strip_edges())) ||
+ (term.begins_with(".") && term.ends_with("(") && method_name == term.substr(1, term.length() - 2).strip_edges())) {
+ match.constructors.push_back(const_cast<DocData::MethodDoc *>(&class_doc.constructors[i]));
+ }
+ }
+ }
+ if (search_flags & SEARCH_METHODS) {
+ for (int i = 0; i < class_doc.methods.size(); i++) {
+ String method_name = (search_flags & SEARCH_CASE_SENSITIVE) ? class_doc.methods[i].name : class_doc.methods[i].name.to_lower();
+ if (method_name.find(term) > -1 ||
+ term == " " ||
+ (term.begins_with(".") && method_name.begins_with(term.substr(1))) ||
+ (term.ends_with("(") && method_name.ends_with(term.left(term.length() - 1).strip_edges())) ||
+ (term.begins_with(".") && term.ends_with("(") && method_name == term.substr(1, term.length() - 2).strip_edges())) {
+ match.methods.push_back(const_cast<DocData::MethodDoc *>(&class_doc.methods[i]));
+ }
+ }
+ }
+ if (search_flags & SEARCH_OPERATORS) {
+ for (int i = 0; i < class_doc.operators.size(); i++) {
+ String method_name = (search_flags & SEARCH_CASE_SENSITIVE) ? class_doc.operators[i].name : class_doc.operators[i].name.to_lower();
+ if (method_name.find(term) > -1 ||
+ term == " " ||
+ (term.begins_with(".") && method_name.begins_with(term.substr(1))) ||
+ (term.ends_with("(") && method_name.ends_with(term.left(term.length() - 1).strip_edges())) ||
+ (term.begins_with(".") && term.ends_with("(") && method_name == term.substr(1, term.length() - 2).strip_edges())) {
+ match.operators.push_back(const_cast<DocData::MethodDoc *>(&class_doc.operators[i]));
+ }
+ }
+ }
+ if (search_flags & SEARCH_SIGNALS) {
+ for (int i = 0; i < class_doc.signals.size(); i++) {
+ if (_match_string(term, class_doc.signals[i].name) ||
+ term == " ") {
+ match.signals.push_back(const_cast<DocData::MethodDoc *>(&class_doc.signals[i]));
+ }
+ }
+ }
+ if (search_flags & SEARCH_CONSTANTS) {
+ for (int i = 0; i < class_doc.constants.size(); i++) {
+ if (_match_string(term, class_doc.constants[i].name) ||
+ term == " ") {
+ match.constants.push_back(const_cast<DocData::ConstantDoc *>(&class_doc.constants[i]));
+ }
+ }
+ }
+ if (search_flags & SEARCH_PROPERTIES) {
+ for (int i = 0; i < class_doc.properties.size(); i++) {
+ if (_match_string(term, class_doc.properties[i].name) ||
+ term == " " ||
+ _match_string(term, class_doc.properties[i].getter) ||
+ _match_string(term, class_doc.properties[i].setter)) {
+ match.properties.push_back(const_cast<DocData::PropertyDoc *>(&class_doc.properties[i]));
+ }
+ }
+ }
+ if (search_flags & SEARCH_THEME_ITEMS) {
+ for (int i = 0; i < class_doc.theme_properties.size(); i++) {
+ if (_match_string(term, class_doc.theme_properties[i].name) ||
+ term == " ") {
+ match.theme_properties.push_back(const_cast<DocData::ThemeItemDoc *>(&class_doc.theme_properties[i]));
}
}
}
}
}
- memdelete(names);
+ iterator_doc = iterator_doc->next();
+ return !iterator_doc;
+}
- if (text.is_empty()) {
- return;
- }
+bool VisualScriptPropertySelector::SearchRunner::_phase_class_items_init() {
+ results_tree->clear();
+ iterator_match = matches.front();
- help_bit->set_text(text);
-}
+ root_item = results_tree->create_item();
+ class_items.clear();
-void VisualScriptPropertySelector::_hide_requested() {
- _cancel_pressed(); // From AcceptDialog.
+ return true;
}
-void VisualScriptPropertySelector::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
- connect("confirmed", callable_mp(this, &VisualScriptPropertySelector::_confirmed));
+bool VisualScriptPropertySelector::SearchRunner::_phase_class_items() {
+ if (!iterator_match) {
+ return true;
}
-}
-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;
- properties = false;
- instance = nullptr;
- virtuals_only = p_virtuals_only;
+ ClassMatch &match = iterator_match->value();
- show_window(.5f);
- if (clear_text) {
- search_box->set_text("");
+ if (search_flags & SEARCH_SHOW_HIERARCHY) {
+ if (match.required()) {
+ _create_class_hierarchy(match);
+ }
} else {
- search_box->select_all();
+ if (match.name) {
+ _create_class_item(root_item, match.doc, true);
+ }
}
- search_box->grab_focus();
- connecting = p_connecting;
- _update_search();
+ iterator_match = iterator_match->next();
+ return !iterator_match;
}
-void VisualScriptPropertySelector::set_type_filter(const Vector<Variant::Type> &p_type_filter) {
- type_filter = p_type_filter;
+bool VisualScriptPropertySelector::SearchRunner::_phase_member_items_init() {
+ iterator_match = matches.front();
+
+ return true;
}
-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;
- properties = true;
- visual_script_generic = false;
- instance = nullptr;
- virtuals_only = p_virtuals_only;
+bool VisualScriptPropertySelector::SearchRunner::_phase_member_items() {
+ if (!iterator_match) {
+ return true;
+ }
- show_window(.5f);
- if (clear_text) {
- search_box->set_text("");
+ ClassMatch &match = iterator_match->value();
+
+ TreeItem *parent = (search_flags & SEARCH_SHOW_HIERARCHY) ? class_items[match.doc->name] : root_item;
+ bool constructor_created = false;
+ for (int i = 0; i < match.methods.size(); i++) {
+ String text = match.methods[i]->name;
+ if (!constructor_created) {
+ if (match.doc->name == match.methods[i]->name) {
+ text += " " + TTR("(constructors)");
+ constructor_created = true;
+ }
+ } else {
+ if (match.doc->name == match.methods[i]->name) {
+ continue;
+ }
+ }
+ _create_method_item(parent, match.doc, text, match.methods[i]);
+ }
+ for (int i = 0; i < match.signals.size(); i++) {
+ _create_signal_item(parent, match.doc, match.signals[i]);
+ }
+ for (int i = 0; i < match.constants.size(); i++) {
+ _create_constant_item(parent, match.doc, match.constants[i]);
+ }
+ for (int i = 0; i < match.properties.size(); i++) {
+ _create_property_item(parent, match.doc, match.properties[i]);
+ }
+ for (int i = 0; i < match.theme_properties.size(); i++) {
+ _create_theme_property_item(parent, match.doc, match.theme_properties[i]);
+ }
+
+ iterator_match = iterator_match->next();
+ return !iterator_match;
+}
+
+bool VisualScriptPropertySelector::SearchRunner::_phase_select_match() {
+ if (matched_item) {
+ matched_item->select(0);
+ }
+ return true;
+}
+
+bool VisualScriptPropertySelector::SearchRunner::_match_string(const String &p_term, const String &p_string) const {
+ if (search_flags & SEARCH_CASE_SENSITIVE) {
+ return p_string.find(p_term) > -1;
} else {
- search_box->select_all();
+ return p_string.findn(p_term) > -1;
}
- search_box->grab_focus();
- seq_connect = p_seq_connect;
- connecting = p_connecting;
+}
- _update_search();
+bool VisualScriptPropertySelector::SearchRunner::_match_visual_script(DocData::ClassDoc &class_doc) {
+ if (class_doc.category.ends_with("_class")) {
+ if (class_doc.category.begins_with("VisualScript") && search_flags & SEARCH_CLASSES) {
+ if (matches.has(class_doc.inherits)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ if (class_doc.category.begins_with("VisualScript") && search_flags & SEARCH_VISUAL_SCRIPT_NODES) {
+ return true;
+ }
+ if (class_doc.name.begins_with("operators") && search_flags & SEARCH_OPERATORS) {
+ return true;
+ }
+ if (class_doc.category.begins_with("VisualScriptNode/deconstruct")) {
+ if (class_doc.name.find(selector_ui->base_type, 0) > -1) {
+ return true;
+ }
+ }
+
+ return false;
}
-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());
+bool VisualScriptPropertySelector::SearchRunner::_match_is_hidden(DocData::ClassDoc &class_doc) {
+ if (class_doc.category.begins_with("VisualScript")) {
+ if (class_doc.name.begins_with("flow_control")) {
+ return false;
+ } else if (class_doc.name.begins_with("operators")) {
+ return !(search_flags & SEARCH_OPERATORS);
+ } else if (class_doc.name.begins_with("functions/built_in/print")) {
+ return false;
+ }
+ return true;
+ }
+ return false;
+}
- 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;
+void VisualScriptPropertySelector::SearchRunner::_match_item(TreeItem *p_item, const String &p_text) {
+ float inverse_length = 1.f / float(p_text.length());
- show_window(.5f);
- if (clear_text) {
- search_box->set_text("");
- } else {
- search_box->select_all();
+ // Favor types where search term is a substring close to the start of the type.
+ float w = 0.5f;
+ int pos = p_text.findn(term);
+ float score = (pos > -1) ? 1.0f - w * MIN(1, 3 * pos * inverse_length) : MAX(0.f, .9f - w);
+
+ // Favor shorter items: they resemble the search term more.
+ w = 0.1f;
+ score *= (1 - w) + w * (term.length() * inverse_length);
+
+ if (match_highest_score == 0 || score > match_highest_score) {
+ matched_item = p_item;
+ match_highest_score = score;
}
- search_box->grab_focus();
- seq_connect = false;
- connecting = p_connecting;
+}
- _update_search();
+void VisualScriptPropertySelector::SearchRunner::_add_class_doc(String class_name, String inherits, String category) {
+ DocData::ClassDoc class_doc = DocData::ClassDoc();
+ class_doc.name = class_name;
+ class_doc.inherits = inherits;
+ class_doc.category = "VisualScriptNode/" + category;
+ class_doc.brief_description = category;
+ combined_docs.insert(class_doc.name, class_doc);
}
-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;
- properties = true;
- visual_script_generic = false;
- instance = nullptr;
- virtuals_only = false;
+DocData::MethodDoc VisualScriptPropertySelector::SearchRunner::_get_method_doc(MethodInfo method_info) {
+ DocData::MethodDoc method_doc = DocData::MethodDoc();
+ method_doc.name = method_info.name;
+ method_doc.return_type = Variant::get_type_name(method_info.return_val.type);
+ method_doc.description = "No description available";
+ for (List<PropertyInfo>::Element *P = method_info.arguments.front(); P; P = P->next()) {
+ DocData::ArgumentDoc argument_doc = DocData::ArgumentDoc();
+ argument_doc.name = P->get().name;
+ argument_doc.type = Variant::get_type_name(P->get().type);
+ method_doc.arguments.push_back(argument_doc);
+ }
+ return method_doc;
+}
- show_window(.5f);
- if (clear_text) {
- search_box->set_text("");
- } else {
- search_box->select_all();
+TreeItem *VisualScriptPropertySelector::SearchRunner::_create_class_hierarchy(const ClassMatch &p_match) {
+ if (class_items.has(p_match.doc->name)) {
+ return class_items[p_match.doc->name];
}
- search_box->grab_focus();
- seq_connect = false;
- connecting = p_connecting;
- _update_search();
+ // Ensure parent nodes are created first.
+ TreeItem *parent = root_item;
+ if (p_match.doc->inherits != "") {
+ if (class_items.has(p_match.doc->inherits)) {
+ parent = class_items[p_match.doc->inherits];
+ } else if (matches.has(p_match.doc->inherits)) {
+ ClassMatch &base_match = matches[p_match.doc->inherits];
+ parent = _create_class_hierarchy(base_match);
+ }
+ }
+
+ TreeItem *class_item = _create_class_item(parent, p_match.doc, !p_match.name);
+ class_items[p_match.doc->name] = class_item;
+ return class_item;
}
-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;
- properties = false;
- visual_script_generic = false;
- instance = nullptr;
- virtuals_only = false;
+TreeItem *VisualScriptPropertySelector::SearchRunner::_create_class_item(TreeItem *p_parent, const DocData::ClassDoc *p_doc, bool p_gray) {
+ Ref<Texture2D> icon = empty_icon;
+ String text_0 = p_doc->name;
+ String text_1 = "Class";
+
+ String what = "Class";
+ String details = p_doc->name;
+ if (p_doc->category.begins_with("VisualScriptCustomNode/")) {
+ Vector<String> path = p_doc->name.split("/");
+ icon = ui_service->get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons"));
+ text_0 = path[path.size() - 1];
+ text_1 = "VisualScriptCustomNode";
+ what = "VisualScriptCustomNode";
+ details = "CustomNode";
+ } else if (p_doc->category.begins_with("VisualScriptNode/")) {
+ Vector<String> path = p_doc->name.split("/");
+ icon = ui_service->get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons"));
+ text_0 = path[path.size() - 1];
+ if (p_doc->category.begins_with("VisualScriptNode/deconstruct")) {
+ text_0 = "deconstruct " + text_0;
+ }
+ text_1 = "VisualScriptNode";
+ what = "VisualScriptNode";
+ details = p_doc->name;
+
+ if (path.size() == 1) {
+ if (path[0] == "functions" || path[0] == "operators") {
+ text_1 = "VisualScript";
+ p_gray = true;
+ what = "no_result";
+ details = "";
+ }
+ }
- show_window(.5f);
- if (clear_text) {
- search_box->set_text("");
} else {
- search_box->select_all();
+ if (p_doc->name.is_quoted()) {
+ text_0 = p_doc->name.unquote().get_file();
+ if (ui_service->has_theme_icon(p_doc->inherits, "EditorIcons")) {
+ icon = ui_service->get_theme_icon(p_doc->inherits, "EditorIcons");
+ }
+ } else if (ui_service->has_theme_icon(p_doc->name, "EditorIcons")) {
+ icon = ui_service->get_theme_icon(p_doc->name, "EditorIcons");
+ } else if (ClassDB::class_exists(p_doc->name) && ClassDB::is_parent_class(p_doc->name, "Object")) {
+ icon = ui_service->get_theme_icon(SNAME("Object"), SNAME("EditorIcons"));
+ }
+ }
+ String tooltip = p_doc->brief_description.strip_edges();
+
+ TreeItem *item = results_tree->create_item(p_parent);
+ item->set_icon(0, icon);
+ item->set_text(0, text_0);
+ item->set_text(1, TTR(text_1));
+ item->set_tooltip(0, tooltip);
+ item->set_tooltip(1, tooltip);
+ item->set_metadata(0, details);
+ item->set_metadata(1, what);
+ if (p_gray) {
+ item->set_custom_color(0, disabled_color);
+ item->set_custom_color(1, disabled_color);
}
- search_box->grab_focus();
- seq_connect = true;
- connecting = p_connecting;
- _update_search();
+ _match_item(item, p_doc->name);
+
+ return item;
}
-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;
- properties = true;
- visual_script_generic = false;
- instance = p_instance;
- virtuals_only = false;
+TreeItem *VisualScriptPropertySelector::SearchRunner::_create_method_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const String &p_text, const DocData::MethodDoc *p_doc) {
+ String tooltip = p_doc->return_type + " " + p_class_doc->name + "." + p_doc->name + "(";
+ for (int i = 0; i < p_doc->arguments.size(); i++) {
+ const DocData::ArgumentDoc &arg = p_doc->arguments[i];
+ tooltip += arg.type + " " + arg.name;
+ if (arg.default_value != "") {
+ tooltip += " = " + arg.default_value;
+ }
+ if (i < p_doc->arguments.size() - 1) {
+ tooltip += ", ";
+ }
+ }
+ tooltip += ")";
+ return _create_member_item(p_parent, p_class_doc->name, "MemberMethod", p_doc->name, p_text, TTRC("Method"), "method", tooltip, p_doc->description);
+}
- show_window(.5f);
- if (clear_text) {
- search_box->set_text("");
- } else {
- search_box->select_all();
+TreeItem *VisualScriptPropertySelector::SearchRunner::_create_signal_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc) {
+ String tooltip = p_doc->return_type + " " + p_class_doc->name + "." + p_doc->name + "(";
+ for (int i = 0; i < p_doc->arguments.size(); i++) {
+ const DocData::ArgumentDoc &arg = p_doc->arguments[i];
+ tooltip += arg.type + " " + arg.name;
+ if (arg.default_value != "") {
+ tooltip += " = " + arg.default_value;
+ }
+ if (i < p_doc->arguments.size() - 1) {
+ tooltip += ", ";
+ }
}
- search_box->grab_focus();
- seq_connect = false;
- connecting = p_connecting;
+ tooltip += ")";
+ return _create_member_item(p_parent, p_class_doc->name, "MemberSignal", p_doc->name, p_doc->name, TTRC("Signal"), "signal", tooltip, p_doc->description);
+}
- _update_search();
+TreeItem *VisualScriptPropertySelector::SearchRunner::_create_constant_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ConstantDoc *p_doc) {
+ String tooltip = p_class_doc->name + "." + p_doc->name;
+ return _create_member_item(p_parent, p_class_doc->name, "MemberConstant", p_doc->name, p_doc->name, TTRC("Constant"), "constant", tooltip, p_doc->description);
}
-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;
- properties = true;
- visual_script_generic = true;
- instance = nullptr;
- virtuals_only = false;
- show_window(.5f);
- if (clear_text) {
- search_box->set_text("");
+TreeItem *VisualScriptPropertySelector::SearchRunner::_create_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::PropertyDoc *p_doc) {
+ String tooltip = p_doc->type + " " + p_class_doc->name + "." + p_doc->name;
+ tooltip += "\n " + p_class_doc->name + "." + p_doc->setter + "(value) setter";
+ tooltip += "\n " + p_class_doc->name + "." + p_doc->getter + "() getter";
+ return _create_member_item(p_parent, p_class_doc->name, "MemberProperty", p_doc->name, p_doc->name, TTRC("Property"), "property", tooltip, p_doc->description);
+}
+
+TreeItem *VisualScriptPropertySelector::SearchRunner::_create_theme_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ThemeItemDoc *p_doc) {
+ String tooltip = p_doc->type + " " + p_class_doc->name + "." + p_doc->name;
+ return _create_member_item(p_parent, p_class_doc->name, "MemberTheme", p_doc->name, p_doc->name, TTRC("Theme Property"), "theme_item", tooltip, p_doc->description);
+}
+
+TreeItem *VisualScriptPropertySelector::SearchRunner::_create_member_item(TreeItem *p_parent, const String &p_class_name, const String &p_icon, const String &p_name, const String &p_text, const String &p_type, const String &p_metatype, const String &p_tooltip, const String &p_description) {
+ Ref<Texture2D> icon;
+ String text;
+ if (search_flags & SEARCH_SHOW_HIERARCHY) {
+ icon = ui_service->get_theme_icon(p_icon, SNAME("EditorIcons"));
+ text = p_text;
} else {
- search_box->select_all();
+ icon = ui_service->get_theme_icon(p_icon, SNAME("EditorIcons"));
+ text = p_class_name + "." + p_text;
}
- search_box->grab_focus();
- connecting = p_connecting;
- _update_search();
-}
+ TreeItem *item = results_tree->create_item(p_parent);
+ item->set_icon(0, icon);
+ item->set_text(0, text);
+ item->set_text(1, TTRGET(p_type));
+ item->set_tooltip(0, p_tooltip);
+ item->set_tooltip(1, p_tooltip);
+ item->set_metadata(0, p_class_name + ":" + p_name);
+ item->set_metadata(1, "class_" + p_metatype);
+ item->set_meta("description", p_description);
-void VisualScriptPropertySelector::show_window(float p_screen_ratio) {
- popup_centered_ratio(p_screen_ratio);
+ _match_item(item, p_name);
+
+ return item;
}
-void VisualScriptPropertySelector::_bind_methods() {
- ADD_SIGNAL(MethodInfo("selected", PropertyInfo(Variant::STRING, "name"), PropertyInfo(Variant::STRING, "category"), PropertyInfo(Variant::BOOL, "connecting")));
+bool VisualScriptPropertySelector::SearchRunner::work(uint64_t slot) {
+ // Return true when the search has been completed, otherwise false.
+ const uint64_t until = OS::get_singleton()->get_ticks_usec() + slot;
+ while (!_slice()) {
+ if (OS::get_singleton()->get_ticks_usec() > until) {
+ return false;
+ }
+ }
+ return true;
}
-VisualScriptPropertySelector::VisualScriptPropertySelector() {
- 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", callable_mp(this, &VisualScriptPropertySelector::_text_changed));
- search_box->connect("gui_input", callable_mp(this, &VisualScriptPropertySelector::_sbox_input));
- search_options = memnew(Tree);
- vbc->add_margin_child(TTR("Matches:"), search_options, true);
- get_ok_button()->set_text(TTR("Open"));
- get_ok_button()->set_disabled(true);
- register_text_enter(search_box);
- set_hide_on_ok(false);
- search_options->connect("item_activated", callable_mp(this, &VisualScriptPropertySelector::_confirmed));
- search_options->connect("cell_selected", callable_mp(this, &VisualScriptPropertySelector::_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", callable_mp(this, &VisualScriptPropertySelector::_hide_requested));
- search_options->set_columns(3);
- search_options->set_column_expand(1, false);
- search_options->set_column_expand(2, false);
+VisualScriptPropertySelector::SearchRunner::SearchRunner(VisualScriptPropertySelector *p_selector_ui, Tree *p_results_tree) :
+ selector_ui(p_selector_ui),
+ ui_service(p_selector_ui->vbox),
+ results_tree(p_results_tree),
+ term(p_selector_ui->search_box->get_text()),
+ empty_icon(ui_service->get_theme_icon(SNAME("ArrowRight"), SNAME("EditorIcons"))),
+ disabled_color(ui_service->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))) {
}
diff --git a/modules/visual_script/editor/visual_script_property_selector.h b/modules/visual_script/editor/visual_script_property_selector.h
index 7a87f3d3ee..6b5112f1af 100644
--- a/modules/visual_script/editor/visual_script_property_selector.h
+++ b/modules/visual_script/editor/visual_script_property_selector.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -31,6 +31,7 @@
#ifndef VISUALSCRIPT_PROPERTYSELECTOR_H
#define VISUALSCRIPT_PROPERTYSELECTOR_H
+#include "../visual_script.h"
#include "editor/editor_help.h"
#include "editor/property_editor.h"
#include "scene/gui/rich_text_label.h"
@@ -38,15 +39,56 @@
class VisualScriptPropertySelector : public ConfirmationDialog {
GDCLASS(VisualScriptPropertySelector, ConfirmationDialog);
+ enum SearchFlags {
+ SEARCH_CLASSES = 1 << 0,
+ SEARCH_CONSTRUCTORS = 1 << 1,
+ SEARCH_METHODS = 1 << 2,
+ SEARCH_OPERATORS = 1 << 3,
+ SEARCH_SIGNALS = 1 << 4,
+ SEARCH_CONSTANTS = 1 << 5,
+ SEARCH_PROPERTIES = 1 << 6,
+ SEARCH_THEME_ITEMS = 1 << 7,
+ SEARCH_VISUAL_SCRIPT_NODES = 1 << 8,
+ SEARCH_ALL = SEARCH_CLASSES | SEARCH_CONSTRUCTORS | SEARCH_METHODS | SEARCH_OPERATORS | SEARCH_SIGNALS | SEARCH_CONSTANTS | SEARCH_PROPERTIES | SEARCH_THEME_ITEMS,
+ SEARCH_CASE_SENSITIVE = 1 << 29,
+ SEARCH_SHOW_HIERARCHY = 1 << 30,
+ };
+
+ enum ScopeFlags {
+ SCOPE_BASE = 1 << 0,
+ SCOPE_INHERITERS = 1 << 1,
+ SCOPE_UNRELATED = 1 << 2,
+ SCOPE_RELATED = SCOPE_BASE | SCOPE_INHERITERS,
+ SCOPE_ALL = SCOPE_BASE | SCOPE_INHERITERS | SCOPE_UNRELATED
+ };
+
LineEdit *search_box;
- Tree *search_options;
- void _text_changed(const String &p_newtext);
- void _sbox_input(const Ref<InputEvent> &p_ie);
- void _update_search();
+ Button *case_sensitive_button;
+ Button *hierarchy_button;
+
+ Button *search_visual_script_nodes;
+ Button *search_classes;
+ Button *search_operators;
+
+ Button *search_methods;
+ Button *search_signals;
+ Button *search_constants;
+ Button *search_properties;
+ Button *search_theme_items;
- 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);
+ OptionButton *scope_combo;
+ Tree *results_tree;
+
+ class SearchRunner;
+ Ref<SearchRunner> search_runner;
+
+ void _update_icons();
+
+ void _sbox_input(const Ref<InputEvent> &p_ie);
+ void _update_results_i(int p_int);
+ void _update_results_s(String p_string);
+ void _update_results();
void _confirmed();
void _item_selected();
@@ -54,38 +96,124 @@ class VisualScriptPropertySelector : public ConfirmationDialog {
EditorHelpBit *help_bit;
- bool properties;
- bool visual_script_generic;
- bool connecting;
+ bool properties = false;
+ bool visual_script_generic = false;
+ bool connecting = false;
String selected;
Variant::Type type;
String base_type;
+ String base_script;
ObjectID script;
Object *instance;
- bool virtuals_only;
- bool seq_connect;
- VBoxContainer *vbc;
-
- Vector<Variant::Type> type_filter;
+ bool virtuals_only = false;
+ VBoxContainer *vbox;
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 select_method_from_base_type(const String &p_base, 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_base_script = "", bool p_virtuals_only = false, const bool p_connecting = true, bool clear_text = true);
+ void select_from_script(const Ref<Script> &p_script, const bool p_connecting = true, bool clear_text = true);
+ void select_from_basic_type(Variant::Type p_type, const bool p_connecting = true, bool clear_text = true);
+ void select_from_action(const String &p_type, const bool p_connecting = true, bool clear_text = true);
+ void select_from_instance(Object *p_instance, const bool p_connecting = true, bool clear_text = true);
+ void select_from_visual_script(const Ref<Script> &p_script, bool clear_text = true);
void show_window(float p_screen_ratio);
- void set_type_filter(const Vector<Variant::Type> &p_type_filter);
-
VisualScriptPropertySelector();
};
+class VisualScriptPropertySelector::SearchRunner : public RefCounted {
+ enum Phase {
+ PHASE_INIT,
+ PHASE_MATCH_CLASSES_INIT,
+ PHASE_NODE_CLASSES_INIT,
+ PHASE_NODE_CLASSES_BUILD,
+ PHASE_MATCH_CLASSES,
+ PHASE_CLASS_ITEMS_INIT,
+ PHASE_CLASS_ITEMS,
+ PHASE_MEMBER_ITEMS_INIT,
+ PHASE_MEMBER_ITEMS,
+ PHASE_SELECT_MATCH,
+ PHASE_MAX
+ };
+ int phase = 0;
+
+ struct ClassMatch {
+ DocData::ClassDoc *doc;
+ bool name = false;
+ String category = "";
+ Vector<DocData::MethodDoc *> constructors;
+ Vector<DocData::MethodDoc *> methods;
+ Vector<DocData::MethodDoc *> operators;
+ Vector<DocData::MethodDoc *> signals;
+ Vector<DocData::ConstantDoc *> constants;
+ Vector<DocData::PropertyDoc *> properties;
+ Vector<DocData::ThemeItemDoc *> theme_properties;
+
+ bool required() {
+ return name || methods.size() || signals.size() || constants.size() || properties.size() || theme_properties.size();
+ }
+ };
+
+ VisualScriptPropertySelector *selector_ui;
+ Control *ui_service;
+ Tree *results_tree;
+ String term;
+ int search_flags;
+ int scope_flags;
+
+ Ref<Texture2D> empty_icon;
+ Color disabled_color;
+
+ Map<String, DocData::ClassDoc>::Element *iterator_doc = nullptr;
+ Map<String, ClassMatch> matches;
+ Map<String, ClassMatch>::Element *iterator_match = nullptr;
+ TreeItem *root_item = nullptr;
+ Map<String, TreeItem *> class_items;
+ TreeItem *matched_item = nullptr;
+ float match_highest_score = 0;
+
+ Map<String, DocData::ClassDoc> combined_docs;
+ List<String> vs_nodes;
+
+ bool _is_class_disabled_by_feature_profile(const StringName &p_class);
+ bool _is_class_disabled_by_scope(const StringName &p_class);
+
+ bool _slice();
+ bool _phase_init();
+ bool _phase_match_classes_init();
+ bool _phase_node_classes_init();
+ bool _phase_node_classes_build();
+ bool _phase_match_classes();
+ bool _phase_class_items_init();
+ bool _phase_class_items();
+ bool _phase_member_items_init();
+ bool _phase_member_items();
+ bool _phase_select_match();
+
+ bool _match_string(const String &p_term, const String &p_string) const;
+ bool _match_visual_script(DocData::ClassDoc &class_doc);
+ bool _match_is_hidden(DocData::ClassDoc &class_doc);
+ void _match_item(TreeItem *p_item, const String &p_text);
+ void _add_class_doc(String class_name, String inherits, String category);
+ DocData::MethodDoc _get_method_doc(MethodInfo method_info);
+ TreeItem *_create_class_hierarchy(const ClassMatch &p_match);
+ TreeItem *_create_class_item(TreeItem *p_parent, const DocData::ClassDoc *p_doc, bool p_gray);
+ TreeItem *_create_method_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const String &p_text, const DocData::MethodDoc *p_doc);
+ TreeItem *_create_signal_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc);
+ TreeItem *_create_constant_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ConstantDoc *p_doc);
+ TreeItem *_create_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::PropertyDoc *p_doc);
+ TreeItem *_create_theme_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ThemeItemDoc *p_doc);
+ TreeItem *_create_member_item(TreeItem *p_parent, const String &p_class_name, const String &p_icon, const String &p_name, const String &p_text, const String &p_type, const String &p_metatype, const String &p_tooltip, const String &p_description);
+
+public:
+ bool work(uint64_t slot = 100000);
+
+ SearchRunner(VisualScriptPropertySelector *p_selector_ui, Tree *p_results_tree);
+};
+
#endif // VISUALSCRIPT_PROPERTYSELECTOR_H
diff --git a/modules/visual_script/icons/VisualScript.svg b/modules/visual_script/icons/VisualScript.svg
index 2352ba5d87..bc698247c9 100644
--- a/modules/visual_script/icons/VisualScript.svg
+++ b/modules/visual_script/icons/VisualScript.svg
@@ -1 +1 @@
-<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g transform="translate(0 -1036.4)"><ellipse cx="3" cy="1039.4" fill="#6e6e6e"/><path d="m7 1-.56445 2.2578a5 5 0 0 0 -.68945.2793l-1.9883-1.1934-1.4141 1.4141 1.1953 1.9941a5 5 0 0 0 -.28516.68555l-2.2539.5625v2h5.2715a2 2 0 0 1 -.27148-1 2 2 0 0 1 2-2 2 2 0 0 1 2 2 2 2 0 0 1 -.26953 1h5.2695v-2l-2.2578-.56445a5 5 0 0 0 -.2793-.6875l1.1934-1.9902-1.4141-1.4141-1.9941 1.1953a5 5 0 0 0 -.68555-.28516l-.5625-2.2539h-2zm-4 9v6h2a3 3 0 0 0 3-3v-3h-2v3a1 1 0 0 1 -1 1v-4zm8 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-2z" fill="#e0e0e0" transform="translate(0 1036.4)"/></g></svg>
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g transform="translate(0 -1036.4)"><ellipse cx="3" cy="1039.4" fill="#e0e0e0"/><path d="m7 1-.56445 2.2578a5 5 0 0 0 -.68945.2793l-1.9883-1.1934-1.4141 1.4141 1.1953 1.9941a5 5 0 0 0 -.28516.68555l-2.2539.5625v2h5.2715a2 2 0 0 1 -.27148-1 2 2 0 0 1 2-2 2 2 0 0 1 2 2 2 2 0 0 1 -.26953 1h5.2695v-2l-2.2578-.56445a5 5 0 0 0 -.2793-.6875l1.1934-1.9902-1.4141-1.4141-1.9941 1.1953a5 5 0 0 0 -.68555-.28516l-.5625-2.2539h-2zm-4 9v6h2a3 3 0 0 0 3-3v-3h-2v3a1 1 0 0 1 -1 1v-4zm8 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-2z" fill="#e0e0e0" transform="translate(0 1036.4)"/></g></svg>
diff --git a/modules/visual_script/icons/VisualScriptInternal.svg b/modules/visual_script/icons/VisualScriptInternal.svg
new file mode 100644
index 0000000000..8ab39ad929
--- /dev/null
+++ b/modules/visual_script/icons/VisualScriptInternal.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><circle cx="3" cy="3.000024" fill="#e0e0e0" r="0"/><path d="m11 10a2 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-2z" fill="#e0e0e0"/><path d="m3 10v6h2a3 3 0 0 0 3-3v-3h-2v3a1 1 0 0 1 -1 1v-4z" fill="#e0e0e0"/><path d="m7 1-.56445 2.2578a5 5 0 0 0 -.68945.2793l-1.9883-1.1934-1.4141 1.4141 1.1953 1.9941a5 5 0 0 0 -.28516.68555l-2.2539.5625v2h5.2715a2 2 0 0 1 -.27148-1 2 2 0 0 1 2-2 2 2 0 0 1 2 2 2 2 0 0 1 -.26953 1h5.2695v-2l-2.2578-.56445a5 5 0 0 0 -.2793-.6875l1.1934-1.9902-1.4141-1.4141-1.9941 1.1953a5 5 0 0 0 -.68555-.28516l-.5625-2.2539h-2z" fill="none" stroke="#e0e0e0"/></svg>
diff --git a/modules/visual_script/register_types.cpp b/modules/visual_script/register_types.cpp
index 6f56fbbc70..e7b5f58174 100644
--- a/modules/visual_script/register_types.cpp
+++ b/modules/visual_script/register_types.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/modules/visual_script/register_types.h b/modules/visual_script/register_types.h
index b02a93ebc1..29768da67f 100644
--- a/modules/visual_script/register_types.h
+++ b/modules/visual_script/register_types.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index 63bd9bbee4..88445f2f98 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -1164,9 +1164,6 @@ void VisualScript::_bind_methods() {
ClassDB::bind_method(D_METHOD("remove_custom_signal", "name"), &VisualScript::remove_custom_signal);
ClassDB::bind_method(D_METHOD("rename_custom_signal", "name", "new_name"), &VisualScript::rename_custom_signal);
- //ClassDB::bind_method(D_METHOD("set_variable_info","name","info"),&VScript::set_variable_info);
- //ClassDB::bind_method(D_METHOD("get_variable_info","name"),&VScript::set_variable_info);
-
ClassDB::bind_method(D_METHOD("set_instance_base_type", "type"), &VisualScript::set_instance_base_type);
ClassDB::bind_method(D_METHOD("_set_data", "data"), &VisualScript::_set_data);
@@ -2241,20 +2238,15 @@ void VisualScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) co
void VisualScriptLanguage::get_string_delimiters(List<String> *p_delimiters) const {
}
-Ref<Script> VisualScriptLanguage::get_template(const String &p_class_name, const String &p_base_class_name) const {
- Ref<VisualScript> script;
- script.instantiate();
- script->set_instance_base_type(p_base_class_name);
- return script;
-}
-
bool VisualScriptLanguage::is_using_templates() {
- return true;
+ return false;
}
-void VisualScriptLanguage::make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script) {
- Ref<VisualScript> script = p_script;
+Ref<Script> VisualScriptLanguage::make_template(const String &p_template, const String &p_class_name, const String &p_base_class_name) const {
+ Ref<VisualScript> script;
+ script.instantiate();
script->set_instance_base_type(p_base_class_name);
+ return script;
}
bool VisualScriptLanguage::validate(const String &p_script, const String &p_path, List<String> *r_functions, List<ScriptLanguage::ScriptError> *r_errors, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h
index 39cef8f68b..e5c8ab48ee 100644
--- a/modules/visual_script/visual_script.h
+++ b/modules/visual_script/visual_script.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -554,57 +554,56 @@ public:
//////////////////////////////////////
- virtual String get_name() const;
+ virtual String get_name() const override;
/* 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();
+ virtual void init() override;
+ virtual String get_type() const override;
+ virtual String get_extension() const override;
+ virtual Error execute_file(const String &p_path) override;
+ virtual void finish() override;
/* 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, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::ScriptError> *r_errors = 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 PackedStringArray &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);
+ virtual void get_reserved_words(List<String> *p_words) const override;
+ virtual bool is_control_flow_keyword(String p_keyword) const override;
+ virtual void get_comment_delimiters(List<String> *p_delimiters) const override;
+ virtual void get_string_delimiters(List<String> *p_delimiters) const override;
+ virtual bool is_using_templates() override;
+ virtual Ref<Script> make_template(const String &p_template, const String &p_class_name, const String &p_base_class_name) const override;
+ virtual bool validate(const String &p_script, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::ScriptError> *r_errors = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const override;
+ virtual Script *create_script() const override;
+ virtual bool has_named_classes() const override;
+ virtual bool supports_builtin_mode() const override;
+ virtual int find_function(const String &p_function, const String &p_code) const override;
+ virtual String make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const override;
+ virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const override;
+ virtual void add_global_constant(const StringName &p_variable, const Variant &p_value) override;
/* 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);
+ virtual String debug_get_error() const override;
+ virtual int debug_get_stack_level_count() const override;
+ virtual int debug_get_stack_level_line(int p_level) const override;
+ virtual String debug_get_stack_level_function(int p_level) const override;
+ virtual String debug_get_stack_level_source(int p_level) const override;
+ 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) override;
+ 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) override;
+ virtual void debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1) override;
+ virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems = -1, int p_max_depth = -1) override;
+
+ virtual void reload_all_scripts() override;
+ virtual void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) override;
/* 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 get_recognized_extensions(List<String> *p_extensions) const override;
+ virtual void get_public_functions(List<MethodInfo> *p_functions) const override;
+ virtual void get_public_constants(List<Pair<String, Variant>> *p_constants) const override;
- virtual void profiling_start();
- virtual void profiling_stop();
+ virtual void profiling_start() override;
+ virtual void profiling_stop() override;
- 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);
+ virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max) override;
+ virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max) override;
void add_register_func(const String &p_name, VisualScriptNodeRegisterFunc p_func);
void remove_register_func(const String &p_name);
diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp
index 7ae85ea415..fd55796a66 100644
--- a/modules/visual_script/visual_script_builtin_funcs.cpp
+++ b/modules/visual_script/visual_script_builtin_funcs.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -964,7 +964,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
return;
}
- if (p_inputs[0]->is_ref()) {
+ if (p_inputs[0]->is_ref_counted()) {
REF r = *p_inputs[0];
if (!r.is_valid()) {
return;
diff --git a/modules/visual_script/visual_script_builtin_funcs.h b/modules/visual_script/visual_script_builtin_funcs.h
index f71a053f7d..d689296233 100644
--- a/modules/visual_script/visual_script_builtin_funcs.h
+++ b/modules/visual_script/visual_script_builtin_funcs.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp
index 699042ffa6..e8942b9788 100644
--- a/modules/visual_script/visual_script_expression.cpp
+++ b/modules/visual_script/visual_script_expression.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -176,7 +176,7 @@ PropertyInfo VisualScriptExpression::get_output_value_port_info(int p_idx) const
}
String VisualScriptExpression::get_caption() const {
- return "Expression";
+ return TTR("Expression");
}
String VisualScriptExpression::get_text() const {
@@ -328,6 +328,7 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
};
case '"': {
String str;
+ char32_t prev = 0;
while (true) {
char32_t ch = GET_CHAR();
@@ -364,9 +365,11 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
case 'r':
res = 13;
break;
+ case 'U':
case 'u': {
- // hex number
- for (int j = 0; j < 4; j++) {
+ // Hexadecimal sequence.
+ int hex_len = (next == 'U') ? 6 : 4;
+ for (int j = 0; j < hex_len; j++) {
char32_t c = GET_CHAR();
if (c == 0) {
@@ -374,13 +377,13 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
r_token.type = TK_ERROR;
return ERR_PARSE_ERROR;
}
- if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))) {
+ if (!is_hex_digit(c)) {
_set_error("Malformed hex constant in string");
r_token.type = TK_ERROR;
return ERR_PARSE_ERROR;
}
char32_t v;
- if (c >= '0' && c <= '9') {
+ if (is_digit(c)) {
v = c - '0';
} else if (c >= 'a' && c <= 'f') {
v = c - 'a';
@@ -403,12 +406,46 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
} break;
}
+ // Parse UTF-16 pair.
+ if ((res & 0xfffffc00) == 0xd800) {
+ if (prev == 0) {
+ prev = res;
+ continue;
+ } else {
+ _set_error("Invalid UTF-16 sequence in string, unpaired lead surrogate");
+ r_token.type = TK_ERROR;
+ return ERR_PARSE_ERROR;
+ }
+ } else if ((res & 0xfffffc00) == 0xdc00) {
+ if (prev == 0) {
+ _set_error("Invalid UTF-16 sequence in string, unpaired trail surrogate");
+ r_token.type = TK_ERROR;
+ return ERR_PARSE_ERROR;
+ } else {
+ res = (prev << 10UL) + res - ((0xd800 << 10UL) + 0xdc00 - 0x10000);
+ prev = 0;
+ }
+ }
+ if (prev != 0) {
+ _set_error("Invalid UTF-16 sequence in string, unpaired lead surrogate");
+ r_token.type = TK_ERROR;
+ return ERR_PARSE_ERROR;
+ }
str += res;
-
} else {
+ if (prev != 0) {
+ _set_error("Invalid UTF-16 sequence in string, unpaired lead surrogate");
+ r_token.type = TK_ERROR;
+ return ERR_PARSE_ERROR;
+ }
str += ch;
}
}
+ if (prev != 0) {
+ _set_error("Invalid UTF-16 sequence in string, unpaired lead surrogate");
+ r_token.type = TK_ERROR;
+ return ERR_PARSE_ERROR;
+ }
r_token.type = TK_CONSTANT;
r_token.value = str;
@@ -420,7 +457,7 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
break;
}
- if (cchar >= '0' && cchar <= '9') {
+ if (is_digit(cchar)) {
//a number
String num;
@@ -439,7 +476,7 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
while (true) {
switch (reading) {
case READING_INT: {
- if (c >= '0' && c <= '9') {
+ if (is_digit(c)) {
//pass
} else if (c == '.') {
reading = READING_DEC;
@@ -452,7 +489,7 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
} break;
case READING_DEC: {
- if (c >= '0' && c <= '9') {
+ if (is_digit(c)) {
} else if (c == 'e') {
reading = READING_EXP;
@@ -462,7 +499,7 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
} break;
case READING_EXP: {
- if (c >= '0' && c <= '9') {
+ if (is_digit(c)) {
exp_beg = true;
} else if ((c == '-' || c == '+') && !exp_sign && !exp_beg) {
@@ -495,11 +532,11 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
}
return OK;
- } else if ((cchar >= 'A' && cchar <= 'Z') || (cchar >= 'a' && cchar <= 'z') || cchar == '_') {
+ } else if (is_ascii_char(cchar) || cchar == '_') {
String id;
bool first = true;
- while ((cchar >= 'A' && cchar <= 'Z') || (cchar >= 'a' && cchar <= 'z') || cchar == '_' || (!first && cchar >= '0' && cchar <= '9')) {
+ while (is_ascii_char(cchar) || cchar == '_' || (!first && is_digit(cchar))) {
id += String::chr(cchar);
cchar = GET_CHAR();
first = false;
diff --git a/modules/visual_script/visual_script_expression.h b/modules/visual_script/visual_script_expression.h
index ef16222b42..c93eb0686b 100644
--- a/modules/visual_script/visual_script_expression.h
+++ b/modules/visual_script/visual_script_expression.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp
index 278d806595..fd1861abc4 100644
--- a/modules/visual_script/visual_script_flow_control.cpp
+++ b/modules/visual_script/visual_script_flow_control.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -70,7 +70,7 @@ PropertyInfo VisualScriptReturn::get_output_value_port_info(int p_idx) const {
}
String VisualScriptReturn::get_caption() const {
- return "Return";
+ return TTR("Return");
}
String VisualScriptReturn::get_text() const {
@@ -201,11 +201,11 @@ PropertyInfo VisualScriptCondition::get_output_value_port_info(int p_idx) const
}
String VisualScriptCondition::get_caption() const {
- return "Condition";
+ return TTR("Condition");
}
String VisualScriptCondition::get_text() const {
- return "if (cond) is: ";
+ return TTR("if (cond) is:");
}
void VisualScriptCondition::_bind_methods() {
@@ -281,11 +281,11 @@ PropertyInfo VisualScriptWhile::get_output_value_port_info(int p_idx) const {
}
String VisualScriptWhile::get_caption() const {
- return "While";
+ return TTR("While");
}
String VisualScriptWhile::get_text() const {
- return "while (cond): ";
+ return TTR("while (cond):");
}
void VisualScriptWhile::_bind_methods() {
@@ -364,11 +364,11 @@ PropertyInfo VisualScriptIterator::get_output_value_port_info(int p_idx) const {
}
String VisualScriptIterator::get_caption() const {
- return "Iterator";
+ return TTR("Iterator");
}
String VisualScriptIterator::get_text() const {
- return "for (elem) in (input): ";
+ return TTR("for (elem) in (input):");
}
void VisualScriptIterator::_bind_methods() {
@@ -478,11 +478,11 @@ PropertyInfo VisualScriptSequence::get_output_value_port_info(int p_idx) const {
}
String VisualScriptSequence::get_caption() const {
- return "Sequence";
+ return TTR("Sequence");
}
String VisualScriptSequence::get_text() const {
- return "in order: ";
+ return TTR("in order:");
}
void VisualScriptSequence::set_steps(int p_steps) {
@@ -587,11 +587,11 @@ PropertyInfo VisualScriptSwitch::get_output_value_port_info(int p_idx) const {
}
String VisualScriptSwitch::get_caption() const {
- return "Switch";
+ return TTR("Switch");
}
String VisualScriptSwitch::get_text() const {
- return "'input' is:";
+ return TTR("'input' is:");
}
class VisualScriptNodeInstanceSwitch : public VisualScriptNodeInstance {
@@ -720,14 +720,14 @@ PropertyInfo VisualScriptTypeCast::get_output_value_port_info(int p_idx) const {
}
String VisualScriptTypeCast::get_caption() const {
- return "Type Cast";
+ return TTR("Type Cast");
}
String VisualScriptTypeCast::get_text() const {
if (!script.is_empty()) {
- return "Is " + script.get_file() + "?";
+ return vformat(TTR("Is %s?"), script.get_file());
} else {
- return "Is " + base_type + "?";
+ return vformat(TTR("Is %s?"), base_type);
}
}
diff --git a/modules/visual_script/visual_script_flow_control.h b/modules/visual_script/visual_script_flow_control.h
index 73822fcc37..7ffdf3df65 100644
--- a/modules/visual_script/visual_script_flow_control.h
+++ b/modules/visual_script/visual_script_flow_control.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp
index 651464dfdb..ef6c1ecdb9 100644
--- a/modules/visual_script/visual_script_func_nodes.cpp
+++ b/modules/visual_script/visual_script_func_nodes.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -261,13 +261,13 @@ String VisualScriptFunctionCall::get_text() const {
String text;
if (call_mode == CALL_MODE_BASIC_TYPE) {
- text = String("On ") + Variant::get_type_name(basic_type);
+ text = vformat(TTR("On %s"), Variant::get_type_name(basic_type));
} else if (call_mode == CALL_MODE_INSTANCE) {
- text = String("On ") + base_type;
+ text = vformat(TTR("On %s"), base_type);
} else if (call_mode == CALL_MODE_NODE_PATH) {
text = "[" + String(base_path.simplified()) + "]";
} else if (call_mode == CALL_MODE_SELF) {
- text = "On Self";
+ text = TTR("On Self");
} else if (call_mode == CALL_MODE_SINGLETON) {
text = String(singleton) + ":" + String(function) + "()";
}
@@ -912,7 +912,7 @@ int VisualScriptPropertySet::get_output_sequence_port_count() const {
}
bool VisualScriptPropertySet::has_input_sequence_port() const {
- return 1;
+ return true;
}
Node *VisualScriptPropertySet::_get_base_node() const {
@@ -1033,15 +1033,25 @@ PropertyInfo VisualScriptPropertySet::get_output_value_port_info(int p_idx) cons
String VisualScriptPropertySet::get_caption() const {
static const char *opname[ASSIGN_OP_MAX] = {
- "Set", "Add", "Subtract", "Multiply", "Divide", "Mod", "ShiftLeft", "ShiftRight", "BitAnd", "BitOr", "BitXor"
+ TTRC("Set %s"),
+ TTRC("Add %s"),
+ TTRC("Subtract %s"),
+ TTRC("Multiply %s"),
+ TTRC("Divide %s"),
+ TTRC("Mod %s"),
+ TTRC("ShiftLeft %s"),
+ TTRC("ShiftRight %s"),
+ TTRC("BitAnd %s"),
+ TTRC("BitOr %s"),
+ TTRC("BitXor %s")
};
- String prop = String(opname[assign_op]) + " " + property;
+ String prop = property;
if (index != StringName()) {
prop += "." + String(index);
}
- return prop;
+ return vformat(TTRGET(opname[assign_op]), prop);
}
String VisualScriptPropertySet::get_text() const {
@@ -1049,13 +1059,13 @@ String VisualScriptPropertySet::get_text() const {
return "";
}
if (call_mode == CALL_MODE_BASIC_TYPE) {
- return String("On ") + Variant::get_type_name(basic_type);
+ return vformat(TTR("On %s"), Variant::get_type_name(basic_type));
} else if (call_mode == CALL_MODE_INSTANCE) {
- return String("On ") + base_type;
+ return vformat(TTR("On %s"), base_type);
} else if (call_mode == CALL_MODE_NODE_PATH) {
return " [" + String(base_path.simplified()) + "]";
} else {
- return "On Self";
+ return TTR("On Self");
}
}
@@ -1761,23 +1771,23 @@ PropertyInfo VisualScriptPropertyGet::get_output_value_port_info(int p_idx) cons
}
String VisualScriptPropertyGet::get_caption() const {
- String prop = String("Get ") + property;
+ String prop = property;
if (index != StringName()) {
prop += "." + String(index);
}
- return prop;
+ return vformat(TTR("Get %s"), prop);
}
String VisualScriptPropertyGet::get_text() const {
if (call_mode == CALL_MODE_BASIC_TYPE) {
- return String("On ") + Variant::get_type_name(basic_type);
+ return vformat(TTR("On %s"), Variant::get_type_name(basic_type));
} else if (call_mode == CALL_MODE_INSTANCE) {
- return String("On ") + base_type;
+ return vformat(TTR("On %s"), base_type);
} else if (call_mode == CALL_MODE_NODE_PATH) {
return " [" + String(base_path.simplified()) + "]";
} else {
- return "On Self";
+ return TTR("On Self");
}
}
@@ -2293,7 +2303,7 @@ PropertyInfo VisualScriptEmitSignal::get_output_value_port_info(int p_idx) const
}
String VisualScriptEmitSignal::get_caption() const {
- return "Emit " + String(name);
+ return vformat(TTR("Emit %s"), name);
}
void VisualScriptEmitSignal::set_signal(const StringName &p_type) {
@@ -2316,10 +2326,12 @@ void VisualScriptEmitSignal::_validate_property(PropertyInfo &property) const {
property.hint = PROPERTY_HINT_ENUM;
List<StringName> sigs;
+ List<MethodInfo> base_sigs;
Ref<VisualScript> vs = get_visual_script();
if (vs.is_valid()) {
vs->get_custom_signal_list(&sigs);
+ ClassDB::get_signal_list(vs->get_instance_base_type(), &base_sigs);
}
String ml;
@@ -2329,6 +2341,12 @@ void VisualScriptEmitSignal::_validate_property(PropertyInfo &property) const {
}
ml += E;
}
+ for (const MethodInfo &E : base_sigs) {
+ if (!ml.is_empty()) {
+ ml += ",";
+ }
+ ml += E.name;
+ }
property.hint_string = ml;
}
diff --git a/modules/visual_script/visual_script_func_nodes.h b/modules/visual_script/visual_script_func_nodes.h
index cca08455f9..886ed7bc81 100644
--- a/modules/visual_script/visual_script_func_nodes.h
+++ b/modules/visual_script/visual_script_func_nodes.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index bb4c83bd24..e7f4e542c1 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -204,7 +204,7 @@ PropertyInfo VisualScriptFunction::get_output_value_port_info(int p_idx) const {
}
String VisualScriptFunction::get_caption() const {
- return "Function";
+ return TTR("Function");
}
String VisualScriptFunction::get_text() const {
@@ -767,7 +767,7 @@ PropertyInfo VisualScriptComposeArray::get_output_value_port_info(int p_idx) con
}
String VisualScriptComposeArray::get_caption() const {
- return "Compose Array";
+ return TTR("Compose Array");
}
String VisualScriptComposeArray::get_text() const {
@@ -1186,11 +1186,11 @@ PropertyInfo VisualScriptSelect::get_output_value_port_info(int p_idx) const {
}
String VisualScriptSelect::get_caption() const {
- return "Select";
+ return TTR("Select");
}
String VisualScriptSelect::get_text() const {
- return "a if cond, else b";
+ return TTR("a if cond, else b");
}
void VisualScriptSelect::set_typed(Variant::Type p_op) {
@@ -1284,7 +1284,7 @@ PropertyInfo VisualScriptVariableGet::get_output_value_port_info(int p_idx) cons
}
String VisualScriptVariableGet::get_caption() const {
- return "Get " + variable;
+ return vformat(TTR("Get %s"), variable);
}
void VisualScriptVariableGet::set_variable(StringName p_variable) {
@@ -1394,7 +1394,7 @@ PropertyInfo VisualScriptVariableSet::get_output_value_port_info(int p_idx) cons
}
String VisualScriptVariableSet::get_caption() const {
- return "Set " + variable;
+ return vformat(TTR("Set %s"), variable);
}
void VisualScriptVariableSet::set_variable(StringName p_variable) {
@@ -1501,7 +1501,7 @@ PropertyInfo VisualScriptConstant::get_output_value_port_info(int p_idx) const {
}
String VisualScriptConstant::get_caption() const {
- return "Constant";
+ return TTR("Constant");
}
void VisualScriptConstant::set_constant_type(Variant::Type p_type) {
@@ -1628,7 +1628,7 @@ PropertyInfo VisualScriptPreload::get_output_value_port_info(int p_idx) const {
}
String VisualScriptPreload::get_caption() const {
- return "Preload";
+ return TTR("Preload");
}
void VisualScriptPreload::set_preload(const Ref<Resource> &p_preload) {
@@ -1708,7 +1708,7 @@ PropertyInfo VisualScriptIndexGet::get_output_value_port_info(int p_idx) const {
}
String VisualScriptIndexGet::get_caption() const {
- return "Get Index";
+ return TTR("Get Index");
}
class VisualScriptNodeInstanceIndexGet : public VisualScriptNodeInstance {
@@ -1775,7 +1775,7 @@ PropertyInfo VisualScriptIndexSet::get_output_value_port_info(int p_idx) const {
}
String VisualScriptIndexSet::get_caption() const {
- return "Set Index";
+ return TTR("Set Index");
}
class VisualScriptNodeInstanceIndexSet : public VisualScriptNodeInstance {
@@ -1839,7 +1839,7 @@ PropertyInfo VisualScriptGlobalConstant::get_output_value_port_info(int p_idx) c
}
String VisualScriptGlobalConstant::get_caption() const {
- return "Global Constant";
+ return TTR("Global Constant");
}
void VisualScriptGlobalConstant::set_global_constant(int p_which) {
@@ -1925,7 +1925,7 @@ PropertyInfo VisualScriptClassConstant::get_output_value_port_info(int p_idx) co
}
String VisualScriptClassConstant::get_caption() const {
- return "Class Constant";
+ return TTR("Class Constant");
}
void VisualScriptClassConstant::set_class_constant(const StringName &p_which) {
@@ -2050,7 +2050,7 @@ PropertyInfo VisualScriptBasicTypeConstant::get_output_value_port_info(int p_idx
}
String VisualScriptBasicTypeConstant::get_caption() const {
- return "Basic Constant";
+ return TTR("Basic Constant");
}
String VisualScriptBasicTypeConstant::get_text() const {
@@ -2215,7 +2215,7 @@ PropertyInfo VisualScriptMathConstant::get_output_value_port_info(int p_idx) con
}
String VisualScriptMathConstant::get_caption() const {
- return "Math Constant";
+ return TTR("Math Constant");
}
void VisualScriptMathConstant::set_math_constant(MathConstant p_which) {
@@ -2307,7 +2307,7 @@ PropertyInfo VisualScriptEngineSingleton::get_output_value_port_info(int p_idx)
}
String VisualScriptEngineSingleton::get_caption() const {
- return "Get Engine Singleton";
+ return TTR("Get Engine Singleton");
}
void VisualScriptEngineSingleton::set_singleton(const String &p_string) {
@@ -2417,7 +2417,7 @@ PropertyInfo VisualScriptSceneNode::get_output_value_port_info(int p_idx) const
}
String VisualScriptSceneNode::get_caption() const {
- return "Get Scene Node";
+ return TTR("Get Scene Node");
}
void VisualScriptSceneNode::set_node_path(const NodePath &p_path) {
@@ -2495,7 +2495,7 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const
VisualScriptSceneNode::TypeGuess VisualScriptSceneNode::guess_output_type(TypeGuess *p_inputs, int p_output) const {
VisualScriptSceneNode::TypeGuess tg;
tg.type = Variant::OBJECT;
- tg.gdclass = "Node";
+ tg.gdclass = SNAME("Node");
#ifdef TOOLS_ENABLED
Ref<Script> script = get_visual_script();
@@ -2608,7 +2608,7 @@ PropertyInfo VisualScriptSceneTree::get_output_value_port_info(int p_idx) const
}
String VisualScriptSceneTree::get_caption() const {
- return "Get Scene Tree";
+ return TTR("Get Scene Tree");
}
class VisualScriptNodeInstanceSceneTree : public VisualScriptNodeInstance {
@@ -2649,7 +2649,7 @@ VisualScriptNodeInstance *VisualScriptSceneTree::instantiate(VisualScriptInstanc
VisualScriptSceneTree::TypeGuess VisualScriptSceneTree::guess_output_type(TypeGuess *p_inputs, int p_output) const {
TypeGuess tg;
tg.type = Variant::OBJECT;
- tg.gdclass = "SceneTree";
+ tg.gdclass = SNAME("SceneTree");
return tg;
}
@@ -2695,7 +2695,7 @@ PropertyInfo VisualScriptResourcePath::get_output_value_port_info(int p_idx) con
}
String VisualScriptResourcePath::get_caption() const {
- return "Resource Path";
+ return TTR("Resource Path");
}
void VisualScriptResourcePath::set_resource_path(const String &p_path) {
@@ -2766,18 +2766,18 @@ PropertyInfo VisualScriptSelf::get_input_value_port_info(int p_idx) const {
}
PropertyInfo VisualScriptSelf::get_output_value_port_info(int p_idx) const {
- String type_name;
+ StringName type_name;
if (get_visual_script().is_valid()) {
type_name = get_visual_script()->get_instance_base_type();
} else {
- type_name = "instance";
+ type_name = SNAME("instance");
}
return PropertyInfo(Variant::OBJECT, type_name);
}
String VisualScriptSelf::get_caption() const {
- return "Get Self";
+ return TTR("Get Self");
}
class VisualScriptNodeInstanceSelf : public VisualScriptNodeInstance {
@@ -2801,7 +2801,7 @@ VisualScriptNodeInstance *VisualScriptSelf::instantiate(VisualScriptInstance *p_
VisualScriptSelf::TypeGuess VisualScriptSelf::guess_output_type(TypeGuess *p_inputs, int p_output) const {
VisualScriptSceneNode::TypeGuess tg;
tg.type = Variant::OBJECT;
- tg.gdclass = "Object";
+ tg.gdclass = SNAME("Object");
Ref<Script> script = get_visual_script();
if (!script.is_valid()) {
@@ -2947,7 +2947,7 @@ String VisualScriptCustomNode::get_caption() const {
if (GDVIRTUAL_CALL(_get_caption, ret)) {
return ret;
}
- return "CustomNode";
+ return TTR("CustomNode");
}
String VisualScriptCustomNode::get_text() const {
@@ -3141,7 +3141,7 @@ PropertyInfo VisualScriptSubCall::get_output_value_port_info(int p_idx) const {
}
String VisualScriptSubCall::get_caption() const {
- return "SubCall";
+ return TTR("SubCall");
}
String VisualScriptSubCall::get_text() const {
@@ -3352,7 +3352,7 @@ PropertyInfo VisualScriptConstructor::get_output_value_port_info(int p_idx) cons
}
String VisualScriptConstructor::get_caption() const {
- return "Construct " + Variant::get_type_name(type);
+ return vformat(TTR("Construct %s"), Variant::get_type_name(type));
}
String VisualScriptConstructor::get_category() const {
@@ -3469,7 +3469,7 @@ PropertyInfo VisualScriptLocalVar::get_output_value_port_info(int p_idx) const {
}
String VisualScriptLocalVar::get_caption() const {
- return "Get Local Var";
+ return TTR("Get Local Var");
}
String VisualScriptLocalVar::get_category() const {
@@ -3572,7 +3572,7 @@ PropertyInfo VisualScriptLocalVarSet::get_output_value_port_info(int p_idx) cons
}
String VisualScriptLocalVarSet::get_caption() const {
- return "Set Local Var";
+ return TTR("Set Local Var");
}
String VisualScriptLocalVarSet::get_text() const {
@@ -3696,7 +3696,7 @@ PropertyInfo VisualScriptInputAction::get_output_value_port_info(int p_idx) cons
}
String VisualScriptInputAction::get_caption() const {
- return "Action " + name;
+ return vformat(TTR("Action %s"), name);
}
String VisualScriptInputAction::get_category() const {
@@ -3850,7 +3850,7 @@ PropertyInfo VisualScriptDeconstruct::get_output_value_port_info(int p_idx) cons
}
String VisualScriptDeconstruct::get_caption() const {
- return "Deconstruct " + Variant::get_type_name(type);
+ return vformat(TTR("Deconstruct %s"), Variant::get_type_name(type));
}
String VisualScriptDeconstruct::get_category() const {
diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h
index 78881f0a53..18573f8682 100644
--- a/modules/visual_script/visual_script_nodes.h
+++ b/modules/visual_script/visual_script_nodes.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp
index c5d17e5a11..fbd5ad35ab 100644
--- a/modules/visual_script/visual_script_yield_nodes.cpp
+++ b/modules/visual_script/visual_script_yield_nodes.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -68,7 +68,7 @@ PropertyInfo VisualScriptYield::get_output_value_port_info(int p_idx) const {
}
String VisualScriptYield::get_caption() const {
- return yield_mode == YIELD_RETURN ? "Yield" : "Wait";
+ return yield_mode == YIELD_RETURN ? TTR("Yield") : TTR("Wait");
}
String VisualScriptYield::get_text() const {
@@ -77,13 +77,13 @@ String VisualScriptYield::get_text() const {
return "";
break;
case YIELD_FRAME:
- return "Next Frame";
+ return TTR("Next Frame");
break;
case YIELD_PHYSICS_FRAME:
- return "Next Physics Frame";
+ return TTR("Next Physics Frame");
break;
case YIELD_WAIT:
- return rtos(wait_time) + " sec(s)";
+ return vformat(TTR("%s sec(s)"), rtos(wait_time));
break;
}
@@ -336,12 +336,12 @@ PropertyInfo VisualScriptYieldSignal::get_output_value_port_info(int p_idx) cons
String VisualScriptYieldSignal::get_caption() const {
static const char *cname[3] = {
- "WaitSignal",
- "WaitNodeSignal",
- "WaitInstanceSigna;",
+ TTRC("WaitSignal"),
+ TTRC("WaitNodeSignal"),
+ TTRC("WaitInstanceSignal"),
};
- return cname[call_mode];
+ return TTRGET(cname[call_mode]);
}
String VisualScriptYieldSignal::get_text() const {
diff --git a/modules/visual_script/visual_script_yield_nodes.h b/modules/visual_script/visual_script_yield_nodes.h
index 6005ff30b0..a7bf4e8a78 100644
--- a/modules/visual_script/visual_script_yield_nodes.h
+++ b/modules/visual_script/visual_script_yield_nodes.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */