From 57dc76b345c97b8ee76abdf8de1c596d757ec9ed Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Tue, 19 Sep 2023 03:17:07 +0300 Subject: [PATCH] Revert "Update `GetTexture` signature rather than creating new overload" This reverts commit 96f12cfbaac4cfc0d8782de0d2890aa8b63e3fdb. --- .../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, 73 insertions(+), 84 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyBananaPiece.cs b/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyBananaPiece.cs index d471a7ee32..9f99e3a586 100644 --- a/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyBananaPiece.cs +++ b/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyBananaPiece.cs @@ -2,6 +2,7 @@ // 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 @@ -14,8 +15,8 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy { base.LoadComplete(); - Texture? texture = Skin.GetTexture("fruit-bananas", banana_max_size); - Texture? overlayTexture = Skin.GetTexture("fruit-bananas-overlay", banana_max_size); + Texture? texture = Skin.GetTextureWithMaxSize("fruit-bananas", banana_max_size); + Texture? overlayTexture = Skin.GetTextureWithMaxSize("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 f1b1b45288..63be1bcf91 100644 --- a/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyDropletPiece.cs +++ b/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyDropletPiece.cs @@ -2,6 +2,7 @@ // 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 @@ -19,8 +20,8 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy { base.LoadComplete(); - Texture? texture = Skin.GetTexture("fruit-drop", droplet_max_size); - Texture? overlayTexture = Skin.GetTexture("fruit-drop-overlay", droplet_max_size); + Texture? texture = Skin.GetTextureWithMaxSize("fruit-drop", droplet_max_size); + Texture? overlayTexture = Skin.GetTextureWithMaxSize("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 3c853e5d3d..e4d25e036b 100644 --- a/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyFruitPiece.cs +++ b/osu.Game.Rulesets.Catch/Skinning/Legacy/LegacyFruitPiece.cs @@ -2,6 +2,7 @@ // 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 @@ -25,19 +26,19 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy switch (visualRepresentation) { case FruitVisualRepresentation.Pear: - SetTexture(Skin.GetTexture("fruit-pear", fruit_max_size), Skin.GetTexture("fruit-pear-overlay", fruit_max_size)); + SetTexture(Skin.GetTextureWithMaxSize("fruit-pear", fruit_max_size), Skin.GetTextureWithMaxSize("fruit-pear-overlay", fruit_max_size)); break; case FruitVisualRepresentation.Grape: - SetTexture(Skin.GetTexture("fruit-grapes", fruit_max_size), Skin.GetTexture("fruit-grapes-overlay", fruit_max_size)); + SetTexture(Skin.GetTextureWithMaxSize("fruit-grapes", fruit_max_size), Skin.GetTextureWithMaxSize("fruit-grapes-overlay", fruit_max_size)); break; case FruitVisualRepresentation.Pineapple: - SetTexture(Skin.GetTexture("fruit-apple", fruit_max_size), Skin.GetTexture("fruit-apple-overlay", fruit_max_size)); + SetTexture(Skin.GetTextureWithMaxSize("fruit-apple", fruit_max_size), Skin.GetTextureWithMaxSize("fruit-apple-overlay", fruit_max_size)); break; case FruitVisualRepresentation.Raspberry: - SetTexture(Skin.GetTexture("fruit-orange", fruit_max_size), Skin.GetTexture("fruit-orange-overlay", fruit_max_size)); + SetTexture(Skin.GetTextureWithMaxSize("fruit-orange", fruit_max_size), Skin.GetTextureWithMaxSize("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 dbeae2a76e..baaa24959f 100644 --- a/osu.Game.Rulesets.Osu.Tests/LegacyMainCirclePieceTest.cs +++ b/osu.Game.Rulesets.Osu.Tests/LegacyMainCirclePieceTest.cs @@ -14,7 +14,6 @@ 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 { @@ -78,9 +77,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(), It.IsAny(), It.IsAny(), It.IsAny())).CallBase(); + skin.Setup(s => s.GetTexture(It.IsAny())).CallBase(); - skin.Setup(s => s.GetTexture(It.IsIn(textureFilenames), It.IsAny(), It.IsAny(), It.IsAny())) + skin.Setup(s => s.GetTexture(It.IsIn(textureFilenames), 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 22111d4412..9582ee491b 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, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) + public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) { switch (componentName) { diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneGameplayCursor.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneGameplayCursor.cs index 29dffd029e..c84a6ab70f 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, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => null; + public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => 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 da959b6be0..09b906cb10 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs @@ -25,7 +25,6 @@ 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 { @@ -164,7 +163,7 @@ namespace osu.Game.Rulesets.Osu.Tests }; } - public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => null; + public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => 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 cf91ac4596..45a18152c2 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.GetTexture(circleName, circle_piece_size) }) + CircleSprite = new LegacyKiaiFlashingDrawable(() => new Sprite { Texture = skin.GetTextureWithMaxSize(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 bf8f5fd1e8..f38c2c9416 100644 --- a/osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs +++ b/osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs @@ -20,7 +20,6 @@ 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 @@ -141,7 +140,7 @@ namespace osu.Game.Tests.Gameplay public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => throw new NotImplementedException(); - public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => throw new NotImplementedException(); + public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => 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 34ea459988..197e9404ff 100644 --- a/osu.Game.Tests/NonVisual/Skinning/LegacySkinAnimationTest.cs +++ b/osu.Game.Tests/NonVisual/Skinning/LegacySkinAnimationTest.cs @@ -18,7 +18,6 @@ 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 { @@ -69,7 +68,7 @@ namespace osu.Game.Tests.NonVisual.Skinning this.renderer = renderer; } - public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) + public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) { 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 705fd19d93..11f3fe660d 100644 --- a/osu.Game.Tests/Rulesets/TestSceneRulesetSkinProvidingContainer.cs +++ b/osu.Game.Tests/Rulesets/TestSceneRulesetSkinProvidingContainer.cs @@ -17,7 +17,6 @@ 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 { @@ -81,7 +80,7 @@ namespace osu.Game.Tests.Rulesets public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => skin.GetDrawableComponent(lookup); - public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => skin.GetTexture(componentName); + public Texture GetTexture(string componentName, 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 79ce4de720..82d204f134 100644 --- a/osu.Game.Tests/Skins/SkinDeserialisationTest.cs +++ b/osu.Game.Tests/Skins/SkinDeserialisationTest.cs @@ -16,7 +16,6 @@ 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 { @@ -134,7 +133,7 @@ namespace osu.Game.Tests.Skins { } - public override Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => throw new NotImplementedException(); + public override Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => 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 5144f57f8d..0bbf4406fb 100644 --- a/osu.Game.Tests/Skins/TestSceneBeatmapSkinLookupDisables.cs +++ b/osu.Game.Tests/Skins/TestSceneBeatmapSkinLookupDisables.cs @@ -18,7 +18,6 @@ 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 { @@ -101,8 +100,7 @@ namespace osu.Game.Tests.Skins public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => skin.GetDrawableComponent(lookup); - public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => - skin.GetTexture(componentName, maxSize, wrapModeS, wrapModeT); + public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => skin.GetTexture(componentName, 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 a433b67bfb..816834989c 100644 --- a/osu.Game.Tests/Skins/TestSceneSkinConfigurationLookup.cs +++ b/osu.Game.Tests/Skins/TestSceneSkinConfigurationLookup.cs @@ -21,7 +21,6 @@ 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 @@ -224,8 +223,7 @@ namespace osu.Game.Tests.Skins public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => skin.GetDrawableComponent(lookup); - public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => - skin.GetTexture(componentName, maxSize, wrapModeS, wrapModeT); + public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => skin.GetTexture(componentName, 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 4acd127a58..df314b56a9 100644 --- a/osu.Game.Tests/Skins/TestSceneSkinProvidingContainer.cs +++ b/osu.Game.Tests/Skins/TestSceneSkinProvidingContainer.cs @@ -16,7 +16,6 @@ using osu.Framework.Testing; using osu.Game.Audio; using osu.Game.Skinning; using osu.Game.Tests.Visual; -using osuTK; namespace osu.Game.Tests.Skins { @@ -90,7 +89,7 @@ namespace osu.Game.Tests.Skins public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => throw new System.NotImplementedException(); - public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) + public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) { if (componentName == TEXTURE_NAME) return renderer.WhitePixel; diff --git a/osu.Game.Tests/Skins/TestSceneSkinResources.cs b/osu.Game.Tests/Skins/TestSceneSkinResources.cs index 636f1071dd..aaec319b57 100644 --- a/osu.Game.Tests/Skins/TestSceneSkinResources.cs +++ b/osu.Game.Tests/Skins/TestSceneSkinResources.cs @@ -22,7 +22,6 @@ 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 { @@ -101,7 +100,7 @@ namespace osu.Game.Tests.Skins { } - public override Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => throw new NotImplementedException(); + public override Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => 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 326e233e3f..c02cec8c75 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, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => throw new NotImplementedException(); + public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => 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, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => throw new NotImplementedException(); + public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => 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, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => throw new NotImplementedException(); + public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => 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 0071c7e2c0..3f78dbfd96 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableSound.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableSound.cs @@ -15,7 +15,6 @@ 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 { @@ -164,10 +163,7 @@ namespace osu.Game.Tests.Visual.Gameplay IBindable ISamplePlaybackDisabler.SamplePlaybackDisabled => SamplePlaybackDisabled; public Drawable? GetDrawableComponent(ISkinComponentLookup lookup) => source.GetDrawableComponent(lookup); - - public Texture? GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => - source.GetTexture(componentName, maxSize, wrapModeS, wrapModeT); - + public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => source.GetTexture(componentName, 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 d04bb72bd9..80239504d8 100644 --- a/osu.Game/Screens/Edit/EditorBeatmapSkin.cs +++ b/osu.Game/Screens/Edit/EditorBeatmapSkin.cs @@ -11,7 +11,6 @@ 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 @@ -55,10 +54,7 @@ namespace osu.Game.Screens.Edit #region Delegated ISkin implementation public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => Skin.GetDrawableComponent(lookup); - - public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => - Skin.GetTexture(componentName, maxSize, wrapModeS, wrapModeT); - + public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => Skin.GetTexture(componentName, 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 3d14df70ce..61b0dc5aa1 100644 --- a/osu.Game/Skinning/ArgonSkin.cs +++ b/osu.Game/Skinning/ArgonSkin.cs @@ -67,8 +67,7 @@ namespace osu.Game.Skinning }; } - public override Texture? GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => - Textures?.Get(componentName, wrapModeS, wrapModeT).WithMaximumSize(maxSize); + public override Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => Textures?.Get(componentName, wrapModeS, wrapModeT); public override ISample? GetSample(ISampleInfo sampleInfo) { diff --git a/osu.Game/Skinning/ISkin.cs b/osu.Game/Skinning/ISkin.cs index 5cc677ad1c..fa04dda202 100644 --- a/osu.Game/Skinning/ISkin.cs +++ b/osu.Game/Skinning/ISkin.cs @@ -6,7 +6,6 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Textures; using osu.Game.Audio; -using osuTK; namespace osu.Game.Skinning { @@ -26,11 +25,17 @@ namespace osu.Game.Skinning /// Retrieve a . /// /// The requested texture. - /// The maximum dimensions that the texture should be. + /// A matching texture, or null if unavailable. + Texture? GetTexture(string componentName) => GetTexture(componentName, default, default); + + /// + /// Retrieve a . + /// + /// The requested texture. /// 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, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default); + Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT); /// /// Retrieve a . diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 1b0b1be585..cf51fa8f74 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, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) + public override Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) { switch (componentName) { @@ -497,8 +497,7 @@ namespace osu.Game.Skinning continue; texture.ScaleAdjust = ratio; - - return texture.WithMaximumSize(maxSize); + return texture; } return null; diff --git a/osu.Game/Skinning/LegacySkinExtensions.cs b/osu.Game/Skinning/LegacySkinExtensions.cs index bd38eda259..ad3b10edd3 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, maxSize, wrapModeS, wrapModeT) != null; + return s.GetTexture(componentName, wrapModeS, wrapModeT) != null; }) ?? source; if (animatable) @@ -79,15 +79,21 @@ namespace osu.Game.Skinning } // if an animation was not allowed or not found, fall back to a sprite retrieval. - var singleTexture = retrievalSource.GetTexture(componentName, maxSize, wrapModeS, wrapModeT); + var singleTexture = maxSize != null + ? retrievalSource.GetTextureWithMaxSize(componentName, maxSize.Value, wrapModeS, wrapModeT) + : retrievalSource.GetTexture(componentName, 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 = skin.GetTexture(getFrameName(i), maxSize, wrapModeS, wrapModeT); + var texture = maxSize != null + ? skin.GetTextureWithMaxSize(getFrameName(i), maxSize.Value, wrapModeS, wrapModeT) + : skin.GetTexture(getFrameName(i), wrapModeS, wrapModeT); if (texture == null) break; @@ -99,16 +105,17 @@ namespace osu.Game.Skinning string getFrameName(int frameIndex) => $"{componentName}{animationSeparator}{frameIndex}"; } - public static Texture? WithMaximumSize(this Texture? texture, Vector2? maxSize) + public static Texture? GetTextureWithMaxSize(this ISkin source, string componentName, Vector2 maxSize, WrapMode wrapModeS = WrapMode.None, WrapMode wrapModeT = WrapMode.None) { - if (texture == null || maxSize == null) + var texture = source.GetTexture(componentName, wrapModeS, wrapModeT); + if (texture == null) return texture; - if (texture.DisplayWidth <= maxSize.Value.X && texture.DisplayHeight <= maxSize.Value.Y) + if (texture.DisplayWidth <= maxSize.X && texture.DisplayHeight <= maxSize.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.Value.X, texture.DisplayHeight / maxSize.Value.Y); + texture.ScaleAdjust *= Math.Max(texture.DisplayWidth / maxSize.X, texture.DisplayHeight / maxSize.Y); return texture; } diff --git a/osu.Game/Skinning/ResourceStoreBackedSkin.cs b/osu.Game/Skinning/ResourceStoreBackedSkin.cs index 35165c2e6f..f5c6192ba5 100644 --- a/osu.Game/Skinning/ResourceStoreBackedSkin.cs +++ b/osu.Game/Skinning/ResourceStoreBackedSkin.cs @@ -10,7 +10,6 @@ using osu.Framework.Graphics.Textures; using osu.Framework.IO.Stores; using osu.Framework.Platform; using osu.Game.Audio; -using osuTK; namespace osu.Game.Skinning { @@ -30,8 +29,7 @@ namespace osu.Game.Skinning public Drawable? GetDrawableComponent(ISkinComponentLookup lookup) => null; - public Texture? GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => - textures.Get(componentName, wrapModeS, wrapModeT).WithMaximumSize(maxSize); + public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => textures.Get(componentName, wrapModeS, wrapModeT); public ISample? GetSample(ISampleInfo sampleInfo) { diff --git a/osu.Game/Skinning/Skin.cs b/osu.Game/Skinning/Skin.cs index 0e96feaccc..a6250d7488 100644 --- a/osu.Game/Skinning/Skin.cs +++ b/osu.Game/Skinning/Skin.cs @@ -18,7 +18,6 @@ using osu.Framework.Logging; using osu.Game.Audio; using osu.Game.Database; using osu.Game.IO; -using osuTK; namespace osu.Game.Skinning { @@ -45,7 +44,9 @@ namespace osu.Game.Skinning public abstract ISample? GetSample(ISampleInfo sampleInfo); - public abstract Texture? GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default); + public Texture? GetTexture(string componentName) => GetTexture(componentName, default, default); + + public abstract Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT); public abstract IBindable? GetConfig(TLookup lookup) where TLookup : notnull diff --git a/osu.Game/Skinning/SkinManager.cs b/osu.Game/Skinning/SkinManager.cs index f0819211c0..51605c6045 100644 --- a/osu.Game/Skinning/SkinManager.cs +++ b/osu.Game/Skinning/SkinManager.cs @@ -25,7 +25,6 @@ using osu.Game.Database; using osu.Game.IO; using osu.Game.Overlays.Notifications; using osu.Game.Utils; -using osuTK; namespace osu.Game.Skinning { @@ -224,8 +223,7 @@ namespace osu.Game.Skinning public Drawable GetDrawableComponent(ISkinComponentLookup lookup) => lookupWithFallback(s => s.GetDrawableComponent(lookup)); - public Texture GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => - lookupWithFallback(s => s.GetTexture(componentName, maxSize, wrapModeS, wrapModeT)); + public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => lookupWithFallback(s => s.GetTexture(componentName, 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 342d6d8009..2612e0b47c 100644 --- a/osu.Game/Skinning/SkinProvidingContainer.cs +++ b/osu.Game/Skinning/SkinProvidingContainer.cs @@ -11,7 +11,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Textures; using osu.Game.Audio; -using osuTK; namespace osu.Game.Skinning { @@ -128,19 +127,19 @@ namespace osu.Game.Skinning return ParentSource?.GetDrawableComponent(lookup); } - public Texture? GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) + public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) { foreach (var (_, lookupWrapper) in skinSources) { Texture? sourceTexture; - if ((sourceTexture = lookupWrapper.GetTexture(componentName, maxSize, wrapModeS, wrapModeT)) != null) + if ((sourceTexture = lookupWrapper.GetTexture(componentName, wrapModeS, wrapModeT)) != null) return sourceTexture; } if (!AllowFallingBackToParent) return null; - return ParentSource?.GetTexture(componentName, maxSize, wrapModeS, wrapModeT); + return ParentSource?.GetTexture(componentName, wrapModeS, wrapModeT); } public ISample? GetSample(ISampleInfo sampleInfo) @@ -252,10 +251,10 @@ namespace osu.Game.Skinning return null; } - public Texture? GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) + public Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) { if (provider.AllowTextureLookup(componentName)) - return skin.GetTexture(componentName, maxSize, wrapModeS, wrapModeT); + return skin.GetTexture(componentName, wrapModeS, wrapModeT); return null; } diff --git a/osu.Game/Skinning/SkinTransformer.cs b/osu.Game/Skinning/SkinTransformer.cs index cd7755b854..ed5b04da1e 100644 --- a/osu.Game/Skinning/SkinTransformer.cs +++ b/osu.Game/Skinning/SkinTransformer.cs @@ -7,7 +7,6 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Textures; using osu.Game.Audio; -using osuTK; namespace osu.Game.Skinning { @@ -29,7 +28,9 @@ namespace osu.Game.Skinning public virtual Drawable? GetDrawableComponent(ISkinComponentLookup lookup) => Skin.GetDrawableComponent(lookup); - 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) => GetTexture(componentName, default, default); + + public virtual Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => Skin.GetTexture(componentName, 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 d1d094b301..0957f60579 100644 --- a/osu.Game/Skinning/TrianglesSkin.cs +++ b/osu.Game/Skinning/TrianglesSkin.cs @@ -44,8 +44,7 @@ namespace osu.Game.Skinning this.resources = resources; } - public override Texture? GetTexture(string componentName, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) => - Textures?.Get(componentName, wrapModeS, wrapModeT).WithMaximumSize(maxSize); + public override Texture? GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => Textures?.Get(componentName, wrapModeS, wrapModeT); public override ISample? GetSample(ISampleInfo sampleInfo) { diff --git a/osu.Game/Tests/Visual/SkinnableTestScene.cs b/osu.Game/Tests/Visual/SkinnableTestScene.cs index 6c286f37c7..aab1b72990 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, Vector2? maxSize = null, WrapMode wrapModeS = default, WrapMode wrapModeT = default) + public override Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) { - var lookup = base.GetTexture(componentName, maxSize, wrapModeS, wrapModeT); + var lookup = base.GetTexture(componentName, 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}"), maxSize, wrapModeS, wrapModeT); + return base.GetTexture(componentName.Replace($"-{number}", $"-{number % 2}"), wrapModeS, wrapModeT); } return null;