1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 08:07:40 +08:00

Move combo counter to ruleset-specific HUD components target

This commit is contained in:
Salman Ahmed 2023-12-30 03:47:42 +03:00
parent 0fa4cd5dfe
commit eedb436389
8 changed files with 113 additions and 27 deletions

View File

@ -6,7 +6,7 @@ using osu.Game.Skinning;
namespace osu.Game.Rulesets.Catch.Skinning.Argon
{
public class CatchArgonSkinTransformer : SkinTransformer
public class CatchArgonSkinTransformer : ArgonSkinTransformer
{
public CatchArgonSkinTransformer(ISkin skin)
: base(skin)

View File

@ -7,7 +7,7 @@ using osu.Game.Skinning;
namespace osu.Game.Rulesets.Osu.Skinning.Argon
{
public class OsuArgonSkinTransformer : SkinTransformer
public class OsuArgonSkinTransformer : ArgonSkinTransformer
{
public OsuArgonSkinTransformer(ISkin skin)
: base(skin)

View File

@ -7,16 +7,16 @@ using osu.Game.Skinning;
namespace osu.Game.Rulesets.Taiko.Skinning.Argon
{
public class TaikoArgonSkinTransformer : SkinTransformer
public class TaikoArgonSkinTransformer : ArgonSkinTransformer
{
public TaikoArgonSkinTransformer(ISkin skin)
: base(skin)
{
}
public override Drawable? GetDrawableComponent(ISkinComponentLookup component)
public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
{
switch (component)
switch (lookup)
{
case GameplaySkinComponentLookup<HitResult> resultComponent:
// This should eventually be moved to a skin setting, when supported.
@ -75,7 +75,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Argon
break;
}
return base.GetDrawableComponent(component);
return base.GetDrawableComponent(lookup);
}
}
}

View File

@ -212,7 +212,19 @@ namespace osu.Game.Rulesets
/// <param name="skin">The source skin.</param>
/// <param name="beatmap">The current beatmap.</param>
/// <returns>A skin with a transformer applied, or null if no transformation is provided by this ruleset.</returns>
public virtual ISkin? CreateSkinTransformer(ISkin skin, IBeatmap beatmap) => null;
public virtual ISkin? CreateSkinTransformer(ISkin skin, IBeatmap beatmap)
{
switch (skin)
{
case LegacySkin:
return new LegacySkinTransformer(skin);
case ArgonSkin:
return new ArgonSkinTransformer(skin);
}
return null;
}
protected Ruleset()
{

View File

@ -111,14 +111,13 @@ namespace osu.Game.Skinning
return songSelectComponents;
case SkinComponentsContainerLookup.TargetArea.MainHUDComponents:
var skinnableTargetWrapper = new DefaultSkinComponentsContainer(container =>
var mainHUDComponents = new DefaultSkinComponentsContainer(container =>
{
var health = container.OfType<ArgonHealthDisplay>().FirstOrDefault();
var healthLine = container.OfType<BoxElement>().FirstOrDefault();
var wedgePieces = container.OfType<ArgonWedgePiece>().ToArray();
var score = container.OfType<ArgonScoreCounter>().FirstOrDefault();
var accuracy = container.OfType<ArgonAccuracyCounter>().FirstOrDefault();
var combo = container.OfType<ArgonComboCounter>().FirstOrDefault();
var songProgress = container.OfType<ArgonSongProgress>().FirstOrDefault();
var keyCounter = container.OfType<ArgonKeyCounterDisplay>().FirstOrDefault();
@ -192,13 +191,6 @@ namespace osu.Game.Skinning
keyCounter.Origin = Anchor.BottomRight;
keyCounter.Position = new Vector2(-(hitError.Width + padding), -(padding * 2 + song_progress_offset_height));
}
if (combo != null && hitError != null)
{
combo.Anchor = Anchor.BottomLeft;
combo.Origin = Anchor.BottomLeft;
combo.Position = new Vector2((hitError.Width + padding), -(padding * 2 + song_progress_offset_height));
}
}
}
})
@ -224,10 +216,6 @@ namespace osu.Game.Skinning
CornerRadius = { Value = 0.5f }
},
new ArgonAccuracyCounter(),
new ArgonComboCounter
{
Scale = new Vector2(1.3f)
},
new BarHitErrorMeter(),
new BarHitErrorMeter(),
new ArgonSongProgress(),
@ -235,7 +223,7 @@ namespace osu.Game.Skinning
}
};
return skinnableTargetWrapper;
return mainHUDComponents;
}
return null;

