1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 08:32:57 +08:00

Update GetTexture signature rather than creating new overload

This commit is contained in:
Dean Herbert 2023-09-05 18:01:09 +09:00
parent f182f571cb
commit 96f12cfbaa
30 changed files with 84 additions and 73 deletions

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Skinning;
using osuTK; using osuTK;
namespace osu.Game.Rulesets.Catch.Skinning.Legacy namespace osu.Game.Rulesets.Catch.Skinning.Legacy
@ -15,8 +14,8 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
{ {
base.LoadComplete(); base.LoadComplete();
Texture? texture = Skin.GetTextureWithMaxSize("fruit-bananas", banana_max_size); Texture? texture = Skin.GetTexture("fruit-bananas", banana_max_size);
Texture? overlayTexture = Skin.GetTextureWithMaxSize("fruit-bananas-overlay", banana_max_size); Texture? overlayTexture = Skin.GetTexture("fruit-bananas-overlay", banana_max_size);
SetTexture(texture, overlayTexture); SetTexture(texture, overlayTexture);
} }

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Skinning;
using osuTK; using osuTK;
namespace osu.Game.Rulesets.Catch.Skinning.Legacy namespace osu.Game.Rulesets.Catch.Skinning.Legacy
@ -20,8 +19,8 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
{ {
base.LoadComplete(); base.LoadComplete();
Texture? texture = Skin.GetTextureWithMaxSize("fruit-drop", droplet_max_size); Texture? texture = Skin.GetTexture("fruit-drop", droplet_max_size);
Texture? overlayTexture = Skin.GetTextureWithMaxSize("fruit-drop-overlay", droplet_max_size); Texture? overlayTexture = Skin.GetTexture("fruit-drop-overlay", droplet_max_size);
SetTexture(texture, overlayTexture); SetTexture(texture, overlayTexture);
} }

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Skinning;
using osuTK; using osuTK;
namespace osu.Game.Rulesets.Catch.Skinning.Legacy namespace osu.Game.Rulesets.Catch.Skinning.Legacy
@ -26,19 +25,19 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
switch (visualRepresentation) switch (visualRepresentation)
{ {
case FruitVisualRepresentation.Pear: case FruitVisualRepresentation.Pear:
SetTexture(Skin.GetTextureWithMaxSize("fruit-pear", fruit_max_size), Skin.GetTextureWithMaxSize("fruit-pear-overlay", fruit_max_size)); SetTexture(Skin.GetTexture("fruit-pear", fruit_max_size), Skin.GetTexture("fruit-pear-overlay", fruit_max_size));
break; break;
case FruitVisualRepresentation.Grape: case FruitVisualRepresentation.Grape:
SetTexture(Skin.GetTextureWithMaxSize("fruit-grapes", fruit_max_size), Skin.GetTextureWithMaxSize("fruit-grapes-overlay", fruit_max_size)); SetTexture(Skin.GetTexture("fruit-grapes", fruit_max_size), Skin.GetTexture("fruit-grapes-overlay", fruit_max_size));
break; break;
case FruitVisualRepresentation.Pineapple: case FruitVisualRepresentation.Pineapple:
SetTexture(Skin.GetTextureWithMaxSize("fruit-apple", fruit_max_size), Skin.GetTextureWithMaxSize("fruit-apple-overlay", fruit_max_size)); SetTexture(Skin.GetTexture("fruit-apple", fruit_max_size), Skin.GetTexture("fruit-apple-overlay", fruit_max_size));
break; break;
case FruitVisualRepresentation.Raspberry: case FruitVisualRepresentation.Raspberry:
SetTexture(Skin.GetTextureWithMaxSize("fruit-orange", fruit_max_size), Skin.GetTextureWithMaxSize("fruit-orange-overlay", fruit_max_size)); SetTexture(Skin.GetTexture("fruit-orange", fruit_max_size), Skin.GetTexture("fruit-orange-overlay", fruit_max_size));
break; break;
} }
} }

View File

