diff options
Diffstat (limited to 'editor/shader_globals_editor.cpp')
-rw-r--r-- | editor/shader_globals_editor.cpp | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/editor/shader_globals_editor.cpp b/editor/shader_globals_editor.cpp index 1cd1b4ea00..eef0f3eae1 100644 --- a/editor/shader_globals_editor.cpp +++ b/editor/shader_globals_editor.cpp @@ -32,6 +32,7 @@ #include "core/config/project_settings.h" #include "editor/editor_node.h" +#include "editor/editor_undo_redo_manager.h" #include "servers/rendering/shader_language.h" static const char *global_var_type_names[RS::GLOBAL_VAR_TYPE_MAX] = { @@ -79,18 +80,18 @@ protected: } bool _set(const StringName &p_name, const Variant &p_value) { - Variant existing = RS::get_singleton()->global_shader_uniform_get(p_name); + Variant existing = RS::get_singleton()->global_shader_parameter_get(p_name); if (existing.get_type() == Variant::NIL) { return false; } - UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); + Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Set Shader Global Variable")); - undo_redo->add_do_method(RS::get_singleton(), "global_shader_uniform_set", p_name, p_value); - undo_redo->add_undo_method(RS::get_singleton(), "global_shader_uniform_set", p_name, existing); - RS::GlobalShaderUniformType type = RS::get_singleton()->global_shader_uniform_get_type(p_name); + undo_redo->add_do_method(RS::get_singleton(), "global_shader_parameter_set", p_name, p_value); + undo_redo->add_undo_method(RS::get_singleton(), "global_shader_parameter_set", p_name, existing); + RS::GlobalShaderParameterType type = RS::get_singleton()->global_shader_parameter_get_type(p_name); Dictionary gv; gv["type"] = global_var_type_names[type]; if (type >= RS::GLOBAL_VAR_TYPE_SAMPLER2D) { @@ -117,17 +118,17 @@ protected: } bool _get(const StringName &p_name, Variant &r_ret) const { - r_ret = RS::get_singleton()->global_shader_uniform_get(p_name); + r_ret = RS::get_singleton()->global_shader_parameter_get(p_name); return r_ret.get_type() != Variant::NIL; } void _get_property_list(List<PropertyInfo> *p_list) const { Vector<StringName> variables; - variables = RS::get_singleton()->global_shader_uniform_get_list(); + variables = RS::get_singleton()->global_shader_parameter_get_list(); for (int i = 0; i < variables.size(); i++) { PropertyInfo pinfo; pinfo.name = variables[i]; - switch (RS::get_singleton()->global_shader_uniform_get_type(variables[i])) { + switch (RS::get_singleton()->global_shader_parameter_get_type(variables[i])) { case RS::GLOBAL_VAR_TYPE_BOOL: { pinfo.type = Variant::BOOL; } break; @@ -241,7 +242,7 @@ public: } }; -static Variant create_var(RS::GlobalShaderUniformType p_type) { +static Variant create_var(RS::GlobalShaderParameterType p_type) { switch (p_type) { case RS::GLOBAL_VAR_TYPE_BOOL: { return false; @@ -380,8 +381,8 @@ void ShaderGlobalsEditor::_variable_added() { return; } - if (RenderingServer::get_singleton()->global_shader_uniform_get(var).get_type() != Variant::NIL) { - EditorNode::get_singleton()->show_warning(vformat(TTR("Global shader uniform '%s' already exists'"), var)); + if (RenderingServer::get_singleton()->global_shader_parameter_get(var).get_type() != Variant::NIL) { + EditorNode::get_singleton()->show_warning(vformat(TTR("Global shader parameter '%s' already exists'"), var)); return; } @@ -393,13 +394,13 @@ void ShaderGlobalsEditor::_variable_added() { return; } - UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); + Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_singleton()->get_undo_redo(); - Variant value = create_var(RS::GlobalShaderUniformType(variable_type->get_selected())); + Variant value = create_var(RS::GlobalShaderParameterType(variable_type->get_selected())); - undo_redo->create_action(TTR("Add Shader Global Uniform")); - undo_redo->add_do_method(RS::get_singleton(), "global_shader_uniform_add", var, RS::GlobalShaderUniformType(variable_type->get_selected()), value); - undo_redo->add_undo_method(RS::get_singleton(), "global_shader_uniform_remove", var); + undo_redo->create_action(TTR("Add Shader Global Parameter")); + undo_redo->add_do_method(RS::get_singleton(), "global_shader_parameter_add", var, RS::GlobalShaderParameterType(variable_type->get_selected()), value); + undo_redo->add_undo_method(RS::get_singleton(), "global_shader_parameter_remove", var); Dictionary gv; gv["type"] = global_var_type_names[variable_type->get_selected()]; gv["value"] = value; @@ -412,11 +413,11 @@ void ShaderGlobalsEditor::_variable_added() { } void ShaderGlobalsEditor::_variable_deleted(const String &p_variable) { - UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); + Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_singleton()->get_undo_redo(); - undo_redo->create_action(TTR("Add Shader Global Uniform")); - undo_redo->add_do_method(RS::get_singleton(), "global_shader_uniform_remove", p_variable); - undo_redo->add_undo_method(RS::get_singleton(), "global_shader_uniform_add", p_variable, RS::get_singleton()->global_shader_uniform_get_type(p_variable), RS::get_singleton()->global_shader_uniform_get(p_variable)); + undo_redo->create_action(TTR("Add Shader Global Parameter")); + undo_redo->add_do_method(RS::get_singleton(), "global_shader_parameter_remove", p_variable); + undo_redo->add_undo_method(RS::get_singleton(), "global_shader_parameter_add", p_variable, RS::get_singleton()->global_shader_parameter_get_type(p_variable), RS::get_singleton()->global_shader_parameter_get(p_variable)); undo_redo->add_do_property(ProjectSettings::get_singleton(), "shader_globals/" + p_variable, Variant()); undo_redo->add_undo_property(ProjectSettings::get_singleton(), "shader_globals/" + p_variable, ProjectSettings::get_singleton()->get("shader_globals/" + p_variable)); |