mirror of
https://github.com/osukey/osukey.git
synced 2025-06-08 12:58:01 +09:00
Make room requests handler handle GetBeatmapRequest
This commit is contained in:
parent
da8d94c4b4
commit
1811647e34
@ -9,27 +9,25 @@ namespace osu.Game.Online.API.Requests
|
|||||||
{
|
{
|
||||||
public class GetBeatmapRequest : APIRequest<APIBeatmap>
|
public class GetBeatmapRequest : APIRequest<APIBeatmap>
|
||||||
{
|
{
|
||||||
private readonly IBeatmapInfo beatmapInfo;
|
public readonly IBeatmapInfo BeatmapInfo;
|
||||||
|
public readonly string Filename;
|
||||||
private readonly string filename;
|
|
||||||
|
|
||||||
public GetBeatmapRequest(IBeatmapInfo beatmapInfo)
|
public GetBeatmapRequest(IBeatmapInfo beatmapInfo)
|
||||||
{
|
{
|
||||||
this.beatmapInfo = beatmapInfo;
|
BeatmapInfo = beatmapInfo;
|
||||||
|
Filename = (beatmapInfo as BeatmapInfo)?.Path ?? string.Empty;
|
||||||
filename = (beatmapInfo as BeatmapInfo)?.Path ?? string.Empty;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override WebRequest CreateWebRequest()
|
protected override WebRequest CreateWebRequest()
|
||||||
{
|
{
|
||||||
var request = base.CreateWebRequest();
|
var request = base.CreateWebRequest();
|
||||||
|
|
||||||
if (beatmapInfo.OnlineID > 0)
|
if (BeatmapInfo.OnlineID > 0)
|
||||||
request.AddParameter(@"id", beatmapInfo.OnlineID.ToString());
|
request.AddParameter(@"id", BeatmapInfo.OnlineID.ToString());
|
||||||
if (!string.IsNullOrEmpty(beatmapInfo.MD5Hash))
|
if (!string.IsNullOrEmpty(BeatmapInfo.MD5Hash))
|
||||||
request.AddParameter(@"checksum", beatmapInfo.MD5Hash);
|
request.AddParameter(@"checksum", BeatmapInfo.MD5Hash);
|
||||||
if (!string.IsNullOrEmpty(filename))
|
if (!string.IsNullOrEmpty(Filename))
|
||||||
request.AddParameter(@"filename", filename);
|
request.AddParameter(@"filename", Filename);
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
@ -135,25 +135,15 @@ namespace osu.Game.Tests.Visual.OnlinePlay
|
|||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case GetBeatmapRequest getBeatmapRequest:
|
||||||
|
{
|
||||||
|
getBeatmapRequest.TriggerSuccess(createResponseBeatmaps(getBeatmapRequest.BeatmapInfo.OnlineID).Single());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
case GetBeatmapsRequest getBeatmapsRequest:
|
case GetBeatmapsRequest getBeatmapsRequest:
|
||||||
{
|
{
|
||||||
var result = new List<APIBeatmap>();
|
getBeatmapsRequest.TriggerSuccess(new GetBeatmapsResponse { Beatmaps = createResponseBeatmaps(getBeatmapsRequest.BeatmapIds.ToArray()) });
|
||||||
|
|
||||||
foreach (int id in getBeatmapsRequest.BeatmapIds)
|
|
||||||
{
|
|
||||||
var baseBeatmap = beatmapManager.QueryBeatmap(b => b.OnlineID == id);
|
|
||||||
|
|
||||||
if (baseBeatmap == null)
|
|
||||||
{
|
|
||||||
baseBeatmap = new TestBeatmap(new RulesetInfo { OnlineID = 0 }).BeatmapInfo;
|
|
||||||
baseBeatmap.OnlineID = id;
|
|
||||||
baseBeatmap.BeatmapSet!.OnlineID = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
result.Add(OsuTestScene.CreateAPIBeatmap(baseBeatmap));
|
|
||||||
}
|
|
||||||
|
|
||||||
getBeatmapsRequest.TriggerSuccess(new GetBeatmapsResponse { Beatmaps = result });
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,6 +165,27 @@ namespace osu.Game.Tests.Visual.OnlinePlay
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<APIBeatmap> createResponseBeatmaps(params int[] beatmapIds)
|
||||||
|
{
|
||||||
|
var result = new List<APIBeatmap>();
|
||||||
|
|
||||||
|
foreach (int id in beatmapIds)
|
||||||
|
{
|
||||||
|
var baseBeatmap = beatmapManager.QueryBeatmap(b => b.OnlineID == id);
|
||||||
|
|
||||||
|
if (baseBeatmap == null)
|
||||||
|
{
|
||||||
|
baseBeatmap = new TestBeatmap(new RulesetInfo { OnlineID = 0 }).BeatmapInfo;
|
||||||
|
baseBeatmap.OnlineID = id;
|
||||||
|
baseBeatmap.BeatmapSet!.OnlineID = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.Add(OsuTestScene.CreateAPIBeatmap(baseBeatmap));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user