Merge pull request #22464 from bdach/conflicting-filenames-in-skin-alt

Fix skin texture store attempting to read image data from samples
This commit is contained in:
Dean Herbert
2023-01-31 17:27:22 +09:00
committed by GitHub
11 changed files with 62 additions and 32 deletions

View File

@ -10,7 +10,7 @@
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk> <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ppy.osu.Framework.Android" Version="2023.120.0" /> <PackageReference Include="ppy.osu.Framework.Android" Version="2023.131.0" />
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<!-- Fody does not handle Android build well, and warns when unchanged. <!-- Fody does not handle Android build well, and warns when unchanged.

View File

@ -150,6 +150,8 @@ namespace osu.Game.Tests.Rulesets
public IBindable<double> AggregateTempo => throw new NotImplementedException(); public IBindable<double> AggregateTempo => throw new NotImplementedException();
public int PlaybackConcurrency { get; set; } public int PlaybackConcurrency { get; set; }
public void AddExtension(string extension) => throw new NotImplementedException();
} }
private class TestShaderManager : ShaderManager private class TestShaderManager : ShaderManager

View File

@ -1,12 +1,11 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio.Track; using osu.Framework.Audio.Track;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
@ -20,29 +19,36 @@ namespace osu.Game.Tests.Skins
public partial class TestSceneBeatmapSkinResources : OsuTestScene public partial class TestSceneBeatmapSkinResources : OsuTestScene
{ {
[Resolved] [Resolved]
private BeatmapManager beatmaps { get; set; } private BeatmapManager beatmaps { get; set; } = null!;
private IWorkingBeatmap beatmap; [Test]
public void TestRetrieveOggAudio()
[BackgroundDependencyLoader]
private void load()
{ {
var imported = beatmaps.Import(new ImportTask(TestResources.OpenResource("Archives/ogg-beatmap.osz"), "ogg-beatmap.osz")).GetResultSafely(); IWorkingBeatmap beatmap = null!;
imported?.PerformRead(s => AddStep("import beatmap", () => beatmap = importBeatmapFromArchives(@"ogg-beatmap.osz"));
AddAssert("sample is non-null", () => beatmap.Skin.GetSample(new SampleInfo(@"sample")) != null);
AddAssert("track is non-null", () =>
{ {
beatmap = beatmaps.GetWorkingBeatmap(s.Beatmaps[0]); using (var track = beatmap.LoadTrack())
return track is not TrackVirtual;
}); });
} }
[Test] [Test]
public void TestRetrieveOggSample() => AddAssert("sample is non-null", () => beatmap.Skin.GetSample(new SampleInfo("sample")) != null); public void TestRetrievalWithConflictingFilenames()
[Test]
public void TestRetrieveOggTrack() => AddAssert("track is non-null", () =>
{ {
using (var track = beatmap.LoadTrack()) IWorkingBeatmap beatmap = null!;
return track is not TrackVirtual;
}); AddStep("import beatmap", () => beatmap = importBeatmapFromArchives(@"conflicting-filenames-beatmap.osz"));
AddAssert("texture is non-null", () => beatmap.Skin.GetTexture(@"spinner-osu") != null);
AddAssert("sample is non-null", () => beatmap.Skin.GetSample(new SampleInfo(@"spinner-osu")) != null);
}
private IWorkingBeatmap importBeatmapFromArchives(string filename)
{
var imported = beatmaps.Import(new ImportTask(TestResources.OpenResource($@"Archives/{filename}"), filename)).GetResultSafely();
return imported.AsNonNull().PerformRead(s => beatmaps.GetWorkingBeatmap(s.Beatmaps[0]));
}
} }
} }

View File

