2019-05-12 13:53:12 +00:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 08:43:03 +00:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-11-06 17:27:55 +00:00
|
|
|
|
using System.Globalization;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Beatmaps.Formats;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Skinning
|
|
|
|
|
{
|
2019-10-09 20:05:50 +00:00
|
|
|
|
public class LegacySkinDecoder : LegacyDecoder<LegacySkinConfiguration>
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
public LegacySkinDecoder()
|
|
|
|
|
: base(1)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-09 20:05:50 +00:00
|
|
|
|
protected override void ParseLine(LegacySkinConfiguration skin, Section section, string line)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-09-03 08:57:34 +00:00
|
|
|
|
if (section != Section.Colours)
|
|
|
|
|
{
|
|
|
|
|
var pair = SplitKeyVal(line);
|
2019-04-01 02:39:02 +00:00
|
|
|
|
|
2019-09-03 08:57:34 +00: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-09 20:05:50 +00:00
|
|
|
|
|
|
|
|
|
case @"Version":
|
2019-11-06 17:23:22 +00:00
|
|
|
|
if (pair.Value == "latest")
|
2019-10-09 20:05:50 +00:00
|
|
|
|
skin.LegacyVersion = LegacySkinConfiguration.LATEST_VERSION;
|
2019-11-06 17:27:55 +00:00
|
|
|
|
else if (decimal.TryParse(pair.Value, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var version))
|
2019-10-09 20:05:50 +00:00
|
|
|
|
skin.LegacyVersion = version;
|
|
|
|
|
|
|
|
|
|
return;
|
2019-09-03 08:57:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
2020-04-05 19:10:35 +00:00
|
|
|
|
|
|
|
|
|
// osu!catch section only has colour settings
|
|
|
|
|
// so no harm in handling the entire section
|
|
|
|
|
case Section.CatchTheBeat:
|
|
|
|
|
HandleColours(skin, line);
|
|
|
|
|
return;
|
2019-09-03 08:57:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(pair.Key))
|
2019-09-03 09:56:01 +00:00
|
|
|
|
skin.ConfigDictionary[pair.Key] = pair.Value;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-20 09:32:24 +00:00
|
|
|
|
base.ParseLine(skin, section, line);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
2020-04-06 10:36:04 +00:00
|
|
|
|
|
|
|
|
|
protected override LegacySkinConfiguration CreateTemplateObject()
|
|
|
|
|
{
|
|
|
|
|
var config = base.CreateTemplateObject();
|
|
|
|
|
config.LegacyVersion = 1.0m;
|
|
|
|
|
return config;
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|