2019-08-20 01:28:03 +08:00
|
|
|
|
// 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.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Configuration;
|
|
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
2019-08-20 03:04:27 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2019-08-20 01:28:03 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play.HitErrorDisplay
|
|
|
|
|
{
|
|
|
|
|
public class HitErrorDisplayOverlay : Container<HitErrorDisplay>
|
|
|
|
|
{
|
|
|
|
|
private const int fade_duration = 200;
|
|
|
|
|
private const int margin = 10;
|
|
|
|
|
|
|
|
|
|
private readonly Bindable<ScoreMeterType> type = new Bindable<ScoreMeterType>();
|
2019-08-20 03:04:27 +08:00
|
|
|
|
private readonly HitWindows hitWindows;
|
|
|
|
|
private readonly ScoreProcessor processor;
|
|
|
|
|
private readonly float overallDifficulty;
|
2019-08-20 01:28:03 +08:00
|
|
|
|
|
|
|
|
|
public HitErrorDisplayOverlay(ScoreProcessor processor, WorkingBeatmap workingBeatmap)
|
|
|
|
|
{
|
2019-08-20 03:04:27 +08:00
|
|
|
|
this.processor = processor;
|
2019-08-20 01:28:03 +08:00
|
|
|
|
|
2019-08-20 03:04:27 +08:00
|
|
|
|
overallDifficulty = workingBeatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty;
|
|
|
|
|
hitWindows = processor.CreateHitWindows();
|
2019-08-20 01:28:03 +08:00
|
|
|
|
|
2019-08-20 03:04:27 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
2019-08-20 01:28:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuConfigManager config)
|
|
|
|
|
{
|
|
|
|
|
config.BindWith(OsuSetting.ScoreMeter, type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
type.BindValueChanged(onTypeChanged, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onTypeChanged(ValueChangedEvent<ScoreMeterType> type)
|
|
|
|
|
{
|
2019-08-20 03:04:27 +08:00
|
|
|
|
clear();
|
|
|
|
|
|
2019-08-20 01:28:03 +08:00
|
|
|
|
switch (type.NewValue)
|
|
|
|
|
{
|
|
|
|
|
case ScoreMeterType.None:
|
|
|
|
|
break;
|
|
|
|
|
|
2019-08-20 03:04:27 +08:00
|
|
|
|
case ScoreMeterType.HitErrorBoth:
|
|
|
|
|
createNew();
|
|
|
|
|
createNew(true);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ScoreMeterType.HitErrorLeft:
|
|
|
|
|
createNew();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ScoreMeterType.HitErrorRight:
|
|
|
|
|
createNew(true);
|
2019-08-20 01:28:03 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-20 03:04:27 +08:00
|
|
|
|
|
|
|
|
|
private void clear()
|
|
|
|
|
{
|
|
|
|
|
Children.ForEach(t =>
|
|
|
|
|
{
|
|
|
|
|
processor.NewJudgement -= t.OnNewJudgement;
|
|
|
|
|
t.FadeOut(fade_duration, Easing.OutQuint).Expire();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void createNew(bool reversed = false)
|
|
|
|
|
{
|
2019-08-20 13:03:17 +08:00
|
|
|
|
var display = new BarHitErrorDisplay(overallDifficulty, hitWindows, reversed)
|
2019-08-20 03:04:27 +08:00
|
|
|
|
{
|
|
|
|
|
Margin = new MarginPadding(margin),
|
|
|
|
|
Anchor = reversed ? Anchor.CentreRight : Anchor.CentreLeft,
|
|
|
|
|
Origin = reversed ? Anchor.CentreRight : Anchor.CentreLeft,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
processor.NewJudgement += display.OnNewJudgement;
|
|
|
|
|
Add(display);
|
|
|
|
|
display.FadeInFromZero(fade_duration, Easing.OutQuint);
|
|
|
|
|
}
|
2019-08-20 01:28:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|