mirror of
https://github.com/ppy/osu
synced 2024-12-26 17:02:59 +00:00
Add basic hotkey offset adjust support (via existing offset control)
This commit is contained in:
parent
fc56188b95
commit
27a9dcc5a1
@ -160,6 +160,8 @@ namespace osu.Game.Input.Bindings
|
||||
new KeyBinding(InputKey.Enter, GlobalAction.ToggleChatFocus),
|
||||
new KeyBinding(InputKey.F1, GlobalAction.SaveReplay),
|
||||
new KeyBinding(InputKey.F2, GlobalAction.ExportReplay),
|
||||
new KeyBinding(InputKey.Plus, GlobalAction.IncreaseOffset),
|
||||
new KeyBinding(InputKey.Minus, GlobalAction.DecreaseOffset),
|
||||
};
|
||||
|
||||
private static IEnumerable<KeyBinding> replayKeyBindings => new[]
|
||||
@ -404,6 +406,12 @@ namespace osu.Game.Input.Bindings
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorToggleRotateControl))]
|
||||
EditorToggleRotateControl,
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.IncreaseOffset))]
|
||||
IncreaseOffset,
|
||||
|
||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.DecreaseOffset))]
|
||||
DecreaseOffset
|
||||
}
|
||||
|
||||
public enum GlobalActionCategory
|
||||
|
@ -344,6 +344,16 @@ namespace osu.Game.Localisation
|
||||
/// </summary>
|
||||
public static LocalisableString ExportReplay => new TranslatableString(getKey(@"export_replay"), @"Export replay");
|
||||
|
||||
/// <summary>
|
||||
/// "Increase offset"
|
||||
/// </summary>
|
||||
public static LocalisableString IncreaseOffset => new TranslatableString(getKey(@"increase_offset"), @"Increase offset");
|
||||
|
||||
/// <summary>
|
||||
/// "Decrease offset"
|
||||
/// </summary>
|
||||
public static LocalisableString DecreaseOffset => new TranslatableString(getKey(@"decrease_offset"), @"Decrease offset");
|
||||
|
||||
/// <summary>
|
||||
/// "Toggle rotate control"
|
||||
/// </summary>
|
||||
|
@ -9,6 +9,8 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -16,6 +18,7 @@ using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
@ -26,7 +29,7 @@ using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Play.PlayerSettings
|
||||
{
|
||||
public partial class BeatmapOffsetControl : CompositeDrawable
|
||||
public partial class BeatmapOffsetControl : CompositeDrawable, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
public Bindable<ScoreInfo?> ReferenceScore { get; } = new Bindable<ScoreInfo?>();
|
||||
|
||||
@ -88,28 +91,6 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
||||
};
|
||||
}
|
||||
|
||||
public partial class OffsetSliderBar : PlayerSliderBar<double>
|
||||
{
|
||||
protected override Drawable CreateControl() => new CustomSliderBar();
|
||||
|
||||
protected partial class CustomSliderBar : SliderBar
|
||||
{
|
||||
public override LocalisableString TooltipText =>
|
||||
Current.Value == 0
|
||||
? LocalisableString.Interpolate($@"{base.TooltipText} ms")
|
||||
: LocalisableString.Interpolate($@"{base.TooltipText} ms {getEarlyLateText(Current.Value)}");
|
||||
|
||||
private LocalisableString getEarlyLateText(double value)
|
||||
{
|
||||
Debug.Assert(value != 0);
|
||||
|
||||
return value > 0
|
||||
? BeatmapOffsetControlStrings.HitObjectsAppearEarlier
|
||||
: BeatmapOffsetControlStrings.HitObjectsAppearLater;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
@ -243,5 +224,51 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
||||
base.Dispose(isDisposing);
|
||||
beatmapOffsetSubscription?.Dispose();
|
||||
}
|
||||
|
||||
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
||||
{
|
||||
double amount = e.AltPressed ? 1 : 5;
|
||||
|
||||
switch (e.Action)
|
||||
{
|
||||
case GlobalAction.IncreaseOffset:
|
||||
Current.Value += amount;
|
||||
|
||||
return true;
|
||||
|
||||
case GlobalAction.DecreaseOffset:
|
||||
Current.Value -= amount;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
|
||||
{
|
||||
}
|
||||
|
||||
public partial class OffsetSliderBar : PlayerSliderBar<double>
|
||||
{
|
||||
protected override Drawable CreateControl() => new CustomSliderBar();
|
||||
|
||||
protected partial class CustomSliderBar : SliderBar
|
||||
{
|
||||
public override LocalisableString TooltipText =>
|
||||
Current.Value == 0
|
||||
? LocalisableString.Interpolate($@"{base.TooltipText} ms")
|
||||
: LocalisableString.Interpolate($@"{base.TooltipText} ms {getEarlyLateText(Current.Value)}");
|
||||
|
||||
private LocalisableString getEarlyLateText(double value)
|
||||
{
|
||||
Debug.Assert(value != 0);
|
||||
|
||||
return value > 0
|
||||
? BeatmapOffsetControlStrings.HitObjectsAppearEarlier
|
||||
: BeatmapOffsetControlStrings.HitObjectsAppearLater;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user