summaryrefslogtreecommitdiff
path: root/editor/plugins/shader_editor_plugin.h
diff options
context:
space:
mode:
authorYuri Roubinsky <chaosus89@gmail.com>2022-03-08 13:39:16 +0300
committerJuan Linietsky <reduzio@gmail.com>2022-07-22 22:51:57 +0200
commit7b94603baa8259947facc5ab5fe02d82fa129ef8 (patch)
treeb82bac57373cc01ffa0dd6da05e117e4b24ccbc4 /editor/plugins/shader_editor_plugin.h
parent79463aa5defb083569d193658a62755223f14dc4 (diff)
Adding shader preprocessor support
Co-authored-by: TheOrangeDay <6472143+TheOrangeDay@users.noreply.github.com>
Diffstat (limited to 'editor/plugins/shader_editor_plugin.h')
-rw-r--r--editor/plugins/shader_editor_plugin.h24
1 files changed, 20 insertions, 4 deletions
diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h
index 2e0dbe0d60..c9cd75e451 100644
--- a/editor/plugins/shader_editor_plugin.h
+++ b/editor/plugins/shader_editor_plugin.h
@@ -40,6 +40,7 @@
#include "scene/gui/text_edit.h"
#include "scene/main/timer.h"
#include "scene/resources/shader.h"
+#include "scene/resources/shader_include.h"
#include "servers/rendering/shader_warnings.h"
class ItemList;
@@ -59,6 +60,7 @@ class ShaderTextEditor : public CodeTextEditor {
Ref<CodeHighlighter> syntax_highlighter;
RichTextLabel *warnings_panel = nullptr;
Ref<Shader> shader;
+ Ref<ShaderInclude> shader_inc;
List<ShaderWarning> warnings;
Error last_compile_result = Error::OK;
@@ -79,7 +81,14 @@ public:
void set_warnings_panel(RichTextLabel *p_warnings_panel);
Ref<Shader> get_edited_shader() const;
+ Ref<ShaderInclude> get_edited_shader_include() const;
+
void set_edited_shader(const Ref<Shader> &p_shader);
+ void set_edited_shader(const Ref<Shader> &p_shader, const String &p_code);
+ void set_edited_shader_include(const Ref<ShaderInclude> &p_include);
+ void set_edited_shader_include(const Ref<ShaderInclude> &p_include, const String &p_code);
+ void set_edited_code(const String &p_code);
+
ShaderTextEditor();
};
@@ -129,12 +138,15 @@ class ShaderEditor : public PanelContainer {
void _menu_option(int p_option);
mutable Ref<Shader> shader;
+ mutable Ref<ShaderInclude> shader_inc;
void _editor_settings_changed();
void _project_settings_changed();
void _check_for_external_edit();
void _reload_shader_from_disk();
+ void _reload_shader_include_from_disk();
+ void _reload();
void _show_warnings_panel(bool p_show);
void _warning_clicked(Variant p_line);
void _update_warnings(bool p_validate);
@@ -143,21 +155,21 @@ protected:
void _notification(int p_what);
static void _bind_methods();
void _make_context_menu(bool p_selection, Vector2 p_position);
- void _text_edit_gui_input(const Ref<InputEvent> &ev);
+ void _text_edit_gui_input(const Ref<InputEvent> &p_ev);
void _update_bookmark_list();
void _bookmark_item_pressed(int p_idx);
public:
void apply_shaders();
-
void ensure_select_current();
void edit(const Ref<Shader> &p_shader);
-
+ void edit(const Ref<ShaderInclude> &p_shader_inc);
void goto_line_selection(int p_line, int p_begin, int p_end);
+ void save_external_data(const String &p_str = "");
+ void validate_script();
virtual Size2 get_minimum_size() const override { return Size2(0, 200); }
- void save_external_data(const String &p_str = "");
ShaderEditor();
};
@@ -167,6 +179,7 @@ class ShaderEditorPlugin : public EditorPlugin {
struct EditedShader {
Ref<Shader> shader;
+ Ref<ShaderInclude> shader_inc;
ShaderEditor *shader_editor = nullptr;
VisualShaderEditor *visual_shader_editor = nullptr;
};
@@ -175,7 +188,9 @@ class ShaderEditorPlugin : public EditorPlugin {
enum {
FILE_NEW,
+ FILE_NEW_INCLUDE,
FILE_OPEN,
+ FILE_OPEN_INCLUDE,
FILE_SAVE,
FILE_SAVE_AS,
FILE_INSPECT,
@@ -199,6 +214,7 @@ class ShaderEditorPlugin : public EditorPlugin {
void _close_shader(int p_index);
void _shader_created(Ref<Shader> p_shader);
+ void _shader_include_created(Ref<ShaderInclude> p_shader_inc);
public:
virtual String get_name() const override { return "Shader"; }