summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuri Roubinsky <chaosus89@gmail.com>2019-08-08 22:32:26 +0300
committerGitHub <noreply@github.com>2019-08-08 22:32:26 +0300
commit7841800c1e7fe47de6ad8a54197ee3ed2b611d89 (patch)
tree5b7087a68c579403288b2a59e8ddc954b27ea4c1
parentd2a67c9c1fdee470064f2b3c5750c98f174b5399 (diff)
parent6c8a55aa0da8ca5e6ebf1b7b6bc0052c63785d2f (diff)
Merge pull request #31214 from Chaosus/vs_fix_search_bug
Fix incorrect search member in visual shaders
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp111
1 files changed, 47 insertions, 64 deletions
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index dc22507f39..863cf75a93 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -211,6 +211,9 @@ void VisualShaderEditor::_update_options_menu() {
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 (category != NULL && item_count == 0) {
memdelete(category);
@@ -241,73 +244,53 @@ void VisualShaderEditor::_update_options_menu() {
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 {
- 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);
+ sub_category = NULL;
+ }
+
+ TreeItem *p_category = NULL;
+
+ if (sub_category != NULL) {
+ p_category = sub_category;
+ ++item_count2;
+ } 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)
+ 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 (p_category == sub_category) {
+ 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);
}
prev_sub_category = add_options[i].sub_category;