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; return default_input_values;
} }
String VisualScriptNode::get_text() const {
return "";
}
void VisualScriptNode::_bind_methods() { void VisualScriptNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_visual_script"), &VisualScriptNode::get_visual_script); 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; Variant get_default_input_value(int p_port) const;
virtual String get_caption() const = 0; virtual String get_caption() const = 0;
virtual String get_text() const = 0; virtual String get_text() const;
virtual String get_category() const = 0; virtual String get_category() const = 0;
//used by editor, this is not really saved //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, ""); return PropertyInfo(t, "");
} }
/*
String VisualScriptBuiltinFunc::get_caption() const { String VisualScriptBuiltinFunc::get_caption() const {
return "BuiltinFunc"; return "BuiltinFunc";
} }
*/
String VisualScriptBuiltinFunc::get_text() const { String VisualScriptBuiltinFunc::get_caption() const {
return func_name[func]; return func_name[func];
} }

View file

@ -129,7 +129,7 @@ public:
virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual PropertyInfo get_output_value_port_info(int p_idx) const;
virtual String get_caption() const; virtual String get_caption() const;
virtual String get_text() const; //virtual String get_text() const;
virtual String get_category() const { return "functions"; } virtual String get_category() const { return "functions"; }
void set_func(BuiltinFunc p_which); void set_func(BuiltinFunc p_which);

View file

@ -527,6 +527,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
GraphNode *gnode = memnew(GraphNode); GraphNode *gnode = memnew(GraphNode);
gnode->set_title(node->get_caption()); gnode->set_title(node->get_caption());
gnode->set_offset(pos * EDSCALE);
if (error_line == E->get()) { if (error_line == E->get()) {
gnode->set_overlay(GraphNode::OVERLAY_POSITION); gnode->set_overlay(GraphNode::OVERLAY_POSITION);
} else if (node->is_breakpoint()) { } else if (node->is_breakpoint()) {
@ -543,8 +544,10 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
gnode->set_show_close_button(true); 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); LineEdit *line_edit = memnew(LineEdit);
line_edit->set_text(node->get_text()); line_edit->set_text(node->get_text());
line_edit->set_expand_to_text_length(true); 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); gnode->add_child(line_edit);
line_edit->connect("text_changed", this, "_expression_text_changed", varray(E->get())); line_edit->connect("text_changed", this, "_expression_text_changed", varray(E->get()));
} else { } else {
Label *text = memnew(Label); String text = node->get_text();
text->set_text(node->get_text()); if (!text.empty()) {
gnode->add_child(text); has_gnode_text = true;
Label *label = memnew(Label);
label->set_text(text);
gnode->add_child(label);
}
} }
if (Object::cast_to<VisualScriptComment>(node.ptr())) { if (Object::cast_to<VisualScriptComment>(node.ptr())) {
@ -589,9 +596,21 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
int slot_idx = 0; int slot_idx = 0;
bool single_seq_output = node->get_output_sequence_port_count() == 1 && node->get_output_sequence_port_text(0) == String(); 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); if ((node->has_input_sequence_port() || single_seq_output) || has_gnode_text) {
gnode->set_offset(pos * EDSCALE); // IF has_gnode_text is true BUT we have no sequence ports to draw (in here),
slot_idx++; // 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; 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 { 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) if (call_mode == CALL_MODE_SELF)
return " " + String(function) + "()"; return " " + String(function) + "()";
if (call_mode == CALL_MODE_SINGLETON) if (call_mode == CALL_MODE_SINGLETON)
@ -294,6 +274,14 @@ String VisualScriptFunctionCall::get_text() const {
return " " + base_type + "." + String(function) + "()"; 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) { void VisualScriptFunctionCall::set_basic_type(Variant::Type p_type) {
if (basic_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(); return PropertyInfo();
} }
/*
String VisualScriptEmitSignal::get_caption() const { String VisualScriptEmitSignal::get_caption() const {
return "EmitSignal"; return "EmitSignal";
} }
*/
String VisualScriptEmitSignal::get_text() const { String VisualScriptEmitSignal::get_caption() const {
return "emit " + String(name); return "emit " + String(name);
} }

View file

@ -346,7 +346,7 @@ public:
virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual PropertyInfo get_output_value_port_info(int p_idx) const;
virtual String get_caption() const; virtual String get_caption() const;
virtual String get_text() const; //virtual String get_text() const;
virtual String get_category() const { return "functions"; } virtual String get_category() const { return "functions"; }
void set_signal(const StringName &p_type); 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 { String VisualScriptIndexGet::get_caption() const {
return "IndexGet"; return "Get Index";
}
String VisualScriptIndexGet::get_text() const {
return String("get");
} }
class VisualScriptNodeInstanceIndexGet : public VisualScriptNodeInstance { class VisualScriptNodeInstanceIndexGet : public VisualScriptNodeInstance {
@ -1371,12 +1366,7 @@ PropertyInfo VisualScriptIndexSet::get_output_value_port_info(int p_idx) const {
String VisualScriptIndexSet::get_caption() const { String VisualScriptIndexSet::get_caption() const {
return "IndexSet"; return "Set Index";
}
String VisualScriptIndexSet::get_text() const {
return String("set");
} }
class VisualScriptNodeInstanceIndexSet : public VisualScriptNodeInstance { class VisualScriptNodeInstanceIndexSet : public VisualScriptNodeInstance {
@ -3032,12 +3022,7 @@ PropertyInfo VisualScriptConstructor::get_output_value_port_info(int p_idx) cons
String VisualScriptConstructor::get_caption() const { String VisualScriptConstructor::get_caption() const {
return "Construct"; return "Construct " + Variant::get_type_name(type);
}
String VisualScriptConstructor::get_text() const {
return "new " + Variant::get_type_name(type) + "()";
} }
String VisualScriptConstructor::get_category() const { 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 { String VisualScriptDeconstruct::get_caption() const {
return "Deconstruct"; return "Deconstruct " + Variant::get_type_name(type);
}
String VisualScriptDeconstruct::get_text() const {
return "from " + Variant::get_type_name(type) + ":";
} }
String VisualScriptDeconstruct::get_category() const { String VisualScriptDeconstruct::get_category() const {

View file

@ -327,7 +327,6 @@ public:
virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual PropertyInfo get_output_value_port_info(int p_idx) const;
virtual String get_caption() const; virtual String get_caption() const;
virtual String get_text() const;
virtual String get_category() const { return "operators"; } virtual String get_category() const { return "operators"; }
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance); virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
@ -352,7 +351,6 @@ public:
virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual PropertyInfo get_output_value_port_info(int p_idx) const;
virtual String get_caption() const; virtual String get_caption() const;
virtual String get_text() const;
virtual String get_category() const { return "operators"; } virtual String get_category() const { return "operators"; }
virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance); virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
@ -822,7 +820,6 @@ public:
virtual PropertyInfo get_output_value_port_info(int p_idx) const; virtual PropertyInfo get_output_value_port_info(int p_idx) const;
virtual String get_caption() const; virtual String get_caption() const;
virtual String get_text() const;
virtual String get_category() const; virtual String get_category() const;
void set_constructor_type(Variant::Type p_type); 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 PropertyInfo get_output_value_port_info(int p_idx) const;
virtual String get_caption() const; virtual String get_caption() const;
virtual String get_text() const;
virtual String get_category() const; virtual String get_category() const;
void set_deconstruct_type(Variant::Type p_type); void set_deconstruct_type(Variant::Type p_type);