|
@@ -30,6 +30,7 @@
|
|
|
|
|
|
#include "editor_settings_dialog.h"
|
|
#include "editor_settings_dialog.h"
|
|
|
|
|
|
|
|
+#include "core/config/project_settings.h"
|
|
#include "core/input/input_map.h"
|
|
#include "core/input/input_map.h"
|
|
#include "core/os/keyboard.h"
|
|
#include "core/os/keyboard.h"
|
|
#include "editor/debugger/editor_debugger_node.h"
|
|
#include "editor/debugger/editor_debugger_node.h"
|
|
@@ -44,6 +45,7 @@
|
|
#include "editor/event_listener_line_edit.h"
|
|
#include "editor/event_listener_line_edit.h"
|
|
#include "editor/input_event_configuration_dialog.h"
|
|
#include "editor/input_event_configuration_dialog.h"
|
|
#include "editor/plugins/node_3d_editor_plugin.h"
|
|
#include "editor/plugins/node_3d_editor_plugin.h"
|
|
|
|
+#include "editor/project_settings_editor.h"
|
|
#include "editor/themes/editor_scale.h"
|
|
#include "editor/themes/editor_scale.h"
|
|
#include "editor/themes/editor_theme_manager.h"
|
|
#include "editor/themes/editor_theme_manager.h"
|
|
#include "scene/gui/check_button.h"
|
|
#include "scene/gui/check_button.h"
|
|
@@ -239,6 +241,8 @@ void EditorSettingsDialog::_notification(int p_what) {
|
|
} break;
|
|
} break;
|
|
|
|
|
|
case NOTIFICATION_READY: {
|
|
case NOTIFICATION_READY: {
|
|
|
|
+ EditorSettingsPropertyWrapper::restart_request_callback = callable_mp(this, &EditorSettingsDialog::_editor_restart_request);
|
|
|
|
+
|
|
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);
|
|
@@ -1009,4 +1013,121 @@ EditorSettingsDialog::EditorSettingsDialog() {
|
|
add_child(timer);
|
|
add_child(timer);
|
|
EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &EditorSettingsDialog::_settings_changed));
|
|
EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &EditorSettingsDialog::_settings_changed));
|
|
set_ok_button_text(TTRC("Close"));
|
|
set_ok_button_text(TTRC("Close"));
|
|
|
|
+
|
|
|
|
+ Ref<EditorSettingsInspectorPlugin> plugin;
|
|
|
|
+ plugin.instantiate();
|
|
|
|
+ plugin->inspector = inspector;
|
|
|
|
+ EditorInspector::add_inspector_plugin(plugin);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void EditorSettingsPropertyWrapper::_update_override() {
|
|
|
|
+ // Don't allow overriding theme properties, because it causes problems. Overriding Project Manager settings makes no sense.
|
|
|
|
+ // TODO: Find a better way to define exception prefixes (if the list happens to grow).
|
|
|
|
+ if (property.begins_with("interface/theme") || property.begins_with("project_manager")) {
|
|
|
|
+ can_override = false;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const bool has_override = ProjectSettings::get_singleton()->has_editor_setting_override(property);
|
|
|
|
+ if (has_override) {
|
|
|
|
+ const Variant override_value = EDITOR_GET(property);
|
|
|
|
+ override_label->set_text(vformat(TTR("Overridden in project: %s"), override_value));
|
|
|
|
+ // In case the text is too long and trimmed.
|
|
|
|
+ override_label->set_tooltip_text(override_value);
|
|
|
|
+ }
|
|
|
|
+ override_info->set_visible(has_override);
|
|
|
|
+ can_override = !has_override;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void EditorSettingsPropertyWrapper::_create_override() {
|
|
|
|
+ ProjectSettings::get_singleton()->set_editor_setting_override(property, EDITOR_GET(property));
|
|
|
|
+ ProjectSettings::get_singleton()->save();
|
|
|
|
+ _update_override();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void EditorSettingsPropertyWrapper::_remove_override() {
|
|
|
|
+ ProjectSettings::get_singleton()->set_editor_setting_override(property, Variant());
|
|
|
|
+ ProjectSettings::get_singleton()->save();
|
|
|
|
+ EditorSettings::get_singleton()->mark_setting_changed(property);
|
|
|
|
+ EditorNode::get_singleton()->notify_settings_overrides_changed();
|
|
|
|
+ _update_override();
|
|
|
|
+
|
|
|
|
+ if (requires_restart) {
|
|
|
|
+ restart_request_callback.call();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void EditorSettingsPropertyWrapper::_notification(int p_what) {
|
|
|
|
+ if (p_what == NOTIFICATION_THEME_CHANGED) {
|
|
|
|
+ goto_button->set_button_icon(get_editor_theme_icon(SNAME("MethodOverride")));
|
|
|
|
+ remove_button->set_button_icon(get_editor_theme_icon(SNAME("Close")));
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void EditorSettingsPropertyWrapper::update_property() {
|
|
|
|
+ editor_property->update_property();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void EditorSettingsPropertyWrapper::setup(const String &p_property, EditorProperty *p_editor_property, bool p_requires_restart) {
|
|
|
|
+ requires_restart = p_requires_restart;
|
|
|
|
+
|
|
|
|
+ property = p_property;
|
|
|
|
+ container = memnew(VBoxContainer);
|
|
|
|
+
|
|
|
|
+ editor_property = p_editor_property;
|
|
|
|
+ editor_property->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
+ container->add_child(editor_property);
|
|
|
|
+
|
|
|
|
+ override_info = memnew(HBoxContainer);
|
|
|
|
+ override_info->hide();
|
|
|
|
+ container->add_child(override_info);
|
|
|
|
+
|
|
|
|
+ override_label = memnew(Label);
|
|
|
|
+ override_label->set_text_overrun_behavior(TextServer::OVERRUN_TRIM_ELLIPSIS);
|
|
|
|
+ override_label->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
|
|
|
|
+ override_label->set_mouse_filter(MOUSE_FILTER_STOP); // For tooltip.
|
|
|
|
+ override_label->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
+ override_info->add_child(override_label);
|
|
|
|
+
|
|
|
|
+ goto_button = memnew(Button);
|
|
|
|
+ goto_button->set_tooltip_text(TTRC("Go to the override in the Project Settings."));
|
|
|
|
+ override_info->add_child(goto_button);
|
|
|
|
+ goto_button->connect(SceneStringName(pressed), callable_mp(EditorNode::get_singleton(), &EditorNode::open_setting_override).bind(property), CONNECT_DEFERRED);
|
|
|
|
+
|
|
|
|
+ remove_button = memnew(Button);
|
|
|
|
+ remove_button->set_tooltip_text(TTRC("Remove this override."));
|
|
|
|
+ override_info->add_child(remove_button);
|
|
|
|
+ remove_button->connect(SceneStringName(pressed), callable_mp(this, &EditorSettingsPropertyWrapper::_remove_override));
|
|
|
|
+
|
|
|
|
+ add_child(container);
|
|
|
|
+ _update_override();
|
|
|
|
+
|
|
|
|
+ connect(SNAME("property_overridden"), callable_mp(this, &EditorSettingsPropertyWrapper::_create_override));
|
|
|
|
+ editor_property->connect("property_changed", callable_mp((EditorProperty *)this, &EditorProperty::emit_changed));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool EditorSettingsInspectorPlugin::can_handle(Object *p_object) {
|
|
|
|
+ return p_object->is_class("SectionedInspectorFilter") && p_object != current_object;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool EditorSettingsInspectorPlugin::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide) {
|
|
|
|
+ if (!p_object->is_class("SectionedInspectorFilter")) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const String property = inspector->get_full_item_path(p_path);
|
|
|
|
+ if (!EditorSettings::get_singleton()->has_setting(property)) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ current_object = p_object;
|
|
|
|
+
|
|
|
|
+ EditorSettingsPropertyWrapper *editor = memnew(EditorSettingsPropertyWrapper);
|
|
|
|
+ EditorProperty *real_property = inspector->get_inspector()->instantiate_property_editor(p_object, p_type, p_path, p_hint, p_hint_text, p_usage, p_wide);
|
|
|
|
+ real_property->set_object_and_property(p_object, p_path);
|
|
|
|
+ real_property->set_name_split_ratio(0.0);
|
|
|
|
+ editor->setup(property, real_property, bool(p_usage & PROPERTY_USAGE_RESTART_IF_CHANGED));
|
|
|
|
+
|
|
|
|
+ add_property_editor(p_path, editor);
|
|
|
|
+ current_object = nullptr;
|
|
|
|
+ return true;
|
|
}
|
|
}
|