void VisualShaderEditor::remove_custom_type(const Ref<Script> &p_script) { for (int i = 0; i < add_options.size(); i++) { if (add_options[i].script == p_script) { add_options.remove(i); return; } } _update_options_menu(); }
void AnimationNodeBlendTreeEditor::remove_custom_type(const Ref<Script> &p_script) { for (int i = 0; i < add_options.size(); i++) { if (add_options[i].script == p_script) { add_options.remove(i); return; } } _update_options_menu(); }
void AnimationNodeBlendTreeEditor::add_custom_type(const String &p_name, const Ref<Script> &p_script) { for (int i = 0; i < add_options.size(); i++) { ERR_FAIL_COND(add_options[i].script == p_script); } AddOption ao; ao.name = p_name; ao.script = p_script; add_options.push_back(ao); _update_options_menu(); }
void VisualShaderEditor::add_custom_type(const String &p_name, const String &p_category, const Ref<Script> &p_script) { for (int i = 0; i < add_options.size(); i++) { ERR_FAIL_COND(add_options[i].script == p_script); } AddOption ao; ao.name = p_name; ao.script = p_script; ao.category = p_category; add_options.push_back(ao); _update_options_menu(); }
VisualShaderEditor::VisualShaderEditor() { singleton = this; updating = false; graph = memnew(GraphEdit); add_child(graph); graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_SCALAR); graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_VECTOR); graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_TRANSFORM); //graph->add_valid_left_disconnect_type(0); graph->set_v_size_flags(SIZE_EXPAND_FILL); graph->connect("connection_request", this, "_connection_request", varray(), CONNECT_DEFERRED); graph->connect("disconnection_request", this, "_disconnection_request", varray(), CONNECT_DEFERRED); graph->connect("node_selected", this, "_node_selected"); graph->connect("scroll_offset_changed", this, "_scroll_changed"); graph->connect("duplicate_nodes_request", this, "_duplicate_nodes"); graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_SCALAR); graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_VECTOR); graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_VECTOR, VisualShaderNode::PORT_TYPE_SCALAR); graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_VECTOR, VisualShaderNode::PORT_TYPE_VECTOR); graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShaderNode::PORT_TYPE_TRANSFORM); VSeparator *vs = memnew(VSeparator); graph->get_zoom_hbox()->add_child(vs); graph->get_zoom_hbox()->move_child(vs, 0); edit_type = memnew(OptionButton); edit_type->add_item(TTR("Vertex")); edit_type->add_item(TTR("Fragment")); edit_type->add_item(TTR("Light")); edit_type->select(1); edit_type->connect("item_selected", this, "_mode_selected"); graph->get_zoom_hbox()->add_child(edit_type); graph->get_zoom_hbox()->move_child(edit_type, 0); add_node = memnew(MenuButton); graph->get_zoom_hbox()->add_child(add_node); add_node->set_text(TTR("Add Node...")); graph->get_zoom_hbox()->move_child(add_node, 0); add_node->get_popup()->connect("id_pressed", this, "_add_node"); add_options.push_back(AddOption("Scalar", "Constants", "VisualShaderNodeScalarConstant")); add_options.push_back(AddOption("Vector", "Constants", "VisualShaderNodeVec3Constant")); add_options.push_back(AddOption("Color", "Constants", "VisualShaderNodeColorConstant")); add_options.push_back(AddOption("Transform", "Constants", "VisualShaderNodeTransformConstant")); add_options.push_back(AddOption("Texture", "Constants", "VisualShaderNodeTexture")); add_options.push_back(AddOption("CubeMap", "Constants", "VisualShaderNodeCubeMap")); add_options.push_back(AddOption("ScalarOp", "Operators", "VisualShaderNodeScalarOp")); add_options.push_back(AddOption("VectorOp", "Operators", "VisualShaderNodeVectorOp")); add_options.push_back(AddOption("ColorOp", "Operators", "VisualShaderNodeColorOp")); add_options.push_back(AddOption("TransformMult", "Operators", "VisualShaderNodeTransformMult")); add_options.push_back(AddOption("TransformVectorMult", "Operators", "VisualShaderNodeTransformVecMult")); add_options.push_back(AddOption("ScalarFunc", "Functions", "VisualShaderNodeScalarFunc")); add_options.push_back(AddOption("VectorFunc", "Functions", "VisualShaderNodeVectorFunc")); add_options.push_back(AddOption("DotProduct", "Functions", "VisualShaderNodeDotProduct")); add_options.push_back(AddOption("VectorLen", "Functions", "VisualShaderNodeVectorLen")); add_options.push_back(AddOption("ScalarInterp", "Interpolation", "VisualShaderNodeScalarInterp")); add_options.push_back(AddOption("VectorInterp", "Interpolation", "VisualShaderNodeVectorInterp")); add_options.push_back(AddOption("VectorCompose", "Compose", "VisualShaderNodeVectorCompose")); add_options.push_back(AddOption("TransformCompose", "Compose", "VisualShaderNodeTransformCompose")); add_options.push_back(AddOption("VectorDecompose", "Decompose", "VisualShaderNodeVectorDecompose")); add_options.push_back(AddOption("TransformDecompose", "Decompose", "VisualShaderNodeTransformDecompose")); add_options.push_back(AddOption("Scalar", "Uniforms", "VisualShaderNodeScalarUniform")); add_options.push_back(AddOption("Vector", "Uniforms", "VisualShaderNodeVec3Uniform")); add_options.push_back(AddOption("Color", "Uniforms", "VisualShaderNodeColorUniform")); add_options.push_back(AddOption("Transform", "Uniforms", "VisualShaderNodeTransformUniform")); add_options.push_back(AddOption("Texture", "Uniforms", "VisualShaderNodeTextureUniform")); add_options.push_back(AddOption("CubeMap", "Uniforms", "VisualShaderNodeCubeMapUniform")); add_options.push_back(AddOption("Input", "Inputs", "VisualShaderNodeInput")); _update_options_menu(); error_panel = memnew(PanelContainer); add_child(error_panel); error_label = memnew(Label); error_panel->add_child(error_label); error_label->set_text("eh"); error_panel->hide(); undo_redo = EditorNode::get_singleton()->get_undo_redo(); Ref<VisualShaderNodePluginDefault> default_plugin; default_plugin.instance(); add_plugin(default_plugin); property_editor = memnew(CustomPropertyEditor); add_child(property_editor); property_editor->connect("variant_changed", this, "_port_edited"); }
AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() { singleton = this; updating = false; graph = memnew(GraphEdit); add_child(graph); graph->add_valid_right_disconnect_type(0); graph->add_valid_left_disconnect_type(0); graph->set_v_size_flags(SIZE_EXPAND_FILL); graph->connect("connection_request", this, "_connection_request", varray(), CONNECT_DEFERRED); graph->connect("disconnection_request", this, "_disconnection_request", varray(), CONNECT_DEFERRED); graph->connect("node_selected", this, "_node_selected"); graph->connect("scroll_offset_changed", this, "_scroll_changed"); VSeparator *vs = memnew(VSeparator); graph->get_zoom_hbox()->add_child(vs); graph->get_zoom_hbox()->move_child(vs, 0); add_node = memnew(MenuButton); graph->get_zoom_hbox()->add_child(add_node); add_node->set_text(TTR("Add Node..")); graph->get_zoom_hbox()->move_child(add_node, 0); add_node->get_popup()->connect("index_pressed", this, "_add_node"); goto_parent = memnew(Button); graph->get_zoom_hbox()->add_child(goto_parent); graph->get_zoom_hbox()->move_child(goto_parent, 0); goto_parent->hide(); goto_parent->connect("pressed", this, "_open_parent"); add_options.push_back(AddOption("Animation", "AnimationNodeAnimation")); add_options.push_back(AddOption("OneShot", "AnimationNodeOneShot")); add_options.push_back(AddOption("Add2", "AnimationNodeAdd2")); add_options.push_back(AddOption("Add3", "AnimationNodeAdd3")); add_options.push_back(AddOption("Blend2", "AnimationNodeBlend2")); add_options.push_back(AddOption("Blend3", "AnimationNodeBlend3")); add_options.push_back(AddOption("Seek", "AnimationNodeTimeSeek")); add_options.push_back(AddOption("TimeScale", "AnimationNodeTimeScale")); add_options.push_back(AddOption("Transition", "AnimationNodeTransition")); add_options.push_back(AddOption("BlendTree", "AnimationNodeBlendTree")); add_options.push_back(AddOption("BlendSpace1D", "AnimationNodeBlendSpace1D")); add_options.push_back(AddOption("BlendSpace2D", "AnimationNodeBlendSpace2D")); add_options.push_back(AddOption("StateMachine", "AnimationNodeStateMachine")); _update_options_menu(); error_panel = memnew(PanelContainer); add_child(error_panel); error_label = memnew(Label); error_panel->add_child(error_label); error_label->set_text("eh"); filter_dialog = memnew(AcceptDialog); add_child(filter_dialog); filter_dialog->set_title(TTR("Edit Filtered Tracks:")); VBoxContainer *filter_vbox = memnew(VBoxContainer); filter_dialog->add_child(filter_vbox); filter_enabled = memnew(CheckBox); filter_enabled->set_text(TTR("Enable filtering")); filter_enabled->connect("pressed", this, "_filter_toggled"); filter_vbox->add_child(filter_enabled); filters = memnew(Tree); filter_vbox->add_child(filters); filters->set_v_size_flags(SIZE_EXPAND_FILL); filters->set_hide_root(true); filters->connect("item_edited", this, "_filter_edited"); undo_redo = EditorNode::get_singleton()->get_undo_redo(); }