mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 23:23:04 +08:00
Fix selection box operation hotkeys not registering in change handler
Could lead to crashes after reversing a note cluster and playing it back. The root cause of the crash was that the hotkey operations were not ran inside of an editor change handler operation. This, in turn, caused the autoplay replay to not be regenerated after flipping an object cluster, therefore finally manifesting as a hard crash due to negative time offsets appearing in judgement results, which interfered with the default implementation of note lock. Note that this incidentally also fixes the fact that selection box hotkey operations (reverse and flip) did not handle undo/redo.
This commit is contained in:
parent
5a7e416495
commit
2e63c2ce20
@ -113,16 +113,25 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
if (e.Repeat || !e.ControlPressed)
|
if (e.Repeat || !e.ControlPressed)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
bool runOperationFromHotkey(Func<bool> operation)
|
||||||
|
{
|
||||||
|
operationStarted();
|
||||||
|
bool result = operation?.Invoke() ?? false;
|
||||||
|
operationEnded();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
switch (e.Key)
|
switch (e.Key)
|
||||||
{
|
{
|
||||||
case Key.G:
|
case Key.G:
|
||||||
return CanReverse && OnReverse?.Invoke() == true;
|
return CanReverse && runOperationFromHotkey(OnReverse);
|
||||||
|
|
||||||
case Key.H:
|
case Key.H:
|
||||||
return CanScaleX && OnFlip?.Invoke(Direction.Horizontal) == true;
|
return CanScaleX && runOperationFromHotkey(() => OnFlip?.Invoke(Direction.Horizontal) ?? false);
|
||||||
|
|
||||||
case Key.J:
|
case Key.J:
|
||||||
return CanScaleY && OnFlip?.Invoke(Direction.Vertical) == true;
|
return CanScaleY && runOperationFromHotkey(() => OnFlip?.Invoke(Direction.Vertical) ?? false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return base.OnKeyDown(e);
|
return base.OnKeyDown(e);
|
||||||
|
Loading…
Reference in New Issue
Block a user