diff options
Diffstat (limited to 'editor/plugins/visual_shader_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/visual_shader_editor_plugin.cpp | 139 |
1 files changed, 70 insertions, 69 deletions
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 330a9a36eb..b6330bdf75 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -39,6 +39,7 @@ #include "editor/editor_properties_vector.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" +#include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" #include "editor/filesystem_dock.h" #include "editor/inspector_dock.h" @@ -348,10 +349,10 @@ void VisualShaderGraphPlugin::register_parameter_name(int p_node_id, LineEdit *p } void VisualShaderGraphPlugin::update_theme() { - vector_expanded_color[0] = editor->get_theme_color(SNAME("axis_x_color"), SNAME("Editor")); // red - vector_expanded_color[1] = editor->get_theme_color(SNAME("axis_y_color"), SNAME("Editor")); // green - vector_expanded_color[2] = editor->get_theme_color(SNAME("axis_z_color"), SNAME("Editor")); // blue - vector_expanded_color[3] = editor->get_theme_color(SNAME("axis_w_color"), SNAME("Editor")); // alpha + vector_expanded_color[0] = editor->get_theme_color(SNAME("axis_x_color"), EditorStringName(Editor)); // red + vector_expanded_color[1] = editor->get_theme_color(SNAME("axis_y_color"), EditorStringName(Editor)); // green + vector_expanded_color[2] = editor->get_theme_color(SNAME("axis_z_color"), EditorStringName(Editor)); // blue + vector_expanded_color[3] = editor->get_theme_color(SNAME("axis_w_color"), EditorStringName(Editor)); // alpha } bool VisualShaderGraphPlugin::is_node_has_parameter_instances_relatively(VisualShader::Type p_type, int p_node) const { @@ -414,7 +415,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool // Visual shader specific theme for MSDF font. Ref<Theme> vstheme; vstheme.instantiate(); - Ref<Font> label_font = EditorNode::get_singleton()->get_editor_theme()->get_font("main_msdf", "EditorFonts"); + Ref<Font> label_font = EditorNode::get_singleton()->get_editor_theme()->get_font("main_msdf", EditorStringName(EditorFonts)); vstheme->set_font("font", "Label", label_font); vstheme->set_font("font", "LineEdit", label_font); vstheme->set_font("font", "Button", label_font); @@ -789,7 +790,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool name_box->connect("focus_exited", callable_mp(editor, &VisualShaderEditor::_port_name_focus_out).bind(name_box, p_id, i, false), CONNECT_DEFERRED); Button *remove_btn = memnew(Button); - remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Remove"))); remove_btn->set_tooltip_text(TTR("Remove") + " " + name_left); remove_btn->connect("pressed", callable_mp(editor, &VisualShaderEditor::_remove_input_port).bind(p_id, i), CONNECT_DEFERRED); hb->add_child(remove_btn); @@ -816,7 +817,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool if (valid_right) { if (is_group) { Button *remove_btn = memnew(Button); - remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); + remove_btn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Remove"))); remove_btn->set_tooltip_text(TTR("Remove") + " " + name_left); remove_btn->connect("pressed", callable_mp(editor, &VisualShaderEditor::_remove_output_port).bind(p_id, i), CONNECT_DEFERRED); hb->add_child(remove_btn); @@ -855,8 +856,8 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool if (vsnode->is_output_port_expandable(i)) { TextureButton *expand = memnew(TextureButton); expand->set_toggle_mode(true); - expand->set_texture_normal(editor->get_theme_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons"))); - expand->set_texture_pressed(editor->get_theme_icon(SNAME("GuiTreeArrowRight"), SNAME("EditorIcons"))); + expand->set_texture_normal(editor->get_editor_theme_icon(SNAME("GuiTreeArrowDown"))); + expand->set_texture_pressed(editor->get_editor_theme_icon(SNAME("GuiTreeArrowRight"))); expand->set_v_size_flags(Control::SIZE_SHRINK_CENTER); expand->set_pressed(vsnode->_is_output_port_expanded(i)); expand->connect("pressed", callable_mp(editor, &VisualShaderEditor::_expand_output_port).bind(p_id, i, !vsnode->_is_output_port_expanded(i)), CONNECT_DEFERRED); @@ -865,8 +866,8 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool if (vsnode->has_output_port_preview(i) && port_right != VisualShaderNode::PORT_TYPE_TRANSFORM && port_right != VisualShaderNode::PORT_TYPE_SAMPLER) { TextureButton *preview = memnew(TextureButton); preview->set_toggle_mode(true); - preview->set_texture_normal(editor->get_theme_icon(SNAME("GuiVisibilityHidden"), SNAME("EditorIcons"))); - preview->set_texture_pressed(editor->get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"))); + preview->set_texture_normal(editor->get_editor_theme_icon(SNAME("GuiVisibilityHidden"))); + preview->set_texture_pressed(editor->get_editor_theme_icon(SNAME("GuiVisibilityVisible"))); preview->set_v_size_flags(Control::SIZE_SHRINK_CENTER); register_output_port(p_id, j, preview); @@ -1002,7 +1003,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool } if (!error.is_empty()) { Label *error_label = memnew(Label); - error_label->add_theme_color_override("font_color", editor->get_theme_color(SNAME("error_color"), SNAME("Editor"))); + error_label->add_theme_color_override("font_color", editor->get_theme_color(SNAME("error_color"), EditorStringName(Editor))); error_label->set_text(error); node->add_child(error_label); } @@ -1036,8 +1037,8 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool } } - expression_box->add_theme_font_override("font", editor->get_theme_font(SNAME("expression"), SNAME("EditorFonts"))); - expression_box->add_theme_font_size_override("font_size", editor->get_theme_font_size(SNAME("expression_size"), SNAME("EditorFonts"))); + expression_box->add_theme_font_override("font", editor->get_theme_font(SNAME("expression"), EditorStringName(EditorFonts))); + expression_box->add_theme_font_size_override("font_size", editor->get_theme_font_size(SNAME("expression_size"), EditorStringName(EditorFonts))); expression_box->add_theme_color_override("font_color", text_color); expression_syntax_highlighter->set_number_color(number_color); expression_syntax_highlighter->set_symbol_color(symbol_color); @@ -1677,8 +1678,8 @@ void VisualShaderEditor::_update_options_menu() { bool is_first_item = true; - Color unsupported_color = get_theme_color(SNAME("error_color"), SNAME("Editor")); - Color supported_color = get_theme_color(SNAME("warning_color"), SNAME("Editor")); + Color unsupported_color = get_theme_color(SNAME("error_color"), EditorStringName(Editor)); + Color supported_color = get_theme_color(SNAME("warning_color"), EditorStringName(Editor)); static bool low_driver = GLOBAL_GET("rendering/renderer/rendering_method") == "gl_compatibility"; @@ -1833,31 +1834,31 @@ void VisualShaderEditor::_update_options_menu() { } switch (options[i].return_type) { case VisualShaderNode::PORT_TYPE_SCALAR: - item->set_icon(0, get_theme_icon(SNAME("float"), SNAME("EditorIcons"))); + item->set_icon(0, get_editor_theme_icon(SNAME("float"))); break; case VisualShaderNode::PORT_TYPE_SCALAR_INT: - item->set_icon(0, get_theme_icon(SNAME("int"), SNAME("EditorIcons"))); + item->set_icon(0, get_editor_theme_icon(SNAME("int"))); break; case VisualShaderNode::PORT_TYPE_SCALAR_UINT: - item->set_icon(0, get_theme_icon(SNAME("uint"), SNAME("EditorIcons"))); + item->set_icon(0, get_editor_theme_icon(SNAME("uint"))); break; case VisualShaderNode::PORT_TYPE_VECTOR_2D: - item->set_icon(0, get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons"))); + item->set_icon(0, get_editor_theme_icon(SNAME("Vector2"))); break; case VisualShaderNode::PORT_TYPE_VECTOR_3D: - item->set_icon(0, get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons"))); + item->set_icon(0, get_editor_theme_icon(SNAME("Vector3"))); break; case VisualShaderNode::PORT_TYPE_VECTOR_4D: - item->set_icon(0, get_theme_icon(SNAME("Vector4"), SNAME("EditorIcons"))); + item->set_icon(0, get_editor_theme_icon(SNAME("Vector4"))); break; case VisualShaderNode::PORT_TYPE_BOOLEAN: - item->set_icon(0, get_theme_icon(SNAME("bool"), SNAME("EditorIcons"))); + item->set_icon(0, get_editor_theme_icon(SNAME("bool"))); break; case VisualShaderNode::PORT_TYPE_TRANSFORM: - item->set_icon(0, get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons"))); + item->set_icon(0, get_editor_theme_icon(SNAME("Transform3D"))); break; case VisualShaderNode::PORT_TYPE_SAMPLER: - item->set_icon(0, get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"))); + item->set_icon(0, get_editor_theme_icon(SNAME("ImageTexture"))); break; default: break; @@ -4085,11 +4086,11 @@ void VisualShaderEditor::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - highend_label->set_modulate(get_theme_color(SNAME("highend_color"), SNAME("Editor"))); + highend_label->set_modulate(get_theme_color(SNAME("highend_color"), EditorStringName(Editor))); - node_filter->set_right_icon(Control::get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + node_filter->set_right_icon(Control::get_editor_theme_icon(SNAME("Search"))); - preview_shader->set_icon(Control::get_theme_icon(SNAME("Shader"), SNAME("EditorIcons"))); + preview_shader->set_icon(Control::get_editor_theme_icon(SNAME("Shader"))); { Color background_color = EDITOR_GET("text_editor/theme/highlighting/background_color"); @@ -4101,7 +4102,7 @@ void VisualShaderEditor::_notification(int p_what) { Color function_color = EDITOR_GET("text_editor/theme/highlighting/function_color"); Color number_color = EDITOR_GET("text_editor/theme/highlighting/number_color"); Color members_color = EDITOR_GET("text_editor/theme/highlighting/member_variable_color"); - Color error_color = get_theme_color(SNAME("error_color"), SNAME("Editor")); + Color error_color = get_theme_color(SNAME("error_color"), EditorStringName(Editor)); preview_text->add_theme_color_override("background_color", background_color); varying_error_label->add_theme_color_override("font_color", error_color); @@ -4114,8 +4115,8 @@ void VisualShaderEditor::_notification(int p_what) { } } - preview_text->add_theme_font_override("font", get_theme_font(SNAME("expression"), SNAME("EditorFonts"))); - preview_text->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("expression_size"), SNAME("EditorFonts"))); + preview_text->add_theme_font_override("font", get_theme_font(SNAME("expression"), EditorStringName(EditorFonts))); + preview_text->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("expression_size"), EditorStringName(EditorFonts))); preview_text->add_theme_color_override("font_color", text_color); syntax_highlighter->set_number_color(number_color); syntax_highlighter->set_symbol_color(symbol_color); @@ -4130,12 +4131,12 @@ void VisualShaderEditor::_notification(int p_what) { preview_text->add_comment_delimiter("//", "", true); error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Panel"))); - error_label->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); - error_label->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); + error_label->add_theme_font_override("font", get_theme_font(SNAME("status_source"), EditorStringName(EditorFonts))); + error_label->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), EditorStringName(EditorFonts))); error_label->add_theme_color_override("font_color", error_color); } - tools->set_icon(get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); + tools->set_icon(get_editor_theme_icon(SNAME("Tools"))); if (p_what == NOTIFICATION_THEME_CHANGED && is_visible_in_tree()) { _update_graph(); @@ -4691,28 +4692,28 @@ void VisualShaderEditor::_update_varying_tree() { switch (varying->type) { case VisualShader::VARYING_TYPE_FLOAT: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("float"), SNAME("EditorIcons"))); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("float"))); break; case VisualShader::VARYING_TYPE_INT: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("int"), SNAME("EditorIcons"))); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("int"))); break; case VisualShader::VARYING_TYPE_UINT: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("uint"), SNAME("EditorIcons"))); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("uint"))); break; case VisualShader::VARYING_TYPE_VECTOR_2D: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons"))); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector2"))); break; case VisualShader::VARYING_TYPE_VECTOR_3D: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons"))); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector3"))); break; case VisualShader::VARYING_TYPE_VECTOR_4D: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector4"), SNAME("EditorIcons"))); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector4"))); break; case VisualShader::VARYING_TYPE_BOOLEAN: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("bool"), SNAME("EditorIcons"))); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("bool"))); break; case VisualShader::VARYING_TYPE_TRANSFORM: - item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons"))); + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Transform3D"))); break; default: break; @@ -6177,15 +6178,15 @@ public: editor = p_editor; input = p_input; Ref<Texture2D> type_icon[] = { - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("float"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("int"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("uint"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector4"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("bool"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("float")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("int")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("uint")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector2")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector3")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector4")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("bool")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Transform3D")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("ImageTexture")), }; add_item("[None]"); @@ -6227,14 +6228,14 @@ public: varying = p_varying; Ref<Texture2D> type_icon[] = { - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("float"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("int"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("uint"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector4"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("bool"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("float")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("int")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("uint")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector2")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector3")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector4")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("bool")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Transform3D")), }; bool is_getter = Ref<VisualShaderNodeVaryingGetter>(p_varying.ptr()).is_valid(); @@ -6307,16 +6308,16 @@ public: parameter_ref = p_parameter_ref; Ref<Texture2D> type_icon[] = { - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("float"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("int"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("uint"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("bool"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector4"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Color"), SNAME("EditorIcons")), - EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("float")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("int")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("uint")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("bool")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector2")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector3")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Vector4")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Transform3D")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("Color")), + EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon(SNAME("ImageTexture")), }; add_item("[None]"); |