mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 09:03:50 +09:00
Move handling of replay seek operations out of progress bar
This is in order to avoid using the now obsoleted property `SliderBar.AllowKeyboardInputWhenNotHovered` (see https://github.com/ppy/osu-framework/pull/4579).
This commit is contained in:
@ -87,6 +87,8 @@ namespace osu.Game.Input.Bindings
|
|||||||
new KeyBinding(new[] { InputKey.Shift, InputKey.Tab }, GlobalAction.ToggleInGameInterface),
|
new KeyBinding(new[] { InputKey.Shift, InputKey.Tab }, GlobalAction.ToggleInGameInterface),
|
||||||
new KeyBinding(InputKey.MouseMiddle, GlobalAction.PauseGameplay),
|
new KeyBinding(InputKey.MouseMiddle, GlobalAction.PauseGameplay),
|
||||||
new KeyBinding(InputKey.Space, GlobalAction.TogglePauseReplay),
|
new KeyBinding(InputKey.Space, GlobalAction.TogglePauseReplay),
|
||||||
|
new KeyBinding(InputKey.Left, GlobalAction.SeekReplayBackward),
|
||||||
|
new KeyBinding(InputKey.Right, GlobalAction.SeekReplayForward),
|
||||||
new KeyBinding(InputKey.Control, GlobalAction.HoldForHUD),
|
new KeyBinding(InputKey.Control, GlobalAction.HoldForHUD),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -272,5 +274,11 @@ namespace osu.Game.Input.Bindings
|
|||||||
|
|
||||||
[Description("Next volume meter")]
|
[Description("Next volume meter")]
|
||||||
NextVolumeMeter,
|
NextVolumeMeter,
|
||||||
|
|
||||||
|
[Description("Seek replay forward")]
|
||||||
|
SeekReplayForward,
|
||||||
|
|
||||||
|
[Description("Seek replay backward")]
|
||||||
|
SeekReplayBackward,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,15 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens.Ranking;
|
using osu.Game.Screens.Ranking;
|
||||||
|
|
||||||
@ -43,10 +47,24 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
protected override ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score, false);
|
protected override ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score, false);
|
||||||
|
|
||||||
|
private ScheduledDelegate keyboardSeekDelegate;
|
||||||
|
|
||||||
public bool OnPressed(GlobalAction action)
|
public bool OnPressed(GlobalAction action)
|
||||||
{
|
{
|
||||||
|
const double keyboard_seek_amount = 5000;
|
||||||
|
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
|
case GlobalAction.SeekReplayBackward:
|
||||||
|
keyboardSeekDelegate?.Cancel();
|
||||||
|
keyboardSeekDelegate = this.BeginKeyRepeat(Scheduler, () => keyboardSeek(-1));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case GlobalAction.SeekReplayForward:
|
||||||
|
keyboardSeekDelegate?.Cancel();
|
||||||
|
keyboardSeekDelegate = this.BeginKeyRepeat(Scheduler, () => keyboardSeek(1));
|
||||||
|
return true;
|
||||||
|
|
||||||
case GlobalAction.TogglePauseReplay:
|
case GlobalAction.TogglePauseReplay:
|
||||||
if (GameplayClockContainer.IsPaused.Value)
|
if (GameplayClockContainer.IsPaused.Value)
|
||||||
GameplayClockContainer.Start();
|
GameplayClockContainer.Start();
|
||||||
@ -56,10 +74,24 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
void keyboardSeek(int direction)
|
||||||
|
{
|
||||||
|
double target = Math.Clamp(GameplayClockContainer.CurrentTime + direction * keyboard_seek_amount, 0, GameplayBeatmap.HitObjects.Last().GetEndTime());
|
||||||
|
|
||||||
|
Seek(target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnReleased(GlobalAction action)
|
public void OnReleased(GlobalAction action)
|
||||||
{
|
{
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case GlobalAction.SeekReplayBackward:
|
||||||
|
case GlobalAction.SeekReplayForward:
|
||||||
|
keyboardSeekDelegate?.Cancel();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,8 +57,6 @@ namespace osu.Game.Screens.Play
|
|||||||
set => CurrentNumber.Value = value;
|
set => CurrentNumber.Value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool AllowKeyboardInputWhenNotHovered => true;
|
|
||||||
|
|
||||||
public SongProgressBar(float barHeight, float handleBarHeight, Vector2 handleSize)
|
public SongProgressBar(float barHeight, float handleBarHeight, Vector2 handleSize)
|
||||||
{
|
{
|
||||||
CurrentNumber.MinValue = 0;
|
CurrentNumber.MinValue = 0;
|
||||||
|
Reference in New Issue
Block a user