mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 19:42:55 +08:00
Merge pull request #24942 from peppy/fix-missing-skin-ini-version
Fix skin version being incorrectly set to `1.0` when skin is missing `skin.ini`
This commit is contained in:
commit
fc38b2c024
@ -27,7 +27,7 @@ namespace osu.Game.Tests.Skins.IO
|
||||
var import1 = await loadSkinIntoOsu(osu, new ImportTask(createOskWithIni("test skin", "skinner"), "skin.osk"));
|
||||
|
||||
// When the import filename doesn't match, it should be appended (and update the skin.ini).
|
||||
assertCorrectMetadata(import1, "test skin [skin]", "skinner", osu);
|
||||
assertCorrectMetadata(import1, "test skin [skin]", "skinner", 1.0m, osu);
|
||||
});
|
||||
|
||||
[Test]
|
||||
@ -36,7 +36,7 @@ namespace osu.Game.Tests.Skins.IO
|
||||
var import1 = await loadSkinIntoOsu(osu, new ImportTask(createOskWithIni("test skin", "skinner", iniFilename: "Skin.InI"), "skin.osk"));
|
||||
|
||||
// When the import filename doesn't match, it should be appended (and update the skin.ini).
|
||||
assertCorrectMetadata(import1, "test skin [skin]", "skinner", osu);
|
||||
assertCorrectMetadata(import1, "test skin [skin]", "skinner", 1.0m, osu);
|
||||
});
|
||||
|
||||
[Test]
|
||||
@ -45,7 +45,7 @@ namespace osu.Game.Tests.Skins.IO
|
||||
var import1 = await loadSkinIntoOsu(osu, new ImportTask(createOskWithIni("test skin", "skinner", includeSectionHeader: false), "skin.osk"));
|
||||
|
||||
// When the import filename doesn't match, it should be appended (and update the skin.ini).
|
||||
assertCorrectMetadata(import1, "test skin [skin]", "skinner", osu);
|
||||
assertCorrectMetadata(import1, "test skin [skin]", "skinner", 1.0m, osu);
|
||||
});
|
||||
|
||||
[Test]
|
||||
@ -54,7 +54,7 @@ namespace osu.Game.Tests.Skins.IO
|
||||
var import1 = await loadSkinIntoOsu(osu, new ImportTask(createOskWithIni("test skin", "skinner"), "test skin.osk"));
|
||||
|
||||
// When the import filename matches it shouldn't be appended.
|
||||
assertCorrectMetadata(import1, "test skin", "skinner", osu);
|
||||
assertCorrectMetadata(import1, "test skin", "skinner", 1.0m, osu);
|
||||
});
|
||||
|
||||
[Test]
|
||||
@ -63,7 +63,7 @@ namespace osu.Game.Tests.Skins.IO
|
||||
var import1 = await loadSkinIntoOsu(osu, new ImportTask(createOskWithNonIniFile(), "test skin.osk"));
|
||||
|
||||
// When the import filename matches it shouldn't be appended.
|
||||
assertCorrectMetadata(import1, "test skin", "Unknown", osu);
|
||||
assertCorrectMetadata(import1, "test skin", "Unknown", SkinConfiguration.LATEST_VERSION, osu);
|
||||
});
|
||||
|
||||
[Test]
|
||||
@ -72,7 +72,7 @@ namespace osu.Game.Tests.Skins.IO
|
||||
var import1 = await loadSkinIntoOsu(osu, new ImportTask(createEmptyOsk(), "test skin.osk"));
|
||||
|
||||
// When the import filename matches it shouldn't be appended.
|
||||
assertCorrectMetadata(import1, "test skin", "Unknown", osu);
|
||||
assertCorrectMetadata(import1, "test skin", "Unknown", SkinConfiguration.LATEST_VERSION, osu);
|
||||
});
|
||||
|
||||
#endregion
|
||||
@ -102,7 +102,7 @@ namespace osu.Game.Tests.Skins.IO
|
||||
public Task TestImportUpperCasedOskArchive() => runSkinTest(async osu =>
|
||||
{
|
||||
var import1 = await loadSkinIntoOsu(osu, new ImportTask(createOskWithIni("name 1", "author 1"), "name 1.OsK"));
|
||||
assertCorrectMetadata(import1, "name 1", "author 1", osu);
|
||||
assertCorrectMetadata(import1, "name 1", "author 1", 1.0m, osu);
|
||||
|
||||
var import2 = await loadSkinIntoOsu(osu, new ImportTask(createOskWithIni("name 1", "author 1"), "name 1.oSK"));
|
||||
|
||||
@ -115,14 +115,14 @@ namespace osu.Game.Tests.Skins.IO
|
||||
MemoryStream exportStream = new MemoryStream();
|
||||
|
||||
var import1 = await loadSkinIntoOsu(osu, new ImportTask(createOskWithIni("name 1", "author 1"), "custom.osk"));
|
||||
assertCorrectMetadata(import1, "name 1 [custom]", "author 1", osu);
|
||||
assertCorrectMetadata(import1, "name 1 [custom]", "author 1", 1.0m, osu);
|
||||
|
||||
await new LegacySkinExporter(osu.Dependencies.Get<Storage>()).ExportToStreamAsync(import1, exportStream);
|
||||
|
||||
string exportFilename = import1.GetDisplayString();
|
||||
|
||||
var import2 = await loadSkinIntoOsu(osu, new ImportTask(exportStream, $"{exportFilename}.osk"));
|
||||
assertCorrectMetadata(import2, "name 1 [custom]", "author 1", osu);
|
||||
assertCorrectMetadata(import2, "name 1 [custom]", "author 1", 1.0m, osu);
|
||||
|
||||
assertImportedOnce(import1, import2);
|
||||
});
|
||||
@ -133,14 +133,14 @@ namespace osu.Game.Tests.Skins.IO
|
||||
MemoryStream exportStream = new MemoryStream();
|
||||
|
||||
var import1 = await loadSkinIntoOsu(osu, new ImportTask(createOskWithIni("name 『1』", "author 1"), "custom.osk"));
|
||||
assertCorrectMetadata(import1, "name 『1』 [custom]", "author 1", osu);
|
||||
assertCorrectMetadata(import1, "name 『1』 [custom]", "author 1", 1.0m, osu);
|
||||
|
||||
await new LegacySkinExporter(osu.Dependencies.Get<Storage>()).ExportToStreamAsync(import1, exportStream);
|
||||
|
||||
string exportFilename = import1.GetDisplayString().GetValidFilename();
|
||||
|
||||
var import2 = await loadSkinIntoOsu(osu, new ImportTask(exportStream, $"{exportFilename}.osk"));
|
||||
assertCorrectMetadata(import2, "name 『1』 [custom]", "author 1", osu);
|
||||
assertCorrectMetadata(import2, "name 『1』 [custom]", "author 1", 1.0m, osu);
|
||||
});
|
||||
|
||||
[Test]
|
||||
@ -150,7 +150,7 @@ namespace osu.Game.Tests.Skins.IO
|
||||
var import2 = await loadSkinIntoOsu(osu, new ImportTask(createOskWithIni("name 1", "author 1"), "my custom skin 1"), batchImport);
|
||||
|
||||
assertImportedOnce(import1, import2);
|
||||
assertCorrectMetadata(import1, "name 1 [my custom skin 1]", "author 1", osu);
|
||||
assertCorrectMetadata(import1, "name 1 [my custom skin 1]", "author 1", 1.0m, osu);
|
||||
});
|
||||
|
||||
#endregion
|
||||
@ -183,8 +183,8 @@ namespace osu.Game.Tests.Skins.IO
|
||||
var import2 = await loadSkinIntoOsu(osu, new ImportTask(createOskWithIni("test skin v2.1", "skinner"), "skin.osk"));
|
||||
|
||||
assertImportedBoth(import1, import2);
|
||||
assertCorrectMetadata(import1, "test skin v2 [skin]", "skinner", osu);
|
||||
assertCorrectMetadata(import2, "test skin v2.1 [skin]", "skinner", osu);
|
||||
assertCorrectMetadata(import1, "test skin v2 [skin]", "skinner", 1.0m, osu);
|
||||
assertCorrectMetadata(import2, "test skin v2.1 [skin]", "skinner", 1.0m, osu);
|
||||
});
|
||||
|
||||
[Test]
|
||||
@ -194,8 +194,8 @@ namespace osu.Game.Tests.Skins.IO
|
||||
var import2 = await loadSkinIntoOsu(osu, new ImportTask(createOskWithIni("name 1", "author 1"), "my custom skin 2"));
|
||||
|
||||
assertImportedBoth(import1, import2);
|
||||
assertCorrectMetadata(import1, "name 1 [my custom skin 1]", "author 1", osu);
|
||||
assertCorrectMetadata(import2, "name 1 [my custom skin 2]", "author 1", osu);
|
||||
assertCorrectMetadata(import1, "name 1 [my custom skin 1]", "author 1", 1.0m, osu);
|
||||
assertCorrectMetadata(import2, "name 1 [my custom skin 2]", "author 1", 1.0m, osu);
|
||||
});
|
||||
|
||||
[Test]
|
||||
@ -264,7 +264,7 @@ namespace osu.Game.Tests.Skins.IO
|
||||
|
||||
#endregion
|
||||
|
||||
private void assertCorrectMetadata(Live<SkinInfo> import1, string name, string creator, OsuGameBase osu)
|
||||
private void assertCorrectMetadata(Live<SkinInfo> import1, string name, string creator, decimal version, OsuGameBase osu)
|
||||
{
|
||||
import1.PerformRead(i =>
|
||||
{
|
||||
@ -276,6 +276,7 @@ namespace osu.Game.Tests.Skins.IO
|
||||
|
||||
Assert.That(instance.Configuration.SkinInfo.Name, Is.EqualTo(name));
|
||||
Assert.That(instance.Configuration.SkinInfo.Creator, Is.EqualTo(creator));
|
||||
Assert.That(instance.Configuration.LegacyVersion, Is.EqualTo(version));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,14 @@ namespace osu.Game.Skinning
|
||||
Debug.Assert(Configuration != null);
|
||||
}
|
||||
else
|
||||
Configuration = new SkinConfiguration();
|
||||
{
|
||||
Configuration = new SkinConfiguration
|
||||
{
|
||||
// generally won't be hit as we always write a `skin.ini` on import, but best be safe than sorry.
|
||||
// see https://github.com/peppy/osu-stable-reference/blob/1531237b63392e82c003c712faa028406073aa8f/osu!/Graphics/Skinning/SkinManager.cs#L297-L298
|
||||
LegacyVersion = SkinConfiguration.LATEST_VERSION,
|
||||
};
|
||||
}
|
||||
|
||||
// skininfo files may be null for default skin.
|
||||
foreach (SkinComponentsContainerLookup.TargetArea skinnableTarget in Enum.GetValues<SkinComponentsContainerLookup.TargetArea>())
|
||||
|
@ -118,7 +118,7 @@ namespace osu.Game.Skinning
|
||||
string nameLine = @$"Name: {item.Name}";
|
||||
string authorLine = @$"Author: {item.Creator}";
|
||||
|
||||
string[] newLines =
|
||||
List<string> newLines = new List<string>
|
||||
{
|
||||
@"// The following content was automatically added by osu! during import, based on filename / folder metadata.",
|
||||
@"[General]",
|
||||
@ -130,6 +130,10 @@ namespace osu.Game.Skinning
|
||||
|
||||
if (existingFile == null)
|
||||
{
|
||||
// skins without a skin.ini are supposed to import using the "latest version" spec.
|
||||
// see https://github.com/peppy/osu-stable-reference/blob/1531237b63392e82c003c712faa028406073aa8f/osu!/Graphics/Skinning/SkinManager.cs#L297-L298
|
||||
newLines.Add($"Version: {SkinConfiguration.LATEST_VERSION}");
|
||||
|
||||
// In the case a skin doesn't have a skin.ini yet, let's create one.
|
||||
writeNewSkinIni();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user