2019-05-12 21:53:12 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 16:43:03 +08:00
|
|
|
|
// 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;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Beatmaps.Formats;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Skinning
|
|
|
|
|
{
|
2021-10-22 13:41:59 +08:00
|
|
|
|
public class LegacySkinDecoder : LegacyDecoder<SkinConfiguration>
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
public LegacySkinDecoder()
|
|
|
|
|
: base(1)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-22 13:41:59 +08:00
|
|
|
|
protected override void ParseLine(SkinConfiguration skin, Section section, string line)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-09-03 16:57:34 +08:00
|
|
|
|
if (section != Section.Colours)
|
|
|
|
|
{
|
|
|
|
|
var pair = SplitKeyVal(line);
|
2019-04-01 10:39:02 +08:00
|
|
|
|
|
2019-09-03 16:57:34 +08:00
|
|
|
|
switch (section)
|
|
|
|
|
{
|
|
|
|
|
case Section.General:
|
|
|
|
|
switch (pair.Key)
|
|
|
|
|
{
|
|
|
|
|
case @"Name":
|
|
|
|
|
skin.SkinInfo.Name = pair.Value;
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case @"Author":
|
|
|
|
|
skin.SkinInfo.Creator = pair.Value;
|
|
|
|
|
return;
|
2019-10-10 04:05:50 +08:00
|
|
|
|
|
|
|
|
|
case @"Version":
|
2019-11-07 01:23:22 +08:00
|
|
|
|
if (pair.Value == "latest")
|
2021-10-22 13:41:59 +08:00
|
|
|
|
skin.LegacyVersion = SkinConfiguration.LATEST_VERSION;
|
2021-10-27 12:04:41 +08:00
|
|
|
|
else if (decimal.TryParse(pair.Value, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out decimal version))
|
2019-10-10 04:05:50 +08:00
|
|
|
|
skin.LegacyVersion = version;
|
|
|
|
|
|
|
|
|
|
return;
|
2019-09-03 16:57:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
2020-04-06 03:10:35 +08:00
|
|
|
|
|
|
|
|
|
// osu!catch section only has colour settings
|
|
|
|
|
// so no harm in handling the entire section
|
|
|
|
|
case Section.CatchTheBeat:
|
2022-09-21 15:04:32 +08:00
|
|
|
|
HandleColours(skin, line, true);
|
2020-04-06 03:10:35 +08:00
|
|
|
|
return;
|
2019-09-03 16:57:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2018-04-20 17:32:24 +08:00
|
|
|
|
base.ParseLine(skin, section, line);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2020-04-06 18:36:04 +08:00
|
|
|
|
|
2021-10-22 13:41:59 +08:00
|
|
|
|
protected override SkinConfiguration CreateTemplateObject()
|
2020-04-06 18:36:04 +08:00
|
|
|
|
{
|
|
|
|
|
var config = base.CreateTemplateObject();
|
|
|
|
|
config.LegacyVersion = 1.0m;
|
|
|
|
|
return config;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|