1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-18 12:00:22 +08:00

Map sliderpoint textures directly to HitResult types

This commit is contained in:
clayton
2025-08-16 04:54:34 -07:00
Unverified
parent f2839c7b65
commit 4d1ecab4e3
4 changed files with 16 additions and 49 deletions
@@ -1,34 +1,15 @@
// 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.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Skinning;
using osuTK;
namespace osu.Game.Rulesets.Osu.Skinning.Legacy
{
public partial class LegacyJudgementPieceSliderTickHit : Sprite, IAnimatableJudgement, IAppliesJudgementResult
public partial class LegacyJudgementPieceSliderTickHit : Sprite, IAnimatableJudgement
{
private Texture? texture10;
private Texture? texture30;
[BackgroundDependencyLoader]
private void load(ISkinSource skin)
{
texture10 = skin.GetTexture("sliderpoint10");
texture30 = skin.GetTexture("sliderpoint30");
}
public void ApplyJudgementResult(JudgementResult result)
{
Texture = result.HitObject is SliderTick ? texture10 : texture30;
}
public void PlayAnimation()
{
// https://github.com/peppy/osu-stable-reference/blob/0e91e49bc83fe8b21c3ba5f1eb2d5d06456eae84/osu!/GameModes/Play/Rulesets/Ruleset.cs#L804-L806
@@ -5,6 +5,7 @@ using System;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play.HUD;
@@ -119,18 +120,19 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
case SkinComponentLookup<HitResult> resultComponent:
switch (resultComponent.Component)
{
// osu!stable didn't show slider points on the tail, since that's where the slider judgement was shown. Here, sliderpoint30 will be shown on non-classic tails via SliderTailHit.
case HitResult.LargeTickHit:
case HitResult.SliderTailHit:
if (hasSliderPoints())
return new LegacyJudgementPieceSliderTickHit();
if (getSliderPointTexture(resultComponent.Component) is Texture texture)
return new LegacyJudgementPieceSliderTickHit { Texture = texture };
return base.GetDrawableComponent(lookup);
// If slider points are showing and tick misses aren't provided by this skin, don't look up tick misses from any further skins.
// If the corresponding hit result displays a judgement and the miss texture isn't provided by this skin, don't look up the miss texture from any further skins.
case HitResult.LargeTickMiss:
case HitResult.IgnoreMiss:
if (hasSliderPoints())
if (getSliderPointTexture(resultComponent.Component == HitResult.LargeTickMiss
? HitResult.LargeTickHit
: HitResult.SliderTailHit) != null)
return base.GetDrawableComponent(lookup) ?? Drawable.Empty();
return base.GetDrawableComponent(lookup);
@@ -139,12 +141,15 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
return base.GetDrawableComponent(lookup);
}
bool hasSliderPoints() =>
Texture? getSliderPointTexture(HitResult result)
{
// https://github.com/peppy/osu-stable-reference/blob/0e91e49bc83fe8b21c3ba5f1eb2d5d06456eae84/osu!/GameModes/Play/Rulesets/Ruleset.cs#L799
GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value < 2m
// Note that osu!stable didn't require both sliderpoint textures to be present like this. There's not enough information in the lookup to decide which of the textures should be used, so we can't handle them separately. The hope is that this won't break many skins because it'd be very odd to customise only one of these textures.
&& GetTexture("sliderpoint10") != null
&& GetTexture("sliderpoint30") != null;
if (GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value < 2m)
// Note that osu!stable used sliderpoint30 for heads and repeats, and sliderpoint10 for ticks, but the mapping is intentionally changed here so that each texture represents one type of HitResult.
return GetTexture(result == HitResult.LargeTickHit ? "sliderpoint30" : "sliderpoint10");
return null;
}
case OsuSkinComponentLookup osuComponent:
switch (osuComponent.Component)
@@ -89,9 +89,6 @@ namespace osu.Game.Rulesets.Judgements
{
Result = result;
JudgedHitObject = judgedObject?.HitObject;
if (JudgementBody?.Drawable is IAppliesJudgementResult appliesResult)
appliesResult.ApplyJudgementResult(Result);
}
protected override void FreeAfterUse()
@@ -1,16 +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.
namespace osu.Game.Rulesets.Judgements
{
/// <summary>
/// A skinnable judgement element which requires the full <see cref="JudgementResult"/>.
/// </summary>
public interface IAppliesJudgementResult
{
/// <summary>
/// Associate a result with this judgement element.
/// </summary>
void ApplyJudgementResult(JudgementResult result);
}
}