Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move things into the title bars of Visual Script nodes. #18516

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions modules/visual_script/visual_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion modules/visual_script/visual_script.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class VisualScriptNode : public Resource {
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
Expand Down
4 changes: 3 additions & 1 deletion modules/visual_script/visual_script_builtin_funcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
2 changes: 1 addition & 1 deletion modules/visual_script/visual_script_builtin_funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class VisualScriptBuiltinFunc : public VisualScriptNode {
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);
Expand Down
33 changes: 26 additions & 7 deletions modules/visual_script/visual_script_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -543,18 +544,24 @@ 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);
line_edit->add_font_override("font", get_font("source", "EditorFonts"));
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())) {
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion modules/visual_script/visual_script_flow_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ PropertyInfo VisualScriptTypeCast::get_output_value_port_info(int p_idx) const {

String VisualScriptTypeCast::get_caption() const {

return "TypeCast";
return "Type Cast";
}

String VisualScriptTypeCast::get_text() const {
Expand Down
102 changes: 36 additions & 66 deletions modules/visual_script/visual_script_func_nodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -1075,36 +1063,31 @@ PropertyInfo VisualScriptPropertySet::get_output_value_port_info(int p_idx) cons

String VisualScriptPropertySet::get_caption() const {

static const char *cname[4] = {
"Self",
"Node",
"Instance",
"Basic"
};

static const char *opname[ASSIGN_OP_MAX] = {
"Set", "Add", "Sub", "Mul", "Div", "Mod", "ShiftLeft", "ShiftRight", "BitAnd", "BitOr", "BitXor"
"Set", "Add", "Subtract", "Multiply", "Divide", "Mod", "ShiftLeft", "ShiftRight", "BitAnd", "BitOr", "BitXor"
};
return String(cname[call_mode]) + opname[assign_op];

String prop = String(opname[assign_op]) + " " + property;
if (index != StringName()) {
prop += "." + String(index);
}

return prop;
}

String VisualScriptPropertySet::get_text() const {

String prop;
if (call_mode == CALL_MODE_BASIC_TYPE) {
return String("On ") + Variant::get_type_name(basic_type);
}

if (call_mode == CALL_MODE_BASIC_TYPE)
prop = Variant::get_type_name(basic_type) + "." + property;
else if (call_mode == CALL_MODE_NODE_PATH)
prop = String(base_path) + ":" + property;
else if (call_mode == CALL_MODE_SELF)
prop = property;
else if (call_mode == CALL_MODE_INSTANCE)
prop = String(base_type) + ":" + property;
static const char *cname[3] = {
"Self",
"Scene Node",
"Instance"
};

if (index != StringName()) {
prop += "." + String(index);
}
return prop;
return String("On ") + cname[call_mode];
}

void VisualScriptPropertySet::_update_base_type() {
Expand Down Expand Up @@ -1838,30 +1821,22 @@ PropertyInfo VisualScriptPropertyGet::get_output_value_port_info(int p_idx) cons

String VisualScriptPropertyGet::get_caption() const {

static const char *cname[4] = {
"SelfGet",
"NodeGet",
"InstanceGet",
"BasicGet"
};

return cname[call_mode];
return String("Get ") + property;
}

String VisualScriptPropertyGet::get_text() const {

String prop;
if (call_mode == CALL_MODE_BASIC_TYPE) {
return String("On ") + Variant::get_type_name(basic_type);
}

if (call_mode == CALL_MODE_BASIC_TYPE)
prop = Variant::get_type_name(basic_type) + "." + property;
else if (call_mode == CALL_MODE_NODE_PATH)
prop = String(base_path) + ":" + property;
else if (call_mode == CALL_MODE_SELF)
prop = property;
else if (call_mode == CALL_MODE_INSTANCE)
prop = String(base_type) + ":" + property;
static const char *cname[3] = {
"Self",
"Scene Node",
"Instance"
};

return prop;
return String("On ") + cname[call_mode];
}

void VisualScriptPropertyGet::set_base_type(const StringName &p_type) {
Expand Down Expand Up @@ -2399,12 +2374,7 @@ PropertyInfo VisualScriptEmitSignal::get_output_value_port_info(int p_idx) const

String VisualScriptEmitSignal::get_caption() const {

return "EmitSignal";
}

String VisualScriptEmitSignal::get_text() const {

return "emit " + String(name);
return "Emit " + String(name);
}

void VisualScriptEmitSignal::set_signal(const StringName &p_type) {
Expand Down
2 changes: 1 addition & 1 deletion modules/visual_script/visual_script_func_nodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ class VisualScriptEmitSignal : public VisualScriptNode {
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);
Expand Down
Loading