mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 08:33:21 +08:00
Merge pull request #26076 from peppy/gameplay-offset-adjust
Add control to allow changing offset from gameplay
This commit is contained in:
commit
a0915a0dd1
@ -160,6 +160,8 @@ namespace osu.Game.Input.Bindings
|
|||||||
new KeyBinding(InputKey.Enter, GlobalAction.ToggleChatFocus),
|
new KeyBinding(InputKey.Enter, GlobalAction.ToggleChatFocus),
|
||||||
new KeyBinding(InputKey.F1, GlobalAction.SaveReplay),
|
new KeyBinding(InputKey.F1, GlobalAction.SaveReplay),
|
||||||
new KeyBinding(InputKey.F2, GlobalAction.ExportReplay),
|
new KeyBinding(InputKey.F2, GlobalAction.ExportReplay),
|
||||||
|
new KeyBinding(InputKey.Plus, GlobalAction.IncreaseOffset),
|
||||||
|
new KeyBinding(InputKey.Minus, GlobalAction.DecreaseOffset),
|
||||||
};
|
};
|
||||||
|
|
||||||
private static IEnumerable<KeyBinding> replayKeyBindings => new[]
|
private static IEnumerable<KeyBinding> replayKeyBindings => new[]
|
||||||
@ -404,6 +406,12 @@ namespace osu.Game.Input.Bindings
|
|||||||
|
|
||||||
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorToggleRotateControl))]
|
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorToggleRotateControl))]
|
||||||
EditorToggleRotateControl,
|
EditorToggleRotateControl,
|
||||||
|
|
||||||
|
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.IncreaseOffset))]
|
||||||
|
IncreaseOffset,
|
||||||
|
|
||||||
|
[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.DecreaseOffset))]
|
||||||
|
DecreaseOffset
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum GlobalActionCategory
|
public enum GlobalActionCategory
|
||||||
|
@ -344,6 +344,16 @@ namespace osu.Game.Localisation
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static LocalisableString ExportReplay => new TranslatableString(getKey(@"export_replay"), @"Export replay");
|
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>
|
/// <summary>
|
||||||
/// "Toggle rotate control"
|
/// "Toggle rotate control"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
107
osu.Game/Screens/Play/GameplayOffsetControl.cs
Normal file
107
osu.Game/Screens/Play/GameplayOffsetControl.cs
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Threading;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Screens.Play.PlayerSettings;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This provides the ability to change the offset while in gameplay.
|
||||||
|
/// Eventually this should be replaced with all settings from PlayerLoader being accessible from the game.
|
||||||
|
/// </summary>
|
||||||
|
internal partial class GameplayOffsetControl : VisibilityContainer
|
||||||
|
{
|
||||||
|
protected override bool StartHidden => true;
|
||||||
|
|
||||||
|
public override bool PropagateNonPositionalInputSubTree => true;
|
||||||
|
|
||||||
|
// Disable interaction for now to avoid any funny business with slider bar dragging.
|
||||||
|
public override bool PropagatePositionalInputSubTree => false;
|
||||||
|
|
||||||
|
private BeatmapOffsetControl offsetControl = null!;
|
||||||
|
|
||||||
|
private OsuTextFlowContainer text = null!;
|
||||||
|
|
||||||
|
private ScheduledDelegate? hideOp;
|
||||||
|
|
||||||
|
public GameplayOffsetControl()
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Y;
|
||||||
|
Width = SettingsToolboxGroup.CONTAINER_WIDTH;
|
||||||
|
|
||||||
|
Masking = true;
|
||||||
|
CornerRadius = 5;
|
||||||
|
|
||||||
|
// Allow BeatmapOffsetControl to handle keyboard input.
|
||||||
|
AlwaysPresent = true;
|
||||||
|
|
||||||
|
Anchor = Anchor.CentreRight;
|
||||||
|
Origin = Anchor.CentreRight;
|
||||||
|
|
||||||
|
X = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OverlayColourProvider? colourProvider)
|
||||||
|
{
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = 0.8f,
|
||||||
|
Colour = colourProvider?.Background4 ?? Color4.Black,
|
||||||
|
},
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Padding = new MarginPadding(10),
|
||||||
|
Spacing = new Vector2(5),
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
offsetControl = new BeatmapOffsetControl(),
|
||||||
|
text = new OsuTextFlowContainer(cp => cp.Font = OsuFont.Default.With(weight: FontWeight.SemiBold))
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
TextAnchor = Anchor.TopCentre,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
offsetControl.Current.BindValueChanged(val =>
|
||||||
|
{
|
||||||
|
text.Text = BeatmapOffsetControl.GetOffsetExplanatoryText(val.NewValue);
|
||||||
|
Show();
|
||||||
|
|
||||||
|
hideOp?.Cancel();
|
||||||
|
hideOp = Scheduler.AddDelayed(Hide, 500);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void PopIn()
|
||||||
|
{
|
||||||
|
this.FadeIn(500, Easing.OutQuint)
|
||||||
|
.MoveToX(0, 500, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void PopOut()
|
||||||
|
{
|
||||||
|
this.FadeOut(500, Easing.InQuint)
|
||||||
|
.MoveToX(100, 500, Easing.InQuint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -461,6 +461,12 @@ namespace osu.Game.Screens.Play
|
|||||||
OnRetry = () => Restart(),
|
OnRetry = () => Restart(),
|
||||||
OnQuit = () => PerformExit(true),
|
OnQuit = () => PerformExit(true),
|
||||||
},
|
},
|
||||||
|
new GameplayOffsetControl
|
||||||
|
{
|
||||||
|
Margin = new MarginPadding(20),
|
||||||
|
Anchor = Anchor.CentreRight,
|
||||||
|
Origin = Anchor.CentreRight,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
@ -16,6 +18,7 @@ using osu.Game.Database;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Localisation;
|
using osu.Game.Localisation;
|
||||||
using osu.Game.Overlays.Settings;
|
using osu.Game.Overlays.Settings;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
@ -26,7 +29,7 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Play.PlayerSettings
|
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?>();
|
public Bindable<ScoreInfo?> ReferenceScore { get; } = new Bindable<ScoreInfo?>();
|
||||||
|
|
||||||
@ -48,6 +51,12 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuColour colours { get; set; } = null!;
|
private OsuColour colours { get; set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private Player? player { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IGameplayClock? gameplayClock { get; set; }
|
||||||
|
|
||||||
private double lastPlayAverage;
|
private double lastPlayAverage;
|
||||||
private double lastPlayBeatmapOffset;
|
private double lastPlayBeatmapOffset;
|
||||||
private HitEventTimingDistributionGraph? lastPlayGraph;
|
private HitEventTimingDistributionGraph? lastPlayGraph;
|
||||||
@ -88,28 +97,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()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
@ -243,5 +230,68 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
|||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
beatmapOffsetSubscription?.Dispose();
|
beatmapOffsetSubscription?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
||||||
|
{
|
||||||
|
// General limitations to ensure players don't do anything too weird.
|
||||||
|
// These match stable for now.
|
||||||
|
if (player is SubmittingPlayer)
|
||||||
|
{
|
||||||
|
// TODO: the blocking conditions should probably display a message.
|
||||||
|
if (player?.IsBreakTime.Value == false && gameplayClock?.CurrentTime - gameplayClock?.StartTime > 10000)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (gameplayClock?.IsPaused.Value == true)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// To match stable, this should adjust by 5 ms, or 1 ms when holding alt.
|
||||||
|
// But that is hard to make work with global actions due to the operating mode.
|
||||||
|
// Let's use the more precise as a default for now.
|
||||||
|
const double amount = 1;
|
||||||
|
|
||||||
|
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 static LocalisableString GetOffsetExplanatoryText(double offset)
|
||||||
|
{
|
||||||
|
return offset == 0
|
||||||
|
? LocalisableString.Interpolate($@"{offset:0.0} ms")
|
||||||
|
: LocalisableString.Interpolate($@"{offset:0.0} ms {getEarlyLateText(offset)}");
|
||||||
|
|
||||||
|
LocalisableString getEarlyLateText(double value)
|
||||||
|
{
|
||||||
|
Debug.Assert(value != 0);
|
||||||
|
|
||||||
|
return value > 0
|
||||||
|
? BeatmapOffsetControlStrings.HitObjectsAppearEarlier
|
||||||
|
: BeatmapOffsetControlStrings.HitObjectsAppearLater;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public partial class OffsetSliderBar : PlayerSliderBar<double>
|
||||||
|
{
|
||||||
|
protected override Drawable CreateControl() => new CustomSliderBar();
|
||||||
|
|
||||||
|
protected partial class CustomSliderBar : SliderBar
|
||||||
|
{
|
||||||
|
public override LocalisableString TooltipText => GetOffsetExplanatoryText(Current.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user