2020-05-10 18:53:46 +08:00
|
|
|
/**************************************************************************/
|
|
|
|
/* shader_file_editor_plugin.h */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/**************************************************************************/
|
|
|
|
|
2020-04-20 10:19:21 +08:00
|
|
|
#ifndef SHADER_FILE_EDITOR_PLUGIN_H
|
|
|
|
#define SHADER_FILE_EDITOR_PLUGIN_H
|
|
|
|
|
|
|
|
#include "editor/code_editor.h"
|
|
|
|
#include "editor/editor_plugin.h"
|
|
|
|
#include "scene/gui/menu_button.h"
|
|
|
|
#include "scene/gui/panel_container.h"
|
|
|
|
#include "scene/gui/rich_text_label.h"
|
|
|
|
#include "scene/gui/tab_container.h"
|
|
|
|
#include "scene/gui/text_edit.h"
|
|
|
|
#include "scene/main/timer.h"
|
|
|
|
#include "servers/rendering/rendering_device_binds.h"
|
|
|
|
|
2022-02-12 09:46:22 +08:00
|
|
|
class ItemList;
|
|
|
|
|
2020-04-20 10:19:21 +08:00
|
|
|
class ShaderFileEditor : public PanelContainer {
|
|
|
|
GDCLASS(ShaderFileEditor, PanelContainer);
|
|
|
|
|
|
|
|
Ref<RDShaderFile> shader_file;
|
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
HBoxContainer *stage_hb = nullptr;
|
|
|
|
ItemList *versions = nullptr;
|
2020-04-20 10:19:21 +08:00
|
|
|
Button *stages[RD::SHADER_STAGE_MAX];
|
2022-04-04 21:06:57 +08:00
|
|
|
RichTextLabel *error_text = nullptr;
|
2020-04-20 10:19:21 +08:00
|
|
|
|
|
|
|
void _update_version(const StringName &p_version_txt, const RenderingDevice::ShaderStage p_stage);
|
|
|
|
void _version_selected(int p_stage);
|
|
|
|
void _editor_settings_changed();
|
|
|
|
|
|
|
|
void _update_options();
|
|
|
|
void _shader_changed();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
|
|
|
static ShaderFileEditor *singleton;
|
|
|
|
void edit(const Ref<RDShaderFile> &p_shader);
|
|
|
|
|
2022-01-27 17:36:51 +08:00
|
|
|
ShaderFileEditor();
|
2020-04-20 10:19:21 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class ShaderFileEditorPlugin : public EditorPlugin {
|
|
|
|
GDCLASS(ShaderFileEditorPlugin, EditorPlugin);
|
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
ShaderFileEditor *shader_editor = nullptr;
|
|
|
|
Button *button = nullptr;
|
2020-04-20 10:19:21 +08:00
|
|
|
|
|
|
|
public:
|
2020-07-10 18:34:39 +08:00
|
|
|
virtual String get_name() const override { return "ShaderFile"; }
|
|
|
|
bool has_main_screen() const override { return false; }
|
|
|
|
virtual void edit(Object *p_object) override;
|
|
|
|
virtual bool handles(Object *p_object) const override;
|
|
|
|
virtual void make_visible(bool p_visible) override;
|
2020-04-20 10:19:21 +08:00
|
|
|
|
|
|
|
ShaderFileEditor *get_shader_editor() const { return shader_editor; }
|
|
|
|
|
2022-01-27 17:36:51 +08:00
|
|
|
ShaderFileEditorPlugin();
|
2020-04-20 10:19:21 +08:00
|
|
|
~ShaderFileEditorPlugin();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SHADER_FILE_EDITOR_PLUGIN_H
|