1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 05:32:54 +08:00

Use decimal data type instead

This commit is contained in:
iiSaLMaN 2019-10-09 23:33:25 +03:00
parent d15db378ce
commit 2cf17e0bf3
5 changed files with 27 additions and 11 deletions

View File

@ -57,15 +57,31 @@ namespace osu.Game.Tests.Skins
}
}
[TestCase("skin-20.ini", 2.0)]
[TestCase("skin-latest.ini", LegacySkinConfiguration.LATEST_VERSION)]
[TestCase("skin-empty.ini", null)]
public void TestDecodeVersion(string filename, double? expected)
[Test]
public void TestDecodeSpecifiedVersion()
{
var decoder = new LegacySkinDecoder();
using (var resStream = TestResources.OpenResource(filename))
using (var resStream = TestResources.OpenResource("skin-20.ini"))
using (var stream = new LineBufferedReader(resStream))
Assert.AreEqual(expected, decoder.Decode(stream).LegacyVersion);
Assert.AreEqual(2.0m, decoder.Decode(stream).LegacyVersion);
}
[Test]
public void TestDecodeLatestVersion()
{
var decoder = new LegacySkinDecoder();
using (var resStream = TestResources.OpenResource("skin-latest.ini"))
using (var stream = new LineBufferedReader(resStream))
Assert.AreEqual(LegacySkinConfiguration.LATEST_VERSION, decoder.Decode(stream).LegacyVersion);
}
[Test]
public void TestDecodeNoVersion()
{
var decoder = new LegacySkinDecoder();
using (var resStream = TestResources.OpenResource("skin-empty.ini"))
using (var stream = new LineBufferedReader(resStream))
Assert.IsNull(decoder.Decode(stream).LegacyVersion);
}
}
}

View File

@ -21,7 +21,7 @@ namespace osu.Game.Skinning
new Color4(242, 24, 57, 255),
});
Configuration.LegacyVersion = 2.0;
Configuration.LegacyVersion = 2.0m;
}
public static SkinInfo Info { get; } = new SkinInfo

View File

@ -78,7 +78,7 @@ namespace osu.Game.Skinning
{
case LegacySkinConfigurations.Version:
if (Configuration.LegacyVersion.HasValue)
return SkinUtils.As<TValue>(new BindableDouble(Configuration.LegacyVersion.Value));
return SkinUtils.As<TValue>(new Bindable<decimal>(Configuration.LegacyVersion.Value));
break;
}

View File

@ -5,12 +5,12 @@ namespace osu.Game.Skinning
{
public class LegacySkinConfiguration : DefaultSkinConfiguration
{
public const double LATEST_VERSION = 2.5;
public const decimal LATEST_VERSION = 2.5m;
/// <summary>
/// Legacy version of this skin.
/// </summary>
public double? LegacyVersion { get; internal set; }
public decimal? LegacyVersion { get; internal set; }
}
public enum LegacySkinConfigurations

View File

@ -36,7 +36,7 @@ namespace osu.Game.Skinning
case @"Version":
if (pair.Value == "latest" || pair.Value == "User")
skin.LegacyVersion = LegacySkinConfiguration.LATEST_VERSION;
else if (double.TryParse(pair.Value, out var version))
else if (decimal.TryParse(pair.Value, out var version))
skin.LegacyVersion = version;
return;