Minor fixes/refactoring of project and editor setting dialogs

This commit is contained in:
Hendrik Brucker 2022-02-01 00:19:01 +01:00
parent 2c85f2a8f6
commit 2f1e7c28a4
8 changed files with 102 additions and 53 deletions

View File

@ -93,6 +93,7 @@
#include "editor/editor_run_script.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_settings_dialog.h"
#include "editor/editor_spin_slider.h"
#include "editor/editor_themes.h"
#include "editor/editor_toaster.h"
@ -190,7 +191,6 @@
#include "editor/project_settings_editor.h"
#include "editor/quick_open.h"
#include "editor/register_exporters.h"
#include "editor/settings_config_dialog.h"
#include <stdio.h>
#include <stdlib.h>
@ -822,8 +822,8 @@ void EditorNode::_on_plugin_ready(Object *p_script, const String &p_activate_nam
if (p_activate_name.length()) {
set_addon_plugin_enabled(p_activate_name, true);
}
project_settings->update_plugins();
project_settings->hide();
project_settings_editor->update_plugins();
project_settings_editor->hide();
push_item(script.operator->());
}
@ -2773,7 +2773,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case RUN_SETTINGS: {
project_settings->popup_project_settings();
project_settings_editor->popup_project_settings();
} break;
case FILE_INSTALL_ANDROID_SOURCE: {
if (p_confirmed) {
@ -2846,7 +2846,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
_update_update_spinner();
} break;
case SETTINGS_PREFERENCES: {
settings_config_dialog->popup_edit_settings();
editor_settings_dialog->popup_edit_settings();
} break;
case SETTINGS_EDITOR_DATA_FOLDER: {
OS::get_singleton()->shell_open(String("file://") + EditorPaths::get_singleton()->get_data_dir());
@ -3240,7 +3240,7 @@ void EditorNode::_update_addon_config() {
ProjectSettings::get_singleton()->set("editor_plugins/enabled", enabled_addons);
}
project_settings->queue_save();
project_settings_editor->queue_save();
}
void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, bool p_config_changed) {
@ -6325,11 +6325,11 @@ EditorNode::EditorNode() {
dependency_fixer = memnew(DependencyEditor);
gui_base->add_child(dependency_fixer);
settings_config_dialog = memnew(EditorSettingsDialog);
gui_base->add_child(settings_config_dialog);
editor_settings_dialog = memnew(EditorSettingsDialog);
gui_base->add_child(editor_settings_dialog);
project_settings = memnew(ProjectSettingsEditor(&editor_data));
gui_base->add_child(project_settings);
project_settings_editor = memnew(ProjectSettingsEditor(&editor_data));
gui_base->add_child(project_settings_editor);
scene_import_settings = memnew(SceneImportSettings);
gui_base->add_child(scene_import_settings);

View File

@ -323,8 +323,8 @@ private:
ConfirmationDialog *install_android_build_template;
ConfirmationDialog *remove_android_build_template;
EditorSettingsDialog *settings_config_dialog;
ProjectSettingsEditor *project_settings;
EditorSettingsDialog *editor_settings_dialog;
ProjectSettingsEditor *project_settings_editor;
bool settings_changed = true; // make it update settings on first frame
void _update_from_settings();
@ -713,7 +713,7 @@ public:
EditorPluginList *get_editor_plugins_force_over() { return editor_plugins_force_over; }
EditorPluginList *get_editor_plugins_force_input_forwarding() { return editor_plugins_force_input_forwarding; }
ProjectSettingsEditor *get_project_settings() { return project_settings; }
ProjectSettingsEditor *get_project_settings() { return project_settings_editor; }
static void add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed = false);
static void remove_editor_plugin(EditorPlugin *p_editor, bool p_config_changed = false);

View File

@ -1263,7 +1263,7 @@ void EditorPropertyInteger::_bind_methods() {
void EditorPropertyInteger::setup(int64_t p_min, int64_t p_max, int64_t p_step, bool p_allow_greater, bool p_allow_lesser) {
spin->set_min(p_min);
spin->set_max(p_max);
spin->set_step(p_step);
spin->set_step((p_step == 0) ? 1 : p_step);
spin->set_allow_greater(p_allow_greater);
spin->set_allow_lesser(p_allow_lesser);
}
@ -1353,7 +1353,7 @@ void EditorPropertyFloat::setup(double p_min, double p_max, double p_step, bool
angle_in_radians = p_angle_in_radians;
spin->set_min(p_min);
spin->set_max(p_max);
spin->set_step(p_step);
spin->set_step((p_step == 0) ? 0.1 : p_step);
spin->set_hide_slider(p_no_slider);
spin->set_exp_ratio(p_exp_range);
spin->set_allow_greater(p_greater);
@ -3435,7 +3435,9 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
EditorPropertyInteger *editor = memnew(EditorPropertyInteger);
EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1);
if (hint.step == 0) {
WARN_PRINT(p_path + ": Range step size is 0.");
}
editor->setup(hint.min, hint.max, hint.step, hint.greater, hint.lesser);
return editor;
@ -3464,6 +3466,9 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
EditorPropertyFloat *editor = memnew(EditorPropertyFloat);
EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step);
if (hint.step == 0) {
WARN_PRINT(p_path + ": Range step size is 0.");
}
editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, hint.exp_range, hint.greater, hint.lesser, hint.suffix, hint.radians);
return editor;

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* settings_config_dialog.cpp */
/* editor_settings_dialog.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "settings_config_dialog.h"
#include "editor_settings_dialog.h"
#include "core/config/project_settings.h"
#include "core/input/input_map.h"

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* settings_config_dialog.h */
/* editor_settings_dialog.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,8 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef SETTINGS_CONFIG_DIALOG_H
#define SETTINGS_CONFIG_DIALOG_H
#ifndef EDITOR_SETTINGS_DIALOG_H
#define EDITOR_SETTINGS_DIALOG_H
#include "editor/action_map_editor.h"
#include "editor/editor_sectioned_inspector.h"
@ -128,4 +128,4 @@ public:
~EditorSettingsDialog();
};
#endif // SETTINGS_CONFIG_DIALOG_H
#endif // EDITOR_SETTINGS_DIALOG_H

View File

@ -32,6 +32,7 @@
#include "core/config/project_settings.h"
#include "editor/editor_export.h"
#include "editor/editor_log.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
@ -47,7 +48,8 @@ void ProjectSettingsEditor::popup_project_settings() {
}
_add_feature_overrides();
inspector->update_category_list();
general_settings_inspector->update_category_list();
set_process_unhandled_input(true);
localization_editor->update_translations();
autoload_settings->update_autoload();
@ -74,7 +76,7 @@ void ProjectSettingsEditor::_setting_edited(const String &p_name) {
void ProjectSettingsEditor::_advanced_toggled(bool p_button_pressed) {
EditorSettings::get_singleton()->set_project_metadata("project_settings", "advanced_mode", p_button_pressed);
inspector->set_restrict_to_basic_settings(!p_button_pressed);
general_settings_inspector->set_restrict_to_basic_settings(!p_button_pressed);
}
void ProjectSettingsEditor::_setting_selected(const String &p_path) {
@ -82,7 +84,7 @@ void ProjectSettingsEditor::_setting_selected(const String &p_path) {
return;
}
property_box->set_text(inspector->get_current_section() + "/" + p_path);
property_box->set_text(general_settings_inspector->get_current_section() + "/" + p_path);
_update_property_box(); // set_text doesn't trigger text_changed
}
@ -99,13 +101,13 @@ void ProjectSettingsEditor::_add_setting() {
undo_redo->add_do_property(ps, setting, value);
undo_redo->add_undo_property(ps, setting, ps->has_setting(setting) ? ps->get(setting) : Variant());
undo_redo->add_do_method(inspector, "update_category_list");
undo_redo->add_undo_method(inspector, "update_category_list");
undo_redo->add_do_method(general_settings_inspector, "update_category_list");
undo_redo->add_undo_method(general_settings_inspector, "update_category_list");
undo_redo->add_do_method(this, "queue_save");
undo_redo->add_undo_method(this, "queue_save");
undo_redo->commit_action();
inspector->set_current_section(setting.get_slice("/", 1));
general_settings_inspector->set_current_section(setting.get_slice("/", 1));
add_button->release_focus();
}
@ -120,8 +122,8 @@ void ProjectSettingsEditor::_delete_setting() {
undo_redo->add_undo_method(ps, "set", setting, value);
undo_redo->add_undo_method(ps, "set_order", setting, order);
undo_redo->add_do_method(inspector, "update_category_list");
undo_redo->add_undo_method(inspector, "update_category_list");
undo_redo->add_do_method(general_settings_inspector, "update_category_list");
undo_redo->add_undo_method(general_settings_inspector, "update_category_list");
undo_redo->add_do_method(this, "queue_save");
undo_redo->add_undo_method(this, "queue_save");
@ -200,6 +202,44 @@ void ProjectSettingsEditor::_select_type(Variant::Type p_type) {
type_box->select(type_box->get_item_index(p_type));
}
void ProjectSettingsEditor::unhandled_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
const Ref<InputEventKey> k = p_event;
if (k.is_valid() && k->is_pressed()) {
bool handled = false;
if (ED_IS_SHORTCUT("ui_undo", p_event)) {
String action = undo_redo->get_current_action_name();
if (!action.is_empty()) {
EditorNode::get_log()->add_message("Undo: " + action, EditorLog::MSG_TYPE_EDITOR);
}
undo_redo->undo();
handled = true;
}
if (ED_IS_SHORTCUT("ui_redo", p_event)) {
undo_redo->redo();
String action = undo_redo->get_current_action_name();
if (!action.is_empty()) {
EditorNode::get_log()->add_message("Redo: " + action, EditorLog::MSG_TYPE_EDITOR);
}
handled = true;
}
if (k->get_keycode_with_modifiers() == (KeyModifierMask::CMD | Key::F)) {
search_box->grab_focus();
search_box->select_all();
handled = true;
}
if (handled) {
set_input_as_handled();
}
}
}
String ProjectSettingsEditor::_get_setting_name() const {
String name = property_box->get_text().strip_edges();
if (name.find("/") == -1) {
@ -463,7 +503,7 @@ void ProjectSettingsEditor::_update_action_map_editor() {
actions.push_back(action_info);
}
action_map->update_action_list(actions);
action_map_editor->update_action_list(actions);
}
void ProjectSettingsEditor::_update_theme() {
@ -482,7 +522,7 @@ void ProjectSettingsEditor::_notification(int p_what) {
}
} break;
case NOTIFICATION_ENTER_TREE: {
inspector->edit(ps);
general_settings_inspector->edit(ps);
_update_action_map_editor();
_update_theme();
} break;
@ -569,14 +609,14 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
del_button->connect("pressed", callable_mp(this, &ProjectSettingsEditor::_delete_setting));
header->add_child(del_button);
inspector = memnew(SectionedInspector);
inspector->get_inspector()->set_undo_redo(EditorNode::get_singleton()->get_undo_redo());
inspector->set_v_size_flags(Control::SIZE_EXPAND_FILL);
inspector->register_search_box(search_box);
inspector->get_inspector()->connect("property_selected", callable_mp(this, &ProjectSettingsEditor::_setting_selected));
inspector->get_inspector()->connect("property_edited", callable_mp(this, &ProjectSettingsEditor::_setting_edited));
inspector->get_inspector()->connect("restart_requested", callable_mp(this, &ProjectSettingsEditor::_editor_restart_request));
general_editor->add_child(inspector);
general_settings_inspector = memnew(SectionedInspector);
general_settings_inspector->get_inspector()->set_undo_redo(EditorNode::get_singleton()->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()->connect("property_selected", callable_mp(this, &ProjectSettingsEditor::_setting_selected));
general_settings_inspector->get_inspector()->connect("property_edited", callable_mp(this, &ProjectSettingsEditor::_setting_edited));
general_settings_inspector->get_inspector()->connect("restart_requested", callable_mp(this, &ProjectSettingsEditor::_editor_restart_request));
general_editor->add_child(general_settings_inspector);
restart_container = memnew(PanelContainer);
general_editor->add_child(restart_container);
@ -604,14 +644,14 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
restart_close_button->connect("pressed", callable_mp(this, &ProjectSettingsEditor::_editor_restart_close));
restart_hb->add_child(restart_close_button);
action_map = memnew(ActionMapEditor);
action_map->set_name(TTR("Input Map"));
action_map->connect("action_added", callable_mp(this, &ProjectSettingsEditor::_action_added));
action_map->connect("action_edited", callable_mp(this, &ProjectSettingsEditor::_action_edited));
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));
tab_container->add_child(action_map);
action_map_editor = memnew(ActionMapEditor);
action_map_editor->set_name(TTR("Input Map"));
action_map_editor->connect("action_added", callable_mp(this, &ProjectSettingsEditor::_action_added));
action_map_editor->connect("action_edited", callable_mp(this, &ProjectSettingsEditor::_action_edited));
action_map_editor->connect("action_removed", callable_mp(this, &ProjectSettingsEditor::_action_removed));
action_map_editor->connect("action_renamed", callable_mp(this, &ProjectSettingsEditor::_action_renamed));
action_map_editor->connect("action_reordered", callable_mp(this, &ProjectSettingsEditor::_action_reordered));
tab_container->add_child(action_map_editor);
localization_editor = memnew(LocalizationEditor);
localization_editor->set_name(TTR("Localization"));
@ -647,7 +687,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
advanced->set_pressed(true);
}
inspector->set_restrict_to_basic_settings(!use_advanced);
general_settings_inspector->set_restrict_to_basic_settings(!use_advanced);
import_defaults_editor = memnew(ImportDefaultsEditor);
import_defaults_editor->set_name(TTR("Import Defaults"));

View File

@ -50,8 +50,8 @@ class ProjectSettingsEditor : public AcceptDialog {
Timer *timer;
TabContainer *tab_container;
SectionedInspector *inspector;
ActionMapEditor *action_map;
SectionedInspector *general_settings_inspector;
ActionMapEditor *action_map_editor;
LocalizationEditor *localization_editor;
EditorAutoloadSettings *autoload_settings;
ShaderGlobalsEditor *shaders_global_variables_editor;
@ -81,6 +81,8 @@ class ProjectSettingsEditor : public AcceptDialog {
void _feature_selected(int p_index);
void _select_type(Variant::Type p_type);
virtual void unhandled_input(const Ref<InputEvent> &p_event) override;
String _get_setting_name() const;
void _setting_edited(const String &p_name);
void _setting_selected(const String &p_path);

View File

@ -1311,11 +1311,13 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
PropertyInfo(Variant::INT, "display/window/size/viewport_width",
PROPERTY_HINT_RANGE,
"0,7680,or_greater")); // 8K resolution
GLOBAL_DEF_BASIC("display/window/size/viewport_height", 600);
ProjectSettings::get_singleton()->set_custom_property_info("display/window/size/viewport_height",
PropertyInfo(Variant::INT, "display/window/size/viewport_height",
PROPERTY_HINT_RANGE,
"0,4320,or_greater")); // 8K resolution
"0,4320,1,or_greater")); // 8K resolution
GLOBAL_DEF_BASIC("display/window/size/resizable", true);
GLOBAL_DEF_BASIC("display/window/size/borderless", false);
GLOBAL_DEF_BASIC("display/window/size/fullscreen", false);
@ -1325,7 +1327,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
PropertyInfo(Variant::INT,
"display/window/size/window_width_override",
PROPERTY_HINT_RANGE,
"0,7680,or_greater")); // 8K resolution
"0,7680,1,or_greater")); // 8K resolution
GLOBAL_DEF("display/window/size/window_height_override", 0);
ProjectSettings::get_singleton()->set_custom_property_info("display/window/size/window_height_override",
PropertyInfo(Variant::INT,