mirror of
https://github.com/ppy/osu.git
synced 2025-02-16 18:32:56 +08:00
Merge pull request #15405 from peppy/legacy-decoder-default-section
Default legacy decoder to `General` section, rather than none
This commit is contained in:
commit
6f941a8916
@ -38,6 +38,15 @@ namespace osu.Game.Tests.Skins.IO
|
|||||||
assertCorrectMetadata(import1, "test skin [skin]", "skinner", osu);
|
assertCorrectMetadata(import1, "test skin [skin]", "skinner", osu);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public Task TestSingleImportMissingSectionHeader() => runSkinTest(async osu =>
|
||||||
|
{
|
||||||
|
var import1 = await loadSkinIntoOsu(osu, new ZipArchiveReader(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);
|
||||||
|
});
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public Task TestSingleImportMatchingFilename() => runSkinTest(async osu =>
|
public Task TestSingleImportMatchingFilename() => runSkinTest(async osu =>
|
||||||
{
|
{
|
||||||
@ -199,21 +208,23 @@ namespace osu.Game.Tests.Skins.IO
|
|||||||
return zipStream;
|
return zipStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MemoryStream createOskWithIni(string name, string author, bool makeUnique = false, string iniFilename = @"skin.ini")
|
private MemoryStream createOskWithIni(string name, string author, bool makeUnique = false, string iniFilename = @"skin.ini", bool includeSectionHeader = true)
|
||||||
{
|
{
|
||||||
var zipStream = new MemoryStream();
|
var zipStream = new MemoryStream();
|
||||||
using var zip = ZipArchive.Create();
|
using var zip = ZipArchive.Create();
|
||||||
zip.AddEntry(iniFilename, generateSkinIni(name, author, makeUnique));
|
zip.AddEntry(iniFilename, generateSkinIni(name, author, makeUnique, includeSectionHeader));
|
||||||
zip.SaveTo(zipStream);
|
zip.SaveTo(zipStream);
|
||||||
return zipStream;
|
return zipStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MemoryStream generateSkinIni(string name, string author, bool makeUnique = true)
|
private MemoryStream generateSkinIni(string name, string author, bool makeUnique = true, bool includeSectionHeader = true)
|
||||||
{
|
{
|
||||||
var stream = new MemoryStream();
|
var stream = new MemoryStream();
|
||||||
var writer = new StreamWriter(stream);
|
var writer = new StreamWriter(stream);
|
||||||
|
|
||||||
writer.WriteLine("[General]");
|
if (includeSectionHeader)
|
||||||
|
writer.WriteLine("[General]");
|
||||||
|
|
||||||
writer.WriteLine($"Name: {name}");
|
writer.WriteLine($"Name: {name}");
|
||||||
writer.WriteLine($"Author: {author}");
|
writer.WriteLine($"Author: {author}");
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
protected override void ParseStreamInto(LineBufferedReader stream, T output)
|
protected override void ParseStreamInto(LineBufferedReader stream, T output)
|
||||||
{
|
{
|
||||||
Section section = Section.None;
|
Section section = Section.General;
|
||||||
|
|
||||||
string line;
|
string line;
|
||||||
|
|
||||||
@ -47,10 +47,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
if (line.StartsWith('[') && line.EndsWith(']'))
|
if (line.StartsWith('[') && line.EndsWith(']'))
|
||||||
{
|
{
|
||||||
if (!Enum.TryParse(line[1..^1], out section))
|
if (!Enum.TryParse(line[1..^1], out section))
|
||||||
{
|
|
||||||
Logger.Log($"Unknown section \"{line}\" in \"{output}\"");
|
Logger.Log($"Unknown section \"{line}\" in \"{output}\"");
|
||||||
section = Section.None;
|
|
||||||
}
|
|
||||||
|
|
||||||
OnBeginNewSection(section);
|
OnBeginNewSection(section);
|
||||||
continue;
|
continue;
|
||||||
@ -148,7 +145,6 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
protected enum Section
|
protected enum Section
|
||||||
{
|
{
|
||||||
None,
|
|
||||||
General,
|
General,
|
||||||
Editor,
|
Editor,
|
||||||
Metadata,
|
Metadata,
|
||||||
|
Loading…
Reference in New Issue
Block a user