save show built-in actions button state

This commit is contained in:
jsjtxietian 2023-08-22 15:44:20 +08:00
parent 8e0346bade
commit 9c1278cae8

View File

@ -31,6 +31,7 @@
#include "editor/action_map_editor.h" #include "editor/action_map_editor.h"
#include "editor/editor_scale.h" #include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/event_listener_line_edit.h" #include "editor/event_listener_line_edit.h"
#include "editor/input_event_configuration_dialog.h" #include "editor/input_event_configuration_dialog.h"
#include "scene/gui/check_button.h" #include "scene/gui/check_button.h"
@ -224,6 +225,7 @@ void ActionMapEditor::_tree_item_activated() {
void ActionMapEditor::set_show_builtin_actions(bool p_show) { void ActionMapEditor::set_show_builtin_actions(bool p_show) {
show_builtin_actions = p_show; show_builtin_actions = p_show;
show_builtin_actions_checkbutton->set_pressed(p_show); show_builtin_actions_checkbutton->set_pressed(p_show);
EditorSettings::get_singleton()->set_project_metadata("project_settings", "show_builtin_actions", show_builtin_actions);
// Prevent unnecessary updates of action list when cache is empty. // Prevent unnecessary updates of action list when cache is empty.
if (!actions_cache.is_empty()) { if (!actions_cache.is_empty()) {
@ -568,11 +570,13 @@ ActionMapEditor::ActionMapEditor() {
_add_edit_text_changed(add_edit->get_text()); _add_edit_text_changed(add_edit->get_text());
show_builtin_actions_checkbutton = memnew(CheckButton); show_builtin_actions_checkbutton = memnew(CheckButton);
show_builtin_actions_checkbutton->set_pressed(false);
show_builtin_actions_checkbutton->set_text(TTR("Show Built-in Actions")); show_builtin_actions_checkbutton->set_text(TTR("Show Built-in Actions"));
show_builtin_actions_checkbutton->connect("toggled", callable_mp(this, &ActionMapEditor::set_show_builtin_actions)); show_builtin_actions_checkbutton->connect("toggled", callable_mp(this, &ActionMapEditor::set_show_builtin_actions));
add_hbox->add_child(show_builtin_actions_checkbutton); add_hbox->add_child(show_builtin_actions_checkbutton);
show_builtin_actions = EditorSettings::get_singleton()->get_project_metadata("project_settings", "show_builtin_actions", false);
show_builtin_actions_checkbutton->set_pressed(show_builtin_actions);
main_vbox->add_child(add_hbox); main_vbox->add_child(add_hbox);
// Action Editor Tree // Action Editor Tree