mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 20:12:56 +08:00
Add and consume skinnable accuracy counter
This commit is contained in:
parent
90ff8ff050
commit
254eba9008
@ -2,7 +2,6 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Utils;
|
using osu.Game.Utils;
|
||||||
@ -28,9 +27,6 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Current.Value = DisplayedCount = 1.0f;
|
Current.Value = DisplayedCount = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(OsuColour colours) => Colour = colours.BlueLighter;
|
|
||||||
|
|
||||||
protected override string FormatCount(double count) => count.FormatAccuracy();
|
protected override string FormatCount(double count) => count.FormatAccuracy();
|
||||||
|
|
||||||
protected override double GetProportionalDuration(double currentValue, double newValue)
|
protected override double GetProportionalDuration(double currentValue, double newValue)
|
||||||
|
41
osu.Game/Screens/Play/HUD/DefaultAccuracyCounter.cs
Normal file
41
osu.Game/Screens/Play/HUD/DefaultAccuracyCounter.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// 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.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play.HUD
|
||||||
|
{
|
||||||
|
public class DefaultAccuracyCounter : PercentageCounter, IAccuracyCounter
|
||||||
|
{
|
||||||
|
private readonly Vector2 offset = new Vector2(-20, 5);
|
||||||
|
|
||||||
|
public DefaultAccuracyCounter()
|
||||||
|
{
|
||||||
|
Origin = Anchor.TopRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Resolved(canBeNull: true)]
|
||||||
|
private HUDOverlay hud { get; set; }
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
Colour = colours.BlueLighter;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
if (hud?.ScoreCounter.Drawable is DefaultScoreCounter score)
|
||||||
|
{
|
||||||
|
// for now align with the score counter. eventually this will be user customisable.
|
||||||
|
Position = Parent.ToLocalSpace(score.ScreenSpaceDrawQuad.TopLeft) + offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
19
osu.Game/Screens/Play/HUD/IAccuracyCounter.cs
Normal file
19
osu.Game/Screens/Play/HUD/IAccuracyCounter.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// 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.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play.HUD
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An interface providing a set of methods to update a accuracy counter.
|
||||||
|
/// </summary>
|
||||||
|
public interface IAccuracyCounter : IDrawable
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The current accuracy to be displayed.
|
||||||
|
/// </summary>
|
||||||
|
Bindable<double> Current { get; }
|
||||||
|
}
|
||||||
|
}
|
29
osu.Game/Screens/Play/HUD/SkinnableAccuracyCounter.cs
Normal file
29
osu.Game/Screens/Play/HUD/SkinnableAccuracyCounter.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// 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.Bindables;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play.HUD
|
||||||
|
{
|
||||||
|
public class SkinnableAccuracyCounter : SkinnableDrawable, IAccuracyCounter
|
||||||
|
{
|
||||||
|
public Bindable<double> Current { get; } = new Bindable<double>();
|
||||||
|
|
||||||
|
public SkinnableAccuracyCounter()
|
||||||
|
: base(new HUDSkinComponent(HUDSkinComponents.AccuracyCounter), _ => new DefaultAccuracyCounter())
|
||||||
|
{
|
||||||
|
CentreComponent = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IAccuracyCounter skinnedCounter;
|
||||||
|
|
||||||
|
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
||||||
|
{
|
||||||
|
base.SkinChanged(skin, allowFallback);
|
||||||
|
|
||||||
|
skinnedCounter = Drawable as IAccuracyCounter;
|
||||||
|
skinnedCounter?.Current.BindTo(Current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,7 +10,6 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics.UserInterface;
|
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
@ -32,7 +31,7 @@ namespace osu.Game.Screens.Play
|
|||||||
public readonly KeyCounterDisplay KeyCounter;
|
public readonly KeyCounterDisplay KeyCounter;
|
||||||
public readonly SkinnableComboCounter ComboCounter;
|
public readonly SkinnableComboCounter ComboCounter;
|
||||||
public readonly SkinnableScoreCounter ScoreCounter;
|
public readonly SkinnableScoreCounter ScoreCounter;
|
||||||
public readonly RollingCounter<double> AccuracyCounter;
|
public readonly SkinnableAccuracyCounter AccuracyCounter;
|
||||||
public readonly HealthDisplay HealthDisplay;
|
public readonly HealthDisplay HealthDisplay;
|
||||||
public readonly SongProgress Progress;
|
public readonly SongProgress Progress;
|
||||||
public readonly ModDisplay ModDisplay;
|
public readonly ModDisplay ModDisplay;
|
||||||
@ -254,13 +253,7 @@ namespace osu.Game.Screens.Play
|
|||||||
return base.OnKeyDown(e);
|
return base.OnKeyDown(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual RollingCounter<double> CreateAccuracyCounter() => new PercentageCounter
|
protected virtual SkinnableAccuracyCounter CreateAccuracyCounter() => new SkinnableAccuracyCounter();
|
||||||
{
|
|
||||||
BypassAutoSizeAxes = Axes.X,
|
|
||||||
Anchor = Anchor.TopLeft,
|
|
||||||
Origin = Anchor.TopRight,
|
|
||||||
Margin = new MarginPadding { Top = 5, Right = 20 },
|
|
||||||
};
|
|
||||||
|
|
||||||
protected virtual SkinnableScoreCounter CreateScoreCounter() => new SkinnableScoreCounter();
|
protected virtual SkinnableScoreCounter CreateScoreCounter() => new SkinnableScoreCounter();
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ namespace osu.Game.Skinning
|
|||||||
public enum HUDSkinComponents
|
public enum HUDSkinComponents
|
||||||
{
|
{
|
||||||
ComboCounter,
|
ComboCounter,
|
||||||
ScoreCounter
|
ScoreCounter,
|
||||||
|
AccuracyCounter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
47
osu.Game/Skinning/LegacyAccuracyCounter.cs
Normal file
47
osu.Game/Skinning/LegacyAccuracyCounter.cs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// 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.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
using osu.Game.Screens.Play.HUD;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Skinning
|
||||||
|
{
|
||||||
|
public class LegacyAccuracyCounter : PercentageCounter, IAccuracyCounter
|
||||||
|
{
|
||||||
|
private readonly ISkin skin;
|
||||||
|
|
||||||
|
public LegacyAccuracyCounter(ISkin skin)
|
||||||
|
{
|
||||||
|
Origin = Anchor.TopRight;
|
||||||
|
Scale = new Vector2(0.75f);
|
||||||
|
|
||||||
|
this.skin = skin;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Resolved(canBeNull: true)]
|
||||||
|
private HUDOverlay hud { get; set; }
|
||||||
|
|
||||||
|
protected sealed override OsuSpriteText CreateSpriteText() =>
|
||||||
|
new LegacySpriteText(skin, "score" /*, true*/)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
};
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
if (hud?.ScoreCounter.Drawable is LegacyScoreCounter score)
|
||||||
|
{
|
||||||
|
// for now align with the score counter. eventually this will be user customisable.
|
||||||
|
Position = Parent.ToLocalSpace(score.ScreenSpaceDrawQuad.BottomRight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -344,6 +344,9 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
case HUDSkinComponents.ScoreCounter:
|
case HUDSkinComponents.ScoreCounter:
|
||||||
return new LegacyScoreCounter(this);
|
return new LegacyScoreCounter(this);
|
||||||
|
|
||||||
|
case HUDSkinComponents.AccuracyCounter:
|
||||||
|
return new LegacyAccuracyCounter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user