summaryrefslogtreecommitdiff
path: root/modules/visual_script
diff options
context:
space:
mode:
Diffstat (limited to 'modules/visual_script')
-rw-r--r--modules/visual_script/visual_script.cpp130
-rw-r--r--modules/visual_script/visual_script_editor.cpp260
-rw-r--r--modules/visual_script/visual_script_flow_control.cpp4
-rw-r--r--modules/visual_script/visual_script_func_nodes.cpp56
-rw-r--r--modules/visual_script/visual_script_nodes.cpp54
-rw-r--r--modules/visual_script/visual_script_property_selector.cpp40
-rw-r--r--modules/visual_script/visual_script_yield_nodes.cpp10
7 files changed, 275 insertions, 279 deletions
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index 0de39512ae..5828529103 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -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 ed0583a133..16313d58d0 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -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);
}
}
@@ -656,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;
@@ -696,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()) {
@@ -706,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())) {
@@ -716,7 +714,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
line_edit->set_expand_to_text_length_enabled(true);
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()) {
@@ -732,7 +730,7 @@ 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())) {
@@ -835,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)));
}
@@ -849,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(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);
@@ -887,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 {
@@ -911,7 +909,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
Button *rmbtn = memnew(Button);
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);
@@ -921,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()) {
@@ -930,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)));
}
@@ -1047,13 +1045,13 @@ void VisualScriptEditor::_update_members() {
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->set_metadata(0, E);
ti->add_button(0, Control::get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), 0);
- if (selected == E->get()) {
+ if (selected == E) {
ti->select(0);
}
}
@@ -1101,18 +1099,18 @@ void VisualScriptEditor::_update_members() {
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);
}
}
@@ -1125,13 +1123,13 @@ void VisualScriptEditor::_update_members() {
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);
}
}
@@ -1237,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;
}
@@ -1572,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);
}
}
@@ -1587,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);
}
}
@@ -1642,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;
@@ -1698,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));
@@ -1707,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);
}
}
}
@@ -1767,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);
}
}
@@ -1903,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;
}
@@ -2221,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);
@@ -2554,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(SNAME("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;
}
}
@@ -2600,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.
}
}
}
@@ -2775,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);
}
}
@@ -2804,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;
@@ -3462,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;
}
}
@@ -3734,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);
}
@@ -3774,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) {
@@ -3811,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);
}
}
@@ -3935,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.
@@ -3978,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);
}
}
}
@@ -4092,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.
@@ -4168,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");
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 a6c52a0f8c..c694d6b8e0 100644
--- a/modules/visual_script/visual_script_func_nodes.cpp
+++ b/modules/visual_script/visual_script_func_nodes.cpp
@@ -538,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;
}
@@ -683,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");
@@ -1004,13 +1004,13 @@ PropertyInfo VisualScriptPropertySet::get_input_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) {
+ 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->get().type, detail_prop_name, PROPERTY_HINT_TYPE_STRING, E->get().hint_string);
+ PropertyInfo pinfo = PropertyInfo(E.type, detail_prop_name, PROPERTY_HINT_TYPE_STRING, E.hint_string);
_adjust_input_index(pinfo);
return pinfo;
}
@@ -1135,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;
}
}
@@ -1186,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;
}
}
@@ -1354,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;
@@ -1410,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");
@@ -1820,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;
}
}
@@ -2059,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;
@@ -2112,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");
@@ -2323,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;
@@ -2418,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_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index 86d8050acb..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);
}
}
}
@@ -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;
@@ -3749,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;
}
@@ -3844,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);
}
}
@@ -4025,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_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp
index ccb2e2df75..5e9ecbe615 100644
--- a/modules/visual_script/visual_script_property_selector.cpp
+++ b/modules/visual_script/visual_script_property_selector.cpp
@@ -93,7 +93,7 @@ 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;
@@ -135,7 +135,7 @@ void VisualScriptPropertySelector::_update_search() {
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("*", ""));
@@ -154,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);
@@ -189,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);
@@ -211,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()) {
@@ -340,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;
@@ -355,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;
}
@@ -366,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;
}
}
@@ -375,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()) {
@@ -409,7 +409,7 @@ 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(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);
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;