1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-26 02:22:54 +08:00
osu-lazer/osu.Game/Skinning/LegacySkinDecoder.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

68 lines
2.2 KiB
C#
Raw Normal View History

2019-05-12 21:53:12 +08:00
// 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.
2018-04-13 17:19:50 +08:00
2019-11-07 01:27:55 +08:00
using System.Globalization;
using osu.Game.Beatmaps.Formats;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Skinning
{
public class LegacySkinDecoder : LegacyDecoder<SkinConfiguration>
{
public LegacySkinDecoder()
: base(1)
{
}
2018-04-13 17:19:50 +08:00
protected override void ParseLine(SkinConfiguration skin, Section section, string line)
{
if (section != Section.Colours)
{
var pair = SplitKeyVal(line);
switch (section)
{
case Section.General:
switch (pair.Key)
{
case @"Name":
skin.SkinInfo.Name = pair.Value;
return;
case @"Author":
skin.SkinInfo.Creator = pair.Value;
return;
case @"Version":
2019-11-07 01:23:22 +08:00
if (pair.Value == "latest")
skin.LegacyVersion = SkinConfiguration.LATEST_VERSION;
else if (decimal.TryParse(pair.Value, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out decimal version))
skin.LegacyVersion = version;
return;
}
break;
// osu!catch section only has colour settings
// so no harm in handling the entire section
case Section.CatchTheBeat:
HandleColours(skin, line);
return;
}
if (!string.IsNullOrEmpty(pair.Key))
2019-09-03 17:56:01 +08:00
skin.ConfigDictionary[pair.Key] = pair.Value;
}
2018-04-13 17:19:50 +08:00
base.ParseLine(skin, section, line);
}
protected override SkinConfiguration CreateTemplateObject()
{
var config = base.CreateTemplateObject();
config.LegacyVersion = 1.0m;
return config;
}
}
}