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,73 +244,53 @@ void VisualShaderEditor::_update_options_menu() {
sub_category->set_collapsed(true); sub_category->set_collapsed(true);
} }
} }
if (sub_category != NULL) {
if ((add_options[i].func == current_func || add_options[i].func == -1) && _is_available(add_options[i].mode)) {
++item_count2;
TreeItem *item = members->create_item(sub_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);
if (is_first_item) {
item->select(0);
is_first_item = false;
}
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);
}
}
} else { } else {
if (category != NULL) { sub_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); TreeItem *p_category = NULL;
if (add_options[i].highend && low_driver)
item->set_custom_color(0, unsupported_color); if (sub_category != NULL) {
else if (add_options[i].highend) p_category = sub_category;
item->set_custom_color(0, supported_color); ++item_count2;
item->set_text(0, add_options[i].name); } else if (category != NULL) {
switch (add_options[i].return_type) { p_category = category;
case VisualShaderNode::PORT_TYPE_SCALAR: ++item_count;
item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("float", "EditorIcons")); }
break;
case VisualShaderNode::PORT_TYPE_VECTOR: if (p_category != NULL) {
item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("Vector3", "EditorIcons")); TreeItem *item = members->create_item(p_category);
break; if (add_options[i].highend && low_driver)
case VisualShaderNode::PORT_TYPE_BOOLEAN: item->set_custom_color(0, unsupported_color);
item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("bool", "EditorIcons")); else if (add_options[i].highend)
break; item->set_custom_color(0, supported_color);
case VisualShaderNode::PORT_TYPE_TRANSFORM: item->set_text(0, add_options[i].name);
item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("Transform", "EditorIcons")); if (p_category == sub_category) {
break; if (is_first_item) {
case VisualShaderNode::PORT_TYPE_COLOR: item->select(0);
item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_icon("Color", "EditorIcons")); is_first_item = false;
break;
default:
break;
}
item->set_meta("id", i);
} }
} }
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;