diff options
Diffstat (limited to 'editor/project_settings_editor.cpp')
-rw-r--r-- | editor/project_settings_editor.cpp | 59 |
1 files changed, 27 insertions, 32 deletions
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index db12e90540..bcc597d595 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-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 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 */ @@ -78,7 +78,7 @@ void ProjectSettingsEditor::_advanced_toggled(bool p_button_pressed) { } void ProjectSettingsEditor::_setting_selected(const String &p_path) { - if (p_path == String()) { + if (p_path.is_empty()) { return; } @@ -147,12 +147,12 @@ void ProjectSettingsEditor::_update_property_box() { const Vector<String> t = setting.split(".", true, 1); const String name = t[0]; const String feature = (t.size() == 2) ? t[1] : ""; - bool feature_invalid = (t.size() == 2) && (t[1] == ""); + bool feature_invalid = (t.size() == 2) && (t[1].is_empty()); add_button->set_disabled(true); del_button->set_disabled(true); - if (feature != "") { + if (!feature.is_empty()) { feature_invalid = true; for (int i = 1; i < feature_box->get_item_count(); i++) { if (feature == feature_box->get_item_text(i)) { @@ -163,11 +163,11 @@ void ProjectSettingsEditor::_update_property_box() { } } - if (feature == "" || feature_invalid) { + if (feature.is_empty() || feature_invalid) { feature_box->select(0); } - if (property_box->get_text() == "") { + if (property_box->get_text().is_empty()) { return; } @@ -215,7 +215,6 @@ void ProjectSettingsEditor::_add_feature_overrides() { presets.insert("s3tc"); presets.insert("etc"); presets.insert("etc2"); - presets.insert("pvrtc"); presets.insert("debug"); presets.insert("release"); presets.insert("editor"); @@ -244,7 +243,7 @@ void ProjectSettingsEditor::_add_feature_overrides() { Vector<String> custom_list = custom.split(","); for (int j = 0; j < custom_list.size(); j++) { String f = custom_list[j].strip_edges(); - if (f != String()) { + if (!f.is_empty()) { presets.insert(f); } } @@ -275,10 +274,8 @@ void ProjectSettingsEditor::_editor_restart_close() { void ProjectSettingsEditor::_action_added(const String &p_name) { String name = "input/" + p_name; - if (ProjectSettings::get_singleton()->has_setting(name)) { - action_map->show_message(vformat(TTR("An action with the name '%s' already exists."), name)); - return; - } + ERR_FAIL_COND_MSG(ProjectSettings::get_singleton()->has_setting(name), + "An action with this name already exists."); Dictionary action; action["events"] = Array(); @@ -351,10 +348,8 @@ void ProjectSettingsEditor::_action_renamed(const String &p_old_name, const Stri const String old_property_name = "input/" + p_old_name; const String new_property_name = "input/" + p_new_name; - if (ProjectSettings::get_singleton()->has_setting(new_property_name)) { - action_map->show_message(vformat(TTR("An action with the name '%s' already exists."), new_property_name)); - return; - } + ERR_FAIL_COND_MSG(ProjectSettings::get_singleton()->has_setting(new_property_name), + "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); @@ -471,6 +466,14 @@ void ProjectSettingsEditor::_update_action_map_editor() { action_map->update_action_list(actions); } +void ProjectSettingsEditor::_update_theme() { + search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); + restart_close_button->set_icon(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); + restart_container->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); + restart_icon->set_texture(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); + restart_label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); +} + void ProjectSettingsEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_VISIBILITY_CHANGED: { @@ -480,21 +483,12 @@ void ProjectSettingsEditor::_notification(int p_what) { } break; case NOTIFICATION_ENTER_TREE: { inspector->edit(ps); - - search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - search_box->set_clear_button_enabled(true); - - restart_close_button->set_icon(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); - restart_container->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree"))); - restart_icon->set_texture(get_theme_icon(SNAME("StatusWarning"), SNAME("EditorIcons"))); - restart_label->add_theme_color_override("font_color", get_theme_color(SNAME("warning_color"), SNAME("Editor"))); - _update_action_map_editor(); + _update_theme(); } break; - case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { - search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); - search_box->set_clear_button_enabled(true); - } break; + case NOTIFICATION_THEME_CHANGED: + _update_theme(); + break; } } @@ -513,13 +507,13 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { data = p_data; tab_container = memnew(TabContainer); - tab_container->set_tab_align(TabContainer::ALIGN_LEFT); + tab_container->set_tab_alignment(TabContainer::ALIGNMENT_LEFT); tab_container->set_use_hidden_tabs_for_min_size(true); add_child(tab_container); VBoxContainer *general_editor = memnew(VBoxContainer); general_editor->set_name(TTR("General")); - general_editor->set_alignment(BoxContainer::ALIGN_BEGIN); + general_editor->set_alignment(BoxContainer::ALIGNMENT_BEGIN); general_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); tab_container->add_child(general_editor); @@ -528,6 +522,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { search_box = memnew(LineEdit); search_box->set_placeholder(TTR("Filter Settings")); + search_box->set_clear_button_enabled(true); search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL); search_bar->add_child(search_box); |