mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 11:12:54 +08:00
Import beatmaps into the database via IPC
This commit is contained in:
parent
3a163de0f7
commit
45c0bc5428
@ -20,7 +20,7 @@ namespace osu.Game.Beatmaps.IO
|
||||
foreach (var reader in readers)
|
||||
{
|
||||
if (reader.Test(storage, path))
|
||||
return (ArchiveReader)Activator.CreateInstance(reader.Type);
|
||||
return (ArchiveReader)Activator.CreateInstance(reader.Type, storage.GetStream(path));
|
||||
}
|
||||
throw new IOException("Unknown file format");
|
||||
}
|
||||
|
@ -13,12 +13,7 @@ namespace osu.Game.Beatmaps.IO
|
||||
AddReader<OszArchiveReader>((storage, path) =>
|
||||
{
|
||||
using (var stream = storage.GetStream(path))
|
||||
{
|
||||
if (!ZipFile.IsZipFile(stream, false))
|
||||
return false;
|
||||
using (ZipFile zip = ZipFile.Read(stream))
|
||||
return zip.Entries.Any(e => e.FileName.EndsWith(".osu"));
|
||||
}
|
||||
return ZipFile.IsZipFile(stream, false);
|
||||
});
|
||||
OsuLegacyDecoder.Register();
|
||||
}
|
||||
|
@ -18,7 +18,12 @@ namespace osu.Game.Beatmaps.Objects.Osu
|
||||
Circle = 1,
|
||||
Slider = 2,
|
||||
NewCombo = 4,
|
||||
CircleNewCombo = 5,
|
||||
SliderNewCombo = 6,
|
||||
Spinner = 8,
|
||||
ColourHax = 122,
|
||||
Hold = 128,
|
||||
ManiaLong = 128,
|
||||
}
|
||||
|
||||
public static OsuBaseHit Parse(string val)
|
||||
@ -26,6 +31,7 @@ namespace osu.Game.Beatmaps.Objects.Osu
|
||||
string[] split = val.Split(',');
|
||||
var type = (HitObjectType)int.Parse(split[3]);
|
||||
bool combo = type.HasFlag(HitObjectType.NewCombo);
|
||||
type &= (HitObjectType)0xF;
|
||||
type &= ~HitObjectType.NewCombo;
|
||||
OsuBaseHit result;
|
||||
switch (type)
|
||||
|
@ -21,6 +21,7 @@ using osu.Framework.Input;
|
||||
using osu.Game.Input;
|
||||
using OpenTK.Input;
|
||||
using System.IO;
|
||||
using osu.Game.Beatmaps.IO;
|
||||
|
||||
namespace osu.Game
|
||||
{
|
||||
@ -68,8 +69,21 @@ namespace osu.Game
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
BeatmapIPC.MessageReceived += (message) => Console.WriteLine($@"Got beatmap: {message.Path}");
|
||||
|
||||
BeatmapIPC.MessageReceived += message =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var reader = ArchiveReader.GetReader(Host.Storage, message.Path);
|
||||
Beatmaps.AddBeatmap(reader);
|
||||
// TODO: Switch to beatmap list and select the new song
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// TODO: Show the user some info?
|
||||
Console.WriteLine($@"Failed to import beatmap: {ex}");
|
||||
}
|
||||
};
|
||||
|
||||
base.Load(game);
|
||||
|
||||
//attach our bindables to the audio subsystem.
|
||||
|
Loading…
Reference in New Issue
Block a user