// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using System.ComponentModel; using osu.Framework.Extensions; using osu.Game.Rulesets; namespace osu.Game.Skinning { /// /// Represents a lookup of a collection of elements that make up a particular skinnable of the game. /// public class SkinComponentsContainerLookup : ISkinComponentLookup, IEquatable { /// /// The target area / layer of the game for which skin components will be returned. /// public readonly TargetArea Target; /// /// The ruleset for which skin components should be returned. /// A value means that returned components are global and should be applied for all rulesets. /// public readonly RulesetInfo? Ruleset; public SkinComponentsContainerLookup(TargetArea target, RulesetInfo? ruleset = null) { Target = target; Ruleset = ruleset; } public override string ToString() { if (Ruleset == null) return Target.GetDescription(); return $"{Target.GetDescription()} (\"{Ruleset.Name}\" only)"; } public bool Equals(SkinComponentsContainerLookup? other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Target == other.Target && (ReferenceEquals(Ruleset, other.Ruleset) || Ruleset?.Equals(other.Ruleset) == true); } public override bool Equals(object? obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; if (obj.GetType() != GetType()) return false; return Equals((SkinComponentsContainerLookup)obj); } public override int GetHashCode() { return HashCode.Combine((int)Target, Ruleset); } /// /// Represents a particular area or part of a game screen whose layout can be customised using the skin editor. /// public enum TargetArea { [Description("HUD")] MainHUDComponents, [Description("Song select")] SongSelect, [Description("Playfield")] Playfield } } }