mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 02:43:19 +08:00
Add IEquatable
and ToString
support to SkinComponentsContainerLookup
This commit is contained in:
parent
a01c3090e4
commit
c03b6cec23
@ -1,6 +1,9 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// 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;
|
using osu.Game.Rulesets;
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
@ -8,7 +11,7 @@ namespace osu.Game.Skinning
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a lookup of a collection of elements that make up a particular skinnable <see cref="TargetArea"/> of the game.
|
/// Represents a lookup of a collection of elements that make up a particular skinnable <see cref="TargetArea"/> of the game.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SkinComponentsContainerLookup : ISkinComponentLookup
|
public class SkinComponentsContainerLookup : ISkinComponentLookup, IEquatable<SkinComponentsContainerLookup>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The target area / layer of the game for which skin components will be returned.
|
/// The target area / layer of the game for which skin components will be returned.
|
||||||
@ -25,12 +28,44 @@ namespace osu.Game.Skinning
|
|||||||
Ruleset = ruleset;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a particular area or part of a game screen whose layout can be customised using the skin editor.
|
/// Represents a particular area or part of a game screen whose layout can be customised using the skin editor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum TargetArea
|
public enum TargetArea
|
||||||
{
|
{
|
||||||
|
[Description("HUD")]
|
||||||
MainHUDComponents,
|
MainHUDComponents,
|
||||||
|
|
||||||
|
[Description("Song select")]
|
||||||
SongSelect
|
SongSelect
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user