Remove extensions.
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9bd9e24d7c553341a2a12391843542f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,189 +0,0 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Math;
|
||||
using Cryville.Crtr.Browsing;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
namespace Cryville.Crtr.Extensions.Bestdori {
|
||||
public class BestdoriChartConverter : ResourceConverter {
|
||||
static readonly string[] SUPPORTED_FORMATS = { ".bestdori" };
|
||||
public override string[] GetSupportedFormats() {
|
||||
return SUPPORTED_FORMATS;
|
||||
}
|
||||
|
||||
public override IEnumerable<Resource> ConvertFrom(FileInfo file) {
|
||||
List<Resource> result = new List<Resource>();
|
||||
List<BestdoriChartEvent> src;
|
||||
using (var reader = new StreamReader(file.FullName)) {
|
||||
src = JsonConvert.DeserializeObject<List<BestdoriChartEvent>>(reader.ReadToEnd());
|
||||
}
|
||||
var group = new Chart.Group() {
|
||||
tracks = new List<Chart.Track>(),
|
||||
notes = new List<Chart.Note>(),
|
||||
motions = new List<Chart.Motion>(),
|
||||
};
|
||||
Chart chart = new Chart {
|
||||
format = 2,
|
||||
time = new BeatTime(0, 0, 1),
|
||||
ruleset = "bang_dream_girls_band_party",
|
||||
sigs = new List<Chart.Signature>(),
|
||||
sounds = new List<Chart.Sound>(),
|
||||
motions = new List<Chart.Motion>(),
|
||||
groups = new List<Chart.Group> { group },
|
||||
};
|
||||
var tm = new BeatTimeTimingModel();
|
||||
string bgm = null;
|
||||
double endbeat = 0;
|
||||
foreach (var ev in src) {
|
||||
tm.ForwardTo(ev.StartBeat);
|
||||
if (ev.StartBeat > endbeat) endbeat = ev.StartBeat;
|
||||
if (ev is BestdoriChartEvent.System) {
|
||||
if (bgm != null) continue;
|
||||
var tev = (BestdoriChartEvent.System)ev;
|
||||
bgm = StringUtils.TrimExt(tev.data);
|
||||
var name = "bang_dream_girls_band_party__" + bgm;
|
||||
result.Add(new SongResource(name, new FileInfo(Path.Combine(file.Directory.FullName, tev.data))));
|
||||
chart.sounds.Add(new Chart.Sound { time = ToBeatTime(tev.beat), id = name });
|
||||
}
|
||||
else if (ev is BestdoriChartEvent.BPM) {
|
||||
var tev = (BestdoriChartEvent.BPM)ev;
|
||||
tm.BPM = tev.bpm;
|
||||
chart.sigs.Add(new Chart.Signature { time = ToBeatTime(tev.beat), tempo = (float)tev.bpm });
|
||||
}
|
||||
else if (ev is BestdoriChartEvent.Single) {
|
||||
var tev = (BestdoriChartEvent.Single)ev;
|
||||
group.notes.Add(new Chart.Note {
|
||||
time = ToBeatTime(tev.beat),
|
||||
judges = new List<Chart.Judge> { new Chart.Judge { name = tev.flick ? "single_flick" : "single" } },
|
||||
motions = new List<Chart.Motion> { new Chart.Motion { motion = "track:" + tev.lane.ToString(CultureInfo.InvariantCulture) } },
|
||||
});
|
||||
}
|
||||
else if (ev is BestdoriChartEvent.Long) {
|
||||
var tev = (BestdoriChartEvent.Long)ev;
|
||||
var c1 = tev.connections[tev.connections.Count - 1];
|
||||
var note = new Chart.Note {
|
||||
time = ToBeatTime(tev.connections[0].beat),
|
||||
endtime = ToBeatTime(c1.beat),
|
||||
judges = new List<Chart.Judge>(),
|
||||
};
|
||||
for (int i = 0; i < tev.connections.Count; i++) {
|
||||
BestdoriChartEvent.Connection c = tev.connections[i];
|
||||
var motion = new Chart.Motion { motion = "track:" + c.lane.ToString(CultureInfo.InvariantCulture) };
|
||||
if (i == 0) {
|
||||
note.judges.Add(new Chart.Judge { name = "single" });
|
||||
note.motions.Add(motion);
|
||||
}
|
||||
else {
|
||||
var cbeat = motion.endtime = ToBeatTime(c.beat);
|
||||
if (i > 1) motion.time = ToBeatTime(tev.connections[i - 1].beat);
|
||||
note.motions.Add(motion);
|
||||
if (i == tev.connections.Count - 1)
|
||||
note.judges.Add(new Chart.Judge { time = cbeat, name = c.flick ? "longend_flick" : "longend" });
|
||||
else if (!c.hidden)
|
||||
note.judges.Add(new Chart.Judge { time = cbeat, name = "longnode" });
|
||||
}
|
||||
}
|
||||
if (c1.beat > endbeat) endbeat = c1.beat;
|
||||
group.notes.Add(note);
|
||||
}
|
||||
else throw new NotImplementedException("Unsupported event: " + ev.type);
|
||||
}
|
||||
if (bgm == null) throw new FormatException("Chart contains no song");
|
||||
chart.endtime = ToBeatTime(endbeat + 4);
|
||||
if (endbeat > tm.BeatTime) tm.ForwardTo(endbeat);
|
||||
result.Add(new RawChartResource(string.Format("bang_dream_girls_band_party__{0}__{1}", bgm, StringUtils.TrimExt(file.Name)), chart, new ChartMeta {
|
||||
name = string.Format("Bandori {0} {1}", bgm, StringUtils.TrimExt(file.Name)),
|
||||
author = "©BanG Dream! Project ©Craft Egg Inc. ©bushiroad",
|
||||
ruleset = "bang_dream_girls_band_party",
|
||||
note_count = group.notes.Count,
|
||||
length = (float)tm.Time,
|
||||
song = new SongMetaInfo {
|
||||
name = bgm,
|
||||
author = "©BanG Dream! Project ©Craft Egg Inc. ©bushiroad",
|
||||
}
|
||||
}));
|
||||
return result;
|
||||
}
|
||||
|
||||
BeatTime ToBeatTime(double beat, double error = 1e-4) {
|
||||
int i, n, d;
|
||||
FractionUtils.ToFraction(beat, error, out n, out d);
|
||||
i = n / d; n %= d;
|
||||
return new BeatTime(i, n, d);
|
||||
}
|
||||
|
||||
#pragma warning disable IDE1006
|
||||
[JsonConverter(typeof(BestdoriChartEventCreator))]
|
||||
abstract class BestdoriChartEvent {
|
||||
public abstract string type { get; }
|
||||
public abstract double StartBeat { get; }
|
||||
public abstract class InstantEvent : BestdoriChartEvent {
|
||||
public double beat;
|
||||
public override double StartBeat { get { return beat; } }
|
||||
}
|
||||
public class BPM : InstantEvent {
|
||||
public override string type { get { return "BPM"; } }
|
||||
public double bpm;
|
||||
}
|
||||
public class System : InstantEvent {
|
||||
public override string type { get { return "System"; } }
|
||||
public string data;
|
||||
}
|
||||
public abstract class SingleBase : InstantEvent {
|
||||
public double lane;
|
||||
public bool skill;
|
||||
public bool flick;
|
||||
}
|
||||
public class Single : SingleBase {
|
||||
public override string type { get { return "Single"; } }
|
||||
}
|
||||
public class Directional : SingleBase {
|
||||
public override string type { get { return "Directional"; } }
|
||||
public string direction;
|
||||
public int width;
|
||||
}
|
||||
public class Connection : SingleBase {
|
||||
public override string type { get { return null; } }
|
||||
public bool hidden;
|
||||
}
|
||||
public class Long : BestdoriChartEvent {
|
||||
public override string type { get { return "Long"; } }
|
||||
public List<Connection> connections;
|
||||
public override double StartBeat { get { return connections[0].beat; } }
|
||||
}
|
||||
public class Slide : Long {
|
||||
public override string type { get { return "Slide"; } }
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE1006
|
||||
class BestdoriChartEventCreator : CustomCreationConverter<BestdoriChartEvent> {
|
||||
string _currentType;
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
|
||||
var obj = JObject.ReadFrom(reader);
|
||||
var type = obj["type"];
|
||||
if (type == null) _currentType = null;
|
||||
else _currentType = obj["type"].ToObject<string>();
|
||||
return base.ReadJson(obj.CreateReader(), objectType, existingValue, serializer);
|
||||
}
|
||||
|
||||
public override BestdoriChartEvent Create(Type objectType) {
|
||||
switch (_currentType) {
|
||||
case "BPM": return new BestdoriChartEvent.BPM();
|
||||
case "System": return new BestdoriChartEvent.System();
|
||||
case "Single": return new BestdoriChartEvent.Single();
|
||||
case "Directional": return new BestdoriChartEvent.Directional();
|
||||
case null: return new BestdoriChartEvent.Connection();
|
||||
case "Long": return new BestdoriChartEvent.Long();
|
||||
case "Slide": return new BestdoriChartEvent.Slide();
|
||||
default: throw new ArgumentException("Unknown event type: " + _currentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e3c5a8bf05d5e284ba498e91cb0dd35e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,27 +0,0 @@
|
||||
using Cryville.Crtr.Browsing;
|
||||
using Cryville.Crtr.Extensions.Bestdori;
|
||||
using Cryville.Crtr.Extensions.Malody;
|
||||
using Cryville.Crtr.Extensions.osu;
|
||||
using Cryville.Crtr.Extensions.Quaver;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Cryville.Crtr.Extensions {
|
||||
public class Extensions : ExtensionInterface {
|
||||
public override IEnumerable<ResourceConverter> GetResourceConverters() {
|
||||
return new ResourceConverter[] {
|
||||
new BestdoriChartConverter(),
|
||||
new MalodyChartConverter(),
|
||||
new osuChartConverter(),
|
||||
new QuaverChartConverter(),
|
||||
};
|
||||
}
|
||||
|
||||
public override IEnumerable<LocalResourceFinder> GetResourceFinders() {
|
||||
return new LocalResourceFinder[] {
|
||||
new MalodyChartFinder(),
|
||||
new osuChartFinder(),
|
||||
new QuaverChartFinder(),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23377bf2926d93a4b8e3f3ab6040c7f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dfd44d1c0681e4842a1f031556519042
|
||||
folderAsset: yes
|
||||
timeCreated: 1637936550
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,225 +0,0 @@
|
||||
using Cryville.Crtr.Browsing;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace Cryville.Crtr.Extensions.Malody {
|
||||
public class MalodyChartConverter : ResourceConverter {
|
||||
static readonly string[] SUPPORTED_FORMATS = { ".mc", ".mcz" };
|
||||
static readonly string[] MODES = { "key", "step", "dj", "catch", "pad", "taiko", "ring", "slide", "live" };
|
||||
|
||||
public override string[] GetSupportedFormats() {
|
||||
return SUPPORTED_FORMATS;
|
||||
}
|
||||
|
||||
public override IEnumerable<Resource> ConvertFrom(FileInfo file) {
|
||||
List<Resource> result = new List<Resource>();
|
||||
MalodyChart src;
|
||||
if (file.Extension != ".mc") throw new NotImplementedException("mcz file is not supported yet");
|
||||
using (var reader = new StreamReader(file.FullName)) {
|
||||
src = JsonConvert.DeserializeObject<MalodyChart>(reader.ReadToEnd());
|
||||
}
|
||||
if (src.meta.mode != 0) throw new NotImplementedException(string.Format("{0} mode is not supported yet", MODES[src.meta.mode]));
|
||||
|
||||
var ruleset = "malody!" + MODES[src.meta.mode];
|
||||
if (src.meta.mode == 0) {
|
||||
ruleset += "." + src.meta.mode_ext.column.ToString(CultureInfo.InvariantCulture) + "k";
|
||||
}
|
||||
|
||||
ChartMeta meta = new ChartMeta() {
|
||||
name = src.meta.version,
|
||||
author = src.meta.creator,
|
||||
song = new SongMetaInfo() {
|
||||
name = src.meta.song.titleorg != null ? src.meta.song.titleorg : src.meta.song.title,
|
||||
author = src.meta.song.artistorg != null ? src.meta.song.artistorg : src.meta.song.artist,
|
||||
},
|
||||
ruleset = ruleset,
|
||||
};
|
||||
|
||||
Chart chart = new Chart {
|
||||
format = 2,
|
||||
time = new BeatTime(-4, 0, 1),
|
||||
ruleset = ruleset,
|
||||
sigs = new List<Chart.Signature>(),
|
||||
sounds = new List<Chart.Sound>(),
|
||||
motions = new List<Chart.Motion>(),
|
||||
groups = new List<Chart.Group>(),
|
||||
};
|
||||
var group = new Chart.Group() {
|
||||
tracks = new List<Chart.Track>(),
|
||||
notes = new List<Chart.Note>(),
|
||||
motions = new List<Chart.Motion>(),
|
||||
};
|
||||
chart.groups.Add(group);
|
||||
int col = src.meta.mode_ext.column;
|
||||
|
||||
IEnumerable<MalodyChart.IEvent> events = src.time.Cast<MalodyChart.IEvent>();
|
||||
if (src.effect != null) events = events.Concat(src.effect.Cast<MalodyChart.IEvent>());
|
||||
events = events.Concat(src.note.Cast<MalodyChart.IEvent>());
|
||||
List<MalodyChart.IEvent> endEvents = new List<MalodyChart.IEvent>();
|
||||
foreach (var ev in events)
|
||||
if (ev.endbeat != null)
|
||||
endEvents.Add(new MalodyChart.EndEvent {
|
||||
beat = ev.endbeat,
|
||||
StartEvent = ev,
|
||||
});
|
||||
events = events.Concat(endEvents)
|
||||
.OrderBy(e => e.beat[0] + (float)e.beat[1] / e.beat[2])
|
||||
.ThenBy(e => e.Priority);
|
||||
|
||||
Dictionary<MalodyChart.IEvent, StartEventState> longEvents
|
||||
= new Dictionary<MalodyChart.IEvent, StartEventState>();
|
||||
|
||||
float? baseBpm = null;
|
||||
var tm = new FractionalBeatTimeTimingModel();
|
||||
foreach (var ev in events) {
|
||||
var beat = new BeatTime(ev.beat[0], ev.beat[1], ev.beat[2]);
|
||||
tm.ForwardTo(beat);
|
||||
if (ev is MalodyChart.Time) {
|
||||
var tev = (MalodyChart.Time)ev;
|
||||
if (baseBpm == null) baseBpm = tev.bpm;
|
||||
tm.BPM = tev.bpm;
|
||||
chart.sigs.Add(new Chart.Signature {
|
||||
time = beat,
|
||||
tempo = tev.bpm,
|
||||
});
|
||||
chart.motions.Add(new Chart.Motion {
|
||||
time = beat,
|
||||
motion = "svm:" + (tev.bpm / baseBpm.Value).ToString(CultureInfo.InvariantCulture)
|
||||
});
|
||||
}
|
||||
else if (ev is MalodyChart.Effect) {
|
||||
var tev = (MalodyChart.Effect)ev;
|
||||
if (tev.scroll != null) group.motions.Add(new Chart.Motion {
|
||||
time = beat,
|
||||
motion = "svm:" + tev.scroll.Value.ToString(CultureInfo.InvariantCulture)
|
||||
});
|
||||
}
|
||||
else if (ev is MalodyChart.Note) {
|
||||
var tev = (MalodyChart.Note)ev;
|
||||
if (tev.type == 1) {
|
||||
if (tev.beat[0] == 0 && tev.beat[1] == 0) {
|
||||
var res = new SongResource(meta.song.name, new FileInfo(file.DirectoryName + "/" + tev.sound));
|
||||
result.Add(res);
|
||||
chart.sounds.Add(new Chart.Sound {
|
||||
time = new BeatTime(0, 0, 1),
|
||||
id = res.Name,
|
||||
offset = -tev.offset / 1000f,
|
||||
});
|
||||
}
|
||||
else throw new NotImplementedException("Key sounds are not supported yet");
|
||||
}
|
||||
else {
|
||||
var rn = new Chart.Note() {
|
||||
time = beat,
|
||||
motions = new List<Chart.Motion> {
|
||||
new Chart.Motion() { motion = "track:" + tev.column.ToString(CultureInfo.InvariantCulture) }
|
||||
},
|
||||
};
|
||||
if (tev.endbeat != null) {
|
||||
rn.endtime = new BeatTime(tev.endbeat[0], tev.endbeat[1], tev.endbeat[2]);
|
||||
longEvents.Add(ev, new StartEventState {
|
||||
Destination = rn,
|
||||
Time = tm.Time,
|
||||
});
|
||||
}
|
||||
group.notes.Add(rn);
|
||||
}
|
||||
}
|
||||
else if (ev is MalodyChart.EndEvent) {
|
||||
var tev = (MalodyChart.EndEvent)ev;
|
||||
if (tev.StartEvent is MalodyChart.Note) {
|
||||
var sev = tev.StartEvent;
|
||||
longEvents.Remove(sev);
|
||||
}
|
||||
else throw new NotSupportedException("Unrecognized long event");
|
||||
}
|
||||
else throw new NotSupportedException("Unrecognized event");
|
||||
}
|
||||
var endbeat = tm.FractionalBeatTime;
|
||||
endbeat.b += 4;
|
||||
chart.endtime = endbeat;
|
||||
meta.length = (float)tm.Time;
|
||||
meta.note_count = group.notes.Count;
|
||||
string chartName = string.Format("{0} - {1}", meta.song.name, meta.name);
|
||||
if (src.meta.background != null) {
|
||||
meta.cover = src.meta.background;
|
||||
}
|
||||
result.Add(new RawChartResource(chartName, chart, meta));
|
||||
return result;
|
||||
}
|
||||
|
||||
struct StartEventState {
|
||||
public double Time { get; set; }
|
||||
public ChartEvent Destination { get; set; }
|
||||
}
|
||||
|
||||
#pragma warning disable IDE1006
|
||||
struct MalodyChart {
|
||||
public interface IEvent {
|
||||
int[] beat { get; set; }
|
||||
int[] endbeat { get; set; }
|
||||
int Priority { get; }
|
||||
}
|
||||
public struct EndEvent : IEvent {
|
||||
public int[] beat { get; set; }
|
||||
public int[] endbeat { get; set; }
|
||||
public IEvent StartEvent { get; set; }
|
||||
public int Priority { get { return StartEvent.Priority - 1; } }
|
||||
}
|
||||
|
||||
public Meta meta;
|
||||
public struct Meta {
|
||||
public SongInfo song;
|
||||
public struct SongInfo {
|
||||
public string title;
|
||||
public string artist;
|
||||
public string titleorg;
|
||||
public string artistorg;
|
||||
}
|
||||
|
||||
public string background;
|
||||
|
||||
public string creator;
|
||||
public string version;
|
||||
|
||||
public int mode;
|
||||
public ModeExt mode_ext;
|
||||
public struct ModeExt {
|
||||
public int column;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Time> time;
|
||||
public struct Time : IEvent {
|
||||
public int[] beat { get; set; }
|
||||
public int[] endbeat { get; set; }
|
||||
public float bpm;
|
||||
public int Priority { get { return -2; } }
|
||||
}
|
||||
|
||||
public List<Effect> effect;
|
||||
public struct Effect : IEvent {
|
||||
public int[] beat { get; set; }
|
||||
public int[] endbeat { get; set; }
|
||||
public float? scroll;
|
||||
public int Priority { get { return 0; } }
|
||||
}
|
||||
|
||||
public List<Note> note;
|
||||
public struct Note : IEvent {
|
||||
public int[] beat { get; set; }
|
||||
public int[] endbeat { get; set; }
|
||||
public int column;
|
||||
public string sound;
|
||||
public int offset;
|
||||
public int type;
|
||||
public int Priority { get { return 0; } }
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE1006
|
||||
}
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b3624013a6911ba45933085332724ff1
|
||||
timeCreated: 1637936498
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,47 +0,0 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Crtr.Browsing;
|
||||
using Microsoft.Win32;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Cryville.Crtr.Extensions.Malody {
|
||||
public class MalodyChartFinder : LocalResourceFinder {
|
||||
public override string Name { get { return "Malody beatmaps"; } }
|
||||
|
||||
public override string GetRootPath() {
|
||||
var malodyDataPath = GetMalodyDataPath();
|
||||
var malodyConfigPath = Path.Combine(malodyDataPath, "config.json");
|
||||
if (File.Exists(malodyConfigPath)) {
|
||||
using (var reader = new StreamReader(malodyConfigPath, Encoding.UTF8)) {
|
||||
var config = JsonConvert.DeserializeObject<Dictionary<string, object>>(reader.ReadToEnd());
|
||||
object userPath;
|
||||
if (config.TryGetValue("user_chart_path", out userPath)) {
|
||||
var strUserPath = userPath as string;
|
||||
if (!string.IsNullOrEmpty(strUserPath)) {
|
||||
return strUserPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Path.Combine(malodyDataPath, "beatmap");
|
||||
}
|
||||
|
||||
string GetMalodyDataPath() {
|
||||
switch (Environment.OSVersion.Platform) {
|
||||
case PlatformID.Unix:
|
||||
return "/storage/emulated/0/data/malody";
|
||||
case PlatformID.Win32NT:
|
||||
var reg = Registry.ClassesRoot.OpenSubKey(@"malody\Shell\Open\Command");
|
||||
if (reg == null) return null;
|
||||
var pathObj = reg.GetValue(null);
|
||||
if (pathObj == null) return null;
|
||||
var path = (string)pathObj;
|
||||
return new FileInfo(StringUtils.GetProcessPathFromCommand(path)).Directory.FullName;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c9beaff62143a2468e18ad4642232c0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6823ead66b33bc048bbad48719feb25d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,154 +0,0 @@
|
||||
using Cryville.Crtr.Browsing;
|
||||
using Quaver.API.Maps;
|
||||
using Quaver.API.Maps.Structures;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
namespace Cryville.Crtr.Extensions.Quaver {
|
||||
public class QuaverChartConverter : ResourceConverter {
|
||||
static readonly string[] SUPPORTED_FORMATS = { ".qua" };
|
||||
const double OFFSET = 0.05;
|
||||
|
||||
public override string[] GetSupportedFormats() {
|
||||
return SUPPORTED_FORMATS;
|
||||
}
|
||||
|
||||
public override IEnumerable<Resource> ConvertFrom(FileInfo file) {
|
||||
List<Resource> result = new List<Resource>();
|
||||
var src = Qua.Parse(file.FullName);
|
||||
var ruleset = "quaver!" + src.Mode.ToString().ToLower();
|
||||
var meta = new ChartMeta {
|
||||
name = src.DifficultyName,
|
||||
author = src.Creator,
|
||||
song = new SongMetaInfo {
|
||||
name = src.Title,
|
||||
author = src.Artist,
|
||||
},
|
||||
ruleset = ruleset,
|
||||
cover = src.BackgroundFile,
|
||||
note_count = src.HitObjects.Count,
|
||||
};
|
||||
var chart = new Chart {
|
||||
format = 2,
|
||||
time = new BeatTime(-4, 0, 1),
|
||||
ruleset = ruleset,
|
||||
sigs = new List<Chart.Signature>(),
|
||||
sounds = new List<Chart.Sound> {
|
||||
new Chart.Sound { time = new BeatTime(0, 0, 1), id = src.Title, offset = (float)(src.TimingPoints[0].StartTime / 1e3 + OFFSET) }
|
||||
},
|
||||
motions = new List<Chart.Motion>(),
|
||||
groups = new List<Chart.Group>(),
|
||||
};
|
||||
var group = new Chart.Group() {
|
||||
tracks = new List<Chart.Track>(),
|
||||
notes = new List<Chart.Note>(),
|
||||
motions = new List<Chart.Motion>(),
|
||||
};
|
||||
chart.groups.Add(group);
|
||||
result.Add(new RawChartResource(string.Format("{0} - {1}", meta.song.name, meta.name), chart, meta));
|
||||
result.Add(new SongResource(meta.song.name, new FileInfo(Path.Combine(file.DirectoryName, src.AudioFile))));
|
||||
|
||||
var evs = new List<EventWrapper>();
|
||||
foreach (var e in src.HitObjects) evs.Add(new EventWrapper.HitObject(e));
|
||||
foreach (var e in src.SliderVelocities) evs.Add(new EventWrapper.SliderVelocity(e));
|
||||
foreach (var e in src.SoundEffects) evs.Add(new EventWrapper.SoundEffect(e));
|
||||
foreach (var e in src.TimingPoints) evs.Add(new EventWrapper.TimingPoint(e));
|
||||
var evc = evs.Count;
|
||||
for (int i = 0; i < evc; i++) if (evs[i].IsLong) evs.Add(new EventWrapper.EndEvent(evs[i]));
|
||||
evs.Sort();
|
||||
|
||||
var longevs = new Dictionary<EventWrapper, ChartEvent>();
|
||||
var tm = new TimeTimingModel(src.TimingPoints[0].StartTime / 1e3, 2e-3);
|
||||
foreach (var ev in evs) {
|
||||
tm.ForwardTo(ev.StartTime / 1e3);
|
||||
if (ev is EventWrapper.HitObject) {
|
||||
var tev = (EventWrapper.HitObject)ev;
|
||||
var rn = new Chart.Note {
|
||||
time = tm.FractionalBeatTime,
|
||||
motions = new List<Chart.Motion> {
|
||||
new Chart.Motion { motion = string.Format(CultureInfo.InvariantCulture, "track:{0}", tev.Event.Lane - 1) }
|
||||
},
|
||||
};
|
||||
if (ev.IsLong) longevs.Add(ev, rn);
|
||||
group.notes.Add(rn);
|
||||
}
|
||||
else if (ev is EventWrapper.SliderVelocity) {
|
||||
var tev = (EventWrapper.SliderVelocity)ev;
|
||||
group.motions.Add(new Chart.Motion {
|
||||
time = tm.FractionalBeatTime,
|
||||
motion = string.Format(CultureInfo.InvariantCulture, "svm:{0}", tev.Event.Multiplier),
|
||||
});
|
||||
}
|
||||
else if (ev is EventWrapper.TimingPoint) {
|
||||
var tev = (EventWrapper.TimingPoint)ev;
|
||||
tm.BPM = tev.Event.Bpm;
|
||||
tm.ForceSnap();
|
||||
chart.sigs.Add(new Chart.Signature {
|
||||
time = tm.FractionalBeatTime,
|
||||
tempo = tev.Event.Bpm,
|
||||
});
|
||||
}
|
||||
else if (ev is EventWrapper.EndEvent) {
|
||||
var tev = (EventWrapper.EndEvent)ev;
|
||||
var oev = tev.Original;
|
||||
longevs[oev].endtime = tm.FractionalBeatTime;
|
||||
}
|
||||
else throw new NotSupportedException("Sound effects are not supported yet");
|
||||
}
|
||||
var endbeat = tm.FractionalBeatTime;
|
||||
endbeat.b += 4;
|
||||
chart.endtime = endbeat;
|
||||
meta.length = (float)tm.Time;
|
||||
return result;
|
||||
}
|
||||
|
||||
abstract class EventWrapper : IComparable<EventWrapper> {
|
||||
public abstract int StartTime { get; }
|
||||
public abstract int EndTime { get; }
|
||||
public bool IsLong { get { return EndTime > 0; } }
|
||||
public abstract int Priority { get; }
|
||||
public int CompareTo(EventWrapper other) {
|
||||
var c = StartTime.CompareTo(other.StartTime);
|
||||
if (c != 0) return c;
|
||||
return Priority.CompareTo(other.Priority);
|
||||
}
|
||||
public class HitObject : EventWrapper {
|
||||
public HitObjectInfo Event;
|
||||
public HitObject(HitObjectInfo ev) { Event = ev; }
|
||||
public override int StartTime { get { return Event.StartTime; } }
|
||||
public override int EndTime { get { return Event.EndTime; } }
|
||||
public override int Priority { get { return 0; } }
|
||||
}
|
||||
public class SliderVelocity : EventWrapper {
|
||||
public SliderVelocityInfo Event;
|
||||
public SliderVelocity(SliderVelocityInfo ev) { Event = ev; }
|
||||
public override int StartTime { get { return (int)Event.StartTime; } }
|
||||
public override int EndTime { get { return 0; } }
|
||||
public override int Priority { get { return 0; } }
|
||||
}
|
||||
public class SoundEffect : EventWrapper {
|
||||
public SoundEffectInfo Event;
|
||||
public SoundEffect(SoundEffectInfo ev) { Event = ev; }
|
||||
public override int StartTime { get { return (int)Event.StartTime; } }
|
||||
public override int EndTime { get { return 0; } }
|
||||
public override int Priority { get { return 0; } }
|
||||
}
|
||||
public class TimingPoint : EventWrapper {
|
||||
public TimingPointInfo Event;
|
||||
public TimingPoint(TimingPointInfo ev) { Event = ev; }
|
||||
public override int StartTime { get { return (int)Event.StartTime; } }
|
||||
public override int EndTime { get { return 0; } }
|
||||
public override int Priority { get { return -2; } }
|
||||
}
|
||||
public class EndEvent : EventWrapper {
|
||||
public EventWrapper Original;
|
||||
public EndEvent(EventWrapper ev) { if (!ev.IsLong) throw new ArgumentException("Event is not long"); Original = ev; }
|
||||
public override int StartTime { get { return Original.EndTime; } }
|
||||
public override int EndTime { get { return 0; } }
|
||||
public override int Priority { get { return Original.Priority - 1; } }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b073cac7ce0d41a4f8ca589845678aa2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,24 +0,0 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Crtr.Browsing;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Cryville.Crtr.Extensions.Quaver {
|
||||
public class QuaverChartFinder : LocalResourceFinder {
|
||||
public override string Name { get { return "Quaver beatmaps"; } }
|
||||
|
||||
public override string GetRootPath() {
|
||||
switch (Environment.OSVersion.Platform) {
|
||||
case PlatformID.Win32NT:
|
||||
var reg = Registry.ClassesRoot.OpenSubKey(@"quaver\Shell\Open\Command");
|
||||
if (reg == null) return null;
|
||||
var pathObj = reg.GetValue(null);
|
||||
if (pathObj == null) return null;
|
||||
var path = (string)pathObj;
|
||||
return Path.Combine(new FileInfo(StringUtils.GetProcessPathFromCommand(path)).Directory.FullName, "Songs");
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68bacf7746cbeea42a78a7d55cfdbea0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,65 +0,0 @@
|
||||
using Cryville.Common.Math;
|
||||
using System;
|
||||
|
||||
namespace Cryville.Crtr.Extensions {
|
||||
public abstract class TimingModel {
|
||||
public double Time { get; protected set; }
|
||||
public double BeatTime { get; protected set; }
|
||||
public BeatTime FractionalBeatTime { get; protected set; }
|
||||
double m_bpm;
|
||||
public double BPM { get { return m_bpm; } set { m_bpm = value; } }
|
||||
public double BeatLength { get { return 60 / m_bpm; } set { m_bpm = 60 / value; } }
|
||||
public TimingModel(double offset) {
|
||||
Time = offset;
|
||||
FractionalBeatTime = new BeatTime(0, 0, 1);
|
||||
}
|
||||
}
|
||||
public class FractionalBeatTimeTimingModel : TimingModel {
|
||||
public FractionalBeatTimeTimingModel(double offset = 0) : base(offset) { }
|
||||
public void ForwardTo(BeatTime t) {
|
||||
if (t == FractionalBeatTime) return;
|
||||
if (BPM == 0) throw new InvalidOperationException("BPM not determined");
|
||||
FractionalBeatTime = t;
|
||||
var nt = t.Decimal;
|
||||
Time += (nt - BeatTime) / BPM * 60;
|
||||
BeatTime = nt;
|
||||
}
|
||||
}
|
||||
public class BeatTimeTimingModel : TimingModel {
|
||||
public BeatTimeTimingModel(double offset = 0) : base(offset) { }
|
||||
public void ForwardTo(double t) {
|
||||
if (t == BeatTime) return;
|
||||
if (BPM == 0) throw new InvalidOperationException("BPM not determined");
|
||||
Time += (t - BeatTime) / BPM * 60;
|
||||
BeatTime = t;
|
||||
FractionalBeatTime = ToBeatTime(t);
|
||||
}
|
||||
static BeatTime ToBeatTime(double beat, double error = 1e-4) {
|
||||
int i, n, d;
|
||||
FractionUtils.ToFraction(beat, error, out n, out d);
|
||||
i = n / d; n %= d;
|
||||
return new BeatTime(i, n, d);
|
||||
}
|
||||
}
|
||||
public class TimeTimingModel : TimingModel {
|
||||
public readonly double InputTimeAccuracy;
|
||||
public TimeTimingModel(double offset = 0, double accuracy = 2e-3) : base(offset) {
|
||||
if (accuracy <= 0) throw new ArgumentOutOfRangeException("accuracy");
|
||||
InputTimeAccuracy = accuracy;
|
||||
}
|
||||
public void ForwardTo(double t) {
|
||||
if (t == Time) return;
|
||||
if (BPM == 0) throw new InvalidOperationException("BPM not determined");
|
||||
BeatTime += (t - Time) * BPM / 60;
|
||||
int n, d;
|
||||
FractionUtils.ToFraction(BeatTime, Math.Min(1, InputTimeAccuracy * BPM / 60), out n, out d);
|
||||
FractionalBeatTime = new BeatTime(n, d);
|
||||
Time = t;
|
||||
}
|
||||
public void ForceSnap() {
|
||||
var alignedBeat = (int)Math.Round(BeatTime);
|
||||
BeatTime = alignedBeat;
|
||||
FractionalBeatTime = new BeatTime(alignedBeat, 1);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c4a1fab8f53dd742ba6501d682eb7f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbc046e7cabacbb4fbf74520399a7340
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,384 +0,0 @@
|
||||
using Cryville.Crtr.Browsing;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Cryville.Crtr.Extensions.osu {
|
||||
#pragma warning disable IDE1006
|
||||
public class osuChartConverter : ResourceConverter {
|
||||
#pragma warning restore IDE1006
|
||||
static readonly string[] SUPPORTED_FORMATS = { ".osu" };
|
||||
const double OFFSET = 0.011;
|
||||
|
||||
public override string[] GetSupportedFormats() {
|
||||
return SUPPORTED_FORMATS;
|
||||
}
|
||||
|
||||
public override IEnumerable<Resource> ConvertFrom(FileInfo file) {
|
||||
List<Resource> result = new List<Resource>();
|
||||
var meta = new ChartMeta { song = new SongMetaInfo() };
|
||||
var group = new Chart.Group() {
|
||||
tracks = new List<Chart.Track>(),
|
||||
notes = new List<Chart.Note>(),
|
||||
motions = new List<Chart.Motion>(),
|
||||
};
|
||||
var chart = new Chart {
|
||||
format = 2,
|
||||
time = new BeatTime(-4, 0, 1),
|
||||
sigs = new List<Chart.Signature>(),
|
||||
sounds = new List<Chart.Sound>(),
|
||||
motions = new List<Chart.Motion>(),
|
||||
groups = new List<Chart.Group> { group },
|
||||
};
|
||||
var diff = new DifficultyInfo();
|
||||
var evs = new List<osuEvent>();
|
||||
|
||||
bool ftc = false;
|
||||
using (var reader = new StreamReader(file.FullName, Encoding.UTF8)) {
|
||||
Section section = Section.General;
|
||||
int version;
|
||||
bool flag = false;
|
||||
string line;
|
||||
while ((line = reader.ReadLine()) != null) {
|
||||
if (!flag) {
|
||||
if (line.StartsWith("osu file format v")) {
|
||||
version = int.Parse(line.Substring(17), CultureInfo.InvariantCulture);
|
||||
if (version > 14) throw new NotSupportedException("osu! chart format version too high");
|
||||
else if (version < 5) throw new NotImplementedException("osu! chart format version too low"); // TODO apply offset
|
||||
}
|
||||
else throw new NotSupportedException("Unrecognized osu! chart format");
|
||||
flag = true;
|
||||
}
|
||||
if (ShouldSkipLine(line)) continue;
|
||||
if (section != Section.Metadata) line = StripComments(line);
|
||||
line = line.TrimEnd();
|
||||
if (line.StartsWith('[') && line.EndsWith(']')) {
|
||||
Enum.TryParse(line.Substring(1, line.Length - 2), out section);
|
||||
continue;
|
||||
}
|
||||
ParseLine(meta, chart, diff, evs, ref ftc, section, line);
|
||||
}
|
||||
}
|
||||
if (meta.ruleset == "osu!mania") {
|
||||
chart.ruleset = meta.ruleset += "." + diff.CircleSize.ToString(CultureInfo.InvariantCulture) + "k";
|
||||
}
|
||||
|
||||
if (!ftc) throw new InvalidOperationException("Unconvertible chart: no timing point is present in this beatmap");
|
||||
result.Add(new RawChartResource(string.Format("{0} - {1}", meta.song.name, meta.name), chart, meta));
|
||||
var evc = evs.Count;
|
||||
for (int i = 0; i < evc; i++) if (evs[i].IsLong) evs.Add(new osuEvent.EndEvent(evs[i]));
|
||||
evs.Sort();
|
||||
|
||||
var longevs = new Dictionary<osuEvent, ChartEvent>();
|
||||
Chart.Sound bgmEv = null;
|
||||
TimeTimingModel tm = null;
|
||||
foreach (var ev in evs) {
|
||||
if (tm != null) tm.ForwardTo(ev.StartTime / 1e3);
|
||||
if (ev is osuEvent.Audio) {
|
||||
var tev = (osuEvent.Audio)ev;
|
||||
chart.sounds.Add(bgmEv = new Chart.Sound { time = new BeatTime(0, 0, 1), id = meta.song.name });
|
||||
result.Add(new SongResource(meta.song.name, new FileInfo(Path.Combine(file.DirectoryName, tev.AudioFile))));
|
||||
}
|
||||
else if (ev is osuEvent.Background) {
|
||||
meta.cover = ((osuEvent.Background)ev).FileName;
|
||||
}
|
||||
else if (ev is osuEvent.EffectPoint) {
|
||||
var tev = (osuEvent.EffectPoint)ev;
|
||||
group.motions.Add(new Chart.Motion { time = tm.FractionalBeatTime, motion = string.Format(CultureInfo.InvariantCulture, "svm:{0}", tev.ScrollSpeed) });
|
||||
}
|
||||
else if (ev is osuEvent.EndEvent) {
|
||||
if (tm == null) throw new InvalidOperationException("Unconvertible chart: timed event before first timing point");
|
||||
var tev = (osuEvent.EndEvent)ev;
|
||||
longevs[tev.Original].endtime = tm.FractionalBeatTime;
|
||||
}
|
||||
else if (ev is osuEvent.HOMania) {
|
||||
if (tm == null) throw new InvalidOperationException("Unconvertible chart: timed event before first timing point");
|
||||
var tev = (osuEvent.HOMania)ev;
|
||||
var rn = new Chart.Note {
|
||||
time = tm.FractionalBeatTime,
|
||||
motions = new List<Chart.Motion> {
|
||||
new Chart.Motion{ motion = string.Format(CultureInfo.InvariantCulture, "track:{0}", (int)(tev.X * diff.CircleSize / 512)) }
|
||||
},
|
||||
};
|
||||
group.notes.Add(rn);
|
||||
if (tev.IsLong) longevs.Add(tev, rn);
|
||||
}
|
||||
else if (ev is osuEvent.TimingChange) {
|
||||
var tev = (osuEvent.TimingChange)ev;
|
||||
if (tm == null) {
|
||||
tm = new TimeTimingModel(tev.StartTime / 1e3, 2e-3);
|
||||
bgmEv.offset = (float)(tev.StartTime / 1e3 + OFFSET);
|
||||
}
|
||||
tm.BeatLength = tev.BeatLength / 1e3;
|
||||
tm.ForceSnap();
|
||||
chart.sigs.Add(new Chart.Signature {
|
||||
time = tm.FractionalBeatTime,
|
||||
tempo = (float)tm.BPM,
|
||||
});
|
||||
}
|
||||
else throw new NotSupportedException("Unsupported event detected");
|
||||
}
|
||||
var endbeat = tm.FractionalBeatTime;
|
||||
endbeat.b += 4;
|
||||
chart.endtime = endbeat;
|
||||
meta.length = (float)tm.Time;
|
||||
meta.note_count = group.notes.Count;
|
||||
return result;
|
||||
}
|
||||
|
||||
void ParseLine(ChartMeta meta, Chart chart, DifficultyInfo diff, List<osuEvent> evs, ref bool ftc, Section section, string line) {
|
||||
switch (section) {
|
||||
case Section.General: HandleGeneral(meta, chart, evs, line); return;
|
||||
case Section.Metadata: HandleMetadata(meta, line); return;
|
||||
case Section.Difficulty: HandleDifficulty(diff, line); return;
|
||||
case Section.Events: HandleEvent(evs, line); return;
|
||||
case Section.TimingPoints: HandleTimingPoint(chart, evs, ref ftc, line); return;
|
||||
case Section.HitObjects: HandleHitObject(evs, line); return;
|
||||
}
|
||||
}
|
||||
|
||||
void HandleGeneral(ChartMeta meta, Chart chart, List<osuEvent> evs, string line) {
|
||||
var pair = SplitKeyVal(line);
|
||||
switch (pair.Key) {
|
||||
case @"AudioFilename":
|
||||
evs.Add(new osuEvent.Audio { StartTime = double.NegativeInfinity, AudioFile = pair.Value });
|
||||
break;
|
||||
case @"Mode":
|
||||
int rulesetID = int.Parse(pair.Value, CultureInfo.InvariantCulture);
|
||||
var ruleset = "osu!";
|
||||
switch (rulesetID) {
|
||||
case 0: /*ruleset += "standard";*/ throw new NotImplementedException("osu!standard mode is not supported yet");
|
||||
case 1: /*ruleset += "taiko";*/ throw new NotImplementedException("osu!taiko mode is not supported yet");
|
||||
case 2: /*ruleset += "catch";*/ throw new NotImplementedException("osu!catch mode is not supported yet");
|
||||
case 3: ruleset += "mania"; break;
|
||||
}
|
||||
meta.ruleset = chart.ruleset = ruleset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void HandleMetadata(ChartMeta meta, string line) {
|
||||
var pair = SplitKeyVal(line);
|
||||
switch (pair.Key) {
|
||||
case @"Title": if (meta.song.name == null) meta.song.name = pair.Value; break;
|
||||
case @"TitleUnicode": meta.song.name = pair.Value; break;
|
||||
case @"Artist": if (meta.song.author == null) meta.song.author = pair.Value; break;
|
||||
case @"ArtistUnicode": meta.song.author = pair.Value; break;
|
||||
case @"Creator": meta.author = pair.Value; break;
|
||||
case @"Version": meta.name = pair.Value; break;
|
||||
}
|
||||
}
|
||||
|
||||
void HandleDifficulty(DifficultyInfo diff, string line) {
|
||||
var pair = SplitKeyVal(line);
|
||||
switch (pair.Key) {
|
||||
case @"CircleSize":
|
||||
diff.CircleSize = float.Parse(pair.Value, CultureInfo.InvariantCulture);
|
||||
break;
|
||||
case @"SliderMultiplier":
|
||||
diff.SliderMultiplier = double.Parse(pair.Value, CultureInfo.InvariantCulture);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void HandleEvent(List<osuEvent> evs, string line) {
|
||||
string[] split = line.Split(',');
|
||||
if (!Enum.TryParse(split[0], out LegacyEventType type))
|
||||
throw new InvalidDataException($@"Unknown event type: {split[0]}");
|
||||
switch (type) {
|
||||
case LegacyEventType.Sprite:
|
||||
if (evs.Count == 0 || !(evs[evs.Count - 1] is osuEvent.Background))
|
||||
evs.Add(new osuEvent.Background { StartTime = double.NegativeInfinity, FileName = CleanFilename(split[3]) });
|
||||
break;
|
||||
case LegacyEventType.Background:
|
||||
evs.Add(new osuEvent.Background { StartTime = double.NegativeInfinity, FileName = CleanFilename(split[2]) });
|
||||
break;
|
||||
}
|
||||
}
|
||||
enum LegacyEventType {
|
||||
Background = 0,
|
||||
Video = 1,
|
||||
Break = 2,
|
||||
Colour = 3,
|
||||
Sprite = 4,
|
||||
Sample = 5,
|
||||
Animation = 6
|
||||
}
|
||||
|
||||
void HandleTimingPoint(Chart chart, List<osuEvent> evs, ref bool ftc, string line) {
|
||||
string[] split = line.Split(',');
|
||||
|
||||
double time = double.Parse(split[0].Trim(), CultureInfo.InvariantCulture)/* + offset*/;
|
||||
|
||||
// beatLength is allowed to be NaN to handle an edge case in which some beatmaps use NaN slider velocity to disable slider tick generation (see LegacyDifficultyControlPoint).
|
||||
double beatLength = double.Parse(split[1].Trim(), CultureInfo.InvariantCulture);
|
||||
|
||||
// If beatLength is NaN, speedMultiplier should still be 1 because all comparisons against NaN are false.
|
||||
double speedMultiplier = beatLength < 0 ? 100.0 / -beatLength : 1;
|
||||
|
||||
int timeSignature = 4;
|
||||
if (split.Length >= 3)
|
||||
timeSignature = split[2][0] == '0' ? 4 : int.Parse(split[2], CultureInfo.InvariantCulture);
|
||||
|
||||
bool timingChange = true;
|
||||
if (split.Length >= 7)
|
||||
timingChange = split[6][0] == '1';
|
||||
|
||||
//bool omitFirstBarSignature = false;
|
||||
|
||||
//if (split.Length >= 8) {
|
||||
// int effectFlags = int.Parse(split[7], CultureInfo.InvariantCulture);
|
||||
// omitFirstBarSignature = (effectFlags & 0x8) != 0;
|
||||
//}
|
||||
|
||||
if (timingChange) {
|
||||
if (double.IsNaN(beatLength))
|
||||
throw new InvalidDataException("Beat length cannot be NaN in a timing control point");
|
||||
var ev = new osuEvent.TimingChange { StartTime = time, BeatLength = beatLength, TimeSignature = timeSignature };
|
||||
if (!ftc) {
|
||||
ftc = true;
|
||||
ev.StartTime = time % beatLength - beatLength;
|
||||
}
|
||||
evs.Add(ev);
|
||||
}
|
||||
|
||||
// osu!taiko and osu!mania use effect points rather than difficulty points for scroll speed adjustments.
|
||||
if (chart.ruleset == "osu!taiko" || chart.ruleset == "osu!mania")
|
||||
evs.Add(new osuEvent.EffectPoint { StartTime = time, ScrollSpeed = speedMultiplier });
|
||||
}
|
||||
|
||||
void HandleHitObject(List<osuEvent> evs, string line) {
|
||||
string[] split = line.Split(',');
|
||||
|
||||
int posx = (int)float.Parse(split[0], CultureInfo.InvariantCulture);
|
||||
// int posy = (int)float.Parse(split[1], CultureInfo.InvariantCulture);
|
||||
|
||||
double startTime = double.Parse(split[2], CultureInfo.InvariantCulture)/* + Offset*/;
|
||||
|
||||
LegacyHitObjectType type = (LegacyHitObjectType)int.Parse(split[3], CultureInfo.InvariantCulture);
|
||||
|
||||
// int comboOffset = (int)(type & LegacyHitObjectType.ComboOffset) >> 4;
|
||||
type &= ~LegacyHitObjectType.ComboOffset;
|
||||
|
||||
// bool combo = type.HasFlag(LegacyHitObjectType.NewCombo);
|
||||
type &= ~LegacyHitObjectType.NewCombo;
|
||||
|
||||
osuEvent.HitObject result;
|
||||
|
||||
if (type.HasFlag(LegacyHitObjectType.Circle)) {
|
||||
result = new osuEvent.HOManiaHit { X = posx };
|
||||
}
|
||||
else if (type.HasFlag(LegacyHitObjectType.Hold)) {
|
||||
double endTime = Math.Max(startTime, double.Parse(split[2], CultureInfo.InvariantCulture));
|
||||
if (split.Length > 5 && !string.IsNullOrEmpty(split[5])) {
|
||||
string[] ss = split[5].Split(':');
|
||||
endTime = Math.Max(startTime, double.Parse(ss[0], CultureInfo.InvariantCulture));
|
||||
}
|
||||
result = new osuEvent.HOManiaHold { X = posx, EndTime = endTime };
|
||||
}
|
||||
else throw new NotSupportedException(string.Format("Hit objects of type {0} is not supported yet", type));
|
||||
|
||||
if (result == null) throw new InvalidDataException($"Unknown hit object type: {split[3]}");
|
||||
|
||||
result.StartTime = startTime;
|
||||
|
||||
if (result != null) evs.Add(result);
|
||||
}
|
||||
[Flags]
|
||||
enum LegacyHitObjectType {
|
||||
Circle = 1,
|
||||
Slider = 1 << 1,
|
||||
NewCombo = 1 << 2,
|
||||
Spinner = 1 << 3,
|
||||
ComboOffset = (1 << 4) | (1 << 5) | (1 << 6),
|
||||
Hold = 1 << 7
|
||||
}
|
||||
|
||||
static bool ShouldSkipLine(string line) => string.IsNullOrWhiteSpace(line) || line.TrimStart().StartsWith("//", StringComparison.Ordinal)
|
||||
|| line.StartsWith(' ') || line.StartsWith('_');
|
||||
protected string StripComments(string line) {
|
||||
int index = line.IndexOf("//");
|
||||
if (index > 0) return line.Substring(0, index);
|
||||
return line;
|
||||
}
|
||||
KeyValuePair<string, string> SplitKeyVal(string line, char separator = ':', bool shouldTrim = true) {
|
||||
string[] split = line.Split(separator, 2);
|
||||
if (shouldTrim) {
|
||||
for (int i = 0; i < split.Length; i++)
|
||||
split[i] = split[i].Trim();
|
||||
}
|
||||
return new KeyValuePair<string, string> (
|
||||
split[0],
|
||||
split.Length > 1 ? split[1] : string.Empty
|
||||
);
|
||||
}
|
||||
static string CleanFilename(string path) => path.Replace(@"\\", @"\").Trim('"');
|
||||
|
||||
enum Section {
|
||||
General,
|
||||
Editor,
|
||||
Metadata,
|
||||
Difficulty,
|
||||
Events,
|
||||
TimingPoints,
|
||||
Colours,
|
||||
HitObjects,
|
||||
Variables,
|
||||
Fonts,
|
||||
CatchTheBeat,
|
||||
Mania,
|
||||
}
|
||||
|
||||
class DifficultyInfo {
|
||||
public float CircleSize { get; internal set; }
|
||||
public double SliderMultiplier { get; set; }
|
||||
}
|
||||
#pragma warning disable IDE1006 // Naming Styles
|
||||
abstract class osuEvent : IComparable<osuEvent> {
|
||||
public virtual double StartTime { get; set; }
|
||||
public virtual double EndTime { get; set; }
|
||||
public bool IsLong { get { return EndTime - StartTime > 0 && EndTime > 0; } }
|
||||
public abstract int Priority { get; }
|
||||
public int CompareTo(osuEvent other) {
|
||||
var c = StartTime.CompareTo(other.StartTime);
|
||||
if (c != 0) return c;
|
||||
return Priority.CompareTo(other.Priority);
|
||||
}
|
||||
public class EndEvent : osuEvent {
|
||||
public osuEvent Original;
|
||||
public EndEvent(osuEvent ev) { if (!ev.IsLong) throw new ArgumentException("Event is not long"); Original = ev; }
|
||||
public override double StartTime { get { return Original.EndTime; } }
|
||||
public override double EndTime { get { return 0; } }
|
||||
public override int Priority { get { return Original.Priority - 1; } }
|
||||
}
|
||||
public class Audio : osuEvent {
|
||||
public string AudioFile { get; set; }
|
||||
public override int Priority { get { return 0; } }
|
||||
}
|
||||
public class TimingChange : osuEvent {
|
||||
public double BeatLength { get; set; }
|
||||
public int TimeSignature { get; set; }
|
||||
public override int Priority { get { return -4; } }
|
||||
}
|
||||
public class EffectPoint : osuEvent {
|
||||
public double ScrollSpeed { get; set; }
|
||||
public override int Priority { get { return -2; } }
|
||||
}
|
||||
public class Background : osuEvent {
|
||||
public string FileName { get; set; }
|
||||
public override int Priority { get { return 0; } }
|
||||
}
|
||||
public class HitObject : osuEvent {
|
||||
public sealed override int Priority { get { return 0; } }
|
||||
}
|
||||
public class HOMania : HitObject {
|
||||
public float X { get; set; }
|
||||
}
|
||||
public class HOManiaHit : HOMania { }
|
||||
public class HOManiaHold : HOMania { }
|
||||
}
|
||||
#pragma warning restore IDE1006 // Naming Styles
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82838dd8639c2244caf3c830edfbc59c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,24 +0,0 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Crtr.Browsing;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Cryville.Crtr.Extensions.osu {
|
||||
public class osuChartFinder : LocalResourceFinder {
|
||||
public override string Name { get { return "osu! beatmaps"; } }
|
||||
|
||||
public override string GetRootPath() {
|
||||
switch (Environment.OSVersion.Platform) {
|
||||
case PlatformID.Win32NT:
|
||||
var reg = Registry.ClassesRoot.OpenSubKey(@"osu!\Shell\Open\Command");
|
||||
if (reg == null) return null;
|
||||
var pathObj = reg.GetValue(null);
|
||||
if (pathObj == null) return null;
|
||||
var path = (string)pathObj;
|
||||
return Path.Combine(new FileInfo(StringUtils.GetProcessPathFromCommand(path)).Directory.FullName, "Songs");
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 365d879536c05284fa2335a7676c6cf4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -2,7 +2,6 @@
|
||||
"name": "Cryville.Crtr",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:d8ea0e0da3ad53a45b65c912ffcacab0",
|
||||
"GUID:5686e5ee69d0e084c843d61c240d7fdb",
|
||||
"GUID:2922aa74af3b2854e81b8a8b286d8206",
|
||||
"GUID:da293eebbcb9a4947a212534c52d1a32"
|
||||
|
Reference in New Issue
Block a user