Initial support code for beatmap loading

This commit is contained in:
Drew DeVault
2016-10-04 16:29:08 -04:00
parent 768c3bc31e
commit bc69aa1455
11 changed files with 274 additions and 6 deletions

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.IO;
namespace osu.Game.Beatmaps.Formats
{
public abstract class BeatmapDecoder
{
private static Dictionary<string, Type> Decoders { get; set; } = new Dictionary<string, Type>();
public static BeatmapDecoder GetDecoder(TextReader stream)
{
var line = stream.ReadLine().Trim();
if (!Decoders.ContainsKey(line))
throw new IOException("Unknown file format");
return (BeatmapDecoder)Activator.CreateInstance(Decoders[line]);
}
protected static void AddDecoder<T>(string magic) where T : BeatmapDecoder
{
Decoders[magic] = typeof(T);
}
public abstract Beatmap Decode(TextReader stream);
}