diff options
author | Pieter-Jan Briers <pieterjan.briers@gmail.com> | 2018-04-30 01:28:31 +0200 |
---|---|---|
committer | Pieter-Jan Briers <pieterjan.briers@gmail.com> | 2018-04-30 01:28:31 +0200 |
commit | 8d9d847a1a66844ca7605ffb0189e3f9dcbdb112 (patch) | |
tree | 0db1e78dad8ef91e1a35cd0cd5c7dc7d469c6c21 /modules/visual_script | |
parent | 3bd3f41465a604caa4a826dbc53537435fb37933 (diff) |
Move things into the title bars of Visual Script nodes.
This is an attempt to make VS slightly nicer to use.
WiP.
Diffstat (limited to 'modules/visual_script')
-rw-r--r-- | modules/visual_script/visual_script.cpp | 4 | ||||
-rw-r--r-- | modules/visual_script/visual_script.h | 2 | ||||
-rw-r--r-- | modules/visual_script/visual_script_builtin_funcs.cpp | 4 | ||||
-rw-r--r-- | modules/visual_script/visual_script_builtin_funcs.h | 2 | ||||
-rw-r--r-- | modules/visual_script/visual_script_editor.cpp | 33 | ||||
-rw-r--r-- | modules/visual_script/visual_script_func_nodes.cpp | 32 | ||||
-rw-r--r-- | modules/visual_script/visual_script_func_nodes.h | 2 | ||||
-rw-r--r-- | modules/visual_script/visual_script_nodes.cpp | 28 | ||||
-rw-r--r-- | modules/visual_script/visual_script_nodes.h | 4 |
9 files changed, 51 insertions, 60 deletions
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index ef680547ca..7fd0062352 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 69bb522173..d9c539df09 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 7f0a42da82..73b6d702c1 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 f862d5c26f..3345762b9f 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 eb10c5e99f..824f63702c 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<VisualScriptExpression>(node.ptr())) { + bool has_gnode_text = false; + if (Object::cast_to<VisualScriptExpression>(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<VisualScriptComment>(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 187c9b0b9e..b7e7189ab4 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 0b30eae65a..3b522564d4 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 c5654a5a20..4ffaaba6f1 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 a581e81c8c..836fd5061f 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); |