View File

@ -0,0 +1,53 @@
// 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 System.Linq;
using osu.Framework.Graphics;
using osu.Game.Screens.Play.HUD;
using osuTK;
namespace osu.Game.Skinning
{
public class ArgonSkinTransformer : SkinTransformer
{
public ArgonSkinTransformer(ISkin skin)
: base(skin)
{
}
public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
{
switch (lookup)
{
case SkinComponentsContainerLookup containerLookup:
switch (containerLookup.Target)
{
case SkinComponentsContainerLookup.TargetArea.MainHUDComponents when containerLookup.Ruleset != null:
var rulesetHUDComponents = Skin.GetDrawableComponent(lookup);
rulesetHUDComponents ??= new DefaultSkinComponentsContainer(container =>
{
var combo = container.OfType<ArgonComboCounter>().FirstOrDefault();
if (combo != null)
{
combo.Anchor = Anchor.BottomLeft;
combo.Origin = Anchor.BottomLeft;
combo.Position = new Vector2(36, -66);
combo.Scale = new Vector2(1.3f);
}
})
{
new ArgonComboCounter(),
};
return rulesetHUDComponents;
}
break;
}
return base.GetDrawableComponent(lookup);
}
}
}

View File

@ -399,7 +399,6 @@ namespace osu.Game.Skinning
{
Children = new Drawable[]
{
new LegacyComboCounter(),
new LegacyScoreCounter(),
new LegacyAccuracyCounter(),
new LegacySongProgress(),

View File

@ -1,28 +1,62 @@
// 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 System.Linq;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics;
using osu.Game.Audio;
using osu.Game.Rulesets.Objects.Legacy;
using osuTK;
using static osu.Game.Skinning.SkinConfiguration;
namespace osu.Game.Skinning
{
/// <summary>
/// Transformer used to handle support of legacy features for individual rulesets.
/// </summary>
public abstract class LegacySkinTransformer : SkinTransformer
public class LegacySkinTransformer : SkinTransformer
{
/// <summary>
/// Whether the skin being transformed is able to provide legacy resources for the ruleset.
/// </summary>
public virtual bool IsProvidingLegacyResources => this.HasFont(LegacyFont.Combo);
protected LegacySkinTransformer(ISkin skin)
public LegacySkinTransformer(ISkin skin)
: base(skin)
{
}
public override Drawable? GetDrawableComponent(ISkinComponentLookup lookup)
{
switch (lookup)
{
case SkinComponentsContainerLookup containerLookup:
switch (containerLookup.Target)
{
case SkinComponentsContainerLookup.TargetArea.MainHUDComponents when containerLookup.Ruleset != null:
var rulesetHUDComponents = base.GetDrawableComponent(lookup);
rulesetHUDComponents ??= new DefaultSkinComponentsContainer(container =>
{
var combo = container.OfType<LegacyComboCounter>().FirstOrDefault();
if (combo != null)
{
combo.Anchor = Anchor.BottomLeft;
combo.Origin = Anchor.BottomLeft;
combo.Scale = new Vector2(1.28f);
}
})
{
new LegacyComboCounter()
};
return rulesetHUDComponents;
}
break;
}
return base.GetDrawableComponent(lookup);
}
public override ISample? GetSample(ISampleInfo sampleInfo)
{
if (!(sampleInfo is ConvertHitObjectParser.LegacyHitSampleInfo legacySample))