Fix incorrect search member in visual shaders

This commit is contained in:
Yuri Roubinski 2019-08-08 21:42:53 +03:00
parent 22b42c3315
commit 6c8a55aa0d

View file

@ -211,6 +211,9 @@ void VisualShaderEditor::_update_options_menu() {
if (!use_filter || add_options[i].name.findn(filter) != -1) { if (!use_filter || add_options[i].name.findn(filter) != -1) {
if ((add_options[i].func != current_func && add_options[i].func != -1) || !_is_available(add_options[i].mode))
continue;
if (prev_category != add_options[i].category) { if (prev_category != add_options[i].category) {
if (category != NULL && item_count == 0) { if (category != NULL && item_count == 0) {
memdelete(category); memdelete(category);
@ -241,19 +244,33 @@ void VisualShaderEditor::_update_options_menu() {
sub_category->set_collapsed(true); sub_category->set_collapsed(true);
} }
} }
} else {
sub_category = NULL;
}
TreeItem *p_category = NULL;
if (sub_category != NULL) { if (sub_category != NULL) {
if ((add_options[i].func == current_func || add_options[i].func == -1) && _is_available(add_options[i].mode)) { p_category = sub_category;
++item_count2; ++item_count2;
TreeItem *item = members->create_item(sub_category); } else if (category != NULL) {
p_category = category;
++item_count;
}
if (p_category != NULL) {
TreeItem *item = members->create_item(p_category);
if (add_options[i].highend && low_driver) if (add_options[i].highend && low_driver)
item->set_custom_color(0, unsupported_color); item->set_custom_color(0, unsupported_color);
else if (add_options[i].highend) else if (add_options[i].highend)
item->set_custom_color(0, supported_color); item->set_custom_color(0, supported_color);
item->set_text(0, add_options[i].name); item->set_text(0, add_options[i].name);
if (p_category == sub_category) {
if (is_first_item) { if (is_first_item) {
item->select(0); item->select(0);
is_first_item = false; is_first_item = false;
} }
}
switch (add_options[i].return_type) { switch (add_options[i].return_type) {
case VisualShaderNode::PORT_TYPE_SCALAR: case VisualShaderNode::PORT_TYPE_SCALAR:
item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("float", "EditorIcons")); item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("float", "EditorIcons"));
@ -275,40 +292,6 @@ void VisualShaderEditor::_update_options_menu() {
} }
item->set_meta("id", i); item->set_meta("id", i);
} }
}
} else {
if (category != NULL) {
if ((add_options[i].func == current_func || add_options[i].func == -1) && _is_available(add_options[i].mode)) {
++item_count;
TreeItem *item = members->create_item(category);
if (add_options[i].highend && low_driver)
item->set_custom_color(0, unsupported_color);
else if (add_options[i].highend)
item->set_custom_color(0, supported_color);
item->set_text(0, add_options[i].name);
switch (add_options[i].return_type) {
case VisualShaderNode::PORT_TYPE_SCALAR:
item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("float", "EditorIcons"));
break;
case VisualShaderNode::PORT_TYPE_VECTOR:
item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("Vector3", "EditorIcons"));
break;
case VisualShaderNode::PORT_TYPE_BOOLEAN:
item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("bool", "EditorIcons"));
break;
case VisualShaderNode::PORT_TYPE_TRANSFORM:
item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("Transform", "EditorIcons"));
break;
case VisualShaderNode::PORT_TYPE_COLOR:
item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("Color", "EditorIcons"));
break;
default:
break;
}
item->set_meta("id", i);
}
}
}
prev_sub_category = add_options[i].sub_category; prev_sub_category = add_options[i].sub_category;
prev_category = add_options[i].category; prev_category = add_options[i].category;