@ -14,6 +14,7 @@ using osu.Framework.Testing;
using osu.Game.Rulesets.Osu.Skinning.Legacy; using osu.Game.Rulesets.Osu.Skinning.Legacy;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osuTK;
namespace osu.Game.Rulesets.Osu.Tests namespace osu.Game.Rulesets.Osu.Tests
{ {
@ -77,9 +78,9 @@ namespace osu.Game.Rulesets.Osu.Tests
// shouldn't be required as GetTexture(string) calls GetTexture(string, WrapMode, WrapMode) by default, // shouldn't be required as GetTexture(string) calls GetTexture(string, WrapMode, WrapMode) by default,
// but moq doesn't handle that well, therefore explicitly requiring to use `CallBase`: // but moq doesn't handle that well, therefore explicitly requiring to use `CallBase`:
// https://github.com/moq/moq4/issues/972 // https://github.com/moq/moq4/issues/972
skin.Setup(s => s.GetTexture(It.IsAny<string>())).CallBase(); skin.Setup(s => s.GetTexture(It.IsAny<string>(), It.IsAny<Vector2>(), It.IsAny<WrapMode>(), It.IsAny<WrapMode>())).CallBase();
skin.Setup(s => s.GetTexture(It.IsIn(textureFilenames), It.IsAny<WrapMode>(), It.IsAny<WrapMode>())) skin.Setup(s => s.GetTexture(It.IsIn(textureFilenames), It.IsAny<Vector2>(), It.IsAny<WrapMode>(), It.IsAny<WrapMode>()))
.Returns((string componentName, WrapMode _, WrapMode _) => .Returns((string componentName, WrapMode _, WrapMode _) =>
{ {
var tex = renderer.CreateTexture(1, 1); var tex = renderer.CreateTexture(1, 1);

View File

@ -98,7 +98,7 @@ namespace osu.Game.Rulesets.Osu.Tests
public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => null; public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => null;
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default)
{ {
switch (componentName) switch (componentName)
{ {

View File

@ -130,7 +130,7 @@ namespace osu.Game.Rulesets.Osu.Tests
private class TopLeftCursorSkin : ISkin private class TopLeftCursorSkin : ISkin
{ {
public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => null; public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => null;
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => null; public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => null;
public ISample GetSample(ISampleInfo sampleInfo) => null; public ISample GetSample(ISampleInfo sampleInfo) => null;
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)

View File

@ -25,6 +25,7 @@ using osu.Game.Rulesets.Osu.Skinning.Default;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Game.Storyboards; using osu.Game.Storyboards;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osuTK;
namespace osu.Game.Rulesets.Osu.Tests namespace osu.Game.Rulesets.Osu.Tests
{ {
@ -163,7 +164,7 @@ namespace osu.Game.Rulesets.Osu.Tests
}; };
} }
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => null; public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => null;
public ISample GetSample(ISampleInfo sampleInfo) => null; public ISample GetSample(ISampleInfo sampleInfo) => null;

View File

@ -70,7 +70,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
// expected behaviour in this scenario is not showing the overlay, rather than using hitcircleoverlay.png. // expected behaviour in this scenario is not showing the overlay, rather than using hitcircleoverlay.png.
InternalChildren = new[] InternalChildren = new[]
{ {
CircleSprite = new LegacyKiaiFlashingDrawable(() => new Sprite { Texture = skin.GetTextureWithMaxSize(circleName, circle_piece_size) }) CircleSprite = new LegacyKiaiFlashingDrawable(() => new Sprite { Texture = skin.GetTexture(circleName, circle_piece_size) })
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,

View File

@ -20,6 +20,7 @@ using osu.Game.Rulesets.Objects.Legacy;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
namespace osu.Game.Tests.Gameplay namespace osu.Game.Tests.Gameplay
@ -140,7 +141,7 @@ namespace osu.Game.Tests.Gameplay
public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => throw new NotImplementedException(); public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => throw new NotImplementedException();
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => throw new NotImplementedException(); public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => throw new NotImplementedException();
public ISample GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException(); public ISample GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();

View File

@ -18,6 +18,7 @@ using osu.Framework.Timing;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osuTK;
namespace osu.Game.Tests.NonVisual.Skinning namespace osu.Game.Tests.NonVisual.Skinning
{ {
@ -68,7 +69,7 @@ namespace osu.Game.Tests.NonVisual.Skinning
this.renderer = renderer; this.renderer = renderer;
} }
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default)
{ {
return lookup_names.Contains(componentName) ? renderer.WhitePixel : null; return lookup_names.Contains(componentName) ? renderer.WhitePixel : null;
} }

View File

@ -17,6 +17,7 @@ using osu.Game.Rulesets;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Game.Tests.Testing; using osu.Game.Tests.Testing;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osuTK;
namespace osu.Game.Tests.Rulesets namespace osu.Game.Tests.Rulesets
{ {
@ -80,7 +81,7 @@ namespace osu.Game.Tests.Rulesets
public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => skin.GetDrawableComponent(lookup); public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => skin.GetDrawableComponent(lookup);
public Texture GetTexture(string componentName, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => skin.GetTexture(componentName); public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => skin.GetTexture(componentName);
public ISample GetSample(ISampleInfo sampleInfo) => skin.GetSample(sampleInfo); public ISample GetSample(ISampleInfo sampleInfo) => skin.GetSample(sampleInfo);

View File

@ -16,6 +16,7 @@ using osu.Game.Screens.Play.HUD;
using osu.Game.Screens.Play.HUD.HitErrorMeters; using osu.Game.Screens.Play.HUD.HitErrorMeters;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Game.Tests.Resources; using osu.Game.Tests.Resources;
using osuTK;
namespace osu.Game.Tests.Skins namespace osu.Game.Tests.Skins
{ {
@ -133,7 +134,7 @@ namespace osu.Game.Tests.Skins
{ {
} }
public override Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => throw new NotImplementedException(); public override Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => throw new NotImplementedException();
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => throw new NotImplementedException(); public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => throw new NotImplementedException();

View File

@ -18,6 +18,7 @@ using osu.Game.Rulesets.Osu;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Game.Tests.Beatmaps; using osu.Game.Tests.Beatmaps;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osuTK;
namespace osu.Game.Tests.Skins namespace osu.Game.Tests.Skins
{ {
@ -100,7 +101,8 @@ namespace osu.Game.Tests.Skins
public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => skin.GetDrawableComponent(lookup); public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => skin.GetDrawableComponent(lookup);
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => skin.GetTexture(componentName, wrapModeS, wrapModeT); public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) =>
skin.GetTexture(componentName, maxSize, wrapModeS, wrapModeT);
public ISample GetSample(ISampleInfo sampleInfo) => skin.GetSample(sampleInfo); public ISample GetSample(ISampleInfo sampleInfo) => skin.GetSample(sampleInfo);

View File

@ -21,6 +21,7 @@ using osu.Game.Rulesets.Osu;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Game.Tests.Beatmaps; using osu.Game.Tests.Beatmaps;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
namespace osu.Game.Tests.Skins namespace osu.Game.Tests.Skins
@ -223,7 +224,8 @@ namespace osu.Game.Tests.Skins
public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => skin.GetDrawableComponent(lookup); public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => skin.GetDrawableComponent(lookup);
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => skin.GetTexture(componentName, wrapModeS, wrapModeT); public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) =>
skin.GetTexture(componentName, maxSize, wrapModeS, wrapModeT);
public ISample GetSample(ISampleInfo sampleInfo) => skin.GetSample(sampleInfo); public ISample GetSample(ISampleInfo sampleInfo) => skin.GetSample(sampleInfo);

View File

@ -16,6 +16,7 @@ using osu.Framework.Testing;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osuTK;
namespace osu.Game.Tests.Skins namespace osu.Game.Tests.Skins
{ {
@ -89,7 +90,7 @@ namespace osu.Game.Tests.Skins
public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => throw new System.NotImplementedException(); public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => throw new System.NotImplementedException();
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default)
{ {
if (componentName == TEXTURE_NAME) if (componentName == TEXTURE_NAME)
return renderer.WhitePixel; return renderer.WhitePixel;

View File

@ -22,6 +22,7 @@ using osu.Game.IO;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Game.Tests.Resources; using osu.Game.Tests.Resources;
using osu.Game.Tests.Visual; using osu.Game.Tests.Visual;
using osuTK;
namespace osu.Game.Tests.Skins namespace osu.Game.Tests.Skins
{ {
@ -100,7 +101,7 @@ namespace osu.Game.Tests.Skins
{ {
} }
public override Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => throw new NotImplementedException(); public override Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => throw new NotImplementedException();
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => throw new NotImplementedException(); public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => throw new NotImplementedException();

View File

@ -297,7 +297,7 @@ namespace osu.Game.Tests.Visual.Gameplay
} }
: null; : null;
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => throw new NotImplementedException(); public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => throw new NotImplementedException();
public ISample GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException(); public ISample GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
@ -308,7 +308,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
public Drawable GetDrawableComponent(ISkinComponentLookup componentLookupName) => new SecondarySourceBox(); public Drawable GetDrawableComponent(ISkinComponentLookup componentLookupName) => new SecondarySourceBox();
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => throw new NotImplementedException(); public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => throw new NotImplementedException();
public ISample GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException(); public ISample GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
@ -320,7 +320,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
public Drawable GetDrawableComponent(ISkinComponentLookup componentLookupName) => new BaseSourceBox(); public Drawable GetDrawableComponent(ISkinComponentLookup componentLookupName) => new BaseSourceBox();
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => throw new NotImplementedException(); public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => throw new NotImplementedException();
public ISample GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException(); public ISample GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();

View File

@ -15,6 +15,7 @@ using osu.Framework.Graphics.Textures;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK;
namespace osu.Game.Tests.Visual.Gameplay namespace osu.Game.Tests.Visual.Gameplay
{ {
@ -163,7 +164,10 @@ namespace osu.Game.Tests.Visual.Gameplay
IBindable<bool> ISamplePlaybackDisabler.SamplePlaybackDisabled => SamplePlaybackDisabled; IBindable<bool> ISamplePlaybackDisabler.SamplePlaybackDisabled => SamplePlaybackDisabled;
public Drawable? GetDrawableComponent(ISkinComponentLookup lookup) => source.GetDrawableComponent(lookup); public Drawable? GetDrawableComponent(ISkinComponentLookup lookup) => source.GetDrawableComponent(lookup);
public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => source.GetTexture(componentName, wrapModeS, wrapModeT);
public Texture? GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) =>
source.GetTexture(componentName, maxSize, wrapModeS, wrapModeT);
public ISample? GetSample(ISampleInfo sampleInfo) => OverridingSample ?? source.GetSample(sampleInfo); public ISample? GetSample(ISampleInfo sampleInfo) => OverridingSample ?? source.GetSample(sampleInfo);
public IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup) public IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup)

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
namespace osu.Game.Screens.Edit namespace osu.Game.Screens.Edit
@ -54,7 +55,10 @@ namespace osu.Game.Screens.Edit
#region Delegated ISkin implementation #region Delegated ISkin implementation
public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => Skin.GetDrawableComponent(lookup); public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => Skin.GetDrawableComponent(lookup);
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => Skin.GetTexture(componentName, wrapModeS, wrapModeT);
public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) =>
Skin.GetTexture(componentName, maxSize, wrapModeS, wrapModeT);
public ISample GetSample(ISampleInfo sampleInfo) => Skin.GetSample(sampleInfo); public ISample GetSample(ISampleInfo sampleInfo) => Skin.GetSample(sampleInfo);
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => Skin.GetConfig<TLookup, TValue>(lookup); public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => Skin.GetConfig<TLookup, TValue>(lookup);

View File

@ -67,7 +67,8 @@ namespace osu.Game.Skinning
}; };
} }
public override Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => Textures?.Get(componentName, wrapModeS, wrapModeT); public override Texture? GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) =>
Textures?.Get(componentName, wrapModeS, wrapModeT).WithMaximumSize(maxSize);
public override ISample? GetSample(ISampleInfo sampleInfo) public override ISample? GetSample(ISampleInfo sampleInfo)
{ {

View File

@ -6,6 +6,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Audio; using osu.Game.Audio;
using osuTK;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
@ -25,17 +26,11 @@ namespace osu.Game.Skinning
/// Retrieve a <see cref="Texture"/>. /// Retrieve a <see cref="Texture"/>.
/// </summary> /// </summary>
/// <param name="componentName">The requested texture.</param> /// <param name="componentName">The requested texture.</param>
/// <returns>A matching texture, or null if unavailable.</returns> /// <param name="maxSize">The maximum dimensions that the texture should be.</param>
Texture? GetTexture(string componentName) => GetTexture(componentName, default, default);
/// <summary>
/// Retrieve a <see cref="Texture"/>.
/// </summary>
/// <param name="componentName">The requested texture.</param>
/// <param name="wrapModeS">The texture wrap mode in horizontal direction.</param> /// <param name="wrapModeS">The texture wrap mode in horizontal direction.</param>
/// <param name="wrapModeT">The texture wrap mode in vertical direction.</param> /// <param name="wrapModeT">The texture wrap mode in vertical direction.</param>
/// <returns>A matching texture, or null if unavailable.</returns> /// <returns>A matching texture, or null if unavailable.</returns>
Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT); Texture? GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default);
/// <summary> /// <summary>
/// Retrieve a <see cref="SampleChannel"/>. /// Retrieve a <see cref="SampleChannel"/>.

View File

@ -466,7 +466,7 @@ namespace osu.Game.Skinning
return null; return null;
} }
public override Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) public override Texture? GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default)
{ {
switch (componentName) switch (componentName)
{ {
@ -497,7 +497,8 @@ namespace osu.Game.Skinning
continue; continue;
texture.ScaleAdjust = ratio; texture.ScaleAdjust = ratio;
return texture;
return texture.WithMaximumSize(maxSize);
} }
return null; return null;

View File

@ -67,7 +67,7 @@ namespace osu.Game.Skinning
if (animatable && s.GetTexture(getFrameName(0)) != null) if (animatable && s.GetTexture(getFrameName(0)) != null)
return true; return true;
return s.GetTexture(componentName, wrapModeS, wrapModeT) != null; return s.GetTexture(componentName, maxSize, wrapModeS, wrapModeT) != null;
}) ?? source; }) ?? source;
if (animatable) if (animatable)
@ -79,21 +79,15 @@ namespace osu.Game.Skinning
} }
// if an animation was not allowed or not found, fall back to a sprite retrieval. // if an animation was not allowed or not found, fall back to a sprite retrieval.
var singleTexture = maxSize != null var singleTexture = retrievalSource.GetTexture(componentName, maxSize, wrapModeS, wrapModeT);
? retrievalSource.GetTextureWithMaxSize(componentName, maxSize.Value, wrapModeS, wrapModeT)
: retrievalSource.GetTexture(componentName, wrapModeS, wrapModeT);
return singleTexture != null return singleTexture != null ? new[] { singleTexture } : Array.Empty<Texture>();
? new[] { singleTexture }
: Array.Empty<Texture>();
IEnumerable<Texture> getTextures(ISkin skin) IEnumerable<Texture> getTextures(ISkin skin)
{ {
for (int i = 0; true; i++) for (int i = 0; true; i++)
{ {
var texture = maxSize != null var texture = skin.GetTexture(getFrameName(i), maxSize, wrapModeS, wrapModeT);
? skin.GetTextureWithMaxSize(getFrameName(i), maxSize.Value, wrapModeS, wrapModeT)
: skin.GetTexture(getFrameName(i), wrapModeS, wrapModeT);
if (texture == null) if (texture == null)
break; break;
@ -105,17 +99,16 @@ namespace osu.Game.Skinning
string getFrameName(int frameIndex) => $"{componentName}{animationSeparator}{frameIndex}"; string getFrameName(int frameIndex) => $"{componentName}{animationSeparator}{frameIndex}";
} }
public static Texture? GetTextureWithMaxSize(this ISkin source, string componentName, Vector2 maxSize, WrapMode wrapModeS = WrapMode.None, WrapMode wrapModeT = WrapMode.None) public static Texture? WithMaximumSize(this Texture? texture, Vector2? maxSize)
{ {
var texture = source.GetTexture(componentName, wrapModeS, wrapModeT); if (texture == null || maxSize == null)
if (texture == null)
return texture; return texture;
if (texture.DisplayWidth <= maxSize.X && texture.DisplayHeight <= maxSize.Y) if (texture.DisplayWidth <= maxSize.Value.X && texture.DisplayHeight <= maxSize.Value.Y)
return texture; return texture;
// use scale adjust property for downscaling the texture in order to meet the specified maximum dimensions. // use scale adjust property for downscaling the texture in order to meet the specified maximum dimensions.
texture.ScaleAdjust *= Math.Max(texture.DisplayWidth / maxSize.X, texture.DisplayHeight / maxSize.Y); texture.ScaleAdjust *= Math.Max(texture.DisplayWidth / maxSize.Value.X, texture.DisplayHeight / maxSize.Value.Y);
return texture; return texture;
} }

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics.Textures;
using osu.Framework.IO.Stores; using osu.Framework.IO.Stores;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Audio; using osu.Game.Audio;
using osuTK;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
@ -29,7 +30,8 @@ namespace osu.Game.Skinning
public Drawable? GetDrawableComponent(ISkinComponentLookup lookup) => null; public Drawable? GetDrawableComponent(ISkinComponentLookup lookup) => null;
public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => textures.Get(componentName, wrapModeS, wrapModeT); public Texture? GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) =>
textures.Get(componentName, wrapModeS, wrapModeT).WithMaximumSize(maxSize);
public ISample? GetSample(ISampleInfo sampleInfo) public ISample? GetSample(ISampleInfo sampleInfo)
{ {

View File

@ -18,6 +18,7 @@ using osu.Framework.Logging;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.IO; using osu.Game.IO;
using osuTK;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
@ -44,9 +45,7 @@ namespace osu.Game.Skinning
public abstract ISample? GetSample(ISampleInfo sampleInfo); public abstract ISample? GetSample(ISampleInfo sampleInfo);
public Texture? GetTexture(string componentName) => GetTexture(componentName, default, default); public abstract Texture? GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default);
public abstract Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT);
public abstract IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup) public abstract IBindable<TValue>? GetConfig<TLookup, TValue>(TLookup lookup)
where TLookup : notnull where TLookup : notnull

View File

@ -25,6 +25,7 @@ using osu.Game.Database;
using osu.Game.IO; using osu.Game.IO;
using osu.Game.Overlays.Notifications; using osu.Game.Overlays.Notifications;
using osu.Game.Utils; using osu.Game.Utils;
using osuTK;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
@ -223,7 +224,8 @@ namespace osu.Game.Skinning
public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => lookupWithFallback(s => s.GetDrawableComponent(lookup)); public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => lookupWithFallback(s => s.GetDrawableComponent(lookup));
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => lookupWithFallback(s => s.GetTexture(componentName, wrapModeS, wrapModeT)); public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) =>
lookupWithFallback(s => s.GetTexture(componentName, maxSize, wrapModeS, wrapModeT));
public ISample GetSample(ISampleInfo sampleInfo) => lookupWithFallback(s => s.GetSample(sampleInfo)); public ISample GetSample(ISampleInfo sampleInfo) => lookupWithFallback(s => s.GetSample(sampleInfo));

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Audio; using osu.Game.Audio;
using osuTK;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
@ -127,19 +128,19 @@ namespace osu.Game.Skinning
return ParentSource?.GetDrawableComponent(lookup); return ParentSource?.GetDrawableComponent(lookup);
} }
public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) public Texture? GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default)
{ {
foreach (var (_, lookupWrapper) in skinSources) foreach (var (_, lookupWrapper) in skinSources)
{ {
Texture? sourceTexture; Texture? sourceTexture;
if ((sourceTexture = lookupWrapper.GetTexture(componentName, wrapModeS, wrapModeT)) != null) if ((sourceTexture = lookupWrapper.GetTexture(componentName, maxSize, wrapModeS, wrapModeT)) != null)
return sourceTexture; return sourceTexture;
} }
if (!AllowFallingBackToParent) if (!AllowFallingBackToParent)
return null; return null;
return ParentSource?.GetTexture(componentName, wrapModeS, wrapModeT); return ParentSource?.GetTexture(componentName, maxSize, wrapModeS, wrapModeT);
} }
public ISample? GetSample(ISampleInfo sampleInfo) public ISample? GetSample(ISampleInfo sampleInfo)
@ -251,10 +252,10 @@ namespace osu.Game.Skinning
return null; return null;
} }
public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) public Texture? GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default)
{ {
if (provider.AllowTextureLookup(componentName)) if (provider.AllowTextureLookup(componentName))
return skin.GetTexture(componentName, wrapModeS, wrapModeT); return skin.GetTexture(componentName, maxSize, wrapModeS, wrapModeT);
return null; return null;
} }

