From 31a6c052f31cb96538ea14b6801ab9d90015936a Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 14 Mar 2023 12:33:29 +0100 Subject: [PATCH 1/7] Fix tests build --- Source/Tools/FlaxEngine.Tests/FlaxEngine.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Tools/FlaxEngine.Tests/FlaxEngine.Tests.csproj b/Source/Tools/FlaxEngine.Tests/FlaxEngine.Tests.csproj index 89426d3fd..6a57cc83c 100644 --- a/Source/Tools/FlaxEngine.Tests/FlaxEngine.Tests.csproj +++ b/Source/Tools/FlaxEngine.Tests/FlaxEngine.Tests.csproj @@ -70,7 +70,7 @@ - + {ed088b51-41ac-403b-9b3e-91a38c41523e} FlaxEngine From 1a2eb487052ea8fb9c20125457a13351d860ed9b Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 16 Mar 2023 20:54:56 -0500 Subject: [PATCH 2/7] Added updating the main menu shortcut keys on editor options saved. Also adds an action that can be used to update plugin short keys if needed. --- Source/Editor/Modules/UIModule.cs | 55 +++++++++++++++----- Source/Editor/Windows/EditorOptionsWindow.cs | 2 + 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/Source/Editor/Modules/UIModule.cs b/Source/Editor/Modules/UIModule.cs index 4edd4540b..2e106e52e 100644 --- a/Source/Editor/Modules/UIModule.cs +++ b/Source/Editor/Modules/UIModule.cs @@ -39,6 +39,7 @@ namespace FlaxEditor.Modules private ContextMenuButton _menuFileSaveScenes; private ContextMenuButton _menuFileCloseScenes; private ContextMenuButton _menuFileGenerateScriptsProjectFiles; + private ContextMenuButton _menuSaveAll; private ContextMenuButton _menuEditUndo; private ContextMenuButton _menuEditRedo; private ContextMenuButton _menuEditCut; @@ -47,6 +48,7 @@ namespace FlaxEditor.Modules private ContextMenuButton _menuEditDelete; private ContextMenuButton _menuEditDuplicate; private ContextMenuButton _menuEditSelectAll; + private ContextMenuButton _menuEditFind; private ContextMenuButton _menuSceneMoveActorToViewport; private ContextMenuButton _menuSceneAlignActorWithViewport; private ContextMenuButton _menuSceneAlignViewportWithActor; @@ -136,6 +138,11 @@ namespace FlaxEditor.Modules /// public MainMenuButton MenuHelp { get; private set; } + /// + /// Fired when the main menu short cut keys are updated. Can be used to update plugin short cut keys. + /// + public event Action MainMenuShortcutKeysUpdated; + internal UIModule(Editor editor) : base(editor) { @@ -464,11 +471,13 @@ namespace FlaxEditor.Modules Parent = mainWindow }; + var inputOptions = Editor.Options.Options.Input; + // File MenuFile = MainMenu.AddButton("File"); var cm = MenuFile.ContextMenu; cm.VisibleChanged += OnMenuFileShowHide; - cm.AddButton("Save All", "Ctrl+S", Editor.SaveAll); + _menuSaveAll = cm.AddButton("Save All", inputOptions.Save.ToString(), Editor.SaveAll); _menuFileSaveScenes = cm.AddButton("Save scenes", Editor.Scene.SaveScenes); _menuFileCloseScenes = cm.AddButton("Close scenes", Editor.Scene.CloseAllScenes); cm.AddSeparator(); @@ -484,18 +493,18 @@ namespace FlaxEditor.Modules MenuEdit = MainMenu.AddButton("Edit"); cm = MenuEdit.ContextMenu; cm.VisibleChanged += OnMenuEditShowHide; - _menuEditUndo = cm.AddButton(string.Empty, "Ctrl+Z", Editor.PerformUndo); - _menuEditRedo = cm.AddButton(string.Empty, "Ctrl+Y", Editor.PerformRedo); + _menuEditUndo = cm.AddButton(string.Empty, inputOptions.Undo.ToString(), Editor.PerformUndo); + _menuEditRedo = cm.AddButton(string.Empty, inputOptions.Redo.ToString(), Editor.PerformRedo); cm.AddSeparator(); - _menuEditCut = cm.AddButton("Cut", "Ctrl+X", Editor.SceneEditing.Cut); - _menuEditCopy = cm.AddButton("Copy", "Ctrl+C", Editor.SceneEditing.Copy); - _menuEditPaste = cm.AddButton("Paste", "Ctrl+V", Editor.SceneEditing.Paste); + _menuEditCut = cm.AddButton("Cut", inputOptions.Cut.ToString(), Editor.SceneEditing.Cut); + _menuEditCopy = cm.AddButton("Copy", inputOptions.Copy.ToString(), Editor.SceneEditing.Copy); + _menuEditPaste = cm.AddButton("Paste", inputOptions.Paste.ToString(), Editor.SceneEditing.Paste); cm.AddSeparator(); - _menuEditDelete = cm.AddButton("Delete", "Del", Editor.SceneEditing.Delete); - _menuEditDuplicate = cm.AddButton("Duplicate", "Ctrl+D", Editor.SceneEditing.Duplicate); + _menuEditDelete = cm.AddButton("Delete", inputOptions.Delete.ToString(), Editor.SceneEditing.Delete); + _menuEditDuplicate = cm.AddButton("Duplicate", inputOptions.Duplicate.ToString(), Editor.SceneEditing.Duplicate); cm.AddSeparator(); - _menuEditSelectAll = cm.AddButton("Select all", "Ctrl+A", Editor.SceneEditing.SelectAllScenes); - cm.AddButton("Find", "Ctrl+F", Editor.Windows.SceneWin.Search); + _menuEditSelectAll = cm.AddButton("Select all", inputOptions.SelectAll.ToString(), Editor.SceneEditing.SelectAllScenes); + _menuEditFind = cm.AddButton("Find", inputOptions.Search.ToString(), Editor.Windows.SceneWin.Search); // Scene MenuScene = MainMenu.AddButton("Scene"); @@ -512,8 +521,8 @@ namespace FlaxEditor.Modules MenuGame = MainMenu.AddButton("Game"); cm = MenuGame.ContextMenu; cm.VisibleChanged += OnMenuGameShowHide; - _menuGamePlay = cm.AddButton("Play", "F5", Editor.Simulation.RequestStartPlay); - _menuGamePause = cm.AddButton("Pause", "F6", Editor.Simulation.RequestPausePlay); + _menuGamePlay = cm.AddButton("Play", inputOptions.Play.ToString(), Editor.Simulation.RequestStartPlay); + _menuGamePause = cm.AddButton("Pause", inputOptions.Pause.ToString(), Editor.Simulation.RequestPausePlay); cm.AddSeparator(); cm.AddButton("Cook&Run", Editor.Windows.GameCookerWin.BuildAndRun).LinkTooltip("Runs Game Cooker to build the game for this platform and runs the game after."); cm.AddButton("Run cooked game", Editor.Windows.GameCookerWin.RunCooked).LinkTooltip("Runs the game build from the last cooking output. Use Cook&Play or Game Cooker first."); @@ -579,6 +588,28 @@ namespace FlaxEditor.Modules cm.AddButton("Information about Flax", () => new AboutDialog().Show()); } + /// + /// Updates the short cut keys for the main menu + /// + public void UpdateMainMenuShortcuts() + { + var inputOptions = Editor.Options.Options.Input; + + _menuSaveAll.ShortKeys = inputOptions.Save.ToString(); + _menuEditUndo.ShortKeys = inputOptions.Undo.ToString(); + _menuEditRedo.ShortKeys = inputOptions.Redo.ToString(); + _menuEditCut.ShortKeys = inputOptions.Cut.ToString(); + _menuEditCopy.ShortKeys = inputOptions.Copy.ToString(); + _menuEditDelete.ShortKeys = inputOptions.Delete.ToString(); + _menuEditDuplicate.ShortKeys = inputOptions.Duplicate.ToString(); + _menuEditSelectAll.ShortKeys = inputOptions.SelectAll.ToString(); + _menuEditFind.ShortKeys = inputOptions.Search.ToString(); + _menuGamePlay.ShortKeys = inputOptions.Play.ToString(); + _menuGamePause.ShortKeys = inputOptions.Pause.ToString(); + + MainMenuShortcutKeysUpdated?.Invoke(); + } + private void InitToolstrip(RootControl mainWindow) { ToolStrip = new ToolStrip(34.0f, MainMenu.Bottom) diff --git a/Source/Editor/Windows/EditorOptionsWindow.cs b/Source/Editor/Windows/EditorOptionsWindow.cs index 2942f98c0..4597eeae5 100644 --- a/Source/Editor/Windows/EditorOptionsWindow.cs +++ b/Source/Editor/Windows/EditorOptionsWindow.cs @@ -144,6 +144,8 @@ namespace FlaxEditor.Windows } Editor.Options.Apply(_options); + + Editor.UI.UpdateMainMenuShortcuts(); ClearDirtyFlag(); } From 98ebbf8b9987a4f232e5da8f0ac7367371b3b199 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 16 Mar 2023 21:03:36 -0500 Subject: [PATCH 3/7] Fix double color change on animation state machine states --- .../Editor/Surface/Archetypes/Animation.StateMachine.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Source/Editor/Surface/Archetypes/Animation.StateMachine.cs b/Source/Editor/Surface/Archetypes/Animation.StateMachine.cs index 334ed4742..3859f842f 100644 --- a/Source/Editor/Surface/Archetypes/Animation.StateMachine.cs +++ b/Source/Editor/Surface/Archetypes/Animation.StateMachine.cs @@ -357,10 +357,8 @@ namespace FlaxEditor.Surface.Archetypes BackgroundColor = style.BackgroundNormal; var dragAreaColor = BackgroundColor / 2.0f; - if (IsMouseOver) - BackgroundColor *= 1.2f; if (_textRectHovered) - BackgroundColor *= 1.2f; + BackgroundColor *= 1.5f; Render2D.FillRectangle(_textRect, BackgroundColor); Render2D.FillRectangle(_dragAreaRect, dragAreaColor); @@ -1192,10 +1190,8 @@ namespace FlaxEditor.Surface.Archetypes BackgroundColor = style.BackgroundNormal; var dragAreaColor = BackgroundColor / 2.0f; - if (IsMouseOver) - BackgroundColor *= 1.2f; if (_textRectHovered) - BackgroundColor *= 1.2f; + BackgroundColor *= 1.5f; Render2D.FillRectangle(_textRect, BackgroundColor); Render2D.FillRectangle(_dragAreaRect, dragAreaColor); From 773047dc69514fa082c7799d3a15604f78169e8b Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 16 Mar 2023 21:46:07 -0500 Subject: [PATCH 4/7] Add Copy Euler angles to Quaternion editor. --- Source/Editor/CustomEditors/Editors/QuaternionEditor.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/Editor/CustomEditors/Editors/QuaternionEditor.cs b/Source/Editor/CustomEditors/Editors/QuaternionEditor.cs index 637b3ecaf..3a469dd1a 100644 --- a/Source/Editor/CustomEditors/Editors/QuaternionEditor.cs +++ b/Source/Editor/CustomEditors/Editors/QuaternionEditor.cs @@ -3,6 +3,7 @@ using FlaxEditor.CustomEditors.Elements; using FlaxEngine; using FlaxEngine.GUI; +using FlaxEngine.Json; namespace FlaxEditor.CustomEditors.Editors { @@ -54,6 +55,13 @@ namespace FlaxEditor.CustomEditors.Editors ZElement = grid.FloatValue(); ZElement.ValueBox.ValueChanged += OnValueChanged; ZElement.ValueBox.SlidingEnd += ClearToken; + + LinkedLabel.SetupContextMenu += (label, menu, editor) => + { + menu.AddSeparator(); + var value = ((Quaternion)Values[0]).EulerAngles; + menu.AddButton("Copy Euler", () => { Clipboard.Text = JsonSerializer.Serialize(value); }).TooltipText = "Copy the Euler Angles in Degrees"; + }; } private void OnValueChanged() From 27ab8ea404709c11a2839d75781726cf5f4ecbd5 Mon Sep 17 00:00:00 2001 From: Wiktor Kocielski <118038102+Withaust@users.noreply.github.com> Date: Sun, 26 Mar 2023 15:12:53 +0300 Subject: [PATCH 5/7] Make InputBindings modifiable --- Source/Editor/Options/InputBinding.cs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Source/Editor/Options/InputBinding.cs b/Source/Editor/Options/InputBinding.cs index d007be9a7..83789338a 100644 --- a/Source/Editor/Options/InputBinding.cs +++ b/Source/Editor/Options/InputBinding.cs @@ -397,14 +397,17 @@ namespace FlaxEditor.Options } } - private readonly List _bindings; + /// + /// List of all available bindings. + /// + public List Bindings; /// /// Initializes a new instance of the class. /// public InputActionsContainer() { - _bindings = new List(); + Bindings = new List(); } /// @@ -413,7 +416,7 @@ namespace FlaxEditor.Options /// The input bindings collection. public InputActionsContainer(params Binding[] bindings) { - _bindings = new List(bindings); + Bindings = new List(bindings); } /// @@ -422,7 +425,7 @@ namespace FlaxEditor.Options /// The input binding. public void Add(Binding binding) { - _bindings.Add(binding); + Bindings.Add(binding); } /// @@ -432,7 +435,7 @@ namespace FlaxEditor.Options /// The callback to invoke on user input. public void Add(Func binder, Action callback) { - _bindings.Add(new Binding(binder, callback)); + Bindings.Add(new Binding(binder, callback)); } /// @@ -441,7 +444,7 @@ namespace FlaxEditor.Options /// The input bindings collection. public void Add(params Binding[] bindings) { - _bindings.AddRange(bindings); + Bindings.AddRange(bindings); } /// @@ -456,12 +459,12 @@ namespace FlaxEditor.Options var root = control.Root; var options = editor.Options.Options.Input; - for (int i = 0; i < _bindings.Count; i++) + for (int i = 0; i < Bindings.Count; i++) { - var binding = _bindings[i].Binder(options); + var binding = Bindings[i].Binder(options); if (binding.Process(control, key)) { - _bindings[i].Callback(); + Bindings[i].Callback(); return true; } } From a8c6b2b619d5674318b262d710ec4e62ca8b6b35 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 4 Apr 2023 15:56:56 +0200 Subject: [PATCH 6/7] Fix crash on end play when one of the actors has been manually disabled --- Source/Engine/Level/Actor.cpp | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/Source/Engine/Level/Actor.cpp b/Source/Engine/Level/Actor.cpp index 1c2f1768e..090f3c071 100644 --- a/Source/Engine/Level/Actor.cpp +++ b/Source/Engine/Level/Actor.cpp @@ -802,18 +802,7 @@ void Actor::Initialize() void Actor::BeginPlay(SceneBeginData* data) { - // Perform additional verification ASSERT(!IsDuringPlay()); -#if BUILD_DEBUG - for (int32 i = 0; i < Children.Count(); i++) - { - ASSERT(Children[i]->IsDuringPlay() == IsDuringPlay()); - } - for (int32 i = 0; i < Scripts.Count(); i++) - { - ASSERT(Scripts[i]->IsDuringPlay() == IsDuringPlay()); - } -#endif // Set flag Flags |= ObjectFlags::IsDuringPlay; @@ -843,18 +832,7 @@ void Actor::BeginPlay(SceneBeginData* data) void Actor::EndPlay() { - // Perform additional verification ASSERT(IsDuringPlay()); -#if BUILD_DEBUG - for (int32 i = 0; i < Children.Count(); i++) - { - ASSERT(Children[i]->IsDuringPlay() == IsDuringPlay()); - } - for (int32 i = 0; i < Scripts.Count(); i++) - { - ASSERT(Scripts[i]->IsDuringPlay() == IsDuringPlay()); - } -#endif // Fire event for scripting if (IsActiveInHierarchy() && GetScene()) @@ -871,7 +849,8 @@ void Actor::EndPlay() // Call event deeper for (int32 i = 0; i < Children.Count(); i++) { - Children[i]->EndPlay(); + if (Children[i]->IsDuringPlay()) + Children[i]->EndPlay(); } // Fire event for scripting @@ -886,7 +865,8 @@ void Actor::EndPlay() // Inform attached scripts for (int32 i = 0; i < Scripts.Count(); i++) { - Scripts[i]->EndPlay(); + if (Scripts[i]->IsDuringPlay()) + Scripts[i]->EndPlay(); } // Cleanup managed object From 6c8b5e5e8a350771e83fd6444e3faac03606a4a5 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 4 Apr 2023 17:40:05 +0200 Subject: [PATCH 7/7] Improve #970 by using `OptionsChanged` event --- Source/Editor/Modules/UIModule.cs | 13 ++++++------- Source/Editor/Windows/EditorOptionsWindow.cs | 2 -- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Source/Editor/Modules/UIModule.cs b/Source/Editor/Modules/UIModule.cs index 2e106e52e..9f8167731 100644 --- a/Source/Editor/Modules/UIModule.cs +++ b/Source/Editor/Modules/UIModule.cs @@ -356,6 +356,8 @@ namespace FlaxEditor.Modules InitStatusBar(mainWindow); InitDockPanel(mainWindow); + Editor.Options.OptionsChanged += OnOptionsChanged; + // Add dummy control for drawing the main window borders if using a custom style #if PLATFORM_WINDOWS if (!Editor.Options.Options.Interface.UseNativeWindowSystem) @@ -588,13 +590,10 @@ namespace FlaxEditor.Modules cm.AddButton("Information about Flax", () => new AboutDialog().Show()); } - /// - /// Updates the short cut keys for the main menu - /// - public void UpdateMainMenuShortcuts() + private void OnOptionsChanged(FlaxEditor.Options.EditorOptions options) { - var inputOptions = Editor.Options.Options.Input; - + var inputOptions = options.Input; + _menuSaveAll.ShortKeys = inputOptions.Save.ToString(); _menuEditUndo.ShortKeys = inputOptions.Undo.ToString(); _menuEditRedo.ShortKeys = inputOptions.Redo.ToString(); @@ -606,7 +605,7 @@ namespace FlaxEditor.Modules _menuEditFind.ShortKeys = inputOptions.Search.ToString(); _menuGamePlay.ShortKeys = inputOptions.Play.ToString(); _menuGamePause.ShortKeys = inputOptions.Pause.ToString(); - + MainMenuShortcutKeysUpdated?.Invoke(); } diff --git a/Source/Editor/Windows/EditorOptionsWindow.cs b/Source/Editor/Windows/EditorOptionsWindow.cs index 4597eeae5..2942f98c0 100644 --- a/Source/Editor/Windows/EditorOptionsWindow.cs +++ b/Source/Editor/Windows/EditorOptionsWindow.cs @@ -144,8 +144,6 @@ namespace FlaxEditor.Windows } Editor.Options.Apply(_options); - - Editor.UI.UpdateMainMenuShortcuts(); ClearDirtyFlag(); }