diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 3b03a5e8c..4f09a6d68 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -195,7 +195,6 @@ #ifdef MODULE_CODE_EDITOR_ENABLED #include "modules/code_editor/script_editor_plugin.h" #include "modules/code_editor/script_text_editor.h" -#include "modules/code_editor/shader_editor_plugin.h" #include "modules/code_editor/text_editor.h" #endif diff --git a/editor_modules/shader_editor/SCsub b/editor_modules/shader_editor/SCsub new file mode 100644 index 000000000..1526697e4 --- /dev/null +++ b/editor_modules/shader_editor/SCsub @@ -0,0 +1,12 @@ +#!/usr/bin/env python + +Import("env") + +env_mlp = env.Clone() + +sources = [ + "register_types.cpp", + "shader_editor_plugin.cpp", +] + +env_mlp.add_source_files(env.modules_sources, sources) diff --git a/editor_modules/shader_editor/config.py b/editor_modules/shader_editor/config.py new file mode 100644 index 000000000..7df830233 --- /dev/null +++ b/editor_modules/shader_editor/config.py @@ -0,0 +1,20 @@ + + +def can_build(env, platform): + if not env["tools"]: + return False + + env.module_add_dependencies("shader_editor", ["code_editor"], False) + + return True + +def configure(env): + pass + + +def get_doc_classes(): + return [ + ] + +def get_doc_path(): + return "doc_classes" diff --git a/editor_modules/shader_editor/register_types.cpp b/editor_modules/shader_editor/register_types.cpp new file mode 100644 index 000000000..927d1ae69 --- /dev/null +++ b/editor_modules/shader_editor/register_types.cpp @@ -0,0 +1,19 @@ + +#include "register_types.h" + +#include "shader_editor_plugin.h" + +void register_shader_editor_types(ModuleRegistrationLevel p_level) { + if (p_level == MODULE_REGISTRATION_LEVEL_SCENE) { + //ClassDB::register_class<>(); + } + +#ifdef TOOLS_ENABLED + if (p_level == MODULE_REGISTRATION_LEVEL_EDITOR) { + EditorPlugins::add_by_type(); + } +#endif +} + +void unregister_shader_editor_types(ModuleRegistrationLevel p_level) { +} diff --git a/editor_modules/shader_editor/register_types.h b/editor_modules/shader_editor/register_types.h new file mode 100644 index 000000000..0f31ea111 --- /dev/null +++ b/editor_modules/shader_editor/register_types.h @@ -0,0 +1,9 @@ +#ifndef SHADER_EDITOR_REGISTER_TYPES_H +#define SHADER_EDITOR_REGISTER_TYPES_H + +#include "modules/register_module_types.h" + +void register_shader_editor_types(ModuleRegistrationLevel p_level); +void unregister_shader_editor_types(ModuleRegistrationLevel p_level); + +#endif diff --git a/modules/code_editor/shader_editor_plugin.cpp b/editor_modules/shader_editor/shader_editor_plugin.cpp similarity index 100% rename from modules/code_editor/shader_editor_plugin.cpp rename to editor_modules/shader_editor/shader_editor_plugin.cpp diff --git a/modules/code_editor/shader_editor_plugin.h b/editor_modules/shader_editor/shader_editor_plugin.h similarity index 99% rename from modules/code_editor/shader_editor_plugin.h rename to editor_modules/shader_editor/shader_editor_plugin.h index 0b3ef24a9..ff8e91e51 100644 --- a/modules/code_editor/shader_editor_plugin.h +++ b/editor_modules/shader_editor/shader_editor_plugin.h @@ -30,7 +30,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "code_editor.h" +#include "modules/code_editor/code_editor.h" #include "editor/editor_plugin.h" #include "scene/gui/margin_container.h" diff --git a/modules/code_editor/SCsub b/modules/code_editor/SCsub index f1a6f19a0..112e01e12 100644 --- a/modules/code_editor/SCsub +++ b/modules/code_editor/SCsub @@ -9,7 +9,6 @@ sources = [ "code_editor.cpp", "script_editor_plugin.cpp", "script_text_editor.cpp", - "shader_editor_plugin.cpp", "text_editor.cpp", ] diff --git a/modules/code_editor/register_types.cpp b/modules/code_editor/register_types.cpp index b18125429..abef97d8b 100644 --- a/modules/code_editor/register_types.cpp +++ b/modules/code_editor/register_types.cpp @@ -2,7 +2,6 @@ #include "register_types.h" #include "script_editor_plugin.h" -#include "shader_editor_plugin.h" #include "script_text_editor.h" #include "text_editor.h" @@ -16,7 +15,6 @@ void register_code_editor_types(ModuleRegistrationLevel p_level) { #ifdef TOOLS_ENABLED if (p_level == MODULE_REGISTRATION_LEVEL_EDITOR) { EditorPlugins::add_by_type(); - EditorPlugins::add_by_type(); } #endif } diff --git a/modules/code_editor/script_editor_plugin.cpp b/modules/code_editor/script_editor_plugin.cpp index 0047d366a..0c4b52a8f 100644 --- a/modules/code_editor/script_editor_plugin.cpp +++ b/modules/code_editor/script_editor_plugin.cpp @@ -90,9 +90,14 @@ #include "scene/resources/texture.h" #include "scene/scene_string_names.h" #include "script_text_editor.h" -#include "shader_editor_plugin.h" #include "text_editor.h" +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_SHADER_EDITOR_ENABLED +#include "shader_editor/shader_editor_plugin.h" +#endif + /*** SCRIPT EDITOR ****/ void ScriptEditorBase::_bind_methods() { @@ -3140,6 +3145,7 @@ void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_numb if (ResourceLoader::exists(fpath)) { RES res = ResourceLoader::load(fpath); +#ifdef MODULE_SHADER_EDITOR_ENABLED if (fpath.get_extension() == "gdshader" || fpath.get_extension() == "shader") { ShaderEditorPlugin *shader_editor = Object::cast_to(EditorNode::get_singleton()->get_editor_data().get_editor("Shader")); shader_editor->edit(res.ptr()); @@ -3147,6 +3153,9 @@ void ScriptEditor::_on_find_in_files_result_selected(String fpath, int line_numb shader_editor->get_shader_editor()->goto_line_selection(line_number - 1, begin, end); return; } else if (fpath.get_extension() == "tscn") { +#else + if (fpath.get_extension() == "tscn") { +#endif editor->load_scene(fpath); return; } else {