From 96f12cfbaac4cfc0d8782de0d2890aa8b63e3fdb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 5 Sep 2023 18:01:09 +0900 Subject: [PATCH] Update `GetTexture` signature rather than creating new overload --- .../Skinning/Legacy/LegacyBananaPiece.cs | 5 ++-- .../Skinning/Legacy/LegacyDropletPiece.cs | 5 ++-- .../Skinning/Legacy/LegacyFruitPiece.cs | 9 ++++---- .../LegacyMainCirclePieceTest.cs | 5 ++-- .../TestSceneCursorTrail.cs | 2 +- .../TestSceneGameplayCursor.cs | 2 +- .../TestSceneSkinFallbacks.cs | 3 ++- .../Skinning/Legacy/LegacyMainCirclePiece.cs | 2 +- .../TestSceneHitObjectAccentColour.cs | 3 ++- .../Skinning/LegacySkinAnimationTest.cs | 3 ++- .../TestSceneRulesetSkinProvidingContainer.cs | 3 ++- .../Skins/SkinDeserialisationTest.cs | 3 ++- .../TestSceneBeatmapSkinLookupDisables.cs | 4 +++- .../Skins/TestSceneSkinConfigurationLookup.cs | 4 +++- .../Skins/TestSceneSkinProvidingContainer.cs | 3 ++- .../Skins/TestSceneSkinResources.cs | 3 ++- .../Gameplay/TestSceneSkinnableDrawable.cs | 6 ++--- .../Gameplay/TestSceneSkinnableSound.cs | 6 ++++- osu.Game/Screens/Edit/EditorBeatmapSkin.cs | 6 ++++- osu.Game/Skinning/ArgonSkin.cs | 3 ++- osu.Game/Skinning/ISkin.cs | 11 +++------ osu.Game/Skinning/LegacySkin.cs | 5 ++-- osu.Game/Skinning/LegacySkinExtensions.cs | 23 +++++++------------ osu.Game/Skinning/ResourceStoreBackedSkin.cs | 4 +++- osu.Game/Skinning/Skin.cs | 5 ++-- osu.Game/Skinning/SkinManager.cs | 4 +++- osu.Game/Skinning/SkinProvidingContainer.cs | 11 +++++---- osu.Game/Skinning/SkinTransformer.cs | 5 ++-- osu.Game/Skinning/TrianglesSkin.cs | 3 ++- osu.Game/Tests/Visual/SkinnableTestScene.cs | 6 ++--- 30 files changed, 84 insertions(+), 73 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyBananaPiece.cs b/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyBananaPiece.cs index 9f99e3a586..d471a7ee32 100644 --- a/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyBananaPiece.cs +++ b/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyBananaPiece.cs @@ -2,7 +2,6 @@ // 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 @@ -15,8 +14,8 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy { base.LoadComplete(); - Texture? texture = Skin.GetTextureWithMaxSize("fruit-bananas", banana_max_size); - Texture? overlayTexture = Skin.GetTextureWithMaxSize("fruit-bananas-overlay", banana_max_size); + Texture? texture = Skin.GetTexture("fruit-bananas", banana_max_size); + Texture? overlayTexture = Skin.GetTexture("fruit-bananas-overlay", banana_max_size); SetTexture(texture, overlayTexture); } diff --git a/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyDropletPiece.cs b/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyDropletPiece.cs index 63be1bcf91..f1b1b45288 100644 --- a/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyDropletPiece.cs +++ b/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyDropletPiece.cs @@ -2,7 +2,6 @@ // 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 @@ -20,8 +19,8 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy { base.LoadComplete(); - Texture? texture = Skin.GetTextureWithMaxSize("fruit-drop", droplet_max_size); - Texture? overlayTexture = Skin.GetTextureWithMaxSize("fruit-drop-overlay", droplet_max_size); + Texture? texture = Skin.GetTexture("fruit-drop", droplet_max_size); + Texture? overlayTexture = Skin.GetTexture("fruit-drop-overlay", droplet_max_size); SetTexture(texture, overlayTexture); } diff --git a/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyFruitPiece.cs b/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyFruitPiece.cs index e4d25e036b..3c853e5d3d 100644 --- a/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyFruitPiece.cs +++ b/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyFruitPiece.cs @@ -2,7 +2,6 @@ // 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 @@ -26,19 +25,19 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy switch (visualRepresentation) { 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; 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; 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; 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; } } diff --git a/osu.Game.Rulesets.Osu.Tests/LegacyMainCirclePieceTest.cs b/osu.Game.Rulesets.Osu.Tests/LegacyMainCirclePieceTest.cs index baaa24959f..dbeae2a76e 100644 --- a/osu.Game.Rulesets.Osu.Tests/LegacyMainCirclePieceTest.cs +++ b/osu.Game.Rulesets.Osu.Tests/LegacyMainCirclePieceTest.cs @@ -14,6 +14,7 @@ using osu.Framework.Testing; using osu.Game.Rulesets.Osu.Skinning.Legacy; using osu.Game.Skinning; using osu.Game.Tests.Visual; +using osuTK; 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, // but moq doesn't handle that well, therefore explicitly requiring to use `CallBase`: // https://github.com/moq/moq4/issues/972 - skin.Setup(s => s.GetTexture(It.IsAny())).CallBase(); + skin.Setup(s => s.GetTexture(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())).CallBase(); - skin.Setup(s => s.GetTexture(It.IsIn(textureFilenames), It.IsAny(), It.IsAny())) + skin.Setup(s => s.GetTexture(It.IsIn(textureFilenames), It.IsAny(), It.IsAny(), It.IsAny())) .Returns((string componentName, WrapMode _, WrapMode _) => { var tex = renderer.CreateTexture(1, 1); diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneCursorTrail.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneCursorTrail.cs index 9582ee491b..22111d4412 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneCursorTrail.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneCursorTrail.cs @@ -98,7 +98,7 @@ namespace osu.Game.Rulesets.Osu.Tests 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) { diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneGameplayCursor.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneGameplayCursor.cs index c84a6ab70f..29dffd029e 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneGameplayCursor.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneGameplayCursor.cs @@ -130,7 +130,7 @@ namespace osu.Game.Rulesets.Osu.Tests private class TopLeftCursorSkin : ISkin { 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 IBindable GetConfig(TLookup lookup) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs index 09b906cb10..da959b6be0 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs @@ -25,6 +25,7 @@ using osu.Game.Rulesets.Osu.Skinning.Default; using osu.Game.Skinning; using osu.Game.Storyboards; using osu.Game.Tests.Visual; +using osuTK; 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; diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyMainCirclePiece.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyMainCirclePiece.cs index 45a18152c2..cf91ac4596 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyMainCirclePiece.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyMainCirclePiece.cs @@ -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. 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, Origin = Anchor.Centre, diff --git a/osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs b/osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs index f38c2c9416..bf8f5fd1e8 100644 --- a/osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs +++ b/osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs @@ -20,6 +20,7 @@ using osu.Game.Rulesets.Objects.Legacy; using osu.Game.Rulesets.Objects.Types; using osu.Game.Skinning; using osu.Game.Tests.Visual; +using osuTK; using osuTK.Graphics; namespace osu.Game.Tests.Gameplay @@ -140,7 +141,7 @@ namespace osu.Game.Tests.Gameplay 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(); diff --git a/osu.Game.Tests/NonVisual/Skinning/LegacySkinAnimationTest.cs b/osu.Game.Tests/NonVisual/Skinning/LegacySkinAnimationTest.cs index 197e9404ff..34ea459988 100644 --- a/osu.Game.Tests/NonVisual/Skinning/LegacySkinAnimationTest.cs +++ b/osu.Game.Tests/NonVisual/Skinning/LegacySkinAnimationTest.cs @@ -18,6 +18,7 @@ using osu.Framework.Timing; using osu.Game.Audio; using osu.Game.Skinning; using osu.Game.Tests.Visual; +using osuTK; namespace osu.Game.Tests.NonVisual.Skinning { @@ -68,7 +69,7 @@ namespace osu.Game.Tests.NonVisual.Skinning 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; } diff --git a/osu.Game.Tests/Rulesets/TestSceneRulesetSkinProvidingContainer.cs b/osu.Game.Tests/Rulesets/TestSceneRulesetSkinProvidingContainer.cs index 11f3fe660d..705fd19d93 100644 --- a/osu.Game.Tests/Rulesets/TestSceneRulesetSkinProvidingContainer.cs +++ b/osu.Game.Tests/Rulesets/TestSceneRulesetSkinProvidingContainer.cs @@ -17,6 +17,7 @@ using osu.Game.Rulesets; using osu.Game.Skinning; using osu.Game.Tests.Testing; using osu.Game.Tests.Visual; +using osuTK; namespace osu.Game.Tests.Rulesets { @@ -80,7 +81,7 @@ namespace osu.Game.Tests.Rulesets 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); diff --git a/osu.Game.Tests/Skins/SkinDeserialisationTest.cs b/osu.Game.Tests/Skins/SkinDeserialisationTest.cs index 82d204f134..79ce4de720 100644 --- a/osu.Game.Tests/Skins/SkinDeserialisationTest.cs +++ b/osu.Game.Tests/Skins/SkinDeserialisationTest.cs @@ -16,6 +16,7 @@ using osu.Game.Screens.Play.HUD; using osu.Game.Screens.Play.HUD.HitErrorMeters; using osu.Game.Skinning; using osu.Game.Tests.Resources; +using osuTK; 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 GetConfig(TLookup lookup) => throw new NotImplementedException(); diff --git a/osu.Game.Tests/Skins/TestSceneBeatmapSkinLookupDisables.cs b/osu.Game.Tests/Skins/TestSceneBeatmapSkinLookupDisables.cs index 0bbf4406fb..5144f57f8d 100644 --- a/osu.Game.Tests/Skins/TestSceneBeatmapSkinLookupDisables.cs +++ b/osu.Game.Tests/Skins/TestSceneBeatmapSkinLookupDisables.cs @@ -18,6 +18,7 @@ using osu.Game.Rulesets.Osu; using osu.Game.Skinning; using osu.Game.Tests.Beatmaps; using osu.Game.Tests.Visual; +using osuTK; namespace osu.Game.Tests.Skins { @@ -100,7 +101,8 @@ namespace osu.Game.Tests.Skins 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); diff --git a/osu.Game.Tests/Skins/TestSceneSkinConfigurationLookup.cs b/osu.Game.Tests/Skins/TestSceneSkinConfigurationLookup.cs index 816834989c..a433b67bfb 100644 --- a/osu.Game.Tests/Skins/TestSceneSkinConfigurationLookup.cs +++ b/osu.Game.Tests/Skins/TestSceneSkinConfigurationLookup.cs @@ -21,6 +21,7 @@ using osu.Game.Rulesets.Osu; using osu.Game.Skinning; using osu.Game.Tests.Beatmaps; using osu.Game.Tests.Visual; +using osuTK; using osuTK.Graphics; namespace osu.Game.Tests.Skins @@ -223,7 +224,8 @@ namespace osu.Game.Tests.Skins 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); diff --git a/osu.Game.Tests/Skins/TestSceneSkinProvidingContainer.cs b/osu.Game.Tests/Skins/TestSceneSkinProvidingContainer.cs index df314b56a9..4acd127a58 100644 --- a/osu.Game.Tests/Skins/TestSceneSkinProvidingContainer.cs +++ b/osu.Game.Tests/Skins/TestSceneSkinProvidingContainer.cs @@ -16,6 +16,7 @@ using osu.Framework.Testing; using osu.Game.Audio; using osu.Game.Skinning; using osu.Game.Tests.Visual; +using osuTK; namespace osu.Game.Tests.Skins { @@ -89,7 +90,7 @@ namespace osu.Game.Tests.Skins 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) return renderer.WhitePixel; diff --git a/osu.Game.Tests/Skins/TestSceneSkinResources.cs b/osu.Game.Tests/Skins/TestSceneSkinResources.cs index aaec319b57..636f1071dd 100644 --- a/osu.Game.Tests/Skins/TestSceneSkinResources.cs +++ b/osu.Game.Tests/Skins/TestSceneSkinResources.cs @@ -22,6 +22,7 @@ using osu.Game.IO; using osu.Game.Skinning; using osu.Game.Tests.Resources; using osu.Game.Tests.Visual; +using osuTK; 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 GetConfig(TLookup lookup) => throw new NotImplementedException(); diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableDrawable.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableDrawable.cs index c02cec8c75..326e233e3f 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableDrawable.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableDrawable.cs @@ -297,7 +297,7 @@ namespace osu.Game.Tests.Visual.Gameplay } : 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(); @@ -308,7 +308,7 @@ namespace osu.Game.Tests.Visual.Gameplay { 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(); @@ -320,7 +320,7 @@ namespace osu.Game.Tests.Visual.Gameplay { 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(); diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableSound.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableSound.cs index 3f78dbfd96..0071c7e2c0 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableSound.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableSound.cs @@ -15,6 +15,7 @@ using osu.Framework.Graphics.Textures; using osu.Framework.Testing; using osu.Game.Audio; using osu.Game.Skinning; +using osuTK; namespace osu.Game.Tests.Visual.Gameplay { @@ -163,7 +164,10 @@ namespace osu.Game.Tests.Visual.Gameplay IBindable ISamplePlaybackDisabler.SamplePlaybackDisabled => SamplePlaybackDisabled; 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 IBindable? GetConfig(TLookup lookup) diff --git a/osu.Game/Screens/Edit/EditorBeatmapSkin.cs b/osu.Game/Screens/Edit/EditorBeatmapSkin.cs index 80239504d8..d04bb72bd9 100644 --- a/osu.Game/Screens/Edit/EditorBeatmapSkin.cs +++ b/osu.Game/Screens/Edit/EditorBeatmapSkin.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Textures; using osu.Game.Audio; using osu.Game.Skinning; +using osuTK; using osuTK.Graphics; namespace osu.Game.Screens.Edit @@ -54,7 +55,10 @@ namespace osu.Game.Screens.Edit #region Delegated ISkin implementation 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 IBindable GetConfig(TLookup lookup) => Skin.GetConfig(lookup); diff --git a/osu.Game/Skinning/ArgonSkin.cs b/osu.Game/Skinning/ArgonSkin.cs index 61b0dc5aa1..3d14df70ce 100644 --- a/osu.Game/Skinning/ArgonSkin.cs +++ b/osu.Game/Skinning/ArgonSkin.cs @@ -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) { diff --git a/osu.Game/Skinning/ISkin.cs b/osu.Game/Skinning/ISkin.cs index fa04dda202..5cc677ad1c 100644 --- a/osu.Game/Skinning/ISkin.cs +++ b/osu.Game/Skinning/ISkin.cs @@ -6,6 +6,7 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Textures; using osu.Game.Audio; +using osuTK; namespace osu.Game.Skinning { @@ -25,17 +26,11 @@ namespace osu.Game.Skinning /// Retrieve a . /// /// The requested texture. - /// A matching texture, or null if unavailable. - Texture? GetTexture(string componentName) => GetTexture(componentName, default, default); - - /// - /// Retrieve a . - /// - /// The requested texture. + /// The maximum dimensions that the texture should be. /// The texture wrap mode in horizontal direction. /// The texture wrap mode in vertical direction. /// A matching texture, or null if unavailable. - Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT); + Texture? GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default); /// /// Retrieve a . diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index cf51fa8f74..1b0b1be585 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -466,7 +466,7 @@ namespace osu.Game.Skinning 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) { @@ -497,7 +497,8 @@ namespace osu.Game.Skinning continue; texture.ScaleAdjust = ratio; - return texture; + + return texture.WithMaximumSize(maxSize); } return null; diff --git a/osu.Game/Skinning/LegacySkinExtensions.cs b/osu.Game/Skinning/LegacySkinExtensions.cs index ad3b10edd3..bd38eda259 100644 --- a/osu.Game/Skinning/LegacySkinExtensions.cs +++ b/osu.Game/Skinning/LegacySkinExtensions.cs @@ -67,7 +67,7 @@ namespace osu.Game.Skinning if (animatable && s.GetTexture(getFrameName(0)) != null) return true; - return s.GetTexture(componentName, wrapModeS, wrapModeT) != null; + return s.GetTexture(componentName, maxSize, wrapModeS, wrapModeT) != null; }) ?? source; 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. - var singleTexture = maxSize != null - ? retrievalSource.GetTextureWithMaxSize(componentName, maxSize.Value, wrapModeS, wrapModeT) - : retrievalSource.GetTexture(componentName, wrapModeS, wrapModeT); + var singleTexture = retrievalSource.GetTexture(componentName, maxSize, wrapModeS, wrapModeT); - return singleTexture != null - ? new[] { singleTexture } - : Array.Empty(); + return singleTexture != null ? new[] { singleTexture } : Array.Empty(); IEnumerable getTextures(ISkin skin) { for (int i = 0; true; i++) { - var texture = maxSize != null - ? skin.GetTextureWithMaxSize(getFrameName(i), maxSize.Value, wrapModeS, wrapModeT) - : skin.GetTexture(getFrameName(i), wrapModeS, wrapModeT); + var texture = skin.GetTexture(getFrameName(i), maxSize, wrapModeS, wrapModeT); if (texture == null) break; @@ -105,17 +99,16 @@ namespace osu.Game.Skinning 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) + if (texture == null || maxSize == null) return texture; - if (texture.DisplayWidth <= maxSize.X && texture.DisplayHeight <= maxSize.Y) + if (texture.DisplayWidth <= maxSize.Value.X && texture.DisplayHeight <= maxSize.Value.Y) return texture; // 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; } diff --git a/osu.Game/Skinning/ResourceStoreBackedSkin.cs b/osu.Game/Skinning/ResourceStoreBackedSkin.cs index f5c6192ba5..35165c2e6f 100644 --- a/osu.Game/Skinning/ResourceStoreBackedSkin.cs +++ b/osu.Game/Skinning/ResourceStoreBackedSkin.cs @@ -10,6 +10,7 @@ using osu.Framework.Graphics.Textures; using osu.Framework.IO.Stores; using osu.Framework.Platform; using osu.Game.Audio; +using osuTK; namespace osu.Game.Skinning { @@ -29,7 +30,8 @@ namespace osu.Game.Skinning 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) { diff --git a/osu.Game/Skinning/Skin.cs b/osu.Game/Skinning/Skin.cs index a6250d7488..0e96feaccc 100644 --- a/osu.Game/Skinning/Skin.cs +++ b/osu.Game/Skinning/Skin.cs @@ -18,6 +18,7 @@ using osu.Framework.Logging; using osu.Game.Audio; using osu.Game.Database; using osu.Game.IO; +using osuTK; namespace osu.Game.Skinning { @@ -44,9 +45,7 @@ namespace osu.Game.Skinning public abstract ISample? GetSample(ISampleInfo sampleInfo); - public Texture? GetTexture(string componentName) => GetTexture(componentName, default, default); - - public abstract Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT); + public abstract Texture? GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default); public abstract IBindable? GetConfig(TLookup lookup) where TLookup : notnull diff --git a/osu.Game/Skinning/SkinManager.cs b/osu.Game/Skinning/SkinManager.cs index 51605c6045..f0819211c0 100644 --- a/osu.Game/Skinning/SkinManager.cs +++ b/osu.Game/Skinning/SkinManager.cs @@ -25,6 +25,7 @@ using osu.Game.Database; using osu.Game.IO; using osu.Game.Overlays.Notifications; using osu.Game.Utils; +using osuTK; namespace osu.Game.Skinning { @@ -223,7 +224,8 @@ namespace osu.Game.Skinning 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)); diff --git a/osu.Game/Skinning/SkinProvidingContainer.cs b/osu.Game/Skinning/SkinProvidingContainer.cs index 2612e0b47c..342d6d8009 100644 --- a/osu.Game/Skinning/SkinProvidingContainer.cs +++ b/osu.Game/Skinning/SkinProvidingContainer.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Textures; using osu.Game.Audio; +using osuTK; namespace osu.Game.Skinning { @@ -127,19 +128,19 @@ namespace osu.Game.Skinning 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) { Texture? sourceTexture; - if ((sourceTexture = lookupWrapper.GetTexture(componentName, wrapModeS, wrapModeT)) != null) + if ((sourceTexture = lookupWrapper.GetTexture(componentName, maxSize, wrapModeS, wrapModeT)) != null) return sourceTexture; } if (!AllowFallingBackToParent) return null; - return ParentSource?.GetTexture(componentName, wrapModeS, wrapModeT); + return ParentSource?.GetTexture(componentName, maxSize, wrapModeS, wrapModeT); } public ISample? GetSample(ISampleInfo sampleInfo) @@ -251,10 +252,10 @@ namespace osu.Game.Skinning 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)) - return skin.GetTexture(componentName, wrapModeS, wrapModeT); + return skin.GetTexture(componentName, maxSize, wrapModeS, wrapModeT); return null; } diff --git a/osu.Game/Skinning/SkinTransformer.cs b/osu.Game/Skinning/SkinTransformer.cs index ed5b04da1e..cd7755b854 100644 --- a/osu.Game/Skinning/SkinTransformer.cs +++ b/osu.Game/Skinning/SkinTransformer.cs @@ -7,6 +7,7 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Textures; using osu.Game.Audio; +using osuTK; namespace osu.Game.Skinning { @@ -28,9 +29,7 @@ namespace osu.Game.Skinning 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, WrapMode wrapModeS, WrapMode wrapModeT) => Skin.GetTexture(componentName, wrapModeS, wrapModeT); + public virtual Texture? GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => Skin.GetTexture(componentName, maxSize, wrapModeS, wrapModeT); public virtual ISample? GetSample(ISampleInfo sampleInfo) => Skin.GetSample(sampleInfo); diff --git a/osu.Game/Skinning/TrianglesSkin.cs b/osu.Game/Skinning/TrianglesSkin.cs index 0957f60579..d1d094b301 100644 --- a/osu.Game/Skinning/TrianglesSkin.cs +++ b/osu.Game/Skinning/TrianglesSkin.cs @@ -44,7 +44,8 @@ namespace osu.Game.Skinning 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) { diff --git a/osu.Game/Tests/Visual/SkinnableTestScene.cs b/osu.Game/Tests/Visual/SkinnableTestScene.cs index aab1b72990..6c286f37c7 100644 --- a/osu.Game/Tests/Visual/SkinnableTestScene.cs +++ b/osu.Game/Tests/Visual/SkinnableTestScene.cs @@ -207,9 +207,9 @@ namespace osu.Game.Tests.Visual 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) return lookup; @@ -220,7 +220,7 @@ namespace osu.Game.Tests.Visual var match = Regex.Match(componentName, "-([0-9]*)"); 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;