Move things into the title bars of Visual Script nodes.

This is an attempt to make VS slightly nicer to use.

WiP.
This commit is contained in:
Pieter-Jan Briers 2018-04-30 01:28:31 +02:00
parent 3bd3f41465
commit 8d9d847a1a
9 changed files with 51 additions and 60 deletions

View file

@ -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);

View file

@ -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

View file

@ -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];
}

View file

@ -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);

View file

@ -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;

View file

@ -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);
}

View file

@ -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);

View file

@ -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 {

View file

@ -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);