1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 13:22:55 +08:00

Hook offset adjustment control up to last play via PlayerLoader

This commit is contained in:
Dean Herbert 2022-03-01 16:14:57 +09:00
parent 7215f3f66b
commit 2901d2a650
3 changed files with 61 additions and 39 deletions

View File

@ -23,7 +23,6 @@ using osu.Game.Graphics.Containers;
using osu.Game.Input;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Menu;
using osu.Game.Screens.Play.PlayerSettings;
using osu.Game.Users;
@ -62,6 +61,8 @@ namespace osu.Game.Screens.Play
protected VisualSettings VisualSettings { get; private set; }
protected AudioSettings AudioSettings { get; private set; }
protected Task LoadTask { get; private set; }
protected Task DisposalTask { get; private set; }
@ -168,7 +169,7 @@ namespace osu.Game.Screens.Play
Children = new PlayerSettingsGroup[]
{
VisualSettings = new VisualSettings(),
new AudioSettings(),
AudioSettings = new AudioSettings(),
new InputSettings()
}
},
@ -229,11 +230,7 @@ namespace osu.Game.Screens.Play
var lastScore = player.Score;
if (lastScore != null)
{
// TODO: use this
double? lastPlayHitError = lastScore.ScoreInfo.HitEvents.CalculateAverageHitError();
}
AudioSettings.ReferenceScore.Value = lastScore?.ScoreInfo;
// prepare for a retry.
player = null;

View File

@ -2,13 +2,17 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Configuration;
using osu.Game.Scoring;
namespace osu.Game.Screens.Play.PlayerSettings
{
public class AudioSettings : PlayerSettingsGroup
{
public Bindable<ScoreInfo> ReferenceScore { get; } = new Bindable<ScoreInfo>();
private readonly PlayerCheckbox beatmapHitsoundsToggle;
public AudioSettings()
@ -16,7 +20,11 @@ namespace osu.Game.Screens.Play.PlayerSettings
{
Children = new Drawable[]
{
beatmapHitsoundsToggle = new PlayerCheckbox { LabelText = "Beatmap hitsounds" }
beatmapHitsoundsToggle = new PlayerCheckbox { LabelText = "Beatmap hitsounds" },
new BeatmapOffsetControl
{
ReferenceScore = { BindTarget = ReferenceScore },
},
};
}

View File

@ -1,13 +1,13 @@
// 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 System.Collections.Generic;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Screens.Ranking.Statistics;
using osuTK;
@ -15,9 +15,7 @@ namespace osu.Game.Screens.Play.PlayerSettings
{
public class BeatmapOffsetControl : CompositeDrawable
{
private readonly SettingsButton useAverageButton;
private readonly double lastPlayAverage;
public Bindable<ScoreInfo> ReferenceScore { get; } = new Bindable<ScoreInfo>();
public Bindable<double> Current { get; } = new BindableDouble
{
@ -28,14 +26,18 @@ namespace osu.Game.Screens.Play.PlayerSettings
Precision = 0.1,
};
public BeatmapOffsetControl(IReadOnlyList<HitEvent> hitEvents)
private SettingsButton useAverageButton;
private double lastPlayAverage;
private readonly FillFlowContainer referenceScoreContainer;
public BeatmapOffsetControl()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
FillFlowContainer flow;
InternalChild = flow = new FillFlowContainer
InternalChild = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
@ -49,32 +51,17 @@ namespace osu.Game.Screens.Play.PlayerSettings
LabelText = "Beatmap offset",
Current = Current,
},
referenceScoreContainer = new FillFlowContainer
{
Spacing = new Vector2(10),
Direction = FillDirection.Vertical,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
},
}
};
if (hitEvents.CalculateAverageHitError() is double average)
{
lastPlayAverage = average;
flow.AddRange(new Drawable[]
{
new OsuSpriteText
{
Text = "Last play:"
},
new HitEventTimingDistributionGraph(hitEvents)
{
RelativeSizeAxes = Axes.X,
Height = 50,
},
new AverageHitError(hitEvents),
useAverageButton = new SettingsButton
{
Text = "Calibrate using last play",
Action = () => Current.Value = lastPlayAverage
},
});
}
ReferenceScore.BindValueChanged(scoreChanged, true);
Current.BindValueChanged(offset =>
{
@ -84,5 +71,35 @@ namespace osu.Game.Screens.Play.PlayerSettings
}
}, true);
}
private void scoreChanged(ValueChangedEvent<ScoreInfo> score)
{
if (!(score.NewValue?.HitEvents.CalculateAverageHitError() is double average))
{
referenceScoreContainer.Clear();
return;
}
lastPlayAverage = average;
referenceScoreContainer.Children = new Drawable[]
{
new OsuSpriteText
{
Text = "Last play:"
},
new HitEventTimingDistributionGraph(score.NewValue.HitEvents)
{
RelativeSizeAxes = Axes.X,
Height = 50,
},
new AverageHitError(score.NewValue.HitEvents),
useAverageButton = new SettingsButton
{
Text = "Calibrate using last play",
Action = () => Current.Value = lastPlayAverage
},
};
}
}
}