diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-04-06 23:36:37 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-04-06 23:49:27 -0300 |
commit | 74808ac4d9176180dc7ecace99723edab8a73e0e (patch) | |
tree | 065e903073bbdebe864bb6322ca0abc2fca108bb /editor/plugins/shader_editor_plugin.cpp | |
parent | 25d09b92be0f5d86cdee6eada80823cdcc2d42bc (diff) |
New particle system, mostly working, some small features missing.
Diffstat (limited to 'editor/plugins/shader_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/shader_editor_plugin.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 11dfb7b910..37782ed173 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -137,14 +137,35 @@ void ShaderTextEditor::_load_theme_settings() { }*/ } +void ShaderTextEditor::_check_shader_mode() { + + String type = ShaderLanguage::get_shader_type(get_text_edit()->get_text()); + + print_line("type is: " + type); + Shader::Mode mode; + + if (type == "canvas_item") { + mode = Shader::MODE_CANVAS_ITEM; + } else if (type == "particles") { + mode = Shader::MODE_PARTICLES; + } else { + mode = Shader::MODE_SPATIAL; + } + + if (shader->get_mode() != mode) { + shader->set_code(get_text_edit()->get_text()); + _load_theme_settings(); + } +} + void ShaderTextEditor::_code_complete_script(const String &p_code, List<String> *r_options) { - print_line("code complete"); + _check_shader_mode(); ShaderLanguage sl; String calltip; - Error err = sl.complete(p_code, ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())), r_options, calltip); + Error err = sl.complete(p_code, ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types(), r_options, calltip); if (calltip != "") { get_text_edit()->set_code_hint(calltip); @@ -153,13 +174,15 @@ void ShaderTextEditor::_code_complete_script(const String &p_code, List<String> void ShaderTextEditor::_validate_script() { + _check_shader_mode(); + String code = get_text_edit()->get_text(); //List<StringName> params; //shader->get_param_list(¶ms); ShaderLanguage sl; - Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode()))); + Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(VisualServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types()); if (err != OK) { String error_text = "error(" + itos(sl.get_error_line()) + "): " + sl.get_error_text(); |