Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add maximum dimensions limit to skinnable gameplay elements #24706

Merged
merged 23 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2c81fe5
Make gameplay skin elements in `special-skin` awfully large
frenzibyte Sep 1, 2023
6674c70
Add support for limiting skin texture/animation dimensions
frenzibyte Sep 2, 2023
351081e
Add limit to osu! hit circle elements
frenzibyte Sep 2, 2023
d286816
Add limit to taiko hit elements
frenzibyte Sep 2, 2023
f182f57
Add limit to catch palpable object elements
frenzibyte Sep 2, 2023
96f12cf
Update `GetTexture` signature rather than creating new overload
peppy Sep 5, 2023
9d17539
Add size limitations for taiko drum rolls
peppy Sep 5, 2023
57dc76b
Revert "Update `GetTexture` signature rather than creating new overload"
frenzibyte Sep 19, 2023
291a91b
Change extension from retrieval to post-processing instead
frenzibyte Sep 19, 2023
a373d71
Add basic test scene upscaling all skin elements
frenzibyte Sep 19, 2023
fc1a39e
Add size limitations for slider balls
frenzibyte Sep 19, 2023
f963a92
Add size limitation for slider follow circle
frenzibyte Sep 19, 2023
b823507
Add size limitation for approach circles
frenzibyte Sep 19, 2023
ab52268
Add size limitation for slider reverse arrow piece
frenzibyte Sep 19, 2023
922f6f3
Add size limitation for hit object numbers
frenzibyte Sep 19, 2023
8f5d1b5
Revert "Make gameplay skin elements in `special-skin` awfully large"
frenzibyte Sep 19, 2023
8e16b1d
Simplify some maximum size specs
peppy Sep 20, 2023
bd66285
Rename parameter on `LegacySpriteText` to better imply the maximum si…
peppy Sep 20, 2023
1316403
Fix inspection in new test scene
peppy Sep 20, 2023
c4fc419
Use correct maximum size for droplets
frenzibyte Sep 21, 2023
ad86bf2
Revert redundant size limitations
frenzibyte Sep 21, 2023
b1561b6
Rename test scene, add xmldoc and increase scale factor to something …
peppy Sep 26, 2023
990c545
Merge branch 'master' into limit-gameplay-sprite-dimensions
peppy Sep 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyBananaPiece.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Graphics.Textures;
using osu.Game.Skinning;
using osuTK;

