summaryrefslogtreecommitdiff
path: root/editor/project_settings_editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/project_settings_editor.cpp')
-rw-r--r--editor/project_settings_editor.cpp138
1 files changed, 76 insertions, 62 deletions
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 0428aafe7e..9bee84b482 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,9 @@
#include "core/os/keyboard.h"
#include "core/project_settings.h"
#include "core/translation.h"
+#include "editor/editor_export.h"
#include "editor/editor_node.h"
+#include "editor/editor_scale.h"
#include "scene/gui/margin_container.h"
#include "scene/gui/tab_container.h"
@@ -106,7 +108,7 @@ void ProjectSettingsEditor::_notification(int p_what) {
action_add_error->add_color_override("font_color", get_color("error_color", "Editor"));
- translation_list->connect("button_pressed", this, "_translation_delete");
+ translation_list->connect_compat("button_pressed", this, "_translation_delete");
_update_actions();
popup_add->add_icon_item(get_icon("Keyboard", "EditorIcons"), TTR("Key "), INPUT_KEY); //"Key " - because the word 'key' has already been used as a key animation
popup_add->add_icon_item(get_icon("JoyButton", "EditorIcons"), TTR("Joy Button"), INPUT_JOY_BUTTON);
@@ -717,9 +719,18 @@ void ProjectSettingsEditor::_update_actions() {
item->set_range(1, action["deadzone"]);
item->set_custom_bg_color(1, get_color("prop_subsection", "Editor"));
+ const bool is_builtin_input = ProjectSettings::get_singleton()->get_input_presets().find(pi.name) != NULL;
+ const String tooltip = is_builtin_input ? TTR("Built-in actions can't be removed as they're used for UI navigation.") : TTR("Remove");
item->add_button(2, get_icon("Add", "EditorIcons"), 1, false, TTR("Add Event"));
- if (!ProjectSettings::get_singleton()->get_input_presets().find(pi.name)) {
- item->add_button(2, get_icon("Remove", "EditorIcons"), 2, false, TTR("Remove"));
+ item->add_button(2, get_icon("Remove", "EditorIcons"), 2, false, tooltip);
+
+ if (is_builtin_input) {
+ // Built-in action (like `ui_up`). Make the action not removable,
+ // but still display the button so the "Add" button is at the same
+ // horizontal position as for custom actions.
+ item->set_button_disabled(2, 1, true);
+ } else {
+ // Not a built-in action. Make the action name editable.
item->set_editable(0, true);
}
@@ -745,10 +756,9 @@ void ProjectSettingsEditor::_update_actions() {
if (jb.is_valid()) {
String str = _get_device_string(jb->get_device()) + ", " + TTR("Button") + " " + itos(jb->get_button_index());
- if (jb->get_button_index() >= 0 && jb->get_button_index() < JOY_BUTTON_MAX)
- str += String() + " (" + _button_names[jb->get_button_index()] + ").";
- else
- str += ".";
+ if (jb->get_button_index() >= 0 && jb->get_button_index() < JOY_BUTTON_MAX) {
+ str += String() + " (" + _button_names[jb->get_button_index()] + ")";
+ }
action2->set_text(0, str);
action2->set_icon(0, get_icon("JoyButton", "EditorIcons"));
@@ -759,12 +769,12 @@ void ProjectSettingsEditor::_update_actions() {
if (mb.is_valid()) {
String str = _get_device_string(mb->get_device()) + ", ";
switch (mb->get_button_index()) {
- case BUTTON_LEFT: str += TTR("Left Button."); break;
- case BUTTON_RIGHT: str += TTR("Right Button."); break;
- case BUTTON_MIDDLE: str += TTR("Middle Button."); break;
- case BUTTON_WHEEL_UP: str += TTR("Wheel Up."); break;
- case BUTTON_WHEEL_DOWN: str += TTR("Wheel Down."); break;
- default: str += TTR("Button") + " " + itos(mb->get_button_index()) + ".";
+ case BUTTON_LEFT: str += TTR("Left Button"); break;
+ case BUTTON_RIGHT: str += TTR("Right Button"); break;
+ case BUTTON_MIDDLE: str += TTR("Middle Button"); break;
+ case BUTTON_WHEEL_UP: str += TTR("Wheel Up"); break;
+ case BUTTON_WHEEL_DOWN: str += TTR("Wheel Down"); break;
+ default: str += vformat(TTR("%d Button"), mb->get_button_index());
}
action2->set_text(0, str);
@@ -778,7 +788,7 @@ void ProjectSettingsEditor::_update_actions() {
int ax = jm->get_axis();
int n = 2 * ax + (jm->get_axis_value() < 0 ? 0 : 1);
String desc = _axis_names[n];
- String str = _get_device_string(jm->get_device()) + ", " + TTR("Axis") + " " + itos(ax) + " " + (jm->get_axis_value() < 0 ? "-" : "+") + desc + ".";
+ String str = _get_device_string(jm->get_device()) + ", " + TTR("Axis") + " " + itos(ax) + " " + (jm->get_axis_value() < 0 ? "-" : "+") + desc;
action2->set_text(0, str);
action2->set_icon(0, get_icon("JoyAxis", "EditorIcons"));
}
@@ -787,6 +797,10 @@ void ProjectSettingsEditor::_update_actions() {
action2->add_button(2, get_icon("Edit", "EditorIcons"), 3, false, TTR("Edit"));
action2->add_button(2, get_icon("Remove", "EditorIcons"), 2, false, TTR("Remove"));
+ // Fade out the individual event buttons slightly to make the
+ // Add/Remove buttons stand out more.
+ action2->set_button_color(2, 0, Color(1, 1, 1, 0.75));
+ action2->set_button_color(2, 1, Color(1, 1, 1, 0.75));
}
}
@@ -833,7 +847,7 @@ void ProjectSettingsEditor::_item_add() {
// Initialize the property with the default value for the given type.
// The type list starts at 1 (as we exclude Nil), so add 1 to the selected value.
- Variant::CallError ce;
+ Callable::CallError ce;
const Variant value = Variant::construct(Variant::Type(type->get_selected() + 1), NULL, 0, ce);
String catname = category->get_text().strip_edges();
@@ -1174,7 +1188,7 @@ void ProjectSettingsEditor::add_translation(const String &p_translation) {
void ProjectSettingsEditor::_translation_add(const String &p_path) {
- PoolStringArray translations = ProjectSettings::get_singleton()->get("locale/translations");
+ PackedStringArray translations = ProjectSettings::get_singleton()->get("locale/translations");
for (int i = 0; i < translations.size(); i++) {
@@ -1205,7 +1219,7 @@ void ProjectSettingsEditor::_translation_delete(Object *p_item, int p_column, in
int idx = ti->get_metadata(0);
- PoolStringArray translations = ProjectSettings::get_singleton()->get("locale/translations");
+ PackedStringArray translations = ProjectSettings::get_singleton()->get("locale/translations");
ERR_FAIL_INDEX(idx, translations.size());
@@ -1239,7 +1253,7 @@ void ProjectSettingsEditor::_translation_res_add(const String &p_path) {
if (remaps.has(p_path))
return; //pointless already has it
- remaps[p_path] = PoolStringArray();
+ remaps[p_path] = PackedStringArray();
undo_redo->create_action(TTR("Add Remapped Path"));
undo_redo->add_do_property(ProjectSettings::get_singleton(), "locale/translation_remaps", remaps);
@@ -1267,7 +1281,7 @@ void ProjectSettingsEditor::_translation_res_option_add(const String &p_path) {
String key = k->get_metadata(0);
ERR_FAIL_COND(!remaps.has(key));
- PoolStringArray r = remaps[key];
+ PackedStringArray r = remaps[key];
r.push_back(p_path + ":" + "en");
remaps[key] = r;
@@ -1314,7 +1328,7 @@ void ProjectSettingsEditor::_translation_res_option_changed() {
ERR_FAIL_INDEX(which, langs.size());
ERR_FAIL_COND(!remaps.has(key));
- PoolStringArray r = remaps[key];
+ PackedStringArray r = remaps[key];
ERR_FAIL_INDEX(idx, r.size());
if (translation_locales_idxs_remap.size() > which) {
r.set(idx, path + ":" + langs[translation_locales_idxs_remap[which]]);
@@ -1381,7 +1395,7 @@ void ProjectSettingsEditor::_translation_res_option_delete(Object *p_item, int p
int idx = ed->get_metadata(0);
ERR_FAIL_COND(!remaps.has(key));
- PoolStringArray r = remaps[key];
+ PackedStringArray r = remaps[key];
ERR_FAIL_INDEX(idx, r.size());
r.remove(idx);
remaps[key] = r;
@@ -1492,7 +1506,7 @@ void ProjectSettingsEditor::_update_translations() {
translation_list->set_hide_root(true);
if (ProjectSettings::get_singleton()->has_setting("locale/translations")) {
- PoolStringArray translations = ProjectSettings::get_singleton()->get("locale/translations");
+ PackedStringArray translations = ProjectSettings::get_singleton()->get("locale/translations");
for (int i = 0; i < translations.size(); i++) {
TreeItem *t = translation_list->create_item(root);
@@ -1628,7 +1642,7 @@ void ProjectSettingsEditor::_update_translations() {
t->select(0);
translation_res_option_add_button->set_disabled(false);
- PoolStringArray selected = remaps[keys[i]];
+ PackedStringArray selected = remaps[keys[i]];
for (int j = 0; j < selected.size(); j++) {
String s2 = selected[j];
@@ -1791,7 +1805,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
search_button->set_pressed(false);
search_button->set_text(TTR("Search"));
hbc->add_child(search_button);
- search_button->connect("toggled", this, "_toggle_search_bar");
+ search_button->connect_compat("toggled", this, "_toggle_search_bar");
hbc->add_child(memnew(VSeparator));
@@ -1806,7 +1820,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
category = memnew(LineEdit);
category->set_h_size_flags(Control::SIZE_EXPAND_FILL);
add_prop_bar->add_child(category);
- category->connect("text_entered", this, "_item_adds");
+ category->connect_compat("text_entered", this, "_item_adds");
l = memnew(Label);
add_prop_bar->add_child(l);
@@ -1815,7 +1829,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
property = memnew(LineEdit);
property->set_h_size_flags(Control::SIZE_EXPAND_FILL);
add_prop_bar->add_child(property);
- property->connect("text_entered", this, "_item_adds");
+ property->connect_compat("text_entered", this, "_item_adds");
l = memnew(Label);
add_prop_bar->add_child(l);
@@ -1833,7 +1847,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
Button *add = memnew(Button);
add_prop_bar->add_child(add);
add->set_text(TTR("Add"));
- add->connect("pressed", this, "_item_add");
+ add->connect_compat("pressed", this, "_item_add");
search_bar = memnew(HBoxContainer);
search_bar->set_h_size_flags(Control::SIZE_EXPAND_FILL);
@@ -1849,14 +1863,14 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
globals_editor->get_inspector()->set_undo_redo(EditorNode::get_singleton()->get_undo_redo());
globals_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
globals_editor->register_search_box(search_box);
- globals_editor->get_inspector()->connect("property_selected", this, "_item_selected");
- globals_editor->get_inspector()->connect("property_edited", this, "_settings_prop_edited");
- globals_editor->get_inspector()->connect("restart_requested", this, "_editor_restart_request");
+ globals_editor->get_inspector()->connect_compat("property_selected", this, "_item_selected");
+ globals_editor->get_inspector()->connect_compat("property_edited", this, "_settings_prop_edited");
+ globals_editor->get_inspector()->connect_compat("restart_requested", this, "_editor_restart_request");
Button *del = memnew(Button);
hbc->add_child(del);
del->set_text(TTR("Delete"));
- del->connect("pressed", this, "_item_del");
+ del->connect_compat("pressed", this, "_item_del");
add_prop_bar->add_child(memnew(VSeparator));
@@ -1865,8 +1879,8 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
popup_copy_to_feature->set_disabled(true);
add_prop_bar->add_child(popup_copy_to_feature);
- popup_copy_to_feature->get_popup()->connect("id_pressed", this, "_copy_to_platform");
- popup_copy_to_feature->get_popup()->connect("about_to_show", this, "_copy_to_platform_about_to_show");
+ popup_copy_to_feature->get_popup()->connect_compat("id_pressed", this, "_copy_to_platform");
+ popup_copy_to_feature->get_popup()->connect_compat("about_to_show", this, "_copy_to_platform_about_to_show");
get_ok()->set_text(TTR("Close"));
set_hide_on_ok(true);
@@ -1883,11 +1897,11 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
restart_hb->add_child(restart_label);
restart_hb->add_spacer();
Button *restart_button = memnew(Button);
- restart_button->connect("pressed", this, "_editor_restart");
+ restart_button->connect_compat("pressed", this, "_editor_restart");
restart_hb->add_child(restart_button);
restart_button->set_text(TTR("Save & Restart"));
restart_close_button = memnew(ToolButton);
- restart_close_button->connect("pressed", this, "_editor_restart_close");
+ restart_close_button->connect_compat("pressed", this, "_editor_restart_close");
restart_hb->add_child(restart_close_button);
restart_container->hide();
@@ -1915,8 +1929,8 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
action_name = memnew(LineEdit);
action_name->set_h_size_flags(SIZE_EXPAND_FILL);
hbc->add_child(action_name);
- action_name->connect("text_entered", this, "_action_adds");
- action_name->connect("text_changed", this, "_action_check");
+ action_name->connect_compat("text_entered", this, "_action_adds");
+ action_name->connect_compat("text_changed", this, "_action_check");
action_add_error = memnew(Label);
hbc->add_child(action_add_error);
@@ -1926,7 +1940,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
hbc->add_child(add);
add->set_text(TTR("Add"));
add->set_disabled(true);
- add->connect("pressed", this, "_action_add");
+ add->connect_compat("pressed", this, "_action_add");
action_add = add;
input_editor = memnew(Tree);
@@ -1940,15 +1954,15 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
input_editor->set_column_min_width(1, 80 * EDSCALE);
input_editor->set_column_expand(2, false);
input_editor->set_column_min_width(2, 50 * EDSCALE);
- input_editor->connect("item_edited", this, "_action_edited");
- input_editor->connect("item_activated", this, "_action_activated");
- input_editor->connect("cell_selected", this, "_action_selected");
- input_editor->connect("button_pressed", this, "_action_button_pressed");
+ input_editor->connect_compat("item_edited", this, "_action_edited");
+ input_editor->connect_compat("item_activated", this, "_action_activated");
+ input_editor->connect_compat("cell_selected", this, "_action_selected");
+ input_editor->connect_compat("button_pressed", this, "_action_button_pressed");
input_editor->set_drag_forwarding(this);
popup_add = memnew(PopupMenu);
add_child(popup_add);
- popup_add->connect("id_pressed", this, "_add_item");
+ popup_add->connect_compat("id_pressed", this, "_add_item");
press_a_key = memnew(ConfirmationDialog);
press_a_key->set_focus_mode(FOCUS_ALL);
@@ -1963,13 +1977,13 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
press_a_key->get_ok()->set_disabled(true);
press_a_key_label = l;
press_a_key->add_child(l);
- press_a_key->connect("gui_input", this, "_wait_for_key");
- press_a_key->connect("confirmed", this, "_press_a_key_confirm");
+ press_a_key->connect_compat("gui_input", this, "_wait_for_key");
+ press_a_key->connect_compat("confirmed", this, "_press_a_key_confirm");
device_input = memnew(ConfirmationDialog);
add_child(device_input);
device_input->get_ok()->set_text(TTR("Add"));
- device_input->connect("confirmed", this, "_device_input_add");
+ device_input->connect_compat("confirmed", this, "_device_input_add");
hbc = memnew(HBoxContainer);
device_input->add_child(hbc);
@@ -2020,7 +2034,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
thb->add_child(memnew(Label(TTR("Translations:"))));
thb->add_spacer();
Button *addtr = memnew(Button(TTR("Add...")));
- addtr->connect("pressed", this, "_translation_file_open");
+ addtr->connect_compat("pressed", this, "_translation_file_open");
thb->add_child(addtr);
VBoxContainer *tmc = memnew(VBoxContainer);
tvb->add_child(tmc);
@@ -2032,7 +2046,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
translation_file_open = memnew(EditorFileDialog);
add_child(translation_file_open);
translation_file_open->set_mode(EditorFileDialog::MODE_OPEN_FILE);
- translation_file_open->connect("file_selected", this, "_translation_add");
+ translation_file_open->connect_compat("file_selected", this, "_translation_add");
}
{
@@ -2044,28 +2058,28 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
thb->add_child(memnew(Label(TTR("Resources:"))));
thb->add_spacer();
Button *addtr = memnew(Button(TTR("Add...")));
- addtr->connect("pressed", this, "_translation_res_file_open");
+ addtr->connect_compat("pressed", this, "_translation_res_file_open");
thb->add_child(addtr);
VBoxContainer *tmc = memnew(VBoxContainer);
tvb->add_child(tmc);
tmc->set_v_size_flags(SIZE_EXPAND_FILL);
translation_remap = memnew(Tree);
translation_remap->set_v_size_flags(SIZE_EXPAND_FILL);
- translation_remap->connect("cell_selected", this, "_translation_res_select");
+ translation_remap->connect_compat("cell_selected", this, "_translation_res_select");
tmc->add_child(translation_remap);
- translation_remap->connect("button_pressed", this, "_translation_res_delete");
+ translation_remap->connect_compat("button_pressed", this, "_translation_res_delete");
translation_res_file_open = memnew(EditorFileDialog);
add_child(translation_res_file_open);
translation_res_file_open->set_mode(EditorFileDialog::MODE_OPEN_FILE);
- translation_res_file_open->connect("file_selected", this, "_translation_res_add");
+ translation_res_file_open->connect_compat("file_selected", this, "_translation_res_add");
thb = memnew(HBoxContainer);
tvb->add_child(thb);
thb->add_child(memnew(Label(TTR("Remaps by Locale:"))));
thb->add_spacer();
addtr = memnew(Button(TTR("Add...")));
- addtr->connect("pressed", this, "_translation_res_option_file_open");
+ addtr->connect_compat("pressed", this, "_translation_res_option_file_open");
translation_res_option_add_button = addtr;
thb->add_child(addtr);
tmc = memnew(VBoxContainer);
@@ -2082,13 +2096,13 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
translation_remap_options->set_column_expand(0, true);
translation_remap_options->set_column_expand(1, false);
translation_remap_options->set_column_min_width(1, 200);
- translation_remap_options->connect("item_edited", this, "_translation_res_option_changed");
- translation_remap_options->connect("button_pressed", this, "_translation_res_option_delete");
+ translation_remap_options->connect_compat("item_edited", this, "_translation_res_option_changed");
+ translation_remap_options->connect_compat("button_pressed", this, "_translation_res_option_delete");
translation_res_option_file_open = memnew(EditorFileDialog);
add_child(translation_res_option_file_open);
translation_res_option_file_open->set_mode(EditorFileDialog::MODE_OPEN_FILE);
- translation_res_option_file_open->connect("file_selected", this, "_translation_res_option_add");
+ translation_res_option_file_open->connect_compat("file_selected", this, "_translation_res_option_add");
}
{
@@ -2104,20 +2118,20 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
translation_locale_filter_mode->add_item(TTR("Show Selected Locales Only"), SHOW_ONLY_SELECTED_LOCALES);
translation_locale_filter_mode->select(0);
tmc->add_margin_child(TTR("Filter mode:"), translation_locale_filter_mode);
- translation_locale_filter_mode->connect("item_selected", this, "_translation_filter_mode_changed");
+ translation_locale_filter_mode->connect_compat("item_selected", this, "_translation_filter_mode_changed");
translation_filter = memnew(Tree);
translation_filter->set_v_size_flags(SIZE_EXPAND_FILL);
translation_filter->set_columns(1);
tmc->add_child(memnew(Label(TTR("Locales:"))));
tmc->add_child(translation_filter);
- translation_filter->connect("item_edited", this, "_translation_filter_option_changed");
+ translation_filter->connect_compat("item_edited", this, "_translation_filter_option_changed");
}
autoload_settings = memnew(EditorAutoloadSettings);
autoload_settings->set_name(TTR("AutoLoad"));
tab_container->add_child(autoload_settings);
- autoload_settings->connect("autoload_changed", this, "_settings_changed");
+ autoload_settings->connect_compat("autoload_changed", this, "_settings_changed");
plugin_settings = memnew(EditorPluginSettings);
plugin_settings->set_name(TTR("Plugins"));
@@ -2125,7 +2139,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
timer = memnew(Timer);
timer->set_wait_time(1.5);
- timer->connect("timeout", ProjectSettings::get_singleton(), "save");
+ timer->connect_compat("timeout", ProjectSettings::get_singleton(), "save");
timer->set_one_shot(true);
add_child(timer);