mirror of
https://github.com/ppy/osu-tools.git
synced 2025-06-11 18:20:35 +09:00
Make simulate
download missing beatmaps
This commit is contained in:
parent
bf1aac3e48
commit
f87f0d996c
6 changed files with 63 additions and 35 deletions
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
@ -11,6 +12,7 @@ using Alba.CsConsoleFormat;
|
|||
using JetBrains.Annotations;
|
||||
using McMaster.Extensions.CommandLineUtils;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using osu.Framework.IO.Network;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
|
@ -21,10 +23,13 @@ namespace PerformanceCalculator.Simulate
|
|||
{
|
||||
public abstract class SimulateCommand : ProcessorCommand
|
||||
{
|
||||
public abstract string Beatmap { get; }
|
||||
|
||||
public abstract Ruleset Ruleset { get; }
|
||||
|
||||
[UsedImplicitly]
|
||||
[Required]
|
||||
[Argument(0, Name = "beatmap", Description = "Required. Can be either a path to beatmap file (.osu) or beatmap ID.")]
|
||||
public string Beatmap { get; set; }
|
||||
|
||||
[UsedImplicitly]
|
||||
public virtual double Accuracy { get; }
|
||||
|
||||
|
@ -59,6 +64,25 @@ namespace PerformanceCalculator.Simulate
|
|||
|
||||
var mods = getMods(ruleset).ToArray();
|
||||
|
||||
if (!Beatmap.EndsWith(".osu"))
|
||||
{
|
||||
if (!int.TryParse(Beatmap, out _))
|
||||
{
|
||||
Console.WriteLine("Incorrect beatmap ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
string cachePath = Path.Combine("cache", $"{Beatmap}.osu");
|
||||
|
||||
if (!File.Exists(cachePath))
|
||||
{
|
||||
Console.WriteLine($"Downloading {Beatmap}.osu...");
|
||||
new FileWebRequest(cachePath, $"https://osu.ppy.sh/osu/{Beatmap}").Perform();
|
||||
|
||||
Beatmap = cachePath;
|
||||
}
|
||||
}
|
||||
|
||||
var workingBeatmap = new ProcessorWorkingBeatmap(Beatmap);
|
||||
|
||||
var beatmap = workingBeatmap.GetPlayableBeatmap(ruleset.RulesetInfo, mods);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue