diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-05-07 00:48:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-07 00:48:15 +0200 |
commit | 49b556a9f112be63b1c188dfb7ba055db7118471 (patch) | |
tree | d7e008f2d3e9be49abd16f3592decb3c07de7405 | |
parent | 04e995dd5d864f04a89ce02d957a425bd5109810 (diff) | |
parent | c316a515ed70c6449040e17579bc92998b35d8da (diff) |
Merge pull request #48491 from dalexeev/action-map-editor
Improve ActionMapEditor
-rw-r--r-- | editor/action_map_editor.cpp | 46 | ||||
-rw-r--r-- | editor/action_map_editor.h | 10 | ||||
-rw-r--r-- | editor/project_settings_editor.cpp | 2 |
3 files changed, 15 insertions, 43 deletions
diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp index 9949fd8199..c0d5716c4e 100644 --- a/editor/action_map_editor.cpp +++ b/editor/action_map_editor.cpp @@ -730,10 +730,6 @@ void ActionMapEditor::_add_action_pressed() { } void ActionMapEditor::_add_action(const String &p_name) { - if (!allow_editing_actions) { - return; - } - if (p_name == "" || !_is_action_name_valid(p_name)) { show_message(TTR("Invalid action name. it cannot be.is_empty()() nor contain '/', ':', '=', '\\' or '\"'")); return; @@ -744,10 +740,6 @@ void ActionMapEditor::_add_action(const String &p_name) { } void ActionMapEditor::_action_edited() { - if (!allow_editing_actions) { - return; - } - TreeItem *ti = action_tree->get_edited(); if (!ti) { return; @@ -812,10 +804,6 @@ void ActionMapEditor::_tree_button_pressed(Object *p_item, int p_column, int p_i } break; case ActionMapEditor::BUTTON_REMOVE_ACTION: { - if (!allow_editing_actions) { - break; - } - // Send removed action name String name = item->get_meta("__name"); emit_signal("action_removed", name); @@ -848,11 +836,11 @@ void ActionMapEditor::_tree_item_activated() { _tree_button_pressed(item, 2, BUTTON_EDIT_EVENT); } -void ActionMapEditor::set_show_uneditable(bool p_show) { - show_uneditable = p_show; - show_uneditable_actions_checkbox->set_pressed(p_show); +void ActionMapEditor::set_show_builtin_actions(bool p_show) { + show_builtin_actions = p_show; + show_builtin_actions_checkbutton->set_pressed(p_show); - // Prevent unnecessary updates of action list when cache is.is_empty()(). + // Prevent unnecessary updates of action list when cache is empty. if (!actions_cache.is_empty()) { update_action_list(); } @@ -1022,7 +1010,7 @@ void ActionMapEditor::update_action_list(const Vector<ActionInfo> &p_action_info continue; } - if (!action_info.editable && !show_uneditable) { + if (!action_info.editable && !show_builtin_actions) { continue; } @@ -1080,15 +1068,6 @@ void ActionMapEditor::show_message(const String &p_message) { message->popup_centered(Size2(300, 100) * EDSCALE); } -void ActionMapEditor::set_allow_editing_actions(bool p_allow) { - allow_editing_actions = p_allow; - add_hbox->set_visible(p_allow); -} - -void ActionMapEditor::set_toggle_editable_label(const String &p_label) { - show_uneditable_actions_checkbox->set_text(p_label); -} - void ActionMapEditor::use_external_search_box(LineEdit *p_searchbox) { memdelete(action_list_search); action_list_search = p_searchbox; @@ -1096,8 +1075,7 @@ void ActionMapEditor::use_external_search_box(LineEdit *p_searchbox) { } ActionMapEditor::ActionMapEditor() { - allow_editing_actions = true; - show_uneditable = true; + show_builtin_actions = false; // Main Vbox Container VBoxContainer *main_vbox = memnew(VBoxContainer); @@ -1114,11 +1092,11 @@ ActionMapEditor::ActionMapEditor() { action_list_search->connect("text_changed", callable_mp(this, &ActionMapEditor::_search_term_updated)); top_hbox->add_child(action_list_search); - show_uneditable_actions_checkbox = memnew(CheckBox); - show_uneditable_actions_checkbox->set_pressed(false); - show_uneditable_actions_checkbox->set_text(TTR("Show Uneditable Actions")); - show_uneditable_actions_checkbox->connect("toggled", callable_mp(this, &ActionMapEditor::set_show_uneditable)); - top_hbox->add_child(show_uneditable_actions_checkbox); + 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->connect("toggled", callable_mp(this, &ActionMapEditor::set_show_builtin_actions)); + top_hbox->add_child(show_builtin_actions_checkbutton); // Adding Action line edit + button add_hbox = memnew(HBoxContainer); @@ -1132,7 +1110,7 @@ ActionMapEditor::ActionMapEditor() { add_hbox->add_child(add_edit); Button *add_button = memnew(Button); - add_button->set_text("Add"); + add_button->set_text(TTR("Add")); add_button->connect("pressed", callable_mp(this, &ActionMapEditor::_add_action_pressed)); add_hbox->add_child(add_button); diff --git a/editor/action_map_editor.h b/editor/action_map_editor.h index f1f7bffef4..fb097ddfdd 100644 --- a/editor/action_map_editor.h +++ b/editor/action_map_editor.h @@ -156,11 +156,10 @@ private: // Filtering and Adding actions - bool show_uneditable; - CheckBox *show_uneditable_actions_checkbox; + bool show_builtin_actions; + CheckButton *show_builtin_actions_checkbutton; LineEdit *action_list_search; - bool allow_editing_actions; HBoxContainer *add_hbox; LineEdit *add_edit; @@ -190,10 +189,7 @@ public: void update_action_list(const Vector<ActionInfo> &p_action_infos = Vector<ActionInfo>()); void show_message(const String &p_message); - void set_show_uneditable(bool p_show); - void set_allow_editing_actions(bool p_allow); - - void set_toggle_editable_label(const String &p_label); + void set_show_builtin_actions(bool p_show); void use_external_search_box(LineEdit *p_searchbox); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index faec3355ac..76290b4b62 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -649,8 +649,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { action_map->connect("action_removed", callable_mp(this, &ProjectSettingsEditor::_action_removed)); action_map->connect("action_renamed", callable_mp(this, &ProjectSettingsEditor::_action_renamed)); action_map->connect("action_reordered", callable_mp(this, &ProjectSettingsEditor::_action_reordered)); - action_map->set_toggle_editable_label(TTR("Show Built-in Actions")); - action_map->set_show_uneditable(false); tab_container->add_child(action_map); localization_editor = memnew(LocalizationEditor); |