Browse Source

Allow editing editor settings from project manager

kobewi 2 years ago
parent
commit
a1340f05a9

+ 1 - 1
drivers/gles3/storage/material_storage.cpp

@@ -1870,7 +1870,7 @@ void MaterialStorage::global_shader_parameter_remove(const StringName &p_name) {
 }
 }
 
 
 Vector<StringName> MaterialStorage::global_shader_parameter_get_list() const {
 Vector<StringName> MaterialStorage::global_shader_parameter_get_list() const {
-	if (!Engine::get_singleton()->is_editor_hint()) {
+	if (!Engine::get_singleton()->is_editor_hint() && !Engine::get_singleton()->is_project_manager_hint()) {
 		ERR_FAIL_V_MSG(Vector<StringName>(), "This function should never be used outside the editor, it can severely damage performance.");
 		ERR_FAIL_V_MSG(Vector<StringName>(), "This function should never be used outside the editor, it can severely damage performance.");
 	}
 	}
 
 

+ 1 - 0
editor/editor_node.cpp

@@ -8300,6 +8300,7 @@ EditorNode::EditorNode() {
 
 
 	editor_settings_dialog = memnew(EditorSettingsDialog);
 	editor_settings_dialog = memnew(EditorSettingsDialog);
 	gui_base->add_child(editor_settings_dialog);
 	gui_base->add_child(editor_settings_dialog);
+	editor_settings_dialog->connect("restart_requested", callable_mp(this, &EditorNode::_restart_editor).bind(false));
 
 
 	project_settings_editor = memnew(ProjectSettingsEditor(&editor_data));
 	project_settings_editor = memnew(ProjectSettingsEditor(&editor_data));
 	gui_base->add_child(project_settings_editor);
 	gui_base->add_child(project_settings_editor);

+ 9 - 4
editor/inspector/editor_inspector.cpp

@@ -3782,6 +3782,10 @@ void EditorInspector::_parse_added_editors(VBoxContainer *current_vbox, EditorIn
 }
 }
 
 
 bool EditorInspector::_is_property_disabled_by_feature_profile(const StringName &p_property) {
 bool EditorInspector::_is_property_disabled_by_feature_profile(const StringName &p_property) {
+	if (!EditorFeatureProfileManager::get_singleton()) {
+		return false;
+	}
+
 	Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile();
 	Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile();
 	if (profile.is_null()) {
 	if (profile.is_null()) {
 		return false;
 		return false;
@@ -3872,7 +3876,7 @@ void EditorInspector::update_tree() {
 	// or if the whole object should be considered read-only.
 	// or if the whole object should be considered read-only.
 	bool draw_warning = false;
 	bool draw_warning = false;
 	bool all_read_only = false;
 	bool all_read_only = false;
-	if (is_inside_tree()) {
+	if (is_inside_tree() && EditorNode::get_singleton()) {
 		if (object->has_method("_is_read_only")) {
 		if (object->has_method("_is_read_only")) {
 			all_read_only = object->call("_is_read_only");
 			all_read_only = object->call("_is_read_only");
 		}
 		}
@@ -5153,7 +5157,7 @@ void EditorInspector::_edit_set(const String &p_name, const Variant &p_value, bo
 	}
 	}
 
 
 	EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
 	EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
-	if (bool(object->call("_dont_undo_redo"))) {
+	if (!undo_redo || bool(object->call("_dont_undo_redo"))) {
 		object->set(p_name, p_value);
 		object->set(p_name, p_value);
 		if (p_refresh_all) {
 		if (p_refresh_all) {
 			_edit_request_change(object, "");
 			_edit_request_change(object, "");
@@ -5664,8 +5668,9 @@ void EditorInspector::_notification(int p_what) {
 		} break;
 		} break;
 
 
 		case NOTIFICATION_READY: {
 		case NOTIFICATION_READY: {
-			ERR_FAIL_NULL(EditorFeatureProfileManager::get_singleton());
-			EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &EditorInspector::_feature_profile_changed));
+			if (EditorFeatureProfileManager::get_singleton()) {
+				EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &EditorInspector::_feature_profile_changed));
+			}
 			set_process(is_visible_in_tree());
 			set_process(is_visible_in_tree());
 			if (!is_sub_inspector()) {
 			if (!is_sub_inspector()) {
 				get_tree()->connect("node_removed", callable_mp(this, &EditorInspector::_node_removed));
 				get_tree()->connect("node_removed", callable_mp(this, &EditorInspector::_node_removed));

+ 3 - 1
editor/inspector/editor_properties.cpp

@@ -2801,7 +2801,9 @@ void EditorPropertyColor::_picker_created() {
 }
 }
 
 
 void EditorPropertyColor::_popup_opening() {
 void EditorPropertyColor::_popup_opening() {
-	EditorNode::get_singleton()->setup_color_picker(picker->get_picker());
+	if (EditorNode::get_singleton()) {
+		EditorNode::get_singleton()->setup_color_picker(picker->get_picker());
+	}
 	last_color = picker->get_pick_color();
 	last_color = picker->get_pick_color();
 	was_checked = !is_checkable() || is_checked();
 	was_checked = !is_checkable() || is_checked();
 }
 }

+ 31 - 0
editor/project_manager/quick_settings_dialog.cpp

@@ -31,8 +31,11 @@
 #include "quick_settings_dialog.h"
 #include "quick_settings_dialog.h"
 
 
 #include "core/string/translation_server.h"
 #include "core/string/translation_server.h"
+#include "editor/doc/editor_help.h"
 #include "editor/editor_string_names.h"
 #include "editor/editor_string_names.h"
+#include "editor/inspector/editor_properties.h"
 #include "editor/settings/editor_settings.h"
 #include "editor/settings/editor_settings.h"
+#include "editor/settings/editor_settings_dialog.h"
 #include "editor/themes/editor_scale.h"
 #include "editor/themes/editor_scale.h"
 #include "scene/gui/box_container.h"
 #include "scene/gui/box_container.h"
 #include "scene/gui/button.h"
 #include "scene/gui/button.h"
@@ -228,6 +231,25 @@ void QuickSettingsDialog::_set_setting_value(const String &p_setting, const Vari
 	}
 	}
 }
 }
 
 
+void QuickSettingsDialog::_show_full_settings() {
+	if (!editor_settings_dialog) {
+		EditorHelp::generate_doc();
+
+		Ref<EditorInspectorDefaultPlugin> eidp;
+		eidp.instantiate();
+		EditorInspector::add_inspector_plugin(eidp);
+
+		EditorPropertyNameProcessor *epnp = memnew(EditorPropertyNameProcessor);
+		add_child(epnp);
+
+		editor_settings_dialog = memnew(EditorSettingsDialog);
+		get_parent()->add_child(editor_settings_dialog);
+		editor_settings_dialog->connect("restart_requested", callable_mp(this, &QuickSettingsDialog::_request_restart));
+	}
+	hide();
+	editor_settings_dialog->popup_edit_settings();
+}
+
 void QuickSettingsDialog::_request_restart() {
 void QuickSettingsDialog::_request_restart() {
 	emit_signal("restart_required");
 	emit_signal("restart_required");
 }
 }
@@ -378,6 +400,15 @@ QuickSettingsDialog::QuickSettingsDialog() {
 		_update_current_values();
 		_update_current_values();
 	}
 	}
 
 
+	// Full settings button.
+	{
+		Button *open_full_settings = memnew(Button);
+		open_full_settings->set_text(TTRC("Edit All Settings"));
+		open_full_settings->set_h_size_flags(Control::SIZE_SHRINK_END);
+		settings_list->add_child(open_full_settings);
+		open_full_settings->connect(SceneStringName(pressed), callable_mp(this, &QuickSettingsDialog::_show_full_settings));
+	}
+
 	// Restart required panel.
 	// Restart required panel.
 	{
 	{
 		restart_required_label = memnew(Label(TTRC("Settings changed! The project manager must be restarted for changes to take effect.")));
 		restart_required_label = memnew(Label(TTRC("Settings changed! The project manager must be restarted for changes to take effect.")));

+ 3 - 0
editor/project_manager/quick_settings_dialog.h

@@ -33,6 +33,7 @@
 #include "scene/gui/dialogs.h"
 #include "scene/gui/dialogs.h"
 
 
 class Button;
 class Button;
+class EditorSettingsDialog;
 class Label;
 class Label;
 class MarginContainer;
 class MarginContainer;
 class OptionButton;
 class OptionButton;
@@ -71,6 +72,7 @@ class QuickSettingsDialog : public AcceptDialog {
 	OptionButton *directory_naming_convention_button = nullptr;
 	OptionButton *directory_naming_convention_button = nullptr;
 
 
 	Label *custom_theme_label = nullptr;
 	Label *custom_theme_label = nullptr;
+	EditorSettingsDialog *editor_settings_dialog = nullptr;
 
 
 #ifndef ANDROID_ENABLED
 #ifndef ANDROID_ENABLED
 	void _language_selected(int p_id);
 	void _language_selected(int p_id);
@@ -81,6 +83,7 @@ class QuickSettingsDialog : public AcceptDialog {
 	void _check_for_update_selected(int p_id);
 	void _check_for_update_selected(int p_id);
 	void _directory_naming_convention_selected(int p_id);
 	void _directory_naming_convention_selected(int p_id);
 	void _set_setting_value(const String &p_setting, const Variant &p_value, bool p_restart_required = false);
 	void _set_setting_value(const String &p_setting, const Variant &p_value, bool p_restart_required = false);
+	void _show_full_settings();
 
 
 	Label *restart_required_label = nullptr;
 	Label *restart_required_label = nullptr;
 	Button *restart_required_button = nullptr;
 	Button *restart_required_button = nullptr;

+ 40 - 14
editor/settings/editor_settings_dialog.cpp

@@ -205,9 +205,15 @@ void EditorSettingsDialog::popup_edit_settings() {
 	set_process_shortcut_input(true);
 	set_process_shortcut_input(true);
 
 
 	// Restore valid window bounds or pop up at default size.
 	// Restore valid window bounds or pop up at default size.
-	Rect2 saved_size = EditorSettings::get_singleton()->get_project_metadata("dialog_bounds", "editor_settings", Rect2());
+	Rect2 saved_size;
+	if (!_is_in_project_manager()) {
+		saved_size = EditorSettings::get_singleton()->get_project_metadata("dialog_bounds", "editor_settings", Rect2());
+	}
+
 	if (saved_size != Rect2()) {
 	if (saved_size != Rect2()) {
 		popup(saved_size);
 		popup(saved_size);
+	} else if (_is_in_project_manager()) {
+		popup_centered_clamped(Size2(800, 600) * EDSCALE, 0.8); // Make it smaller that the default Project Manager size.
 	} else {
 	} else {
 		popup_centered_clamped(Size2(900, 700) * EDSCALE, 0.8);
 		popup_centered_clamped(Size2(900, 700) * EDSCALE, 0.8);
 	}
 	}
@@ -222,7 +228,7 @@ void EditorSettingsDialog::_undo_redo_callback(void *p_self, const String &p_nam
 void EditorSettingsDialog::_notification(int p_what) {
 void EditorSettingsDialog::_notification(int p_what) {
 	switch (p_what) {
 	switch (p_what) {
 		case NOTIFICATION_VISIBILITY_CHANGED: {
 		case NOTIFICATION_VISIBILITY_CHANGED: {
-			if (!is_visible()) {
+			if (!is_visible() && !_is_in_project_manager()) {
 				EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "editor_settings", Rect2(get_position(), get_size()));
 				EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "editor_settings", Rect2(get_position(), get_size()));
 				set_process_shortcut_input(false);
 				set_process_shortcut_input(false);
 			}
 			}
@@ -231,6 +237,9 @@ void EditorSettingsDialog::_notification(int p_what) {
 		case NOTIFICATION_READY: {
 		case NOTIFICATION_READY: {
 			EditorSettingsPropertyWrapper::restart_request_callback = callable_mp(this, &EditorSettingsDialog::_editor_restart_request);
 			EditorSettingsPropertyWrapper::restart_request_callback = callable_mp(this, &EditorSettingsDialog::_editor_restart_request);
 
 
+			if (_is_in_project_manager()) {
+				return;
+			}
 			EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
 			EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
 			undo_redo->get_or_create_history(EditorUndoRedoManager::GLOBAL_HISTORY).undo_redo->set_method_notify_callback(EditorDebuggerNode::_methods_changed, nullptr);
 			undo_redo->get_or_create_history(EditorUndoRedoManager::GLOBAL_HISTORY).undo_redo->set_method_notify_callback(EditorDebuggerNode::_methods_changed, nullptr);
 			undo_redo->get_or_create_history(EditorUndoRedoManager::GLOBAL_HISTORY).undo_redo->set_property_notify_callback(EditorDebuggerNode::_properties_changed, nullptr);
 			undo_redo->get_or_create_history(EditorUndoRedoManager::GLOBAL_HISTORY).undo_redo->set_property_notify_callback(EditorDebuggerNode::_properties_changed, nullptr);
@@ -275,14 +284,16 @@ void EditorSettingsDialog::shortcut_input(const Ref<InputEvent> &p_event) {
 	if (k.is_valid() && k->is_pressed()) {
 	if (k.is_valid() && k->is_pressed()) {
 		bool handled = false;
 		bool handled = false;
 
 
-		if (ED_IS_SHORTCUT("ui_undo", p_event)) {
-			EditorNode::get_singleton()->undo();
-			handled = true;
-		}
+		if (EditorNode::get_singleton()) {
+			if (ED_IS_SHORTCUT("ui_undo", p_event)) {
+				EditorNode::get_singleton()->undo();
+				handled = true;
+			}
 
 
-		if (ED_IS_SHORTCUT("ui_redo", p_event)) {
-			EditorNode::get_singleton()->redo();
-			handled = true;
+			if (ED_IS_SHORTCUT("ui_redo", p_event)) {
+				EditorNode::get_singleton()->redo();
+				handled = true;
+			}
 		}
 		}
 
 
 		if (k->is_match(InputEventKey::create_reference(KeyModifierMask::CMD_OR_CTRL | Key::F))) {
 		if (k->is_match(InputEventKey::create_reference(KeyModifierMask::CMD_OR_CTRL | Key::F))) {
@@ -327,6 +338,10 @@ void EditorSettingsDialog::_event_config_confirmed() {
 	}
 	}
 }
 }
 
 
+bool EditorSettingsDialog::_is_in_project_manager() const {
+	return !ProjectSettings::get_singleton()->is_project_loaded();
+}
+
 void EditorSettingsDialog::_update_builtin_action(const String &p_name, const Array &p_events) {
 void EditorSettingsDialog::_update_builtin_action(const String &p_name, const Array &p_events) {
 	Array old_input_array = EditorSettings::get_singleton()->get_builtin_action_overrides(p_name);
 	Array old_input_array = EditorSettings::get_singleton()->get_builtin_action_overrides(p_name);
 	if (old_input_array.is_empty()) {
 	if (old_input_array.is_empty()) {
@@ -842,6 +857,10 @@ PropertyInfo EditorSettingsDialog::_create_mouse_shortcut_property_info(const St
 String EditorSettingsDialog::_get_shortcut_button_string(const String &p_shortcut_name) {
 String EditorSettingsDialog::_get_shortcut_button_string(const String &p_shortcut_name) {
 	String button_string;
 	String button_string;
 	Ref<Shortcut> shortcut_ref = EditorSettings::get_singleton()->get_shortcut(p_shortcut_name);
 	Ref<Shortcut> shortcut_ref = EditorSettings::get_singleton()->get_shortcut(p_shortcut_name);
+	if (shortcut_ref.is_null()) {
+		return String();
+	}
+
 	Array events = shortcut_ref->get_events();
 	Array events = shortcut_ref->get_events();
 	for (Ref<InputEvent> input_event : events) {
 	for (Ref<InputEvent> input_event : events) {
 		button_string += input_event->as_text() + " + ";
 		button_string += input_event->as_text() + " + ";
@@ -869,8 +888,7 @@ void EditorSettingsDialog::_advanced_toggled(bool p_button_pressed) {
 }
 }
 
 
 void EditorSettingsDialog::_editor_restart() {
 void EditorSettingsDialog::_editor_restart() {
-	EditorNode::get_singleton()->save_all_scenes();
-	EditorNode::get_singleton()->restart_editor();
+	emit_signal("restart_requested");
 }
 }
 
 
 void EditorSettingsDialog::_editor_restart_request() {
 void EditorSettingsDialog::_editor_restart_request() {
@@ -884,6 +902,8 @@ void EditorSettingsDialog::_editor_restart_close() {
 void EditorSettingsDialog::_bind_methods() {
 void EditorSettingsDialog::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("_update_shortcuts"), &EditorSettingsDialog::_update_shortcuts);
 	ClassDB::bind_method(D_METHOD("_update_shortcuts"), &EditorSettingsDialog::_update_shortcuts);
 	ClassDB::bind_method(D_METHOD("_settings_changed"), &EditorSettingsDialog::_settings_changed);
 	ClassDB::bind_method(D_METHOD("_settings_changed"), &EditorSettingsDialog::_settings_changed);
+
+	ADD_SIGNAL(MethodInfo("restart_requested"));
 }
 }
 
 
 EditorSettingsDialog::EditorSettingsDialog() {
 EditorSettingsDialog::EditorSettingsDialog() {
@@ -943,7 +963,11 @@ EditorSettingsDialog::EditorSettingsDialog() {
 	restart_hb->add_child(restart_icon);
 	restart_hb->add_child(restart_icon);
 	restart_label = memnew(Label);
 	restart_label = memnew(Label);
 	restart_label->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
 	restart_label->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
-	restart_label->set_text(TTRC("The editor must be restarted for changes to take effect."));
+	if (_is_in_project_manager()) {
+		restart_label->set_text(TTRC("The Project Manager must be restarted for changes to take effect."));
+	} else {
+		restart_label->set_text(TTRC("The editor must be restarted for changes to take effect."));
+	}
 	restart_hb->add_child(restart_label);
 	restart_hb->add_child(restart_label);
 	restart_hb->add_spacer();
 	restart_hb->add_spacer();
 	Button *restart_button = memnew(Button);
 	Button *restart_button = memnew(Button);
@@ -1012,7 +1036,7 @@ void EditorSettingsPropertyWrapper::_update_override() {
 		return;
 		return;
 	}
 	}
 
 
-	const bool has_override = ProjectSettings::get_singleton()->has_editor_setting_override(property);
+	const bool has_override = ProjectSettings::get_singleton()->is_project_loaded() && ProjectSettings::get_singleton()->has_editor_setting_override(property);
 	if (has_override) {
 	if (has_override) {
 		const Variant override_value = EDITOR_GET(property);
 		const Variant override_value = EDITOR_GET(property);
 		override_label->set_text(vformat(TTR("Overridden in project: %s"), override_value));
 		override_label->set_text(vformat(TTR("Overridden in project: %s"), override_value));
@@ -1076,7 +1100,9 @@ void EditorSettingsPropertyWrapper::setup(const String &p_property, EditorProper
 	goto_button = memnew(Button);
 	goto_button = memnew(Button);
 	goto_button->set_tooltip_text(TTRC("Go to the override in the Project Settings."));
 	goto_button->set_tooltip_text(TTRC("Go to the override in the Project Settings."));
 	override_info->add_child(goto_button);
 	override_info->add_child(goto_button);
-	goto_button->connect(SceneStringName(pressed), callable_mp(EditorNode::get_singleton(), &EditorNode::open_setting_override).bind(property), CONNECT_DEFERRED);
+	if (EditorNode::get_singleton()) {
+		goto_button->connect(SceneStringName(pressed), callable_mp(EditorNode::get_singleton(), &EditorNode::open_setting_override).bind(property), CONNECT_DEFERRED);
+	}
 
 
 	remove_button = memnew(Button);
 	remove_button = memnew(Button);
 	remove_button->set_tooltip_text(TTRC("Remove this override."));
 	remove_button->set_tooltip_text(TTRC("Remove this override."));

+ 1 - 0
editor/settings/editor_settings_dialog.h

@@ -89,6 +89,7 @@ class EditorSettingsDialog : public AcceptDialog {
 	void _update_icons();
 	void _update_icons();
 
 
 	void _event_config_confirmed();
 	void _event_config_confirmed();
+	bool _is_in_project_manager() const;
 
 
 	TreeItem *_create_shortcut_treeitem(TreeItem *p_parent, const String &p_shortcut_identifier, const String &p_display, Array &p_events, bool p_allow_revert, bool p_is_common, bool p_is_collapsed);
 	TreeItem *_create_shortcut_treeitem(TreeItem *p_parent, const String &p_shortcut_identifier, const String &p_display, Array &p_events, bool p_allow_revert, bool p_is_common, bool p_is_collapsed);
 	Array _event_list_to_array_helper(const List<Ref<InputEvent>> &p_events);
 	Array _event_list_to_array_helper(const List<Ref<InputEvent>> &p_events);