mirror of
https://github.com/ppy/osu
synced 2024-12-26 08:53:10 +00:00
86a7f4dfd0
- It is entirely derived from `SkinLayoutInfo.DrawableInfo`, which is the actual primary thing we want to serialise. - It will never get read out from any serialised files anyway (corollary of the previous point - it is a get-only property derived from another). - It is only used in tests. All of the three reasons above make serialising the property out to skin files nothing more than a waste of space.
38 lines
1.5 KiB
C#
38 lines
1.5 KiB
C#
// 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 System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Linq;
|
|
using Newtonsoft.Json;
|
|
using osu.Game.Rulesets;
|
|
|
|
namespace osu.Game.Skinning
|
|
{
|
|
/// <summary>
|
|
/// A serialisable model describing layout of a <see cref="SkinComponentsContainer"/>.
|
|
/// May contain multiple configurations for different rulesets, each of which should manifest their own <see cref="SkinComponentsContainer"/> as required.
|
|
/// </summary>
|
|
[Serializable]
|
|
public class SkinLayoutInfo
|
|
{
|
|
private const string global_identifier = @"global";
|
|
|
|
[JsonIgnore]
|
|
public IEnumerable<SerialisedDrawableInfo> AllDrawables => DrawableInfo.Values.SelectMany(v => v);
|
|
|
|
[JsonProperty]
|
|
public Dictionary<string, SerialisedDrawableInfo[]> DrawableInfo { get; set; } = new Dictionary<string, SerialisedDrawableInfo[]>();
|
|
|
|
public bool TryGetDrawableInfo(RulesetInfo? ruleset, [NotNullWhen(true)] out SerialisedDrawableInfo[]? components) =>
|
|
DrawableInfo.TryGetValue(ruleset?.ShortName ?? global_identifier, out components);
|
|
|
|
public void Reset(RulesetInfo? ruleset) =>
|
|
DrawableInfo.Remove(ruleset?.ShortName ?? global_identifier);
|
|
|
|
public void Update(RulesetInfo? ruleset, SerialisedDrawableInfo[] components) =>
|
|
DrawableInfo[ruleset?.ShortName ?? global_identifier] = components;
|
|
}
|
|
}
|