mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 23:12:55 +08:00
Merge pull request #17773 from peppy/fix-skin-duplication
Fix skins getting duplicated when importing after export
This commit is contained in:
commit
0eb0b5b456
@ -11,6 +11,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
|
using osu.Game.Extensions;
|
||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
using osu.Game.IO.Archives;
|
using osu.Game.IO.Archives;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
@ -110,6 +111,27 @@ namespace osu.Game.Tests.Skins.IO
|
|||||||
assertImportedOnce(import1, import2);
|
assertImportedOnce(import1, import2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public Task TestImportExportedSkinFilename() => runSkinTest(async osu =>
|
||||||
|
{
|
||||||
|
MemoryStream exportStream = new MemoryStream();
|
||||||
|
|
||||||
|
var import1 = await loadSkinIntoOsu(osu, new ZipArchiveReader(createOskWithIni("name 1", "author 1"), "custom.osk"));
|
||||||
|
assertCorrectMetadata(import1, "name 1 [custom]", "author 1", osu);
|
||||||
|
|
||||||
|
import1.PerformRead(s =>
|
||||||
|
{
|
||||||
|
new LegacySkinExporter(osu.Dependencies.Get<Storage>()).ExportModelTo(s, exportStream);
|
||||||
|
});
|
||||||
|
|
||||||
|
string exportFilename = import1.GetDisplayString();
|
||||||
|
|
||||||
|
var import2 = await loadSkinIntoOsu(osu, new ZipArchiveReader(exportStream, $"{exportFilename}.osk"));
|
||||||
|
assertCorrectMetadata(import2, "name 1 [custom]", "author 1", osu);
|
||||||
|
|
||||||
|
assertImportedOnce(import1, import2);
|
||||||
|
});
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public Task TestSameMetadataNameSameFolderName() => runSkinTest(async osu =>
|
public Task TestSameMetadataNameSameFolderName() => runSkinTest(async osu =>
|
||||||
{
|
{
|
||||||
|
@ -104,7 +104,9 @@ namespace osu.Game.Skinning
|
|||||||
// For imports, we want to use the archive or folder name as part of the metadata, in addition to any existing skin.ini metadata.
|
// For imports, we want to use the archive or folder name as part of the metadata, in addition to any existing skin.ini metadata.
|
||||||
// In an ideal world, skin.ini would be the only source of metadata, but a lot of skin creators and users don't update it when making modifications.
|
// In an ideal world, skin.ini would be the only source of metadata, but a lot of skin creators and users don't update it when making modifications.
|
||||||
// In both of these cases, the expectation from the user is that the filename or folder name is displayed somewhere to identify the skin.
|
// In both of these cases, the expectation from the user is that the filename or folder name is displayed somewhere to identify the skin.
|
||||||
if (archiveName != item.Name)
|
if (archiveName != item.Name
|
||||||
|
// lazer exports use this format
|
||||||
|
&& archiveName != item.GetDisplayString())
|
||||||
item.Name = @$"{item.Name} [{archiveName}]";
|
item.Name = @$"{item.Name} [{archiveName}]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user