namespace osu.Game.Rulesets.Catch.Skinning.Legacy
{
public partial class LegacyBananaPiece : LegacyCatchHitObjectPiece
{
private static readonly Vector2 banana_max_size = new Vector2(128);

protected override void LoadComplete()
{
base.LoadComplete();

Texture? texture = Skin.GetTexture("fruit-bananas");
Texture? overlayTexture = Skin.GetTexture("fruit-bananas-overlay");
Texture? texture = Skin.GetTexture("fruit-bananas")?.WithMaximumSize(banana_max_size);
Texture? overlayTexture = Skin.GetTexture("fruit-bananas-overlay")?.WithMaximumSize(banana_max_size);

SetTexture(texture, overlayTexture);
}
Expand Down
7 changes: 5 additions & 2 deletions osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyDropletPiece.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Graphics.Textures;
using osu.Game.Skinning;
using osuTK;

namespace osu.Game.Rulesets.Catch.Skinning.Legacy
{
public partial class LegacyDropletPiece : LegacyCatchHitObjectPiece
{
private static readonly Vector2 droplet_max_size = new Vector2(100);
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does 100 come from? The template skin is 82 x 103 (@1x).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not to say it's correct, but I think I picked 100 as it's closest to 103...I'll change to 82x103


public LegacyDropletPiece()
{
Scale = new Vector2(0.8f);
Expand All @@ -17,8 +20,8 @@ protected override void LoadComplete()
{
base.LoadComplete();

Texture? texture = Skin.GetTexture("fruit-drop");
Texture? overlayTexture = Skin.GetTexture("fruit-drop-overlay");
Texture? texture = Skin.GetTexture("fruit-drop")?.WithMaximumSize(droplet_max_size);
Texture? overlayTexture = Skin.GetTexture("fruit-drop-overlay")?.WithMaximumSize(droplet_max_size);

SetTexture(texture, overlayTexture);
}
Expand Down
17 changes: 13 additions & 4 deletions osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyFruitPiece.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
// See the LICENCE file in the repository root for full licence text.

using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Skinning;
using osuTK;

namespace osu.Game.Rulesets.Catch.Skinning.Legacy
{
internal partial class LegacyFruitPiece : LegacyCatchHitObjectPiece
{
private static readonly Vector2 fruit_max_size = new Vector2(128);

protected override void LoadComplete()
{
base.LoadComplete();
Expand All @@ -22,21 +26,26 @@ private void setTexture(FruitVisualRepresentation visualRepresentation)
switch (visualRepresentation)
{
case FruitVisualRepresentation.Pear:
SetTexture(Skin.GetTexture("fruit-pear"), Skin.GetTexture("fruit-pear-overlay"));
setTextures("pear");
break;

case FruitVisualRepresentation.Grape:
SetTexture(Skin.GetTexture("fruit-grapes"), Skin.GetTexture("fruit-grapes-overlay"));
setTextures("grapes");
break;

case FruitVisualRepresentation.Pineapple:
SetTexture(Skin.GetTexture("fruit-apple"), Skin.GetTexture("fruit-apple-overlay"));
setTextures("apple");
break;

case FruitVisualRepresentation.Raspberry:
SetTexture(Skin.GetTexture("fruit-orange"), Skin.GetTexture("fruit-orange-overlay"));
setTextures("orange");
break;
}

void setTextures(string fruitName) => SetTexture(
Skin.GetTexture($"fruit-{fruitName}")?.WithMaximumSize(fruit_max_size),
Skin.GetTexture($"fruit-{fruitName}-overlay")?.WithMaximumSize(fruit_max_size)
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public HitCircleOverlapMarker()
{
Origin = Anchor.Centre;

Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
Size = OsuHitObject.OBJECT_DIMENSIONS;

InternalChild = content = new Container
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public HitCirclePiece()
{
Origin = Anchor.Centre;

Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
Size = OsuHitObject.OBJECT_DIMENSIONS;

CornerRadius = Size.X / 2;
CornerExponent = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public partial class HitReceptor : CompositeDrawable, IKeyBindingHandler<OsuActi

public HitReceptor()
{
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
Size = OsuHitObject.OBJECT_DIMENSIONS;

Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private void load(DrawableHitObject drawableSlider)

Origin = Anchor.Centre;

Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
Size = OsuHitObject.OBJECT_DIMENSIONS;

Children = new[]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public DrawableSliderRepeat(SliderRepeat sliderRepeat)
private void load()
{
Origin = Anchor.Centre;
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
Size = OsuHitObject.OBJECT_DIMENSIONS;

AddInternal(scaleContainer = new Container
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public DrawableSliderTail(SliderTailCircle tailCircle)
private void load()
{
Origin = Anchor.Centre;
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
Size = OsuHitObject.OBJECT_DIMENSIONS;

AddRangeInternal(new Drawable[]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public DrawableSliderTick(SliderTick sliderTick)
[BackgroundDependencyLoader]
private void load()
{
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
Size = OsuHitObject.OBJECT_DIMENSIONS;
Origin = Anchor.Centre;

AddInternal(scaleContainer = new SkinnableDrawable(new OsuSkinComponentLookup(OsuSkinComponents.SliderScorePoint), _ => new CircularContainer
Expand Down
5 changes: 5 additions & 0 deletions osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public abstract class OsuHitObject : HitObject, IHasComboInformation, IHasPositi
/// </summary>
public const float OBJECT_RADIUS = 64;

/// <summary>
/// The width and height any element participating in display of a hitcircle (or similarly sized object) should be.
/// </summary>
public static readonly Vector2 OBJECT_DIMENSIONS = new Vector2(OBJECT_RADIUS * 2);

/// <summary>
/// Scoring distance with a speed-adjusted beat length of 1 second (ie. the speed slider balls move through their track).
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public partial class ArgonMainCirclePiece : CompositeDrawable

private Bindable<bool> configHitLighting = null!;

private static readonly Vector2 circle_size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
private static readonly Vector2 circle_size = OsuHitObject.OBJECT_DIMENSIONS;

[Resolved]
private DrawableHitObject drawableObject { get; set; } = null!;
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Osu/Skinning/Argon/ArgonReverseArrow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private void load(DrawableHitObject hitObject)
Anchor = Anchor.Centre;
Origin = Anchor.Centre;

Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
Size = OsuHitObject.OBJECT_DIMENSIONS;

InternalChildren = new Drawable[]
{
Expand Down
3 changes: 1 addition & 2 deletions osu.Game.Rulesets.Osu/Skinning/Default/CirclePiece.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using osu.Framework.Graphics.Textures;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
using osuTK;

namespace osu.Game.Rulesets.Osu.Skinning.Default
{
Expand All @@ -22,7 +21,7 @@ public partial class CirclePiece : CompositeDrawable

public CirclePiece()
{
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
Size = OsuHitObject.OBJECT_DIMENSIONS;
Masking = true;

CornerRadius = Size.X / 2;
Expand Down
3 changes: 1 addition & 2 deletions osu.Game.Rulesets.Osu/Skinning/Default/ExplodePiece.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
using osuTK;

namespace osu.Game.Rulesets.Osu.Skinning.Default
{
Expand All @@ -20,7 +19,7 @@ public partial class ExplodePiece : Container

public ExplodePiece()
{
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
Size = OsuHitObject.OBJECT_DIMENSIONS;

Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Expand Down
3 changes: 1 addition & 2 deletions osu.Game.Rulesets.Osu/Skinning/Default/FlashPiece.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Osu.Objects;
using osuTK;

namespace osu.Game.Rulesets.Osu.Skinning.Default
{
public partial class FlashPiece : Container
{
public FlashPiece()
{
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
Size = OsuHitObject.OBJECT_DIMENSIONS;

Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Expand Down
3 changes: 1 addition & 2 deletions osu.Game.Rulesets.Osu/Skinning/Default/MainCirclePiece.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Osu.Skinning.Default
Expand All @@ -25,7 +24,7 @@ public partial class MainCirclePiece : CompositeDrawable

public MainCirclePiece()
{
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
Size = OsuHitObject.OBJECT_DIMENSIONS;

Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public ReverseArrowPiece()
Anchor = Anchor.Centre;
Origin = Anchor.Centre;

Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
Size = OsuHitObject.OBJECT_DIMENSIONS;

Child = new SkinnableDrawable(new OsuSkinComponentLookup(OsuSkinComponents.ReverseArrow), _ => new SpriteIcon
{
Expand Down
3 changes: 1 addition & 2 deletions osu.Game.Rulesets.Osu/Skinning/Default/RingPiece.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Osu.Objects;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Osu.Skinning.Default
Expand All @@ -14,7 +13,7 @@ public partial class RingPiece : CircularContainer
{
public RingPiece(float thickness = 9)
{
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
Size = OsuHitObject.OBJECT_DIMENSIONS;

Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
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>();
Expand All @@ -19,7 +21,7 @@ public partial class LegacyApproachCircle : SkinnableSprite
private DrawableHitObject drawableObject { get; set; } = null!;

public LegacyApproachCircle()
: base("Gameplay/osu/approachcircle")
: base("Gameplay/osu/approachcircle", OsuHitObject.OBJECT_DIMENSIONS)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Osu.Skinning.Legacy
Expand Down Expand Up @@ -51,7 +50,7 @@ public LegacyMainCirclePiece(string? priorityLookupPrefix = null, bool hasNumber
this.priorityLookupPrefix = priorityLookupPrefix;
this.hasNumber = hasNumber;

Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
Size = OsuHitObject.OBJECT_DIMENSIONS;
}

[BackgroundDependencyLoader]
Expand All @@ -68,7 +67,7 @@ private void load()
// expected behaviour in this scenario is not showing the overlay, rather than using hitcircleoverlay.png.
InternalChildren = new[]
{
CircleSprite = new LegacyKiaiFlashingDrawable(() => new Sprite { Texture = skin.GetTexture(circleName) })
CircleSprite = new LegacyKiaiFlashingDrawable(() => new Sprite { Texture = skin.GetTexture(circleName)?.WithMaximumSize(OsuHitObject.OBJECT_DIMENSIONS) })
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Expand All @@ -77,7 +76,7 @@ private void load()
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Child = OverlaySprite = new LegacyKiaiFlashingDrawable(() => skin.GetAnimation(@$"{circleName}overlay", true, true, frameLength: 1000 / 2d))
Child = OverlaySprite = new LegacyKiaiFlashingDrawable(() => skin.GetAnimation(@$"{circleName}overlay", true, true, frameLength: 1000 / 2d, maxSize: OsuHitObject.OBJECT_DIMENSIONS))
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Expand Down
3 changes: 2 additions & 1 deletion osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyReverseArrow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Skinning;
using osuTK.Graphics;
Expand Down Expand Up @@ -35,7 +36,7 @@ private void load(ISkinSource skinSource)

var skin = skinSource.FindProvider(s => s.GetTexture(lookupName) != null);

InternalChild = arrow = (skin?.GetAnimation(lookupName, true, true) ?? Empty());
InternalChild = arrow = (skin?.GetAnimation(lookupName, true, true, maxSize: OsuHitObject.OBJECT_DIMENSIONS) ?? Empty());
textureIsDefaultSkin = skin is ISkinTransformer transformer && transformer.Skin is DefaultLegacySkin;
}

Expand Down
5 changes: 3 additions & 2 deletions osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Skinning;
using osuTK.Graphics;
Expand Down Expand Up @@ -46,7 +47,7 @@ private void load()
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Texture = skin.GetTexture("sliderb-nd"),
Texture = skin.GetTexture("sliderb-nd")?.WithMaximumSize(OsuHitObject.OBJECT_DIMENSIONS),
Colour = new Color4(5, 5, 5, 255),
},
LegacyColourCompatibility.ApplyWithDoubledAlpha(animationContent.With(d =>
Expand All @@ -58,7 +59,7 @@ private void load()
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Texture = skin.GetTexture("sliderb-spec"),
Texture = skin.GetTexture("sliderb-spec")?.WithMaximumSize(OsuHitObject.OBJECT_DIMENSIONS),
Blending = BlendingParameters.Additive,
},
};
Expand Down