Change frame header to use dictionary for compatibility

This commit is contained in:
Dean Herbert 2020-12-16 15:35:07 +09:00
parent 88b3bf06e8
commit 84a0770789
2 changed files with 6 additions and 27 deletions

View File

@ -4,8 +4,9 @@
#nullable enable
using System;
using System.Linq;
using System.Collections.Generic;
using Newtonsoft.Json;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
namespace osu.Game.Online.Spectator
@ -17,7 +18,7 @@ public class FrameHeader
public int MaxCombo { get; set; }
public StatisticPair[] Statistics { get; set; }
public Dictionary<HitResult, int> Statistics { get; set; }
/// <summary>
/// Construct header summary information from a point-in-time reference to a score which is actively being played.
@ -28,11 +29,12 @@ public FrameHeader(ScoreInfo score)
Combo = score.Combo;
MaxCombo = score.MaxCombo;
Statistics = score.Statistics.Select(kvp => new StatisticPair(kvp.Key, kvp.Value)).ToArray();
// copy for safety
Statistics = new Dictionary<HitResult, int>(score.Statistics);
}
[JsonConstructor]
public FrameHeader(int combo, int maxCombo, StatisticPair[] statistics)
public FrameHeader(int combo, int maxCombo, Dictionary<HitResult, int> statistics)
{
Combo = combo;
MaxCombo = maxCombo;

View File

@ -1,23 +0,0 @@
// 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 osu.Game.Rulesets.Scoring;
namespace osu.Game.Online.Spectator
{
[Serializable]
public struct StatisticPair
{
public HitResult Result;
public int Count;
public StatisticPair(HitResult result, int count)
{
Result = result;
Count = count;
}
public override string ToString() => $"{Result}=>{Count}";
}
}