diff options
Diffstat (limited to 'editor/project_settings_editor.cpp')
-rw-r--r-- | editor/project_settings_editor.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 2da49f11cc..28111bed58 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -36,6 +36,7 @@ #include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "editor/editor_undo_redo_manager.h" +#include "scene/gui/check_button.h" #include "servers/movie_writer/movie_writer.h" ProjectSettingsEditor *ProjectSettingsEditor::singleton = nullptr; @@ -72,6 +73,11 @@ void ProjectSettingsEditor::set_plugins_page() { tab_container->set_current_tab(tab_container->get_tab_idx_from_control(plugin_settings)); } +void ProjectSettingsEditor::set_general_page(const String &p_category) { + tab_container->set_current_tab(tab_container->get_tab_idx_from_control(general_editor)); + general_settings_inspector->set_current_section(p_category); +} + void ProjectSettingsEditor::update_plugins() { plugin_settings->update_plugins(); } @@ -108,6 +114,7 @@ void ProjectSettingsEditor::_add_setting() { Variant value; Variant::construct(Variant::Type(type_box->get_selected_id()), value, nullptr, 0, ce); + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Add Project Setting")); undo_redo->add_do_property(ps, setting, value); undo_redo->add_undo_property(ps, setting, ps->has_setting(setting) ? ps->get(setting) : Variant()); @@ -127,6 +134,7 @@ void ProjectSettingsEditor::_delete_setting() { Variant value = ps->get(setting); int order = ps->get_order(setting); + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Delete Item")); undo_redo->add_do_method(ps, "clear", setting); @@ -215,9 +223,9 @@ void ProjectSettingsEditor::_select_type(Variant::Type p_type) { void ProjectSettingsEditor::shortcut_input(const Ref<InputEvent> &p_event) { ERR_FAIL_COND(p_event.is_null()); + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); const Ref<InputEventKey> k = p_event; - if (k.is_valid() && k->is_pressed()) { bool handled = false; @@ -333,6 +341,7 @@ void ProjectSettingsEditor::_action_added(const String &p_name) { action["events"] = Array(); action["deadzone"] = 0.5f; + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Add Input Action")); undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", name, action); undo_redo->add_undo_method(ProjectSettings::get_singleton(), "clear", name); @@ -346,8 +355,9 @@ void ProjectSettingsEditor::_action_added(const String &p_name) { void ProjectSettingsEditor::_action_edited(const String &p_name, const Dictionary &p_action) { const String property_name = "input/" + p_name; - Dictionary old_val = ProjectSettings::get_singleton()->get(property_name); + Dictionary old_val = GLOBAL_GET(property_name); + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); if (old_val["deadzone"] != p_action["deadzone"]) { // Deadzone Changed undo_redo->create_action(TTR("Change Action deadzone")); @@ -356,12 +366,12 @@ void ProjectSettingsEditor::_action_edited(const String &p_name, const Dictionar } else { // Events changed - int event_count = ((Array)p_action["events"]).size(); + int act_event_count = ((Array)p_action["events"]).size(); int old_event_count = ((Array)old_val["events"]).size(); - if (event_count == old_event_count) { + if (act_event_count == old_event_count) { undo_redo->create_action(TTR("Edit Input Action Event")); - } else if (event_count > old_event_count) { + } else if (act_event_count > old_event_count) { undo_redo->create_action(TTR("Add Input Action Event")); } else { undo_redo->create_action(TTR("Remove Input Action Event")); @@ -381,9 +391,10 @@ void ProjectSettingsEditor::_action_edited(const String &p_name, const Dictionar void ProjectSettingsEditor::_action_removed(const String &p_name) { const String property_name = "input/" + p_name; - Dictionary old_val = ProjectSettings::get_singleton()->get(property_name); + Dictionary old_val = GLOBAL_GET(property_name); int order = ProjectSettings::get_singleton()->get_order(property_name); + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Erase Input Action")); undo_redo->add_do_method(ProjectSettings::get_singleton(), "clear", property_name); undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", property_name, old_val); @@ -404,8 +415,9 @@ void ProjectSettingsEditor::_action_renamed(const String &p_old_name, const Stri "An action with this name already exists."); int order = ProjectSettings::get_singleton()->get_order(old_property_name); - Dictionary action = ProjectSettings::get_singleton()->get(old_property_name); + Dictionary action = GLOBAL_GET(old_property_name); + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Rename Input Action Event")); // Do: clear old, set new undo_redo->add_do_method(ProjectSettings::get_singleton(), "clear", old_property_name); @@ -435,6 +447,7 @@ void ProjectSettingsEditor::_action_reordered(const String &p_action_name, const HashMap<String, Variant> action_values; ProjectSettings::get_singleton()->get_property_list(&props); + Ref<EditorUndoRedoManager> &undo_redo = EditorNode::get_undo_redo(); undo_redo->create_action(TTR("Update Input Action Order")); for (const PropertyInfo &prop : props) { @@ -499,7 +512,7 @@ void ProjectSettingsEditor::_update_action_map_editor() { // Strip the "input/" from the left. String display_name = property_name.substr(String("input/").size() - 1); - Dictionary action = ProjectSettings::get_singleton()->get(property_name); + Dictionary action = GLOBAL_GET(property_name); ActionMapEditor::ActionInfo action_info; action_info.action = action; @@ -567,7 +580,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { set_title(TTR("Project Settings (project.godot)")); ps = ProjectSettings::get_singleton(); - undo_redo = p_data->get_undo_redo(); data = p_data; tab_container = memnew(TabContainer); @@ -575,7 +587,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { tab_container->set_theme_type_variation("TabContainerOdd"); add_child(tab_container); - VBoxContainer *general_editor = memnew(VBoxContainer); + general_editor = memnew(VBoxContainer); general_editor->set_name(TTR("General")); general_editor->set_alignment(BoxContainer::ALIGNMENT_BEGIN); general_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); @@ -626,7 +638,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { custom_properties->add_child(del_button); general_settings_inspector = memnew(SectionedInspector); - general_settings_inspector->get_inspector()->set_undo_redo(EditorNode::get_undo_redo()); general_settings_inspector->set_v_size_flags(Control::SIZE_EXPAND_FILL); general_settings_inspector->register_search_box(search_box); general_settings_inspector->get_inspector()->set_use_filter(true); |