Merge 'dev-extension' into 'master'.

This commit is contained in:
2023-03-23 19:25:14 +08:00
521 changed files with 502 additions and 29600 deletions

View File

@@ -28,8 +28,8 @@ namespace Cryville.Common.Unity {
set { m_filter = value; }
}
public Dictionary<string, string> m_presetPaths = new Dictionary<string, string>();
public Dictionary<string, string> PresetPaths {
public IReadOnlyDictionary<string, string> m_presetPaths = new Dictionary<string, string>();
public IReadOnlyDictionary<string, string> PresetPaths {
get { return m_presetPaths; }
set { m_presetPaths = value; }
}

View File

@@ -1,8 +0,0 @@
using System.Collections.Generic;
namespace Cryville.Crtr.Browsing {
public abstract class ExtensionInterface {
public abstract IEnumerable<ResourceConverter> GetResourceConverters();
public abstract IEnumerable<LocalResourceFinder> GetResourceFinders();
}
}

View File

@@ -0,0 +1,138 @@
using Cryville.Common;
using Cryville.Crtr.Extension;
using Mono.Cecil;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
namespace Cryville.Crtr.Browsing {
internal static class ExtensionManager {
static readonly Dictionary<string, List<ResourceConverter>> _converters
= new Dictionary<string, List<ResourceConverter>>();
public static IEnumerable<string> GetSupportedFormats() {
return _converters.Keys;
}
public static bool TryGetConverters(string extension, out IEnumerable<ResourceConverter> converters) {
List<ResourceConverter> outResult;
bool result = _converters.TryGetValue(extension, out outResult);
converters = outResult;
return result;
}
static readonly Dictionary<string, string> _localRes
= new Dictionary<string, string>();
public static IReadOnlyDictionary<string, string> GetLocalResourcePaths() {
return _localRes;
}
public static void Init(string rootPath) {
LoadExtension(typeof(Extensions.Umg.Extension));
var asms = AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetName().Name).ToHashSet();
var modules = new Queue<ModuleItem>();
var extensionDir = new DirectoryInfo(Path.Combine(rootPath, "extensions"));
if (extensionDir.Exists) {
foreach (var extension in extensionDir.EnumerateFiles("*.dll")) {
try {
modules.Enqueue(new ModuleItem(extension.OpenRead()));
}
catch (Exception ex) {
Logger.Log("main", 4, "Extension", "Failed to load DLL {0}: {1}", extension, ex);
}
}
}
int refCounter = 0;
while (modules.Count > 0 && refCounter < modules.Count) {
var module = modules.Dequeue();
bool flag = false;
foreach (var reference in module.Definition.AssemblyReferences) {
if (!asms.Contains(reference.Name)) {
flag = true;
break;
}
}
if (flag) {
modules.Enqueue(module);
refCounter++;
}
else {
try {
var stream = module.Stream;
stream.Seek(0, SeekOrigin.Begin);
var buf = new byte[stream.Length];
stream.Read(buf, 0, buf.Length);
var asm = Assembly.Load(buf);
if (asm == null) throw new TypeLoadException("Failed to load the module");
asms.Add(asm.GetName().Name);
foreach (var type in asm.GetTypes()) {
if (typeof(ExtensionInterface).IsAssignableFrom(type)) {
LoadExtension(type);
}
}
Logger.Log("main", 1, "Extension", "Loaded module {0}", module.Definition.Name);
}
catch (Exception ex) {
Logger.Log("main", 4, "Extension", "An error occured while trying to load module {0}: {1}", module.Definition.Name, ex);
}
finally {
module.Definition.Dispose();
module.Stream.Dispose();
refCounter = 0;
}
}
}
var missingList = new List<string>();
while (modules.Count > 0) {
missingList.Clear();
var module = modules.Dequeue();
foreach (var reference in module.Definition.AssemblyReferences) {
if (!asms.Contains(reference.Name)) {
missingList.Add(reference.Name);
}
}
Logger.Log("main", 4, "Extension", "Could not load the module {0} because the following dependencies were missing: {1}", module.Definition.Name, missingList.Aggregate((current, next) => current + ", " + next));
module.Definition.Dispose();
module.Stream.Dispose();
}
}
struct ModuleItem {
public ModuleDefinition Definition { get; set; }
public FileStream Stream { get; set; }
public ModuleItem(FileStream stream) {
Stream = stream;
Definition = ModuleDefinition.ReadModule(stream);
}
}
static void LoadExtension(Type type) {
try {
var extension = (ExtensionInterface)Activator.CreateInstance(type);
var l1 = extension.GetResourceConverters();
if (l1 != null) {
foreach (var c in l1) {
var fs = c.GetSupportedFormats();
if (fs == null) continue;
foreach (var f in fs) {
if (f == null) continue;
if (!_converters.ContainsKey(f))
_converters.Add(f, new List<ResourceConverter> { c });
else _converters[f].Add(c);
}
}
}
var l2 = extension.GetResourceFinders();
if (l2 != null) {
foreach (var f in l2) {
var name = f.Name;
var path = f.GetRootPath();
if (name != null && path != null) _localRes.Add(name, path);
}
}
Logger.Log("main", 1, "Extension", "Loaded extension {0}", type);
}
catch (Exception ex) {
Logger.Log("main", 4, "Extension", "Failed to load extension {0}: {1}", type, ex);
}
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: f5b3f3294f679f14f8ec1195b0def630
guid: a9ea11165e6269b488f916982507a2af
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -12,6 +12,6 @@ namespace Cryville.Crtr.Browsing {
bool ImportItemFrom(string path);
string[] GetSupportedFormats();
Dictionary<string, string> GetPresetPaths();
IReadOnlyDictionary<string, string> GetPresetPaths();
}
}

View File

@@ -1,5 +1,7 @@
using Cryville.Common;
using Cryville.Common.Unity;
using Cryville.Crtr.Extension;
using Cryville.Crtr.Extensions.Umg;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@@ -15,49 +17,13 @@ namespace Cryville.Crtr.Browsing {
private DirectoryInfo[] items = new DirectoryInfo[0];
public string[] CurrentDirectory { get; private set; }
static readonly Dictionary<string, List<ResourceConverter>> converters
= new Dictionary<string, List<ResourceConverter>>();
static readonly Dictionary<string, string> localRes
= new Dictionary<string, string>();
static bool _init;
public LegacyResourceManager(string rootPath) {
_rootPath = rootPath;
}
static LegacyResourceManager() {
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) {
foreach (var type in asm.GetTypes()) {
if (!type.IsSubclassOf(typeof(ExtensionInterface))) continue;
var ext = (ExtensionInterface)Activator.CreateInstance(type);
try {
var cs = ext.GetResourceConverters();
if (cs != null) {
foreach (var c in cs) {
var fs = c.GetSupportedFormats();
if (fs == null) continue;
foreach (var f in fs) {
if (f == null) continue;
if (!converters.ContainsKey(f))
converters.Add(f, new List<ResourceConverter> { c });
else converters[f].Add(c);
}
}
}
var fs2 = ext.GetResourceFinders();
if (fs2 != null) {
foreach (var f in fs2) {
var name = f.Name;
var path = f.GetRootPath();
if (name != null && path != null)
localRes.Add(name, path);
}
}
Logger.Log("main", 1, "Resource", "Loaded extension {0}", ReflectionHelper.GetNamespaceQualifiedName(type));
}
catch (Exception ex) {
Logger.Log("main", 4, "Resource", "Failed to initialize extension {0}: {1}", ReflectionHelper.GetNamespaceQualifiedName(type), ex);
}
}
if (!_init) {
_init = true;
ExtensionManager.Init(rootPath);
}
}
@@ -149,14 +115,15 @@ namespace Cryville.Crtr.Browsing {
public bool ImportItemFrom(string path) {
var file = new FileInfo(path);
if (!converters.ContainsKey(file.Extension)) return false;
foreach (var converter in converters[file.Extension]) {
IEnumerable<ResourceConverter> converters;
if (!ExtensionManager.TryGetConverters(file.Extension, out converters)) return false;
foreach (var converter in converters) {
IEnumerable<Resource> resources = null;
try {
resources = converter.ConvertFrom(file);
}
catch (Exception ex) {
LogAndPopup(4, ex.Message);
LogAndPopupExtra(4, ex, "Failed to import resource: {0}", ex.Message);
return false;
}
foreach (var res in resources) {
@@ -168,7 +135,7 @@ namespace Cryville.Crtr.Browsing {
var dir = new DirectoryInfo(_rootPath + "/charts/" + res.Name);
if (!dir.Exists) dir.Create();
using (var writer = new StreamWriter(dir.FullName + "/.json")) {
writer.Write(JsonConvert.SerializeObject(tres.Main, Game.GlobalJsonSerializerSettings));
writer.Write(JsonConvert.SerializeObject(ConvertChartData(tres.Main), Game.GlobalJsonSerializerSettings));
}
using (var writer = new StreamWriter(dir.FullName + "/.umgc")) {
tres.Meta.data = "";
@@ -219,12 +186,89 @@ namespace Cryville.Crtr.Browsing {
Popup.Create(msg);
}
public string[] GetSupportedFormats() {
return converters.Keys.ToArray();
void LogAndPopupExtra(int level, object extraLog, string format, params object[] args) {
var msg = string.Format(format, args);
Logger.Log("main", level, "Resource", "{0}\n{1}", msg, extraLog);
Popup.Create(msg);
}
public Dictionary<string, string> GetPresetPaths() {
return localRes;
public string[] GetSupportedFormats() {
return ExtensionManager.GetSupportedFormats().ToArray();
}
public IReadOnlyDictionary<string, string> GetPresetPaths() {
return ExtensionManager.GetLocalResourcePaths();
}
static Chart ConvertChartData(ChartData i) {
return new Chart {
endtime = ConvertBeatTime(i.endtime),
format = i.format,
groups = ConvertGroups(i.groups),
motions = ConvertMotions(i.motions),
ruleset = i.ruleset,
sigs = ConvertSignatures(i.sigs),
sounds = ConvertSounds(i.sounds),
time = ConvertBeatTime(i.time),
};
}
static BeatTime? ConvertBeatTime(Extension.BeatTime? value) {
if (value == null) return null;
return new BeatTime(value.Value.b, value.Value.n, value.Value.d);
}
static List<Chart.Group> ConvertGroups(List<ChartData.Group> l) {
return l.Select(i => new Chart.Group {
endtime = ConvertBeatTime(i.endtime),
motions = ConvertMotions(i.motions),
notes = ConvertNotes(i.notes),
time = ConvertBeatTime(i.time),
tracks = ConvertTracks(i.tracks),
}).ToList();
}
static List<Chart.Judge> ConvertJudges(List<ChartData.Judge> l) {
return l.Select(i => new Chart.Judge {
endtime = ConvertBeatTime(i.endtime),
name = i.name,
time = ConvertBeatTime(i.time),
}).ToList();
}
static List<Chart.Motion> ConvertMotions(List<ChartData.Motion> l) {
return l.Select(i => new Chart.Motion {
endtime = ConvertBeatTime(i.endtime),
motion = i.motion,
sumfix = i.sumfix,
time = ConvertBeatTime(i.time),
}).ToList();
}
static List<Chart.Note> ConvertNotes(List<ChartData.Note> l) {
return l.Select(i => new Chart.Note {
endtime = ConvertBeatTime(i.endtime),
judges = ConvertJudges(i.judges),
motions = ConvertMotions(i.motions),
time = ConvertBeatTime(i.time),
}).ToList();
}
static List<Chart.Signature> ConvertSignatures(List<ChartData.Signature> l) {
return l.Select(i => new Chart.Signature {
endtime = ConvertBeatTime(i.endtime),
tempo = i.tempo,
time = ConvertBeatTime(i.time),
}).ToList();
}
static List<Chart.Sound> ConvertSounds(List<ChartData.Sound> l) {
return l.Select(i => new Chart.Sound {
endtime = ConvertBeatTime(i.endtime),
id = i.id,
offset = i.offset,
time = ConvertBeatTime(i.time),
}).ToList();
}
static List<Chart.Track> ConvertTracks(List<ChartData.Track> l) {
return l.Select(i => new Chart.Track {
endtime = ConvertBeatTime(i.endtime),
motions = ConvertMotions(i.motions),
time = ConvertBeatTime(i.time),
}).ToList();
}
}
}

View File

@@ -1,6 +0,0 @@
namespace Cryville.Crtr.Browsing {
public abstract class LocalResourceFinder {
public abstract string Name { get; }
public abstract string GetRootPath();
}
}

View File

@@ -1,7 +1,7 @@
using Cryville.Common;
using Cryville.Common.Unity.UI;
using Cryville.Crtr.Config;
using Newtonsoft.Json;
using Cryville.Crtr.Extension;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
@@ -94,24 +94,4 @@ namespace Cryville.Crtr.Browsing {
public AsyncDelivery<Texture2D> Cover { get; set; }
public ChartMeta Meta { get; set; }
}
#pragma warning disable IDE1006
public class MetaInfo {
public string name { get; set; }
public string author { get; set; }
[JsonRequired]
public string data { get; set; }
}
public class SongMetaInfo {
public string name { get; set; }
public string author { get; set; }
}
public class ChartMeta : MetaInfo {
public SongMetaInfo song { get; set; }
public float length { get; set; }
public string ruleset { get; set; }
public int note_count { get; set; }
public string cover { get; set; }
}
#pragma warning restore IDE1006
}

View File

@@ -1,79 +0,0 @@
using Cryville.Common;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
namespace Cryville.Crtr.Browsing {
public abstract class ResourceConverter {
public abstract string[] GetSupportedFormats();
public abstract IEnumerable<Resource> ConvertFrom(FileInfo file);
}
public abstract class Resource {
protected Resource(string name) {
Name = StringUtils.EscapeFileName(name);
}
public string Name { get; private set; }
public abstract bool Valid { get; }
public override string ToString() {
return string.Format("{0} ({1})", Name, ReflectionHelper.GetSimpleName(GetType()));
}
}
public class RawChartResource : Resource {
public RawChartResource(string name, Chart main, ChartMeta meta) : base(name) {
Main = main; Meta = meta;
}
public Chart Main { get; private set; }
public ChartMeta Meta { get; private set; }
public override bool Valid { get { return true; } }
}
public abstract class FileResource : Resource {
public FileResource(string name, FileInfo master) : base(name) {
Master = master;
Attachments = new List<FileInfo>();
}
public FileInfo Master { get; private set; }
public List<FileInfo> Attachments { get; private set; }
public override bool Valid {
get {
if (!Master.Exists) return false;
foreach (var file in Attachments) {
if (!file.Exists) return false;
}
return true;
}
}
}
public class ChartResource : FileResource {
public ChartResource(string name, FileInfo master) : base(name, master) {
using (var reader = new StreamReader(master.FullName)) {
var meta = JsonConvert.DeserializeObject<ChartMeta>(reader.ReadToEnd());
Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, meta.data + ".json")));
if (meta.cover != null) Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, meta.cover)));
}
}
}
public class SongResource : FileResource {
public SongResource(string name, FileInfo master) : base(name, master) { }
}
public class RulesetResource : FileResource {
public RulesetResource(string name, FileInfo master) : base(name, master) {
using (var reader = new StreamReader(master.FullName)) {
var meta = JsonConvert.DeserializeObject<Ruleset>(reader.ReadToEnd());
Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, meta.data + ".pdt")));
}
}
}
public class SkinResource : FileResource {
public string RulesetName { get; private set; }
public SkinResource(string name, FileInfo master) : base(name, master) {
using (var reader = new StreamReader(master.FullName)) {
var meta = JsonConvert.DeserializeObject<Skin>(reader.ReadToEnd());
RulesetName = meta.ruleset;
Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, meta.data + ".pdt")));
foreach (var frame in meta.frames) {
Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, frame)));
}
}
}
}
}

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 2546fb1d514348842a14a03531be192d
timeCreated: 1637982768
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,20 +0,0 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace Cryville.Crtr.Browsing {
public class SkinResourceImporter : ResourceConverter {
static readonly string[] SUPPORTED_FORMATS = { ".umgs" };
public override string[] GetSupportedFormats() {
return SUPPORTED_FORMATS;
}
public override IEnumerable<Resource> ConvertFrom(FileInfo file) {
using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) {
var data = JsonConvert.DeserializeObject<Skin>(reader.ReadToEnd());
return new Resource[] { new SkinResource(data.name, file) };
}
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 5335612e48e4c3947808c99fb99411d5
guid: b35ffffce02252548a66e18cf98050e2
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@@ -0,0 +1,107 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using UnityEngine.Scripting;
namespace Cryville.Crtr.Extension {
[Preserve]
public static class RefTypes {
[Preserve]
public static void PreserveEnumerable() {
IEnumerable<object> p = Enumerable.Empty<object>();
p.All(i => false);
p.Any();
p.Any(i => false);
p.Cast<object>();
p.Concat(Enumerable.Empty<object>());
p.Contains(null);
p.Count();
p.Count(i => false);
p.DefaultIfEmpty();
p.DefaultIfEmpty(null);
p.Distinct();
p.ElementAt(0);
p.ElementAtOrDefault(0);
p.First();
p.First(i => false);
p.FirstOrDefault();
p.FirstOrDefault(i => false);
p.GetEnumerator();
p.Last();
p.Last(i => false);
p.LastOrDefault();
p.LastOrDefault(i => false);
p.LongCount();
p.LongCount(i => false);
p.OrderBy(i => i).ThenBy(i => i);
p.OrderByDescending(i => i).ThenByDescending(i => i);
p.Reverse();
p.Select(i => i);
p.Select((i, j) => false);
p.SequenceEqual(p);
p.Single();
p.Single(i => false);
p.SingleOrDefault();
p.SingleOrDefault(i => false);
p.Skip(0);
p.SkipLast(0);
p.SkipWhile(i => false);
p.SkipWhile((i, j) => false);
p.Take(0);
p.TakeLast(0);
p.TakeWhile(i => false);
p.TakeWhile((i, j) => false);
p.ToArray();
p.ToDictionary(i => new object());
p.ToDictionary(i => new object(), i => new object());
p.ToHashSet();
p.ToList();
p.Where(i => false);
p.Where((i, j) => false);
}
[Preserve]
public static void PreserveBinaryReader() {
BinaryReader p = new BinaryReader(null);
p.Close();
p.Dispose();
p.PeekChar();
p.Read();
p.ReadBoolean();
p.ReadByte();
p.ReadBytes(0);
p.ReadChar();
p.ReadChars(0);
p.ReadDouble();
p.ReadInt16();
p.ReadInt32();
p.ReadInt64();
p.ReadSByte();
p.ReadSingle();
p.ReadUInt16();
p.ReadUInt32();
p.ReadUInt64();
}
[Preserve]
public static void PreserveStreamReader() {
object _;
StreamReader p = new StreamReader((Stream)null);
p.Close();
_ = p.CurrentEncoding;
p.DiscardBufferedData();
p.Dispose();
_ = p.EndOfStream;
p.Peek();
p.Read();
p.ReadBlock(null, 0, 0);
p.ReadLine();
p.ReadToEnd();
}
[Preserve]
public static void PreserveConvert() {
Convert.ChangeType(0, typeof(byte));
Convert.ChangeType(0, typeof(byte), CultureInfo.InvariantCulture);
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 23377bf2926d93a4b8e3f3ab6040c7f2
guid: 29a6376ce10b77e4099d2613876f9549
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: b9bd9e24d7c553341a2a12391843542f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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);
}
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: e3c5a8bf05d5e284ba498e91cb0dd35e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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(),
};
}
}
}

