diff options
Diffstat (limited to 'modules/visual_script')
23 files changed, 297 insertions, 226 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..ec1a8a6b42 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 */ @@ -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(script->get_instance_base_type(), mouse_up_position); + } 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(); + } } } @@ -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")); } @@ -3704,7 +3731,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 +3780,11 @@ 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->set_panning_scheme((GraphEdit::PanningScheme)EDITOR_GET("interface/editors/sub_editor_panning_scheme").operator int()); + } 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 +3900,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(script->get_instance_base_type(), mouse_up_position); + } break; case EDIT_DELETE_NODES: { _on_nodes_delete(); } break; @@ -3908,6 +3943,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 +4173,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 +4366,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 +4597,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..90e4fb9d56 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, }; @@ -123,7 +128,7 @@ class VisualScriptEditor : public ScriptEditorBase { Label *select_func_text; - bool updating_graph; + bool updating_graph = false; void _show_hint(const String &p_hint); void _hide_timer(); @@ -162,7 +167,8 @@ class VisualScriptEditor : public ScriptEditorBase { static Clipboard *clipboard; - PopupMenu *member_popup; + PopupMenu *popup_menu = nullptr; + PopupMenu *member_popup = nullptr; MemberType member_type; String member_name; @@ -172,8 +178,7 @@ class VisualScriptEditor : public ScriptEditorBase { Vector2 port_action_pos; int port_action_new_node; - bool saved_pos_dirty; - Vector2 saved_position; + bool saved_pos_dirty = false; Vector2 mouse_up_position; diff --git a/modules/visual_script/editor/visual_script_property_selector.cpp b/modules/visual_script/editor/visual_script_property_selector.cpp index 9fa35d4453..c88d10dabd 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 */ diff --git a/modules/visual_script/editor/visual_script_property_selector.h b/modules/visual_script/editor/visual_script_property_selector.h index 7a87f3d3ee..9e065548a0 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 */ diff --git a/modules/visual_script/icons/VisualScriptInternal.svg b/modules/visual_script/icons/VisualScriptInternal.svg new file mode 100644 index 0000000000..ea83047a29 --- /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="#6e6e6e" 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..fbdf3a654b 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 */ @@ -2241,20 +2241,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..99e75f9289 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 */ 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..2abbd19e12 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 { 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..cc18d48dd8 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) + "()"; } @@ -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..f3594e5164 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) { @@ -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 { @@ -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) { @@ -2777,7 +2777,7 @@ PropertyInfo VisualScriptSelf::get_output_value_port_info(int p_idx) const { } String VisualScriptSelf::get_caption() const { - return "Get Self"; + return TTR("Get Self"); } class VisualScriptNodeInstanceSelf : public VisualScriptNodeInstance { @@ -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 */ |