Skip to content

Commit

Permalink
Disabled undo/redo commands as long as a dialog or the guide overlay …
Browse files Browse the repository at this point in the history
…is open
  • Loading branch information
BlackTasty committed Mar 17, 2024
1 parent f7ed580 commit 48c15c4
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions SLC_LayoutEditor/Resources/patchnotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Added: You can now manage pre-packaged templates either via "Editor" -> "Manage default templates" or via the settings
Added: Two new default templates have been added ("B744 - Boeing 747-400" and "B748 - Boeing 747-8i")
Changed: Added some more logging to the undo/redo system
Changed: The undo and redo commands (Ctrl+Z and Ctrl+Y) are now only available if no dialog or guide overlay is open or the current view is not the editor (e.g. settings)
Fixed: Potential fix for a crash when undoing/redoing a step
Fixed: "Rows" and "Columns" texts have been swapped
Fixed: When undoing or redoing multiple steps, the editor no longer checks for issues for every step
1 change: 1 addition & 0 deletions SLC_LayoutEditor/SLC_LayoutEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@
<Compile Include="ViewModel\BaseDialogViewModel.cs" />
<Compile Include="ViewModel\Commands\CancelDialogCommand.cs" />
<Compile Include="ViewModel\Commands\CommandInterface.cs" />
<Compile Include="ViewModel\Commands\HistoryCommandBase.cs" />
<Compile Include="ViewModel\Commands\LayoutBaseCommand.cs" />
<Compile Include="ViewModel\Commands\MakeTemplateCommand.cs" />
<Compile Include="ViewModel\Commands\OpenLayoutFolderCommand.cs" />
Expand Down
17 changes: 17 additions & 0 deletions SLC_LayoutEditor/ViewModel/Commands/HistoryCommandBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tasty.ViewModel.Commands;

namespace SLC_LayoutEditor.ViewModel.Commands
{
internal class HistoryCommandBase : CommandBase
{
public override bool CanExecute(object parameter)
{
return parameter is MainViewModel vm && vm.AllowHistoryCommands;
}
}
}
4 changes: 2 additions & 2 deletions SLC_LayoutEditor/ViewModel/Commands/RedoCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

namespace SLC_LayoutEditor.ViewModel.Commands
{
internal class RedoCommand : CommandBase
internal class RedoCommand : HistoryCommandBase
{
public override bool CanExecute(object parameter)
{
return parameter is MainViewModel vm && !vm.IsViewNotEditor && vm.History.CanRedo;
return base.CanExecute(parameter) && parameter is MainViewModel vm && vm.History.CanRedo;
}

public override void Execute(object parameter)
Expand Down
4 changes: 2 additions & 2 deletions SLC_LayoutEditor/ViewModel/Commands/UndoCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

namespace SLC_LayoutEditor.ViewModel.Commands
{
internal class UndoCommand : CommandBase
internal class UndoCommand : HistoryCommandBase
{
public override bool CanExecute(object parameter)
{
return parameter is MainViewModel vm && !vm.IsViewNotEditor && vm.History.CanUndo;
return base.CanExecute(parameter) && parameter is MainViewModel vm && vm.History.CanUndo;
}

public override void Execute(object parameter)
Expand Down
5 changes: 5 additions & 0 deletions SLC_LayoutEditor/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ public CabinDeckControl SelectedDeck
}
}

public bool AllowHistoryCommands => !IsViewNotEditor && !IsDialogOpen && !mIsGuideOpen;

public bool IsViewNotEditor => !(mContent is LayoutEditor) && App.Settings.WelcomeScreenShown;

public bool IsTourRunning => App.GuidedTour?.IsTourRunning ?? false;
Expand All @@ -276,6 +278,9 @@ public CabinDeckControl SelectedDeck

public int MaxSteps => FixedValues.TOTAL_TOUR_STEPS;

/// <summary>
/// Defines if any <see cref="LiveGuideAdorner"/> is currently open
/// </summary>
public bool IsGuideOpen
{
get => mIsGuideOpen;
Expand Down

0 comments on commit 48c15c4

Please sign in to comment.