@ -31,17 +31,24 @@ namespace osu.Game.Tests.Skins
[Resolved] [Resolved]
private SkinManager skins { get; set; } = null!; private SkinManager skins { get; set; } = null!;
private ISkin skin = null!; [Test]
public void TestRetrieveOggSample()
[BackgroundDependencyLoader]
private void load()
{ {
var imported = skins.Import(new ImportTask(TestResources.OpenResource("Archives/ogg-skin.osk"), "ogg-skin.osk")).GetResultSafely(); ISkin skin = null!;
skin = imported.PerformRead(skinInfo => skins.GetSkin(skinInfo));
AddStep("import skin", () => skin = importSkinFromArchives(@"ogg-skin.osk"));
AddAssert("sample is non-null", () => skin.GetSample(new SampleInfo(@"sample")) != null);
} }
[Test] [Test]
public void TestRetrieveOggSample() => AddAssert("sample is non-null", () => skin.GetSample(new SampleInfo("sample")) != null); public void TestRetrievalWithConflictingFilenames()
{
ISkin skin = null!;
AddStep("import skin", () => skin = importSkinFromArchives(@"conflicting-filenames-skin.osk"));
AddAssert("texture is non-null", () => skin.GetTexture(@"spinner-osu") != null);
AddAssert("sample is non-null", () => skin.GetSample(new SampleInfo(@"spinner-osu")) != null);
}
[Test] [Test]
public void TestSampleRetrievalOrder() public void TestSampleRetrievalOrder()
@ -78,6 +85,12 @@ namespace osu.Game.Tests.Skins
}); });
} }
private Skin importSkinFromArchives(string filename)
{
var imported = skins.Import(new ImportTask(TestResources.OpenResource($@"Archives/{filename}"), filename)).GetResultSafely();
return imported.PerformRead(skinInfo => skins.GetSkin(skinInfo));
}
private class TestSkin : Skin private class TestSkin : Skin
{ {
public const string SAMPLE_NAME = "test-sample"; public const string SAMPLE_NAME = "test-sample";

View File

@ -42,8 +42,12 @@ namespace osu.Game.Graphics.Containers.Markdown
protected override void AddFootnoteBacklink(FootnoteLink footnoteBacklink) => AddDrawable(new OsuMarkdownFootnoteBacklink(footnoteBacklink)); protected override void AddFootnoteBacklink(FootnoteLink footnoteBacklink) => AddDrawable(new OsuMarkdownFootnoteBacklink(footnoteBacklink));
protected override SpriteText CreateEmphasisedSpriteText(bool bold, bool italic) protected override void ApplyEmphasisedCreationParameters(SpriteText spriteText, bool bold, bool italic)
=> CreateSpriteText().With(t => t.Font = t.Font.With(weight: bold ? FontWeight.Bold : FontWeight.Regular, italics: italic)); {
base.ApplyEmphasisedCreationParameters(spriteText, bold, italic);
spriteText.Font = spriteText.Font.With(weight: bold ? FontWeight.Bold : FontWeight.Regular, italics: italic);
}
protected override void AddCustomComponent(CustomContainerInline inline) protected override void AddCustomComponent(CustomContainerInline inline)
{ {

View File

@ -157,6 +157,8 @@ namespace osu.Game.Rulesets.UI
set => throw new NotSupportedException(); set => throw new NotSupportedException();
} }
public void AddExtension(string extension) => throw new NotSupportedException();
public void Dispose() public void Dispose()
{ {
if (primary.IsNotNull()) primary.Dispose(); if (primary.IsNotNull()) primary.Dispose();

View File

@ -69,12 +69,15 @@ namespace osu.Game.Skinning
storage ??= realmBackedStorage = new RealmBackedResourceStore<SkinInfo>(SkinInfo, resources.Files, resources.RealmAccess); storage ??= realmBackedStorage = new RealmBackedResourceStore<SkinInfo>(SkinInfo, resources.Files, resources.RealmAccess);
var samples = resources.AudioManager?.GetSampleStore(storage); var samples = resources.AudioManager?.GetSampleStore(storage);
if (samples != null) if (samples != null)
{
samples.PlaybackConcurrency = OsuGameBase.SAMPLE_CONCURRENCY; samples.PlaybackConcurrency = OsuGameBase.SAMPLE_CONCURRENCY;
// osu-stable performs audio lookups in order of wav -> mp3 -> ogg. // osu-stable performs audio lookups in order of wav -> mp3 -> ogg.
// The GetSampleStore() call above internally adds wav and mp3, so ogg is added at the end to ensure expected ordering. // The GetSampleStore() call above internally adds wav and mp3, so ogg is added at the end to ensure expected ordering.
(storage as ResourceStore<byte[]>)?.AddExtension("ogg"); samples.AddExtension(@"ogg");
}
Samples = samples; Samples = samples;
Textures = new TextureStore(resources.Renderer, new MaxDimensionLimitedTextureLoaderStore(resources.CreateTextureLoaderStore(storage))); Textures = new TextureStore(resources.Renderer, new MaxDimensionLimitedTextureLoaderStore(resources.CreateTextureLoaderStore(storage)));

View File

@ -35,7 +35,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Realm" Version="10.18.0" /> <PackageReference Include="Realm" Version="10.18.0" />
<PackageReference Include="ppy.osu.Framework" Version="2023.120.0" /> <PackageReference Include="ppy.osu.Framework" Version="2023.131.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.1221.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2022.1221.0" />
<PackageReference Include="Sentry" Version="3.23.1" /> <PackageReference Include="Sentry" Version="3.23.1" />
<PackageReference Include="SharpCompress" Version="0.32.2" /> <PackageReference Include="SharpCompress" Version="0.32.2" />

View File

@ -16,6 +16,6 @@
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier> <RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ppy.osu.Framework.iOS" Version="2023.120.0" /> <PackageReference Include="ppy.osu.Framework.iOS" Version="2023.131.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>