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/VisualScriptCustomNode.xml40
-rw-r--r--modules/visual_script/visual_script.cpp134
-rw-r--r--modules/visual_script/visual_script_editor.cpp595
-rw-r--r--modules/visual_script/visual_script_editor.h6
-rw-r--r--modules/visual_script/visual_script_expression.cpp4
-rw-r--r--modules/visual_script/visual_script_flow_control.cpp4
-rw-r--r--modules/visual_script/visual_script_func_nodes.cpp188
-rw-r--r--modules/visual_script/visual_script_func_nodes.h2
-rw-r--r--modules/visual_script/visual_script_nodes.cpp92
-rw-r--r--modules/visual_script/visual_script_nodes.h2
-rw-r--r--modules/visual_script/visual_script_property_selector.cpp112
-rw-r--r--modules/visual_script/visual_script_yield_nodes.cpp10
12 files changed, 675 insertions, 514 deletions
diff --git a/modules/visual_script/doc_classes/VisualScriptCustomNode.xml b/modules/visual_script/doc_classes/VisualScriptCustomNode.xml
index 1c23b58507..ba4eba26fd 100644
--- a/modules/visual_script/doc_classes/VisualScriptCustomNode.xml
+++ b/modules/visual_script/doc_classes/VisualScriptCustomNode.xml
@@ -30,6 +30,24 @@
Return the count of input value ports.
</description>
</method>
+ <method name="_get_input_value_port_hint" qualifiers="virtual">
+ <return type="int">
+ </return>
+ <argument index="0" name="idx" type="int">
+ </argument>
+ <description>
+ Return the specified input port's hint. See the [enum @GlobalScope.PropertyHint] hints.
+ </description>
+ </method>
+ <method name="_get_input_value_port_hint_string" qualifiers="virtual">
+ <return type="String">
+ </return>
+ <argument index="0" name="idx" type="int">
+ </argument>
+ <description>
+ Return the specified input port's hint string.
+ </description>
+ </method>
<method name="_get_input_value_port_name" qualifiers="virtual">
<return type="String">
</return>
@@ -71,13 +89,31 @@
Return the amount of output value ports.
</description>
</method>
+ <method name="_get_output_value_port_hint" qualifiers="virtual">
+ <return type="int">
+ </return>
+ <argument index="0" name="idx" type="int">
+ </argument>
+ <description>
+ Return the specified output port's hint. See the [enum @GlobalScope.PropertyHint] hints.
+ </description>
+ </method>
+ <method name="_get_output_value_port_hint_string" qualifiers="virtual">
+ <return type="String">
+ </return>
+ <argument index="0" name="idx" type="int">
+ </argument>
+ <description>
+ Return the specified output port's hint string.
+ </description>
+ </method>
<method name="_get_output_value_port_name" qualifiers="virtual">
<return type="String">
</return>
<argument index="0" name="idx" type="int">
</argument>
<description>
- Return the specified output's name.
+ Return the specified output port's name.
</description>
</method>
<method name="_get_output_value_port_type" qualifiers="virtual">
@@ -86,7 +122,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
- Return the specified output's type. See the [enum Variant.Type] values.
+ Return the specified output port's type. See the [enum Variant.Type] values.
</description>
</method>
<method name="_get_text" qualifiers="virtual">
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index c4b3f9ba44..5828529103 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -46,7 +46,7 @@ bool VisualScriptNode::is_breakpoint() const {
}
void VisualScriptNode::ports_changed_notify() {
- emit_signal("ports_changed");
+ emit_signal(SNAME("ports_changed"));
}
void VisualScriptNode::set_default_input_value(int p_port, const Variant &p_value) {
@@ -264,7 +264,7 @@ void VisualScript::_node_ports_changed(int p_id) {
#ifdef TOOLS_ENABLED
set_edited(true); // Something changed, let's set as edited.
- emit_signal("node_ports_changed", p_id);
+ emit_signal(SNAME("node_ports_changed"), p_id);
#endif
}
@@ -588,14 +588,14 @@ void VisualScript::rename_variable(const StringName &p_name, const StringName &p
variables.erase(p_name);
List<int> ids;
get_node_list(&ids);
- for (List<int>::Element *E = ids.front(); E; E = E->next()) {
- Ref<VisualScriptVariableGet> nodeget = get_node(E->get());
+ for (int &E : ids) {
+ Ref<VisualScriptVariableGet> nodeget = get_node(E);
if (nodeget.is_valid()) {
if (nodeget->get_variable() == p_name) {
nodeget->set_variable(p_new_name);
}
} else {
- Ref<VisualScriptVariableSet> nodeset = get_node(E->get());
+ Ref<VisualScriptVariableSet> nodeset = get_node(E);
if (nodeset.is_valid()) {
if (nodeset->get_variable() == p_name) {
nodeset->set_variable(p_new_name);
@@ -715,9 +715,9 @@ int VisualScript::get_available_id() const {
List<int> nds;
nodes.get_key_list(&nds);
int max = -1;
- for (const List<int>::Element *E = nds.front(); E; E = E->next()) {
- if (E->get() > max) {
- max = E->get();
+ for (const int &E : nds) {
+ if (E > max) {
+ max = E;
}
}
return (max + 1);
@@ -752,15 +752,15 @@ void VisualScript::_update_placeholders() {
List<StringName> keys;
variables.get_key_list(&keys);
- for (List<StringName>::Element *E = keys.front(); E; E = E->next()) {
- if (!variables[E->get()]._export) {
+ for (StringName &E : keys) {
+ if (!variables[E]._export) {
continue;
}
- PropertyInfo p = variables[E->get()].info;
- p.name = String(E->get());
+ PropertyInfo p = variables[E].info;
+ p.name = String(E);
pinfo.push_back(p);
- values[p.name] = variables[E->get()].default_value;
+ values[p.name] = variables[E].default_value;
}
for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) {
@@ -783,15 +783,15 @@ ScriptInstance *VisualScript::instance_create(Object *p_this) {
List<StringName> keys;
variables.get_key_list(&keys);
- for (const List<StringName>::Element *E = keys.front(); E; E = E->next()) {
- if (!variables[E->get()]._export) {
+ for (const StringName &E : keys) {
+ if (!variables[E]._export) {
continue;
}
- PropertyInfo p = variables[E->get()].info;
- p.name = String(E->get());
+ PropertyInfo p = variables[E].info;
+ p.name = String(E);
pinfo.push_back(p);
- values[p.name] = variables[E->get()].default_value;
+ values[p.name] = variables[E].default_value;
}
sins->update(pinfo, values);
@@ -874,11 +874,11 @@ void VisualScript::get_script_method_list(List<MethodInfo> *p_list) const {
List<StringName> funcs;
functions.get_key_list(&funcs);
- for (List<StringName>::Element *E = funcs.front(); E; E = E->next()) {
+ for (StringName &E : funcs) {
MethodInfo mi;
- mi.name = E->get();
- if (functions[E->get()].func_id >= 0) {
- Ref<VisualScriptFunction> func = nodes[functions[E->get()].func_id].node;
+ mi.name = E;
+ if (functions[E].func_id >= 0) {
+ Ref<VisualScriptFunction> func = nodes[functions[E].func_id].node;
if (func.is_valid()) {
for (int i = 0; i < func->get_argument_count(); i++) {
PropertyInfo arg;
@@ -928,10 +928,10 @@ void VisualScript::get_script_property_list(List<PropertyInfo> *p_list) const {
List<StringName> vars;
get_variable_list(&vars);
- for (List<StringName>::Element *E = vars.front(); E; E = E->next()) {
- //if (!variables[E->get()]._export)
+ for (StringName &E : vars) {
+ //if (!variables[E]._export)
// continue;
- PropertyInfo pi = variables[E->get()].info;
+ PropertyInfo pi = variables[E].info;
pi.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE;
p_list->push_back(pi);
}
@@ -945,8 +945,8 @@ int VisualScript::get_member_line(const StringName &p_member) const {
bool VisualScript::are_subnodes_edited() const {
List<int> keys;
nodes.get_key_list(&keys);
- for (const List<int>::Element *F = keys.front(); F; F = F->next()) {
- if (nodes[F->get()].node->is_edited()) {
+ for (const int &F : keys) {
+ if (nodes[F].node->is_edited()) {
return true;
}
}
@@ -1017,13 +1017,13 @@ void VisualScript::_set_data(const Dictionary &p_data) {
rpc_functions.clear();
List<StringName> fns;
functions.get_key_list(&fns);
- for (const List<StringName>::Element *E = fns.front(); E; E = E->next()) {
- if (functions[E->get()].func_id >= 0 && nodes.has(functions[E->get()].func_id)) {
- Ref<VisualScriptFunction> vsf = nodes[functions[E->get()].func_id].node;
+ for (const StringName &E : fns) {
+ if (functions[E].func_id >= 0 && nodes.has(functions[E].func_id)) {
+ Ref<VisualScriptFunction> vsf = nodes[functions[E].func_id].node;
if (vsf.is_valid()) {
if (vsf->get_rpc_mode() != MultiplayerAPI::RPC_MODE_DISABLED) {
MultiplayerAPI::RPCConfig nd;
- nd.name = E->get();
+ nd.name = E;
nd.rpc_mode = vsf->get_rpc_mode();
nd.transfer_mode = MultiplayerPeer::TRANSFER_MODE_RELIABLE; // TODO
if (rpc_functions.find(nd) == -1) {
@@ -1045,11 +1045,11 @@ Dictionary VisualScript::_get_data() const {
Array vars;
List<StringName> var_names;
variables.get_key_list(&var_names);
- for (const List<StringName>::Element *E = var_names.front(); E; E = E->next()) {
- Dictionary var = _get_variable_info(E->get());
- var["name"] = E->get(); // Make sure it's the right one.
- var["default_value"] = variables[E->get()].default_value;
- var["export"] = variables[E->get()]._export;
+ for (const StringName &E : var_names) {
+ Dictionary var = _get_variable_info(E);
+ var["name"] = E; // Make sure it's the right one.
+ var["default_value"] = variables[E].default_value;
+ var["export"] = variables[E]._export;
vars.push_back(var);
}
d["variables"] = vars;
@@ -1073,10 +1073,10 @@ Dictionary VisualScript::_get_data() const {
Array funcs;
List<StringName> func_names;
functions.get_key_list(&func_names);
- for (const List<StringName>::Element *E = func_names.front(); E; E = E->next()) {
+ for (const StringName &E : func_names) {
Dictionary func;
- func["name"] = E->get();
- func["function_id"] = functions[E->get()].func_id;
+ func["name"] = E;
+ func["function_id"] = functions[E].func_id;
funcs.push_back(func);
}
d["functions"] = funcs;
@@ -1084,10 +1084,10 @@ Dictionary VisualScript::_get_data() const {
Array nds;
List<int> node_ids;
nodes.get_key_list(&node_ids);
- for (const List<int>::Element *F = node_ids.front(); F; F = F->next()) {
- nds.push_back(F->get());
- nds.push_back(nodes[F->get()].pos);
- nds.push_back(nodes[F->get()].node);
+ for (const int &F : node_ids) {
+ nds.push_back(F);
+ nds.push_back(nodes[F].pos);
+ nds.push_back(nodes[F].node);
}
d["nodes"] = nds;
@@ -1202,8 +1202,8 @@ VisualScript::~VisualScript() {
// Remove all nodes and stuff that hold data refs.
List<int> nds;
nodes.get_key_list(&nds);
- for (const List<int>::Element *E = nds.front(); E; E = E->next()) {
- remove_node(E->get());
+ for (const int &E : nds) {
+ remove_node(E);
}
}
@@ -1233,12 +1233,12 @@ bool VisualScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
void VisualScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const {
List<StringName> vars;
script->variables.get_key_list(&vars);
- for (const List<StringName>::Element *E = vars.front(); E; E = E->next()) {
- if (!script->variables[E->get()]._export) {
+ for (const StringName &E : vars) {
+ if (!script->variables[E]._export) {
continue;
}
- PropertyInfo p = script->variables[E->get()].info;
- p.name = String(E->get());
+ PropertyInfo p = script->variables[E].info;
+ p.name = String(E);
p.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE;
p_properties->push_back(p);
}
@@ -1262,11 +1262,11 @@ Variant::Type VisualScriptInstance::get_property_type(const StringName &p_name,
void VisualScriptInstance::get_method_list(List<MethodInfo> *p_list) const {
List<StringName> fns;
script->functions.get_key_list(&fns);
- for (const List<StringName>::Element *E = fns.front(); E; E = E->next()) {
+ for (const StringName &E : fns) {
MethodInfo mi;
- mi.name = E->get();
- if (script->functions[E->get()].func_id >= 0 && script->nodes.has(script->functions[E->get()].func_id)) {
- Ref<VisualScriptFunction> vsf = script->nodes[script->functions[E->get()].func_id].node;
+ mi.name = E;
+ if (script->functions[E].func_id >= 0 && script->nodes.has(script->functions[E].func_id)) {
+ Ref<VisualScriptFunction> vsf = script->nodes[script->functions[E].func_id].node;
if (vsf.is_valid()) {
for (int i = 0; i < vsf->get_argument_count(); i++) {
PropertyInfo arg;
@@ -1868,8 +1868,8 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
{
List<StringName> keys;
script->variables.get_key_list(&keys);
- for (const List<StringName>::Element *E = keys.front(); E; E = E->next()) {
- variables[E->get()] = script->variables[E->get()].default_value;
+ for (const StringName &E : keys) {
+ variables[E] = script->variables[E].default_value;
}
}
@@ -1877,8 +1877,8 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
{
List<StringName> keys;
script->functions.get_key_list(&keys);
- for (const List<StringName>::Element *E = keys.front(); E; E = E->next()) {
- const VisualScript::Function vsfn = p_script->functions[E->get()];
+ for (const StringName &E : keys) {
+ const VisualScript::Function vsfn = p_script->functions[E];
Function function;
function.node = vsfn.func_id;
function.max_stack = 0;
@@ -1889,7 +1889,7 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
Map<StringName, int> local_var_indices;
if (function.node < 0) {
- VisualScriptLanguage::singleton->debug_break_parse(get_script()->get_path(), 0, "No start node in function: " + String(E->get()));
+ VisualScriptLanguage::singleton->debug_break_parse(get_script()->get_path(), 0, "No start node in function: " + String(E));
ERR_CONTINUE(function.node < 0);
}
@@ -1897,7 +1897,7 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
Ref<VisualScriptFunction> func_node = script->get_node(vsfn.func_id);
if (func_node.is_null()) {
- VisualScriptLanguage::singleton->debug_break_parse(get_script()->get_path(), 0, "No VisualScriptFunction typed start node in function: " + String(E->get()));
+ VisualScriptLanguage::singleton->debug_break_parse(get_script()->get_path(), 0, "No VisualScriptFunction typed start node in function: " + String(E));
}
ERR_CONTINUE(!func_node.is_valid());
@@ -1938,12 +1938,12 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
while (!nd_queue.is_empty()) {
int ky = nd_queue.front()->get();
dc_lut[ky].get_key_list(&dc_keys);
- for (const List<int>::Element *F = dc_keys.front(); F; F = F->next()) {
+ for (const int &F : dc_keys) {
VisualScript::DataConnection dc;
- dc.from_node = dc_lut[ky][F->get()].first;
- dc.from_port = dc_lut[ky][F->get()].second;
+ dc.from_node = dc_lut[ky][F].first;
+ dc.from_port = dc_lut[ky][F].second;
dc.to_node = ky;
- dc.to_port = F->get();
+ dc.to_port = F;
dataconns.insert(dc);
nd_queue.push_back(dc.from_node);
node_ids.insert(dc.from_node);
@@ -2093,7 +2093,7 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
}
}
- functions[E->get()] = function;
+ functions[E] = function;
}
}
}
@@ -2467,10 +2467,10 @@ void VisualScriptLanguage::debug_get_stack_level_members(int p_level, List<Strin
List<StringName> vars;
vs->get_variable_list(&vars);
- for (List<StringName>::Element *E = vars.front(); E; E = E->next()) {
+ for (StringName &E : vars) {
Variant v;
- if (_call_stack[l].instance->get_variable(E->get(), &v)) {
- p_members->push_back("variables/" + E->get());
+ if (_call_stack[l].instance->get_variable(E, &v)) {
+ p_members->push_back("variables/" + E);
p_values->push_back(v);
}
}
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 57a631fb6a..16313d58d0 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -62,7 +62,7 @@ protected:
void _sig_changed() {
notify_property_list_changed();
- emit_signal("changed");
+ emit_signal(SNAME("changed"));
}
bool _set(const StringName &p_name, const Variant &p_value) {
@@ -196,10 +196,10 @@ protected:
void _var_changed() {
notify_property_list_changed();
- emit_signal("changed");
+ emit_signal(SNAME("changed"));
}
void _var_value_changed() {
- emit_signal("changed");
+ emit_signal(SNAME("changed"));
}
bool _set(const StringName &p_name, const Variant &p_value) {
@@ -561,18 +561,16 @@ void VisualScriptEditor::_update_graph_connections() {
List<VisualScript::SequenceConnection> sequence_conns;
script->get_sequence_connection_list(&sequence_conns);
- for (List<VisualScript::SequenceConnection>::Element *E = sequence_conns.front(); E; E = E->next()) {
- graph->connect_node(itos(E->get().from_node), E->get().from_output, itos(E->get().to_node), 0);
+ for (VisualScript::SequenceConnection &E : sequence_conns) {
+ graph->connect_node(itos(E.from_node), E.from_output, itos(E.to_node), 0);
}
List<VisualScript::DataConnection> data_conns;
script->get_data_connection_list(&data_conns);
- for (List<VisualScript::DataConnection>::Element *E = data_conns.front(); E; E = E->next()) {
- VisualScript::DataConnection dc = E->get();
-
- Ref<VisualScriptNode> from_node = script->get_node(E->get().from_node);
- Ref<VisualScriptNode> to_node = script->get_node(E->get().to_node);
+ for (VisualScript::DataConnection &dc : data_conns) {
+ Ref<VisualScriptNode> from_node = script->get_node(dc.from_node);
+ Ref<VisualScriptNode> to_node = script->get_node(dc.to_node);
if (to_node->has_input_sequence_port()) {
dc.to_port++;
@@ -580,7 +578,7 @@ void VisualScriptEditor::_update_graph_connections() {
dc.from_port += from_node->get_output_sequence_port_count();
- graph->connect_node(itos(E->get().from_node), dc.from_port, itos(E->get().to_node), dc.to_port);
+ graph->connect_node(itos(dc.from_node), dc.from_port, itos(dc.to_node), dc.to_port);
}
}
@@ -611,41 +609,44 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
select_func_text->hide();
Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = {
- Control::get_theme_icon("Variant", "EditorIcons"),
- Control::get_theme_icon("bool", "EditorIcons"),
- Control::get_theme_icon("int", "EditorIcons"),
- Control::get_theme_icon("float", "EditorIcons"),
- Control::get_theme_icon("String", "EditorIcons"),
- Control::get_theme_icon("Vector2", "EditorIcons"),
- Control::get_theme_icon("Vector2i", "EditorIcons"),
- Control::get_theme_icon("Rect2", "EditorIcons"),
- Control::get_theme_icon("Rect2i", "EditorIcons"),
- Control::get_theme_icon("Vector3", "EditorIcons"),
- Control::get_theme_icon("Vector3i", "EditorIcons"),
- Control::get_theme_icon("Transform2D", "EditorIcons"),
- Control::get_theme_icon("Plane", "EditorIcons"),
- Control::get_theme_icon("Quaternion", "EditorIcons"),
- Control::get_theme_icon("AABB", "EditorIcons"),
- Control::get_theme_icon("Basis", "EditorIcons"),
- Control::get_theme_icon("Transform3D", "EditorIcons"),
- Control::get_theme_icon("Color", "EditorIcons"),
- Control::get_theme_icon("NodePath", "EditorIcons"),
- Control::get_theme_icon("RID", "EditorIcons"),
- Control::get_theme_icon("MiniObject", "EditorIcons"),
- Control::get_theme_icon("Callable", "EditorIcons"),
- Control::get_theme_icon("Signal", "EditorIcons"),
- Control::get_theme_icon("Dictionary", "EditorIcons"),
- Control::get_theme_icon("Array", "EditorIcons"),
- Control::get_theme_icon("PackedByteArray", "EditorIcons"),
- Control::get_theme_icon("PackedInt32Array", "EditorIcons"),
- Control::get_theme_icon("PackedFloat32Array", "EditorIcons"),
- Control::get_theme_icon("PackedStringArray", "EditorIcons"),
- Control::get_theme_icon("PackedVector2Array", "EditorIcons"),
- Control::get_theme_icon("PackedVector3Array", "EditorIcons"),
- Control::get_theme_icon("PackedColorArray", "EditorIcons")
+ Control::get_theme_icon(SNAME("Variant"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("bool"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("int"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("float"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("String"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Vector2i"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Rect2"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Rect2i"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Vector3i"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Transform2D"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Plane"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Quaternion"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("AABB"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Basis"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Color"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("StringName"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("NodePath"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("RID"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("MiniObject"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Callable"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Signal"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Dictionary"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Array"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedByteArray"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedInt32Array"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedInt64Array"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedFloat32Array"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedFloat64Array"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedStringArray"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedVector2Array"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedVector3Array"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedColorArray"), SNAME("EditorIcons"))
};
- Ref<Texture2D> seq_port = Control::get_theme_icon("VisualShaderPort", "EditorIcons");
+ Ref<Texture2D> seq_port = Control::get_theme_icon(SNAME("VisualShaderPort"), SNAME("EditorIcons"));
List<int> node_ids;
script->get_node_list(&node_ids);
@@ -653,27 +654,27 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
script->get_node_list(&ids);
StringName editor_icons = "EditorIcons";
- for (List<int>::Element *E = ids.front(); E; E = E->next()) {
- if (p_only_id >= 0 && p_only_id != E->get()) {
+ for (int &E : ids) {
+ if (p_only_id >= 0 && p_only_id != E) {
continue;
}
- Ref<VisualScriptNode> node = script->get_node(E->get());
- Vector2 pos = script->get_node_position(E->get());
+ Ref<VisualScriptNode> node = script->get_node(E);
+ Vector2 pos = script->get_node_position(E);
GraphNode *gnode = memnew(GraphNode);
gnode->set_title(node->get_caption());
gnode->set_position_offset(pos * EDSCALE);
- if (error_line == E->get()) {
+ if (error_line == E) {
gnode->set_overlay(GraphNode::OVERLAY_POSITION);
} else if (node->is_breakpoint()) {
gnode->set_overlay(GraphNode::OVERLAY_BREAKPOINT);
}
gnode->set_meta("__vnode", node);
- gnode->set_name(itos(E->get()));
- gnode->connect("dragged", callable_mp(this, &VisualScriptEditor::_node_moved), varray(E->get()));
- gnode->connect("close_request", callable_mp(this, &VisualScriptEditor::_remove_node), varray(E->get()), CONNECT_DEFERRED);
+ gnode->set_name(itos(E));
+ gnode->connect("dragged", callable_mp(this, &VisualScriptEditor::_node_moved), varray(E));
+ gnode->connect("close_request", callable_mp(this, &VisualScriptEditor::_remove_node), varray(E), CONNECT_DEFERRED);
{
Ref<VisualScriptFunction> v = node;
@@ -693,7 +694,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
Button *btn = memnew(Button);
btn->set_text(TTR("Add Input Port"));
hbnc->add_child(btn);
- btn->connect("pressed", callable_mp(this, &VisualScriptEditor::_add_input_port), varray(E->get()), CONNECT_DEFERRED);
+ btn->connect("pressed", callable_mp(this, &VisualScriptEditor::_add_input_port), varray(E), CONNECT_DEFERRED);
}
if (nd_list->is_output_port_editable()) {
if (nd_list->is_input_port_editable()) {
@@ -703,7 +704,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
Button *btn = memnew(Button);
btn->set_text(TTR("Add Output Port"));
hbnc->add_child(btn);
- btn->connect("pressed", callable_mp(this, &VisualScriptEditor::_add_output_port), varray(E->get()), CONNECT_DEFERRED);
+ btn->connect("pressed", callable_mp(this, &VisualScriptEditor::_add_output_port), varray(E), CONNECT_DEFERRED);
}
gnode->add_child(hbnc);
} else if (Object::cast_to<VisualScriptExpression>(node.ptr())) {
@@ -711,9 +712,9 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
LineEdit *line_edit = memnew(LineEdit);
line_edit->set_text(node->get_text());
line_edit->set_expand_to_text_length_enabled(true);
- line_edit->add_theme_font_override("font", get_theme_font("source", "EditorFonts"));
+ line_edit->add_theme_font_override("font", get_theme_font(SNAME("source"), SNAME("EditorFonts")));
gnode->add_child(line_edit);
- line_edit->connect("text_changed", callable_mp(this, &VisualScriptEditor::_expression_text_changed), varray(E->get()));
+ line_edit->connect("text_changed", callable_mp(this, &VisualScriptEditor::_expression_text_changed), varray(E));
} else {
String text = node->get_text();
if (!text.is_empty()) {
@@ -729,13 +730,13 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
gnode->set_comment(true);
gnode->set_resizable(true);
gnode->set_custom_minimum_size(vsc->get_size() * EDSCALE);
- gnode->connect("resize_request", callable_mp(this, &VisualScriptEditor::_comment_node_resized), varray(E->get()));
+ gnode->connect("resize_request", callable_mp(this, &VisualScriptEditor::_comment_node_resized), varray(E));
}
if (node_styles.has(node->get_category())) {
Ref<StyleBoxFlat> sbf = node_styles[node->get_category()];
if (gnode->is_comment()) {
- sbf = EditorNode::get_singleton()->get_theme_base()->get_theme()->get_stylebox("comment", "GraphNode");
+ sbf = EditorNode::get_singleton()->get_theme_base()->get_theme()->get_stylebox(SNAME("comment"), SNAME("GraphNode"));
}
Color c = sbf->get_border_color();
@@ -748,7 +749,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
gnode->add_theme_style_override("frame", sbf);
}
- const Color mono_color = get_theme_color("mono_color", "Editor");
+ const Color mono_color = get_theme_color(SNAME("mono_color"), SNAME("Editor"));
int slot_idx = 0;
@@ -832,8 +833,8 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
name_box->set_custom_minimum_size(Size2(60 * EDSCALE, 0));
name_box->set_text(left_name);
name_box->set_expand_to_text_length_enabled(true);
- name_box->connect("resized", callable_mp(this, &VisualScriptEditor::_update_node_size), varray(E->get()));
- name_box->connect("focus_exited", callable_mp(this, &VisualScriptEditor::_port_name_focus_out), varray(name_box, E->get(), i, true));
+ name_box->connect("resized", callable_mp(this, &VisualScriptEditor::_update_node_size), varray(E));
+ name_box->connect("focus_exited", callable_mp(this, &VisualScriptEditor::_port_name_focus_out), varray(name_box, E, i, true));
} else {
hbc->add_child(memnew(Label(left_name)));
}
@@ -846,18 +847,18 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
opbtn->select(left_type);
opbtn->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
hbc->add_child(opbtn);
- opbtn->connect("item_selected", callable_mp(this, &VisualScriptEditor::_change_port_type), varray(E->get(), i, true), CONNECT_DEFERRED);
+ opbtn->connect("item_selected", callable_mp(this, &VisualScriptEditor::_change_port_type), varray(E, i, true), CONNECT_DEFERRED);
}
Button *rmbtn = memnew(Button);
- rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons"));
+ rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
hbc->add_child(rmbtn);
- rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_input_port), varray(E->get(), i), CONNECT_DEFERRED);
+ rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_input_port), varray(E, i), CONNECT_DEFERRED);
} else {
hbc->add_child(memnew(Label(left_name)));
}
- if (left_type != Variant::NIL && !script->is_input_value_port_connected(E->get(), i)) {
+ if (left_type != Variant::NIL && !script->is_input_value_port_connected(E, i)) {
PropertyInfo pi = node->get_input_value_port_info(i);
Button *button = memnew(Button);
Variant value = node->get_default_input_value(i);
@@ -884,7 +885,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
} else {
button->set_text(value);
}
- button->connect("pressed", callable_mp(this, &VisualScriptEditor::_default_value_edited), varray(button, E->get(), i));
+ button->connect("pressed", callable_mp(this, &VisualScriptEditor::_default_value_edited), varray(button, E, i));
hbc2->add_child(button);
}
} else {
@@ -906,9 +907,9 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
if (right_ok) {
if (is_vslist) {
Button *rmbtn = memnew(Button);
- rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons"));
+ rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
hbc->add_child(rmbtn);
- rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_output_port), varray(E->get(), i), CONNECT_DEFERRED);
+ rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_output_port), varray(E, i), CONNECT_DEFERRED);
if (nd_list->is_output_port_type_editable()) {
OptionButton *opbtn = memnew(OptionButton);
@@ -918,7 +919,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
opbtn->select(right_type);
opbtn->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
hbc->add_child(opbtn);
- opbtn->connect("item_selected", callable_mp(this, &VisualScriptEditor::_change_port_type), varray(E->get(), i, false), CONNECT_DEFERRED);
+ opbtn->connect("item_selected", callable_mp(this, &VisualScriptEditor::_change_port_type), varray(E, i, false), CONNECT_DEFERRED);
}
if (nd_list->is_output_port_name_editable()) {
@@ -927,8 +928,8 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
name_box->set_custom_minimum_size(Size2(60 * EDSCALE, 0));
name_box->set_text(right_name);
name_box->set_expand_to_text_length_enabled(true);
- name_box->connect("resized", callable_mp(this, &VisualScriptEditor::_update_node_size), varray(E->get()));
- name_box->connect("focus_exited", callable_mp(this, &VisualScriptEditor::_port_name_focus_out), varray(name_box, E->get(), i, false));
+ name_box->connect("resized", callable_mp(this, &VisualScriptEditor::_update_node_size), varray(E));
+ name_box->connect("focus_exited", callable_mp(this, &VisualScriptEditor::_port_name_focus_out), varray(name_box, E, i, false));
} else {
hbc->add_child(memnew(Label(right_name)));
}
@@ -950,7 +951,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
gnode->add_child(vbc);
- bool dark_theme = get_theme_constant("dark_theme", "Editor");
+ bool dark_theme = get_theme_constant(SNAME("dark_theme"), SNAME("Editor"));
if (i < mixed_seq_ports) {
gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), true, TYPE_SEQUENCE, mono_color, Ref<Texture2D>(), seq_port);
} else {
@@ -973,7 +974,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
graph->set_minimap_opacity(graph_minimap_opacity);
// Use default_func instead of default_func for now I think that should be good stop gap solution to ensure not breaking anything.
- graph->call_deferred("set_scroll_ofs", script->get_scroll() * EDSCALE);
+ graph->call_deferred(SNAME("set_scroll_ofs"), script->get_scroll() * EDSCALE);
updating_graph = false;
}
@@ -1037,20 +1038,20 @@ void VisualScriptEditor::_update_members() {
TreeItem *functions = members->create_item(root);
functions->set_selectable(0, false);
functions->set_text(0, TTR("Functions:"));
- functions->add_button(0, Control::get_theme_icon("Override", "EditorIcons"), 1, false, TTR("Override an existing built-in function."));
- functions->add_button(0, Control::get_theme_icon("Add", "EditorIcons"), 0, false, TTR("Create a new function."));
- functions->set_custom_color(0, Control::get_theme_color("mono_color", "Editor"));
+ functions->add_button(0, Control::get_theme_icon(SNAME("Override"), SNAME("EditorIcons")), 1, false, TTR("Override an existing built-in function."));
+ functions->add_button(0, Control::get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), 0, false, TTR("Create a new function."));
+ functions->set_custom_color(0, Control::get_theme_color(SNAME("mono_color"), SNAME("Editor")));
List<StringName> func_names;
script->get_function_list(&func_names);
func_names.sort_custom<StringName::AlphCompare>();
- for (List<StringName>::Element *E = func_names.front(); E; E = E->next()) {
+ for (StringName &E : func_names) {
TreeItem *ti = members->create_item(functions);
- ti->set_text(0, E->get());
+ ti->set_text(0, E);
ti->set_selectable(0, true);
- ti->set_metadata(0, E->get());
- ti->add_button(0, Control::get_theme_icon("Edit", "EditorIcons"), 0);
- if (selected == E->get()) {
+ ti->set_metadata(0, E);
+ ti->add_button(0, Control::get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), 0);
+ if (selected == E) {
ti->select(0);
}
}
@@ -1058,58 +1059,58 @@ void VisualScriptEditor::_update_members() {
TreeItem *variables = members->create_item(root);
variables->set_selectable(0, false);
variables->set_text(0, TTR("Variables:"));
- variables->add_button(0, Control::get_theme_icon("Add", "EditorIcons"), -1, false, TTR("Create a new variable."));
- variables->set_custom_color(0, Control::get_theme_color("mono_color", "Editor"));
+ variables->add_button(0, Control::get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), -1, false, TTR("Create a new variable."));
+ variables->set_custom_color(0, Control::get_theme_color(SNAME("mono_color"), SNAME("Editor")));
Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = {
- Control::get_theme_icon("Variant", "EditorIcons"),
- Control::get_theme_icon("bool", "EditorIcons"),
- Control::get_theme_icon("int", "EditorIcons"),
- Control::get_theme_icon("float", "EditorIcons"),
- Control::get_theme_icon("String", "EditorIcons"),
- Control::get_theme_icon("Vector2", "EditorIcons"),
- Control::get_theme_icon("Vector2i", "EditorIcons"),
- Control::get_theme_icon("Rect2", "EditorIcons"),
- Control::get_theme_icon("Rect2i", "EditorIcons"),
- Control::get_theme_icon("Vector3", "EditorIcons"),
- Control::get_theme_icon("Vector3i", "EditorIcons"),
- Control::get_theme_icon("Transform2D", "EditorIcons"),
- Control::get_theme_icon("Plane", "EditorIcons"),
- Control::get_theme_icon("Quaternion", "EditorIcons"),
- Control::get_theme_icon("AABB", "EditorIcons"),
- Control::get_theme_icon("Basis", "EditorIcons"),
- Control::get_theme_icon("Transform3D", "EditorIcons"),
- Control::get_theme_icon("Color", "EditorIcons"),
- Control::get_theme_icon("NodePath", "EditorIcons"),
- Control::get_theme_icon("RID", "EditorIcons"),
- Control::get_theme_icon("MiniObject", "EditorIcons"),
- Control::get_theme_icon("Callable", "EditorIcons"),
- Control::get_theme_icon("Signal", "EditorIcons"),
- Control::get_theme_icon("Dictionary", "EditorIcons"),
- Control::get_theme_icon("Array", "EditorIcons"),
- Control::get_theme_icon("PackedByteArray", "EditorIcons"),
- Control::get_theme_icon("PackedInt32Array", "EditorIcons"),
- Control::get_theme_icon("PackedFloat32Array", "EditorIcons"),
- Control::get_theme_icon("PackedStringArray", "EditorIcons"),
- Control::get_theme_icon("PackedVector2Array", "EditorIcons"),
- Control::get_theme_icon("PackedVector3Array", "EditorIcons"),
- Control::get_theme_icon("PackedColorArray", "EditorIcons")
+ Control::get_theme_icon(SNAME("Variant"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("bool"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("int"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("float"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("String"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Vector2i"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Rect2"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Rect2i"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Vector3i"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Transform2D"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Plane"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Quaternion"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("AABB"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Basis"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Color"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("NodePath"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("RID"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("MiniObject"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Callable"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Signal"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Dictionary"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("Array"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedByteArray"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedInt32Array"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedFloat32Array"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedStringArray"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedVector2Array"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedVector3Array"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedColorArray"), SNAME("EditorIcons"))
};
List<StringName> var_names;
script->get_variable_list(&var_names);
- for (List<StringName>::Element *E = var_names.front(); E; E = E->next()) {
+ for (StringName &E : var_names) {
TreeItem *ti = members->create_item(variables);
- ti->set_text(0, E->get());
+ ti->set_text(0, E);
- ti->set_suffix(0, "= " + _sanitized_variant_text(E->get()));
- ti->set_icon(0, type_icons[script->get_variable_info(E->get()).type]);
+ ti->set_suffix(0, "= " + _sanitized_variant_text(E));
+ ti->set_icon(0, type_icons[script->get_variable_info(E).type]);
ti->set_selectable(0, true);
ti->set_editable(0, true);
- ti->set_metadata(0, E->get());
- if (selected == E->get()) {
+ ti->set_metadata(0, E);
+ if (selected == E) {
ti->select(0);
}
}
@@ -1117,30 +1118,30 @@ void VisualScriptEditor::_update_members() {
TreeItem *_signals = members->create_item(root);
_signals->set_selectable(0, false);
_signals->set_text(0, TTR("Signals:"));
- _signals->add_button(0, Control::get_theme_icon("Add", "EditorIcons"), -1, false, TTR("Create a new signal."));
- _signals->set_custom_color(0, Control::get_theme_color("mono_color", "Editor"));
+ _signals->add_button(0, Control::get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), -1, false, TTR("Create a new signal."));
+ _signals->set_custom_color(0, Control::get_theme_color(SNAME("mono_color"), SNAME("Editor")));
List<StringName> signal_names;
script->get_custom_signal_list(&signal_names);
- for (List<StringName>::Element *E = signal_names.front(); E; E = E->next()) {
+ for (StringName &E : signal_names) {
TreeItem *ti = members->create_item(_signals);
- ti->set_text(0, E->get());
+ ti->set_text(0, E);
ti->set_selectable(0, true);
ti->set_editable(0, true);
- ti->set_metadata(0, E->get());
- if (selected == E->get()) {
+ ti->set_metadata(0, E);
+ if (selected == E) {
ti->select(0);
}
}
String base_type = script->get_instance_base_type();
String icon_type = base_type;
- if (!Control::has_theme_icon(base_type, "EditorIcons")) {
+ if (!Control::has_theme_icon(base_type, SNAME("EditorIcons"))) {
icon_type = "Object";
}
base_type_select->set_text(base_type);
- base_type_select->set_icon(Control::get_theme_icon(icon_type, "EditorIcons"));
+ base_type_select->set_icon(Control::get_theme_icon(icon_type, SNAME("EditorIcons")));
updating_members = false;
}
@@ -1234,8 +1235,8 @@ void VisualScriptEditor::_member_edited() {
// Also fix all function calls.
List<int> lst;
script->get_node_list(&lst);
- for (List<int>::Element *F = lst.front(); F; F = F->next()) {
- Ref<VisualScriptFunctionCall> fncall = script->get_node(F->get());
+ for (int &F : lst) {
+ Ref<VisualScriptFunctionCall> fncall = script->get_node(F);
if (!fncall.is_valid()) {
continue;
}
@@ -1366,7 +1367,7 @@ void VisualScriptEditor::_add_func_input() {
hbox->add_child(type_box);
Button *delete_button = memnew(Button);
- delete_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Remove", "EditorIcons"));
+ delete_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
delete_button->set_tooltip(vformat(TTR("Delete input port")));
hbox->add_child(delete_button);
@@ -1569,13 +1570,13 @@ void VisualScriptEditor::_remove_output_port(int p_id, int p_port) {
script->get_data_connection_list(&data_connections);
HashMap<int, Set<int>> conn_map;
- for (const List<VisualScript::DataConnection>::Element *E = data_connections.front(); E; E = E->next()) {
- if (E->get().from_node == p_id && E->get().from_port == p_port) {
+ for (const VisualScript::DataConnection &E : data_connections) {
+ if (E.from_node == p_id && E.from_port == p_port) {
// Push into the connections map.
- if (!conn_map.has(E->get().to_node)) {
- conn_map.set(E->get().to_node, Set<int>());
+ if (!conn_map.has(E.to_node)) {
+ conn_map.set(E.to_node, Set<int>());
}
- conn_map[E->get().to_node].insert(E->get().to_port);
+ conn_map[E.to_node].insert(E.to_port);
}
}
@@ -1584,9 +1585,9 @@ void VisualScriptEditor::_remove_output_port(int p_id, int p_port) {
List<int> keys;
conn_map.get_key_list(&keys);
- for (const List<int>::Element *E = keys.front(); E; E = E->next()) {
- for (const Set<int>::Element *F = conn_map[E->get()].front(); F; F = F->next()) {
- undo_redo->add_undo_method(script.ptr(), "data_connect", p_id, p_port, E->get(), F->get());
+ for (const int &E : keys) {
+ for (const Set<int>::Element *F = conn_map[E].front(); F; F = F->next()) {
+ undo_redo->add_undo_method(script.ptr(), "data_connect", p_id, p_port, E, F);
}
}
@@ -1639,8 +1640,8 @@ Vector2 VisualScriptEditor::_get_available_pos(bool p_centered, Vector2 p_pos) c
bool exists = false;
List<int> existing;
script->get_node_list(&existing);
- for (List<int>::Element *E = existing.front(); E; E = E->next()) {
- Point2 pos = script->get_node_position(E->get());
+ for (int &E : existing) {
+ Point2 pos = script->get_node_position(E);
if (pos.distance_to(p_pos) < 50) {
p_pos += Vector2(graph->get_snap(), graph->get_snap());
exists = true;
@@ -1695,8 +1696,8 @@ void VisualScriptEditor::_on_nodes_delete() {
undo_redo->create_action(TTR("Remove VisualScript Nodes"));
- for (List<int>::Element *F = to_erase.front(); F; F = F->next()) {
- int cr_node = F->get();
+ for (int &F : to_erase) {
+ int cr_node = F;
undo_redo->add_do_method(script.ptr(), "remove_node", cr_node);
undo_redo->add_undo_method(script.ptr(), "add_node", cr_node, script->get_node(cr_node), script->get_node_position(cr_node));
@@ -1704,18 +1705,18 @@ void VisualScriptEditor::_on_nodes_delete() {
List<VisualScript::SequenceConnection> sequence_conns;
script->get_sequence_connection_list(&sequence_conns);
- for (List<VisualScript::SequenceConnection>::Element *E = sequence_conns.front(); E; E = E->next()) {
- if (E->get().from_node == cr_node || E->get().to_node == cr_node) {
- undo_redo->add_undo_method(script.ptr(), "sequence_connect", E->get().from_node, E->get().from_output, E->get().to_node);
+ for (VisualScript::SequenceConnection &E : sequence_conns) {
+ if (E.from_node == cr_node || E.to_node == cr_node) {
+ undo_redo->add_undo_method(script.ptr(), "sequence_connect", E.from_node, E.from_output, E.to_node);
}
}
List<VisualScript::DataConnection> data_conns;
script->get_data_connection_list(&data_conns);
- for (List<VisualScript::DataConnection>::Element *E = data_conns.front(); E; E = E->next()) {
- if (E->get().from_node == F->get() || E->get().to_node == F->get()) {
- undo_redo->add_undo_method(script.ptr(), "data_connect", E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ for (VisualScript::DataConnection &E : data_conns) {
+ if (E.from_node == F || E.to_node == F) {
+ undo_redo->add_undo_method(script.ptr(), "data_connect", E.from_node, E.from_port, E.to_node, E.to_port);
}
}
}
@@ -1764,17 +1765,17 @@ void VisualScriptEditor::_on_nodes_duplicate() {
List<VisualScript::SequenceConnection> seqs;
script->get_sequence_connection_list(&seqs);
- for (List<VisualScript::SequenceConnection>::Element *E = seqs.front(); E; E = E->next()) {
- if (to_duplicate.has(E->get().from_node) && to_duplicate.has(E->get().to_node)) {
- undo_redo->add_do_method(script.ptr(), "sequence_connect", remap[E->get().from_node], E->get().from_output, remap[E->get().to_node]);
+ for (VisualScript::SequenceConnection &E : seqs) {
+ if (to_duplicate.has(E.from_node) && to_duplicate.has(E.to_node)) {
+ undo_redo->add_do_method(script.ptr(), "sequence_connect", remap[E.from_node], E.from_output, remap[E.to_node]);
}
}
List<VisualScript::DataConnection> data;
script->get_data_connection_list(&data);
- for (List<VisualScript::DataConnection>::Element *E = data.front(); E; E = E->next()) {
- if (to_duplicate.has(E->get().from_node) && to_duplicate.has(E->get().to_node)) {
- undo_redo->add_do_method(script.ptr(), "data_connect", remap[E->get().from_node], E->get().from_port, remap[E->get().to_node], E->get().to_port);
+ for (VisualScript::DataConnection &E : data) {
+ if (to_duplicate.has(E.from_node) && to_duplicate.has(E.to_node)) {
+ undo_redo->add_do_method(script.ptr(), "data_connect", remap[E.from_node], E.from_port, remap[E.to_node], E.to_port);
}
}
@@ -1900,8 +1901,8 @@ void VisualScriptEditor::_rename_function(const String &name, const String &new_
// Also fix all function calls.
List<int> lst;
script->get_node_list(&lst);
- for (List<int>::Element *F = lst.front(); F; F = F->next()) {
- Ref<VisualScriptFunctionCall> fncall = script->get_node(F->get());
+ for (int &F : lst) {
+ Ref<VisualScriptFunctionCall> fncall = script->get_node(F);
if (!fncall.is_valid()) {
continue;
}
@@ -2172,6 +2173,11 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "files") {
+#ifdef OSX_ENABLED
+ bool use_preload = Input::get_singleton()->is_key_pressed(KEY_META);
+#else
+ bool use_preload = Input::get_singleton()->is_key_pressed(KEY_CTRL);
+#endif
Vector2 pos = _get_pos_in_graph(p_point);
Array files = d["files"];
@@ -2187,13 +2193,22 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
if (!res.is_valid()) {
continue;
}
+ Ref<Script> drop_script = ResourceLoader::load(files[i]);
+ if (drop_script.is_valid() && drop_script->is_tool() && drop_script->get_instance_base_type() == "VisualScriptCustomNode" && !use_preload) {
+ Ref<VisualScriptCustomNode> vscn;
+ vscn.instantiate();
+ vscn->set_script(drop_script);
+
+ undo_redo->add_do_method(script.ptr(), "add_node", new_id, vscn, pos);
+ undo_redo->add_undo_method(script.ptr(), "remove_node", new_id);
+ } else {
+ Ref<VisualScriptPreload> prnode;
+ prnode.instantiate();
+ prnode->set_preload(res);
- Ref<VisualScriptPreload> prnode;
- prnode.instantiate();
- prnode->set_preload(res);
-
- undo_redo->add_do_method(script.ptr(), "add_node", new_id, prnode, pos);
- undo_redo->add_undo_method(script.ptr(), "remove_node", new_id);
+ undo_redo->add_do_method(script.ptr(), "add_node", new_id, prnode, pos);
+ undo_redo->add_undo_method(script.ptr(), "remove_node", new_id);
+ }
new_ids.push_back(new_id);
new_id++;
pos += Vector2(20, 20);
@@ -2204,8 +2219,8 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
undo_redo->commit_action();
}
- for (List<int>::Element *E = new_ids.front(); E; E = E->next()) {
- Node *node = graph->get_node(itos(E->get()));
+ for (int &E : new_ids) {
+ Node *node = graph->get_node(itos(E));
if (node) {
graph->set_selected(node);
_node_selected(node);
@@ -2234,41 +2249,35 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
undo_redo->create_action(TTR("Add Node(s) From Tree"));
int base_id = script->get_available_id();
- if (nodes.size() > 1) {
- use_node = true;
- }
-
- for (int i = 0; i < nodes.size(); i++) {
- NodePath np = nodes[i];
- Node *node = get_node(np);
- if (!node) {
- continue;
- }
+ if (use_node || nodes.size() > 1) {
+ for (int i = 0; i < nodes.size(); i++) {
+ NodePath np = nodes[i];
+ Node *node = get_node(np);
+ if (!node) {
+ continue;
+ }
- Ref<VisualScriptNode> n;
+ Ref<VisualScriptNode> n;
- if (use_node) {
Ref<VisualScriptSceneNode> scene_node;
scene_node.instantiate();
scene_node->set_node_path(sn->get_path_to(node));
n = scene_node;
- } else {
- // ! Doesn't work properly.
- Ref<VisualScriptFunctionCall> call;
- call.instantiate();
- call->set_call_mode(VisualScriptFunctionCall::CALL_MODE_NODE_PATH);
- call->set_base_path(sn->get_path_to(node));
- call->set_base_type(node->get_class());
- n = call;
- method_select->select_from_instance(node, "", true, node->get_class());
- selecting_method_id = base_id;
- }
- undo_redo->add_do_method(script.ptr(), "add_node", base_id, n, pos);
- undo_redo->add_undo_method(script.ptr(), "remove_node", base_id);
+ undo_redo->add_do_method(script.ptr(), "add_node", base_id, n, pos);
+ undo_redo->add_undo_method(script.ptr(), "remove_node", base_id);
- base_id++;
- pos += Vector2(25, 25);
+ base_id++;
+ pos += Vector2(25, 25);
+ }
+
+ } else {
+ NodePath np = nodes[0];
+ Node *node = get_node(np);
+ 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());
}
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
@@ -2387,21 +2396,13 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
}
-void VisualScriptEditor::_selected_method(const String &p_method, const String &p_type, const bool p_connecting) {
- Ref<VisualScriptFunctionCall> vsfc = script->get_node(selecting_method_id);
- if (!vsfc.is_valid()) {
- return;
- }
- vsfc->set_function(p_method);
-}
-
void VisualScriptEditor::_draw_color_over_button(Object *obj, Color p_color) {
Button *button = Object::cast_to<Button>(obj);
if (!button) {
return;
}
- Ref<StyleBox> normal = get_theme_stylebox("normal", "Button");
+ Ref<StyleBox> normal = get_theme_stylebox(SNAME("normal"), SNAME("Button"));
button->draw_rect(Rect2(normal->get_offset(), button->get_size() - normal->get_minimum_size()), p_color);
}
@@ -2447,7 +2448,7 @@ void VisualScriptEditor::set_edited_resource(const RES &p_res) {
script->connect("node_ports_changed", callable_mp(this, &VisualScriptEditor::_node_ports_changed));
_update_graph();
- call_deferred("_update_members");
+ call_deferred(SNAME("_update_members"));
}
void VisualScriptEditor::enable_editor() {
@@ -2481,7 +2482,7 @@ String VisualScriptEditor::get_name() {
}
Ref<Texture2D> VisualScriptEditor::get_theme_icon() {
- return Control::get_theme_icon("VisualScript", "EditorIcons");
+ return Control::get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons"));
}
bool VisualScriptEditor::is_unsaved() {
@@ -2551,12 +2552,12 @@ void VisualScriptEditor::goto_line(int p_line, bool p_with_error) {
List<StringName> functions;
script->get_function_list(&functions);
- for (List<StringName>::Element *E = functions.front(); E; E = E->next()) {
+ for (StringName &E : functions) {
if (script->has_node(p_line)) {
_update_graph();
_update_members();
- call_deferred("call_deferred", "_center_on_node", E->get(), p_line); //editor might be just created and size might not exist yet
+ call_deferred(SNAME("call_deferred"), "_center_on_node", E, p_line); //editor might be just created and size might not exist yet
return;
}
}
@@ -2597,13 +2598,13 @@ Array VisualScriptEditor::get_breakpoints() {
Array breakpoints;
List<StringName> functions;
script->get_function_list(&functions);
- for (List<StringName>::Element *E = functions.front(); E; E = E->next()) {
+ for (int i = 0; i < functions.size(); i++) {
List<int> nodes;
script->get_node_list(&nodes);
- for (List<int>::Element *F = nodes.front(); F; F = F->next()) {
- Ref<VisualScriptNode> vsn = script->get_node(F->get());
+ for (int &F : nodes) {
+ Ref<VisualScriptNode> vsn = script->get_node(F);
if (vsn->is_breakpoint()) {
- breakpoints.push_back(F->get() - 1); // Subtract 1 because breakpoints in text start from zero.
+ breakpoints.push_back(F - 1); // Subtract 1 because breakpoints in text start from zero.
}
}
}
@@ -2772,18 +2773,18 @@ void VisualScriptEditor::_remove_node(int p_id) {
List<VisualScript::SequenceConnection> sequence_conns;
script->get_sequence_connection_list(&sequence_conns);
- for (List<VisualScript::SequenceConnection>::Element *E = sequence_conns.front(); E; E = E->next()) {
- if (E->get().from_node == p_id || E->get().to_node == p_id) {
- undo_redo->add_undo_method(script.ptr(), "sequence_connect", E->get().from_node, E->get().from_output, E->get().to_node);
+ for (VisualScript::SequenceConnection &E : sequence_conns) {
+ if (E.from_node == p_id || E.to_node == p_id) {
+ undo_redo->add_undo_method(script.ptr(), "sequence_connect", E.from_node, E.from_output, E.to_node);
}
}
List<VisualScript::DataConnection> data_conns;
script->get_data_connection_list(&data_conns);
- for (List<VisualScript::DataConnection>::Element *E = data_conns.front(); E; E = E->next()) {
- if (E->get().from_node == p_id || E->get().to_node == p_id) {
- undo_redo->add_undo_method(script.ptr(), "data_connect", E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ for (VisualScript::DataConnection &E : data_conns) {
+ if (E.from_node == p_id || E.to_node == p_id) {
+ undo_redo->add_undo_method(script.ptr(), "data_connect", E.from_node, E.from_port, E.to_node, E.to_port);
}
}
@@ -2801,9 +2802,9 @@ bool VisualScriptEditor::node_has_sequence_connections(int p_id) {
List<VisualScript::SequenceConnection> sequence_conns;
script->get_sequence_connection_list(&sequence_conns);
- for (List<VisualScript::SequenceConnection>::Element *E = sequence_conns.front(); E; E = E->next()) {
- int from = E->get().from_node;
- int to = E->get().to_node;
+ for (VisualScript::SequenceConnection &E : sequence_conns) {
+ int from = E.from_node;
+ int to = E.to_node;
if (to == p_id || from == p_id) {
return true;
@@ -3136,6 +3137,11 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
Set<int> vn;
+ if (drop_position != Vector2()) {
+ pos = drop_position;
+ }
+ drop_position = Vector2();
+
bool port_node_exists = true;
// if (func == StringName()) {
@@ -3189,18 +3195,62 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
if (p_category == String("method")) {
Ref<VisualScriptFunctionCall> n;
n.instantiate();
+ if (!drop_path.is_empty()) {
+ if (drop_path == ".") {
+ n->set_call_mode(VisualScriptFunctionCall::CALL_MODE_SELF);
+ } else {
+ n->set_call_mode(VisualScriptFunctionCall::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());
+ }
+ }
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);
+ }
+ }
+ 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);
+ }
+ }
+ 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") {
@@ -3410,9 +3460,9 @@ void VisualScriptEditor::_selected_new_virtual_method(const String &p_text, cons
List<MethodInfo> methods;
bool found = false;
ClassDB::get_virtual_methods(script->get_instance_base_type(), &methods);
- for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) {
- if (E->get().name == name) {
- minfo = E->get();
+ for (MethodInfo &E : methods) {
+ if (E.name == name) {
+ minfo = E;
found = true;
}
}
@@ -3561,9 +3611,9 @@ void VisualScriptEditor::_notification(int p_what) {
return;
}
- edit_variable_edit->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
- edit_signal_edit->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
- func_input_scroll->add_theme_style_override("bg", get_theme_stylebox("bg", "Tree"));
+ edit_variable_edit->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
+ edit_signal_edit->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
+ func_input_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
Ref<Theme> tm = EditorNode::get_singleton()->get_theme_base()->get_theme();
@@ -3586,7 +3636,7 @@ void VisualScriptEditor::_notification(int p_what) {
}
for (Map<StringName, Color>::Element *E = node_colors.front(); E; E = E->next()) {
- const Ref<StyleBoxFlat> sb = tm->get_stylebox("frame", "GraphNode");
+ const Ref<StyleBoxFlat> sb = tm->get_stylebox(SNAME("frame"), SNAME("GraphNode"));
if (!sb.is_null()) {
Ref<StyleBoxFlat> frame_style = sb->duplicate();
@@ -3682,8 +3732,8 @@ void VisualScriptEditor::_menu_option(int p_what) {
_update_graph();
- for (List<String>::Element *E = reselect.front(); E; E = E->next()) {
- GraphNode *gn = Object::cast_to<GraphNode>(graph->get_node(E->get()));
+ for (String &E : reselect) {
+ GraphNode *gn = Object::cast_to<GraphNode>(graph->get_node(E));
gn->set_selected(true);
}
@@ -3722,18 +3772,18 @@ void VisualScriptEditor::_menu_option(int p_what) {
List<VisualScript::SequenceConnection> sequence_connections;
script->get_sequence_connection_list(&sequence_connections);
- for (List<VisualScript::SequenceConnection>::Element *E = sequence_connections.front(); E; E = E->next()) {
- if (clipboard->nodes.has(E->get().from_node) && clipboard->nodes.has(E->get().to_node)) {
- clipboard->sequence_connections.insert(E->get());
+ for (VisualScript::SequenceConnection &E : sequence_connections) {
+ if (clipboard->nodes.has(E.from_node) && clipboard->nodes.has(E.to_node)) {
+ clipboard->sequence_connections.insert(E);
}
}
List<VisualScript::DataConnection> data_connections;
script->get_data_connection_list(&data_connections);
- for (List<VisualScript::DataConnection>::Element *E = data_connections.front(); E; E = E->next()) {
- if (clipboard->nodes.has(E->get().from_node) && clipboard->nodes.has(E->get().to_node)) {
- clipboard->data_connections.insert(E->get());
+ for (VisualScript::DataConnection &E : data_connections) {
+ if (clipboard->nodes.has(E.from_node) && clipboard->nodes.has(E.to_node)) {
+ clipboard->data_connections.insert(E);
}
}
if (p_what == EDIT_CUT_NODES) {
@@ -3759,8 +3809,8 @@ void VisualScriptEditor::_menu_option(int p_what) {
{
List<int> nodes;
script->get_node_list(&nodes);
- for (List<int>::Element *E = nodes.front(); E; E = E->next()) {
- Vector2 pos = script->get_node_position(E->get()).snapped(Vector2(2, 2));
+ for (int &E : nodes) {
+ Vector2 pos = script->get_node_position(E).snapped(Vector2(2, 2));
existing_positions.insert(pos);
}
}
@@ -3883,22 +3933,22 @@ void VisualScriptEditor::_menu_option(int p_what) {
// Pick the node with input sequence.
Set<int> nodes_from;
Set<int> nodes_to;
- for (List<VisualScript::SequenceConnection>::Element *E = seqs.front(); E; E = E->next()) {
- if (nodes.has(E->get().from_node) && nodes.has(E->get().to_node)) {
- seqmove.insert(E->get());
- nodes_from.insert(E->get().from_node);
- } else if (nodes.has(E->get().from_node) && !nodes.has(E->get().to_node)) {
- seqext.insert(E->get());
- } else if (!nodes.has(E->get().from_node) && nodes.has(E->get().to_node)) {
+ for (VisualScript::SequenceConnection &E : seqs) {
+ if (nodes.has(E.from_node) && nodes.has(E.to_node)) {
+ seqmove.insert(E);
+ nodes_from.insert(E.from_node);
+ } else if (nodes.has(E.from_node) && !nodes.has(E.to_node)) {
+ seqext.insert(E);
+ } else if (!nodes.has(E.from_node) && nodes.has(E.to_node)) {
if (start_node == -1) {
- seqext.insert(E->get());
- start_node = E->get().to_node;
+ seqext.insert(E);
+ start_node = E.to_node;
} else {
EditorNode::get_singleton()->show_warning(TTR("Try to only have one sequence input in selection."));
return;
}
}
- nodes_to.insert(E->get().to_node);
+ nodes_to.insert(E.to_node);
}
// To use to add return nodes.
@@ -3926,20 +3976,20 @@ void VisualScriptEditor::_menu_option(int p_what) {
{
List<VisualScript::DataConnection> dats;
script->get_data_connection_list(&dats);
- for (List<VisualScript::DataConnection>::Element *E = dats.front(); E; E = E->next()) {
- if (nodes.has(E->get().from_node) && nodes.has(E->get().to_node)) {
- datamove.insert(E->get());
- } else if (!nodes.has(E->get().from_node) && nodes.has(E->get().to_node)) {
+ for (VisualScript::DataConnection &E : dats) {
+ if (nodes.has(E.from_node) && nodes.has(E.to_node)) {
+ datamove.insert(E);
+ } else if (!nodes.has(E.from_node) && nodes.has(E.to_node)) {
// Add all these as inputs for the Function.
- Ref<VisualScriptNode> node = script->get_node(E->get().to_node);
+ Ref<VisualScriptNode> node = script->get_node(E.to_node);
if (node.is_valid()) {
- dataext.insert(E->get());
- PropertyInfo pi = node->get_input_value_port_info(E->get().to_port);
+ dataext.insert(E);
+ PropertyInfo pi = node->get_input_value_port_info(E.to_port);
inputs.push_back(pi.type);
- input_connections.push_back(Pair<int, int>(E->get().to_node, E->get().to_port));
+ input_connections.push_back(Pair<int, int>(E.to_node, E.to_port));
}
- } else if (nodes.has(E->get().from_node) && !nodes.has(E->get().to_node)) {
- dataext.insert(E->get());
+ } else if (nodes.has(E.from_node) && !nodes.has(E.to_node)) {
+ dataext.insert(E);
}
}
}
@@ -4040,9 +4090,9 @@ void VisualScriptEditor::_menu_option(int p_what) {
// but I hope that it will not be a problem considering that we won't be creating functions so frequently,
// and cyclic connections would be a problem but hopefully we won't let them get to this point.
void VisualScriptEditor::_get_ends(int p_node, const List<VisualScript::SequenceConnection> &p_seqs, const Set<int> &p_selected, Set<int> &r_end_nodes) {
- for (const List<VisualScript::SequenceConnection>::Element *E = p_seqs.front(); E; E = E->next()) {
- int from = E->get().from_node;
- int to = E->get().to_node;
+ for (const VisualScript::SequenceConnection &E : p_seqs) {
+ int from = E.from_node;
+ int to = E.to_node;
if (from == p_node && p_selected.has(to)) {
// This is an interior connection move forward to the to node.
@@ -4066,9 +4116,9 @@ void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) {
TreeItem *root = members->get_root();
- Ref<Texture2D> del_icon = Control::get_theme_icon("Remove", "EditorIcons");
+ Ref<Texture2D> del_icon = Control::get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"));
- Ref<Texture2D> edit_icon = Control::get_theme_icon("Edit", "EditorIcons");
+ Ref<Texture2D> edit_icon = Control::get_theme_icon(SNAME("Edit"), SNAME("EditorIcons"));
if (ti->get_parent() == root->get_first_child()) {
member_type = MEMBER_FUNCTION;
@@ -4116,16 +4166,16 @@ void VisualScriptEditor::_member_option(int p_option) {
undo_redo->add_undo_method(script.ptr(), "add_node", fn_node, script->get_node(fn_node), script->get_node_position(fn_node));
List<VisualScript::SequenceConnection> seqcons;
script->get_sequence_connection_list(&seqcons);
- for (const List<VisualScript::SequenceConnection>::Element *E = seqcons.front(); E; E = E->next()) {
- if (E->get().from_node == fn_node) {
- undo_redo->add_undo_method(script.ptr(), "sequence_connect", fn_node, E->get().from_output, E->get().to_node);
+ for (const VisualScript::SequenceConnection &E : seqcons) {
+ if (E.from_node == fn_node) {
+ undo_redo->add_undo_method(script.ptr(), "sequence_connect", fn_node, E.from_output, E.to_node);
}
}
List<VisualScript::DataConnection> datcons;
script->get_data_connection_list(&datcons);
- for (const List<VisualScript::DataConnection>::Element *E = datcons.front(); E; E = E->next()) {
- if (E->get().from_node == fn_node) {
- undo_redo->add_undo_method(script.ptr(), "data_connect", fn_node, E->get().from_port, E->get().to_node, E->get().to_port);
+ for (const VisualScript::DataConnection &E : datcons) {
+ if (E.from_node == fn_node) {
+ undo_redo->add_undo_method(script.ptr(), "data_connect", fn_node, E.from_port, E.to_node, E.to_port);
}
}
undo_redo->add_do_method(this, "_update_members");
@@ -4237,7 +4287,7 @@ VisualScriptEditor::VisualScriptEditor() {
members_section = memnew(VBoxContainer);
// Add but wait until done setting up this.
- ScriptEditor::get_singleton()->get_left_list_split()->call_deferred("add_child", members_section);
+ ScriptEditor::get_singleton()->get_left_list_split()->call_deferred(SNAME("add_child"), members_section);
members_section->set_v_size_flags(SIZE_EXPAND_FILL);
CheckButton *tool_script_check = memnew(CheckButton);
@@ -4429,11 +4479,6 @@ VisualScriptEditor::VisualScriptEditor() {
add_child(default_value_edit);
default_value_edit->connect("variant_changed", callable_mp(this, &VisualScriptEditor::_default_value_changed));
- method_select = memnew(VisualScriptPropertySelector);
- add_child(method_select);
- method_select->connect("selected", callable_mp(this, &VisualScriptEditor::_selected_method));
- error_line = -1;
-
new_connect_node_select = memnew(VisualScriptPropertySelector);
add_child(new_connect_node_select);
new_connect_node_select->connect("selected", callable_mp(this, &VisualScriptEditor::_selected_connect_node));
@@ -4503,14 +4548,14 @@ void _VisualScriptEditor::add_custom_node(const String &p_name, const String &p_
String node_name = "custom/" + p_category + "/" + p_name;
custom_nodes.insert(node_name, p_script);
VisualScriptLanguage::singleton->add_register_func(node_name, &_VisualScriptEditor::create_node_custom);
- emit_signal("custom_nodes_updated");
+ emit_signal(SNAME("custom_nodes_updated"));
}
void _VisualScriptEditor::remove_custom_node(const String &p_name, const String &p_category) {
String node_name = "custom/" + p_category + "/" + p_name;
custom_nodes.erase(node_name);
VisualScriptLanguage::singleton->remove_register_func(node_name);
- emit_signal("custom_nodes_updated");
+ emit_signal(SNAME("custom_nodes_updated"));
}
void _VisualScriptEditor::_bind_methods() {
diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h
index 1f0f087be7..3b7ed3dba6 100644
--- a/modules/visual_script/visual_script_editor.h
+++ b/modules/visual_script/visual_script_editor.h
@@ -179,6 +179,9 @@ class VisualScriptEditor : public ScriptEditorBase {
void connect_data(Ref<VisualScriptNode> vnode_old, Ref<VisualScriptNode> vnode, int new_id);
+ NodePath drop_path;
+ Node *drop_node = nullptr;
+ Vector2 drop_position;
void _selected_connect_node(const String &p_text, const String &p_category, const bool p_connecting = true);
void connect_seq(Ref<VisualScriptNode> vnode_old, Ref<VisualScriptNode> vnode_new, int new_id);
@@ -270,9 +273,6 @@ class VisualScriptEditor : public ScriptEditorBase {
void _graph_ofs_changed(const Vector2 &p_ofs);
void _comment_node_resized(const Vector2 &p_new_size, int p_node);
- int selecting_method_id;
- void _selected_method(const String &p_method, const String &p_type, const bool p_connecting);
-
void _draw_color_over_button(Object *obj, Color p_color);
void _button_resource_previewed(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, Variant p_ud);
diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp
index d63fbeb726..99b7275008 100644
--- a/modules/visual_script/visual_script_expression.cpp
+++ b/modules/visual_script/visual_script_expression.cpp
@@ -526,10 +526,10 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
r_token.value = Math_TAU;
} else if (id == "INF") {
r_token.type = TK_CONSTANT;
- r_token.value = Math_INF;
+ r_token.value = INFINITY;
} else if (id == "NAN") {
r_token.type = TK_CONSTANT;
- r_token.value = Math_NAN;
+ r_token.value = NAN;
} else if (id == "not") {
r_token.type = TK_OP_NOT;
} else if (id == "or") {
diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp
index af86f90b25..ddf6169015 100644
--- a/modules/visual_script/visual_script_flow_control.cpp
+++ b/modules/visual_script/visual_script_flow_control.cpp
@@ -852,11 +852,11 @@ void VisualScriptTypeCast::_bind_methods() {
}
String script_ext_hint;
- for (List<String>::Element *E = script_extensions.front(); E; E = E->next()) {
+ for (String &E : script_extensions) {
if (script_ext_hint != String()) {
script_ext_hint += ",";
}
- script_ext_hint += "*." + E->get();
+ script_ext_hint += "*." + E;
}
ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type");
diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp
index 8f7b514881..c694d6b8e0 100644
--- a/modules/visual_script/visual_script_func_nodes.cpp
+++ b/modules/visual_script/visual_script_func_nodes.cpp
@@ -254,25 +254,32 @@ PropertyInfo VisualScriptFunctionCall::get_output_value_port_info(int p_idx) con
}
String VisualScriptFunctionCall::get_caption() const {
- if (call_mode == CALL_MODE_SELF) {
- return " " + String(function) + "()";
- }
- if (call_mode == CALL_MODE_SINGLETON) {
- return String(singleton) + ":" + String(function) + "()";
- } else if (call_mode == CALL_MODE_BASIC_TYPE) {
- return Variant::get_type_name(basic_type) + "." + String(function) + "()";
- } else if (call_mode == CALL_MODE_NODE_PATH) {
- return " [" + String(base_path.simplified()) + "]." + String(function) + "()";
- } else {
- return " " + base_type + "." + String(function) + "()";
- }
+ return " " + String(function) + "()";
}
String VisualScriptFunctionCall::get_text() const {
+ String text;
+
+ if (call_mode == CALL_MODE_BASIC_TYPE) {
+ text = String("On ") + Variant::get_type_name(basic_type);
+ } else if (call_mode == CALL_MODE_INSTANCE) {
+ text = String("On ") + 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";
+ } else if (call_mode == CALL_MODE_SINGLETON) {
+ text = String(singleton) + ":" + String(function) + "()";
+ }
+
if (rpc_call_mode) {
- return "RPC";
+ text += " RPC";
+ if (rpc_call_mode == RPC_UNRELIABLE || rpc_call_mode == RPC_UNRELIABLE_TO_ID) {
+ text += " UNREL";
+ }
}
- return "";
+
+ return text;
}
void VisualScriptFunctionCall::set_basic_type(Variant::Type p_type) {
@@ -531,11 +538,11 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const
Engine::get_singleton()->get_singletons(&names);
property.hint = PROPERTY_HINT_ENUM;
String sl;
- for (List<Engine::Singleton>::Element *E = names.front(); E; E = E->next()) {
+ for (Engine::Singleton &E : names) {
if (sl != String()) {
sl += ",";
}
- sl += E->get().name;
+ sl += E.name;
}
property.hint_string = sl;
}
@@ -676,11 +683,11 @@ void VisualScriptFunctionCall::_bind_methods() {
}
String script_ext_hint;
- for (List<String>::Element *E = script_extensions.front(); E; E = E->next()) {
+ for (String &E : script_extensions) {
if (script_ext_hint != String()) {
script_ext_hint += ",";
}
- script_ext_hint += "*." + E->get();
+ script_ext_hint += "*." + E;
}
ADD_PROPERTY(PropertyInfo(Variant::INT, "call_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance,Basic Type,Singleton"), "set_call_mode", "get_call_mode");
@@ -901,11 +908,11 @@ static Ref<VisualScriptNode> create_function_call_node(const String &p_name) {
//////////////////////////////////////////
int VisualScriptPropertySet::get_output_sequence_port_count() const {
- return call_mode != CALL_MODE_BASIC_TYPE ? 1 : 0;
+ return 1;
}
bool VisualScriptPropertySet::has_input_sequence_port() const {
- return call_mode != CALL_MODE_BASIC_TYPE;
+ return 1;
}
Node *VisualScriptPropertySet::_get_base_node() const {
@@ -990,31 +997,33 @@ PropertyInfo VisualScriptPropertySet::get_input_value_port_info(int p_idx) const
if (p_idx == 0) {
PropertyInfo pi;
pi.type = (call_mode == CALL_MODE_INSTANCE ? Variant::OBJECT : basic_type);
- pi.name = (call_mode == CALL_MODE_INSTANCE ? String("instance") : Variant::get_type_name(basic_type).to_lower());
- _adjust_input_index(pi);
+ pi.name = "instance";
return pi;
}
}
List<PropertyInfo> props;
ClassDB::get_property_list(_get_base_type(), &props, false);
- for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
- if (E->get().name == property) {
- PropertyInfo pinfo = PropertyInfo(E->get().type, "value", PROPERTY_HINT_TYPE_STRING, E->get().hint_string);
+ for (PropertyInfo &E : props) {
+ if (E.name == property) {
+ String detail_prop_name = property;
+ if (index != StringName()) {
+ detail_prop_name += "." + String(index);
+ }
+ PropertyInfo pinfo = PropertyInfo(E.type, detail_prop_name, PROPERTY_HINT_TYPE_STRING, E.hint_string);
_adjust_input_index(pinfo);
return pinfo;
}
}
PropertyInfo pinfo = type_cache;
- pinfo.name = "value";
_adjust_input_index(pinfo);
return pinfo;
}
PropertyInfo VisualScriptPropertySet::get_output_value_port_info(int p_idx) const {
if (call_mode == CALL_MODE_BASIC_TYPE) {
- return PropertyInfo(basic_type, "out");
+ return PropertyInfo(basic_type, "pass");
} else if (call_mode == CALL_MODE_INSTANCE) {
return PropertyInfo(Variant::OBJECT, "pass", PROPERTY_HINT_TYPE_STRING, get_base_type());
} else {
@@ -1036,17 +1045,18 @@ String VisualScriptPropertySet::get_caption() const {
}
String VisualScriptPropertySet::get_text() const {
+ if (!has_input_sequence_port()) {
+ return "";
+ }
if (call_mode == CALL_MODE_BASIC_TYPE) {
return String("On ") + Variant::get_type_name(basic_type);
+ } else if (call_mode == CALL_MODE_INSTANCE) {
+ return String("On ") + base_type;
+ } else if (call_mode == CALL_MODE_NODE_PATH) {
+ return " [" + String(base_path.simplified()) + "]";
+ } else {
+ return "On Self";
}
-
- static const char *cname[3] = {
- "Self",
- "Scene Node",
- "Instance"
- };
-
- return String("On ") + cname[call_mode];
}
void VisualScriptPropertySet::_update_base_type() {
@@ -1125,9 +1135,9 @@ void VisualScriptPropertySet::_update_cache() {
List<PropertyInfo> pinfo;
v.get_property_list(&pinfo);
- for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
- if (E->get().name == property) {
- type_cache = E->get();
+ for (PropertyInfo &E : pinfo) {
+ if (E.name == property) {
+ type_cache = E;
}
}
@@ -1176,9 +1186,9 @@ void VisualScriptPropertySet::_update_cache() {
script->get_script_property_list(&pinfo);
}
- for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
- if (E->get().name == property) {
- type_cache = E->get();
+ for (PropertyInfo &E : pinfo) {
+ if (E.name == property) {
+ type_cache = E;
return;
}
}
@@ -1344,8 +1354,8 @@ void VisualScriptPropertySet::_validate_property(PropertyInfo &property) const {
List<PropertyInfo> plist;
v.get_property_list(&plist);
String options = "";
- for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
- options += "," + E->get().name;
+ for (PropertyInfo &E : plist) {
+ options += "," + E.name;
}
property.hint = PROPERTY_HINT_ENUM;
@@ -1400,11 +1410,11 @@ void VisualScriptPropertySet::_bind_methods() {
}
String script_ext_hint;
- for (List<String>::Element *E = script_extensions.front(); E; E = E->next()) {
+ for (String &E : script_extensions) {
if (script_ext_hint != String()) {
script_ext_hint += ",";
}
- script_ext_hint += "*." + E->get();
+ script_ext_hint += "*." + E;
}
ADD_PROPERTY(PropertyInfo(Variant::INT, "set_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance,Basic Type"), "set_call_mode", "get_call_mode");
@@ -1707,7 +1717,9 @@ int VisualScriptPropertyGet::get_input_value_port_count() const {
}
int VisualScriptPropertyGet::get_output_value_port_count() const {
- return 1;
+ int pc = (call_mode == CALL_MODE_BASIC_TYPE || call_mode == CALL_MODE_INSTANCE) ? 2 : 1;
+
+ return pc;
}
String VisualScriptPropertyGet::get_output_sequence_port_text(int p_port) const {
@@ -1727,33 +1739,46 @@ PropertyInfo VisualScriptPropertyGet::get_input_value_port_info(int p_idx) const
}
PropertyInfo VisualScriptPropertyGet::get_output_value_port_info(int p_idx) const {
- List<PropertyInfo> props;
- ClassDB::get_property_list(_get_base_type(), &props, false);
- for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
- if (E->get().name == property) {
- return PropertyInfo(E->get().type, "value." + String(index));
+ if (call_mode == CALL_MODE_BASIC_TYPE && p_idx == 0) {
+ return PropertyInfo(basic_type, "pass");
+ } else if (call_mode == CALL_MODE_INSTANCE && p_idx == 0) {
+ return PropertyInfo(Variant::OBJECT, "pass", PROPERTY_HINT_TYPE_STRING, get_base_type());
+ } else {
+ List<PropertyInfo> props;
+ ClassDB::get_property_list(_get_base_type(), &props, false);
+ for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
+ if (E->get().name == property) {
+ PropertyInfo pinfo = PropertyInfo(E->get().type, String(property) + "." + String(index), E->get().hint, E->get().hint_string);
+ _adjust_input_index(pinfo);
+ return pinfo;
+ }
}
}
- return PropertyInfo(type_cache, "value");
+ PropertyInfo pinfo = PropertyInfo(type_cache, "value");
+ _adjust_input_index(pinfo);
+ return pinfo;
}
String VisualScriptPropertyGet::get_caption() const {
- return String("Get ") + property;
+ String prop = String("Get ") + property;
+ if (index != StringName()) {
+ prop += "." + String(index);
+ }
+
+ return prop;
}
String VisualScriptPropertyGet::get_text() const {
if (call_mode == CALL_MODE_BASIC_TYPE) {
return String("On ") + Variant::get_type_name(basic_type);
+ } else if (call_mode == CALL_MODE_INSTANCE) {
+ return String("On ") + base_type;
+ } else if (call_mode == CALL_MODE_NODE_PATH) {
+ return " [" + String(base_path.simplified()) + "]";
+ } else {
+ return "On Self";
}
-
- static const char *cname[3] = {
- "Self",
- "Scene Node",
- "Instance"
- };
-
- return String("On ") + cname[call_mode];
}
void VisualScriptPropertyGet::set_base_type(const StringName &p_type) {
@@ -1795,9 +1820,9 @@ void VisualScriptPropertyGet::_update_cache() {
List<PropertyInfo> pinfo;
v.get_property_list(&pinfo);
- for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
- if (E->get().name == property) {
- type_cache = E->get().type;
+ for (PropertyInfo &E : pinfo) {
+ if (E.name == property) {
+ type_cache = E.type;
return;
}
}
@@ -1933,6 +1958,19 @@ Variant::Type VisualScriptPropertyGet::_get_type_cache() const {
return type_cache;
}
+void VisualScriptPropertyGet::_adjust_input_index(PropertyInfo &pinfo) const {
+ if (index != StringName()) {
+ Variant v;
+ Callable::CallError ce;
+ Variant::construct(pinfo.type, v, nullptr, 0, ce);
+ Variant i = v.get(index);
+ pinfo.type = i.get_type();
+ pinfo.name = String(property) + "." + index;
+ } else {
+ pinfo.name = String(property);
+ }
+}
+
void VisualScriptPropertyGet::set_index(const StringName &p_type) {
if (index == p_type) {
return;
@@ -2021,8 +2059,8 @@ void VisualScriptPropertyGet::_validate_property(PropertyInfo &property) const {
List<PropertyInfo> plist;
v.get_property_list(&plist);
String options = "";
- for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
- options += "," + E->get().name;
+ for (PropertyInfo &E : plist) {
+ options += "," + E.name;
}
property.hint = PROPERTY_HINT_ENUM;
@@ -2074,11 +2112,11 @@ void VisualScriptPropertyGet::_bind_methods() {
}
String script_ext_hint;
- for (List<String>::Element *E = script_extensions.front(); E; E = E->next()) {
+ for (String &E : script_extensions) {
if (script_ext_hint != String()) {
script_ext_hint += ",";
}
- script_ext_hint += "." + E->get();
+ script_ext_hint += "." + E;
}
ADD_PROPERTY(PropertyInfo(Variant::INT, "set_mode", PROPERTY_HINT_ENUM, "Self,Node Path,Instance,Basic Type"), "set_call_mode", "get_call_mode");
@@ -2159,15 +2197,17 @@ public:
bool valid;
Variant v = *p_inputs[0];
- *p_outputs[0] = v.get(property, &valid);
+ *p_outputs[1] = v.get(property, &valid);
if (index != StringName()) {
- *p_outputs[0] = p_outputs[0]->get_named(index, valid);
+ *p_outputs[1] = p_outputs[1]->get_named(index, valid);
}
if (!valid) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("Invalid index property name.");
}
+
+ *p_outputs[0] = v;
};
}
@@ -2283,11 +2323,11 @@ void VisualScriptEmitSignal::_validate_property(PropertyInfo &property) const {
}
String ml;
- for (List<StringName>::Element *E = sigs.front(); E; E = E->next()) {
+ for (StringName &E : sigs) {
if (ml != String()) {
ml += ",";
}
- ml += E->get();
+ ml += E;
}
property.hint_string = ml;
@@ -2378,8 +2418,8 @@ void register_visual_script_func_nodes() {
List<MethodInfo> ml;
vt.get_method_list(&ml);
- for (List<MethodInfo>::Element *E = ml.front(); E; E = E->next()) {
- VisualScriptLanguage::singleton->add_register_func("functions/by_type/" + type_name + "/" + E->get().name, create_basic_type_call_node);
+ for (MethodInfo &E : ml) {
+ VisualScriptLanguage::singleton->add_register_func("functions/by_type/" + type_name + "/" + E.name, create_basic_type_call_node);
}
}
}
diff --git a/modules/visual_script/visual_script_func_nodes.h b/modules/visual_script/visual_script_func_nodes.h
index eb17be1fbe..cca08455f9 100644
--- a/modules/visual_script/visual_script_func_nodes.h
+++ b/modules/visual_script/visual_script_func_nodes.h
@@ -272,6 +272,8 @@ private:
void _set_type_cache(Variant::Type p_type);
Variant::Type _get_type_cache() const;
+ void _adjust_input_index(PropertyInfo &pinfo) const;
+
protected:
virtual void _validate_property(PropertyInfo &property) const override;
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index 41b51c6e65..e6511792aa 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -1306,12 +1306,12 @@ void VisualScriptVariableGet::_validate_property(PropertyInfo &property) const {
vs->get_variable_list(&vars);
String vhint;
- for (List<StringName>::Element *E = vars.front(); E; E = E->next()) {
+ for (StringName &E : vars) {
if (vhint != String()) {
vhint += ",";
}
- vhint += E->get().operator String();
+ vhint += E.operator String();
}
property.hint = PROPERTY_HINT_ENUM;
@@ -1416,12 +1416,12 @@ void VisualScriptVariableSet::_validate_property(PropertyInfo &property) const {
vs->get_variable_list(&vars);
String vhint;
- for (List<StringName>::Element *E = vars.front(); E; E = E->next()) {
+ for (StringName &E : vars) {
if (vhint != String()) {
vhint += ",";
}
- vhint += E->get().operator String();
+ vhint += E.operator String();
}
property.hint = PROPERTY_HINT_ENUM;
@@ -1944,8 +1944,8 @@ void VisualScriptClassConstant::set_base_type(const StringName &p_which) {
ClassDB::get_integer_constant_list(base_type, &constants, true);
if (constants.size() > 0) {
bool found_name = false;
- for (List<String>::Element *E = constants.front(); E; E = E->next()) {
- if (E->get() == name) {
+ for (String &E : constants) {
+ if (E == name) {
found_name = true;
break;
}
@@ -1993,11 +1993,11 @@ void VisualScriptClassConstant::_validate_property(PropertyInfo &property) const
ClassDB::get_integer_constant_list(base_type, &constants, true);
property.hint_string = "";
- for (List<String>::Element *E = constants.front(); E; E = E->next()) {
+ for (String &E : constants) {
if (property.hint_string != String()) {
property.hint_string += ",";
}
- property.hint_string += E->get();
+ property.hint_string += E;
}
}
}
@@ -2078,8 +2078,8 @@ void VisualScriptBasicTypeConstant::set_basic_type(Variant::Type p_which) {
Variant::get_constants_for_type(type, &constants);
if (constants.size() > 0) {
bool found_name = false;
- for (List<StringName>::Element *E = constants.front(); E; E = E->next()) {
- if (E->get() == name) {
+ for (StringName &E : constants) {
+ if (E == name) {
found_name = true;
break;
}
@@ -2131,11 +2131,11 @@ void VisualScriptBasicTypeConstant::_validate_property(PropertyInfo &property) c
return;
}
property.hint_string = "";
- for (List<StringName>::Element *E = constants.front(); E; E = E->next()) {
+ for (StringName &E : constants) {
if (property.hint_string != String()) {
property.hint_string += ",";
}
- property.hint_string += String(E->get());
+ property.hint_string += String(E);
}
}
}
@@ -2182,8 +2182,8 @@ double VisualScriptMathConstant::const_value[MATH_CONSTANT_MAX] = {
Math_TAU,
2.71828182845904523536,
Math::sqrt(2.0),
- Math_INF,
- Math_NAN
+ INFINITY,
+ NAN
};
int VisualScriptMathConstant::get_output_sequence_port_count() const {
@@ -2358,15 +2358,15 @@ void VisualScriptEngineSingleton::_validate_property(PropertyInfo &property) con
Engine::get_singleton()->get_singletons(&singletons);
- for (List<Engine::Singleton>::Element *E = singletons.front(); E; E = E->next()) {
- if (E->get().name == "VS" || E->get().name == "PS" || E->get().name == "PS2D" || E->get().name == "AS" || E->get().name == "TS" || E->get().name == "SS" || E->get().name == "SS2D") {
+ for (Engine::Singleton &E : singletons) {
+ if (E.name == "VS" || E.name == "PS" || E.name == "PS2D" || E.name == "AS" || E.name == "TS" || E.name == "SS" || E.name == "SS2D") {
continue; //skip these, too simple named
}
if (cc != String()) {
cc += ",";
}
- cc += E->get().name;
+ cc += E.name;
}
property.hint = PROPERTY_HINT_ENUM;
@@ -2868,6 +2868,12 @@ PropertyInfo VisualScriptCustomNode::get_input_value_port_info(int p_idx) const
if (get_script_instance() && get_script_instance()->has_method("_get_input_value_port_name")) {
info.name = get_script_instance()->call("_get_input_value_port_name", p_idx);
}
+ if (get_script_instance() && get_script_instance()->has_method("_get_input_value_port_hint")) {
+ info.hint = PropertyHint(int(get_script_instance()->call("_get_input_value_port_hint", p_idx)));
+ }
+ if (get_script_instance() && get_script_instance()->has_method("_get_input_value_port_hint_string")) {
+ info.hint_string = get_script_instance()->call("_get_input_value_port_hint_string", p_idx);
+ }
return info;
}
@@ -2879,9 +2885,31 @@ PropertyInfo VisualScriptCustomNode::get_output_value_port_info(int p_idx) const
if (get_script_instance() && get_script_instance()->has_method("_get_output_value_port_name")) {
info.name = get_script_instance()->call("_get_output_value_port_name", p_idx);
}
+ if (get_script_instance() && get_script_instance()->has_method("_get_output_value_port_hint")) {
+ info.hint = PropertyHint(int(get_script_instance()->call("_get_output_value_port_hint", p_idx)));
+ }
+ if (get_script_instance() && get_script_instance()->has_method("_get_output_value_port_hint_string")) {
+ info.hint_string = get_script_instance()->call("_get_output_value_port_hint_string", p_idx);
+ }
return info;
}
+VisualScriptCustomNode::TypeGuess VisualScriptCustomNode::guess_output_type(TypeGuess *p_inputs, int p_output) const {
+ TypeGuess tg;
+ PropertyInfo pi = VisualScriptCustomNode::get_output_value_port_info(p_output);
+ tg.type = pi.type;
+ if (pi.type == Variant::OBJECT) {
+ if (pi.hint == PROPERTY_HINT_RESOURCE_TYPE) {
+ if (pi.hint_string.is_resource_file()) {
+ tg.script = ResourceLoader::load(pi.hint_string);
+ } else if (ClassDB::class_exists(pi.hint_string)) {
+ tg.gdclass = pi.hint_string;
+ }
+ }
+ }
+ return tg;
+}
+
String VisualScriptCustomNode::get_caption() const {
if (get_script_instance() && get_script_instance()->has_method("_get_caption")) {
return get_script_instance()->call("_get_caption");
@@ -2990,7 +3018,7 @@ VisualScriptNodeInstance *VisualScriptCustomNode::instantiate(VisualScriptInstan
}
void VisualScriptCustomNode::_script_changed() {
- call_deferred("ports_changed_notify");
+ call_deferred(SNAME("ports_changed_notify"));
}
void VisualScriptCustomNode::_bind_methods() {
@@ -3003,9 +3031,13 @@ void VisualScriptCustomNode::_bind_methods() {
BIND_VMETHOD(MethodInfo(Variant::INT, "_get_input_value_port_type", PropertyInfo(Variant::INT, "idx")));
BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_input_value_port_name", PropertyInfo(Variant::INT, "idx")));
+ BIND_VMETHOD(MethodInfo(Variant::INT, "_get_input_value_port_hint", PropertyInfo(Variant::INT, "idx")));
+ BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_input_value_port_hint_string", PropertyInfo(Variant::INT, "idx")));
BIND_VMETHOD(MethodInfo(Variant::INT, "_get_output_value_port_type", PropertyInfo(Variant::INT, "idx")));
BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_output_value_port_name", PropertyInfo(Variant::INT, "idx")));
+ BIND_VMETHOD(MethodInfo(Variant::INT, "_get_output_value_port_hint", PropertyInfo(Variant::INT, "idx")));
+ BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_output_value_port_hint_string", PropertyInfo(Variant::INT, "idx")));
BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_caption"));
BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_text"));
@@ -3717,9 +3749,7 @@ void VisualScriptInputAction::_validate_property(PropertyInfo &property) const {
ProjectSettings::get_singleton()->get_property_list(&pinfo);
Vector<String> al;
- for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
- const PropertyInfo &pi = E->get();
-
+ for (PropertyInfo &pi : pinfo) {
if (!pi.name.begins_with("input/")) {
continue;
}
@@ -3812,10 +3842,10 @@ void VisualScriptDeconstruct::_update_elements() {
List<PropertyInfo> pinfo;
v.get_property_list(&pinfo);
- for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
+ for (PropertyInfo &E : pinfo) {
Element e;
- e.name = E->get().name;
- e.type = E->get().type;
+ e.name = E.name;
+ e.type = E.type;
elements.push_back(e);
}
}
@@ -3993,24 +4023,24 @@ void register_visual_script_nodes() {
List<MethodInfo> constructors;
Variant::get_constructor_list(Variant::Type(i), &constructors);
- for (List<MethodInfo>::Element *E = constructors.front(); E; E = E->next()) {
- if (E->get().arguments.size() > 0) {
+ for (MethodInfo &E : constructors) {
+ if (E.arguments.size() > 0) {
String name = "functions/constructors/" + Variant::get_type_name(Variant::Type(i)) + "(";
- for (int j = 0; j < E->get().arguments.size(); j++) {
+ for (int j = 0; j < E.arguments.size(); j++) {
if (j > 0) {
name += ", ";
}
- if (E->get().arguments.size() == 1) {
- name += Variant::get_type_name(E->get().arguments[j].type);
+ if (E.arguments.size() == 1) {
+ name += Variant::get_type_name(E.arguments[j].type);
} else {
- name += E->get().arguments[j].name;
+ name += E.arguments[j].name;
}
}
name += ")";
VisualScriptLanguage::singleton->add_register_func(name, create_constructor_node);
Pair<Variant::Type, MethodInfo> pair;
pair.first = Variant::Type(i);
- pair.second = E->get();
+ pair.second = E;
constructor_map[name] = pair;
}
}
diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h
index b599b92b3a..2390e5c7bc 100644
--- a/modules/visual_script/visual_script_nodes.h
+++ b/modules/visual_script/visual_script_nodes.h
@@ -792,6 +792,8 @@ public:
virtual VisualScriptNodeInstance *instantiate(VisualScriptInstance *p_instance) override;
+ virtual TypeGuess guess_output_type(TypeGuess *p_inputs, int p_output) const override;
+
void _script_changed();
VisualScriptCustomNode();
diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp
index 79addc5828..5e9ecbe615 100644
--- a/modules/visual_script/visual_script_property_selector.cpp
+++ b/modules/visual_script/visual_script_property_selector.cpp
@@ -93,43 +93,49 @@ void VisualScriptPropertySelector::_update_search() {
base = ClassDB::get_parent_class_nocheck(base);
}
- for (List<StringName>::Element *E = base_list.front(); E; E = E->next()) {
+ for (StringName &E : base_list) {
List<MethodInfo> methods;
List<PropertyInfo> props;
TreeItem *category = nullptr;
Ref<Texture2D> type_icons[Variant::VARIANT_MAX] = {
- vbc->get_theme_icon("Variant", "EditorIcons"),
- vbc->get_theme_icon("bool", "EditorIcons"),
- vbc->get_theme_icon("int", "EditorIcons"),
- vbc->get_theme_icon("float", "EditorIcons"),
- vbc->get_theme_icon("String", "EditorIcons"),
- vbc->get_theme_icon("Vector2", "EditorIcons"),
- vbc->get_theme_icon("Rect2", "EditorIcons"),
- vbc->get_theme_icon("Vector3", "EditorIcons"),
- vbc->get_theme_icon("Transform2D", "EditorIcons"),
- vbc->get_theme_icon("Plane", "EditorIcons"),
- vbc->get_theme_icon("Quaternion", "EditorIcons"),
- vbc->get_theme_icon("AABB", "EditorIcons"),
- vbc->get_theme_icon("Basis", "EditorIcons"),
- vbc->get_theme_icon("Transform3D", "EditorIcons"),
- vbc->get_theme_icon("Color", "EditorIcons"),
- vbc->get_theme_icon("Path", "EditorIcons"),
- vbc->get_theme_icon("RID", "EditorIcons"),
- vbc->get_theme_icon("Object", "EditorIcons"),
- vbc->get_theme_icon("Dictionary", "EditorIcons"),
- vbc->get_theme_icon("Array", "EditorIcons"),
- vbc->get_theme_icon("PackedByteArray", "EditorIcons"),
- vbc->get_theme_icon("PackedInt32Array", "EditorIcons"),
- vbc->get_theme_icon("PackedFloat32Array", "EditorIcons"),
- vbc->get_theme_icon("PackedInt64Array", "EditorIcons"),
- vbc->get_theme_icon("PackedFloat64Array", "EditorIcons"),
- vbc->get_theme_icon("PackedStringArray", "EditorIcons"),
- vbc->get_theme_icon("PackedVector2Array", "EditorIcons"),
- vbc->get_theme_icon("PackedVector3Array", "EditorIcons"),
- vbc->get_theme_icon("PackedColorArray", "EditorIcons")
+ 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->get());
+ String b = String(E);
category = search_options->create_item(root);
if (category) {
category->set_text(0, b.replace_first("*", ""));
@@ -148,30 +154,30 @@ void VisualScriptPropertySelector::_update_search() {
if (Object::cast_to<Script>(obj)) {
Object::cast_to<Script>(obj)->get_script_property_list(&props);
} else {
- ClassDB::get_property_list(E->get(), &props, true);
+ ClassDB::get_property_list(E, &props, true);
}
}
- for (List<PropertyInfo>::Element *F = props.front(); F; F = F->next()) {
- if (!(F->get().usage & PROPERTY_USAGE_EDITOR) && !(F->get().usage & PROPERTY_USAGE_SCRIPT_VARIABLE)) {
+ for (PropertyInfo &F : props) {
+ if (!(F.usage & PROPERTY_USAGE_EDITOR) && !(F.usage & PROPERTY_USAGE_SCRIPT_VARIABLE)) {
continue;
}
- if (type_filter.size() && type_filter.find(F->get().type) == -1) {
+ if (type_filter.size() && type_filter.find(F.type) == -1) {
continue;
}
// capitalize() also converts underscore to space, we'll match again both possible styles
- String get_text_raw = String(vformat(TTR("Get %s"), F->get().name));
+ String get_text_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->get().name));
+ 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 == String() || get_text_raw.findn(input) != -1 || get_text.findn(input) != -1) {
TreeItem *item = search_options->create_item(category ? category : root);
item->set_text(0, get_text);
- item->set_metadata(0, F->get().name);
- item->set_icon(0, type_icons[F->get().type]);
+ item->set_metadata(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);
@@ -183,8 +189,8 @@ void VisualScriptPropertySelector::_update_search() {
if (input == String() || set_text_raw.findn(input) != -1 || set_text.findn(input) != -1) {
TreeItem *item = search_options->create_item(category ? category : root);
item->set_text(0, set_text);
- item->set_metadata(0, F->get().name);
- item->set_icon(0, type_icons[F->get().type]);
+ item->set_metadata(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);
@@ -205,7 +211,7 @@ void VisualScriptPropertySelector::_update_search() {
Object::cast_to<Script>(obj)->get_script_method_list(&methods);
}
- ClassDB::get_method_list(E->get(), &methods, true, true);
+ ClassDB::get_method_list(E, &methods, true, true);
}
}
for (List<MethodInfo>::Element *M = methods.front(); M; M = M->next()) {
@@ -253,7 +259,7 @@ void VisualScriptPropertySelector::_update_search() {
TreeItem *item = search_options->create_item(category ? category : root);
item->set_text(0, desc);
- item->set_icon(0, vbc->get_theme_icon("MemberMethod", "EditorIcons"));
+ item->set_icon(0, vbc->get_theme_icon(SNAME("MemberMethod"), SNAME("EditorIcons")));
item->set_metadata(0, name);
item->set_selectable(0, true);
@@ -317,7 +323,7 @@ void VisualScriptPropertySelector::create_visualscript_item(const String &name,
if (search_input == String() || text.findn(search_input) != -1) {
TreeItem *item = search_options->create_item(root);
item->set_text(0, text);
- item->set_icon(0, vbc->get_theme_icon("VisualScript", "EditorIcons"));
+ 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);
@@ -334,11 +340,11 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt
List<String> fnodes;
VisualScriptLanguage::singleton->get_registered_node_names(&fnodes);
- for (List<String>::Element *E = fnodes.front(); E; E = E->next()) {
- if (!E->get().begins_with(root_filter)) {
+ for (String &E : fnodes) {
+ if (!E.begins_with(root_filter)) {
continue;
}
- Vector<String> path = E->get().split("/");
+ Vector<String> path = E.split("/");
// check if the name has the filter
bool in_filter = false;
@@ -349,7 +355,7 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt
} else {
in_filter = false;
}
- if (E->get().findn(tx_filters[i]) != -1) {
+ if (E.findn(tx_filters[i]) != -1) {
in_filter = true;
break;
}
@@ -360,7 +366,7 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt
bool in_modifier = p_modifiers.is_empty();
for (Set<String>::Element *F = p_modifiers.front(); F && in_modifier; F = F->next()) {
- if (E->get().findn(F->get()) != -1) {
+ if (E.findn(F->get()) != -1) {
in_modifier = true;
}
}
@@ -369,7 +375,7 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt
}
TreeItem *item = search_options->create_item(root);
- Ref<VisualScriptNode> vnode = VisualScriptLanguage::singleton->create_node_from_name(E->get());
+ Ref<VisualScriptNode> vnode = VisualScriptLanguage::singleton->create_node_from_name(E);
Ref<VisualScriptOperator> vnode_operator = vnode;
String type_name;
if (vnode_operator.is_valid()) {
@@ -401,9 +407,9 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt
}
item->set_text(0, type_name + String("").join(desc));
- item->set_icon(0, vbc->get_theme_icon("VisualScript", "EditorIcons"));
+ item->set_icon(0, vbc->get_theme_icon(SNAME("VisualScript"), SNAME("EditorIcons")));
item->set_selectable(0, true);
- item->set_metadata(0, E->get());
+ item->set_metadata(0, E);
item->set_selectable(0, true);
item->set_metadata(1, "visualscript");
item->set_selectable(1, false);
@@ -417,7 +423,7 @@ void VisualScriptPropertySelector::_confirmed() {
if (!ti) {
return;
}
- emit_signal("selected", ti->get_metadata(0), ti->get_metadata(1), ti->get_metadata(2));
+ emit_signal(SNAME("selected"), ti->get_metadata(0), ti->get_metadata(1), ti->get_metadata(2));
set_visible(false);
}
diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp
index d8bc926a1d..bf269b1d7a 100644
--- a/modules/visual_script/visual_script_yield_nodes.cpp
+++ b/modules/visual_script/visual_script_yield_nodes.cpp
@@ -438,21 +438,21 @@ void VisualScriptYieldSignal::_validate_property(PropertyInfo &property) const {
ClassDB::get_signal_list(_get_base_type(), &methods);
List<String> mstring;
- for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) {
- if (E->get().name.begins_with("_")) {
+ for (MethodInfo &E : methods) {
+ if (E.name.begins_with("_")) {
continue;
}
- mstring.push_back(E->get().name.get_slice(":", 0));
+ mstring.push_back(E.name.get_slice(":", 0));
}
mstring.sort();
String ml;
- for (List<String>::Element *E = mstring.front(); E; E = E->next()) {
+ for (String &E : mstring) {
if (ml != String()) {
ml += ",";
}
- ml += E->get();
+ ml += E;
}
property.hint_string = ml;