mirror of
https://github.com/ppy/osu
synced 2025-01-10 08:09:40 +00:00
Properly implement SkinConfiguration equality
This commit is contained in:
parent
48bdbb0cfb
commit
434354c44c
@ -42,18 +42,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
sort(decodedAfterEncode.beatmap);
|
||||
|
||||
Assert.That(decodedAfterEncode.beatmap.Serialize(), Is.EqualTo(decoded.beatmap.Serialize()));
|
||||
|
||||
areSkinsEqual(decoded.beatmapSkin, decodedAfterEncode.beatmapSkin);
|
||||
}
|
||||
|
||||
private void areSkinsEqual(LegacySkin expected, LegacySkin actual)
|
||||
{
|
||||
var expectedColours = expected.Configuration.ComboColours;
|
||||
var actualColours = actual.Configuration.ComboColours;
|
||||
|
||||
Assert.AreEqual(expectedColours.Count, actualColours.Count);
|
||||
for (int i = 0; i < expectedColours.Count; i++)
|
||||
Assert.AreEqual(expectedColours[i], actualColours[i]);
|
||||
Assert.IsTrue(decoded.beatmapSkin.Configuration.Equals(decodedAfterEncode.beatmapSkin.Configuration));
|
||||
}
|
||||
|
||||
private void sort(IBeatmap beatmap)
|
||||
|
@ -1,7 +1,9 @@
|
||||
// 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.Linq;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -10,7 +12,7 @@ namespace osu.Game.Skinning
|
||||
/// <summary>
|
||||
/// An empty skin configuration.
|
||||
/// </summary>
|
||||
public class SkinConfiguration : IHasComboColours, IHasCustomColours
|
||||
public class SkinConfiguration : IHasComboColours, IHasCustomColours, IEquatable<SkinConfiguration>
|
||||
{
|
||||
public readonly SkinInfo SkinInfo = new SkinInfo();
|
||||
|
||||
@ -48,5 +50,13 @@ namespace osu.Game.Skinning
|
||||
public Dictionary<string, Color4> CustomColours { get; set; } = new Dictionary<string, Color4>();
|
||||
|
||||
public readonly Dictionary<string, string> ConfigDictionary = new Dictionary<string, string>();
|
||||
|
||||
public bool Equals(SkinConfiguration other)
|
||||
{
|
||||
return other != null &&
|
||||
ConfigDictionary.SequenceEqual(other.ConfigDictionary) &&
|
||||
ComboColours.SequenceEqual(other.ComboColours) &&
|
||||
CustomColours.SequenceEqual(other.CustomColours);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user