1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 15:52:54 +08:00

Properly implement SkinConfiguration equality

This commit is contained in:
Craftplacer 2020-08-16 00:21:26 +02:00
parent 48bdbb0cfb
commit 434354c44c
2 changed files with 12 additions and 13 deletions

View File

@ -42,18 +42,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
sort(decodedAfterEncode.beatmap); sort(decodedAfterEncode.beatmap);
Assert.That(decodedAfterEncode.beatmap.Serialize(), Is.EqualTo(decoded.beatmap.Serialize())); Assert.That(decodedAfterEncode.beatmap.Serialize(), Is.EqualTo(decoded.beatmap.Serialize()));
Assert.IsTrue(decoded.beatmapSkin.Configuration.Equals(decodedAfterEncode.beatmapSkin.Configuration));
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]);
} }
private void sort(IBeatmap beatmap) private void sort(IBeatmap beatmap)

View File

@ -1,7 +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.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using osu.Game.Beatmaps.Formats; using osu.Game.Beatmaps.Formats;
using osuTK.Graphics; using osuTK.Graphics;
@ -10,7 +12,7 @@ namespace osu.Game.Skinning
/// <summary> /// <summary>
/// An empty skin configuration. /// An empty skin configuration.
/// </summary> /// </summary>
public class SkinConfiguration : IHasComboColours, IHasCustomColours public class SkinConfiguration : IHasComboColours, IHasCustomColours, IEquatable<SkinConfiguration>
{ {
public readonly SkinInfo SkinInfo = new SkinInfo(); 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 Dictionary<string, Color4> CustomColours { get; set; } = new Dictionary<string, Color4>();
public readonly Dictionary<string, string> ConfigDictionary = new Dictionary<string, string>(); 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);
}
} }
} }