1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Add size limitation for approach circles

This commit is contained in:
Salman Ahmed 2023-09-19 04:36:40 +03:00
parent f963a921db
commit b823507b2a
3 changed files with 15 additions and 7 deletions

View File

@ -5,12 +5,14 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Osu.Skinning.Legacy
{
// todo: this should probably not be a SkinnableSprite, as this is always created for legacy skins and is recreated on skin change.
public partial class LegacyApproachCircle : SkinnableSprite
{
private readonly IBindable<Color4> accentColour = new Bindable<Color4>();
@ -19,7 +21,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
private DrawableHitObject drawableObject { get; set; } = null!;
public LegacyApproachCircle()
: base("Gameplay/osu/approachcircle")
: base("Gameplay/osu/approachcircle", new Vector2(OsuHitObject.OBJECT_RADIUS * 2))
{
}

View File

@ -190,7 +190,7 @@ namespace osu.Game.Skinning
{
// This fallback is important for user skins which use SkinnableSprites.
case SkinnableSprite.SpriteComponentLookup sprite:
return this.GetAnimation(sprite.LookupName, false, false);
return this.GetAnimation(sprite.LookupName, false, false, maxSize: sprite.MaxSize);
case SkinComponentsContainerLookup containerLookup:

View File

@ -34,8 +34,8 @@ namespace osu.Game.Skinning
[Resolved]
private ISkinSource source { get; set; } = null!;
public SkinnableSprite(string textureName, ConfineMode confineMode = ConfineMode.NoScaling)
: base(new SpriteComponentLookup(textureName), confineMode)
public SkinnableSprite(string textureName, Vector2? maxSize = null, ConfineMode confineMode = ConfineMode.NoScaling)
: base(new SpriteComponentLookup(textureName, maxSize), confineMode)
{
SpriteName.Value = textureName;
}
@ -56,10 +56,14 @@ namespace osu.Game.Skinning
protected override Drawable CreateDefault(ISkinComponentLookup lookup)
{
var texture = textures.Get(((SpriteComponentLookup)lookup).LookupName);
var spriteLookup = (SpriteComponentLookup)lookup;
var texture = textures.Get(spriteLookup.LookupName);
if (texture == null)
return new SpriteNotFound(((SpriteComponentLookup)lookup).LookupName);
return new SpriteNotFound(spriteLookup.LookupName);
if (spriteLookup.MaxSize != null)
texture = texture.WithMaximumSize(spriteLookup.MaxSize.Value);
return new Sprite { Texture = texture };
}
@ -69,10 +73,12 @@ namespace osu.Game.Skinning
internal class SpriteComponentLookup : ISkinComponentLookup
{
public string LookupName { get; set; }
public Vector2? MaxSize { get; set; }
public SpriteComponentLookup(string textureName)
public SpriteComponentLookup(string textureName, Vector2? maxSize = null)
{
LookupName = textureName;
MaxSize = maxSize;
}
}