2022-11-09 07:03:29 +00: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.
|
|
|
|
|
2023-02-17 06:01:11 +00:00
|
|
|
using System;
|
|
|
|
using osu.Framework.Extensions;
|
2023-02-16 10:20:06 +00:00
|
|
|
using osu.Game.Rulesets;
|
|
|
|
|
2022-11-09 07:03:29 +00:00
|
|
|
namespace osu.Game.Skinning
|
|
|
|
{
|
2023-02-17 05:18:05 +00:00
|
|
|
/// <summary>
|
2024-08-22 09:39:36 +00:00
|
|
|
/// Represents a lookup of a collection of elements that make up a particular skinnable <see cref="GlobalSkinnableContainers"/> of the game.
|
2023-02-17 05:18:05 +00:00
|
|
|
/// </summary>
|
2024-08-22 09:39:36 +00:00
|
|
|
public class GlobalSkinnableContainerLookup : ISkinComponentLookup, IEquatable<GlobalSkinnableContainerLookup>
|
2022-11-09 07:03:29 +00:00
|
|
|
{
|
2023-02-17 05:18:05 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The target area / layer of the game for which skin components will be returned.
|
|
|
|
/// </summary>
|
2024-08-23 05:48:50 +00:00
|
|
|
public readonly GlobalSkinnableContainers Lookup;
|
2022-11-09 07:03:29 +00:00
|
|
|
|
2023-02-20 10:48:18 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The ruleset for which skin components should be returned.
|
|
|
|
/// A <see langword="null"/> value means that returned components are global and should be applied for all rulesets.
|
|
|
|
/// </summary>
|
2023-02-17 06:00:57 +00:00
|
|
|
public readonly RulesetInfo? Ruleset;
|
2023-02-16 10:20:06 +00:00
|
|
|
|
2024-08-23 05:48:50 +00:00
|
|
|
public GlobalSkinnableContainerLookup(GlobalSkinnableContainers lookup, RulesetInfo? ruleset = null)
|
2022-11-09 07:03:29 +00:00
|
|
|
{
|
2024-08-23 05:48:50 +00:00
|
|
|
Lookup = lookup;
|
2023-02-16 10:20:06 +00:00
|
|
|
Ruleset = ruleset;
|
2022-11-09 07:03:29 +00:00
|
|
|
}
|
|
|
|
|
2023-02-17 06:01:11 +00:00
|
|
|
public override string ToString()
|
|
|
|
{
|
2024-08-23 05:48:50 +00:00
|
|
|
if (Ruleset == null) return Lookup.GetDescription();
|
2023-02-17 06:01:11 +00:00
|
|
|
|
2024-08-23 05:48:50 +00:00
|
|
|
return $"{Lookup.GetDescription()} (\"{Ruleset.Name}\" only)";
|
2023-02-17 06:01:11 +00:00
|
|
|
}
|
|
|
|
|
2024-08-22 09:39:36 +00:00
|
|
|
public bool Equals(GlobalSkinnableContainerLookup? other)
|
2023-02-17 06:01:11 +00:00
|
|
|
{
|
|
|
|
if (ReferenceEquals(null, other)) return false;
|
|
|
|
if (ReferenceEquals(this, other)) return true;
|
|
|
|
|
2024-08-23 05:48:50 +00:00
|
|
|
return Lookup == other.Lookup && (ReferenceEquals(Ruleset, other.Ruleset) || Ruleset?.Equals(other.Ruleset) == true);
|
2023-02-17 06:01:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public override bool Equals(object? obj)
|
|
|
|
{
|
|
|
|
if (ReferenceEquals(null, obj)) return false;
|
|
|
|
if (ReferenceEquals(this, obj)) return true;
|
|
|
|
if (obj.GetType() != GetType()) return false;
|
|
|
|
|
2024-08-22 09:39:36 +00:00
|
|
|
return Equals((GlobalSkinnableContainerLookup)obj);
|
2023-02-17 06:01:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
{
|
2024-08-23 05:48:50 +00:00
|
|
|
return HashCode.Combine((int)Lookup, Ruleset);
|
2023-02-17 06:01:11 +00:00
|
|
|
}
|
2022-11-09 07:03:29 +00:00
|
|
|
}
|
|
|
|
}
|