View File

@ -7,6 +7,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Audio; using osu.Game.Audio;
using osuTK;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
@ -28,9 +29,7 @@ namespace osu.Game.Skinning
public virtual Drawable? GetDrawableComponent(ISkinComponentLookup lookup) => Skin.GetDrawableComponent(lookup); public virtual Drawable? GetDrawableComponent(ISkinComponentLookup lookup) => Skin.GetDrawableComponent(lookup);
public virtual Texture? GetTexture(string componentName) => GetTexture(componentName, default, default); public virtual Texture? GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => Skin.GetTexture(componentName, maxSize, wrapModeS, wrapModeT);
public virtual Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => Skin.GetTexture(componentName, wrapModeS, wrapModeT);
public virtual ISample? GetSample(ISampleInfo sampleInfo) => Skin.GetSample(sampleInfo); public virtual ISample? GetSample(ISampleInfo sampleInfo) => Skin.GetSample(sampleInfo);

View File

@ -44,7 +44,8 @@ namespace osu.Game.Skinning
this.resources = resources; this.resources = resources;
} }
public override Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => Textures?.Get(componentName, wrapModeS, wrapModeT); public override Texture? GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) =>
Textures?.Get(componentName, wrapModeS, wrapModeT).WithMaximumSize(maxSize);
public override ISample? GetSample(ISampleInfo sampleInfo) public override ISample? GetSample(ISampleInfo sampleInfo)
{ {

View File

@ -207,9 +207,9 @@ namespace osu.Game.Tests.Visual
this.extrapolateAnimations = extrapolateAnimations; this.extrapolateAnimations = extrapolateAnimations;
} }
public override Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) public override Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default)
{ {
var lookup = base.GetTexture(componentName, wrapModeS, wrapModeT); var lookup = base.GetTexture(componentName, maxSize, wrapModeS, wrapModeT);
if (lookup != null) if (lookup != null)
return lookup; return lookup;
@ -220,7 +220,7 @@ namespace osu.Game.Tests.Visual
var match = Regex.Match(componentName, "-([0-9]*)"); var match = Regex.Match(componentName, "-([0-9]*)");
if (match.Length > 0 && int.TryParse(match.Groups[1].Value, out int number) && number < 60) if (match.Length > 0 && int.TryParse(match.Groups[1].Value, out int number) && number < 60)
return base.GetTexture(componentName.Replace($"-{number}", $"-{number % 2}"), wrapModeS, wrapModeT); return base.GetTexture(componentName.Replace($"-{number}", $"-{number % 2}"), maxSize, wrapModeS, wrapModeT);
} }
return null; return null;