2021-01-03 04:21:50 +03:00
|
|
|
// 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.
|
|
|
|
|
2022-06-17 16:37:17 +09:00
|
|
|
#nullable disable
|
|
|
|
|
2021-01-03 04:21:50 +03:00
|
|
|
using System;
|
2021-01-26 16:26:03 +09:00
|
|
|
using MessagePack;
|
2021-01-11 08:02:57 +03:00
|
|
|
using Newtonsoft.Json;
|
2021-01-03 04:21:50 +03:00
|
|
|
|
|
|
|
namespace osu.Game.Online.Rooms
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// The local availability information about a certain beatmap for the client.
|
|
|
|
/// </summary>
|
2021-01-26 16:26:03 +09:00
|
|
|
[MessagePackObject]
|
2021-01-03 18:34:11 +03:00
|
|
|
public class BeatmapAvailability : IEquatable<BeatmapAvailability>
|
2021-01-03 04:21:50 +03:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// The beatmap's availability state.
|
|
|
|
/// </summary>
|
2021-01-26 16:26:03 +09:00
|
|
|
[Key(0)]
|
2021-01-03 04:21:50 +03:00
|
|
|
public readonly DownloadState State;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The beatmap's downloading progress, null when not in <see cref="DownloadState.Downloading"/> state.
|
|
|
|
/// </summary>
|
2021-02-01 17:27:14 +09:00
|
|
|
[Key(1)]
|
2021-01-17 21:16:45 +03:00
|
|
|
public readonly float? DownloadProgress;
|
2021-01-03 04:21:50 +03:00
|
|
|
|
2021-01-11 08:02:57 +03:00
|
|
|
[JsonConstructor]
|
2021-02-02 17:45:07 +03:00
|
|
|
public BeatmapAvailability(DownloadState state, float? downloadProgress = null)
|
2021-01-03 04:21:50 +03:00
|
|
|
{
|
|
|
|
State = state;
|
|
|
|
DownloadProgress = downloadProgress;
|
|
|
|
}
|
|
|
|
|
2021-01-11 08:04:00 +03:00
|
|
|
public static BeatmapAvailability NotDownloaded() => new BeatmapAvailability(DownloadState.NotDownloaded);
|
2021-01-17 21:16:45 +03:00
|
|
|
public static BeatmapAvailability Downloading(float progress) => new BeatmapAvailability(DownloadState.Downloading, progress);
|
2021-01-13 22:34:48 +03:00
|
|
|
public static BeatmapAvailability Importing() => new BeatmapAvailability(DownloadState.Importing);
|
2021-01-03 18:34:58 +03:00
|
|
|
public static BeatmapAvailability LocallyAvailable() => new BeatmapAvailability(DownloadState.LocallyAvailable);
|
|
|
|
|
2021-01-03 18:34:11 +03:00
|
|
|
public bool Equals(BeatmapAvailability other) => other != null && State == other.State && DownloadProgress == other.DownloadProgress;
|
2021-01-03 04:21:50 +03:00
|
|
|
|
|
|
|
public override string ToString() => $"{string.Join(", ", State, $"{DownloadProgress:0.00%}")}";
|
|
|
|
}
|
|
|
|
}
|