summaryrefslogtreecommitdiff
path: root/modules/visual_script/visual_script_editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/visual_script/visual_script_editor.cpp')
-rw-r--r--modules/visual_script/visual_script_editor.cpp200
1 files changed, 0 insertions, 200 deletions
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 3649486724..f7e9e30ed6 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -46,7 +46,6 @@
#ifdef TOOLS_ENABLED
class VisualScriptEditorSignalEdit : public Object {
-
GDCLASS(VisualScriptEditorSignalEdit, Object);
StringName sig;
@@ -62,18 +61,15 @@ protected:
}
void _sig_changed() {
-
_change_notify();
emit_signal("changed");
}
bool _set(const StringName &p_name, const Variant &p_value) {
-
if (sig == StringName())
return false;
if (p_name == "argument_count") {
-
int new_argc = p_value;
int argc = script->custom_signal_get_argument_count(sig);
if (argc == new_argc)
@@ -87,9 +83,7 @@ protected:
undo_redo->add_undo_method(script.ptr(), "custom_signal_add_argument", sig, script->custom_signal_get_argument_name(sig, i), script->custom_signal_get_argument_type(sig, i), -1);
}
} else if (new_argc > argc) {
-
for (int i = argc; i < new_argc; i++) {
-
undo_redo->add_do_method(script.ptr(), "custom_signal_add_argument", sig, Variant::NIL, "arg" + itos(i + 1), -1);
undo_redo->add_undo_method(script.ptr(), "custom_signal_remove_argument", sig, argc);
}
@@ -107,7 +101,6 @@ protected:
ERR_FAIL_INDEX_V(idx, script->custom_signal_get_argument_count(sig), false);
String what = String(p_name).get_slice("/", 2);
if (what == "type") {
-
int old_type = script->custom_signal_get_argument_type(sig, idx);
int new_type = p_value;
undo_redo->create_action(TTR("Change Argument Type"));
@@ -119,7 +112,6 @@ protected:
}
if (what == "name") {
-
String old_name = script->custom_signal_get_argument_name(sig, idx);
String new_name = p_value;
undo_redo->create_action(TTR("Change Argument name"));
@@ -134,7 +126,6 @@ protected:
}
bool _get(const StringName &p_name, Variant &r_ret) const {
-
if (sig == StringName())
return false;
@@ -159,7 +150,6 @@ protected:
return false;
}
void _get_property_list(List<PropertyInfo> *p_list) const {
-
if (sig == StringName())
return;
@@ -177,7 +167,6 @@ protected:
public:
void edit(const StringName &p_sig) {
-
sig = p_sig;
_change_notify();
}
@@ -186,7 +175,6 @@ public:
};
class VisualScriptEditorVariableEdit : public Object {
-
GDCLASS(VisualScriptEditorVariableEdit, Object);
StringName var;
@@ -203,18 +191,15 @@ protected:
}
void _var_changed() {
-
_change_notify();
emit_signal("changed");
}
void _var_value_changed() {
-
_change_notify("value"); //so the whole tree is not redrawn, makes editing smoother in general
emit_signal("changed");
}
bool _set(const StringName &p_name, const Variant &p_value) {
-
if (var == StringName())
return false;
@@ -232,7 +217,6 @@ protected:
Dictionary d = script->call("get_variable_info", var);
if (String(p_name) == "type") {
-
Dictionary dc = d.duplicate();
dc["type"] = p_value;
undo_redo->create_action(TTR("Set Variable Type"));
@@ -245,7 +229,6 @@ protected:
}
if (String(p_name) == "hint") {
-
Dictionary dc = d.duplicate();
dc["hint"] = p_value;
undo_redo->create_action(TTR("Set Variable Type"));
@@ -258,7 +241,6 @@ protected:
}
if (String(p_name) == "hint_string") {
-
Dictionary dc = d.duplicate();
dc["hint_string"] = p_value;
undo_redo->create_action(TTR("Set Variable Type"));
@@ -280,7 +262,6 @@ protected:
}
bool _get(const StringName &p_name, Variant &r_ret) const {
-
if (var == StringName())
return false;
@@ -312,7 +293,6 @@ protected:
return false;
}
void _get_property_list(List<PropertyInfo> *p_list) const {
-
if (var == StringName())
return;
@@ -330,7 +310,6 @@ protected:
public:
void edit(const StringName &p_var) {
-
var = p_var;
_change_notify();
}
@@ -557,7 +536,6 @@ static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) {
}
void VisualScriptEditor::_update_graph_connections() {
-
graph->clear_connections();
List<StringName> funcs;
@@ -569,12 +547,10 @@ void VisualScriptEditor::_update_graph_connections() {
}
for (List<StringName>::Element *F = funcs.front(); F; F = F->next()) {
-
List<VisualScript::SequenceConnection> sequence_conns;
script->get_sequence_connection_list(F->get(), &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);
}
@@ -582,7 +558,6 @@ void VisualScriptEditor::_update_graph_connections() {
script->get_data_connection_list(F->get(), &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(F->get(), E->get().from_node);
@@ -600,7 +575,6 @@ void VisualScriptEditor::_update_graph_connections() {
}
void VisualScriptEditor::_update_graph(int p_only_id) {
-
if (updating_graph)
return;
@@ -614,9 +588,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
memdelete(gid);
}
} else {
-
for (int i = 0; i < graph->get_child_count(); i++) {
-
if (Object::cast_to<GraphNode>(graph->get_child(i))) {
memdelete(graph->get_child(i));
i--;
@@ -681,7 +653,6 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
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())
continue;
@@ -807,12 +778,10 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
int mixed_seq_ports = 0;
if (!single_seq_output) {
-
if (node->has_mixed_input_and_sequence_ports()) {
mixed_seq_ports = node->get_output_sequence_port_count();
} else {
for (int i = 0; i < node->get_output_sequence_port_count(); i++) {
-
Label *text2 = memnew(Label);
text2->set_text(node->get_output_sequence_port_text(i));
text2->set_align(Label::ALIGN_RIGHT);
@@ -824,7 +793,6 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
}
for (int i = 0; i < MAX(node->get_output_value_port_count(), MAX(mixed_seq_ports, node->get_input_value_port_count())); i++) {
-
bool left_ok = false;
Variant::Type left_type = Variant::NIL;
String left_name;
@@ -852,7 +820,6 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
vbc->add_child(hbc);
vbc->add_child(hbc2);
if (left_ok) {
-
Ref<Texture2D> t;
if (left_type >= 0 && left_type < Variant::VARIANT_MAX) {
t = type_icons[left_type];
@@ -897,7 +864,6 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
}
if (left_type != Variant::NIL && !script->is_input_value_port_connected(F->get(), E->get(), i)) {
-
PropertyInfo pi = node->get_input_value_port_info(i);
Button *button = memnew(Button);
Variant value = node->get_default_input_value(i);
@@ -913,7 +879,6 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
button->set_custom_minimum_size(Size2(30, 0) * EDSCALE);
button->connect("draw", callable_mp(this, &VisualScriptEditor::_draw_color_over_button), varray(button, value));
} else if (left_type == Variant::OBJECT && Ref<Resource>(value).is_valid()) {
-
Ref<Resource> res = value;
Array arr;
arr.push_back(button->get_instance_id());
@@ -921,10 +886,8 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
EditorResourcePreview::get_singleton()->queue_edited_resource_preview(res, this, "_button_resource_previewed", arr);
} else if (pi.type == Variant::INT && pi.hint == PROPERTY_HINT_ENUM) {
-
button->set_text(pi.hint_string.get_slice(",", value));
} else {
-
button->set_text(value);
}
button->connect("pressed", callable_mp(this, &VisualScriptEditor::_default_value_edited), varray(button, E->get(), i));
@@ -940,7 +903,6 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
hbc2->add_spacer();
if (i < mixed_seq_ports) {
-
Label *text2 = memnew(Label);
text2->set_text(node->get_output_sequence_port_text(i));
text2->set_align(Label::ALIGN_RIGHT);
@@ -948,7 +910,6 @@ 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"));
@@ -1019,7 +980,6 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
}
void VisualScriptEditor::_change_port_type(int p_select, int p_id, int p_port, bool is_input) {
-
StringName func = _get_function_of_node(p_id);
Ref<VisualScriptLists> vsn = script->get_node(func, p_id);
@@ -1038,7 +998,6 @@ void VisualScriptEditor::_change_port_type(int p_select, int p_id, int p_port, b
}
void VisualScriptEditor::_update_node_size(int p_id) {
-
Node *node = graph->get_node(itos(p_id));
if (Object::cast_to<Control>(node))
Object::cast_to<Control>(node)->set_size(Vector2(1, 1)); //shrink if text is smaller
@@ -1086,7 +1045,6 @@ void VisualScriptEditor::_update_members() {
List<StringName> func_names;
script->get_function_list(&func_names);
for (List<StringName>::Element *E = func_names.front(); E; E = E->next()) {
-
if (E->get() == default_func) {
continue;
}
@@ -1189,7 +1147,6 @@ void VisualScriptEditor::_update_members() {
}
void VisualScriptEditor::_member_selected() {
-
if (updating_members)
return;
@@ -1199,7 +1156,6 @@ void VisualScriptEditor::_member_selected() {
selected = ti->get_metadata(0);
if (ti->get_parent() == members->get_root()->get_children()) {
-
#ifdef OSX_ENABLED
bool held_ctrl = Input::get_singleton()->is_key_pressed(KEY_META);
#else
@@ -1213,7 +1169,6 @@ void VisualScriptEditor::_member_selected() {
}
void VisualScriptEditor::_member_edited() {
-
if (updating_members)
return;
@@ -1227,7 +1182,6 @@ void VisualScriptEditor::_member_edited() {
return;
if (!new_name.is_valid_identifier()) {
-
EditorNode::get_singleton()->show_warning(TTR("Name is not a valid identifier:") + " " + new_name);
updating_members = true;
ti->set_text(0, name);
@@ -1236,7 +1190,6 @@ void VisualScriptEditor::_member_edited() {
}
if (script->has_function(new_name) || script->has_variable(new_name) || script->has_custom_signal(new_name)) {
-
EditorNode::get_singleton()->show_warning(TTR("Name already in use by another func/var/signal:") + " " + new_name);
updating_members = true;
ti->set_text(0, name);
@@ -1247,7 +1200,6 @@ void VisualScriptEditor::_member_edited() {
TreeItem *root = members->get_root();
if (ti->get_parent() == root->get_children()) {
-
selected = new_name;
int node_id = script->get_function_node_id(name);
@@ -1292,7 +1244,6 @@ void VisualScriptEditor::_member_edited() {
}
if (ti->get_parent() == root->get_children()->get_next()) {
-
selected = new_name;
undo_redo->create_action(TTR("Rename Variable"));
undo_redo->add_do_method(script.ptr(), "rename_variable", name, new_name);
@@ -1309,7 +1260,6 @@ void VisualScriptEditor::_member_edited() {
}
if (ti->get_parent() == root->get_children()->get_next()->get_next()) {
-
selected = new_name;
undo_redo->create_action(TTR("Rename Signal"));
undo_redo->add_do_method(script.ptr(), "rename_custom_signal", name, new_name);
@@ -1431,7 +1381,6 @@ void VisualScriptEditor::_deselect_input_names() {
}
void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_button) {
-
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
TreeItem *root = members->get_root();
@@ -1446,7 +1395,6 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
return;
} else if (p_button == 0) {
-
String name = _validate_name("new_function");
selected = name;
Vector2 ofs = _get_available_pos();
@@ -1514,7 +1462,6 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
}
void VisualScriptEditor::_add_input_port(int p_id) {
-
StringName func = _get_function_of_node(p_id);
Ref<VisualScriptLists> vsn = script->get_node(func, p_id);
@@ -1536,7 +1483,6 @@ void VisualScriptEditor::_add_input_port(int p_id) {
}
void VisualScriptEditor::_add_output_port(int p_id) {
-
StringName func = _get_function_of_node(p_id);
Ref<VisualScriptLists> vsn = script->get_node(func, p_id);
@@ -1558,7 +1504,6 @@ void VisualScriptEditor::_add_output_port(int p_id) {
}
void VisualScriptEditor::_remove_input_port(int p_id, int p_port) {
-
StringName func = _get_function_of_node(p_id);
Ref<VisualScriptLists> vsn = script->get_node(func, p_id);
@@ -1590,7 +1535,6 @@ void VisualScriptEditor::_remove_input_port(int p_id, int p_port) {
}
void VisualScriptEditor::_remove_output_port(int p_id, int p_port) {
-
StringName func = _get_function_of_node(p_id);
Ref<VisualScriptLists> vsn = script->get_node(func, p_id);
@@ -1634,7 +1578,6 @@ void VisualScriptEditor::_remove_output_port(int p_id, int p_port) {
}
void VisualScriptEditor::_expression_text_changed(const String &p_text, int p_id) {
-
StringName func = _get_function_of_node(p_id);
Ref<VisualScriptExpression> vse = script->get_node(func, p_id);
@@ -1694,12 +1637,10 @@ Vector2 VisualScriptEditor::_get_available_pos(bool centered, Vector2 ofs) const
}
String VisualScriptEditor::_validate_name(const String &p_name) const {
-
String valid = p_name;
int counter = 1;
while (true) {
-
bool exists = script->has_function(valid) || script->has_variable(valid) || script->has_custom_signal(valid);
if (exists) {
@@ -1715,7 +1656,6 @@ String VisualScriptEditor::_validate_name(const String &p_name) const {
}
void VisualScriptEditor::_on_nodes_delete() {
-
// delete all the selected nodes
List<int> to_erase;
@@ -1735,7 +1675,6 @@ 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();
StringName func = _get_function_of_node(cr_node);
@@ -1747,7 +1686,6 @@ void VisualScriptEditor::_on_nodes_delete() {
script->get_sequence_connection_list(func, &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", func, E->get().from_node, E->get().from_output, E->get().to_node);
}
@@ -1757,7 +1695,6 @@ void VisualScriptEditor::_on_nodes_delete() {
script->get_data_connection_list(func, &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", func, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
}
@@ -1770,7 +1707,6 @@ void VisualScriptEditor::_on_nodes_delete() {
}
void VisualScriptEditor::_on_nodes_duplicate() {
-
Set<int> to_duplicate;
List<StringName> funcs;
@@ -1795,7 +1731,6 @@ void VisualScriptEditor::_on_nodes_duplicate() {
HashMap<int, int> remap;
for (Set<int>::Element *F = to_duplicate.front(); F; F = F->next()) {
-
// duplicate from the specific function but place it into the default func as it would lack the connections
StringName func = _get_function_of_node(F->get());
Ref<VisualScriptNode> node = script->get_node(func, F->get());
@@ -1884,7 +1819,6 @@ void VisualScriptEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
}
void VisualScriptEditor::_members_gui_input(const Ref<InputEvent> &p_event) {
-
Ref<InputEventKey> key = p_event;
if (key.is_valid() && key->is_pressed() && !key->is_echo()) {
if (members->has_focus()) {
@@ -1920,15 +1854,12 @@ void VisualScriptEditor::_members_gui_input(const Ref<InputEvent> &p_event) {
}
void VisualScriptEditor::_rename_function(const String &name, const String &new_name) {
-
if (!new_name.is_valid_identifier()) {
-
EditorNode::get_singleton()->show_warning(TTR("Name is not a valid identifier:") + " " + new_name);
return;
}
if (script->has_function(new_name) || script->has_variable(new_name) || script->has_custom_signal(new_name)) {
-
EditorNode::get_singleton()->show_warning(TTR("Name already in use by another func/var/signal:") + " " + new_name);
return;
}
@@ -1973,7 +1904,6 @@ void VisualScriptEditor::_rename_function(const String &name, const String &new_
}
void VisualScriptEditor::_fn_name_box_input(const Ref<InputEvent> &p_event) {
-
if (!function_name_edit->is_visible())
return;
@@ -1986,9 +1916,7 @@ void VisualScriptEditor::_fn_name_box_input(const Ref<InputEvent> &p_event) {
}
Variant VisualScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
-
if (p_from == members) {
-
TreeItem *it = members->get_item_at_position(p_point);
if (!it)
return Variant();
@@ -2002,15 +1930,12 @@ Variant VisualScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_f
TreeItem *root = members->get_root();
if (it->get_parent() == root->get_children()) {
-
dd["type"] = "visual_script_function_drag";
dd["function"] = type;
} else if (it->get_parent() == root->get_children()->get_next()) {
-
dd["type"] = "visual_script_variable_drag";
dd["variable"] = type;
} else if (it->get_parent() == root->get_children()->get_next()->get_next()) {
-
dd["type"] = "visual_script_signal_drag";
dd["signal"] = type;
@@ -2027,9 +1952,7 @@ Variant VisualScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_f
}
bool VisualScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
-
if (p_from == graph) {
-
Dictionary d = p_data;
if (d.has("type") &&
(String(d["type"]) == "visual_script_node_drag" ||
@@ -2040,9 +1963,7 @@ bool VisualScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
String(d["type"]) == "resource" ||
String(d["type"]) == "files" ||
String(d["type"]) == "nodes")) {
-
if (String(d["type"]) == "obj_property") {
-
#ifdef OSX_ENABLED
const_cast<VisualScriptEditor *>(this)->_show_hint(vformat(TTR("Hold %s to drop a Getter. Hold Shift to drop a generic signature."), find_keycode_name(KEY_META)));
#else
@@ -2051,7 +1972,6 @@ bool VisualScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
}
if (String(d["type"]) == "nodes") {
-
#ifdef OSX_ENABLED
const_cast<VisualScriptEditor *>(this)->_show_hint(vformat(TTR("Hold %s to drop a simple reference to the node."), find_keycode_name(KEY_META)));
#else
@@ -2060,7 +1980,6 @@ bool VisualScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
}
if (String(d["type"]) == "visual_script_variable_drag") {
-
#ifdef OSX_ENABLED
const_cast<VisualScriptEditor *>(this)->_show_hint(vformat(TTR("Hold %s to drop a Variable Setter."), find_keycode_name(KEY_META)));
#else
@@ -2076,7 +1995,6 @@ bool VisualScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
}
static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) {
-
if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene)
return nullptr;
@@ -2095,7 +2013,6 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const
}
void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
-
if (p_from != graph) {
return;
}
@@ -2130,7 +2047,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "visual_script_variable_drag") {
-
#ifdef OSX_ENABLED
bool use_set = Input::get_singleton()->is_key_pressed(KEY_META);
#else
@@ -2151,7 +2067,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
vnodes->set_variable(d["variable"]);
vnode = vnodes;
} else {
-
Ref<VisualScriptVariableGet> vnodeg;
vnodeg.instance();
vnodeg->set_variable(d["variable"]);
@@ -2175,7 +2090,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "visual_script_function_drag") {
-
Vector2 ofs = graph->get_scroll_ofs() + p_point;
if (graph->is_using_snap()) {
int snap = graph->get_snap();
@@ -2208,7 +2122,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "visual_script_signal_drag") {
-
Vector2 ofs = graph->get_scroll_ofs() + p_point;
if (graph->is_using_snap()) {
int snap = graph->get_snap();
@@ -2238,7 +2151,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "resource") {
-
Vector2 ofs = graph->get_scroll_ofs() + p_point;
if (graph->is_using_snap()) {
int snap = graph->get_snap();
@@ -2268,7 +2180,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "files") {
-
Vector2 ofs = graph->get_scroll_ofs() + p_point;
if (graph->is_using_snap()) {
int snap = graph->get_snap();
@@ -2286,7 +2197,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
undo_redo->create_action(TTR("Add Preload Node"));
for (int i = 0; i < files.size(); i++) {
-
Ref<Resource> res = ResourceLoader::load(files[i]);
if (!res.is_valid())
continue;
@@ -2308,7 +2218,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
for (List<int>::Element *E = new_ids.front(); E; E = E->next()) {
-
Node *node = graph->get_node(itos(E->get()));
if (node) {
graph->set_selected(node);
@@ -2318,7 +2227,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "nodes") {
-
Node *sn = _find_script_node(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root(), script);
if (!sn) {
@@ -2350,7 +2258,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
for (int i = 0; i < nodes.size(); i++) {
-
NodePath np = nodes[i];
Node *node = get_node(np);
if (!node) {
@@ -2388,7 +2295,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
if (String(d["type"]) == "obj_property") {
-
Node *sn = _find_script_node(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root(), script);
if (!sn && !Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
@@ -2417,7 +2323,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
#endif
if (!node || Input::get_singleton()->is_key_pressed(KEY_SHIFT)) {
-
if (use_get)
undo_redo->create_action(TTR("Add Getter Property"));
else
@@ -2428,7 +2333,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
Ref<VisualScriptNode> vnode;
if (!use_get) {
-
Ref<VisualScriptPropertySet> pset;
pset.instance();
pset->set_call_mode(VisualScriptPropertySet::CALL_MODE_INSTANCE);
@@ -2439,7 +2343,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
}*/
vnode = pset;
} else {
-
Ref<VisualScriptPropertyGet> pget;
pget.instance();
pget->set_call_mode(VisualScriptPropertyGet::CALL_MODE_INSTANCE);
@@ -2461,7 +2364,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
undo_redo->commit_action();
} else {
-
if (use_get)
undo_redo->create_action(TTR("Add Getter Property"));
else
@@ -2472,7 +2374,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
Ref<VisualScriptNode> vnode;
if (!use_get) {
-
Ref<VisualScriptPropertySet> pset;
pset.instance();
if (sn == node) {
@@ -2484,7 +2385,6 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
vnode = pset;
} else {
-
Ref<VisualScriptPropertyGet> pget;
pget.instance();
if (sn == node) {
@@ -2510,7 +2410,6 @@ 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(default_func, selecting_method_id);
if (!vsfc.is_valid())
return;
@@ -2518,7 +2417,6 @@ void VisualScriptEditor::_selected_method(const String &p_method, const String &
}
void VisualScriptEditor::_draw_color_over_button(Object *obj, Color p_color) {
-
Button *button = Object::cast_to<Button>(obj);
if (!button)
return;
@@ -2528,7 +2426,6 @@ void VisualScriptEditor::_draw_color_over_button(Object *obj, Color p_color) {
}
void VisualScriptEditor::_button_resource_previewed(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, Variant p_ud) {
-
Array ud = p_ud;
ERR_FAIL_COND(ud.size() != 2);
@@ -2544,7 +2441,6 @@ void VisualScriptEditor::_button_resource_previewed(const String &p_path, const
if (p_preview.is_null()) {
b->set_text(ud[1]);
} else {
-
b->set_icon(p_preview);
}
}
@@ -2559,7 +2455,6 @@ RES VisualScriptEditor::get_edited_resource() const {
}
void VisualScriptEditor::set_edited_resource(const RES &p_res) {
-
script = p_res;
signal_editor->script = script;
signal_editor->undo_redo = undo_redo;
@@ -2581,7 +2476,6 @@ void VisualScriptEditor::set_edited_resource(const RES &p_res) {
}
Vector<String> VisualScriptEditor::get_functions() {
-
return Vector<String>();
}
@@ -2589,7 +2483,6 @@ void VisualScriptEditor::reload_text() {
}
String VisualScriptEditor::get_name() {
-
String name;
if (script->get_path().find("local://") == -1 && script->get_path().find("::") == -1) {
@@ -2606,17 +2499,14 @@ String VisualScriptEditor::get_name() {
}
Ref<Texture2D> VisualScriptEditor::get_theme_icon() {
-
return Control::get_theme_icon("VisualScript", "EditorIcons");
}
bool VisualScriptEditor::is_unsaved() {
-
return script->is_edited() || script->are_subnodes_edited();
}
Variant VisualScriptEditor::get_edit_state() {
-
Dictionary d;
d["function"] = default_func;
d["scroll"] = graph->get_scroll_ofs();
@@ -2627,7 +2517,6 @@ Variant VisualScriptEditor::get_edit_state() {
}
void VisualScriptEditor::set_edit_state(const Variant &p_state) {
-
Dictionary d = p_state;
if (d.has("function")) {
selected = default_func;
@@ -2651,7 +2540,6 @@ void VisualScriptEditor::set_edit_state(const Variant &p_state) {
}
void VisualScriptEditor::_center_on_node(const StringName &p_func, int p_id) {
-
Node *n = graph->get_node(itos(p_id));
GraphNode *gn = Object::cast_to<GraphNode>(n);
@@ -2672,7 +2560,6 @@ void VisualScriptEditor::_center_on_node(const StringName &p_func, int p_id) {
}
void VisualScriptEditor::goto_line(int p_line, bool p_with_error) {
-
p_line += 1; //add one because script lines begin from 0.
if (p_with_error)
@@ -2681,9 +2568,7 @@ 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()) {
-
if (script->has_node(E->get(), p_line)) {
-
_update_graph();
_update_members();
@@ -2714,7 +2599,6 @@ void VisualScriptEditor::convert_indent_to_tabs() {
}
void VisualScriptEditor::ensure_focus() {
-
graph->grab_focus();
}
@@ -2726,15 +2610,12 @@ void VisualScriptEditor::reload(bool p_soft) {
}
void VisualScriptEditor::get_breakpoints(List<int> *p_breakpoints) {
-
List<StringName> functions;
script->get_function_list(&functions);
for (List<StringName>::Element *E = functions.front(); E; E = E->next()) {
-
List<int> nodes;
script->get_node_list(E->get(), &nodes);
for (List<int>::Element *F = nodes.front(); F; F = F->next()) {
-
Ref<VisualScriptNode> vsn = script->get_node(E->get(), F->get());
if (vsn->is_breakpoint()) {
p_breakpoints->push_back(F->get() - 1); //subtract 1 because breakpoints in text start from zero
@@ -2744,7 +2625,6 @@ void VisualScriptEditor::get_breakpoints(List<int> *p_breakpoints) {
}
void VisualScriptEditor::add_callback(const String &p_function, PackedStringArray p_args) {
-
if (script->has_function(p_function)) {
_update_members();
_update_graph();
@@ -2755,7 +2635,6 @@ void VisualScriptEditor::add_callback(const String &p_function, PackedStringArra
Ref<VisualScriptFunction> func;
func.instance();
for (int i = 0; i < p_args.size(); i++) {
-
String name = p_args[i];
Variant::Type type = Variant::NIL;
@@ -2763,7 +2642,6 @@ void VisualScriptEditor::add_callback(const String &p_function, PackedStringArra
String tt = name.get_slice(":", 1);
name = name.get_slice(":", 0);
for (int j = 0; j < Variant::VARIANT_MAX; j++) {
-
String tname = Variant::get_type_name(Variant::Type(j));
if (tname == tt) {
type = Variant::Type(j);
@@ -2790,7 +2668,6 @@ bool VisualScriptEditor::show_members_overview() {
}
void VisualScriptEditor::update_settings() {
-
_update_graph();
}
@@ -2805,12 +2682,10 @@ void VisualScriptEditor::set_tooltip_request_func(String p_method, Object *p_obj
}
Control *VisualScriptEditor::get_edit_menu() {
-
return edit_menu;
}
void VisualScriptEditor::_change_base_type() {
-
select_base_type->popup_create(true, true);
}
@@ -2824,7 +2699,6 @@ void VisualScriptEditor::clear_edit_menu() {
}
void VisualScriptEditor::_change_base_type_callback() {
-
String bt = select_base_type->get_selected_type();
ERR_FAIL_COND(bt == String());
@@ -2837,7 +2711,6 @@ void VisualScriptEditor::_change_base_type_callback() {
}
void VisualScriptEditor::_node_selected(Node *p_node) {
-
Ref<VisualScriptNode> vnode = p_node->get_meta("__vnode");
if (vnode.is_null())
return;
@@ -2846,7 +2719,6 @@ void VisualScriptEditor::_node_selected(Node *p_node) {
}
static bool _get_out_slot(const Ref<VisualScriptNode> &p_node, int p_slot, int &r_real_slot, bool &r_sequence) {
-
if (p_slot < p_node->get_output_sequence_port_count()) {
r_sequence = true;
r_real_slot = p_slot;
@@ -2861,7 +2733,6 @@ static bool _get_out_slot(const Ref<VisualScriptNode> &p_node, int p_slot, int &
}
static bool _get_in_slot(const Ref<VisualScriptNode> &p_node, int p_slot, int &r_real_slot, bool &r_sequence) {
-
if (p_slot == 0 && p_node->has_input_sequence_port()) {
r_sequence = true;
r_real_slot = 0;
@@ -2875,17 +2746,14 @@ static bool _get_in_slot(const Ref<VisualScriptNode> &p_node, int p_slot, int &r
}
void VisualScriptEditor::_begin_node_move() {
-
undo_redo->create_action(TTR("Move Node(s)"));
}
void VisualScriptEditor::_end_node_move() {
-
undo_redo->commit_action();
}
void VisualScriptEditor::_move_node(const StringName &p_func, int p_id, const Vector2 &p_to) {
-
if (!script->has_function(p_func))
return;
@@ -2898,7 +2766,6 @@ void VisualScriptEditor::_move_node(const StringName &p_func, int p_id, const Ve
}
StringName VisualScriptEditor::_get_function_of_node(int p_id) const {
-
List<StringName> funcs;
script->get_function_list(&funcs);
for (List<StringName>::Element *E = funcs.front(); E; E = E->next()) {
@@ -2911,7 +2778,6 @@ StringName VisualScriptEditor::_get_function_of_node(int p_id) const {
}
void VisualScriptEditor::_node_moved(Vector2 p_from, Vector2 p_to, int p_id) {
-
StringName func = _get_function_of_node(p_id);
undo_redo->add_do_method(this, "_move_node", func, p_id, p_to);
@@ -2919,7 +2785,6 @@ void VisualScriptEditor::_node_moved(Vector2 p_from, Vector2 p_to, int p_id) {
}
void VisualScriptEditor::_remove_node(int p_id) {
-
undo_redo->create_action(TTR("Remove VisualScript Node"));
StringName func = _get_function_of_node(p_id);
@@ -2931,7 +2796,6 @@ void VisualScriptEditor::_remove_node(int p_id) {
script->get_sequence_connection_list(func, &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", func, E->get().from_node, E->get().from_output, E->get().to_node);
}
@@ -2941,7 +2805,6 @@ void VisualScriptEditor::_remove_node(int p_id) {
script->get_data_connection_list(func, &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", func, E->get().from_node, E->get().from_port, E->get().to_node, E->get().to_port);
}
@@ -2954,7 +2817,6 @@ void VisualScriptEditor::_remove_node(int p_id) {
}
void VisualScriptEditor::_node_ports_changed(const String &p_func, int p_id) {
-
_update_graph(p_id);
}
@@ -2974,7 +2836,6 @@ bool VisualScriptEditor::node_has_sequence_connections(const StringName &p_func,
}
void VisualScriptEditor::_graph_connected(const String &p_from, int p_from_slot, const String &p_to, int p_to_slot) {
-
StringName from_func = _get_function_of_node(p_from.to_int());
Ref<VisualScriptNode> from_node = script->get_node(from_func, p_from.to_int());
@@ -3172,7 +3033,6 @@ void VisualScriptEditor::_graph_connected(const String &p_from, int p_from_slot,
}
void VisualScriptEditor::_graph_disconnected(const String &p_from, int p_from_slot, const String &p_to, int p_to_slot) {
-
StringName func = _get_function_of_node(p_from.to_int());
ERR_FAIL_COND(func != _get_function_of_node(p_to.to_int()));
@@ -3202,7 +3062,6 @@ void VisualScriptEditor::_graph_disconnected(const String &p_from, int p_from_sl
undo_redo->add_do_method(script.ptr(), "sequence_disconnect", func, p_from.to_int(), from_port, p_to.to_int());
undo_redo->add_undo_method(script.ptr(), "sequence_connect", func, p_from.to_int(), from_port, p_to.to_int());
} else {
-
can_swap = true;
data_disconnect_node = p_to.to_int();
data_disconnect_port = to_port;
@@ -3222,7 +3081,6 @@ void VisualScriptEditor::_graph_disconnected(const String &p_from, int p_from_sl
}
void VisualScriptEditor::_move_nodes_with_rescan(const StringName &p_func_from, const StringName &p_func_to, int p_id) {
-
Set<int> nodes_to_move;
HashMap<int, Map<int, int>> seqconns_to_move; // from => List(outp, to)
HashMap<int, Map<int, Pair<int, int>>> dataconns_to_move; // to => List(inp_p => from, outp)
@@ -3432,7 +3290,6 @@ void VisualScriptEditor::_move_nodes_with_rescan(const StringName &p_func_from,
}
void VisualScriptEditor::_graph_connect_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_pos) {
-
Node *node = graph->get_node(p_from);
GraphNode *gn = Object::cast_to<GraphNode>(node);
if (!gn)
@@ -3447,7 +3304,6 @@ void VisualScriptEditor::_graph_connect_to_empty(const String &p_from, int p_fro
port_action_pos = p_release_pos;
if (p_from_slot < vsn->get_output_sequence_port_count()) {
-
port_action_node = p_from.to_int();
port_action_output = p_from_slot;
_port_action_menu(CREATE_ACTION, func);
@@ -3459,7 +3315,6 @@ void VisualScriptEditor::_graph_connect_to_empty(const String &p_from, int p_fro
}
VisualScriptNode::TypeGuess VisualScriptEditor::_guess_output_type(int p_port_action_node, int p_port_action_output, Set<int> &visited_nodes) {
-
VisualScriptNode::TypeGuess tg;
tg.type = Variant::NIL;
@@ -3473,7 +3328,6 @@ VisualScriptNode::TypeGuess VisualScriptEditor::_guess_output_type(int p_port_ac
Ref<VisualScriptNode> node = script->get_node(func, p_port_action_node);
if (!node.is_valid()) {
-
return tg;
}
@@ -3490,16 +3344,13 @@ VisualScriptNode::TypeGuess VisualScriptEditor::_guess_output_type(int p_port_ac
int from_port;
if (script->get_input_value_port_connection_source(func, p_port_action_node, i, &from_node, &from_port)) {
-
g = _guess_output_type(from_node, from_port, visited_nodes);
} else {
Variant defval = node->get_default_input_value(i);
if (defval.get_type() == Variant::OBJECT) {
-
Object *obj = defval;
if (obj) {
-
g.type = Variant::OBJECT;
g.gdclass = obj->get_class();
g.script = obj->get_script();
@@ -3515,7 +3366,6 @@ VisualScriptNode::TypeGuess VisualScriptEditor::_guess_output_type(int p_port_ac
}
void VisualScriptEditor::_port_action_menu(int p_option, const StringName &func) {
-
Vector2 ofs = graph->get_scroll_ofs() + port_action_pos;
if (graph->is_using_snap()) {
int snap = graph->get_snap();
@@ -3526,7 +3376,6 @@ void VisualScriptEditor::_port_action_menu(int p_option, const StringName &func)
Set<int> vn;
switch (p_option) {
-
case CREATE_CALL_SET_GET: {
Ref<VisualScriptFunctionCall> n;
n.instance();
@@ -3590,7 +3439,6 @@ void VisualScriptEditor::_port_action_menu(int p_option, const StringName &func)
}
void VisualScriptEditor::connect_data(Ref<VisualScriptNode> vnode_old, Ref<VisualScriptNode> vnode, int new_id) {
-
undo_redo->create_action(TTR("Connect Node Data"));
VisualScriptReturn *vnode_return = Object::cast_to<VisualScriptReturn>(vnode.ptr());
if (vnode_return != nullptr && vnode_old->get_output_value_port_count() > 0) {
@@ -3616,7 +3464,6 @@ void VisualScriptEditor::connect_data(Ref<VisualScriptNode> vnode_old, Ref<Visua
}
void VisualScriptEditor::_selected_connect_node(const String &p_text, const String &p_category, const bool p_connecting) {
-
Vector2 ofs = graph->get_scroll_ofs() + port_action_pos;
if (graph->is_using_snap()) {
int snap = graph->get_snap();
@@ -3678,18 +3525,15 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
Ref<VisualScriptPropertySet> script_prop_set;
if (p_category == String("method")) {
-
Ref<VisualScriptFunctionCall> n;
n.instance();
vnode = n;
} else if (p_category == String("set")) {
-
Ref<VisualScriptPropertySet> n;
n.instance();
vnode = n;
script_prop_set = n;
} else if (p_category == String("get")) {
-
Ref<VisualScriptPropertyGet> n;
n.instance();
n->set_property(p_text);
@@ -3698,33 +3542,27 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
if (p_category == String("action")) {
if (p_text == "VisualScriptCondition") {
-
Ref<VisualScriptCondition> n;
n.instance();
vnode = n;
}
if (p_text == "VisualScriptSwitch") {
-
Ref<VisualScriptSwitch> n;
n.instance();
vnode = n;
} else if (p_text == "VisualScriptSequence") {
-
Ref<VisualScriptSequence> n;
n.instance();
vnode = n;
} else if (p_text == "VisualScriptIterator") {
-
Ref<VisualScriptIterator> n;
n.instance();
vnode = n;
} else if (p_text == "VisualScriptWhile") {
-
Ref<VisualScriptWhile> n;
n.instance();
vnode = n;
} else if (p_text == "VisualScriptReturn") {
-
Ref<VisualScriptReturn> n;
n.instance();
vnode = n;
@@ -3747,7 +3585,6 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
Ref<VisualScriptNode> vsn = script->get_node(func, port_action_new_node);
if (Object::cast_to<VisualScriptFunctionCall>(vsn.ptr())) {
-
Ref<VisualScriptFunctionCall> vsfc = vsn;
vsfc->set_function(p_text);
@@ -3857,7 +3694,6 @@ void VisualScriptEditor::_selected_connect_node(const String &p_text, const Stri
}
void VisualScriptEditor::connect_seq(Ref<VisualScriptNode> vnode_old, Ref<VisualScriptNode> vnode_new, int new_id) {
-
VisualScriptOperator *vnode_operator = Object::cast_to<VisualScriptOperator>(vnode_new.ptr());
if (vnode_operator != nullptr && !vnode_operator->has_input_sequence_port()) {
return;
@@ -3905,7 +3741,6 @@ void VisualScriptEditor::connect_seq(Ref<VisualScriptNode> vnode_old, Ref<Visual
}
void VisualScriptEditor::_selected_new_virtual_method(const String &p_text, const String &p_category, const bool p_connecting) {
-
String name = p_text;
if (script->has_function(name)) {
EditorNode::get_singleton()->show_warning(vformat(TTR("Script already has function '%s'"), name));
@@ -3968,7 +3803,6 @@ void VisualScriptEditor::_cancel_connect_node() {
}
int VisualScriptEditor::_create_new_node_from_name(const String &p_text, const Vector2 &p_point, const StringName &p_func) {
-
StringName func = default_func;
if (p_func != StringName())
func = p_func;
@@ -3985,7 +3819,6 @@ int VisualScriptEditor::_create_new_node_from_name(const String &p_text, const V
}
void VisualScriptEditor::_default_value_changed() {
-
Ref<VisualScriptNode> vsn = script->get_node(_get_function_of_node(editing_id), editing_id);
if (vsn.is_null())
return;
@@ -4000,7 +3833,6 @@ void VisualScriptEditor::_default_value_changed() {
}
void VisualScriptEditor::_default_value_edited(Node *p_button, int p_id, int p_input_port) {
-
Ref<VisualScriptNode> vsn = script->get_node(_get_function_of_node(p_id), p_id);
if (vsn.is_null())
return;
@@ -4008,7 +3840,6 @@ void VisualScriptEditor::_default_value_edited(Node *p_button, int p_id, int p_i
PropertyInfo pinfo = vsn->get_input_value_port_info(p_input_port);
Variant existing = vsn->get_default_input_value(p_input_port);
if (pinfo.type != Variant::NIL && existing.get_type() != pinfo.type) {
-
Callable::CallError ce;
const Variant *existingp = &existing;
existing = Variant::construct(pinfo.type, &existingp, 1, ce, false);
@@ -4018,7 +3849,6 @@ void VisualScriptEditor::_default_value_edited(Node *p_button, int p_id, int p_i
default_value_edit->set_size(Size2(1, 1));
if (pinfo.type == Variant::NODE_PATH) {
-
Node *edited_scene = get_tree()->get_edited_scene_root();
if (edited_scene) { // Fixing an old crash bug ( Visual Script Crashes on editing NodePath with an empty scene open)
Node *script_node = _find_script_node(edited_scene, edited_scene, script);
@@ -4047,19 +3877,16 @@ void VisualScriptEditor::_default_value_edited(Node *p_button, int p_id, int p_i
}
void VisualScriptEditor::_show_hint(const String &p_hint) {
-
hint_text->set_text(p_hint);
hint_text->show();
hint_text_timer->start();
}
void VisualScriptEditor::_hide_timer() {
-
hint_text->hide();
}
void VisualScriptEditor::_notification(int p_what) {
-
switch (p_what) {
case NOTIFICATION_READY: {
variable_editor->connect("changed", callable_mp(this, &VisualScriptEditor::_update_members));
@@ -4122,7 +3949,6 @@ void VisualScriptEditor::_notification(int p_what) {
}
void VisualScriptEditor::_graph_ofs_changed(const Vector2 &p_ofs) {
-
if (updating_graph || !script.is_valid())
return;
@@ -4137,7 +3963,6 @@ void VisualScriptEditor::_graph_ofs_changed(const Vector2 &p_ofs) {
}
void VisualScriptEditor::_comment_node_resized(const Vector2 &p_new_size, int p_node) {
-
if (updating_graph)
return;
@@ -4168,13 +3993,11 @@ void VisualScriptEditor::_comment_node_resized(const Vector2 &p_new_size, int p_
}
void VisualScriptEditor::_menu_option(int p_what) {
-
switch (p_what) {
case EDIT_DELETE_NODES: {
_on_nodes_delete();
} break;
case EDIT_TOGGLE_BREAKPOINT: {
-
List<String> reselect;
for (int i = 0; i < graph->get_child_count(); i++) {
GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
@@ -4216,7 +4039,6 @@ void VisualScriptEditor::_menu_option(int p_what) {
GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
if (gn) {
if (gn->is_selected()) {
-
int id = String(gn->get_name()).to_int();
StringName func = _get_function_of_node(id);
Ref<VisualScriptNode> node = script->get_node(func, id);
@@ -4242,9 +4064,7 @@ void VisualScriptEditor::_menu_option(int p_what) {
script->get_sequence_connection_list(F->get(), &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());
}
}
@@ -4254,9 +4074,7 @@ void VisualScriptEditor::_menu_option(int p_what) {
script->get_data_connection_list(F->get(), &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());
}
}
@@ -4298,7 +4116,6 @@ void VisualScriptEditor::_menu_option(int p_what) {
}
for (Map<int, Ref<VisualScriptNode>>::Element *E = clipboard->nodes.front(); E; E = E->next()) {
-
Ref<VisualScriptNode> node = E->get()->duplicate();
int new_id = idc++;
@@ -4317,13 +4134,11 @@ void VisualScriptEditor::_menu_option(int p_what) {
}
for (Set<VisualScript::SequenceConnection>::Element *E = clipboard->sequence_connections.front(); E; E = E->next()) {
-
undo_redo->add_do_method(script.ptr(), "sequence_connect", default_func, remap[E->get().from_node], E->get().from_output, remap[E->get().to_node]);
undo_redo->add_undo_method(script.ptr(), "sequence_disconnect", default_func, remap[E->get().from_node], E->get().from_output, remap[E->get().to_node]);
}
for (Set<VisualScript::DataConnection>::Element *E = clipboard->data_connections.front(); E; E = E->next()) {
-
undo_redo->add_do_method(script.ptr(), "data_connect", default_func, remap[E->get().from_node], E->get().from_port, remap[E->get().to_node], E->get().to_port);
undo_redo->add_undo_method(script.ptr(), "data_disconnect", default_func, remap[E->get().from_node], E->get().from_port, remap[E->get().to_node], E->get().to_port);
}
@@ -4342,7 +4157,6 @@ void VisualScriptEditor::_menu_option(int p_what) {
}
} break;
case EDIT_CREATE_FUNCTION: {
-
StringName function = "";
Map<int, Ref<VisualScriptNode>> nodes;
Set<int> selections;
@@ -4614,7 +4428,6 @@ void VisualScriptEditor::_get_ends(int p_node, const List<VisualScript::Sequence
}
void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) {
-
TreeItem *ti = members->get_selected();
ERR_FAIL_COND(!ti);
@@ -4632,7 +4445,6 @@ void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) {
Ref<Texture2D> edit_icon = Control::get_theme_icon("Edit", "EditorIcons");
if (ti->get_parent() == root->get_children()) {
-
member_type = MEMBER_FUNCTION;
member_name = ti->get_text(0);
member_popup->add_icon_shortcut(edit_icon, ED_GET_SHORTCUT("visual_script_editor/edit_member"), MEMBER_EDIT);
@@ -4643,7 +4455,6 @@ void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) {
}
if (ti->get_parent() == root->get_children()->get_next()) {
-
member_type = MEMBER_VARIABLE;
member_name = ti->get_text(0);
member_popup->add_icon_shortcut(edit_icon, ED_GET_SHORTCUT("visual_script_editor/edit_member"), MEMBER_EDIT);
@@ -4654,7 +4465,6 @@ void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) {
}
if (ti->get_parent() == root->get_children()->get_next()->get_next()) {
-
member_type = MEMBER_SIGNAL;
member_name = ti->get_text(0);
member_popup->add_icon_shortcut(edit_icon, ED_GET_SHORTCUT("visual_script_editor/edit_member"), MEMBER_EDIT);
@@ -4666,10 +4476,8 @@ void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) {
}
void VisualScriptEditor::_member_option(int p_option) {
-
switch (member_type) {
case MEMBER_FUNCTION: {
-
if (p_option == MEMBER_REMOVE) {
//delete the function
String name = member_name;
@@ -4712,7 +4520,6 @@ void VisualScriptEditor::_member_option(int p_option) {
}
} break;
case MEMBER_VARIABLE: {
-
String name = member_name;
if (p_option == MEMBER_REMOVE) {
@@ -4760,7 +4567,6 @@ void VisualScriptEditor::set_syntax_highlighter(SyntaxHighlighter *p_highlighter
}
void VisualScriptEditor::_bind_methods() {
-
ClassDB::bind_method("_move_node", &VisualScriptEditor::_move_node);
ClassDB::bind_method("_update_graph", &VisualScriptEditor::_update_graph, DEFVAL(-1));
@@ -4783,7 +4589,6 @@ void VisualScriptEditor::_bind_methods() {
}
VisualScriptEditor::VisualScriptEditor() {
-
if (!clipboard) {
clipboard = memnew(Clipboard);
}
@@ -5015,14 +4820,12 @@ VisualScriptEditor::VisualScriptEditor() {
}
VisualScriptEditor::~VisualScriptEditor() {
-
undo_redo->clear_history(); // Avoid crashes.
memdelete(signal_editor);
memdelete(variable_editor);
}
static ScriptEditorBase *create_editor(const RES &p_resource) {
-
if (Object::cast_to<VisualScript>(*p_resource)) {
return memnew(VisualScriptEditor);
}
@@ -5038,7 +4841,6 @@ void VisualScriptEditor::free_clipboard() {
}
static void register_editor_callback() {
-
ScriptEditor::register_create_script_editor_function(create_editor);
ED_SHORTCUT("visual_script_editor/delete_selected", TTR("Delete Selected"), KEY_DELETE);
@@ -5053,13 +4855,11 @@ static void register_editor_callback() {
}
void VisualScriptEditor::register_editor() {
-
// Too early to register stuff here, request a callback.
EditorNode::add_plugin_init_callback(register_editor_callback);
}
Ref<VisualScriptNode> _VisualScriptEditor::create_node_custom(const String &p_name) {
-
Ref<VisualScriptCustomNode> node;
node.instance();
node->set_script(singleton->custom_nodes[p_name]);