Add QuaverChartConverter.
This commit is contained in:
8
Assets/Cryville/Crtr/Extensions/Quaver.meta
Normal file
8
Assets/Cryville/Crtr/Extensions/Quaver.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6823ead66b33bc048bbad48719feb25d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
149
Assets/Cryville/Crtr/Extensions/Quaver/QuaverChartConverter.cs
Normal file
149
Assets/Cryville/Crtr/Extensions/Quaver/QuaverChartConverter.cs
Normal file
@@ -0,0 +1,149 @@
|
||||
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" };
|
||||
|
||||
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 = -src.TimingPoints[0].StartTime / 1e3f }
|
||||
},
|
||||
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);
|
||||
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;
|
||||
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");
|
||||
}
|
||||
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; } }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b073cac7ce0d41a4f8ca589845678aa2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Extensions.meta
Normal file
8
Assets/Extensions.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5335612e48e4c3947808c99fb99411d5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Extensions/Quaver.API.meta
Normal file
8
Assets/Extensions/Quaver.API.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82458af35dc0eff4f9f5bcfc7ffd9482
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Extensions/Quaver.API/Enums.meta
Normal file
8
Assets/Extensions/Quaver.API/Enums.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81c3fbb9e3606dd40908ceb861f822ea
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
21
Assets/Extensions/Quaver.API/Enums/GameMode.cs
Normal file
21
Assets/Extensions/Quaver.API/Enums/GameMode.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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
|
||||
}
|
||||
}
|
11
Assets/Extensions/Quaver.API/Enums/GameMode.cs.meta
Normal file
11
Assets/Extensions/Quaver.API/Enums/GameMode.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e80eaf8c181728041aefa03ada870aed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
24
Assets/Extensions/Quaver.API/Enums/Hitsounds.cs
Normal file
24
Assets/Extensions/Quaver.API/Enums/Hitsounds.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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
|
||||
}
|
||||
}
|
11
Assets/Extensions/Quaver.API/Enums/Hitsounds.cs.meta
Normal file
11
Assets/Extensions/Quaver.API/Enums/Hitsounds.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d483d5965d754445b9a330ba2e8dfbc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
14
Assets/Extensions/Quaver.API/Enums/TimeSignature.cs
Normal file
14
Assets/Extensions/Quaver.API/Enums/TimeSignature.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace Quaver.API.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// Signature of a timing point
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public enum TimeSignature
|
||||
{
|
||||
Quadruple = 4,
|
||||
Triple = 3,
|
||||
}
|
||||
}
|
11
Assets/Extensions/Quaver.API/Enums/TimeSignature.cs.meta
Normal file
11
Assets/Extensions/Quaver.API/Enums/TimeSignature.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bb27bc1bd269d214b8d8b95b91992955
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Extensions/Quaver.API/Maps.meta
Normal file
8
Assets/Extensions/Quaver.API/Maps.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15da1854a8e5270489fd79b20f741c1a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
1361
Assets/Extensions/Quaver.API/Maps/Qua.cs
Normal file
1361
Assets/Extensions/Quaver.API/Maps/Qua.cs
Normal file
File diff suppressed because it is too large
Load Diff
11
Assets/Extensions/Quaver.API/Maps/Qua.cs.meta
Normal file
11
Assets/Extensions/Quaver.API/Maps/Qua.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07f411a2b58802d408e547b9f1cf7ca7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Extensions/Quaver.API/Maps/Structures.meta
Normal file
8
Assets/Extensions/Quaver.API/Maps/Structures.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0cdc2cff3891fb34d91ee006bafca3a9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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();
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0690882ce72359c409a12dfa0b4999ba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,79 @@
|
||||
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();
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5d19ab23108e3d41a2d77670afbab10
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
187
Assets/Extensions/Quaver.API/Maps/Structures/HitObjectInfo.cs
Normal file
187
Assets/Extensions/Quaver.API/Maps/Structures/HitObjectInfo.cs
Normal file
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* 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();
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14fc15101f91a2c439d64f27a699da09
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
47
Assets/Extensions/Quaver.API/Maps/Structures/KeySoundInfo.cs
Normal file
47
Assets/Extensions/Quaver.API/Maps/Structures/KeySoundInfo.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
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();
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad94e179dbb3a5e47b47c8475e3e707f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* 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();
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cebb7330d6e4d9b4da4ceb367c1a2fd4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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();
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f1502b1df0fdb9459d43358ed857875
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
102
Assets/Extensions/Quaver.API/Maps/Structures/TimingPointInfo.cs
Normal file
102
Assets/Extensions/Quaver.API/Maps/Structures/TimingPointInfo.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* 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();
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02c7f0a85b74dc34cad4f1e3dea4dbbc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user