mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Remove SkinConfiguration
subclasses and allow configuration parsing for all skin types
This commit is contained in:
@ -66,7 +66,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
case CatchSkinComponents.Catcher:
|
case CatchSkinComponents.Catcher:
|
||||||
var version = GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version)?.Value ?? 1;
|
var version = GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value ?? 1;
|
||||||
|
|
||||||
if (version < 2.3m)
|
if (version < 2.3m)
|
||||||
{
|
{
|
||||||
|
@ -98,7 +98,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
|
|||||||
float rightLineWidth = skin.GetManiaSkinConfig<float>(LegacyManiaSkinConfigurationLookups.RightLineWidth, columnIndex)?.Value ?? 1;
|
float rightLineWidth = skin.GetManiaSkinConfig<float>(LegacyManiaSkinConfigurationLookups.RightLineWidth, columnIndex)?.Value ?? 1;
|
||||||
|
|
||||||
bool hasLeftLine = leftLineWidth > 0;
|
bool hasLeftLine = leftLineWidth > 0;
|
||||||
bool hasRightLine = rightLineWidth > 0 && skin.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version)?.Value >= 2.4m
|
bool hasRightLine = rightLineWidth > 0 && skin.GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value >= 2.4m
|
||||||
|| isLastColumn;
|
|| isLastColumn;
|
||||||
|
|
||||||
Color4 lineColour = skin.GetManiaSkinConfig<Color4>(LegacyManiaSkinConfigurationLookups.ColumnLineColour, columnIndex)?.Value ?? Color4.White;
|
Color4 lineColour = skin.GetManiaSkinConfig<Color4>(LegacyManiaSkinConfigurationLookups.ColumnLineColour, columnIndex)?.Value ?? Color4.White;
|
||||||
|
@ -63,7 +63,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
|
|||||||
{
|
{
|
||||||
this.beatmap = (ManiaBeatmap)beatmap;
|
this.beatmap = (ManiaBeatmap)beatmap;
|
||||||
|
|
||||||
isLegacySkin = new Lazy<bool>(() => GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version) != null);
|
isLegacySkin = new Lazy<bool>(() => GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version) != null);
|
||||||
hasKeyTexture = new Lazy<bool>(() =>
|
hasKeyTexture = new Lazy<bool>(() =>
|
||||||
{
|
{
|
||||||
var keyImage = this.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.KeyImage, 0)?.Value ?? "mania-key1";
|
var keyImage = this.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.KeyImage, 0)?.Value ?? "mania-key1";
|
||||||
|
@ -14,7 +14,6 @@ using osu.Game.Rulesets.Osu.Objects.Drawables;
|
|||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using static osu.Game.Skinning.LegacySkinConfiguration;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||||
{
|
{
|
||||||
@ -158,7 +157,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
|||||||
|
|
||||||
if (hasNumber)
|
if (hasNumber)
|
||||||
{
|
{
|
||||||
var legacyVersion = skin.GetConfig<LegacySetting, decimal>(LegacySetting.Version)?.Value;
|
var legacyVersion = skin.GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value;
|
||||||
|
|
||||||
if (legacyVersion >= 2.0m)
|
if (legacyVersion >= 2.0m)
|
||||||
// legacy skins of version 2.0 and newer only apply very short fade out to the number piece.
|
// legacy skins of version 2.0 and newer only apply very short fade out to the number piece.
|
||||||
|
@ -69,7 +69,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
|
|||||||
// because the right half is flipped, we need to position using width - position to get the true "topleft" origin position
|
// because the right half is flipped, we need to position using width - position to get the true "topleft" origin position
|
||||||
float negativeScaleAdjust = content.Width / ratio;
|
float negativeScaleAdjust = content.Width / ratio;
|
||||||
|
|
||||||
if (skin.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version)?.Value >= 2.1m)
|
if (skin.GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value >= 2.1m)
|
||||||
{
|
{
|
||||||
left.Centre.Position = new Vector2(0, taiko_bar_y) * ratio;
|
left.Centre.Position = new Vector2(0, taiko_bar_y) * ratio;
|
||||||
right.Centre.Position = new Vector2(negativeScaleAdjust - 56, taiko_bar_y) * ratio;
|
right.Centre.Position = new Vector2(negativeScaleAdjust - 56, taiko_bar_y) * ratio;
|
||||||
|
@ -7,7 +7,7 @@ using osu.Game.Rulesets;
|
|||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Tests.Beatmaps;
|
using osu.Game.Tests.Beatmaps;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
using static osu.Game.Skinning.LegacySkinConfiguration;
|
using static osu.Game.Skinning.SkinConfiguration;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Gameplay
|
namespace osu.Game.Tests.Gameplay
|
||||||
{
|
{
|
||||||
|
@ -106,7 +106,7 @@ namespace osu.Game.Tests.Skins
|
|||||||
var decoder = new LegacySkinDecoder();
|
var decoder = new LegacySkinDecoder();
|
||||||
using (var resStream = TestResources.OpenResource("skin-latest.ini"))
|
using (var resStream = TestResources.OpenResource("skin-latest.ini"))
|
||||||
using (var stream = new LineBufferedReader(resStream))
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
Assert.AreEqual(LegacySkinConfiguration.LATEST_VERSION, decoder.Decode(stream).LegacyVersion);
|
Assert.AreEqual(SkinConfiguration.LATEST_VERSION, decoder.Decode(stream).LegacyVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -151,7 +151,7 @@ namespace osu.Game.Tests.Skins
|
|||||||
{
|
{
|
||||||
AddStep("Set user skin version 2.3", () => userSource.Configuration.LegacyVersion = 2.3m);
|
AddStep("Set user skin version 2.3", () => userSource.Configuration.LegacyVersion = 2.3m);
|
||||||
AddStep("Set beatmap skin version null", () => beatmapSource.Configuration.LegacyVersion = null);
|
AddStep("Set beatmap skin version null", () => beatmapSource.Configuration.LegacyVersion = null);
|
||||||
AddAssert("Check legacy version lookup", () => requester.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version)?.Value == 2.3m);
|
AddAssert("Check legacy version lookup", () => requester.GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value == 2.3m);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -160,7 +160,7 @@ namespace osu.Game.Tests.Skins
|
|||||||
// completely ignoring beatmap versions for simplicity.
|
// completely ignoring beatmap versions for simplicity.
|
||||||
AddStep("Set user skin version 2.3", () => userSource.Configuration.LegacyVersion = 2.3m);
|
AddStep("Set user skin version 2.3", () => userSource.Configuration.LegacyVersion = 2.3m);
|
||||||
AddStep("Set beatmap skin version null", () => beatmapSource.Configuration.LegacyVersion = 1.7m);
|
AddStep("Set beatmap skin version null", () => beatmapSource.Configuration.LegacyVersion = 1.7m);
|
||||||
AddAssert("Check legacy version lookup", () => requester.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version)?.Value == 2.3m);
|
AddAssert("Check legacy version lookup", () => requester.GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value == 2.3m);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -169,14 +169,14 @@ namespace osu.Game.Tests.Skins
|
|||||||
AddStep("Set user skin version 2.3", () => userSource.Configuration.LegacyVersion = null);
|
AddStep("Set user skin version 2.3", () => userSource.Configuration.LegacyVersion = null);
|
||||||
AddStep("Set beatmap skin version null", () => beatmapSource.Configuration.LegacyVersion = null);
|
AddStep("Set beatmap skin version null", () => beatmapSource.Configuration.LegacyVersion = null);
|
||||||
AddAssert("Check legacy version lookup",
|
AddAssert("Check legacy version lookup",
|
||||||
() => requester.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version)?.Value == LegacySkinConfiguration.LATEST_VERSION);
|
() => requester.GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value == SkinConfiguration.LATEST_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestIniWithNoVersionFallsBackTo1()
|
public void TestIniWithNoVersionFallsBackTo1()
|
||||||
{
|
{
|
||||||
AddStep("Parse skin with no version", () => userSource.Configuration = new LegacySkinDecoder().Decode(new LineBufferedReader(new MemoryStream())));
|
AddStep("Parse skin with no version", () => userSource.Configuration = new LegacySkinDecoder().Decode(new LineBufferedReader(new MemoryStream())));
|
||||||
AddAssert("Check legacy version lookup", () => requester.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version)?.Value == 1.0m);
|
AddAssert("Check legacy version lookup", () => requester.GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value == 1.0m);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum LookupType
|
public enum LookupType
|
||||||
|
@ -481,7 +481,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Layered hit samples are automatically added in all modes (except osu!mania), but can be disabled
|
/// Layered hit samples are automatically added in all modes (except osu!mania), but can be disabled
|
||||||
/// using the <see cref="LegacySkinConfiguration.LegacySetting.LayeredHitSounds"/> skin config option.
|
/// using the <see cref="SkinConfiguration.LegacySetting.LayeredHitSounds"/> skin config option.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public readonly bool IsLayered;
|
public readonly bool IsLayered;
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@ namespace osu.Game.Skinning
|
|||||||
: base(skin, resources)
|
: base(skin, resources)
|
||||||
{
|
{
|
||||||
this.resources = resources;
|
this.resources = resources;
|
||||||
Configuration = new DefaultSkinConfiguration();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => null;
|
public override Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => null;
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A skin configuration pre-populated with sane defaults.
|
|
||||||
/// </summary>
|
|
||||||
public class DefaultSkinConfiguration : SkinConfiguration
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@ -50,7 +50,7 @@ namespace osu.Game.Skinning
|
|||||||
{
|
{
|
||||||
switch (lookup)
|
switch (lookup)
|
||||||
{
|
{
|
||||||
case LegacySkinConfiguration.LegacySetting s when s == LegacySkinConfiguration.LegacySetting.Version:
|
case SkinConfiguration.LegacySetting s when s == SkinConfiguration.LegacySetting.Version:
|
||||||
// For lookup simplicity, ignore beatmap-level versioning completely.
|
// For lookup simplicity, ignore beatmap-level versioning completely.
|
||||||
|
|
||||||
// If it is decided that we need this due to beatmaps somehow using it, the default (1.0 specified in LegacySkinDecoder.CreateTemplateObject)
|
// If it is decided that we need this due to beatmaps somehow using it, the default (1.0 specified in LegacySkinDecoder.CreateTemplateObject)
|
||||||
|
@ -47,12 +47,6 @@ namespace osu.Game.Skinning
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual bool UseCustomSampleBanks => false;
|
protected virtual bool UseCustomSampleBanks => false;
|
||||||
|
|
||||||
public new LegacySkinConfiguration Configuration
|
|
||||||
{
|
|
||||||
get => base.Configuration as LegacySkinConfiguration;
|
|
||||||
set => base.Configuration = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly Dictionary<int, LegacyManiaSkinConfiguration> maniaConfigurations = new Dictionary<int, LegacyManiaSkinConfiguration>();
|
private readonly Dictionary<int, LegacyManiaSkinConfiguration> maniaConfigurations = new Dictionary<int, LegacyManiaSkinConfiguration>();
|
||||||
|
|
||||||
[UsedImplicitly(ImplicitUseKindFlags.InstantiatedWithFixedConstructorSignature)]
|
[UsedImplicitly(ImplicitUseKindFlags.InstantiatedWithFixedConstructorSignature)]
|
||||||
@ -81,26 +75,8 @@ namespace osu.Game.Skinning
|
|||||||
/// <param name="resources">Access to raw game resources.</param>
|
/// <param name="resources">Access to raw game resources.</param>
|
||||||
/// <param name="configurationStream">An optional stream containing the contents of a skin.ini file.</param>
|
/// <param name="configurationStream">An optional stream containing the contents of a skin.ini file.</param>
|
||||||
protected LegacySkin(SkinInfo skin, [CanBeNull] IResourceStore<byte[]> storage, [CanBeNull] IStorageResourceProvider resources, [CanBeNull] Stream configurationStream)
|
protected LegacySkin(SkinInfo skin, [CanBeNull] IResourceStore<byte[]> storage, [CanBeNull] IStorageResourceProvider resources, [CanBeNull] Stream configurationStream)
|
||||||
: base(skin, resources)
|
: base(skin, resources, configurationStream)
|
||||||
{
|
{
|
||||||
if (configurationStream != null)
|
|
||||||
{
|
|
||||||
using (LineBufferedReader reader = new LineBufferedReader(configurationStream, true))
|
|
||||||
Configuration = new LegacySkinDecoder().Decode(reader);
|
|
||||||
|
|
||||||
configurationStream.Seek(0, SeekOrigin.Begin);
|
|
||||||
|
|
||||||
using (LineBufferedReader reader = new LineBufferedReader(configurationStream))
|
|
||||||
{
|
|
||||||
var maniaList = new LegacyManiaSkinDecoder().Decode(reader);
|
|
||||||
|
|
||||||
foreach (var config in maniaList)
|
|
||||||
maniaConfigurations[config.Keys] = config;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Configuration = new LegacySkinConfiguration();
|
|
||||||
|
|
||||||
if (storage != null)
|
if (storage != null)
|
||||||
{
|
{
|
||||||
var samples = resources?.AudioManager?.GetSampleStore(storage);
|
var samples = resources?.AudioManager?.GetSampleStore(storage);
|
||||||
@ -119,6 +95,21 @@ namespace osu.Game.Skinning
|
|||||||
true) != null);
|
true) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void ParseConfigurationStream(Stream stream)
|
||||||
|
{
|
||||||
|
base.ParseConfigurationStream(stream);
|
||||||
|
|
||||||
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
|
using (LineBufferedReader reader = new LineBufferedReader(stream))
|
||||||
|
{
|
||||||
|
var maniaList = new LegacyManiaSkinDecoder().Decode(reader);
|
||||||
|
|
||||||
|
foreach (var config in maniaList)
|
||||||
|
maniaConfigurations[config.Keys] = config;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
public override IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
|
||||||
{
|
{
|
||||||
switch (lookup)
|
switch (lookup)
|
||||||
@ -155,7 +146,7 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LegacySkinConfiguration.LegacySetting legacy:
|
case SkinConfiguration.LegacySetting legacy:
|
||||||
return legacySettingLookup<TValue>(legacy);
|
return legacySettingLookup<TValue>(legacy);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -198,7 +189,7 @@ namespace osu.Game.Skinning
|
|||||||
case LegacyManiaSkinConfigurationLookups.ExplosionScale:
|
case LegacyManiaSkinConfigurationLookups.ExplosionScale:
|
||||||
Debug.Assert(maniaLookup.TargetColumn != null);
|
Debug.Assert(maniaLookup.TargetColumn != null);
|
||||||
|
|
||||||
if (GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version)?.Value < 2.5m)
|
if (GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value < 2.5m)
|
||||||
return SkinUtils.As<TValue>(new Bindable<float>(1));
|
return SkinUtils.As<TValue>(new Bindable<float>(1));
|
||||||
|
|
||||||
if (existing.ExplosionWidth[maniaLookup.TargetColumn.Value] != 0)
|
if (existing.ExplosionWidth[maniaLookup.TargetColumn.Value] != 0)
|
||||||
@ -245,7 +236,7 @@ namespace osu.Game.Skinning
|
|||||||
case LegacyManiaSkinConfigurationLookups.HoldNoteLightScale:
|
case LegacyManiaSkinConfigurationLookups.HoldNoteLightScale:
|
||||||
Debug.Assert(maniaLookup.TargetColumn != null);
|
Debug.Assert(maniaLookup.TargetColumn != null);
|
||||||
|
|
||||||
if (GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version)?.Value < 2.5m)
|
if (GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value < 2.5m)
|
||||||
return SkinUtils.As<TValue>(new Bindable<float>(1));
|
return SkinUtils.As<TValue>(new Bindable<float>(1));
|
||||||
|
|
||||||
if (existing.HoldNoteLightWidth[maniaLookup.TargetColumn.Value] != 0)
|
if (existing.HoldNoteLightWidth[maniaLookup.TargetColumn.Value] != 0)
|
||||||
@ -318,15 +309,15 @@ namespace osu.Game.Skinning
|
|||||||
=> source.ImageLookups.TryGetValue(lookup, out var image) ? new Bindable<string>(image) : null;
|
=> source.ImageLookups.TryGetValue(lookup, out var image) ? new Bindable<string>(image) : null;
|
||||||
|
|
||||||
[CanBeNull]
|
[CanBeNull]
|
||||||
private IBindable<TValue> legacySettingLookup<TValue>(LegacySkinConfiguration.LegacySetting legacySetting)
|
private IBindable<TValue> legacySettingLookup<TValue>(SkinConfiguration.LegacySetting legacySetting)
|
||||||
{
|
{
|
||||||
switch (legacySetting)
|
switch (legacySetting)
|
||||||
{
|
{
|
||||||
case LegacySkinConfiguration.LegacySetting.Version:
|
case SkinConfiguration.LegacySetting.Version:
|
||||||
return SkinUtils.As<TValue>(new Bindable<decimal>(Configuration.LegacyVersion ?? LegacySkinConfiguration.LATEST_VERSION));
|
return SkinUtils.As<TValue>(new Bindable<decimal>(Configuration.LegacyVersion ?? SkinConfiguration.LATEST_VERSION));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return genericLookup<LegacySkinConfiguration.LegacySetting, TValue>(legacySetting);
|
return genericLookup<SkinConfiguration.LegacySetting, TValue>(legacySetting);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
// 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.
|
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
|
||||||
{
|
|
||||||
public class LegacySkinConfiguration : SkinConfiguration
|
|
||||||
{
|
|
||||||
public const decimal LATEST_VERSION = 2.7m;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Legacy version of this skin.
|
|
||||||
/// </summary>
|
|
||||||
public decimal? LegacyVersion { get; internal set; }
|
|
||||||
|
|
||||||
public enum LegacySetting
|
|
||||||
{
|
|
||||||
Version,
|
|
||||||
ComboPrefix,
|
|
||||||
ComboOverlap,
|
|
||||||
ScorePrefix,
|
|
||||||
ScoreOverlap,
|
|
||||||
HitCirclePrefix,
|
|
||||||
HitCircleOverlap,
|
|
||||||
AnimationFramerate,
|
|
||||||
LayeredHitSounds
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,14 +6,14 @@ using osu.Game.Beatmaps.Formats;
|
|||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
{
|
{
|
||||||
public class LegacySkinDecoder : LegacyDecoder<LegacySkinConfiguration>
|
public class LegacySkinDecoder : LegacyDecoder<SkinConfiguration>
|
||||||
{
|
{
|
||||||
public LegacySkinDecoder()
|
public LegacySkinDecoder()
|
||||||
: base(1)
|
: base(1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ParseLine(LegacySkinConfiguration skin, Section section, string line)
|
protected override void ParseLine(SkinConfiguration skin, Section section, string line)
|
||||||
{
|
{
|
||||||
if (section != Section.Colours)
|
if (section != Section.Colours)
|
||||||
{
|
{
|
||||||
@ -34,7 +34,7 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
case @"Version":
|
case @"Version":
|
||||||
if (pair.Value == "latest")
|
if (pair.Value == "latest")
|
||||||
skin.LegacyVersion = LegacySkinConfiguration.LATEST_VERSION;
|
skin.LegacyVersion = SkinConfiguration.LATEST_VERSION;
|
||||||
else if (decimal.TryParse(pair.Value, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var version))
|
else if (decimal.TryParse(pair.Value, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var version))
|
||||||
skin.LegacyVersion = version;
|
skin.LegacyVersion = version;
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ namespace osu.Game.Skinning
|
|||||||
base.ParseLine(skin, section, line);
|
base.ParseLine(skin, section, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override LegacySkinConfiguration CreateTemplateObject()
|
protected override SkinConfiguration CreateTemplateObject()
|
||||||
{
|
{
|
||||||
var config = base.CreateTemplateObject();
|
var config = base.CreateTemplateObject();
|
||||||
config.LegacyVersion = 1.0m;
|
config.LegacyVersion = 1.0m;
|
||||||
|
@ -12,7 +12,7 @@ using osu.Framework.Graphics.Animations;
|
|||||||
using osu.Framework.Graphics.OpenGL.Textures;
|
using osu.Framework.Graphics.OpenGL.Textures;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using static osu.Game.Skinning.LegacySkinConfiguration;
|
using static osu.Game.Skinning.SkinConfiguration;
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ using osu.Framework.Graphics.OpenGL.Textures;
|
|||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Rulesets.Objects.Legacy;
|
using osu.Game.Rulesets.Objects.Legacy;
|
||||||
using static osu.Game.Skinning.LegacySkinConfiguration;
|
using static osu.Game.Skinning.SkinConfiguration;
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
{
|
{
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -21,8 +23,9 @@ namespace osu.Game.Skinning
|
|||||||
public abstract class Skin : IDisposable, ISkin
|
public abstract class Skin : IDisposable, ISkin
|
||||||
{
|
{
|
||||||
public readonly SkinInfo SkinInfo;
|
public readonly SkinInfo SkinInfo;
|
||||||
|
private readonly IStorageResourceProvider resources;
|
||||||
|
|
||||||
public SkinConfiguration Configuration { get; protected set; }
|
public SkinConfiguration Configuration { get; set; }
|
||||||
|
|
||||||
public IDictionary<SkinnableTarget, SkinnableInfo[]> DrawableComponentInfo => drawableComponentInfo;
|
public IDictionary<SkinnableTarget, SkinnableInfo[]> DrawableComponentInfo => drawableComponentInfo;
|
||||||
|
|
||||||
@ -36,9 +39,17 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
public abstract IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup);
|
public abstract IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup);
|
||||||
|
|
||||||
protected Skin(SkinInfo skin, IStorageResourceProvider resources)
|
protected Skin(SkinInfo skin, IStorageResourceProvider resources, [CanBeNull] Stream configurationStream = null)
|
||||||
{
|
{
|
||||||
SkinInfo = skin;
|
SkinInfo = skin;
|
||||||
|
this.resources = resources;
|
||||||
|
|
||||||
|
configurationStream ??= getConfigurationStream();
|
||||||
|
|
||||||
|
if (configurationStream != null)
|
||||||
|
ParseConfigurationStream(configurationStream);
|
||||||
|
else
|
||||||
|
Configuration = new SkinConfiguration();
|
||||||
|
|
||||||
// we may want to move this to some kind of async operation in the future.
|
// we may want to move this to some kind of async operation in the future.
|
||||||
foreach (SkinnableTarget skinnableTarget in Enum.GetValues(typeof(SkinnableTarget)))
|
foreach (SkinnableTarget skinnableTarget in Enum.GetValues(typeof(SkinnableTarget)))
|
||||||
@ -73,6 +84,22 @@ namespace osu.Game.Skinning
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void ParseConfigurationStream(Stream stream)
|
||||||
|
{
|
||||||
|
using (LineBufferedReader reader = new LineBufferedReader(stream, true))
|
||||||
|
Configuration = new LegacySkinDecoder().Decode(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Stream getConfigurationStream()
|
||||||
|
{
|
||||||
|
var path = SkinInfo.Files.SingleOrDefault(f => f.Filename == "skin.ini")?.FileInfo.StoragePath;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(path))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return resources?.Files.GetStream(path);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove all stored customisations for the provided target.
|
/// Remove all stored customisations for the provided target.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -14,11 +14,31 @@ namespace osu.Game.Skinning
|
|||||||
{
|
{
|
||||||
public readonly SkinInfo SkinInfo = new SkinInfo();
|
public readonly SkinInfo SkinInfo = new SkinInfo();
|
||||||
|
|
||||||
|
public const decimal LATEST_VERSION = 2.7m;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether to allow <see cref="DefaultComboColours"/> as a fallback list for when no combo colours are provided.
|
/// Whether to allow <see cref="DefaultComboColours"/> as a fallback list for when no combo colours are provided.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal bool AllowDefaultComboColoursFallback = true;
|
internal bool AllowDefaultComboColoursFallback = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Legacy version of this skin.
|
||||||
|
/// </summary>
|
||||||
|
public decimal? LegacyVersion { get; internal set; }
|
||||||
|
|
||||||
|
public enum LegacySetting
|
||||||
|
{
|
||||||
|
Version,
|
||||||
|
ComboPrefix,
|
||||||
|
ComboOverlap,
|
||||||
|
ScorePrefix,
|
||||||
|
ScoreOverlap,
|
||||||
|
HitCirclePrefix,
|
||||||
|
HitCircleOverlap,
|
||||||
|
AnimationFramerate,
|
||||||
|
LayeredHitSounds
|
||||||
|
}
|
||||||
|
|
||||||
public static List<Color4> DefaultComboColours { get; } = new List<Color4>
|
public static List<Color4> DefaultComboColours { get; } = new List<Color4>
|
||||||
{
|
{
|
||||||
new Color4(255, 192, 0, 255),
|
new Color4(255, 192, 0, 255),
|
||||||
|
@ -183,7 +183,7 @@ namespace osu.Game.Skinning
|
|||||||
// By this point, the metadata in SkinInfo will be correct.
|
// By this point, the metadata in SkinInfo will be correct.
|
||||||
// Regardless of whether this is an import or not, let's write the skin.ini if non-existing or non-matching.
|
// Regardless of whether this is an import or not, let's write the skin.ini if non-existing or non-matching.
|
||||||
// This is (weirdly) done inside ComputeHash to avoid adding a new method to handle this case. After switching to realm it can be moved into another place.
|
// This is (weirdly) done inside ComputeHash to avoid adding a new method to handle this case. After switching to realm it can be moved into another place.
|
||||||
if (instance is LegacySkin && skinIniSourcedName != item.Name)
|
if (skinIniSourcedName != item.Name)
|
||||||
updateSkinIniMetadata(item);
|
updateSkinIniMetadata(item);
|
||||||
|
|
||||||
return base.ComputeHash(item, reader);
|
return base.ComputeHash(item, reader);
|
||||||
|
Reference in New Issue
Block a user