From 876c383af0028f44d625f811eec27f3bfee198c2 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 21 Mar 2024 21:12:00 -0500 Subject: [PATCH] Allow save input and undo redo in Editor Options --- Source/Editor/Windows/EditorOptionsWindow.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Windows/EditorOptionsWindow.cs b/Source/Editor/Windows/EditorOptionsWindow.cs index 31dea22e3..e9c4385b5 100644 --- a/Source/Editor/Windows/EditorOptionsWindow.cs +++ b/Source/Editor/Windows/EditorOptionsWindow.cs @@ -23,6 +23,7 @@ namespace FlaxEditor.Windows private Tabs _tabs; private EditorOptions _options; private ToolStripButton _saveButton; + private readonly Undo _undo; private readonly List _customTabs = new List(); /// @@ -33,6 +34,12 @@ namespace FlaxEditor.Windows : base(editor, true, ScrollBars.None) { Title = "Editor Options"; + + // Undo + _undo = new Undo(); + _undo.UndoDone += OnUndoRedo; + _undo.RedoDone += OnUndoRedo; + _undo.ActionDone += OnUndoRedo; var toolstrip = new ToolStrip { @@ -58,9 +65,19 @@ namespace FlaxEditor.Windows CreateTab("Visual", () => _options.Visual); CreateTab("Source Code", () => _options.SourceCode); CreateTab("Theme", () => _options.Theme); + + // Setup input actions + InputActions.Add(options => options.Undo, _undo.PerformUndo); + InputActions.Add(options => options.Redo, _undo.PerformRedo); + InputActions.Add(options => options.Save, SaveData); _tabs.SelectedTabIndex = 0; } + + private void OnUndoRedo(IUndoAction action) + { + MarkAsEdited(); + } private Tab CreateTab(string name, Func getValue) { @@ -73,7 +90,7 @@ namespace FlaxEditor.Windows Parent = tab }; - var settings = new CustomEditorPresenter(null); + var settings = new CustomEditorPresenter(_undo); settings.Panel.Parent = panel; settings.Panel.Tag = getValue; settings.Modified += MarkAsEdited;