View File

@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: dfd44d1c0681e4842a1f031556519042
folderAsset: yes
timeCreated: 1637936550
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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
}
}

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: b3624013a6911ba45933085332724ff1
timeCreated: 1637936498
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 3c9beaff62143a2468e18ad4642232c0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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; } }
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: b073cac7ce0d41a4f8ca589845678aa2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 68bacf7746cbeea42a78a7d55cfdbea0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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);
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 5c4a1fab8f53dd742ba6501d682eb7f6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 6823ead66b33bc048bbad48719feb25d
guid: 3fe9f91db8da80f459bcf70ff680644f
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@@ -1,9 +1,10 @@
using Newtonsoft.Json;
using Cryville.Crtr.Extension;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace Cryville.Crtr.Browsing {
namespace Cryville.Crtr.Extensions.Umg {
public class ChartResourceImporter : ResourceConverter {
static readonly string[] SUPPORTED_FORMATS = { ".umgc" };
public override string[] GetSupportedFormats() {
@@ -19,4 +20,13 @@ namespace Cryville.Crtr.Browsing {
}
}
}
public class ChartResource : FileResource {
public ChartResource(string name, FileInfo master) : base(name, master) {
using (var reader = new StreamReader(master.FullName)) {
var meta = JsonConvert.DeserializeObject<ChartMeta>(reader.ReadToEnd());
Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, meta.data + ".json")));
if (meta.cover != null) Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, meta.cover)));
}
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 168366bb891392b42a1d0a6bfa068ff3
guid: bfcd614ec96fbe543aa2b2f1630aac73
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,18 @@
using Cryville.Crtr.Extension;
using System.Collections.Generic;
namespace Cryville.Crtr.Extensions.Umg {
public class Extension : ExtensionInterface {
public override IEnumerable<ResourceConverter> GetResourceConverters() {
return new ResourceConverter[] {
new ChartResourceImporter(),
new RulesetResourceImporter(),
new SkinResourceImporter(),
};
}
public override IEnumerable<LocalResourceFinder> GetResourceFinders() {
return null;
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 4ffe72fef6ebb9e4da3571b4117f0d6d
guid: 323b670cbdea58644ac9ba20fc4c1a89
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,9 +1,10 @@
using Newtonsoft.Json;
using Cryville.Crtr.Extension;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace Cryville.Crtr.Browsing {
namespace Cryville.Crtr.Extensions.Umg {
public class RulesetResourceImporter : ResourceConverter {
static readonly string[] SUPPORTED_FORMATS = { ".umgr" };
public override string[] GetSupportedFormats() {
@@ -17,4 +18,12 @@ namespace Cryville.Crtr.Browsing {
}
}
}
public class RulesetResource : FileResource {
public RulesetResource(string name, FileInfo master) : base(name, master) {
using (var reader = new StreamReader(master.FullName)) {
var meta = JsonConvert.DeserializeObject<Ruleset>(reader.ReadToEnd());
Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, meta.data + ".pdt")));
}
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: f2c1531e76f19a647865f7ec335561cd
guid: 9e856b78a468f644191d62ab489ae089
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,34 @@
using Cryville.Crtr.Extension;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace Cryville.Crtr.Extensions.Umg {
public class SkinResourceImporter : ResourceConverter {
static readonly string[] SUPPORTED_FORMATS = { ".umgs" };
public override string[] GetSupportedFormats() {
return SUPPORTED_FORMATS;
}
public override IEnumerable<Resource> ConvertFrom(FileInfo file) {
using (StreamReader reader = new StreamReader(file.FullName, Encoding.UTF8)) {
var data = JsonConvert.DeserializeObject<Skin>(reader.ReadToEnd());
return new Resource[] { new SkinResource(data.name, file) };
}
}
}
public class SkinResource : FileResource {
public string RulesetName { get; private set; }
public SkinResource(string name, FileInfo master) : base(name, master) {
using (var reader = new StreamReader(master.FullName)) {
var meta = JsonConvert.DeserializeObject<Skin>(reader.ReadToEnd());
RulesetName = meta.ruleset;
Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, meta.data + ".pdt")));
foreach (var frame in meta.frames) {
Attachments.Add(new FileInfo(Path.Combine(master.Directory.FullName, frame)));
}
}
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 9904b4c21758c5046afc341fe2fa8845
guid: 2afd6abf146c2ee45ab749477b8c7fda
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: dbc046e7cabacbb4fbf74520399a7340
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 82838dd8639c2244caf3c830edfbc59c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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;
}
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 365d879536c05284fa2335a7676c6cf4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,7 +1,7 @@
using Cryville.Common;
using Cryville.Common.Collections.Generic;
using Cryville.Common.Pdt;
using Cryville.Crtr.Browsing;
using Cryville.Crtr.Extension;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;

View File

@@ -1,7 +1,7 @@
using Cryville.Common;
using Cryville.Common.Collections.Generic;
using Cryville.Common.Pdt;
using Cryville.Crtr.Browsing;
using Cryville.Crtr.Extension;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;

View File

@@ -2,8 +2,8 @@
"name": "Cryville.Crtr",
"rootNamespace": "",
"references": [
"GUID:d8ea0e0da3ad53a45b65c912ffcacab0",
"GUID:5686e5ee69d0e084c843d61c240d7fdb",
"GUID:13ba8ce62aa80c74598530029cb2d649",
"GUID:2922aa74af3b2854e81b8a8b286d8206",
"GUID:da293eebbcb9a4947a212534c52d1a32"
],

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 82458af35dc0eff4f9f5bcfc7ffd9482
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 81c3fbb9e3606dd40908ceb861f822ea
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,21 +0,0 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* Copyright (c) 2017-2018 Swan & The Quaver Team <support@quavergame.com>.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Quaver.API.Enums
{
public enum GameMode
{
Keys4 = 1,
Keys7 = 2
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: e80eaf8c181728041aefa03ada870aed
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,24 +0,0 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* Copyright (c) 2017-2018 Swan & The Quaver Team <support@quavergame.com>.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Quaver.API.Enums
{
[Flags]
public enum HitSounds
{
Normal = 1 << 0, // This is 1, but Normal should be played regardless if it's 0 or 1.
Whistle = 1 << 1, // 2
Finish = 1 << 2, // 4
Clap = 1 << 3 // 8
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 4d483d5965d754445b9a330ba2e8dfbc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,14 +0,0 @@
using System;
namespace Quaver.API.Enums
{
/// <summary>
/// Signature of a timing point
/// </summary>
[Serializable]
public enum TimeSignature
{
Quadruple = 4,
Triple = 3,
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: bb27bc1bd269d214b8d8b95b91992955
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 15da1854a8e5270489fd79b20f741c1a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 07f411a2b58802d408e547b9f1cf7ca7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 0cdc2cff3891fb34d91ee006bafca3a9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,54 +0,0 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* Copyright (c) 2017-2019 Swan & The Quaver Team <support@quavergame.com>.
*/
using System;
using System.Collections.Generic;
namespace Quaver.API.Maps.Structures
{
/// <summary>
/// CustomAudioSamples section of the .qua
/// </summary>
[Serializable]
public class CustomAudioSampleInfo
{
/// <summary>
/// The path to the audio sample.
/// </summary>
public string Path { get; set; }
/// <summary>
/// If true, the audio sample is always played back at 1.0x speed, regardless of the rate.
/// </summary>
public bool UnaffectedByRate { get; set; }
/// <summary>
/// By-value comparer, auto-generated by Rider.
/// </summary>
private sealed class ByValueEqualityComparer : IEqualityComparer<CustomAudioSampleInfo>
{
public bool Equals(CustomAudioSampleInfo x, CustomAudioSampleInfo y)
{
if (ReferenceEquals(x, y)) return true;
if (ReferenceEquals(x, null)) return false;
if (ReferenceEquals(y, null)) return false;
if (x.GetType() != y.GetType()) return false;
return string.Equals(x.Path, y.Path) && x.UnaffectedByRate == y.UnaffectedByRate;
}
public int GetHashCode(CustomAudioSampleInfo obj)
{
unchecked
{
return ((obj.Path != null ? obj.Path.GetHashCode() : 0) * 397) ^ obj.UnaffectedByRate.GetHashCode();
}
}
}
public static IEqualityComparer<CustomAudioSampleInfo> ByValueComparer { get; } = new ByValueEqualityComparer();
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 0690882ce72359c409a12dfa0b4999ba
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,79 +0,0 @@
using System;
using System.Collections.Generic;
using System.Drawing;
//using MoonSharp.Interpreter;
//using MoonSharp.Interpreter.Interop;
using YamlDotNet.Serialization;
namespace Quaver.API.Maps.Structures
{
[Serializable]
/*[MoonSharpUserData]*/
public class EditorLayerInfo
{
/// <summary>
/// The name of the layer
/// </summary>
public string Name { get; /*[MoonSharpVisible(false)]*/ set; }
/// <summary>
/// Is the layer hidden in the editor?
/// </summary>
public bool Hidden { get; /*[MoonSharpVisible(false)]*/ set; }
/// <summary>
/// The color of the layer (default is white)
/// </summary>
public string ColorRgb { get; /*[MoonSharpVisible(false)]*/ set; }
/// <summary>
/// Converts the stringified color to a System.Drawing color
/// </summary>
/// <returns></returns>
/*[MoonSharpVisible(false)]*/
public Color GetColor()
{
if (ColorRgb == null)
return Color.White;
var split = ColorRgb.Split(',');
try
{
return Color.FromArgb(byte.Parse(split[0]), byte.Parse(split[1]), byte.Parse(split[2]));
}
catch (Exception)
{
return Color.White;
}
}
/// <summary>
/// By-value comparer, auto-generated by Rider.
/// </summary>
private sealed class ByValueEqualityComparer : IEqualityComparer<EditorLayerInfo>
{
public bool Equals(EditorLayerInfo x, EditorLayerInfo y)
{
if (ReferenceEquals(x, y)) return true;
if (ReferenceEquals(x, null)) return false;
if (ReferenceEquals(y, null)) return false;
if (x.GetType() != y.GetType()) return false;
return string.Equals(x.Name, y.Name) && x.Hidden == y.Hidden && string.Equals(x.ColorRgb, y.ColorRgb);
}
public int GetHashCode(EditorLayerInfo obj)
{
unchecked
{
var hashCode = obj.Name.GetHashCode();
hashCode = (hashCode * 397) ^ obj.Hidden.GetHashCode();
hashCode = (hashCode * 397) ^ obj.ColorRgb.GetHashCode();
return hashCode;
}
}
}
public static IEqualityComparer<EditorLayerInfo> ByValueComparer { get; } = new ByValueEqualityComparer();
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: f5d19ab23108e3d41a2d77670afbab10
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,187 +0,0 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* Copyright (c) 2017-2019 Swan & The Quaver Team <support@quavergame.com>.
*/
using System;
using System.Collections.Generic;
using System.Linq;
//using MoonSharp.Interpreter;
//using MoonSharp.Interpreter.Interop;
using Quaver.API.Enums;
using YamlDotNet.Serialization;
namespace Quaver.API.Maps.Structures
{
/// <summary>
/// HitObjects section of the .qua
/// </summary>
/*[MoonSharpUserData]*/
[Serializable]
public class HitObjectInfo
{
/// <summary>
/// The time in milliseconds when the HitObject is supposed to be hit.
/// </summary>
public int StartTime
{
get;
/*[MoonSharpVisible(false)]*/ set;
}
/// <summary>
/// The lane the HitObject falls in
/// </summary>
public int Lane
{
get;
/*MoonSharpVisible(false)]*/ set;
}
/// <summary>
/// The endtime of the HitObject (if greater than 0, it's considered a hold note.)
/// </summary>
public int EndTime
{
get;
/*[MoonSharpVisible(false)]*/ set;
}
/// <summary>
/// Bitwise combination of hit sounds for this object
/// </summary>
public HitSounds HitSound
{
get;
/*[MoonSharpVisible(false)]*/ set;
}
/// <summary>
/// Key sounds to play when this object is hit.
/// </summary>
/*[MoonSharpVisible(false)]*/
public List<KeySoundInfo> KeySounds { get; set; } = new List<KeySoundInfo>();
/// <summary>
/// The layer in the editor that the object belongs to.
/// </summary>
public int EditorLayer
{
get;
/*[MoonSharpVisible(false)]*/ set;
}
/// <summary>
/// If the object is a long note. (EndTime > 0)
/// </summary>
[YamlIgnore]
public bool IsLongNote => EndTime > 0;
/// <summary>
/// Returns if the object is allowed to be edited in lua scripts
/// </summary>
[YamlIgnore]
public bool IsEditableInLuaScript
{
get;
/*[MoonSharpVisible(false)]*/ set;
}
/// <summary>
/// Gets the timing point this object is in range of.
/// </summary>
/// <returns></returns>
public TimingPointInfo GetTimingPoint(List<TimingPointInfo> timingPoints)
{
// Search through the entire list for the correct point
for (var i = timingPoints.Count - 1; i >= 0; i--)
{
if (StartTime >= timingPoints[i].StartTime)
return timingPoints[i];
}
return timingPoints.First();
}
/// <summary>
/// </summary>
/// <param name="time"></param>
/// <exception cref="InvalidOperationException"></exception>
public void SetStartTime(int time)
{
ThrowUneditableException();
StartTime = time;
}
/// <summary>
/// </summary>
/// <exception cref="InvalidOperationException"></exception>
public void SetEndTime(int time)
{
ThrowUneditableException();
EndTime = time;
}
/// <summary>
/// </summary>
/// <param name="lane"></param>
public void SetLane(int lane)
{
ThrowUneditableException();
Lane = lane;
}
/// <summary>
/// </summary>
/// <param name="hitsounds"></param>
public void SetHitSounds(HitSounds hitsounds)
{
ThrowUneditableException();
HitSound = hitsounds;
}
/// <summary>
/// </summary>
/// <exception cref="InvalidOperationException"></exception>
private void ThrowUneditableException()
{
if (!IsEditableInLuaScript)
throw new InvalidOperationException("Value is not allowed to be edited in lua scripts.");
}
/// <summary>
/// By-value comparer, mostly auto-generated by Rider: KeySounds-related code is changed to by-value.
/// </summary>
private sealed class ByValueEqualityComparer : IEqualityComparer<HitObjectInfo>
{
public bool Equals(HitObjectInfo x, HitObjectInfo y)
{
if (ReferenceEquals(x, y)) return true;
if (ReferenceEquals(x, null)) return false;
if (ReferenceEquals(y, null)) return false;
if (x.GetType() != y.GetType()) return false;
return x.StartTime == y.StartTime && x.Lane == y.Lane && x.EndTime == y.EndTime && x.HitSound == y.HitSound && x.KeySounds.SequenceEqual(y.KeySounds, KeySoundInfo.ByValueComparer) && x.EditorLayer == y.EditorLayer;
}
public int GetHashCode(HitObjectInfo obj)
{
unchecked
{
var hashCode = obj.StartTime;
hashCode = (hashCode * 397) ^ obj.Lane;
hashCode = (hashCode * 397) ^ obj.EndTime;
hashCode = (hashCode * 397) ^ (int) obj.HitSound;
foreach (var keySound in obj.KeySounds)
hashCode = (hashCode * 397) ^ KeySoundInfo.ByValueComparer.GetHashCode(keySound);
hashCode = (hashCode * 397) ^ obj.EditorLayer;
return hashCode;
}
}
}
public static IEqualityComparer<HitObjectInfo> ByValueComparer { get; } = new ByValueEqualityComparer();
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 14fc15101f91a2c439d64f27a699da09
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,47 +0,0 @@
using System;
using System.Collections.Generic;
namespace Quaver.API.Maps.Structures
{
/// <summary>
/// KeySounds property of hit objects.
/// </summary>
[Serializable]
public class KeySoundInfo
{
/// <summary>
/// The one-based index of the sound sample in the CustomAudioSamples array.
/// </summary>
public int Sample { get; set; }
/// <summary>
/// The volume of the sound sample. Defaults to 100.
/// </summary>
public int Volume { get; set; }
/// <summary>
/// By-value comparer, auto-generated by Rider.
/// </summary>
private sealed class ByValueEqualityComparer : IEqualityComparer<KeySoundInfo>
{
public bool Equals(KeySoundInfo x, KeySoundInfo y)
{
if (ReferenceEquals(x, y)) return true;
if (ReferenceEquals(x, null)) return false;
if (ReferenceEquals(y, null)) return false;
if (x.GetType() != y.GetType()) return false;
return x.Sample == y.Sample && x.Volume == y.Volume;
}
public int GetHashCode(KeySoundInfo obj)
{
unchecked
{
return (obj.Sample * 397) ^ obj.Volume;
}
}
}
public static IEqualityComparer<KeySoundInfo> ByValueComparer { get; } = new ByValueEqualityComparer();
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: ad94e179dbb3a5e47b47c8475e3e707f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,109 +0,0 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* Copyright (c) 2017-2019 Swan & The Quaver Team <support@quavergame.com>.
*/
using System;
using System.Collections.Generic;
//using MoonSharp.Interpreter;
//using MoonSharp.Interpreter.Interop;
using YamlDotNet.Serialization;
namespace Quaver.API.Maps.Structures
{
/// <summary>
/// SliderVelocities section of the .qua
/// </summary>
[Serializable]
/*[MoonSharpUserData]*/
public class SliderVelocityInfo
{
/// <summary>
/// The time in milliseconds when the new SliderVelocity section begins
/// </summary>
public float StartTime
{
get;
/*[MoonSharpVisible(false)]*/ set;
}
/// <summary>
/// The velocity multiplier relative to the current timing section's BPM
/// </summary>
public float Multiplier
{
get;
/*[MoonSharpVisible(false)]*/ set;
}
/// <summary>
/// Returns if the SV is allowed to be edited in lua scripts
/// </summary>
[YamlIgnore]
public bool IsEditableInLuaScript
{
get;
/*[MoonSharpVisible(false)]*/ set;
}
/// <summary>
/// Sets the start time of the SV.
/// FOR USE IN LUA SCRIPTS ONLY.
/// </summary>
/// <param name="time"></param>
/// <exception cref="InvalidOperationException"></exception>
public void SetStartTime(float time)
{
ThrowUneditableException();
StartTime = time;
}
/// <summary>
/// Sets the multiplier of the SV.
/// FOR USE IN LUA SCRIPTS ONLY.
/// </summary>
/// <param name="multiplier"></param>
/// <exception cref="InvalidOperationException"></exception>
public void SetMultiplier(float multiplier)
{
ThrowUneditableException();
Multiplier = multiplier;
}
/// <summary>
/// </summary>
/// <exception cref="InvalidOperationException"></exception>
private void ThrowUneditableException()
{
if (!IsEditableInLuaScript)
throw new InvalidOperationException("Value is not allowed to be edited in lua scripts.");
}
/// <summary>
/// By-value comparer, auto-generated by Rider.
/// </summary>
private sealed class ByValueEqualityComparer : IEqualityComparer<SliderVelocityInfo>
{
public bool Equals(SliderVelocityInfo x, SliderVelocityInfo y)
{
if (ReferenceEquals(x, y)) return true;
if (ReferenceEquals(x, null)) return false;
if (ReferenceEquals(y, null)) return false;
if (x.GetType() != y.GetType()) return false;
return x.StartTime.Equals(y.StartTime) && x.Multiplier.Equals(y.Multiplier);
}
public int GetHashCode(SliderVelocityInfo obj)
{
unchecked
{
return (obj.StartTime.GetHashCode() * 397) ^ obj.Multiplier.GetHashCode();
}
}
}
public static IEqualityComparer<SliderVelocityInfo> ByValueComparer { get; } = new ByValueEqualityComparer();
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: cebb7330d6e4d9b4da4ceb367c1a2fd4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,62 +0,0 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* Copyright (c) 2017-2019 Swan & The Quaver Team <support@quavergame.com>.
*/
using System;
using System.Collections.Generic;
namespace Quaver.API.Maps.Structures
{
/// <summary>
/// SoundEffects section of the .qua
/// </summary>
[Serializable]
public class SoundEffectInfo
{
/// <summary>
/// The time at which to play the sound sample.
/// </summary>
public float StartTime { get; set; }
/// <summary>
/// The one-based index of the sound sample in the CustomAudioSamples array.
/// </summary>
public int Sample { get; set; }
/// <summary>
/// The volume of the sound sample. Defaults to 100.
/// </summary>
public int Volume { get; set; }
/// <summary>
/// By-value comparer, auto-generated by Rider.
/// </summary>
private sealed class ByValueEqualityComparer : IEqualityComparer<SoundEffectInfo>
{
public bool Equals(SoundEffectInfo x, SoundEffectInfo y)
{
if (ReferenceEquals(x, y)) return true;
if (ReferenceEquals(x, null)) return false;
if (ReferenceEquals(y, null)) return false;
if (x.GetType() != y.GetType()) return false;
return x.StartTime.Equals(y.StartTime) && x.Sample == y.Sample && x.Volume == y.Volume;
}
public int GetHashCode(SoundEffectInfo obj)
{
unchecked
{
var hashCode = obj.StartTime.GetHashCode();
hashCode = (hashCode * 397) ^ obj.Sample;
hashCode = (hashCode * 397) ^ obj.Volume;
return hashCode;
}
}
}
public static IEqualityComparer<SoundEffectInfo> ByValueComparer { get; } = new ByValueEqualityComparer();
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 2f1502b1df0fdb9459d43358ed857875
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,102 +0,0 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* Copyright (c) 2017-2019 Swan & The Quaver Team <support@quavergame.com>.
*/
using System;
using System.Collections.Generic;
//using MoonSharp.Interpreter;
//using MoonSharp.Interpreter.Interop;
using Quaver.API.Enums;
using YamlDotNet.Serialization;
namespace Quaver.API.Maps.Structures
{
/// <summary>
/// TimingPoints section of the .qua
/// </summary>
[Serializable]
/*[MoonSharpUserData]*/
public class TimingPointInfo
{
/// <summary>
/// The time in milliseconds for when this timing point begins
/// </summary>
public float StartTime
{
get;
/*[MoonSharpVisible(false)]*/ set;
}
/// <summary>
/// The BPM during this timing point
/// </summary>
public float Bpm
{
get;
/*[MoonSharpVisible(false)]*/ set;
}
/// <summary>
/// The signature during this timing point
/// </summary>
public TimeSignature Signature
{
get;
/*[MoonSharpVisible(false)]*/ set;
}
/// <summary>
/// Whether timing lines during this timing point should be hidden or not
/// </summary>
public bool Hidden
{
get;
/*[MoonSharpVisible(false)]*/ set;
}
[YamlIgnore]
public bool IsEditableInLuaScript
{
get;
/*[MoonSharpVisible(false)]*/ set;
}
/// <summary>
/// The amount of milliseconds per beat this one takes up.
/// </summary>
[YamlIgnore]
public float MillisecondsPerBeat => 60000 / Bpm;
/// <summary>
/// By-value comparer, auto-generated by Rider.
/// </summary>
private sealed class ByValueEqualityComparer : IEqualityComparer<TimingPointInfo>
{
public bool Equals(TimingPointInfo x, TimingPointInfo y)
{
if (ReferenceEquals(x, y)) return true;
if (ReferenceEquals(x, null)) return false;
if (ReferenceEquals(y, null)) return false;
if (x.GetType() != y.GetType()) return false;
return x.StartTime.Equals(y.StartTime) && x.Bpm.Equals(y.Bpm) && x.Signature == y.Signature && x.Hidden == y.Hidden;
}
public int GetHashCode(TimingPointInfo obj)
{
unchecked
{
var hashCode = obj.StartTime.GetHashCode();
hashCode = (hashCode * 397) ^ obj.Bpm.GetHashCode();
hashCode = (hashCode * 397) ^ (int) obj.Signature;
hashCode = (hashCode * 397) ^ (obj.Hidden ? 1 : 0);
return hashCode;
}
}
}
public static IEqualityComparer<TimingPointInfo> ByValueComparer { get; } = new ByValueEqualityComparer();
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 02c7f0a85b74dc34cad4f1e3dea4dbbc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,16 +0,0 @@
{
"name": "Quaver.API",
"rootNamespace": "",
"references": [
"GUID:b3f49edfedc855a48aa1a9e5d3cba438"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": true
}

View File

@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: d8ea0e0da3ad53a45b65c912ffcacab0
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: d79db49599a8b74419a35dc3a06a1aee
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 47f861a77858b7b42b0e57f60f5ccace
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 9a19996d4b24ff14f99f7b17e0b45ecf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: cbe04dd6a5622cf4fb8a12e664da340d
folderAsset: yes
timeCreated: 1427145262
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,76 +0,0 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System;
using System.Text.RegularExpressions;
namespace YamlDotNet.Core
{
public struct AnchorName : IEquatable<AnchorName>
{
public static readonly AnchorName Empty = default;
// https://yaml.org/spec/1.2/spec.html#id2785586
private static readonly Regex AnchorPattern = new Regex(@"^[^\[\]\{\},]+$", StandardRegexOptions.Compiled);
private readonly string? value;
public string Value => value ?? throw new InvalidOperationException("Cannot read the Value of an empty anchor");
public bool IsEmpty => value is null;
public AnchorName(string value)
{
this.value = value ?? throw new ArgumentNullException(nameof(value));
if (!AnchorPattern.IsMatch(value))
{
throw new ArgumentException($"Anchor cannot be empty or contain disallowed characters: []{{}},\nThe value was '{value}'.", nameof(value));
}
}
public override string ToString() => value ?? "[empty]";
public bool Equals(AnchorName other) => Equals(value, other.value);
public override bool Equals(object? obj)
{
return obj is AnchorName other && Equals(other);
}
public override int GetHashCode()
{
return value?.GetHashCode() ?? 0;
}
public static bool operator ==(AnchorName left, AnchorName right)
{
return left.Equals(right);
}
public static bool operator !=(AnchorName left, AnchorName right)
{
return !(left == right);
}
public static implicit operator AnchorName(string? value) => value == null ? Empty : new AnchorName(value);
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 4b743e73dd5df19488bf7108b4a7e5a8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,58 +0,0 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System;
namespace YamlDotNet.Core
{
/// <summary>
/// The exception that is thrown when an alias references an anchor that does not exist.
/// </summary>
public class AnchorNotFoundException : YamlException
{
/// <summary>
/// Initializes a new instance of the <see cref="AnchorNotFoundException"/> class.
/// </summary>
/// <param name="message">The message.</param>
public AnchorNotFoundException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="AnchorNotFoundException"/> class.
/// </summary>
public AnchorNotFoundException(Mark start, Mark end, string message)
: base(start, end, message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="AnchorNotFoundException"/> class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="inner">The inner.</param>
public AnchorNotFoundException(string message, Exception inner)
: base(message, inner)
{
}
}
}

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: bef940054d2c25041ba1a961abae6c79
timeCreated: 1427145266
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,166 +0,0 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System;
using System.Diagnostics;
namespace YamlDotNet.Core
{
internal sealed class CharacterAnalyzer<TBuffer> where TBuffer : class, ILookAheadBuffer
{
public CharacterAnalyzer(TBuffer buffer)
{
this.Buffer = buffer ?? throw new ArgumentNullException(nameof(buffer));
}
public TBuffer Buffer { get; }
public bool EndOfInput => Buffer.EndOfInput;
public char Peek(int offset)
{
return Buffer.Peek(offset);
}
public void Skip(int length)
{
Buffer.Skip(length);
}
public bool IsAlphaNumericDashOrUnderscore(int offset = 0)
{
var character = Buffer.Peek(offset);
return
(character >= '0' && character <= '9') ||
(character >= 'A' && character <= 'Z') ||
(character >= 'a' && character <= 'z') ||
character == '_' ||
character == '-';
}
public bool IsAscii(int offset = 0)
{
return Buffer.Peek(offset) <= '\x7F';
}
public bool IsPrintable(int offset = 0)
{
var character = Buffer.Peek(offset);
return
character == '\x9' ||
character == '\xA' ||
character == '\xD' ||
(character >= '\x20' && character <= '\x7E') ||
character == '\x85' ||
(character >= '\xA0' && character <= '\xD7FF') ||
(character >= '\xE000' && character <= '\xFFFD');
}
public bool IsDigit(int offset = 0)
{
var character = Buffer.Peek(offset);
return character >= '0' && character <= '9';
}
public int AsDigit(int offset = 0)
{
return Buffer.Peek(offset) - '0';
}
public bool IsHex(int offset)
{
var character = Buffer.Peek(offset);
return
(character >= '0' && character <= '9') ||
(character >= 'A' && character <= 'F') ||
(character >= 'a' && character <= 'f');
}
public int AsHex(int offset)
{
var character = Buffer.Peek(offset);
if (character <= '9')
{
return character - '0';
}
if (character <= 'F')
{
return character - 'A' + 10;
}
return character - 'a' + 10;
}
public bool IsSpace(int offset = 0)
{
return Check(' ', offset);
}
public bool IsZero(int offset = 0)
{
return Check('\0', offset);
}
public bool IsTab(int offset = 0)
{
return Check('\t', offset);
}
public bool IsWhite(int offset = 0)
{
return IsSpace(offset) || IsTab(offset);
}
public bool IsBreak(int offset = 0)
{
return Check("\r\n\x85\x2028\x2029", offset);
}
public bool IsCrLf(int offset = 0)
{
return Check('\r', offset) && Check('\n', offset + 1);
}
public bool IsBreakOrZero(int offset = 0)
{
return IsBreak(offset) || IsZero(offset);
}
public bool IsWhiteBreakOrZero(int offset = 0)
{
return IsWhite(offset) || IsBreakOrZero(offset);
}
public bool Check(char expected, int offset = 0)
{
return Buffer.Peek(offset) == expected;
}
public bool Check(string expectedCharacters, int offset = 0)
{
// Todo: using it this way doesn't break anything, it's not really wrong...
Debug.Assert(expectedCharacters.Length > 1, "Use Check(char, int) instead.");
var character = Buffer.Peek(offset);
return expectedCharacters.IndexOf(character) != -1;
}
}
}

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: cdb65e878b6f92347849551efad9eb74
timeCreated: 1427145266
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,40 +0,0 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using YamlDotNet.Core.Tokens;
namespace YamlDotNet.Core
{
/// <summary>
/// Defines constants that relate to the YAML specification.
/// </summary>
public static class Constants
{
public static readonly TagDirective[] DefaultTagDirectives =
{
new TagDirective("!", "!"),
new TagDirective("!!", "tag:yaml.org,2002:")
};
public const int MajorVersion = 1;
public const int MinorVersion = 3;
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 6143f3f95b0bcb74c92b9996309fab40
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,69 +0,0 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
namespace YamlDotNet.Core
{
public sealed class Cursor
{
public int Index { get; private set; }
public int Line { get; private set; }
public int LineOffset { get; private set; }
public Cursor()
{
Line = 1;
}
public Cursor(Cursor cursor)
{
Index = cursor.Index;
Line = cursor.Line;
LineOffset = cursor.LineOffset;
}
public Mark Mark()
{
return new Mark(Index, Line, LineOffset + 1);
}
public void Skip()
{
Index++;
LineOffset++;
}
public void SkipLineByOffset(int offset)
{
Index += offset;
Line++;
LineOffset = 0;
}
public void ForceSkipLineAfterNonBreak()
{
if (LineOffset != 0)
{
Line++;
LineOffset = 0;
}
}
}
}

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: b4262bdec0f3c254b9a29e755ba3a609
timeCreated: 1427145265
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: f526134efcd8e424c86e492f85fc56ba
timeCreated: 1427145267
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,159 +0,0 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System;
namespace YamlDotNet.Core
{
public sealed class EmitterSettings
{
/// <summary>
/// The preferred indentation.
/// </summary>
public int BestIndent { get; } = 2;
/// <summary>
/// The preferred text width.
/// </summary>
public int BestWidth { get; } = int.MaxValue;
/// <summary>
/// If true, write the output in canonical form.
/// </summary>
public bool IsCanonical { get; } = false;
/// <summary>
/// If true, write output without anchor names.
/// </summary>
public bool SkipAnchorName { get; private set; }
/// <summary>
/// The maximum allowed length for simple keys.
/// </summary>
/// <remarks>
/// The specifiction mandates 1024 characters, but any desired value may be used.
/// </remarks>
public int MaxSimpleKeyLength { get; } = 1024;
/// <summary>
/// Indent sequences. The default is to not indent.
/// </summary>
public bool IndentSequences { get; } = false;
public static readonly EmitterSettings Default = new EmitterSettings();
public EmitterSettings()
{
}
public EmitterSettings(int bestIndent, int bestWidth, bool isCanonical, int maxSimpleKeyLength, bool skipAnchorName = false, bool indentSequences = false)
{
if (bestIndent < 2 || bestIndent > 9)
{
throw new ArgumentOutOfRangeException(nameof(bestIndent), $"BestIndent must be between 2 and 9, inclusive");
}
if (bestWidth <= bestIndent * 2)
{
throw new ArgumentOutOfRangeException(nameof(bestWidth), "BestWidth must be greater than BestIndent x 2.");
}
if (maxSimpleKeyLength < 0)
{
throw new ArgumentOutOfRangeException(nameof(maxSimpleKeyLength), "MaxSimpleKeyLength must be >= 0");
}
BestIndent = bestIndent;
BestWidth = bestWidth;
IsCanonical = isCanonical;
MaxSimpleKeyLength = maxSimpleKeyLength;
SkipAnchorName = skipAnchorName;
IndentSequences = indentSequences;
}
public EmitterSettings WithBestIndent(int bestIndent)
{
return new EmitterSettings(
bestIndent,
BestWidth,
IsCanonical,
MaxSimpleKeyLength,
SkipAnchorName
);
}
public EmitterSettings WithBestWidth(int bestWidth)
{
return new EmitterSettings(
BestIndent,
bestWidth,
IsCanonical,
MaxSimpleKeyLength,
SkipAnchorName
);
}
public EmitterSettings WithMaxSimpleKeyLength(int maxSimpleKeyLength)
{
return new EmitterSettings(
BestIndent,
BestWidth,
IsCanonical,
maxSimpleKeyLength,
SkipAnchorName
);
}
public EmitterSettings Canonical()
{
return new EmitterSettings(
BestIndent,
BestWidth,
true,
MaxSimpleKeyLength,
SkipAnchorName
);
}
public EmitterSettings WithoutAnchorName()
{
return new EmitterSettings(
BestIndent,
BestWidth,
IsCanonical,
MaxSimpleKeyLength,
true
);
}
public EmitterSettings WithIndentedSequences()
{
return new EmitterSettings(
BestIndent,
BestWidth,
IsCanonical,
MaxSimpleKeyLength,
SkipAnchorName,
true
);
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 7496371f913cd4a4aa6e1d7009a88169
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,45 +0,0 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
namespace YamlDotNet.Core
{
internal enum EmitterState
{
StreamStart,
StreamEnd,
FirstDocumentStart,
DocumentStart,
DocumentContent,
DocumentEnd,
FlowSequenceFirstItem,
FlowSequenceItem,
FlowMappingFirstKey,
FlowMappingKey,
FlowMappingSimpleValue,
FlowMappingValue,
BlockSequenceFirstItem,
BlockSequenceItem,
BlockMappingFirstKey,
BlockMappingKey,
BlockMappingSimpleValue,
BlockMappingValue
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 7127212075b19ce4f99a370f02d26037
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,9 +0,0 @@
fileFormatVersion: 2
guid: 2dd1df9756078164587ab6fc3579145d
folderAsset: yes
timeCreated: 1427145262
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,85 +0,0 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
namespace YamlDotNet.Core.Events
{
/// <summary>
/// Represents an alias event.
/// </summary>
public sealed class AnchorAlias : ParsingEvent
{
/// <summary>
/// Gets the event type, which allows for simpler type comparisons.
/// </summary>
internal override EventType Type => EventType.Alias;
/// <summary>
/// Gets the value of the alias.
/// </summary>
public AnchorName Value { get; }
/// <summary>
/// Initializes a new instance of the <see cref="AnchorAlias"/> class.
/// </summary>
/// <param name="value">The value of the alias.</param>
/// <param name="start">The start position of the event.</param>
/// <param name="end">The end position of the event.</param>
public AnchorAlias(AnchorName value, Mark start, Mark end)
: base(start, end)
{
if (value.IsEmpty)
{
throw new YamlException(start, end, "Anchor value must not be empty.");
}
this.Value = value;
}
/// <summary>
/// Initializes a new instance of the <see cref="AnchorAlias"/> class.
/// </summary>
/// <param name="value">The value of the alias.</param>
public AnchorAlias(AnchorName value)
: this(value, Mark.Empty, Mark.Empty)
{
}
/// <summary>
/// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
/// </summary>
/// <returns>
/// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
/// </returns>
public override string ToString()
{
return $"Alias [value = {Value}]";
}
/// <summary>
/// Invokes run-time type specific Visit() method of the specified visitor.
/// </summary>
/// <param name="visitor">visitor, may not be null.</param>
public override void Accept(IParsingEventVisitor visitor)
{
visitor.Visit(this);
}
}
}

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 09b29b54793d9644398fe8e4da326353
timeCreated: 1427145262
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,59 +0,0 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
namespace YamlDotNet.Core.Events
{
public sealed class Comment : ParsingEvent
{
public string Value { get; }
public bool IsInline { get; }
public Comment(string value, bool isInline)
: this(value, isInline, Mark.Empty, Mark.Empty)
{
}
public Comment(string value, bool isInline, Mark start, Mark end)
: base(start, end)
{
Value = value;
IsInline = isInline;
}
internal override EventType Type => EventType.Comment;
public override void Accept(IParsingEventVisitor visitor)
{
visitor.Visit(this);
}
/// <summary>
/// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
/// </summary>
/// <returns>
/// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
/// </returns>
public override string ToString()
{
return $"{(IsInline ? "Inline" : "Block")} Comment [{Value}]";
}
}
}

Some files were not shown because too many files have changed in this diff Show More