mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Setup skinnable combo counter component with default implementation
This commit is contained in:
@ -5,13 +5,14 @@ using System;
|
|||||||
using osu.Framework.Allocation;
|
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.Screens.Play.HUD;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used as an accuracy counter. Represented visually as a percentage.
|
/// Used as an accuracy counter. Represented visually as a percentage.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SimpleComboCounter : RollingCounter<int>
|
public class SimpleComboCounter : RollingCounter<int>, IComboCounter
|
||||||
{
|
{
|
||||||
protected override double RollingDuration => 750;
|
protected override double RollingDuration => 750;
|
||||||
|
|
||||||
|
58
osu.Game/Screens/Play/HUD/SkinnableComboCounter.cs
Normal file
58
osu.Game/Screens/Play/HUD/SkinnableComboCounter.cs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
// 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;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play.HUD
|
||||||
|
{
|
||||||
|
public class SkinnableComboCounter : SkinnableDrawable, IComboCounter
|
||||||
|
{
|
||||||
|
public SkinnableComboCounter()
|
||||||
|
: base(new HUDSkinComponent(HUDSkinComponents.ComboCounter), createDefault)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private IComboCounter skinnedCounter;
|
||||||
|
|
||||||
|
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
||||||
|
{
|
||||||
|
// todo: unnecessary?
|
||||||
|
if (skinnedCounter != null)
|
||||||
|
{
|
||||||
|
Current.UnbindFrom(skinnedCounter.Current);
|
||||||
|
}
|
||||||
|
|
||||||
|
base.SkinChanged(skin, allowFallback);
|
||||||
|
|
||||||
|
// temporary layout code, will eventually be replaced by the skin layout system.
|
||||||
|
if (Drawable is SimpleComboCounter)
|
||||||
|
{
|
||||||
|
Drawable.BypassAutoSizeAxes = Axes.X;
|
||||||
|
Drawable.Anchor = Anchor.TopRight;
|
||||||
|
Drawable.Origin = Anchor.TopLeft;
|
||||||
|
Drawable.Margin = new MarginPadding { Top = 5, Left = 20 };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Drawable.BypassAutoSizeAxes = Axes.X;
|
||||||
|
Drawable.Anchor = Anchor.BottomLeft;
|
||||||
|
Drawable.Origin = Anchor.BottomLeft;
|
||||||
|
Drawable.Margin = new MarginPadding { Top = 5, Left = 20 };
|
||||||
|
}
|
||||||
|
|
||||||
|
skinnedCounter = (IComboCounter)Drawable;
|
||||||
|
|
||||||
|
Current.BindTo(skinnedCounter.Current);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Drawable createDefault(ISkinComponent skinComponent) => new SimpleComboCounter();
|
||||||
|
|
||||||
|
public Bindable<int> Current { get; } = new Bindable<int>();
|
||||||
|
|
||||||
|
public void UpdateCombo(int combo, Color4? hitObjectColour = null) => Current.Value = combo;
|
||||||
|
}
|
||||||
|
}
|
@ -28,7 +28,7 @@ namespace osu.Game.Screens.Play
|
|||||||
private const Easing fade_easing = Easing.Out;
|
private const Easing fade_easing = Easing.Out;
|
||||||
|
|
||||||
public readonly KeyCounterDisplay KeyCounter;
|
public readonly KeyCounterDisplay KeyCounter;
|
||||||
public readonly RollingCounter<int> ComboCounter;
|
public readonly SkinnableComboCounter ComboCounter;
|
||||||
public readonly ScoreCounter ScoreCounter;
|
public readonly ScoreCounter ScoreCounter;
|
||||||
public readonly RollingCounter<double> AccuracyCounter;
|
public readonly RollingCounter<double> AccuracyCounter;
|
||||||
public readonly HealthDisplay HealthDisplay;
|
public readonly HealthDisplay HealthDisplay;
|
||||||
@ -275,13 +275,7 @@ namespace osu.Game.Screens.Play
|
|||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
};
|
};
|
||||||
|
|
||||||
protected virtual RollingCounter<int> CreateComboCounter() => new SimpleComboCounter
|
protected virtual SkinnableComboCounter CreateComboCounter() => new SkinnableComboCounter();
|
||||||
{
|
|
||||||
BypassAutoSizeAxes = Axes.X,
|
|
||||||
Anchor = Anchor.TopRight,
|
|
||||||
Origin = Anchor.TopLeft,
|
|
||||||
Margin = new MarginPadding { Top = 5, Left = 20 },
|
|
||||||
};
|
|
||||||
|
|
||||||
protected virtual HealthDisplay CreateHealthDisplay() => new StandardHealthDisplay
|
protected virtual HealthDisplay CreateHealthDisplay() => new StandardHealthDisplay
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user