mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 15:44:04 +09:00
Fix issues with data serialisation
This commit is contained in:
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using osu.Game.Replays.Legacy;
|
using osu.Game.Replays.Legacy;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
|
||||||
@ -22,5 +23,12 @@ namespace osu.Game.Online.Spectator
|
|||||||
Frames = frames;
|
Frames = frames;
|
||||||
Header = new FrameHeader(score);
|
Header = new FrameHeader(score);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonConstructor]
|
||||||
|
public FrameDataBundle(FrameHeader header, IEnumerable<LegacyReplayFrame> frames)
|
||||||
|
{
|
||||||
|
Header = header;
|
||||||
|
Frames = frames;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Linq;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using Newtonsoft.Json;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Online.Spectator
|
namespace osu.Game.Online.Spectator
|
||||||
@ -17,7 +17,7 @@ namespace osu.Game.Online.Spectator
|
|||||||
|
|
||||||
public int MaxCombo { get; set; }
|
public int MaxCombo { get; set; }
|
||||||
|
|
||||||
public Dictionary<HitResult, int> Statistics = new Dictionary<HitResult, int>();
|
public StatisticPair[] Statistics { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Construct header summary information from a point-in-time reference to a score which is actively being played.
|
/// Construct header summary information from a point-in-time reference to a score which is actively being played.
|
||||||
@ -28,8 +28,15 @@ namespace osu.Game.Online.Spectator
|
|||||||
Combo = score.Combo;
|
Combo = score.Combo;
|
||||||
MaxCombo = score.MaxCombo;
|
MaxCombo = score.MaxCombo;
|
||||||
|
|
||||||
foreach (var kvp in score.Statistics)
|
Statistics = score.Statistics.Select(kvp => new StatisticPair(kvp.Key, kvp.Value)).ToArray();
|
||||||
Statistics[kvp.Key] = kvp.Value;
|
}
|
||||||
|
|
||||||
|
[JsonConstructor]
|
||||||
|
public FrameHeader(int combo, int maxCombo, StatisticPair[] statistics)
|
||||||
|
{
|
||||||
|
Combo = combo;
|
||||||
|
MaxCombo = maxCombo;
|
||||||
|
Statistics = statistics;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
23
osu.Game/Online/Spectator/StatisticPair.cs
Normal file
23
osu.Game/Online/Spectator/StatisticPair.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// 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}";
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user