2023-02-16 18:58:04 +08:00
|
|
|
// 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;
|
2023-02-17 15:22:41 +08:00
|
|
|
using System.Linq;
|
2023-02-16 18:58:04 +08:00
|
|
|
using Newtonsoft.Json;
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
|
|
|
|
namespace osu.Game.Skinning
|
|
|
|
{
|
|
|
|
/// <summary>
|
2024-08-22 16:14:35 +08:00
|
|
|
/// A serialisable model describing layout of a <see cref="SkinnableContainer"/>.
|
|
|
|
/// May contain multiple configurations for different rulesets, each of which should manifest their own <see cref="SkinnableContainer"/> as required.
|
2023-02-16 18:58:04 +08:00
|
|
|
/// </summary>
|
|
|
|
[Serializable]
|
|
|
|
public class SkinLayoutInfo
|
|
|
|
{
|
2023-02-20 18:48:39 +08:00
|
|
|
private const string global_identifier = @"global";
|
2023-02-16 18:58:04 +08:00
|
|
|
|
2024-07-01 11:48:05 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Latest version representing the schema of the skin layout.
|
|
|
|
/// </summary>
|
|
|
|
/// <remarks>
|
|
|
|
/// <list type="bullet">
|
|
|
|
/// <item><description>0: Initial version of all skin layouts.</description></item>
|
|
|
|
/// <item><description>1: Moves existing combo counters from global to per-ruleset HUD targets.</description></item>
|
|
|
|
/// </list>
|
|
|
|
/// </remarks>
|
|
|
|
public const int LATEST_VERSION = 1;
|
|
|
|
|
|
|
|
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
|
|
|
|
public int Version = LATEST_VERSION;
|
2023-02-17 15:22:41 +08:00
|
|
|
|
2023-02-16 18:58:04 +08:00
|
|
|
[JsonProperty]
|
|
|
|
public Dictionary<string, SerialisedDrawableInfo[]> DrawableInfo { get; set; } = new Dictionary<string, SerialisedDrawableInfo[]>();
|
|
|
|
|
2024-07-01 11:48:05 +08:00
|
|
|
[JsonIgnore]
|
|
|
|
public IEnumerable<SerialisedDrawableInfo> AllDrawables => DrawableInfo.Values.SelectMany(v => v);
|
|
|
|
|
2023-02-17 14:00:57 +08:00
|
|
|
public bool TryGetDrawableInfo(RulesetInfo? ruleset, [NotNullWhen(true)] out SerialisedDrawableInfo[]? components) =>
|
2023-02-16 18:58:04 +08:00
|
|
|
DrawableInfo.TryGetValue(ruleset?.ShortName ?? global_identifier, out components);
|
|
|
|
|
2023-02-17 14:00:57 +08:00
|
|
|
public void Reset(RulesetInfo? ruleset) =>
|
2023-02-16 18:58:04 +08:00
|
|
|
DrawableInfo.Remove(ruleset?.ShortName ?? global_identifier);
|
|
|
|
|
2023-02-17 14:00:57 +08:00
|
|
|
public void Update(RulesetInfo? ruleset, SerialisedDrawableInfo[] components) =>
|
2023-02-16 18:58:04 +08:00
|
|
|
DrawableInfo[ruleset?.ShortName ?? global_identifier] = components;
|
|
|
|
}
|
|
|
|
}
|