1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 12:02:54 +08:00

Fix class naming

This commit is contained in:
Dean Herbert 2019-08-30 15:32:47 +09:00
parent 835ee0aa2f
commit bdbfa7bd2f
6 changed files with 146 additions and 147 deletions

View File

@ -19,16 +19,16 @@ using osu.Framework.Graphics.Sprites;
namespace osu.Game.Tests.Visual.Gameplay
{
public class TestSceneHitErrorDisplay : OsuTestScene
public class TestSceneBarHitErrorMeter : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(HitErrorDisplay),
typeof(HitErrorMeter),
};
private HitErrorDisplay display;
private HitErrorMeter meter;
public TestSceneHitErrorDisplay()
public TestSceneBarHitErrorMeter()
{
recreateDisplay(new OsuHitWindows(), 5);
AddStep("New random judgement", () => newJudgement());
@ -115,7 +115,7 @@ namespace osu.Game.Tests.Visual.Gameplay
}
});
Add(display = new BarHitErrorDisplay(hitWindows)
Add(meter = new BarHitErrorMeter(hitWindows)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
@ -124,7 +124,7 @@ namespace osu.Game.Tests.Visual.Gameplay
private void newJudgement(float offset = 0)
{
display?.OnNewJudgement(new JudgementResult(new Judgement())
meter?.OnNewJudgement(new JudgementResult(new Judgement())
{
TimeOffset = offset == 0 ? RNG.Next(-70, 70) : offset,
Type = HitResult.Perfect,

View File

@ -15,7 +15,6 @@ using osu.Game.Overlays.Notifications;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Play.HitErrorDisplay;
using osu.Game.Screens.Play.HUD;
using osuTK;
using osuTK.Input;
@ -34,7 +33,7 @@ namespace osu.Game.Screens.Play
public readonly HealthDisplay HealthDisplay;
public readonly SongProgress Progress;
public readonly ModDisplay ModDisplay;
public readonly HitErrorDisplayOverlay HitErrorDisplayOverlay;
public readonly HitErrorDisplay.HitErrorDisplay HitErrorDisplay;
public readonly HoldForMenuButton HoldToQuit;
public readonly PlayerSettingsOverlay PlayerSettingsOverlay;
@ -86,7 +85,7 @@ namespace osu.Game.Screens.Play
HealthDisplay = CreateHealthDisplay(),
Progress = CreateProgress(),
ModDisplay = CreateModsContainer(),
HitErrorDisplayOverlay = CreateHitErrorDisplayOverlay(),
HitErrorDisplay = CreateHitErrorDisplayOverlay(),
}
},
PlayerSettingsOverlay = CreatePlayerSettingsOverlay(),
@ -259,7 +258,7 @@ namespace osu.Game.Screens.Play
Margin = new MarginPadding { Top = 20, Right = 10 },
};
protected virtual HitErrorDisplayOverlay CreateHitErrorDisplayOverlay() => new HitErrorDisplayOverlay(scoreProcessor)
protected virtual HitErrorDisplay.HitErrorDisplay CreateHitErrorDisplayOverlay() => new HitErrorDisplay.HitErrorDisplay(scoreProcessor)
{
RelativeSizeAxes = Axes.Both,
};

View File

@ -18,7 +18,7 @@ using System.Linq;
namespace osu.Game.Screens.Play.HitErrorDisplay
{
public class BarHitErrorDisplay : HitErrorDisplay
public class BarHitErrorMeter : HitErrorMeter
{
/// <summary>
/// The amount of <see cref="JudgementResult"/> which will be stored to calculate arrow position.
@ -38,7 +38,7 @@ namespace osu.Game.Screens.Play.HitErrorDisplay
private readonly List<double> judgementOffsets = new List<double>();
private readonly double maxHitWindows;
public BarHitErrorDisplay(HitWindows hitWindows, bool reversed = false)
public BarHitErrorMeter(HitWindows hitWindows, bool reversed = false)
: base(hitWindows)
{
maxHitWindows = HitWindows.Meh == 0 ? HitWindows.Good : HitWindows.Meh;

View File

@ -2,20 +2,128 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Judgements;
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.Game.Rulesets.Objects;
namespace osu.Game.Screens.Play.HitErrorDisplay
{
public abstract class HitErrorDisplay : CompositeDrawable
public class HitErrorDisplay : Container<HitErrorMeter>
{
protected readonly HitWindows HitWindows;
private const int fade_duration = 200;
private const int margin = 10;
protected HitErrorDisplay(HitWindows hitWindows)
private readonly Bindable<ScoreMeterType> type = new Bindable<ScoreMeterType>();
private readonly HitWindows hitWindows;
private readonly ScoreProcessor processor;
private BarHitErrorMeter leftMeter;
private BarHitErrorMeter rightMeter;
public HitErrorDisplay(ScoreProcessor processor)
{
HitWindows = hitWindows;
this.processor = processor;
hitWindows = processor.CreateHitWindows();
}
public abstract void OnNewJudgement(JudgementResult newJudgement);
[BackgroundDependencyLoader]
private void load(OsuConfigManager config, Bindable<WorkingBeatmap> workingBeatmap)
{
config.BindWith(OsuSetting.ScoreMeter, type);
hitWindows.SetDifficulty(workingBeatmap.Value.BeatmapInfo.BaseDifficulty.OverallDifficulty);
}
protected override void LoadComplete()
{
base.LoadComplete();
type.BindValueChanged(typeChanged, true);
}
private void typeChanged(ValueChangedEvent<ScoreMeterType> type)
{
switch (type.NewValue)
{
case ScoreMeterType.None:
removeLeftDisplay();
removeRightDisplay();
break;
case ScoreMeterType.HitErrorBoth:
addLeftDisplay();
addRightDisplay();
break;
case ScoreMeterType.HitErrorLeft:
addLeftDisplay();
removeRightDisplay();
break;
case ScoreMeterType.HitErrorRight:
addRightDisplay();
removeLeftDisplay();
break;
}
}
private void addLeftDisplay()
{
if (leftMeter != null)
return;
leftMeter = createNew();
}
private void addRightDisplay()
{
if (rightMeter != null)
return;
rightMeter = createNew(true);
}
private void removeRightDisplay()
{
if (rightMeter == null)
return;
processor.NewJudgement -= rightMeter.OnNewJudgement;
rightMeter.FadeOut(fade_duration, Easing.OutQuint).Expire();
rightMeter = null;
}
private void removeLeftDisplay()
{
if (leftMeter == null)
return;
processor.NewJudgement -= leftMeter.OnNewJudgement;
leftMeter.FadeOut(fade_duration, Easing.OutQuint).Expire();
leftMeter = null;
}
private BarHitErrorMeter createNew(bool reversed = false)
{
var display = new BarHitErrorMeter(hitWindows, reversed)
{
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);
return display;
}
}
}

View File

@ -1,129 +0,0 @@
// 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.Game.Rulesets.Objects;
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>();
private readonly HitWindows hitWindows;
private readonly ScoreProcessor processor;
private BarHitErrorDisplay leftDisplay;
private BarHitErrorDisplay rightDisplay;
public HitErrorDisplayOverlay(ScoreProcessor processor)
{
this.processor = processor;
hitWindows = processor.CreateHitWindows();
}
[BackgroundDependencyLoader]
private void load(OsuConfigManager config, Bindable<WorkingBeatmap> workingBeatmap)
{
config.BindWith(OsuSetting.ScoreMeter, type);
hitWindows.SetDifficulty(workingBeatmap.Value.BeatmapInfo.BaseDifficulty.OverallDifficulty);
}
protected override void LoadComplete()
{
base.LoadComplete();
type.BindValueChanged(typeChanged, true);
}
private void typeChanged(ValueChangedEvent<ScoreMeterType> type)
{
switch (type.NewValue)
{
case ScoreMeterType.None:
removeLeftDisplay();
removeRightDisplay();
break;
case ScoreMeterType.HitErrorBoth:
addLeftDisplay();
addRightDisplay();
break;
case ScoreMeterType.HitErrorLeft:
addLeftDisplay();
removeRightDisplay();
break;
case ScoreMeterType.HitErrorRight:
addRightDisplay();
removeLeftDisplay();
break;
}
}
private void addLeftDisplay()
{
if (leftDisplay != null)
return;
leftDisplay = createNew();
}
private void addRightDisplay()
{
if (rightDisplay != null)
return;
rightDisplay = createNew(true);
}
private void removeRightDisplay()
{
if (rightDisplay == null)
return;
processor.NewJudgement -= rightDisplay.OnNewJudgement;
rightDisplay.FadeOut(fade_duration, Easing.OutQuint).Expire();
rightDisplay = null;
}
private void removeLeftDisplay()
{
if (leftDisplay == null)
return;
processor.NewJudgement -= leftDisplay.OnNewJudgement;
leftDisplay.FadeOut(fade_duration, Easing.OutQuint).Expire();
leftDisplay = null;
}
private BarHitErrorDisplay createNew(bool reversed = false)
{
var display = new BarHitErrorDisplay(hitWindows, reversed)
{
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);
return display;
}
}
}

View File

@ -0,0 +1,21 @@
// 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.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
namespace osu.Game.Screens.Play.HitErrorDisplay
{
public abstract class HitErrorMeter : CompositeDrawable
{
protected readonly HitWindows HitWindows;
protected HitErrorMeter(HitWindows hitWindows)
{
HitWindows = hitWindows;
}
public abstract void OnNewJudgement(JudgementResult newJudgement);
}
}