1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-22 21:00:33 +08:00

Use APIMod for mod serialization

This commit is contained in:
Dean Herbert 2020-10-22 17:38:16 +09:00
parent 0611b30258
commit c834aa6051
3 changed files with 13 additions and 8 deletions

View File

@ -53,5 +53,13 @@ namespace osu.Game.Online.API
}
public bool Equals(IMod other) => Acronym == other?.Acronym;
public override string ToString()
{
if (Settings.Count > 0)
return $"{Acronym} ({string.Join(',', Settings.Select(kvp => $"{kvp.Key}:{kvp.Value}"))})";
return $"{Acronym}";
}
}
}

View File

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using osu.Game.Online.API;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Online.Spectator
@ -12,21 +13,17 @@ namespace osu.Game.Online.Spectator
public int? BeatmapID { get; set; }
[NotNull]
public IEnumerable<Mod> Mods { get; set; } = Enumerable.Empty<Mod>();
public IEnumerable<APIMod> Mods { get; set; } = Enumerable.Empty<APIMod>();
public SpectatorState(int? beatmapId = null, IEnumerable<Mod> mods = null)
public SpectatorState(int? beatmapId = null, IEnumerable<APIMod> mods = null)
{
BeatmapID = beatmapId;
if (mods != null)
Mods = mods;
}
public SpectatorState()
{
}
public bool Equals(SpectatorState other) => this.BeatmapID == other?.BeatmapID && this.Mods.SequenceEqual(other?.Mods);
public override string ToString() => $"Beatmap:{BeatmapID} Mods:{string.Join(',', Mods.SelectMany(m => m.Acronym))}";
public override string ToString() => $"Beatmap:{BeatmapID} Mods:{string.Join(',', Mods)}";
}
}

View File

@ -154,7 +154,7 @@ namespace osu.Game.Online.Spectator
// transfer state at point of beginning play
currentState.BeatmapID = beatmap.Value.BeatmapInfo.OnlineBeatmapID;
currentState.Mods = mods.Value.ToArray();
currentState.Mods = mods.Value.Select(m => new APIMod(m));
connection.SendAsync(nameof(ISpectatorServer.BeginPlaySession), currentState);
}