diff options
Diffstat (limited to 'editor/plugins/shader_editor_plugin.cpp')
| -rw-r--r-- | editor/plugins/shader_editor_plugin.cpp | 124 |
1 files changed, 10 insertions, 114 deletions
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index bad88979ac..069a0c4292 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -29,20 +29,17 @@ /*************************************************************************/ #include "shader_editor_plugin.h" +#include "core/io/resource_loader.h" +#include "core/io/resource_saver.h" +#include "core/os/keyboard.h" +#include "core/os/os.h" #include "editor/editor_node.h" #include "editor/editor_settings.h" #include "editor/property_editor.h" -#include "io/resource_loader.h" -#include "io/resource_saver.h" -#include "os/keyboard.h" -#include "os/os.h" #include "scene/resources/shader_graph.h" #include "servers/visual/shader_types.h" -#include "spatial_editor_plugin.h" -/*** SETTINGS EDITOR ****/ - -/*** SCRIPT EDITOR ****/ +/*** SHADER SCRIPT EDITOR ****/ Ref<Shader> ShaderTextEditor::get_edited_shader() const { @@ -255,9 +252,6 @@ void ShaderEditor::_menu_option(int p_option) { current->get_find_replace_bar()->popup_replace(); } break; - //case SEARCH_LOCATE_SYMBOL: { - - //} break; case SEARCH_GOTO_LINE: { goto_line_dialog->popup_find_line(current->get_text_edit()); @@ -277,90 +271,6 @@ void ShaderEditor::_notification(int p_what) { } } -Dictionary ShaderEditor::get_state() const { -#if 0 - apply_shaders(); - - Dictionary state; - - Array paths; - int open=-1; - - for(int i=0;i<tab_container->get_child_count();i++) { - - ShaderTextEditor *ste = tab_container->get_child(i)->cast_to<ShaderTextEditor>(); - if (!ste) - continue; - - - Ref<Shader> shader = ste->get_edited_shader(); - if (shader->get_path()!="" && shader->get_path().find("local://")==-1 && shader->get_path().find("::")==-1) { - - paths.push_back(shader->get_path()); - } else { - - - const Node *owner = _find_node_with_shader(get_root_node(),shader.get_ref_ptr()); - if (owner) - paths.push_back(owner->get_path()); - - } - - if (i==tab_container->get_current_tab()) - open=i; - } - - if (paths.size()) - state["sources"]=paths; - if (open!=-1) - state["current"]=open; - - - return state; -#endif - return Dictionary(); -} -void ShaderEditor::set_state(const Dictionary &p_state) { -#if 0 - print_line("setting state.."); - if (!p_state.has("sources")) - return; //bleh - - Array sources = p_state["sources"]; - for(int i=0;i<sources.size();i++) { - - Variant source=sources[i]; - - Ref<Shader> shader; - - if (source.get_type()==Variant::NODE_PATH) { - - print_line("cain find owner at path "+String(source)); - Node *owner=get_root_node()->get_node(source); - if (!owner) - continue; - - shader = owner->get_shader(); - } else if (source.get_type()==Variant::STRING) { - - print_line("loading at path "+String(source)); - shader = ResourceLoader::load(source,"Shader"); - } - - print_line("found shader at "+String(source)+"? - "+itos(shader.is_null())); - if (shader.is_null()) //ah well.. - continue; - - get_scene()->get_root_node()->call("_resource_selected",shader); - } - - if (p_state.has("current")) - tab_container->set_current_tab(p_state["current"]); -#endif -} -void ShaderEditor::clear() { -} - void ShaderEditor::_params_changed() { shader_editor->_validate_script(); @@ -397,7 +307,7 @@ void ShaderEditor::ensure_select_current() { /* if (tab_container->get_child_count() && tab_container->get_current_tab()>=0) { - ShaderTextEditor *ste = tab_container->get_child(tab_container->get_current_tab())->cast_to<ShaderTextEditor>(); + ShaderTextEditor *ste = Object::cast_to<ShaderTextEditor>(tab_container->get_child(tab_container->get_current_tab())); if (!ste) return; Ref<Shader> shader = ste->get_edited_shader(); @@ -486,16 +396,16 @@ ShaderEditor::ShaderEditor() { void ShaderEditorPlugin::edit(Object *p_object) { - Shader *s = p_object->cast_to<Shader>(); + Shader *s = Object::cast_to<Shader>(p_object); shader_editor->edit(s); } bool ShaderEditorPlugin::handles(Object *p_object) const { bool handles = true; - Shader *shader = p_object->cast_to<Shader>(); + Shader *shader = Object::cast_to<Shader>(p_object); /* - if (!shader || shader->cast_to<ShaderGraph>()) // Don't handle ShaderGraph's + if (Object::cast_to<ShaderGraph>(shader)) // Don't handle ShaderGraph's handles = false; */ @@ -522,20 +432,6 @@ void ShaderEditorPlugin::selected_notify() { shader_editor->ensure_select_current(); } -Dictionary ShaderEditorPlugin::get_state() const { - - return shader_editor->get_state(); -} - -void ShaderEditorPlugin::set_state(const Dictionary &p_state) { - - shader_editor->set_state(p_state); -} -void ShaderEditorPlugin::clear() { - - shader_editor->clear(); -} - void ShaderEditorPlugin::save_external_data() { shader_editor->save_external_data(); |
