mirror of
https://github.com/ppy/osu.git
synced 2025-03-28 10:17:19 +08:00
Merge pull request #10522 from Morilli/legacyskin-fixes
Add support for ScorePrefix and ScoreOverlap values in legacy skins
This commit is contained in:
commit
e87f515a4f
@ -1,68 +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 NUnit.Framework;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Game.Graphics.UserInterface;
|
|
||||||
using osu.Game.Screens.Play.HUD;
|
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Gameplay
|
|
||||||
{
|
|
||||||
[TestFixture]
|
|
||||||
public class TestSceneScoreCounter : OsuTestScene
|
|
||||||
{
|
|
||||||
public TestSceneScoreCounter()
|
|
||||||
{
|
|
||||||
int numerator = 0, denominator = 0;
|
|
||||||
|
|
||||||
ScoreCounter score = new DefaultScoreCounter
|
|
||||||
{
|
|
||||||
Origin = Anchor.TopRight,
|
|
||||||
Anchor = Anchor.TopRight,
|
|
||||||
Margin = new MarginPadding(20),
|
|
||||||
};
|
|
||||||
Add(score);
|
|
||||||
|
|
||||||
LegacyComboCounter comboCounter = new LegacyComboCounter
|
|
||||||
{
|
|
||||||
Origin = Anchor.BottomLeft,
|
|
||||||
Anchor = Anchor.BottomLeft,
|
|
||||||
Margin = new MarginPadding(10),
|
|
||||||
};
|
|
||||||
Add(comboCounter);
|
|
||||||
|
|
||||||
PercentageCounter accuracyCounter = new PercentageCounter
|
|
||||||
{
|
|
||||||
Origin = Anchor.TopRight,
|
|
||||||
Anchor = Anchor.TopRight,
|
|
||||||
Position = new Vector2(-20, 60),
|
|
||||||
};
|
|
||||||
Add(accuracyCounter);
|
|
||||||
|
|
||||||
AddStep(@"Reset all", delegate
|
|
||||||
{
|
|
||||||
score.Current.Value = 0;
|
|
||||||
comboCounter.Current.Value = 0;
|
|
||||||
numerator = denominator = 0;
|
|
||||||
accuracyCounter.SetFraction(0, 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
AddStep(@"Hit! :D", delegate
|
|
||||||
{
|
|
||||||
score.Current.Value += 300 + (ulong)(300.0 * (comboCounter.Current.Value > 0 ? comboCounter.Current.Value - 1 : 0) / 25.0);
|
|
||||||
comboCounter.Current.Value++;
|
|
||||||
numerator++;
|
|
||||||
denominator++;
|
|
||||||
accuracyCounter.SetFraction(numerator, denominator);
|
|
||||||
});
|
|
||||||
|
|
||||||
AddStep(@"miss...", delegate
|
|
||||||
{
|
|
||||||
comboCounter.Current.Value = 0;
|
|
||||||
denominator++;
|
|
||||||
accuracyCounter.SetFraction(numerator, denominator);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,6 +6,7 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -246,6 +247,6 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
return difference * rolling_duration;
|
return difference * rolling_duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Drawable createSpriteText() => new LegacySpriteText(skin);
|
private OsuSpriteText createSpriteText() => (OsuSpriteText)skin.GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.ComboText));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ namespace osu.Game.Skinning
|
|||||||
{
|
{
|
||||||
ComboCounter,
|
ComboCounter,
|
||||||
ScoreCounter,
|
ScoreCounter,
|
||||||
AccuracyCounter
|
ScoreText,
|
||||||
|
ComboText,
|
||||||
|
AccuracyCounter,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,7 @@ namespace osu.Game.Skinning
|
|||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
private HUDOverlay hud { get; set; }
|
private HUDOverlay hud { get; set; }
|
||||||
|
|
||||||
protected sealed override OsuSpriteText CreateSpriteText() =>
|
protected sealed override OsuSpriteText CreateSpriteText() => (OsuSpriteText)skin?.GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.ScoreText));
|
||||||
new LegacySpriteText(skin, "score" /*, true*/)
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopRight,
|
|
||||||
Origin = Anchor.TopRight,
|
|
||||||
};
|
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
|
@ -25,17 +25,12 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
this.skin = skin;
|
this.skin = skin;
|
||||||
|
|
||||||
// base class uses int for display, but externally we bind to ScoreProcesssor as a double for now.
|
// base class uses int for display, but externally we bind to ScoreProcessor as a double for now.
|
||||||
Current.BindValueChanged(v => base.Current.Value = (int)v.NewValue);
|
Current.BindValueChanged(v => base.Current.Value = (int)v.NewValue);
|
||||||
|
|
||||||
Margin = new MarginPadding(10);
|
Margin = new MarginPadding(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected sealed override OsuSpriteText CreateSpriteText() =>
|
protected sealed override OsuSpriteText CreateSpriteText() => (OsuSpriteText)skin.GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.ScoreText));
|
||||||
new LegacySpriteText(skin, "score" /*, true*/)
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopRight,
|
|
||||||
Origin = Anchor.TopRight,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
@ -324,9 +325,11 @@ namespace osu.Game.Skinning
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private const string score_font = "score";
|
private string scorePrefix => GetConfig<LegacySkinConfiguration.LegacySetting, string>(LegacySkinConfiguration.LegacySetting.ScorePrefix)?.Value ?? "score";
|
||||||
|
|
||||||
private bool hasScoreFont => this.HasFont(score_font);
|
private string comboPrefix => GetConfig<LegacySkinConfiguration.LegacySetting, string>(LegacySkinConfiguration.LegacySetting.ComboPrefix)?.Value ?? "score";
|
||||||
|
|
||||||
|
private bool hasScoreFont => this.HasFont(scorePrefix);
|
||||||
|
|
||||||
public override Drawable GetDrawableComponent(ISkinComponent component)
|
public override Drawable GetDrawableComponent(ISkinComponent component)
|
||||||
{
|
{
|
||||||
@ -347,6 +350,18 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
case HUDSkinComponents.AccuracyCounter:
|
case HUDSkinComponents.AccuracyCounter:
|
||||||
return new LegacyAccuracyCounter(this);
|
return new LegacyAccuracyCounter(this);
|
||||||
|
|
||||||
|
case HUDSkinComponents.ComboText:
|
||||||
|
return new LegacySpriteText(this, comboPrefix)
|
||||||
|
{
|
||||||
|
Spacing = new Vector2(-(GetConfig<LegacySkinConfiguration.LegacySetting, int>(LegacySkinConfiguration.LegacySetting.ComboOverlap)?.Value ?? -2), 0)
|
||||||
|
};
|
||||||
|
|
||||||
|
case HUDSkinComponents.ScoreText:
|
||||||
|
return new LegacySpriteText(this, scorePrefix)
|
||||||
|
{
|
||||||
|
Spacing = new Vector2(-(GetConfig<LegacySkinConfiguration.LegacySetting, int>(LegacySkinConfiguration.LegacySetting.ScoreOverlap)?.Value ?? -2), 0)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -17,6 +17,8 @@ namespace osu.Game.Skinning
|
|||||||
Version,
|
Version,
|
||||||
ComboPrefix,
|
ComboPrefix,
|
||||||
ComboOverlap,
|
ComboOverlap,
|
||||||
|
ScorePrefix,
|
||||||
|
ScoreOverlap,
|
||||||
AnimationFramerate,
|
AnimationFramerate,
|
||||||
LayeredHitSounds
|
LayeredHitSounds
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user