Separated shader editor into a new module.

This commit is contained in:
Relintai 2023-02-18 09:44:05 +01:00
parent 8d7090241a
commit 7c946c9ba9
10 changed files with 71 additions and 6 deletions

View File

@ -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

View File

@ -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)

View File

@ -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"

View File

@ -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<ShaderEditorPlugin>();
}
#endif
}
void unregister_shader_editor_types(ModuleRegistrationLevel p_level) {
}

View File

@ -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

View File

@ -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"

View File

@ -9,7 +9,6 @@ sources = [
"code_editor.cpp",
"script_editor_plugin.cpp",
"script_text_editor.cpp",
"shader_editor_plugin.cpp",
"text_editor.cpp",
]

View File

@ -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<ScriptEditorPlugin>();
EditorPlugins::add_by_type<ShaderEditorPlugin>();
}
#endif
}

View File

@ -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<ShaderEditorPlugin>(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 {