mirror of
https://github.com/ppy/osu.git
synced 2025-02-05 02:43:16 +08:00
Add score text skinnability
This commit is contained in:
parent
2fce064e32
commit
fbbea48c8c
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -18,7 +19,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
public bool IsRolling { get; protected set; }
|
public bool IsRolling { get; protected set; }
|
||||||
|
|
||||||
protected SpriteText PopOutCount;
|
protected Drawable PopOutCount;
|
||||||
|
|
||||||
protected virtual double PopOutDuration => 150;
|
protected virtual double PopOutDuration => 150;
|
||||||
protected virtual float PopOutScale => 2.0f;
|
protected virtual float PopOutScale => 2.0f;
|
||||||
@ -37,7 +38,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected Easing RollingEasing => Easing.None;
|
protected Easing RollingEasing => Easing.None;
|
||||||
|
|
||||||
protected SpriteText DisplayedCountSpriteText;
|
protected Drawable DisplayedCountSpriteText;
|
||||||
|
|
||||||
private int previousValue;
|
private int previousValue;
|
||||||
|
|
||||||
@ -47,30 +48,34 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
protected ComboCounter()
|
protected ComboCounter()
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
DisplayedCountSpriteText = new OsuSpriteText
|
DisplayedCountSpriteText = CreateSpriteText().With(s =>
|
||||||
{
|
{
|
||||||
Alpha = 0,
|
s.Alpha = 0;
|
||||||
},
|
}),
|
||||||
PopOutCount = new OsuSpriteText
|
PopOutCount = CreateSpriteText().With(s =>
|
||||||
{
|
{
|
||||||
Alpha = 0,
|
s.Alpha = 0;
|
||||||
Margin = new MarginPadding(0.05f),
|
s.Margin = new MarginPadding(0.05f);
|
||||||
}
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
TextSize = 80;
|
|
||||||
|
|
||||||
Current.ValueChanged += combo => updateCount(combo.NewValue == 0);
|
Current.ValueChanged += combo => updateCount(combo.NewValue == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual Drawable CreateSpriteText() => new OsuSpriteText();
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
DisplayedCountSpriteText.Text = FormatCount(Current.Value);
|
((IHasText)DisplayedCountSpriteText).Text = FormatCount(Current.Value);
|
||||||
DisplayedCountSpriteText.Anchor = Anchor;
|
DisplayedCountSpriteText.Anchor = Anchor;
|
||||||
DisplayedCountSpriteText.Origin = Origin;
|
DisplayedCountSpriteText.Origin = Origin;
|
||||||
|
|
||||||
@ -94,20 +99,6 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private float textSize;
|
|
||||||
|
|
||||||
public float TextSize
|
|
||||||
{
|
|
||||||
get => textSize;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
textSize = value;
|
|
||||||
|
|
||||||
DisplayedCountSpriteText.Font = DisplayedCountSpriteText.Font.With(size: TextSize);
|
|
||||||
PopOutCount.Font = PopOutCount.Font.With(size: TextSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Increments the combo by an amount.
|
/// Increments the combo by an amount.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play.HUD
|
namespace osu.Game.Screens.Play.HUD
|
||||||
{
|
{
|
||||||
@ -26,6 +31,22 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
Margin = new MarginPadding { Top = 5, Left = 20 };
|
Margin = new MarginPadding { Top = 5, Left = 20 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private ISkinSource skin { get; set; }
|
||||||
|
|
||||||
|
protected override Drawable CreateSpriteText()
|
||||||
|
{
|
||||||
|
return skin?.GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.ScoreText)) ?? new OsuSpriteText();
|
||||||
|
|
||||||
|
/*
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Font = OsuFont.Numeric.With(size: 40),
|
||||||
|
UseFullGlyphHeight = false,
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
@ -41,7 +62,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
protected virtual void TransformPopOut(int newValue)
|
protected virtual void TransformPopOut(int newValue)
|
||||||
{
|
{
|
||||||
PopOutCount.Text = FormatCount(newValue);
|
((IHasText)PopOutCount).Text = FormatCount(newValue);
|
||||||
|
|
||||||
PopOutCount.ScaleTo(PopOutScale);
|
PopOutCount.ScaleTo(PopOutScale);
|
||||||
PopOutCount.FadeTo(PopOutInitialAlpha);
|
PopOutCount.FadeTo(PopOutInitialAlpha);
|
||||||
@ -60,13 +81,13 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
protected virtual void TransformNoPopOut(int newValue)
|
protected virtual void TransformNoPopOut(int newValue)
|
||||||
{
|
{
|
||||||
DisplayedCountSpriteText.Text = FormatCount(newValue);
|
((IHasText)DisplayedCountSpriteText).Text = FormatCount(newValue);
|
||||||
DisplayedCountSpriteText.ScaleTo(1);
|
DisplayedCountSpriteText.ScaleTo(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void TransformPopOutSmall(int newValue)
|
protected virtual void TransformPopOutSmall(int newValue)
|
||||||
{
|
{
|
||||||
DisplayedCountSpriteText.Text = FormatCount(newValue);
|
((IHasText)DisplayedCountSpriteText).Text = FormatCount(newValue);
|
||||||
DisplayedCountSpriteText.ScaleTo(PopOutSmallScale);
|
DisplayedCountSpriteText.ScaleTo(PopOutSmallScale);
|
||||||
DisplayedCountSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing);
|
DisplayedCountSpriteText.ScaleTo(1, PopOutDuration, PopOutEasing);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ namespace osu.Game.Skinning
|
|||||||
{
|
{
|
||||||
public enum HUDSkinComponents
|
public enum HUDSkinComponents
|
||||||
{
|
{
|
||||||
ComboCounter
|
ComboCounter,
|
||||||
|
ScoreText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ using osu.Game.Beatmaps.Formats;
|
|||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
@ -334,6 +335,14 @@ namespace osu.Game.Skinning
|
|||||||
{
|
{
|
||||||
case HUDSkinComponents.ComboCounter:
|
case HUDSkinComponents.ComboCounter:
|
||||||
return new LegacyComboCounter();
|
return new LegacyComboCounter();
|
||||||
|
|
||||||
|
case HUDSkinComponents.ScoreText:
|
||||||
|
const string font = "score";
|
||||||
|
|
||||||
|
if (!this.HasFont(font))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new LegacySpriteText(this, font);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user