diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index ef680547ca4..7fd0062352f 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -121,6 +121,10 @@ Array VisualScriptNode::_get_default_input_values() const { return default_input_values; } +String VisualScriptNode::get_text() const { + return ""; +} + void VisualScriptNode::_bind_methods() { ClassDB::bind_method(D_METHOD("get_visual_script"), &VisualScriptNode::get_visual_script); diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h index 69bb5221732..d9c539df092 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -78,7 +78,7 @@ public: Variant get_default_input_value(int p_port) const; virtual String get_caption() const = 0; - virtual String get_text() const = 0; + virtual String get_text() const; virtual String get_category() const = 0; //used by editor, this is not really saved diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp index 7f0a42da82d..73b6d702c18 100644 --- a/modules/visual_script/visual_script_builtin_funcs.cpp +++ b/modules/visual_script/visual_script_builtin_funcs.cpp @@ -666,12 +666,14 @@ PropertyInfo VisualScriptBuiltinFunc::get_output_value_port_info(int p_idx) cons return PropertyInfo(t, ""); } +/* String VisualScriptBuiltinFunc::get_caption() const { return "BuiltinFunc"; } +*/ -String VisualScriptBuiltinFunc::get_text() const { +String VisualScriptBuiltinFunc::get_caption() const { return func_name[func]; } diff --git a/modules/visual_script/visual_script_builtin_funcs.h b/modules/visual_script/visual_script_builtin_funcs.h index f862d5c26f6..3345762b9f5 100644 --- a/modules/visual_script/visual_script_builtin_funcs.h +++ b/modules/visual_script/visual_script_builtin_funcs.h @@ -129,7 +129,7 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; + //virtual String get_text() const; virtual String get_category() const { return "functions"; } void set_func(BuiltinFunc p_which); diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index eb10c5e99f8..824f63702ca 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -527,6 +527,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) { GraphNode *gnode = memnew(GraphNode); gnode->set_title(node->get_caption()); + gnode->set_offset(pos * EDSCALE); if (error_line == E->get()) { gnode->set_overlay(GraphNode::OVERLAY_POSITION); } else if (node->is_breakpoint()) { @@ -543,8 +544,10 @@ void VisualScriptEditor::_update_graph(int p_only_id) { gnode->set_show_close_button(true); } - if (Object::cast_to(node.ptr())) { + bool has_gnode_text = false; + if (Object::cast_to(node.ptr())) { + has_gnode_text = true; LineEdit *line_edit = memnew(LineEdit); line_edit->set_text(node->get_text()); line_edit->set_expand_to_text_length(true); @@ -552,9 +555,13 @@ void VisualScriptEditor::_update_graph(int p_only_id) { gnode->add_child(line_edit); line_edit->connect("text_changed", this, "_expression_text_changed", varray(E->get())); } else { - Label *text = memnew(Label); - text->set_text(node->get_text()); - gnode->add_child(text); + String text = node->get_text(); + if (!text.empty()) { + has_gnode_text = true; + Label *label = memnew(Label); + label->set_text(text); + gnode->add_child(label); + } } if (Object::cast_to(node.ptr())) { @@ -589,9 +596,21 @@ void VisualScriptEditor::_update_graph(int p_only_id) { int slot_idx = 0; bool single_seq_output = node->get_output_sequence_port_count() == 1 && node->get_output_sequence_port_text(0) == String(); - gnode->set_slot(0, node->has_input_sequence_port(), TYPE_SEQUENCE, mono_color, single_seq_output, TYPE_SEQUENCE, mono_color, seq_port, seq_port); - gnode->set_offset(pos * EDSCALE); - slot_idx++; + if ((node->has_input_sequence_port() || single_seq_output) || has_gnode_text) { + // IF has_gnode_text is true BUT we have no sequence ports to draw (in here), + // we still draw the disabled default ones to shift up the slots by one, + // so the slots DON'T start with the content text. + + // IF has_gnode_text is false, but we DO want to draw default sequence ports, + // we draw a dummy text to take up the position of the sequence nodes, so all the other ports are still aligned correctly. + if (!has_gnode_text) { + Label *dummy = memnew(Label); + dummy->set_text(" "); + gnode->add_child(dummy); + } + gnode->set_slot(0, node->has_input_sequence_port(), TYPE_SEQUENCE, mono_color, single_seq_output, TYPE_SEQUENCE, mono_color, seq_port, seq_port); + slot_idx++; + } int mixed_seq_ports = 0; diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp index 187c9b0b9ea..b7e7189ab46 100644 --- a/modules/visual_script/visual_script_func_nodes.cpp +++ b/modules/visual_script/visual_script_func_nodes.cpp @@ -262,26 +262,6 @@ PropertyInfo VisualScriptFunctionCall::get_output_value_port_info(int p_idx) con } String VisualScriptFunctionCall::get_caption() const { - - static const char *cname[5] = { - "CallSelf", - "CallNode", - "CallInstance", - "CallBasic", - "CallSingleton" - }; - - String caption = cname[call_mode]; - - if (rpc_call_mode) { - caption += " (RPC)"; - } - - return caption; -} - -String VisualScriptFunctionCall::get_text() const { - if (call_mode == CALL_MODE_SELF) return " " + String(function) + "()"; if (call_mode == CALL_MODE_SINGLETON) @@ -294,6 +274,14 @@ String VisualScriptFunctionCall::get_text() const { return " " + base_type + "." + String(function) + "()"; } +String VisualScriptFunctionCall::get_text() const { + + if (rpc_call_mode) { + return "RPC"; + } + return ""; +} + void VisualScriptFunctionCall::set_basic_type(Variant::Type p_type) { if (basic_type == p_type) @@ -2397,12 +2385,14 @@ PropertyInfo VisualScriptEmitSignal::get_output_value_port_info(int p_idx) const return PropertyInfo(); } +/* String VisualScriptEmitSignal::get_caption() const { return "EmitSignal"; } +*/ -String VisualScriptEmitSignal::get_text() const { +String VisualScriptEmitSignal::get_caption() const { return "emit " + String(name); } diff --git a/modules/visual_script/visual_script_func_nodes.h b/modules/visual_script/visual_script_func_nodes.h index 0b30eae65a7..3b522564d40 100644 --- a/modules/visual_script/visual_script_func_nodes.h +++ b/modules/visual_script/visual_script_func_nodes.h @@ -346,7 +346,7 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; + //virtual String get_text() const; virtual String get_category() const { return "functions"; } void set_signal(const StringName &p_type); diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index c5654a5a20c..4ffaaba6f11 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -1291,12 +1291,7 @@ PropertyInfo VisualScriptIndexGet::get_output_value_port_info(int p_idx) const { String VisualScriptIndexGet::get_caption() const { - return "IndexGet"; -} - -String VisualScriptIndexGet::get_text() const { - - return String("get"); + return "Get Index"; } class VisualScriptNodeInstanceIndexGet : public VisualScriptNodeInstance { @@ -1371,12 +1366,7 @@ PropertyInfo VisualScriptIndexSet::get_output_value_port_info(int p_idx) const { String VisualScriptIndexSet::get_caption() const { - return "IndexSet"; -} - -String VisualScriptIndexSet::get_text() const { - - return String("set"); + return "Set Index"; } class VisualScriptNodeInstanceIndexSet : public VisualScriptNodeInstance { @@ -3032,12 +3022,7 @@ PropertyInfo VisualScriptConstructor::get_output_value_port_info(int p_idx) cons String VisualScriptConstructor::get_caption() const { - return "Construct"; -} - -String VisualScriptConstructor::get_text() const { - - return "new " + Variant::get_type_name(type) + "()"; + return "Construct " + Variant::get_type_name(type); } String VisualScriptConstructor::get_category() const { @@ -3600,12 +3585,7 @@ PropertyInfo VisualScriptDeconstruct::get_output_value_port_info(int p_idx) cons String VisualScriptDeconstruct::get_caption() const { - return "Deconstruct"; -} - -String VisualScriptDeconstruct::get_text() const { - - return "from " + Variant::get_type_name(type) + ":"; + return "Deconstruct " + Variant::get_type_name(type); } String VisualScriptDeconstruct::get_category() const { diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h index a581e81c8c0..836fd5061f1 100644 --- a/modules/visual_script/visual_script_nodes.h +++ b/modules/visual_script/visual_script_nodes.h @@ -327,7 +327,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const { return "operators"; } virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance); @@ -352,7 +351,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const { return "operators"; } virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance); @@ -822,7 +820,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const; void set_constructor_type(Variant::Type p_type); @@ -993,7 +990,6 @@ public: virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual String get_caption() const; - virtual String get_text() const; virtual String get_category() const; void set_deconstruct_type(Variant::Type p_type);