1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 10:22:56 +08:00

Merge pull request #5911 from peppy/fix-skin-configuration-fallback

Fix ruleset skins incorrectly providing configuration defaults
This commit is contained in:
Dean Herbert 2019-08-31 21:50:14 +09:00 committed by GitHub
commit 691b89ae19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 39 additions and 14 deletions

View File

@ -115,7 +115,7 @@ namespace osu.Game.Rulesets.Osu.Skinning
public SampleChannel GetSample(ISampleInfo sample) => null;
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration
=> configuration.Value is TConfiguration conf ? query.Invoke(conf) : default;
=> configuration.Value is TConfiguration conf ? query.Invoke(conf) : source.GetValue(query);
private bool hasFont(string fontName) => GetTexture($"{fontName}-0") != null;
}

View File

@ -13,7 +13,7 @@ namespace osu.Game.Skinning
public DefaultSkin()
: base(SkinInfo.Default)
{
Configuration = new SkinConfiguration();
Configuration = new DefaultSkinConfiguration();
}
public override Drawable GetDrawableComponent(string componentName) => null;

View File

@ -0,0 +1,28 @@
// 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.
using osuTK.Graphics;
namespace osu.Game.Skinning
{
/// <summary>
/// A skin configuration pre-populated with sane defaults.
/// </summary>
public class DefaultSkinConfiguration : SkinConfiguration
{
public DefaultSkinConfiguration()
{
HitCircleFont = "default";
ComboColours.AddRange(new[]
{
new Color4(17, 136, 170, 255),
new Color4(102, 136, 0, 255),
new Color4(204, 102, 0, 255),
new Color4(121, 9, 13, 255)
});
CursorExpand = true;
}
}
}

View File

@ -34,7 +34,7 @@ namespace osu.Game.Skinning
using (StreamReader reader = new StreamReader(stream))
Configuration = new LegacySkinDecoder().Decode(reader);
else
Configuration = new SkinConfiguration();
Configuration = new DefaultSkinConfiguration();
Samples = audioManager.GetSampleStore(storage);
Textures = new TextureStore(new TextureLoaderStore(storage));

View File

@ -5,14 +5,14 @@ using osu.Game.Beatmaps.Formats;
namespace osu.Game.Skinning
{
public class LegacySkinDecoder : LegacyDecoder<SkinConfiguration>
public class LegacySkinDecoder : LegacyDecoder<DefaultSkinConfiguration>
{
public LegacySkinDecoder()
: base(1)
{
}
protected override void ParseLine(SkinConfiguration skin, Section section, string line)
protected override void ParseLine(DefaultSkinConfiguration skin, Section section, string line)
{
line = StripComments(line);

View File

@ -7,21 +7,18 @@ using osuTK.Graphics;
namespace osu.Game.Skinning
{
/// <summary>
/// An empty skin configuration.
/// </summary>
public class SkinConfiguration : IHasComboColours, IHasCustomColours
{
public readonly SkinInfo SkinInfo = new SkinInfo();
public List<Color4> ComboColours { get; set; } = new List<Color4>
{
new Color4(17, 136, 170, 255),
new Color4(102, 136, 0, 255),
new Color4(204, 102, 0, 255),
new Color4(121, 9, 13, 255)
};
public List<Color4> ComboColours { get; set; } = new List<Color4>();
public Dictionary<string, Color4> CustomColours { get; set; } = new Dictionary<string, Color4>();
public string HitCircleFont { get; set; } = "default";
public string HitCircleFont { get; set; }
public int HitCircleOverlap { get; set; }
@ -29,6 +26,6 @@ namespace osu.Game.Skinning
public float? SliderPathRadius { get; set; }
public bool? CursorExpand { get; set; } = true;
public bool? CursorExpand { get; set; }
}
}