本文整理汇总了C++中GraphNode::set_name方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphNode::set_name方法的具体用法?C++ GraphNode::set_name怎么用?C++ GraphNode::set_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphNode
的用法示例。
在下文中一共展示了GraphNode::set_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _node_renamed
void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<AnimationNode> p_node) {
String prev_name = blend_tree->get_node_name(p_node);
ERR_FAIL_COND(prev_name == String());
GraphNode *gn = Object::cast_to<GraphNode>(graph->get_node(prev_name));
ERR_FAIL_COND(!gn);
String new_name = p_text;
ERR_FAIL_COND(new_name == "" || new_name.find(".") != -1 || new_name.find("/") != -1)
ERR_FAIL_COND(new_name == prev_name);
String base_name = new_name;
int base = 1;
String name = base_name;
while (blend_tree->has_node(name)) {
base++;
name = base_name + " " + itos(base);
}
updating = true;
undo_redo->create_action("Node Renamed");
undo_redo->add_do_method(blend_tree.ptr(), "rename_node", prev_name, name);
undo_redo->add_undo_method(blend_tree.ptr(), "rename_node", name, prev_name);
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
undo_redo->commit_action();
updating = false;
gn->set_name(new_name);
gn->set_size(gn->get_minimum_size());
}
示例2: _update_graph
void VisualShaderEditor::_update_graph() {
if (updating)
return;
if (visual_shader.is_null())
return;
graph->set_scroll_ofs(visual_shader->get_graph_offset() * EDSCALE);
VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
graph->clear_connections();
//erase all nodes
for (int i = 0; i < graph->get_child_count(); i++) {
if (Object::cast_to<GraphNode>(graph->get_child(i))) {
memdelete(graph->get_child(i));
i--;
}
}
static const Color type_color[3] = {
Color::html("#61daf4"),
Color::html("#d67dee"),
Color::html("#f6a86e")
};
List<VisualShader::Connection> connections;
visual_shader->get_node_connections(type, &connections);
Ref<StyleBoxEmpty> label_style = make_empty_stylebox(2, 1, 2, 1);
Vector<int> nodes = visual_shader->get_node_list(type);
for (int n_i = 0; n_i < nodes.size(); n_i++) {
Vector2 position = visual_shader->get_node_position(type, nodes[n_i]);
Ref<VisualShaderNode> vsnode = visual_shader->get_node(type, nodes[n_i]);
GraphNode *node = memnew(GraphNode);
graph->add_child(node);
/*if (!vsnode->is_connected("changed", this, "_node_changed")) {
vsnode->connect("changed", this, "_node_changed", varray(vsnode->get_instance_id()), CONNECT_DEFERRED);
}*/
node->set_offset(position);
node->set_title(vsnode->get_caption());
node->set_name(itos(nodes[n_i]));
if (nodes[n_i] >= 2) {
node->set_show_close_button(true);
node->connect("close_request", this, "_delete_request", varray(nodes[n_i]), CONNECT_DEFERRED);
}
node->connect("dragged", this, "_node_dragged", varray(nodes[n_i]));
Control *custom_editor = NULL;
int port_offset = 0;
Ref<VisualShaderNodeUniform> uniform = vsnode;
if (uniform.is_valid()) {
LineEdit *uniform_name = memnew(LineEdit);
uniform_name->set_text(uniform->get_uniform_name());
node->add_child(uniform_name);
uniform_name->connect("text_entered", this, "_line_edit_changed", varray(uniform_name, nodes[n_i]));
uniform_name->connect("focus_exited", this, "_line_edit_focus_out", varray(uniform_name, nodes[n_i]));
if (vsnode->get_input_port_count() == 0 && vsnode->get_output_port_count() == 1 && vsnode->get_output_port_name(0) == "") {
//shortcut
VisualShaderNode::PortType port_right = vsnode->get_output_port_type(0);
node->set_slot(0, false, VisualShaderNode::PORT_TYPE_SCALAR, Color(), true, port_right, type_color[port_right]);
continue;
}
port_offset++;
}
for (int i = 0; i < plugins.size(); i++) {
custom_editor = plugins.write[i]->create_editor(vsnode);
if (custom_editor) {
break;
}
}
if (custom_editor && vsnode->get_output_port_count() > 0 && vsnode->get_output_port_name(0) == "" && (vsnode->get_input_port_count() == 0 || vsnode->get_input_port_name(0) == "")) {
//will be embedded in first port
} else if (custom_editor) {
port_offset++;
node->add_child(custom_editor);
custom_editor = NULL;
}
for (int i = 0; i < MAX(vsnode->get_input_port_count(), vsnode->get_output_port_count()); i++) {
if (vsnode->is_port_separator(i)) {
node->add_child(memnew(HSeparator));
port_offset++;
}
//.........这里部分代码省略.........
示例3: _update_graph
void AnimationNodeBlendTreeEditor::_update_graph() {
if (updating)
return;
graph->set_scroll_ofs(blend_tree->get_graph_offset() * EDSCALE);
if (blend_tree->get_parent().is_valid()) {
goto_parent->show();
} else {
goto_parent->hide();
}
graph->clear_connections();
//erase all nodes
for (int i = 0; i < graph->get_child_count(); i++) {
if (Object::cast_to<GraphNode>(graph->get_child(i))) {
memdelete(graph->get_child(i));
i--;
}
}
animations.clear();
List<StringName> nodes;
blend_tree->get_node_list(&nodes);
for (List<StringName>::Element *E = nodes.front(); E; E = E->next()) {
GraphNode *node = memnew(GraphNode);
graph->add_child(node);
Ref<AnimationNode> agnode = blend_tree->get_node(E->get());
if (!agnode->is_connected("changed", this, "_node_changed")) {
agnode->connect("changed", this, "_node_changed", varray(agnode->get_instance_id()), CONNECT_DEFERRED);
}
node->set_offset(agnode->get_position() * EDSCALE);
node->set_title(agnode->get_caption());
node->set_name(E->get());
int base = 0;
if (String(E->get()) != "output") {
LineEdit *name = memnew(LineEdit);
name->set_text(E->get());
name->set_expand_to_text_length(true);
node->add_child(name);
node->set_slot(0, false, 0, Color(), true, 0, get_color("font_color", "Label"));
name->connect("text_entered", this, "_node_renamed", varray(agnode));
name->connect("focus_exited", this, "_node_renamed_focus_out", varray(name, agnode));
base = 1;
node->set_show_close_button(true);
node->connect("close_request", this, "_delete_request", varray(E->get()), CONNECT_DEFERRED);
}
for (int i = 0; i < agnode->get_input_count(); i++) {
Label *in_name = memnew(Label);
node->add_child(in_name);
in_name->set_text(agnode->get_input_name(i));
node->set_slot(base + i, true, 0, get_color("font_color", "Label"), false, 0, Color());
}
node->connect("dragged", this, "_node_dragged", varray(agnode));
if (EditorNode::get_singleton()->item_has_editor(agnode.ptr())) {
node->add_child(memnew(HSeparator));
Button *open_in_editor = memnew(Button);
open_in_editor->set_text(TTR("Open Editor"));
open_in_editor->set_icon(get_icon("Edit", "EditorIcons"));
node->add_child(open_in_editor);
open_in_editor->connect("pressed", this, "_open_in_editor", varray(E->get()), CONNECT_DEFERRED);
open_in_editor->set_h_size_flags(SIZE_SHRINK_CENTER);
}
if (agnode->has_filter()) {
node->add_child(memnew(HSeparator));
Button *edit_filters = memnew(Button);
edit_filters->set_text(TTR("Edit Filters"));
edit_filters->set_icon(get_icon("AnimationFilter", "EditorIcons"));
node->add_child(edit_filters);
edit_filters->connect("pressed", this, "_edit_filters", varray(E->get()), CONNECT_DEFERRED);
edit_filters->set_h_size_flags(SIZE_SHRINK_CENTER);
}
Ref<AnimationNodeAnimation> anim = agnode;
if (anim.is_valid()) {
MenuButton *mb = memnew(MenuButton);
mb->set_text(anim->get_animation());
mb->set_icon(get_icon("Animation", "EditorIcons"));
Array options;
node->add_child(memnew(HSeparator));
node->add_child(mb);
ProgressBar *pb = memnew(ProgressBar);
//.........这里部分代码省略.........