diff --git a/Apps/AcbMaker/DereTore.Apps.AcbMaker.csproj b/Apps/AcbMaker/DereTore.Apps.AcbMaker.csproj index 623847b..757ecf9 100644 --- a/Apps/AcbMaker/DereTore.Apps.AcbMaker.csproj +++ b/Apps/AcbMaker/DereTore.Apps.AcbMaker.csproj @@ -21,6 +21,7 @@ x64 prompt MinimumRecommendedRules.ruleset + 6 bin\x64\Release\ @@ -30,6 +31,7 @@ x64 prompt MinimumRecommendedRules.ruleset + 6 true @@ -39,6 +41,7 @@ x86 prompt MinimumRecommendedRules.ruleset + 6 bin\x86\Release\ @@ -48,6 +51,7 @@ x86 prompt MinimumRecommendedRules.ruleset + 6 diff --git a/Apps/AcbUnzip/DereTore.Apps.AcbUnzip.csproj b/Apps/AcbUnzip/DereTore.Apps.AcbUnzip.csproj index ce8506a..02c2eba 100644 --- a/Apps/AcbUnzip/DereTore.Apps.AcbUnzip.csproj +++ b/Apps/AcbUnzip/DereTore.Apps.AcbUnzip.csproj @@ -19,7 +19,7 @@ DEBUG;TRACE full x86 - 4 + 6 prompt MinimumRecommendedRules.ruleset @@ -29,7 +29,7 @@ true pdbonly x86 - 4 + 6 prompt MinimumRecommendedRules.ruleset @@ -39,7 +39,7 @@ DEBUG;TRACE full x64 - 4 + 6 prompt MinimumRecommendedRules.ruleset @@ -49,7 +49,7 @@ true pdbonly x64 - 4 + 6 prompt MinimumRecommendedRules.ruleset diff --git a/Apps/AcbUnzip/Program.cs b/Apps/AcbUnzip/Program.cs index ff733ee..3c06312 100644 --- a/Apps/AcbUnzip/Program.cs +++ b/Apps/AcbUnzip/Program.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using DereTore.Exchange.Archive.ACB; @@ -13,21 +13,40 @@ private static void Main(string[] args) { var fileName = args[0]; var fileInfo = new FileInfo(fileName); - var fullDirPath = Path.Combine(fileInfo.DirectoryName ?? string.Empty, string.Format(DirTemplate, fileInfo.Name)); + var fullDirPath = Path.Combine(fileInfo.DirectoryName, string.Format(DirTemplate, fileInfo.Name)); if (!Directory.Exists(fullDirPath)) { Directory.CreateDirectory(fullDirPath); } using (var acb = AcbFile.FromFile(fileName)) { - var fileNames = acb.GetFileNames(); - foreach (var s in fileNames) { + var archivedEntryNames = acb.GetFileNames(); + for (var i = 0; i < archivedEntryNames.Length; ++i) { + var isCueNonEmpty = archivedEntryNames[i] != null; + var s = archivedEntryNames[i] ?? AcbFile.GetSymbolicFileNameFromCueId((uint)i); var extractName = Path.Combine(fullDirPath, s); - using (var fs = new FileStream(extractName, FileMode.Create, FileAccess.Write)) { - using (var source = acb.OpenDataStream(s)) { - WriteFile(source, fs); + try { + using (var source = isCueNonEmpty ? acb.OpenDataStream(s) : acb.OpenDataStream((uint)i)) { + using (var fs = new FileStream(extractName, FileMode.Create, FileAccess.Write)) { + WriteFile(source, fs); + } + } + Console.WriteLine(s); + } catch (Exception ex) { + var origForeground = ConsoleColor.Gray; + try { + origForeground = Console.ForegroundColor; + } catch { + } + try { + Console.ForegroundColor = ConsoleColor.Red; + } catch { + } + Console.WriteLine(ex.Message); + try { + Console.ForegroundColor = origForeground; + } catch { } } - Console.WriteLine(s); } } } diff --git a/Apps/Hca2Wav/DereTore.Apps.Hca2Wav.csproj b/Apps/Hca2Wav/DereTore.Apps.Hca2Wav.csproj index ee21fb8..ddb39f7 100644 --- a/Apps/Hca2Wav/DereTore.Apps.Hca2Wav.csproj +++ b/Apps/Hca2Wav/DereTore.Apps.Hca2Wav.csproj @@ -22,6 +22,7 @@ x86 prompt MinimumRecommendedRules.ruleset + 6 bin\x86\Release\ @@ -31,6 +32,7 @@ x86 prompt MinimumRecommendedRules.ruleset + 6 true @@ -40,6 +42,7 @@ x64 prompt MinimumRecommendedRules.ruleset + 6 bin\x64\Release\ @@ -49,6 +52,7 @@ x64 prompt MinimumRecommendedRules.ruleset + 6 diff --git a/Apps/Hca2Wav/Options.cs b/Apps/Hca2Wav/Options.cs index 58628e9..7eabdfc 100644 --- a/Apps/Hca2Wav/Options.cs +++ b/Apps/Hca2Wav/Options.cs @@ -1,32 +1,35 @@ -using CommandLine; +using CommandLine; using DereTore.Common.StarlightStage; using DereTore.Exchange.Audio.HCA; namespace DereTore.Apps.Hca2Wav { public sealed class Options { - [Option('i', "in", Required = true)] + [ValueOption(0)] public string InputFileName { get; set; } = string.Empty; - [Option('o', "out", Required = false)] + [Option('o', "out", HelpText = "Output file name", Required = false)] public string OutputFileName { get; set; } = string.Empty; - [Option('a', "key1", Required = false)] + [Option('a', "key1", HelpText = "Key 1 (8 hex digits)", Required = false, DefaultValue = "f27e3b22")] public string Key1 { get; set; } = CgssCipher.Key1.ToString("x8"); - [Option('b', "key2", Required = false)] + [Option('b', "key2", HelpText = "Key 2 (8 hex digits)", Required = false, DefaultValue = "00003657")] public string Key2 { get; set; } = CgssCipher.Key2.ToString("x8"); - [Option("infinite", Required = false)] + [Option("infinite", HelpText = "Enables infinite loop", Required = false, DefaultValue = false)] public bool InfiniteLoop { get; set; } = AudioParams.Default.InfiniteLoop; - [Option('l', "loop", Required = false)] + [Option('l', "loop", HelpText = "Number of simulated loops", Required = false, DefaultValue = 0u)] public uint SimulatedLoopCount { get; set; } = AudioParams.Default.SimulatedLoopCount; - [Option('e', "header", Required = false)] - public bool OutputWaveHeader { get; set; } = true; + [Option('e', "no-header", HelpText = "Do not emit wave header", Required = false, DefaultValue = false)] + public bool NoWaveHeader { get; set; } - [Option('c', "cipher", Required = false)] + [Option("overrides-cipher", HelpText = "Overrides original cipher type", Required = false, DefaultValue = false)] + public bool OverridesCipherType { get; set; } + + [Option('c', "cipher", HelpText = "Overridden cipher type", Required = false, DefaultValue = 0u)] public uint OverriddenCipherType { get; set; } } diff --git a/Apps/Hca2Wav/Program.cs b/Apps/Hca2Wav/Program.cs index b0ca1e8..eb03a69 100644 --- a/Apps/Hca2Wav/Program.cs +++ b/Apps/Hca2Wav/Program.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Globalization; using System.IO; using DereTore.Common.StarlightStage; @@ -10,8 +10,21 @@ internal static class Program { private static int Main(string[] args) { var options = new Options(); var succeeded = CommandLine.Parser.Default.ParseArguments(args, options); + + if (string.IsNullOrWhiteSpace(options.InputFileName)) { + succeeded = false; + } + if (!succeeded) { - Console.WriteLine(HelpMessage); + var helpText = CommandLine.Text.HelpText.AutoBuild(options); + helpText.AddPreOptionsLine(" "); + helpText.AddPreOptionsLine("Usage: hca2wav [options]"); + Console.Error.WriteLine(helpText); + return CommandLine.Parser.DefaultExitCodeFail; + } + + if (!File.Exists(options.InputFileName)) { + Console.Error.WriteLine("File not found: {0}", options.InputFileName); return CommandLine.Parser.DefaultExitCodeFail; } @@ -25,7 +38,7 @@ private static int Main(string[] args) { var formatProvider = new NumberFormatInfo(); if (!string.IsNullOrWhiteSpace(options.Key1)) { if (!uint.TryParse(options.Key1, NumberStyles.HexNumber, formatProvider, out key1)) { - Console.WriteLine("ERROR: key 1 is of wrong format."); + Console.WriteLine("ERROR: key 1 is of wrong format. It should look like \"a1b2c3d4\"."); return CommandLine.Parser.DefaultExitCodeFail; } } else { @@ -33,7 +46,7 @@ private static int Main(string[] args) { } if (!string.IsNullOrWhiteSpace(options.Key2)) { if (!uint.TryParse(options.Key2, NumberStyles.HexNumber, formatProvider, out key2)) { - Console.WriteLine("ERROR: key 2 is of wrong format."); + Console.WriteLine("ERROR: key 2 is of wrong format. It should look like \"a1b2c3d4\"."); return CommandLine.Parser.DefaultExitCodeFail; } } else { @@ -45,10 +58,14 @@ private static int Main(string[] args) { var decodeParams = DecodeParams.CreateDefault(); decodeParams.Key1 = key1; decodeParams.Key2 = key2; + if (options.OverridesCipherType) { + decodeParams.CipherTypeOverrideEnabled = true; + decodeParams.OverriddenCipherType = (CipherType)options.OverriddenCipherType; + } var audioParams = AudioParams.CreateDefault(); audioParams.InfiniteLoop = options.InfiniteLoop; audioParams.SimulatedLoopCount = options.SimulatedLoopCount; - audioParams.OutputWaveHeader = options.OutputWaveHeader; + audioParams.OutputWaveHeader = !options.NoWaveHeader; using (var hcaStream = new HcaAudioStream(inputFileStream, decodeParams, audioParams)) { var read = 1; var dataBuffer = new byte[1024]; @@ -65,7 +82,5 @@ private static int Main(string[] args) { return 0; } - private static readonly string HelpMessage = "Usage: hca2wav.exe -i [-o .wav>] [-a ] [-b ] [-l ] [--infinite] [--header]"; - } } diff --git a/Apps/Hcacc/DereTore.Apps.Hcacc.csproj b/Apps/Hcacc/DereTore.Apps.Hcacc.csproj index 609bbb1..b96a412 100644 --- a/Apps/Hcacc/DereTore.Apps.Hcacc.csproj +++ b/Apps/Hcacc/DereTore.Apps.Hcacc.csproj @@ -21,6 +21,7 @@ x64 prompt MinimumRecommendedRules.ruleset + 6 bin\x64\Release\ @@ -30,6 +31,7 @@ x64 prompt MinimumRecommendedRules.ruleset + 6 true @@ -39,6 +41,7 @@ x86 prompt MinimumRecommendedRules.ruleset + 6 bin\x86\Release\ @@ -48,6 +51,7 @@ x86 prompt MinimumRecommendedRules.ruleset + 6 diff --git a/Apps/Hcaenc/DereTore.Apps.Hcaenc.csproj b/Apps/Hcaenc/DereTore.Apps.Hcaenc.csproj index 7350739..36a5edc 100644 --- a/Apps/Hcaenc/DereTore.Apps.Hcaenc.csproj +++ b/Apps/Hcaenc/DereTore.Apps.Hcaenc.csproj @@ -21,6 +21,7 @@ x86 prompt MinimumRecommendedRules.ruleset + 6 bin\x86\Release\ @@ -30,6 +31,7 @@ x86 prompt MinimumRecommendedRules.ruleset + 6 true @@ -39,6 +41,7 @@ x64 prompt MinimumRecommendedRules.ruleset + 6 bin\x64\Release\ @@ -48,6 +51,7 @@ x64 prompt MinimumRecommendedRules.ruleset + 6 diff --git a/Apps/JacketCreator/DereTore.Apps.JacketCreator.csproj b/Apps/JacketCreator/DereTore.Apps.JacketCreator.csproj index b90603d..119101f 100644 --- a/Apps/JacketCreator/DereTore.Apps.JacketCreator.csproj +++ b/Apps/JacketCreator/DereTore.Apps.JacketCreator.csproj @@ -20,6 +20,7 @@ x86 prompt MinimumRecommendedRules.ruleset + 6 bin\x86\Release\ @@ -29,6 +30,7 @@ x86 prompt MinimumRecommendedRules.ruleset + 6 true @@ -38,6 +40,7 @@ x64 prompt MinimumRecommendedRules.ruleset + 6 bin\x64\Release\ @@ -47,6 +50,7 @@ x64 prompt MinimumRecommendedRules.ruleset + 6 diff --git a/Apps/LZ4/DereTore.Apps.LZ4.csproj b/Apps/LZ4/DereTore.Apps.LZ4.csproj index e1bc1af..36b3467 100644 --- a/Apps/LZ4/DereTore.Apps.LZ4.csproj +++ b/Apps/LZ4/DereTore.Apps.LZ4.csproj @@ -20,6 +20,7 @@ x64 prompt MinimumRecommendedRules.ruleset + 6 bin\x64\Release\ @@ -29,6 +30,7 @@ x64 prompt MinimumRecommendedRules.ruleset + 6 true @@ -38,6 +40,7 @@ x86 prompt MinimumRecommendedRules.ruleset + 6 bin\x86\Release\ @@ -47,6 +50,7 @@ x86 prompt MinimumRecommendedRules.ruleset + 6 diff --git a/Apps/MusicToolchain/DereTore.Apps.MusicToolchain.csproj b/Apps/MusicToolchain/DereTore.Apps.MusicToolchain.csproj index 1e8784c..8bdb1fa 100644 --- a/Apps/MusicToolchain/DereTore.Apps.MusicToolchain.csproj +++ b/Apps/MusicToolchain/DereTore.Apps.MusicToolchain.csproj @@ -21,6 +21,7 @@ x86 prompt MinimumRecommendedRules.ruleset + 6 bin\x86\Release\ @@ -30,6 +31,7 @@ x86 prompt MinimumRecommendedRules.ruleset + 6 true @@ -39,6 +41,7 @@ x64 prompt MinimumRecommendedRules.ruleset + 6 bin\x64\Release\ @@ -48,6 +51,7 @@ x64 prompt MinimumRecommendedRules.ruleset + 6 diff --git a/Apps/ScoreViewer/DereTore.Apps.ScoreViewer.csproj b/Apps/ScoreViewer/DereTore.Apps.ScoreViewer.csproj index 42400d8..15cd371 100644 --- a/Apps/ScoreViewer/DereTore.Apps.ScoreViewer.csproj +++ b/Apps/ScoreViewer/DereTore.Apps.ScoreViewer.csproj @@ -24,6 +24,7 @@ prompt MinimumRecommendedRules.ruleset false + 6 bin\x86\Release\ @@ -34,6 +35,7 @@ prompt MinimumRecommendedRules.ruleset false + 6 true @@ -44,6 +46,7 @@ prompt MinimumRecommendedRules.ruleset false + 6 bin\x64\Release\ @@ -54,6 +57,7 @@ prompt MinimumRecommendedRules.ruleset false + 6 @@ -222,27 +226,25 @@ ..\..\packages\CsvHelper.2.16.3.0\lib\net40\CsvHelper.dll True - - ..\..\packages\NAudio.1.8.0\lib\net35\NAudio.dll - True + + ..\..\packages\NAudio.1.8.2\lib\net35\NAudio.dll - - ..\..\packages\System.Data.SQLite.Core.1.0.104.0\lib\net40\System.Data.SQLite.dll - True + + ..\..\packages\System.Data.SQLite.Core.1.0.105.2\lib\net40\System.Data.SQLite.dll - + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 - + - \ No newline at end of file diff --git a/StarlightDirector/StarlightDirector.Core/StringHasher.cs b/StarlightDirector/StarlightDirector.Core/StringHasher.cs deleted file mode 100644 index 636a856..0000000 --- a/StarlightDirector/StarlightDirector.Core/StringHasher.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Security.Cryptography; -using System.Text; - -namespace StarlightDirector { - public static class StringHasher { - - public static string GetHash(string source, HashAlgorithm algorithm) { - if (_latin1Encoding == null) { - _latin1Encoding = Encoding.GetEncoding("ISO-8859-1"); - } - var bytes = _latin1Encoding.GetBytes(source); - bytes = algorithm.ComputeHash(bytes); - var hashString = BitConverter.ToString(bytes); - hashString = hashString.Replace("-", string.Empty).ToLowerInvariant(); - return hashString; - } - - public static HashAlgorithm Md5 { - get { - if (_md5 == null) { - _md5 = new MD5Cng(); - _md5.Initialize(); - } - return _md5; - } - } - - public static HashAlgorithm Sha1 { - get { - if (_sha1 == null) { - _sha1 = new SHA1Cng(); - _sha1.Initialize(); - } - return _sha1; - } - } - - private static Encoding _latin1Encoding; - private static HashAlgorithm _md5; - private static HashAlgorithm _sha1; - - } -} diff --git a/StarlightDirector/StarlightDirector.Core/ThreadingTimer.cs b/StarlightDirector/StarlightDirector.Core/ThreadingTimer.cs deleted file mode 100644 index 6341063..0000000 --- a/StarlightDirector/StarlightDirector.Core/ThreadingTimer.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System; -using System.Diagnostics; -using System.Threading; -using DereTore.Common; -using DereTore.Interop; -using DereTore.Interop.OS; - -namespace StarlightDirector { - public sealed class ThreadingTimer : DisposableBase { - - public ThreadingTimer(double interval) { - _lock = new object(); - NativeMethods.timeBeginPeriod(TimerPeriod); - Interval = interval; - _stopwatch = new Stopwatch(); - } - - public event EventHandler Elapsed; - - public void Start() { - lock (_lock) { - if (_thread != null) { - return; - } - _thread = new Thread(ThreadProc) { - IsBackground = true - }; - _continue = true; - _thread.Start(); - Monitor.Wait(_lock); - } - } - - public void Stop() { - lock (_lock) { - if (_thread == null) { - return; - } - try { - _continue = false; - _thread.Join(); - } finally { - _thread = null; - } - } - } - - public double Interval { get; } - - protected override void Dispose(bool explicitDisposing) { - Stop(); - if (explicitDisposing) { - } - NativeMethods.timeEndPeriod(TimerPeriod); - } - - private void ThreadProc() { - lock (_lock) { - Monitor.Pulse(_lock); - } - var stopwatch = _stopwatch; - stopwatch.Start(); - while (_continue) { - var timeDiff = stopwatch.ElapsedMilliseconds; - if (timeDiff >= Interval) { - stopwatch.Restart(); - Elapsed?.Invoke(this, EventArgs.Empty); - } else { - Thread.Sleep(1); - } - } - stopwatch.Reset(); - } - - private readonly object _lock; - private Thread _thread; - private volatile bool _continue; - private readonly Stopwatch _stopwatch; - - private static readonly uint TimerPeriod = 1; - - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/Bar.cs b/StarlightDirector/StarlightDirector.Entities/Bar.cs deleted file mode 100644 index 3a18d4f..0000000 --- a/StarlightDirector/StarlightDirector.Entities/Bar.cs +++ /dev/null @@ -1,220 +0,0 @@ -using System; -using System.Linq; -using DereTore.Common; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; - -namespace StarlightDirector.Entities { - [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy), MemberSerialization = MemberSerialization.OptIn)] - public sealed class Bar { - - [JsonIgnore] - public double StartTime { get; private set; } - - [JsonIgnore] - public double StartBpm { get; private set; } - - [JsonIgnore] - public double TimeLength { get; private set; } - - [JsonIgnore] - public int Signature => Params?.UserDefinedSignature ?? Score.Project.Settings.GlobalSignature; - - [JsonIgnore] - public int GridPerSignature => Params?.UserDefinedGridPerSignature ?? Score.Project.Settings.GlobalGridPerSignature; - - [JsonIgnore] - public int TotalGridCount => Signature * GridPerSignature; - - private double[] _timeAtGrid; - - public double TimeAtSignature(int signature) { - if (signature < 0 || signature >= Signature) - throw new ArgumentException("signature out of range"); - - return TimeAtGrid(signature * GridPerSignature); - } - - public double TimeAtGrid(int grid) { - if (grid < 0 || grid >= TotalGridCount) - throw new ArgumentException("grid out of range"); - - return _timeAtGrid[grid]; - } - - public void UpdateTimings() { - UpdateStartTime(); - UpdateStartBpm(); - UpdateTimeLength(); - } - - private void UpdateStartTime() { - var bars = Score.Bars; - var startTime = Score.Project.Settings.StartTimeOffset; - var thisIndex = Index; - if (bars.Count > 0) { - for (var i = 0; i < thisIndex; ++i) { - startTime += bars[i].TimeLength; - } - } - StartTime = startTime; - } - - private void UpdateStartBpm() { - for (int i = Index - 1; i >= 0; --i) { - var bar = Score.Bars[i]; - if (bar.Notes.All(note => note.Type != NoteType.VariantBpm)) { - continue; - } - - StartBpm = bar.Notes.Last(note => note.Type == NoteType.VariantBpm).ExtraParams.NewBpm; - return; - } - - StartBpm = Score.Project.Settings.GlobalBpm; - } - - /// - /// Fill _timeAtGrid, index in range [from, to], assuming constant BPM (bpm) starting from referenceIdx - /// - private void SetTimeAtGrid(int from, int to, double bpm, int referenceIdx) { - var secondsPerSignature = DirectorHelper.BpmToSeconds(bpm); - for (int i = from; i <= to; ++i) { - var numGrids = i - referenceIdx; - _timeAtGrid[i] = _timeAtGrid[referenceIdx] + numGrids * secondsPerSignature / GridPerSignature; - } - } - - private void UpdateTimeLength() { - var length = 0.0; - Note lastBpmNote = null; - _timeAtGrid = new double[TotalGridCount]; - _timeAtGrid[0] = StartTime; - - // find all BpmNotes and compute the length between them - foreach (var note in Notes) { - if (note.Type != NoteType.VariantBpm) - continue; - - if (lastBpmNote == null) { - // length between start and first BpmNote - length += DirectorHelper.BpmToSeconds(StartBpm) * note.IndexInGrid / GridPerSignature; - SetTimeAtGrid(1, note.IndexInGrid, StartBpm, 0); - } else { - // length between prev BpmNote and current - var deltaGridCount = note.IndexInGrid - lastBpmNote.IndexInGrid; - length += DirectorHelper.BpmToSeconds(lastBpmNote.ExtraParams.NewBpm) * deltaGridCount / GridPerSignature; - SetTimeAtGrid(lastBpmNote.IndexInGrid + 1, note.IndexInGrid, lastBpmNote.ExtraParams.NewBpm, lastBpmNote.IndexInGrid); - } - - lastBpmNote = note; - } - - // length from the last BpmNote to end - // if it's null, there is no BpmNote in the bar - if (lastBpmNote != null) { - length += DirectorHelper.BpmToSeconds(lastBpmNote.ExtraParams.NewBpm) * (TotalGridCount - lastBpmNote.IndexInGrid) / GridPerSignature; - SetTimeAtGrid(lastBpmNote.IndexInGrid + 1, TotalGridCount - 1, lastBpmNote.ExtraParams.NewBpm, lastBpmNote.IndexInGrid); - } else { - length = DirectorHelper.BpmToSeconds(StartBpm) * Signature; - for (int i = 0; i < TotalGridCount; ++i) { - _timeAtGrid[i] = StartTime + length * i / TotalGridCount; - } - } - - TimeLength = length; - } - - /// - /// UpdateTimings() of this Bar and all Bars in the Score after this one - /// - internal void UpdateTimingsChain() { - var myIdx = Score.Bars.IndexOf(this); - - if (myIdx >= 0) { - for (int i = myIdx; i < Score.Bars.Count; ++i) { - Score.Bars[i].UpdateTimings(); - } - } else { - UpdateTimings(); - } - } - - public Note AddNote() { - var id = MathHelper.NextRandomPositiveInt32(); - while (Score.Project.ExistingIDs.Contains(id)) { - id = MathHelper.NextRandomPositiveInt32(); - } - return AddNote(id); - } - - public bool RemoveNote(Note note) { - if (!Notes.Contains(note)) { - return false; - } - Notes.Remove(note); - Score.Notes.Remove(note); - Score.Project.ExistingIDs.Remove(note.ID); - if (note.Type == NoteType.VariantBpm) { - UpdateTimingsChain(); - } - return true; - } - - [JsonProperty] - public InternalList Notes { get; } - - [JsonProperty] - public BarParams Params { get; internal set; } - - [JsonProperty] - public int Index { get; internal set; } - - public Score Score { get; internal set; } - - [JsonConstructor] - internal Bar(Score score, int index) { - Score = score; - Notes = new InternalList(); - Index = index; - } - - internal Note AddNote(int id) { - if (Score.Project.ExistingIDs.Contains(id)) { - return null; - } - var note = new Note(id, this); - Notes.Add(note); - Score.Notes.Add(note); - Score.Project.ExistingIDs.Add(id); - - Notes.Sort(Note.TimingThenPositionComparison); - Score.Notes.Sort(Note.TimingThenPositionComparison); - return note; - } - - internal Note AddNoteWithoutUpdatingGlobalNotes(int id) { - if (Score.Project.ExistingIDs.Contains(id)) { - return null; - } - var note = new Note(id, this); - Notes.Add(note); - Score.Project.ExistingIDs.Add(id); - - Notes.Sort(Note.TimingThenPositionComparison); - return note; - } - - internal void SquashParams() { - if (Params?.CanBeSquashed ?? false) { - Params = null; - } - } - - // Note object will call this when IndexInGrid is changed - internal void SortNotes() { - Notes.Sort(Note.TimingThenPositionComparison); - Score.Notes.Sort(Note.TimingThenPositionComparison); - } - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/BarParams.cs b/StarlightDirector/StarlightDirector.Entities/BarParams.cs deleted file mode 100644 index cd5d6a8..0000000 --- a/StarlightDirector/StarlightDirector.Entities/BarParams.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; - -namespace StarlightDirector.Entities { - [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] - public sealed class BarParams { - - [Obsolete("This property is not used since v0.5.0 alpha. Please consider Note with Note.Type == VariantBpm instead.")] - public double? UserDefinedBpm { get; internal set; } - - public int? UserDefinedGridPerSignature { get; internal set; } - - public int? UserDefinedSignature { get; internal set; } - - [JsonIgnore] - public bool CanBeSquashed => UserDefinedBpm == null && UserDefinedGridPerSignature == null && UserDefinedSignature == null; - - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/CompiledNote.cs b/StarlightDirector/StarlightDirector.Entities/CompiledNote.cs deleted file mode 100644 index b763e4a..0000000 --- a/StarlightDirector/StarlightDirector.Entities/CompiledNote.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; - -namespace StarlightDirector.Entities { - public sealed class CompiledNote { - - public int ID { get; set; } - - public double HitTiming { get; set; } - - public NoteType Type { get; set; } - - public NotePosition StartPosition { get; set; } - - public NotePosition FinishPosition { get; set; } - - // The type is Int32 here because this field ('status') will serve other usages. - // See note type 100 (note count). - public int FlickType { get; set; } - - public bool IsSync { get; set; } - - public int GroupID { get; set; } - - internal static readonly Comparison IDComparison = (n1, n2) => n1.ID.CompareTo(n2.ID); - internal static readonly Comparison TimingComparison = (n1, n2) => n1.HitTiming.CompareTo(n2.HitTiming); - - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/CompiledScore.cs b/StarlightDirector/StarlightDirector.Entities/CompiledScore.cs deleted file mode 100644 index 89101a3..0000000 --- a/StarlightDirector/StarlightDirector.Entities/CompiledScore.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Text; -using CsvHelper; -using CsvHelper.Configuration; -using StarlightDirector.Entities.Serialization; - -namespace StarlightDirector.Entities { - public sealed class CompiledScore { - - public CompiledScore() { - Notes = new InternalList(); - } - - public InternalList Notes { get; } - - public string GetCsvString() { - var sb = new StringBuilder(); - using (var writer = new StringWriter(sb)) { - var config = new CsvConfiguration(); - config.RegisterClassMap(); - config.HasHeaderRecord = true; - config.TrimFields = false; - using (var csv = new CsvWriter(writer, config)) { - var newList = new List(Notes); - csv.WriteRecords(newList); - } - } - - sb.Replace("\r\n", "\n"); - return sb.ToString(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/Difficulty.cs b/StarlightDirector/StarlightDirector.Entities/Difficulty.cs deleted file mode 100644 index 990df0a..0000000 --- a/StarlightDirector/StarlightDirector.Entities/Difficulty.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.ComponentModel; - -namespace StarlightDirector.Entities { - public enum Difficulty { - - Invalid, - [Description("Debut")] - Debut, - [Description("Regular")] - Regular, - [Description("Pro")] - Pro, - [Description("Master")] - Master, - [Description("Master+")] - MasterPlus - - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/EntityID.cs b/StarlightDirector/StarlightDirector.Entities/EntityID.cs deleted file mode 100644 index d9a9297..0000000 --- a/StarlightDirector/StarlightDirector.Entities/EntityID.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace StarlightDirector.Entities { - public static class EntityID { - - public static readonly int Invalid = 0; - - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/Extensions/NoteExtensions.cs b/StarlightDirector/StarlightDirector.Entities/Extensions/NoteExtensions.cs deleted file mode 100644 index ab352be..0000000 --- a/StarlightDirector/StarlightDirector.Entities/Extensions/NoteExtensions.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System.Collections.Generic; - -namespace StarlightDirector.Entities.Extensions { - public static class NoteExtensions { - - public static Note GetFirstNoteBetween(this IEnumerable notes, Note n1, Note n2) { - var first = n1 < n2 ? n1 : n2; - var second = first.Equals(n1) ? n2 : n1; - foreach (var n in notes) { - if (n.Equals(first) || n.Equals(second)) { - continue; - } - if (n.FinishPosition != first.FinishPosition || first.Bar.Index > n.Bar.Index || n.Bar.Index > second.Bar.Index) { - continue; - } - if (first.Bar.Index == second.Bar.Index) { - if (first.IndexInGrid <= n.IndexInGrid && n.IndexInGrid <= second.IndexInGrid) { - return n; - } - } else { - if (first.Bar.Index == n.Bar.Index) { - if (first.IndexInGrid <= n.IndexInGrid) { - return n; - } - } else if (second.Bar.Index == n.Bar.Index) { - if (n.IndexInGrid <= second.IndexInGrid) { - return n; - } - } else { - return n; - } - } - } - return null; - } - - public static bool AnyNoteBetween(this IEnumerable notes, Note start, Note end) { - return GetFirstNoteBetween(notes, start, end) != null; - } - - internal static bool TryGetFlickGroupID(this Note note, out FlickGroupModificationResult modificationResult, out int knownGroupID, out Note groupStart) { - if ((!note.IsFlick && !note.IsSlide) || (note.IsHoldEnd && !note.HasNextFlickOrSlide)) { - knownGroupID = EntityID.Invalid; - modificationResult = FlickGroupModificationResult.Declined; - groupStart = null; - return false; - } - var groupItemCount = 0; - var temp = note; - // Compiler trick. - groupStart = temp; - while (temp != null) { - groupStart = temp; - temp = temp.PrevFlickOrSlideNote; - ++groupItemCount; - } - temp = note; - ++groupItemCount; - while (temp.HasNextFlickOrSlide) { - temp = temp.NextFlickOrSlideNote; - ++groupItemCount; - } - if (groupItemCount < 2) { - // Actually, the flick group is not fully filled. We should throw an exception. - knownGroupID = EntityID.Invalid; - modificationResult = FlickGroupModificationResult.Declined; - return false; - } - if (groupStart.GroupID != EntityID.Invalid) { - knownGroupID = groupStart.GroupID; - modificationResult = FlickGroupModificationResult.Reused; - } else { - knownGroupID = EntityID.Invalid; - modificationResult = FlickGroupModificationResult.CreationPending; - } - return true; - } - - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/Extensions/ScoreExtensions.cs b/StarlightDirector/StarlightDirector.Entities/Extensions/ScoreExtensions.cs deleted file mode 100644 index 0378218..0000000 --- a/StarlightDirector/StarlightDirector.Entities/Extensions/ScoreExtensions.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System.Linq; - -namespace StarlightDirector.Entities.Extensions { - public static class ScoreExtensions { - - public static CompiledScore Compile(this Score score) { - var compiledScore = new CompiledScore(); - CompileTo(score, compiledScore); - return compiledScore; - } - - public static void CompileTo(this Score score, CompiledScore compiledScore) { - FlickGroupIDGenerator.Reset(); - var compiledNotes = compiledScore.Notes; - compiledNotes.Clear(); - - // Clear the GroupID caches. - foreach (var bar in score.Bars) { - foreach (var note in bar.Notes) { - note.GroupID = EntityID.Invalid; - - var compiledNote = new CompiledNote(); - SetCommonNoteProperties(note, compiledNote); - CalculateGroupID(note, compiledNote); - compiledNote.HitTiming = note.HitTiming; - - compiledNotes.Add(compiledNote); - } - } - - // The normal gaming notes. - var noteId = 3; - foreach (var compiledNote in compiledNotes) { - compiledNote.ID = noteId++; - } - - // Special notes are added to their destined positions. - var totalNoteCount = compiledNotes.Count; - var scoreInfoNote = new CompiledNote { - ID = 1, - Type = NoteType.NoteCount, - FlickType = totalNoteCount - }; - var songStartNote = new CompiledNote { - ID = 2, - Type = NoteType.MusicStart - }; - compiledNotes.Insert(0, scoreInfoNote); - compiledNotes.Insert(1, songStartNote); - - double endTiming; - if (score.Bars.Count > 0) { - var lastBar = score.Bars.Last(); - endTiming = lastBar.StartTime + lastBar.TimeLength; - } else { - endTiming = 0; - } - var songEndNote = new CompiledNote { - ID = noteId, - Type = NoteType.MusicEnd, - HitTiming = endTiming - }; - compiledNotes.Add(songEndNote); - } - - private static void SetCommonNoteProperties(Note note, CompiledNote compiledNote) { - compiledNote.Type = note.Type; - compiledNote.StartPosition = note.StartPosition; - compiledNote.FinishPosition = note.FinishPosition; - compiledNote.FlickType = (int)note.FlickType; - compiledNote.IsSync = note.IsSync; - } - - private static void CalculateGroupID(Note note, CompiledNote compiledNote) { - if (note.GroupID != EntityID.Invalid) { - compiledNote.GroupID = note.GroupID; - } else { - int groupID; - FlickGroupModificationResult result; - Note groupStart; - if (!note.TryGetFlickGroupID(out result, out groupID, out groupStart)) { - // No need to set a group ID. E.g. the note is not a flick / slide note. - return; - } - switch (result) { - case FlickGroupModificationResult.Reused: - note.GroupID = compiledNote.GroupID = groupID; - break; - case FlickGroupModificationResult.CreationPending: - groupID = FlickGroupIDGenerator.Next(); - groupStart.GroupID = note.GroupID = compiledNote.GroupID = groupID; - break; - } - } - } - - private static readonly IntegerIDGenerator FlickGroupIDGenerator = new IntegerIDGenerator(1); - - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/FlickGroupModificationResult.cs b/StarlightDirector/StarlightDirector.Entities/FlickGroupModificationResult.cs deleted file mode 100644 index 4b6ab62..0000000 --- a/StarlightDirector/StarlightDirector.Entities/FlickGroupModificationResult.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace StarlightDirector.Entities { - internal enum FlickGroupModificationResult { - - Declined, - Reused, - CreationPending - - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/Gaming/MusicAttribute.cs b/StarlightDirector/StarlightDirector.Entities/Gaming/MusicAttribute.cs deleted file mode 100644 index dca12c9..0000000 --- a/StarlightDirector/StarlightDirector.Entities/Gaming/MusicAttribute.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.ComponentModel; - -namespace StarlightDirector.Entities.Gaming { - [Flags] - public enum MusicAttribute { - - [Description("Cute")] - Cute = 0x01, - [Description("Cool")] - Cool = 0x02, - [Description("Passion")] - Passion = 0x04, - [Description("Multicolor")] - AllTypes = 0x08, - [Description("Event")] - Event = 0x10, - [Description("Solo ver.")] - Solo = 0x20 - - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/Note.cs b/StarlightDirector/StarlightDirector.Entities/Note.cs deleted file mode 100644 index 8ff3deb..0000000 --- a/StarlightDirector/StarlightDirector.Entities/Note.cs +++ /dev/null @@ -1,566 +0,0 @@ -using System; -using System.Diagnostics; -using System.Windows; -using DereTore.Common; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; - -namespace StarlightDirector.Entities { - [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy), MemberSerialization = MemberSerialization.OptIn)] - public sealed class Note : DependencyObject, IComparable { - - public event EventHandler ExtraParamsChanged; - - [JsonProperty] - public int ID { get; private set; } - - [JsonIgnore] - public double HitTiming => Bar.TimeAtGrid(IndexInGrid); - - private int _indexInGrid; - - // "PositionInGrid" was the first name of this property used in serialization. - [JsonProperty("positionInGrid")] - public int IndexInGrid { - get { return _indexInGrid; } - set { - _indexInGrid = value; - Bar?.SortNotes(); - } - } - - public NoteType Type { - get { return (NoteType)GetValue(TypeProperty); } - internal set { SetValue(TypeProperty, value); } - } - - [JsonProperty] - public NotePosition StartPosition { - get { return (NotePosition)GetValue(StartPositionProperty); } - set { SetValue(StartPositionProperty, value); } - } - - [JsonProperty] - public NotePosition FinishPosition { - get { return (NotePosition)GetValue(FinishPositionProperty); } - set { SetValue(FinishPositionProperty, value); } - } - - public int IndexInTrack => (int)FinishPosition - 1; - - [JsonProperty] - public NoteFlickType FlickType { - get { return (NoteFlickType)GetValue(FlickTypeProperty); } - set { SetValue(FlickTypeProperty, value); } - } - - public bool IsSync { - get { return (bool)GetValue(IsSyncProperty); } - private set { SetValue(IsSyncProperty, value); } - } - - public Bar Bar { get; internal set; } - - public bool IsFlick { - get { return (bool)GetValue(IsFlickProperty); } - private set { SetValue(IsFlickProperty, value); } - } - - [JsonProperty("prevFlickNoteID")] - public int PrevFlickOrSlideNoteID { get; internal set; } - - public Note PrevFlickOrSlideNote { - get { return _prevFlickOrSlideNote; } - set { - UpdateFlickTypeStep1(value); - _prevFlickOrSlideNote = value; - UpdateFlickTypeStep2(); - PrevFlickOrSlideNoteID = value?.ID ?? EntityID.Invalid; - DecideRenderingAsFlickOrSlide(); - } - } - - public bool HasPrevFlickOrSlide => (Type == NoteType.TapOrFlick || Type == NoteType.Slide) && PrevFlickOrSlideNote != null; - - [JsonProperty("nextFlickNoteID")] - public int NextFlickOrSlideNoteID { get; internal set; } - - public Note NextFlickOrSlideNote { - get { return _nextFlickOrSlideNote; } - set { - UpdateFlickTypeStep1(value); - _nextFlickOrSlideNote = value; - UpdateFlickTypeStep2(); - NextFlickOrSlideNoteID = value?.ID ?? EntityID.Invalid; - DecideRenderingAsFlickOrSlide(); - } - } - - public bool HasNextFlickOrSlide => (Type == NoteType.TapOrFlick || Type == NoteType.Slide) && NextFlickOrSlideNote != null; - - [Obsolete("This property is provided for forward compatibility only.")] - [JsonProperty] - public int SyncTargetID { - get { - // For legacy versions that generate sync connection from this field - // Connect the first note and the last note of sync groups - if (HasPrevSync) { - if (HasNextSync) { - return EntityID.Invalid; - } - var final = PrevSyncTarget; - while (final.HasPrevSync) { - final = final.PrevSyncTarget; - } - return final.ID; - } else { - if (!HasNextSync) { - return EntityID.Invalid; - } - var final = NextSyncTarget; - while (final.HasNextSync) { - final = final.NextSyncTarget; - } - return final.ID; - } - } - } - - public Note PrevSyncTarget { - get { return _prevSyncTarget; } - internal set { SetPrevSyncTargetInternal(value); } - } - - public Note NextSyncTarget { - get { return _nextSyncTarget; } - internal set { SetNextSyncTargetInternal(value); } - } - - public bool HasPrevSync => PrevSyncTarget != null; - - public bool HasNextSync => NextSyncTarget != null; - - public bool IsHold { - get { return (bool)GetValue(IsHoldProperty); } - private set { SetValue(IsHoldProperty, value); } - } - - public bool IsHoldStart => Type == NoteType.Hold && HoldTarget != null; - - public bool IsHoldEnd => Type == NoteType.TapOrFlick && HoldTarget != null; - - [JsonProperty] - public int HoldTargetID { get; internal set; } - - public Note HoldTarget { - get { return _holdTarget; } - set { - var origHoldTarget = _holdTarget; - _holdTarget = value; - if (origHoldTarget?.HoldTarget != null && origHoldTarget.HoldTarget.Equals(this)) { - origHoldTarget.HoldTarget = null; - } - IsHold = value != null; - // Only the former of the hold pair is considered as a hold note. The other is a tap or flick note. - Type = (value != null && value > this) ? NoteType.Hold : NoteType.TapOrFlick; - HoldTargetID = value?.ID ?? EntityID.Invalid; - } - } - - public bool IsSlide { - get { return (bool)GetValue(IsSlideProperty); } - private set { SetValue(IsSlideProperty, value); } - } - - public bool IsSlideStart => Type == NoteType.Slide && !HasPrevFlickOrSlide && HasNextFlickOrSlide; - - public bool IsSlideContinuation => Type == NoteType.Slide && HasPrevFlickOrSlide && HasNextFlickOrSlide && PrevFlickOrSlideNote.IsSlide && NextFlickOrSlideNote.IsSlide; - - public bool IsSlideEnd => Type == NoteType.Slide && !HasNextFlickOrSlide && HasPrevFlickOrSlide; - - public bool IsTap { - get { return (bool)GetValue(IsTapProperty); } - private set { SetValue(IsTapProperty, value); } - } - - public bool IsGamingNote => IsTypeGaming(Type); - - public bool IsSpecialNote => IsTypeSpecial(Type); - - public NoteExtraParams ExtraParams { - get { return (NoteExtraParams)GetValue(ExtraParamsProperty); } - set { SetValue(ExtraParamsProperty, value); } - } - - public bool ShouldBeRenderedAsFlick { - get { return (bool)GetValue(ShouldBeRenderedAsFlickProperty); } - private set { SetValue(ShouldBeRenderedAsFlickProperty, value); } - } - - public bool ShouldBeRenderedAsSlide { - get { return (bool)GetValue(ShouldBeRenderedAsSlideProperty); } - private set { SetValue(ShouldBeRenderedAsSlideProperty, value); } - } - - public static readonly DependencyProperty TypeProperty = DependencyProperty.Register(nameof(Type), typeof(NoteType), typeof(Note), - new PropertyMetadata(NoteType.Invalid, OnTypeChanged)); - - public static readonly DependencyProperty FlickTypeProperty = DependencyProperty.Register(nameof(FlickType), typeof(NoteFlickType), typeof(Note), - new PropertyMetadata(NoteFlickType.Tap, OnFlickTypeChanged)); - - public static readonly DependencyProperty IsSyncProperty = DependencyProperty.Register(nameof(IsSync), typeof(bool), typeof(Note), - new PropertyMetadata(false)); - - public static readonly DependencyProperty IsFlickProperty = DependencyProperty.Register(nameof(IsFlick), typeof(bool), typeof(Note), - new PropertyMetadata(false)); - - public static readonly DependencyProperty IsHoldProperty = DependencyProperty.Register(nameof(IsHold), typeof(bool), typeof(Note), - new PropertyMetadata(false)); - - public static readonly DependencyProperty IsSlideProperty = DependencyProperty.Register(nameof(IsSlide), typeof(bool), typeof(Note), - new PropertyMetadata(false)); - - public static readonly DependencyProperty IsTapProperty = DependencyProperty.Register(nameof(IsTap), typeof(bool), typeof(Note), - new PropertyMetadata(true)); - - public static readonly DependencyProperty StartPositionProperty = DependencyProperty.Register(nameof(StartPosition), typeof(NotePosition), typeof(Note), - new PropertyMetadata(NotePosition.Nowhere)); - - public static readonly DependencyProperty FinishPositionProperty = DependencyProperty.Register(nameof(FinishPosition), typeof(NotePosition), typeof(Note), - new PropertyMetadata(NotePosition.Nowhere)); - - public static readonly DependencyProperty ExtraParamsProperty = DependencyProperty.Register(nameof(ExtraParams), typeof(NoteExtraParams), typeof(Note), - new PropertyMetadata(null, OnExtraParamsChanged)); - - public static readonly DependencyProperty ShouldBeRenderedAsFlickProperty = DependencyProperty.Register(nameof(ShouldBeRenderedAsFlick), typeof(bool), typeof(Note), - new PropertyMetadata(false)); - - public static readonly DependencyProperty ShouldBeRenderedAsSlideProperty = DependencyProperty.Register(nameof(ShouldBeRenderedAsSlide), typeof(bool), typeof(Note), - new PropertyMetadata(false)); - - public static readonly Comparison TimingThenPositionComparison = (x, y) => { - var r = TimingComparison(x, y); - return r == 0 ? TrackPositionComparison(x, y) : r; - }; - - public static readonly Comparison TimingComparison = (x, y) => { - if (x == null) { - throw new ArgumentNullException(nameof(x)); - } - if (y == null) { - throw new ArgumentNullException(nameof(y)); - } - if (x.Equals(y)) { - return 0; - } - if (x.Bar != y.Bar) { - return x.Bar.Index.CompareTo(y.Bar.Index); - } - var r = x.IndexInGrid.CompareTo(y.IndexInGrid); - if (r == 0 && x.Type != y.Type && (x.Type == NoteType.VariantBpm || y.Type == NoteType.VariantBpm)) { - // The Variant BPM note is always placed at the end on the same grid line. - return x.Type == NoteType.VariantBpm ? 1 : -1; - } else { - return r; - } - }; - - public int CompareTo(Note other) { - if (other == null) { - throw new ArgumentNullException(nameof(other)); - } - return Equals(other) ? 0 : TimingComparison(this, other); - } - - public static readonly Comparison TrackPositionComparison = (n1, n2) => ((int)n1.FinishPosition).CompareTo((int)n2.FinishPosition); - - public static bool operator >(Note left, Note right) { - return TimingComparison(left, right) > 0; - } - - public static bool operator <(Note left, Note right) { - return TimingComparison(left, right) < 0; - } - - public static bool IsTypeGaming(NoteType type) { - return type == NoteType.TapOrFlick || type == NoteType.Hold || type == NoteType.Slide; - } - - public static bool IsTypeSpecial(NoteType type) { - return type == NoteType.VariantBpm; - } - - public static void ConnectSync(Note first, Note second) { - /* - * Before: - * ... <==> first <==> first_next <==> ... - * ... <==> second_prev <==> second <==> ... - * - * After: - * first_next <==> ... - * ... <==> first <==> second <==> ... - * ... <==> second_prev - */ - if (first == second) { - throw new ArgumentException("A note should not be connected to itself", nameof(second)); - } else if (first?.NextSyncTarget == second && second?.PrevSyncTarget == first) { - return; - } - first?.NextSyncTarget?.SetPrevSyncTargetInternal(null); - second?.PrevSyncTarget?.SetNextSyncTargetInternal(null); - first?.SetNextSyncTargetInternal(second); - second?.SetPrevSyncTargetInternal(first); - } - - public void RemoveSync() { - /* - * Before: - * ... <==> prev <==> this <==> next <==> ... - * - * After: - * ... <==> prev <============> next <==> ... - * this - */ - PrevSyncTarget?.SetNextSyncTargetInternal(NextSyncTarget); - NextSyncTarget?.SetPrevSyncTargetInternal(PrevSyncTarget); - SetPrevSyncTargetInternal(null); - SetNextSyncTargetInternal(null); - } - - public void FixSync() { - if (!IsGamingNote) { - return; - } - RemoveSync(); - Note prev = null; - Note next = null; - foreach (var note in Bar.Notes) { - if (note == this) { - continue; - } - if (!note.IsGamingNote) { - continue; - } - if (note.IndexInGrid == IndexInGrid) { - if (note.IndexInTrack < IndexInTrack) { - if (prev == null || prev.IndexInTrack < note.IndexInTrack) { - prev = note; - } - } else { - if (next == null || note.IndexInTrack < next.IndexInTrack) { - next = note; - } - } - } - } - ConnectSync(prev, this); - ConnectSync(this, next); - } - - public static void ConnectFlick(Note first, Note second) { - if (first != null) { - first.NextFlickOrSlideNote = second; - } - if (second != null) { - second.PrevFlickOrSlideNote = first; - } - } - - public static void ConnectHold(Note n1, Note n2) { - if (n1 != null) { - n1.HoldTarget = n2; - } - if (n2 != null) { - n2.HoldTarget = n1; - } - } - - internal int GroupID { get; set; } - - [JsonConstructor] - internal Note(int id, Bar bar) { - ID = id; - Bar = bar; - IndexInGrid = 0; - Type = NoteType.TapOrFlick; - StartPosition = NotePosition.Nowhere; - FinishPosition = NotePosition.Nowhere; - FlickType = NoteFlickType.Tap; - } - - internal void Reset() { - if (NextFlickOrSlideNote != null) { - var next = NextFlickOrSlideNote; - next.PrevFlickOrSlideNote = null; - if (next.IsSlide && !next.IsSlideStart) { - next.Type = NoteType.TapOrFlick; - } - } - NextFlickOrSlideNote = null; - if (PrevFlickOrSlideNote != null) { - var prev = PrevFlickOrSlideNote; - prev.NextFlickOrSlideNote = null; - if (prev.IsSlide && !prev.IsSlideEnd) { - prev.Type = NoteType.TapOrFlick; - } - } - PrevFlickOrSlideNote = null; - if (HoldTarget != null) { - var hold = HoldTarget; - hold.HoldTarget = null; - if (hold != null) { - if (!hold.HasNextFlickOrSlide && !hold.HasPrevFlickOrSlide && hold.FlickType != NoteFlickType.Tap) { - hold.FlickType = NoteFlickType.Tap; - } - } - } - FlickType = NoteFlickType.Tap; - HoldTarget = null; - } - - internal void SetSpecialType(NoteType type) { - switch (type) { - case NoteType.VariantBpm: - break; - default: - throw new ArgumentOutOfRangeException(nameof(type)); - } - Type = type; - } - - // Why is ugly functions like this even exist? - internal void SetIndexInGridWithoutSorting(int newIndex) { - _indexInGrid = newIndex; - } - - private static void OnTypeChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { - var note = (Note)obj; - note.IsFlick = note.IsFlickInternal(); - note.IsTap = note.IsTapInternal(); - note.IsSlide = note.IsSlideInternal(); - note.UpdateFlickTypeStep2(); - note.DecideRenderingAsFlickOrSlide(); - - if (note.IsFlick) { - note.UpdateAsFlickNote(); - } else if (note.IsSlide) { - note.UpdateAsSlideNote(); - } - } - - private static void OnFlickTypeChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { - var note = (Note)obj; - note.IsFlick = note.IsFlickInternal(); - note.IsTap = note.IsTapInternal(); - note.IsSlide = note.IsSlideInternal(); - note.DecideRenderingAsFlickOrSlide(); - } - - private static void OnExtraParamsChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { - var note = (Note)obj; - var oldParams = (NoteExtraParams)e.OldValue; - var newParams = (NoteExtraParams)e.NewValue; - if (oldParams != null) { - oldParams.ParamsChanged -= note.ExtraParams_ParamsChanged; - } - if (newParams != null) { - newParams.ParamsChanged += note.ExtraParams_ParamsChanged; - } - } - - private void UpdateFlickTypeStep1(Note value) { - var n1 = PrevFlickOrSlideNote; - var n2 = NextFlickOrSlideNote; - if (IsSlide) { - FlickType = NoteFlickType.Tap; - } else { - if (n1 == null && n2 == null && value != null) { - FlickType = FinishPosition >= NotePosition.Center ? NoteFlickType.FlickRight : NoteFlickType.FlickLeft; - } - } - } - - private void UpdateFlickTypeStep2() { - var n1 = PrevFlickOrSlideNote; - var n2 = NextFlickOrSlideNote; - if (n1 == null && n2 == null) { - if (!IsHoldStart) { - FlickType = NoteFlickType.Tap; - } - } else { - // Currently there isn't an example of quick 'Z' turn appeared in CGSS (as shown below), - // so the following completion method is good enough. - // --> - // ^ - // \ - // --> - //Debug.Print(HitTiming.ToString(CultureInfo.InvariantCulture)); - if (IsSlide && (n2 == null || !n2.IsFlick)) { - FlickType = NoteFlickType.Tap; - } else { - if (n2 != null) { - FlickType = n2.FinishPosition > FinishPosition ? NoteFlickType.FlickRight : NoteFlickType.FlickLeft; - } else { - FlickType = n1.FinishPosition > FinishPosition ? NoteFlickType.FlickLeft : NoteFlickType.FlickRight; - } - } - } - } - - private void DecideRenderingAsFlickOrSlide() { - if (IsFlick || IsSlide) { - if (IsSlide) { - ShouldBeRenderedAsSlide = FlickType == NoteFlickType.Tap && (!HasNextFlickOrSlide || !NextFlickOrSlideNote.IsFlick); - } else { - ShouldBeRenderedAsSlide = false; - } - ShouldBeRenderedAsFlick = !ShouldBeRenderedAsSlide; - } else { - ShouldBeRenderedAsFlick = ShouldBeRenderedAsSlide = false; - } - } - - private bool IsFlickInternal() => Type == NoteType.TapOrFlick && (FlickType == NoteFlickType.FlickLeft || FlickType == NoteFlickType.FlickRight); - - private bool IsTapInternal() => Type == NoteType.TapOrFlick && FlickType == NoteFlickType.Tap; - - private bool IsSlideInternal() => Type == NoteType.Slide; - - private void ExtraParams_ParamsChanged(object sender, EventArgs e) { - // if we a BPM note is changed, inform the Bar to update its timings - Bar?.UpdateTimingsChain(); - ExtraParamsChanged.Raise(sender, e); - } - - private void SetPrevSyncTargetInternal(Note prev) { - _prevSyncTarget = prev; - IsSync = _prevSyncTarget != null || _nextSyncTarget != null; - } - - private void SetNextSyncTargetInternal(Note next) { - _nextSyncTarget = next; - IsSync = _prevSyncTarget != null || _nextSyncTarget != null; - } - - private void UpdateAsSlideNote() { - if (HasPrevFlickOrSlide && PrevFlickOrSlideNote.IsSlide) { - PrevFlickOrSlideNote.FlickType = NoteFlickType.Tap; - } - } - - private void UpdateAsFlickNote() { - if (HasPrevFlickOrSlide && PrevFlickOrSlideNote.IsSlide) { - var pos1 = (int)PrevFlickOrSlideNote.FinishPosition; - var pos2 = (int)FinishPosition; - PrevFlickOrSlideNote.FlickType = pos2 >= pos1 ? NoteFlickType.FlickRight : NoteFlickType.FlickLeft; - } - } - - private Note _prevFlickOrSlideNote; - private Note _nextFlickOrSlideNote; - private Note _prevSyncTarget; - private Note _nextSyncTarget; - private Note _holdTarget; - - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/NoteExtraParams.cs b/StarlightDirector/StarlightDirector.Entities/NoteExtraParams.cs deleted file mode 100644 index 78543d0..0000000 --- a/StarlightDirector/StarlightDirector.Entities/NoteExtraParams.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.Globalization; -using System.Windows; -using DereTore.Common; - -namespace StarlightDirector.Entities { - public sealed class NoteExtraParams : DependencyObject { - - public event EventHandler ParamsChanged; - - public double NewBpm { - get { return (double)GetValue(NewBpmProperty); } - set { SetValue(NewBpmProperty, value); } - } - - public static readonly DependencyProperty NewBpmProperty = DependencyProperty.Register(nameof(NewBpm), typeof(double), typeof(NoteExtraParams), - new PropertyMetadata(120d, OnNewBpmChanged)); - - public string GetDataString() { - switch (Note.Type) { - case NoteType.VariantBpm: - return NewBpm.ToString(CultureInfo.InvariantCulture); - default: - throw new ArgumentOutOfRangeException(nameof(Note.Type)); - } - } - - public void UpdateByDataString(string s) { - UpdateByDataString(s, Note); - } - - public void UpdateByDataString(string s, Note note) { - Note = note; - switch (note.Type) { - case NoteType.VariantBpm: - NewBpm = double.Parse(s); - break; - default: - throw new ArgumentOutOfRangeException(nameof(note.Type)); - } - } - - public static NoteExtraParams FromDataString(string str, Note note) { - if (string.IsNullOrEmpty(str)) { - return null; - } - var p = new NoteExtraParams { - Note = note - }; - switch (note.Type) { - case NoteType.VariantBpm: - p.NewBpm = double.Parse(str); - break; - default: - break; - } - return p; - } - - public Note Note { get; internal set; } - - private static void OnNewBpmChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { - var p = (NoteExtraParams)obj; - p.Note.Bar.Score.Project.IsChanged = true; - p.ParamsChanged.Raise(p, EventArgs.Empty); - } - - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/NoteFlickType.cs b/StarlightDirector/StarlightDirector.Entities/NoteFlickType.cs deleted file mode 100644 index a464573..0000000 --- a/StarlightDirector/StarlightDirector.Entities/NoteFlickType.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace StarlightDirector.Entities { - public enum NoteFlickType { - - Tap = 0, - FlickLeft = 1, - FlickRight = 2 - - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/NotePosition.cs b/StarlightDirector/StarlightDirector.Entities/NotePosition.cs deleted file mode 100644 index e782581..0000000 --- a/StarlightDirector/StarlightDirector.Entities/NotePosition.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace StarlightDirector.Entities { - public enum NotePosition { - - Nowhere, - Left, - CenterLeft, - Center, - CenterRight, - Right - - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/NoteRelation.cs b/StarlightDirector/StarlightDirector.Entities/NoteRelation.cs deleted file mode 100644 index 5ba3ff9..0000000 --- a/StarlightDirector/StarlightDirector.Entities/NoteRelation.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace StarlightDirector.Entities { - public enum NoteRelation { - - None, - Sync, - FlickOrSlide, - Hold - - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/NoteType.cs b/StarlightDirector/StarlightDirector.Entities/NoteType.cs deleted file mode 100644 index d2f6825..0000000 --- a/StarlightDirector/StarlightDirector.Entities/NoteType.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace StarlightDirector.Entities { - public enum NoteType { - - Invalid = 0, - - TapOrFlick = 1, - Hold = 2, - Slide = 3, - - FeverStart = 81, - FeverEnd = 82, - MusicStart = 91, - MusicEnd = 92, - NoteCount = 100, - - // Starlight Director: avatar note - Avatar = 10001, - // Starlight Director: avatar note - VariantBpm = 10002 - - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/Party.cs b/StarlightDirector/StarlightDirector.Entities/Party.cs deleted file mode 100644 index 3ba5bd5..0000000 --- a/StarlightDirector/StarlightDirector.Entities/Party.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace StarlightDirector.Entities { - public enum Party { - - Neutral, - Cute, - Cool, - Passion - - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/Project.cs b/StarlightDirector/StarlightDirector.Entities/Project.cs deleted file mode 100644 index 78a5eec..0000000 --- a/StarlightDirector/StarlightDirector.Entities/Project.cs +++ /dev/null @@ -1,158 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Windows; -using DereTore.Common; -using Newtonsoft.Json; -using StarlightDirector.Entities.Extensions; - -namespace StarlightDirector.Entities { - public sealed class Project : DependencyObject { - - public Project() { - Version = CurrentVersion; - Scores = new Dictionary(); - Difficulty = Difficulty.Debut; - Settings = ScoreSettings.CreateDefault(); - Settings.SettingChanged += OnSettingsChanged; - } - - ~Project() { - Settings.SettingChanged -= OnSettingsChanged; - } - - public event EventHandler DifficultyChanged; - public event EventHandler GlobalSettingsChanged; - - public static Project Current { get; set; } - - [JsonProperty] - public Dictionary Scores { get; } - - public ScoreSettings Settings { get; } - - public HashSet ExistingIDs { get; } = new HashSet(); - - [JsonProperty] - public string MusicFileName { - get { return (string)GetValue(MusicFileNameProperty); } - set { SetValue(MusicFileNameProperty, value); } - } - - public bool HasMusic { - get { return (bool)GetValue(HasMusicProperty); } - private set { SetValue(HasMusicProperty, value); } - } - - public bool IsChanged { get; internal set; } - - public bool IsSaved { - get { return (bool)GetValue(IsSavedProperty); } - private set { SetValue(IsSavedProperty, value); } - } - - public string SaveFileName { - get { return (string)GetValue(SaveFileNameProperty); } - internal set { SetValue(SaveFileNameProperty, value); } - } - - [JsonProperty] - public string Version { - get { return (string)GetValue(VersionProperty); } - internal set { SetValue(VersionProperty, value); } - } - - public Score GetScore(Difficulty difficulty) { - if (!Scores.ContainsKey(difficulty)) { - var score = new Score(this, difficulty); - Scores.Add(difficulty, score); - } - return Scores[difficulty]; - } - - public void SetScore(Difficulty difficulty, Score score) { - Scores[difficulty] = score; - } - - public void ExportScoreToCsv(Difficulty difficulty, string fileName) { - using (var stream = File.Open(fileName, FileMode.Create, FileAccess.Write)) { - using (var writer = new StreamWriter(stream)) { - ExportScoreToCsv(difficulty, writer); - } - } - } - - public void ExportScoreToCsv(Difficulty difficulty, TextWriter writer) { - var score = GetScore(difficulty); - var compiledScore = score.Compile(); - var csvString = compiledScore.GetCsvString(); - writer.Write(csvString); - } - - public string ExportScoreToCsv(Difficulty difficulty) { - var score = GetScore(difficulty); - var compiledScore = score.Compile(); - var csvString = compiledScore.GetCsvString(); - return csvString; - } - - public Difficulty Difficulty { - get { return (Difficulty)GetValue(DifficultyProperty); } - set { SetValue(DifficultyProperty, value); } - } - - public static readonly DependencyProperty DifficultyProperty = DependencyProperty.Register(nameof(Difficulty), typeof(Difficulty), typeof(Project), - new PropertyMetadata(Difficulty.Master, OnDifficultyChanged)); - - public static readonly DependencyProperty MusicFileNameProperty = DependencyProperty.Register(nameof(MusicFileName), typeof(string), typeof(Project), - new PropertyMetadata(null, OnMusicFileNameChanged)); - - public static readonly DependencyProperty HasMusicProperty = DependencyProperty.Register(nameof(HasMusic), typeof(bool), typeof(Project), - new PropertyMetadata(false)); - - public static readonly DependencyProperty SaveFileNameProperty = DependencyProperty.Register(nameof(SaveFileName), typeof(string), typeof(Project), - new PropertyMetadata(null, OnSaveFileNameChanged)); - - public static readonly DependencyProperty IsSavedProperty = DependencyProperty.Register(nameof(IsSaved), typeof(bool), typeof(Project), - new PropertyMetadata(false)); - - public static readonly DependencyProperty VersionProperty = DependencyProperty.Register(nameof(Version), typeof(string), typeof(Project), - new PropertyMetadata(CurrentVersion)); - - public static string CurrentVersion => ProjectVersion.Current.ToString(); - - private static void OnDifficultyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { - var project = obj as Project; - Debug.Assert(project != null, "project != null"); - Debug.Print($"New difficulty: {e.NewValue}"); - project.DifficultyChanged.Raise(project, EventArgs.Empty); - } - - private static void OnMusicFileNameChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { - var project = obj as Project; - Debug.Assert(project != null, "project != null"); - var newValue = (string)e.NewValue; - project.HasMusic = !string.IsNullOrEmpty(newValue) && File.Exists(newValue); - project.OnSettingsChanged(project, EventArgs.Empty); - } - - private static void OnSaveFileNameChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { - var project = obj as Project; - Debug.Assert(project != null, "project != null"); - var newValue = (string)e.NewValue; - project.IsSaved = !string.IsNullOrEmpty(newValue) && File.Exists(newValue); - } - - private void OnSettingsChanged(object sender, EventArgs e) { - IsChanged = true; - - foreach (var score in Scores.Values) { - score.UpdateBarTimings(); - } - - GlobalSettingsChanged.Raise(sender, e); - } - - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/ProjectVersion.cs b/StarlightDirector/StarlightDirector.Entities/ProjectVersion.cs deleted file mode 100644 index 084b2b7..0000000 --- a/StarlightDirector/StarlightDirector.Entities/ProjectVersion.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace StarlightDirector.Entities { - - public static class ProjectVersion { - - public const int Unknown = 0; - public const int V0_1 = 100; - public const int V0_2 = 200; - public const int V0_3 = 300; - public const int V0_3_1 = 301; - - public static readonly int Current = V0_3_1; - - } - -} diff --git a/StarlightDirector/StarlightDirector.Entities/Properties/AssemblyInfo.cs b/StarlightDirector/StarlightDirector.Entities/Properties/AssemblyInfo.cs deleted file mode 100644 index a730ae6..0000000 --- a/StarlightDirector/StarlightDirector.Entities/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// 有关程序集的一般信息由以下 -// 控制。更改这些特性值可修改 -// 与程序集关联的信息。 -[assembly: AssemblyTitle("StarlightDirector.Entities")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("StarlightDirector.Entities")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -//将 ComVisible 设置为 false 将使此程序集中的类型 -//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, -//请将此类型的 ComVisible 特性设置为 true。 -[assembly: ComVisible(false)] - -// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID -[assembly: Guid("d78a4080-34f4-45ec-a8ef-87f95815e3bd")] - -// 程序集的版本信息由下列四个值组成: -// -// 主版本 -// 次版本 -// 生成号 -// 修订号 -// -//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, -// 方法是按如下所示使用“*”: : -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] - -[assembly: InternalsVisibleTo("StarlightDirector")] -[assembly: InternalsVisibleTo("StarlightDirector.Exchange")] diff --git a/StarlightDirector/StarlightDirector.Entities/Score.cs b/StarlightDirector/StarlightDirector.Entities/Score.cs deleted file mode 100644 index 61de4f1..0000000 --- a/StarlightDirector/StarlightDirector.Entities/Score.cs +++ /dev/null @@ -1,155 +0,0 @@ -using System; -using System.Linq; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; - -namespace StarlightDirector.Entities { - [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy), MemberSerialization = MemberSerialization.OptIn)] - public sealed class Score { - - [JsonProperty] - public InternalList Bars { get; } - - public Project Project { get; internal set; } - - public Difficulty Difficulty { get; internal set; } - - public Bar AddBar() { - return InsertBar(Bars.Count); - } - - public Bar InsertBar(int indexBefore) { - return InsertBar(indexBefore, null); - } - - public Bar InsertBar(int indexBefore, BarParams barParams) { - var bar = new Bar(this, indexBefore) { - Params = barParams - }; - if (indexBefore == Bars.Count) { - Bars.Add(bar); - bar.UpdateTimings(); - - } else { - Bars.Insert(indexBefore, bar); - bar.UpdateTimings(); - - foreach (var b in Bars.Skip(indexBefore + 1)) { - ++b.Index; - b.UpdateTimings(); - } - } - return bar; - } - - public bool RemoveBarAt(int index) { - if (index < 0 || index >= Bars.Count) { - return false; - } - return RemoveBar(Bars[index]); - } - - public bool RemoveBar(Bar bar) { - var bars = Bars; - if (!bars.Contains(bar)) { - return false; - } - var index = bars.IndexOf(bar); - foreach (var note in bar.Notes) { - Notes.Remove(note); - } - bars.Remove(bar); - for (var i = index; i < bars.Count; ++i) { - --bars[i].Index; - bars[i].UpdateTimings(); - } - return true; - } - - public bool HasAnyNote => Notes.Count > 0; - - public InternalList Notes { get; } - - public bool Validate(out string[] problems) { - // Rules: - // 1. [error] Hold lines do not cross on other notes; - // 2. [warning] Two notes on the same grid line have no sync relation; - // 3. [warning] Flick group contains only one flick note. - throw new NotImplementedException(); - } - - public bool Validate() { - string[] dummy; - return Validate(out dummy); - } - - [JsonConstructor] - internal Score(Project project, Difficulty difficulty) { - Bars = new InternalList(); - Project = project; - Difficulty = difficulty; - Notes = new InternalList(); - } - - internal void ResolveReferences(Project project) { - if (Bars == null) { - return; - } - Project = project; - foreach (var bar in Bars) { - foreach (var note in bar.Notes) { - note.Bar = bar; - } - bar.Score = this; - } - var allNotes = Bars.SelectMany(bar => bar.Notes).ToArray(); - Notes.AddRange(allNotes); - foreach (var note in allNotes) { - if (!note.IsGamingNote) { - continue; - } - if (note.NextFlickOrSlideNoteID != EntityID.Invalid) { - note.NextFlickOrSlideNote = FindNoteByID(note.NextFlickOrSlideNoteID); - } - if (note.PrevFlickOrSlideNoteID != EntityID.Invalid) { - note.PrevFlickOrSlideNote = FindNoteByID(note.PrevFlickOrSlideNoteID); - } - if (note.HoldTargetID != EntityID.Invalid) { - note.HoldTarget = FindNoteByID(note.HoldTargetID); - } - } - } - - internal void FixSyncNotes() { - foreach (var bar in Bars) { - var gridIndexGroups = - from n in bar.Notes - where n.IsGamingNote - group n by n.IndexInGrid into g - select g; - foreach (var group in gridIndexGroups) { - var sortedNotesInGroup = - from n in @group - orderby n.IndexInTrack - select n; - Note prev = null; - foreach (var note in sortedNotesInGroup) { - Note.ConnectSync(prev, note); - prev = note; - } - Note.ConnectSync(prev, null); - } - } - } - - private Note FindNoteByID(int noteID) { - return Bars.SelectMany(bar => bar.Notes).FirstOrDefault(note => note.ID == noteID); - } - - internal void UpdateBarTimings() { - foreach (var bar in Bars) { - bar.UpdateTimings(); - } - } - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/ScoreSettings.cs b/StarlightDirector/StarlightDirector.Entities/ScoreSettings.cs deleted file mode 100644 index 28f37e9..0000000 --- a/StarlightDirector/StarlightDirector.Entities/ScoreSettings.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Windows; -using DereTore.Common; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; - -namespace StarlightDirector.Entities { - [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy), MemberSerialization = MemberSerialization.OptIn)] - public sealed class ScoreSettings : DependencyObject, ICloneable { - - public event EventHandler SettingChanged; - - /// - /// Tempo,每分钟四分音符出现次数。 - /// - [JsonProperty] - public double GlobalBpm { - get { return (double)GetValue(GlobalBpmProperty); } - set { SetValue(GlobalBpmProperty, value); } - } - - [JsonProperty] - public double StartTimeOffset { - get { return (double)GetValue(StartTimeOffsetProperty); } - set { SetValue(StartTimeOffsetProperty, value); } - } - - /// - /// 细分级别,一个四分音符被分成多少份。 - /// 例如,分成2份,拍号3(3/4拍),速度120,则每一个小节长度为1.5秒(=60÷120×3),每个note定位精度为一个八分音符(=1/2四分音符)。 - /// - [JsonProperty] - public int GlobalGridPerSignature { get; set; } - - /// - /// 拍号,以四分音符为标准,即 x/4 拍。 - /// - [JsonProperty] - public int GlobalSignature { get; set; } - - public static ScoreSettings CreateDefault() { - return new ScoreSettings { - GlobalBpm = DefaultGlobalBpm, - StartTimeOffset = DefaultStartTimeOffset, - GlobalGridPerSignature = DefaultGlobalGridPerSignature, // 最高分辨率为九十六分音符 - GlobalSignature = DefaultGlobalSignature // 4/4拍 - }; - } - - public static readonly DependencyProperty GlobalBpmProperty = DependencyProperty.Register(nameof(GlobalBpm), typeof(double), typeof(ScoreSettings), - new PropertyMetadata(120d, OnGlobalBpmChanged)); - - public static readonly DependencyProperty StartTimeOffsetProperty = DependencyProperty.Register(nameof(StartTimeOffset), typeof(double), typeof(ScoreSettings), - new PropertyMetadata(0d, OnStartTimeOffsetChanged)); - - public static readonly double DefaultGlobalBpm = 120; - public static readonly double DefaultStartTimeOffset = 0; - public static readonly int DefaultGlobalGridPerSignature = 24; - public static readonly int DefaultGlobalSignature = 4; - - public ScoreSettings Clone() { - return new ScoreSettings { - GlobalBpm = GlobalBpm, - StartTimeOffset = StartTimeOffset, - GlobalGridPerSignature = GlobalGridPerSignature, - GlobalSignature = GlobalSignature - }; - } - - public void CopyFrom(ScoreSettings settings) { - if (settings == null) { - throw new ArgumentNullException(nameof(settings)); - } - GlobalBpm = settings.GlobalBpm; - StartTimeOffset = settings.StartTimeOffset; - GlobalGridPerSignature = settings.GlobalGridPerSignature; - GlobalSignature = settings.GlobalSignature; - } - - private static void OnGlobalBpmChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { - var settings = (ScoreSettings)obj; - settings.SettingChanged.Raise(obj, EventArgs.Empty); - } - - private static void OnStartTimeOffsetChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { - var settings = (ScoreSettings)obj; - settings.SettingChanged.Raise(obj, EventArgs.Empty); - } - - [JsonConstructor] - private ScoreSettings() { - } - - object ICloneable.Clone() { - return Clone(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/Serialization/ScoreCsvMap.cs b/StarlightDirector/StarlightDirector.Entities/Serialization/ScoreCsvMap.cs deleted file mode 100644 index dcae379..0000000 --- a/StarlightDirector/StarlightDirector.Entities/Serialization/ScoreCsvMap.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using CsvHelper.Configuration; -using CsvHelper.TypeConversion; - -namespace StarlightDirector.Entities.Serialization { - public sealed class ScoreCsvMap : CsvClassMap { - - public ScoreCsvMap() { - Map(m => m.ID).Name("id"); - Map(m => m.HitTiming).Name("sec").TypeConverter(); - Map(m => m.Type).Name("type").TypeConverter(); - // See song_3034 (m063), master level score. These fields are empty, so we need a custom type converter. - Map(m => m.StartPosition).Name("startPos").TypeConverter(); - Map(m => m.FinishPosition).Name("finishPos").TypeConverter(); - Map(m => m.FlickType).Name("status").TypeConverter(); - Map(m => m.IsSync).Name("sync").TypeConverter(); - Map(m => m.GroupID).Name("groupId"); - } - - private sealed class IntToBoolConverter : ITypeConverter { - - public string ConvertToString(TypeConverterOptions options, object value) { - return (bool)value ? "1" : "0"; - } - - public object ConvertFromString(TypeConverterOptions options, string text) { - if (string.IsNullOrEmpty(text)) { - return false; - } - var value = int.Parse(text); - return value != 0; - } - - public bool CanConvertFrom(Type type) { - return true; - } - - public bool CanConvertTo(Type type) { - return true; - } - - } - - private sealed class RestrictedDoubleToStringConverter : ITypeConverter { - - public string ConvertToString(TypeConverterOptions options, object value) { - return ((double)value).ToString("0.######"); - } - - public object ConvertFromString(TypeConverterOptions options, string text) { - if (string.IsNullOrEmpty(text)) { - return 0d; - } - return options.NumberStyle != null ? double.Parse(text, options.NumberStyle.Value) : double.Parse(text); - } - - public bool CanConvertFrom(Type type) { - return true; - } - - public bool CanConvertTo(Type type) { - return true; - } - - } - - private sealed class StringToIntConverter : ITypeConverter { - - public string ConvertToString(TypeConverterOptions options, object value) { - // The conversion is for enums. - return ((int)value).ToString(); - } - - public object ConvertFromString(TypeConverterOptions options, string text) { - if (string.IsNullOrEmpty(text)) { - return 0; - } - var value = int.Parse(text); - return value; - } - - public bool CanConvertFrom(Type type) { - return true; - } - - public bool CanConvertTo(Type type) { - return true; - } - - } - - } -} diff --git a/StarlightDirector/StarlightDirector.Entities/StarlightDirector.Entities.csproj b/StarlightDirector/StarlightDirector.Entities/StarlightDirector.Entities.csproj deleted file mode 100644 index 4cca0f0..0000000 --- a/StarlightDirector/StarlightDirector.Entities/StarlightDirector.Entities.csproj +++ /dev/null @@ -1,117 +0,0 @@ - - - - - Debug - AnyCPU - {D78A4080-34F4-45EC-A8EF-87F95815E3BD} - Library - Properties - StarlightDirector.Entities - StarlightDirector.Entities - v4.0 - 512 - - - - - true - bin\x64\Debug\ - DEBUG;TRACE - full - x64 - prompt - MinimumRecommendedRules.ruleset - - - bin\x64\Release\ - TRACE - true - pdbonly - x64 - prompt - MinimumRecommendedRules.ruleset - - - true - bin\x86\Debug\ - DEBUG;TRACE - full - x86 - prompt - MinimumRecommendedRules.ruleset - - - bin\x86\Release\ - TRACE - true - pdbonly - x86 - prompt - MinimumRecommendedRules.ruleset - - - - ..\..\packages\CsvHelper.2.16.3.0\lib\net40\CsvHelper.dll - True - - - ..\..\packages\Newtonsoft.Json.9.0.1\lib\net40\Newtonsoft.Json.dll - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {DBD0DA4A-0057-4D04-AD69-0E7267D72793} - DereTore.Common - - - {7FB2A631-88C4-4C6B-9E8B-8EEEB40575D0} - StarlightDirector.Core - - - - - \ No newline at end of file diff --git a/StarlightDirector/StarlightDirector.Entities/packages.config b/StarlightDirector/StarlightDirector.Entities/packages.config deleted file mode 100644 index c6dd406..0000000 --- a/StarlightDirector/StarlightDirector.Entities/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/StarlightDirector/StarlightDirector.Exchange/Deleste/CommandParameters/ChangeBpmCommandParameters.cs b/StarlightDirector/StarlightDirector.Exchange/Deleste/CommandParameters/ChangeBpmCommandParameters.cs deleted file mode 100644 index c9d8aed..0000000 --- a/StarlightDirector/StarlightDirector.Exchange/Deleste/CommandParameters/ChangeBpmCommandParameters.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; - -namespace StarlightDirector.Exchange.Deleste.CommandParameters { - internal sealed class ChangeBpmCommandParameters : ICloneable { - - public int StartMeasureIndex { get; set; } - - public double NewBpm { get; set; } - - public ChangeBpmCommandParameters Clone() { - return new ChangeBpmCommandParameters { - StartMeasureIndex = StartMeasureIndex, - NewBpm = NewBpm - }; - } - - object ICloneable.Clone() { - return Clone(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector.Exchange/Deleste/Constants.cs b/StarlightDirector/StarlightDirector.Exchange/Deleste/Constants.cs deleted file mode 100644 index 43bbc2c..0000000 --- a/StarlightDirector/StarlightDirector.Exchange/Deleste/Constants.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace StarlightDirector.Exchange.Deleste { - internal static class Constants { - - public static readonly string[] BeatmapCommands = { - "#changeattribute", - "#measure", - "@group_flick" - }; - - public static readonly string BpmCommand = "#bpm"; - public static readonly string ChangeBpmCommand = "#changebpm"; - public static readonly string OffsetCommand = "#offset"; - // Not supported for now. May be integrated in future versions. - public static readonly string DifficultyCommand = "#difficulty"; - - public static readonly int DefaultSignature = 4; - - // We avoid using Environment.NewLine, for format consistency. - public static readonly string NewLine = "\n"; - - } -} diff --git a/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteBasicNote.cs b/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteBasicNote.cs deleted file mode 100644 index 098b1a7..0000000 --- a/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteBasicNote.cs +++ /dev/null @@ -1,40 +0,0 @@ -using StarlightDirector.Entities; - -namespace StarlightDirector.Exchange.Deleste { - internal sealed class DelesteBasicNote { - - public DelesteBasicNote() - : this(null) { - } - - public DelesteBasicNote(DelesteBeatmapEntry entry) { - Entry = entry; - } - - public int IndexInMeasure { get; set; } - - public DelesteNoteType Type { get; set; } - - public NotePosition StartPosition { get; set; } - - public NotePosition FinishPosition { get; set; } - - public bool IsFlick => Type == DelesteNoteType.FlickLeft || Type == DelesteNoteType.FlickRight; - - public bool IsFlickLeft => Type == DelesteNoteType.FlickLeft; - - public bool IsFlickRight => Type == DelesteNoteType.FlickRight; - - public bool IsTap => Type == DelesteNoteType.Tap; - - public bool IsHoldStart => Type == DelesteNoteType.Hold; - - public int IndexInTrack => (int)FinishPosition - 1; - - public DelesteBeatmapEntry Entry { get; internal set; } - - // For usage in compiling to Deleste beatmap only. - internal int GroupID { get; set; } = -1; - - } -} diff --git a/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteBeatmapEntry.cs b/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteBeatmapEntry.cs deleted file mode 100644 index 4444605..0000000 --- a/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteBeatmapEntry.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace StarlightDirector.Exchange.Deleste { - internal sealed class DelesteBeatmapEntry { - - public int GroupID { get; set; } - - public int MeasureIndex { get; set; } - - public int FullLength { get; set; } - - public DelesteBasicNote[] Notes { get; set; } - - public double BPM { get; set; } - - public double Signature { get; set; } - - public bool IsCommand { get; set; } - - public DelesteCommand CommandType { get; set; } - - public object CommandParameter { get; set; } - - } -} diff --git a/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteCommand.cs b/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteCommand.cs deleted file mode 100644 index c98bc44..0000000 --- a/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteCommand.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace StarlightDirector.Exchange.Deleste { - internal enum DelesteCommand { - - None, - ChangeBpm - - } -} diff --git a/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteGroupID.cs b/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteGroupID.cs deleted file mode 100644 index cdee381..0000000 --- a/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteGroupID.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace StarlightDirector.Exchange.Deleste { - internal static class DelesteGroupID { - - public static bool IsSupportedGroup(int groupID) { - var m = groupID % 4; - return m == 0 || m == 1; - } - - } -} diff --git a/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteHelper.cs b/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteHelper.cs deleted file mode 100644 index ca9a27a..0000000 --- a/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteHelper.cs +++ /dev/null @@ -1,453 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using DereTore.Common; -using StarlightDirector.Entities; -using StarlightDirector.Entities.Extensions; -using StarlightDirector.Exchange.Deleste.CommandParameters; -using StarlightDirector.Exchange.Properties; - -namespace StarlightDirector.Exchange.Deleste { - internal static class DelesteHelper { - - public static void AnalyzeBeatmap(Score score, List entries, DelesteState initialState, List warnings) { - var currentHoldingNotes = new Note[5]; - // key: Deleste Group Number - // value: (value) - var lastFlickNotes = new Dictionary(); - var lastBasicFlickNotes = new Dictionary(); - - // Prepare the entry params. This params will affect timing computing. - var state = initialState.Clone(); - var changeBpmCommands = new List(); - foreach (var entry in entries) { - if (entry.IsCommand) { - switch (entry.CommandType) { - case DelesteCommand.ChangeBpm: - var parameters = (ChangeBpmCommandParameters)entry.CommandParameter; - var item = changeBpmCommands.Find(p => p.StartMeasureIndex == parameters.StartMeasureIndex); - if (item != null) { - // Command parameter override - item.NewBpm = parameters.NewBpm; - } else { - changeBpmCommands.Add(parameters.Clone()); - } - state.BPM = parameters.NewBpm; - break; - default: - throw new ArgumentOutOfRangeException(); - } - } else { - // Reset entry state. - entry.BPM = state.BPM; - entry.Signature = state.Signature; - } - } - - // Here is where the main analysis happens. - foreach (var entry in entries) { - if (entry.IsCommand) { - continue; - } - - if (entry.MeasureIndex + 1 > score.Bars.Count) { - for (var i = score.Bars.Count; i < entry.MeasureIndex + 1; ++i) { - score.Bars.Add(new Bar(score, i)); - } - } - var bar = score.Bars[entry.MeasureIndex]; - var totalBarGridCount = bar.TotalGridCount; - - if (entry.FullLength > 0 && !totalBarGridCount.IsMultipleOf(entry.FullLength)) { - // Try to fit in the grid. E.g. Yumeiro Harmony measure #041. - var lengthFactors = new List { - (uint)entry.FullLength - }; - lengthFactors.AddRange(entry.Notes.Select(note => (uint)note.IndexInMeasure)); - var factor = (int)MathHelper.GreatestCommonFactor(lengthFactors.Where(n => n != 0).ToArray()); - var originalEntryFullLength = entry.FullLength; - if (factor > 1) { - entry.FullLength /= factor; - foreach (var basicNote in entry.Notes) { - basicNote.IndexInMeasure /= factor; - } - } - if (!totalBarGridCount.IsMultipleOf(entry.FullLength)) { - var warning = string.Format(Resources.DelesteUnfitGridSizePromptTemplate, entry.MeasureIndex, originalEntryFullLength, totalBarGridCount); - warnings.Add(warning); - continue; - } - } - - foreach (var basicNote in entry.Notes) { - if (!basicNote.IsFlick) { - lastFlickNotes[entry.GroupID] = null; - } - var note = bar.AddNote(); - note.IndexInGrid = (int)(totalBarGridCount * ((float)basicNote.IndexInMeasure / entry.FullLength)); - note.StartPosition = basicNote.StartPosition; - note.FinishPosition = basicNote.FinishPosition; - var positionInTrack = basicNote.IndexInTrack; - - if (basicNote.IsHoldStart) { - // The '<' part fixes this example: (credits to @inosuke01) - // #0,043:330000002020*4*000:42511:12132 - // #1,043:4000202040002000:11211:44544 - // #4,043:0001*1*00000000000:32 - // Without this judgement, the two notes marked with '*' will be wrongly connected. - if (currentHoldingNotes[positionInTrack] != null && currentHoldingNotes[positionInTrack] < note) { - // Invalid holding notes: I haven't released my finger yet! - // OK, accept it, set the newly added note as hold end. - Note.ConnectHold(currentHoldingNotes[positionInTrack], note); - currentHoldingNotes[positionInTrack] = null; - } else { - currentHoldingNotes[positionInTrack] = note; - } - lastFlickNotes[entry.GroupID] = null; - lastBasicFlickNotes[entry.GroupID] = null; - continue; - } - if (currentHoldingNotes[positionInTrack] != null && currentHoldingNotes[positionInTrack] < note) { - Note.ConnectHold(currentHoldingNotes[positionInTrack], note); - currentHoldingNotes[positionInTrack] = null; - if (basicNote.IsFlick) { - note.FlickType = basicNote.IsFlickLeft ? NoteFlickType.FlickLeft : NoteFlickType.FlickRight; - } - } - if (basicNote.IsTap) { - lastFlickNotes[entry.GroupID] = null; - lastBasicFlickNotes[entry.GroupID] = null; - continue; - } - if (basicNote.IsFlick) { - if (!lastFlickNotes.ContainsKey(entry.GroupID) || !lastBasicFlickNotes.ContainsKey(entry.GroupID) || - lastFlickNotes[entry.GroupID] == null || lastBasicFlickNotes[entry.GroupID] == null) { - lastFlickNotes[entry.GroupID] = note; - lastBasicFlickNotes[entry.GroupID] = basicNote; - continue; - } - // Whether the next note is a traditional flick or not, set it. - lastFlickNotes[entry.GroupID].FlickType = lastBasicFlickNotes[entry.GroupID].IsFlickLeft ? NoteFlickType.FlickLeft : NoteFlickType.FlickRight; - // We haven implemented Free Flick Mode so we assume all the notes are in Restricted Flick Mode (as in real gaming). - var requestedFlickDirection = lastBasicFlickNotes[entry.GroupID].IsFlickLeft ? -1 : 1; - var actualFlickDirection = (int)basicNote.FinishPosition - (int)lastBasicFlickNotes[entry.GroupID].FinishPosition; - // <0: Current note is not in the requested trail. (e.g. right vs 5->1) - // =0: Current note is not in the requested trail. (e.g. right vs 3->3) - // >0: Current note is in the requested trail. (e.g. right vs 1->2) - if (actualFlickDirection * requestedFlickDirection <= 0) { - lastFlickNotes[entry.GroupID] = note; - lastBasicFlickNotes[entry.GroupID] = basicNote; - continue; - } - // > ※ただし、1000msを超えると接続されません - var timeDiff = CalculateTimingPeriodBetweenNotes(entries, basicNote, lastBasicFlickNotes[entry.GroupID], entry.FullLength); - if (timeDiff > 1) { - lastFlickNotes[entry.GroupID] = note; - lastBasicFlickNotes[entry.GroupID] = basicNote; - continue; - } - Note.ConnectFlick(lastFlickNotes[entry.GroupID], note); - lastFlickNotes[entry.GroupID] = note; - lastBasicFlickNotes[entry.GroupID] = basicNote; - } - } - } - - // Add variant bpm notes to the bar. - changeBpmCommands.Sort((p1, p2) => p1.StartMeasureIndex.CompareTo(p2.StartMeasureIndex)); - foreach (var p in changeBpmCommands) { - if (p.StartMeasureIndex >= score.Bars.Count) { - break; - } - var bar = score.Bars[p.StartMeasureIndex]; - var vbNote = bar.AddNote(); - vbNote.IndexInGrid = 0; - vbNote.SetSpecialType(NoteType.VariantBpm); - vbNote.ExtraParams = new NoteExtraParams { - Note = vbNote, - NewBpm = p.NewBpm - }; - } - - // Fix sync notes. - score.FixSyncNotes(); - - // Fix hold notes: if any line crosses other note(s). (Is it necessary? Deleste files seem to be organized well.) - foreach (var note in score.Notes) { - if (note.IsHoldStart) { - var between = score.Notes.GetFirstNoteBetween(note, note.HoldTarget); - if (between != null) { - note.HoldTarget = between; - } - } - } - } - - public static DelesteBeatmapEntry ReadEntry(Project temporaryProject, string line, int entryCounter, List noteCache, List warnings, ref bool hasErrors) { - line = line.ToLowerInvariant(); - if (line.StartsWithOfGroup(Constants.BeatmapCommands)) { - line = line.Substring(0, line.IndexOf(' ')); - var warning = string.Format(Resources.DelesteCommandIsNotYetSupportedPromptTemplate, entryCounter, line); - warnings.Add(warning); - return null; - } - - DelesteBeatmapEntry entry; - var isCommand = HandleCommands(line, temporaryProject, out entry); - if (isCommand) { - return entry; - } - if (line.Length < 2 || !char.IsNumber(line, 1)) { - // Not a beatmap entry. May be metadata. - return null; - } - - if (line.IndexOf('.') >= 0) { - hasErrors = true; - var warning = Resources.DelesteTxtFormat2IsNotSupportedPrompt; - warnings.Add(warning); - return null; - } - - // #gid,mid:types&indices:sp[:fp] - var colonStringValues = line.Substring(1).Split(':'); - var commaStringValues = colonStringValues[0].Split(','); - var noteDistribution = colonStringValues[1]; - var standardNoteCount = noteDistribution.Count(ch => ch != '0'); - - // Abbreviated format (1, 2) & full format - // #0,000:2 - // #0,000:2222:1234 - // #0,001:2222:3333:3333 - var groupNumberString = commaStringValues[0]; - var measureIndexString = commaStringValues[1]; - string finishPositions, startPositions; - switch (colonStringValues.Length) { - case 2: - startPositions = finishPositions = new string('3', standardNoteCount); - break; - case 3: - startPositions = finishPositions = colonStringValues[2]; - break; - default: - startPositions = colonStringValues[2]; - finishPositions = colonStringValues[3]; - break; - } - noteCache.Clear(); - - var measureIndex = Convert.ToInt32(measureIndexString); - if (standardNoteCount != startPositions.Length || startPositions.Length != finishPositions.Length) { - var warning = string.Format(Resources.DelesteNoteCountInconsistentPromptTemplate, entryCounter, measureIndex, standardNoteCount, startPositions.Length, finishPositions.Length); - warnings.Add(warning); - return null; - } - entry = new DelesteBeatmapEntry(); - entry.GroupID = Convert.ToInt32(groupNumberString); - entry.MeasureIndex = measureIndex; - entry.FullLength = noteDistribution.Length; - int i = -1, j = -1; - foreach (var ch in noteDistribution) { - ++j; - if (ch == '0') { - continue; - } - ++i; - var note = new DelesteBasicNote(entry); - note.IndexInMeasure = j; - note.Type = (DelesteNoteType)(ch - '0'); - note.StartPosition = (NotePosition)(startPositions[i] - '0'); - note.FinishPosition = (NotePosition)(finishPositions[i] - '0'); - noteCache.Add(note); - } - entry.Notes = noteCache.ToArray(); - return entry; - } - - public static Encoding TryDetectBeatmapEncoding(string fileName) { - using (var fileStream = File.Open(fileName, FileMode.Open, FileAccess.Read)) { - using (var streamReader = new StreamReader(fileStream, Encoding.UTF8)) { - var line = string.Empty; - if (!streamReader.EndOfStream) { - do { - line = streamReader.ReadLine(); - } while (line.Length > 0 && line[0] != '#' && !streamReader.EndOfStream); - } - line = line.ToLowerInvariant(); - if (!string.IsNullOrEmpty(line)) { - if (line == "#utf8" || line == "#utf-8") { - return Encoding.UTF8; - } else { - // According to the help of Deleste: - // - // > 譜面ファイルの文字コードは原則「Shift-JIS」を使用してください。 - // > 例外的に「UTF-8」のみ使用できます。 - // > 使用する場合、テキストファイルの先頭に「#utf8」又は「#utf-8」と記述してください。 - return Encoding.GetEncoding("Shift-JIS"); - } - } else { - return Encoding.GetEncoding("Shift-JIS"); - } - } - } - } - - public static void WriteBeatmapHeader(Score score, StreamWriter writer) { - writer.WriteLine("#utf8"); - writer.WriteLine("#Title (Title Here)"); - writer.WriteLine("#Lyricist (Lyricist)"); - writer.WriteLine("#Composer (Composer)"); - writer.WriteLine("#Background background.jpg"); - writer.WriteLine("#Song song.ogg"); - writer.WriteLine("#Lyrics lyrics.lyr"); - // Using the 240/0 preset as discussed at 2016-10-09. May be updated when a new version of Deleste Viewer is released. - //writer.WriteLine("#BPM {0:F2}", score.Project.Settings.GlobalBpm); - //writer.WriteLine("#Offset {0}", (int)Math.Round(score.Project.Settings.StartTimeOffset * 1000)); - writer.WriteLine("#BPM 240"); - writer.WriteLine("#Offset 0"); - string s; - switch (score.Difficulty) { - case Difficulty.Debut: - case Difficulty.Regular: - case Difficulty.Pro: - case Difficulty.Master: - s = score.Difficulty.ToString(); - break; - case Difficulty.MasterPlus: - s = "Master+"; - break; - default: - throw new ArgumentOutOfRangeException(); - } - writer.WriteLine("#Difficulty {0}", s); - switch (score.Difficulty) { - case Difficulty.Debut: - s = "7"; - break; - case Difficulty.Regular: - s = "13"; - break; - case Difficulty.Pro: - s = "17"; - break; - case Difficulty.Master: - s = "23"; - break; - case Difficulty.MasterPlus: - s = "30"; - break; - default: - throw new ArgumentOutOfRangeException(); - } - writer.WriteLine("#Level {0}", s); - writer.WriteLine("#BGMVolume 100"); - writer.WriteLine("#SEVolume 100"); - writer.WriteLine("#Attribute All"); - // Use the undocumented "Convert" format for CSV-converted beatmaps. - writer.WriteLine("#Format Convert"); - writer.WriteLine(); - } - - public static void WriteEntries(Score score, StreamWriter writer) { - var compiledScore = score.Compile(); - // group_id,measure_index:deleste_note_type:start_position:finish_position - // * measure_index can be floating point numbers: 000.000000 - foreach (var compiledNote in compiledScore.Notes) { - if (!Note.IsTypeGaming(compiledNote.Type)) { - continue; - } - writer.WriteLine("#{0},{1:000.000000}:{2}:{3}:{4}", compiledNote.GroupID, compiledNote.HitTiming, (int)TranslateNoteType(compiledNote), (int)compiledNote.StartPosition, (int)compiledNote.FinishPosition); - } - } - - private static DelesteNoteType TranslateNoteType(CompiledNote note) { - switch (note.Type) { - case NoteType.TapOrFlick: - switch (note.FlickType) { - case (int)NoteFlickType.Tap: - return DelesteNoteType.Tap; - case (int)NoteFlickType.FlickLeft: - return DelesteNoteType.FlickLeft; - case (int)NoteFlickType.FlickRight: - return DelesteNoteType.FlickRight; - default: - // Should have thrown an exception. - return DelesteNoteType.Tap; - } - case NoteType.Hold: - return DelesteNoteType.Hold; - case NoteType.Slide: - return DelesteNoteType.Slide; - default: - throw new ArgumentOutOfRangeException(); - } - } - - private static bool HandleCommands(string line, Project temporaryProject, out DelesteBeatmapEntry entry) { - entry = null; - if (line.StartsWith(Constants.BpmCommand)) { - var dataText = line.Substring(Constants.BpmCommand.Length + 1); - var bpm = double.Parse(dataText); - temporaryProject.Settings.GlobalBpm = bpm; - return true; - } - if (line.StartsWith(Constants.OffsetCommand)) { - var dataText = line.Substring(Constants.OffsetCommand.Length + 1); - var offset = double.Parse(dataText); - offset = Math.Abs(offset); - // msec -> sec - temporaryProject.Settings.StartTimeOffset = offset / 1000; - return true; - } - if (line.StartsWith(Constants.ChangeBpmCommand)) { - var dataText = line.Substring(Constants.ChangeBpmCommand.Length + 1); - var commaSplittedValues = dataText.Split(','); - var measureIndex = double.Parse(commaSplittedValues[0]); - var newBpm = double.Parse(commaSplittedValues[1]); - entry = new DelesteBeatmapEntry { - IsCommand = true, - CommandType = DelesteCommand.ChangeBpm, - CommandParameter = new ChangeBpmCommandParameters { - StartMeasureIndex = (int)measureIndex, - NewBpm = newBpm - } - }; - return true; - } - return false; - } - - private static double CalculateTimingPeriodBetweenNotes(List entries, DelesteBasicNote currentBasicFlickNote, DelesteBasicNote lastBasicFlickNote, int fullLength) { - double timeDiff; - double timePerBeat; - DelesteBeatmapEntry entry; - if (currentBasicFlickNote.Entry.MeasureIndex != lastBasicFlickNote.Entry.MeasureIndex) { - var startIndex = entries.IndexOf(lastBasicFlickNote.Entry); - var endIndex = entries.IndexOf(currentBasicFlickNote.Entry, startIndex + 1); - - entry = lastBasicFlickNote.Entry; - timePerBeat = DirectorHelper.BpmToSeconds(entry.BPM); - timeDiff = timePerBeat * entry.Signature * (1 - (float)lastBasicFlickNote.IndexInMeasure / lastBasicFlickNote.Entry.FullLength); - for (var i = startIndex + 1; i < endIndex; ++i) { - entry = entries[i]; - if (entry.IsCommand) { - continue; - } - timePerBeat = DirectorHelper.BpmToSeconds(entry.BPM); - timeDiff += timePerBeat * entry.Signature; - } - entry = currentBasicFlickNote.Entry; - timePerBeat = DirectorHelper.BpmToSeconds(entry.BPM); - timeDiff += timePerBeat * entry.Signature * ((float)currentBasicFlickNote.IndexInMeasure / fullLength); - } else { - entry = currentBasicFlickNote.Entry; - timePerBeat = DirectorHelper.BpmToSeconds(entry.BPM); - timeDiff = timePerBeat * entry.Signature * ((float)currentBasicFlickNote.IndexInMeasure / fullLength - (float)lastBasicFlickNote.IndexInMeasure / lastBasicFlickNote.Entry.FullLength); - } - return timeDiff; - } - - } -} diff --git a/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteHelperExtensions.cs b/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteHelperExtensions.cs deleted file mode 100644 index d247247..0000000 --- a/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteHelperExtensions.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Linq; - -namespace StarlightDirector.Exchange.Deleste { - internal static class DelesteHelperExtensions { - - public static bool StartsWithOfGroup(this string str, string[] group) { - return group.Any(str.StartsWith); - } - - } -} diff --git a/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteNoteType.cs b/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteNoteType.cs deleted file mode 100644 index 2dce458..0000000 --- a/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteNoteType.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace StarlightDirector.Exchange.Deleste { - internal enum DelesteNoteType { - - Null = 0, - FlickLeft = 1, - Tap = 2, - FlickRight = 3, - Hold = 4, - Slide = 5, - } -} diff --git a/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteState.cs b/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteState.cs deleted file mode 100644 index d703fe7..0000000 --- a/StarlightDirector/StarlightDirector.Exchange/Deleste/DelesteState.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; - -namespace StarlightDirector.Exchange.Deleste { - internal sealed class DelesteState : ICloneable { - - public double BPM { get; set; } - - public int Signature { get; set; } - - public DelesteState Clone() { - return new DelesteState { - BPM = BPM, - Signature = Signature - }; - } - - object ICloneable.Clone() { - return Clone(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector.Exchange/ProjectIO.Legacy.cs b/StarlightDirector/StarlightDirector.Exchange/ProjectIO.Legacy.cs deleted file mode 100644 index 81b32d1..0000000 --- a/StarlightDirector/StarlightDirector.Exchange/ProjectIO.Legacy.cs +++ /dev/null @@ -1,204 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.SQLite; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using StarlightDirector.Entities; -using DereTore.Common; - -namespace StarlightDirector.Exchange { - partial class ProjectIO { - - internal static int CheckProjectFileVersion(string fileName) { - try { - using (var fileStream = File.Open(fileName, FileMode.Open, FileAccess.Read)) { - var buffer = new byte[128]; - fileStream.Read(buffer, 0, buffer.Length); - var separatorIndex = buffer.IndexOf((byte)'\n'); - if (separatorIndex >= 0) { - if (separatorIndex > 0 && buffer[separatorIndex - 1] == '\r') { - --separatorIndex; - } - var stringBuffer = buffer.Take(separatorIndex).ToArray(); - var versionString = Encoding.ASCII.GetString(stringBuffer); - const string standardVersionString = "// DereTore Composer Project, version 0.1"; - if (versionString == standardVersionString) { - return ProjectVersion.V0_1; - } - } - } - } catch (Exception ex) { - Debug.Print(ex.Message); - Debug.Print(ex.StackTrace); - } - try { - string versionString = null; - var builder = new SQLiteConnectionStringBuilder(); - builder.DataSource = fileName; - using (var connection = new SQLiteConnection(builder.ToString())) { - connection.Open(); - var command = connection.CreateCommand(); - command.CommandText = $"SELECT value FROM {Names.Table_Main} WHERE key = @key;"; - command.Parameters.Add("key", DbType.AnsiString).Value = Names.Field_Version; - var value = command.ExecuteScalar(); - if (value != DBNull.Value) { - versionString = (string)value; - } - if (versionString == null) { - command.Parameters["key"].Value = Names.Field_Vesion; - value = command.ExecuteScalar(); - if (value != DBNull.Value) { - versionString = (string)value; - } - } - if (versionString == null) { - var scoreTableExists = SQLiteHelper.DoesTableExist(connection, Names.Table_Scores); - if (scoreTableExists) { - // This is a bug from v0.3.x (maybe also v0.4.x), which occasionally leaves out the version ('vesion') field in 'main' table. - versionString = "0.2"; - } - } - command.Dispose(); - connection.Close(); - } - if (string.IsNullOrEmpty(versionString)) { - return ProjectVersion.Unknown; - } - double v; - double.TryParse(versionString, out v); - if (v.Equals(0.2)) { - return ProjectVersion.V0_2; - } else if (v.Equals(0.3)) { - return ProjectVersion.V0_3; - } else if (v.Equals(ProjectVersion.V0_3_1)) { - return ProjectVersion.V0_3_1; - } else { - return ProjectVersion.Unknown; - } - } catch (Exception ex) { - Debug.Print(ex.Message); - Debug.Print(ex.StackTrace); - return ProjectVersion.Unknown; - } - } - - private static Project LoadFromV01(string fileInput) { - Project project; - ScoreSettings settings = null; - - using (var fileStream = File.Open(fileInput, FileMode.Open, FileAccess.Read)) { - using (var reader = new StreamReader(fileStream, Encoding.ASCII)) { - reader.ReadLine(); - JObject p; - var jsonSerializer = JsonSerializer.Create(); - using (var jsonReader = new JsonTextReader(reader)) { - p = (JObject)jsonSerializer.Deserialize(jsonReader); - } - - project = new Project(); - project.MusicFileName = p.Property("musicFileName").Value.Value(); - var scores = p.Property("scores").Value.ToObject>(); - foreach (var kv in scores) { - project.Scores.Add(kv.Key, kv.Value); - } - - // Score settings - var rawScores = p.Property("scores").Values(); - foreach (var token in rawScores) { - var rawScore = (JObject)((JProperty)token).Value; - var settingsProp = rawScore.Property("settings"); - settings = settingsProp.Value.ToObject(); - if (settings != null) { - break; - } - } - } - } - - foreach (var difficulty in Difficulties) { - var score = project.GetScore(difficulty); - score.ResolveReferences(project); - score.FixSyncNotes(); - score.Difficulty = difficulty; - } - - // Call score.ResolveReferences() first. - if (settings != null) { - project.Settings.GlobalBpm = settings.GlobalBpm; - project.Settings.GlobalGridPerSignature = settings.GlobalGridPerSignature; - project.Settings.GlobalSignature = settings.GlobalSignature; - project.Settings.StartTimeOffset = settings.StartTimeOffset; - } - - project.SaveFileName = fileInput; - - GridLineFixup(project); - return project; - } - - private static Project LoadFromV02(string fileName) { - var fileInfo = new FileInfo(fileName); - if (!fileInfo.Exists) { - throw new FileNotFoundException(string.Empty, fileName); - } - fileName = fileInfo.FullName; - var project = new Project { - IsChanged = false, - SaveFileName = fileName - }; - var builder = new SQLiteConnectionStringBuilder(); - builder.DataSource = fileName; - using (var connection = new SQLiteConnection(builder.ToString())) { - connection.Open(); - SQLiteCommand getValues = null; - - // Main - var mainValues = SQLiteHelper.GetValues(connection, Names.Table_Main, ref getValues); - project.MusicFileName = mainValues[Names.Field_MusicFileName]; - //project.Version = mainValues[Names.Field_Version]; - - // Scores - var scoreValues = SQLiteHelper.GetValues(connection, Names.Table_Scores, ref getValues); - var jsonSerializer = JsonSerializer.CreateDefault(); - foreach (var difficulty in Difficulties) { - var indexString = ((int)difficulty).ToString("00"); - var scoreJson = scoreValues[indexString]; - Score score; - var scoreJsonBytes = Encoding.ASCII.GetBytes(scoreJson); - using (var memoryStream = new MemoryStream(scoreJsonBytes)) { - using (var reader = new StreamReader(memoryStream)) { - using (var jsonReader = new JsonTextReader(reader)) { - score = jsonSerializer.Deserialize(jsonReader); - } - } - } - score.ResolveReferences(project); - score.FixSyncNotes(); - score.Difficulty = difficulty; - project.Scores.Add(difficulty, score); - } - - // Score settings - var scoreSettingsValues = SQLiteHelper.GetValues(connection, Names.Table_ScoreSettings, ref getValues); - var settings = project.Settings; - settings.GlobalBpm = double.Parse(scoreSettingsValues[Names.Field_GlobalBpm]); - settings.StartTimeOffset = double.Parse(scoreSettingsValues[Names.Field_StartTimeOffset]); - settings.GlobalGridPerSignature = int.Parse(scoreSettingsValues[Names.Field_GlobalGridPerSignature]); - settings.GlobalSignature = int.Parse(scoreSettingsValues[Names.Field_GlobalSignature]); - - // Cleanup - getValues.Dispose(); - connection.Close(); - } - - GridLineFixup(project); - return project; - } - - } -} diff --git a/StarlightDirector/StarlightDirector.Exchange/ProjectIO.Names.cs b/StarlightDirector/StarlightDirector.Exchange/ProjectIO.Names.cs deleted file mode 100644 index 4161a0c..0000000 --- a/StarlightDirector/StarlightDirector.Exchange/ProjectIO.Names.cs +++ /dev/null @@ -1,47 +0,0 @@ -namespace StarlightDirector.Exchange { - static partial class ProjectIO { - - private static class Names { - - public static readonly string Table_Main = "main"; - public static readonly string Table_ScoreSettings = "score_settings"; - public static readonly string Table_Metadata = "metadata"; - public static readonly string Table_NoteIDs = "note_ids"; - public static readonly string Table_Notes = "notes"; - public static readonly string Table_BarParams = "bar_params"; - public static readonly string Table_SpecialNotes = "special_notes"; - - public static readonly string Field_MusicFileName = "music_file_name"; - public static readonly string Field_Version = "version"; - - public static readonly string Field_GlobalBpm = "global_bpm"; - public static readonly string Field_StartTimeOffset = "start_time_offset"; - public static readonly string Field_GlobalGridPerSignature = "global_grid_per_signature"; - public static readonly string Field_GlobalSignature = "global_signature"; - - public static readonly string Column_ID = "id"; - public static readonly string Column_Difficulty = "difficulty"; - public static readonly string Column_BarIndex = "bar_index"; - public static readonly string Column_IndexInGrid = "index_in_grid"; - public static readonly string Column_StartPosition = "start_position"; - public static readonly string Column_FinishPosition = "finish_position"; - public static readonly string Column_FlickType = "flick_type"; - public static readonly string Column_PrevFlickNoteID = "prev_flick_note_id"; - public static readonly string Column_NextFlickNoteID = "next_flick_note_id"; - public static readonly string Column_HoldTargetID = "hold_target_id"; - public static readonly string Column_GridPerSignature = "grid_per_signature"; - public static readonly string Column_Signature = "signature"; - public static readonly string Column_NoteType = "note_type"; - public static readonly string Column_ParamValues = "param_values"; - - // Legacy. Do not use. - public static readonly string Table_Scores = "scores"; - // Legacy. I made a spelling mistake in all v0.2 save files. :-( - public static readonly string Field_Vesion = "vesion"; - // Lagacy. Saved for forward compatibility - public static readonly string Column_SyncTargetID = "sync_target_id"; - - } - - } -} diff --git a/StarlightDirector/StarlightDirector.Exchange/ProjectIO.SQLiteHelper.cs b/StarlightDirector/StarlightDirector.Exchange/ProjectIO.SQLiteHelper.cs deleted file mode 100644 index d352327..0000000 --- a/StarlightDirector/StarlightDirector.Exchange/ProjectIO.SQLiteHelper.cs +++ /dev/null @@ -1,330 +0,0 @@ -using System.Collections.Specialized; -using System.Data; -using System.Data.SQLite; -using StarlightDirector.Entities; - -namespace StarlightDirector.Exchange { - static partial class ProjectIO { - - private static class SQLiteHelper { - - public static bool DoesTableExist(SQLiteTransaction transaction, string tableName) { - return DoesTableExist(transaction.Connection, tableName); - } - - public static bool DoesTableExist(SQLiteConnection connection, string tableName) { - using (var command = connection.CreateCommand()) { - command.CommandText = "SELECT name FROM sqlite_master WHERE type = 'table' AND name = @tableName;"; - command.Parameters.Add("tableName", DbType.AnsiString).Value = tableName; - var value = command.ExecuteScalar(); - return value != null; - } - } - - public static bool DoesColumnExist(SQLiteTransaction transaction, string tableName, string columnName) { - return DoesColumnExist(transaction.Connection, tableName, columnName); - } - - public static bool DoesColumnExist(SQLiteConnection connection, string tableName, string columnName) { - using (var command = connection.CreateCommand()) { - command.CommandText = "SELECT name FROM sqlite_master WHERE type = 'table' AND name = @tableName;"; - command.Parameters.Add("tableName", DbType.AnsiString).Value = tableName; - var value = command.ExecuteScalar(); - if (value == null) { - return false; - } - // TODO: Is it possible to use command parameters? - command.CommandText = $"PRAGMA table_info('{tableName}');"; - command.Parameters.RemoveAt("tableName"); - using (var reader = command.ExecuteReader()) { - while (reader.NextResult()) { - while (reader.Read()) { - var ordinal = reader.GetOrdinal("name"); - value = reader.GetValue(ordinal); - if ((string)value == columnName) { - return true; - } - } - } - } - } - return false; - } - - public static void SetValue(SQLiteTransaction transaction, string tableName, string key, string value, bool creatingNewDatabase, ref SQLiteCommand command) { - SetValue(transaction.Connection, tableName, key, value, creatingNewDatabase, ref command); - } - - public static void SetValue(SQLiteConnection connection, string tableName, string key, string value, bool creatingNewDatabase, ref SQLiteCommand command) { - if (creatingNewDatabase) { - InsertValue(connection, tableName, key, value, ref command); - } else { - UpdateValue(connection, tableName, key, value, ref command); - } - } - - public static void InsertValue(SQLiteTransaction transaction, string tableName, string key, string value, ref SQLiteCommand command) { - InsertValue(transaction.Connection, tableName, key, value, ref command); - } - - public static void InsertValue(SQLiteConnection connection, string tableName, string key, string value, ref SQLiteCommand command) { - if (command == null) { - command = connection.CreateCommand(); - command.CommandText = $"INSERT INTO {tableName} (key, value) VALUES (@key, @value);"; - command.Parameters.Add("key", DbType.AnsiString).Value = key; - command.Parameters.Add("value", DbType.AnsiString).Value = value; - } else { - command.CommandText = $"INSERT INTO {tableName} (key, value) VALUES (@key, @value);"; - command.Parameters["key"].Value = key; - command.Parameters["value"].Value = value; - } - command.ExecuteNonQuery(); - } - - public static void UpdateValue(SQLiteTransaction transaction, string tableName, string key, string value, ref SQLiteCommand command) { - UpdateValue(transaction.Connection, tableName, key, value, ref command); - } - - public static void UpdateValue(SQLiteConnection connection, string tableName, string key, string value, ref SQLiteCommand command) { - if (command == null) { - command = connection.CreateCommand(); - command.CommandText = $"UPDATE {tableName} SET value = @value WHERE key = @key;"; - command.Parameters.Add("key", DbType.AnsiString).Value = key; - command.Parameters.Add("value", DbType.AnsiString).Value = value; - } else { - command.CommandText = $"UPDATE {tableName} SET value = @value WHERE key = @key;"; - command.Parameters["key"].Value = key; - command.Parameters["value"].Value = value; - } - command.ExecuteNonQuery(); - } - - public static string GetValue(SQLiteTransaction transaction, string tableName, string key, ref SQLiteCommand command) { - return GetValue(transaction.Connection, tableName, key, ref command); - } - - public static string GetValue(SQLiteConnection connection, string tableName, string key, ref SQLiteCommand command) { - if (command == null) { - command = connection.CreateCommand(); - command.CommandText = $"SELECT value FROM {tableName} WHERE key = @key;"; - command.Parameters.Add("key", DbType.AnsiString).Value = key; - } else { - command.CommandText = $"SELECT value FROM {tableName} WHERE key = @key;"; - command.Parameters["key"].Value = key; - } - var value = command.ExecuteScalar(); - return (string)value; - } - - public static StringDictionary GetValues(SQLiteTransaction transaction, string tableName, ref SQLiteCommand command) { - return GetValues(transaction.Connection, tableName, ref command); - } - - public static StringDictionary GetValues(SQLiteConnection connection, string tableName, ref SQLiteCommand command) { - if (command == null) { - command = connection.CreateCommand(); - } - command.CommandText = $"SELECT key, value FROM {tableName};"; - var result = new StringDictionary(); - using (var reader = command.ExecuteReader()) { - while (reader.Read()) { - var row = reader.GetValues(); - result.Add(row[0], row[1]); - } - } - return result; - } - - public static void CreateKeyValueTable(SQLiteTransaction transaction, string tableName) { - CreateKeyValueTable(transaction.Connection, tableName); - } - - public static void CreateKeyValueTable(SQLiteConnection connection, string tableName) { - using (var command = connection.CreateCommand()) { - // Have to use LONGTEXT (2^31-1) rather than TEXT (32768). - command.CommandText = $"CREATE TABLE {tableName} (key LONGTEXT PRIMARY KEY NOT NULL, value LONGTEXT NOT NULL);"; - command.ExecuteNonQuery(); - } - } - - public static void CreateBarParamsTable(SQLiteTransaction transaction) { - CreateBarParamsTable(transaction.Connection); - } - - public static void CreateBarParamsTable(SQLiteConnection connection) { - using (var command = connection.CreateCommand()) { - command.CommandText = $@"CREATE TABLE {Names.Table_BarParams} ( -{Names.Column_Difficulty} INTEGER NOT NULL, {Names.Column_BarIndex} INTEGER NOT NULL, {Names.Column_GridPerSignature} INTEGER, {Names.Column_Signature} INTEGER, -PRIMARY KEY ({Names.Column_Difficulty}, {Names.Column_BarIndex}));"; - command.ExecuteNonQuery(); - } - } - - public static void CreateSpecialNotesTable(SQLiteTransaction transaction) { - CreateSpecialNotesTable(transaction.Connection); - } - - public static void CreateSpecialNotesTable(SQLiteConnection connection) { - using (var command = connection.CreateCommand()) { - command.CommandText = $@"CREATE TABLE {Names.Table_SpecialNotes} ( -{Names.Column_ID} INTEGER NOT NULL PRIMARY KEY, {Names.Column_Difficulty} INTEGER NOT NULL, {Names.Column_BarIndex} INTEGER NOT NULL, {Names.Column_IndexInGrid} INTEGER NOT NULL, -{Names.Column_NoteType} INTEGER NOT NULL, {Names.Column_ParamValues} TEXT NOT NULL, -FOREIGN KEY ({Names.Column_ID}) REFERENCES {Names.Table_NoteIDs}({Names.Column_ID}));"; - command.ExecuteNonQuery(); - } - } - - public static void CreateScoresTable(SQLiteTransaction transaction) { - CreateScoresTable(transaction.Connection); - } - - public static void CreateScoresTable(SQLiteConnection connection) { - using (var command = connection.CreateCommand()) { - command.CommandText = $"CREATE TABLE {Names.Table_NoteIDs} ({Names.Column_ID} INTEGER NOT NULL PRIMARY KEY);"; - command.ExecuteNonQuery(); - command.CommandText = $@"CREATE TABLE {Names.Table_Notes} ( -{Names.Column_ID} INTEGER PRIMARY KEY NOT NULL, {Names.Column_Difficulty} INTEGER NOT NULL, {Names.Column_BarIndex} INTEGER NOT NULL, {Names.Column_IndexInGrid} INTEGER NOT NULL, -{Names.Column_NoteType} INTEGER NOT NULL, {Names.Column_StartPosition} INTEGER NOT NULL, {Names.Column_FinishPosition} INTEGER NOT NULL, {Names.Column_FlickType} INTEGER NOT NULL, -{Names.Column_PrevFlickNoteID} INTEGER NOT NULL, {Names.Column_NextFlickNoteID} NOT NULL, {Names.Column_SyncTargetID} INTEGER NOT NULL, {Names.Column_HoldTargetID} INTEGER NOT NULL, -FOREIGN KEY ({Names.Column_ID}) REFERENCES {Names.Table_NoteIDs}({Names.Column_ID}), FOREIGN KEY ({Names.Column_PrevFlickNoteID}) REFERENCES {Names.Table_NoteIDs}({Names.Column_ID}), -FOREIGN KEY ({Names.Column_NextFlickNoteID}) REFERENCES {Names.Table_NoteIDs}({Names.Column_ID}), FOREIGN KEY ({Names.Column_SyncTargetID}) REFERENCES {Names.Table_NoteIDs}({Names.Column_ID}), -FOREIGN KEY ({Names.Column_HoldTargetID}) REFERENCES {Names.Table_NoteIDs}({Names.Column_ID}));"; - command.ExecuteNonQuery(); - } - } - - public static void InsertNoteID(SQLiteTransaction transaction, int id, ref SQLiteCommand command) { - InsertNoteID(transaction.Connection, id, ref command); - } - - public static void InsertNoteID(SQLiteConnection connection, int id, ref SQLiteCommand command) { - if (command == null) { - command = connection.CreateCommand(); - command.CommandText = $"INSERT INTO {Names.Table_NoteIDs} ({Names.Column_ID}) VALUES (@id);"; - command.Parameters.Add("id", DbType.Int32); - } - command.Parameters["id"].Value = id; - command.ExecuteNonQuery(); - } - - public static void InsertNote(SQLiteTransaction transaction, Note note, ref SQLiteCommand command) { - InsertNote(transaction.Connection, note, ref command); - } - - public static void InsertNote(SQLiteConnection connection, Note note, ref SQLiteCommand command) { - if (command == null) { - command = connection.CreateCommand(); - command.CommandText = $@"INSERT INTO {Names.Table_Notes} ( -{Names.Column_ID}, {Names.Column_Difficulty}, {Names.Column_BarIndex}, {Names.Column_IndexInGrid}, {Names.Column_NoteType}, {Names.Column_StartPosition}, {Names.Column_FinishPosition}, -{Names.Column_FlickType}, {Names.Column_PrevFlickNoteID}, {Names.Column_NextFlickNoteID}, {Names.Column_SyncTargetID}, {Names.Column_HoldTargetID} -) VALUES (@id, @difficulty, @bar, @grid, @note_type, @start, @finish, @flick, @prev_flick, @next_flick, @sync, @hold);"; - command.Parameters.Add("id", DbType.Int32); - command.Parameters.Add("difficulty", DbType.Int32); - command.Parameters.Add("bar", DbType.Int32); - command.Parameters.Add("grid", DbType.Int32); - command.Parameters.Add("note_type", DbType.Int32); - command.Parameters.Add("start", DbType.Int32); - command.Parameters.Add("finish", DbType.Int32); - command.Parameters.Add("flick", DbType.Int32); - command.Parameters.Add("prev_flick", DbType.Int32); - command.Parameters.Add("next_flick", DbType.Int32); - command.Parameters.Add("sync", DbType.Int32); - command.Parameters.Add("hold", DbType.Int32); - } - command.Parameters["id"].Value = note.ID; - command.Parameters["difficulty"].Value = note.Bar.Score.Difficulty; - command.Parameters["bar"].Value = note.Bar.Index; - command.Parameters["grid"].Value = note.IndexInGrid; - command.Parameters["note_type"].Value = (int)note.Type; - command.Parameters["start"].Value = (int)note.StartPosition; - command.Parameters["finish"].Value = (int)note.FinishPosition; - command.Parameters["flick"].Value = (int)note.FlickType; - command.Parameters["prev_flick"].Value = note.PrevFlickOrSlideNoteID; - command.Parameters["next_flick"].Value = note.NextFlickOrSlideNoteID; - command.Parameters["sync"].Value = note.SyncTargetID; - command.Parameters["hold"].Value = note.HoldTargetID; - command.ExecuteNonQuery(); - } - - public static void InsertBarParams(SQLiteTransaction transaction, Bar bar, ref SQLiteCommand command) { - InsertBarParams(transaction.Connection, bar, ref command); - } - - public static void InsertBarParams(SQLiteConnection connection, Bar bar, ref SQLiteCommand command) { - if (bar.Params == null) { - return; - } - if (command == null) { - command = connection.CreateCommand(); - command.CommandText = $"INSERT INTO {Names.Table_BarParams} ({Names.Column_Difficulty}, {Names.Column_BarIndex}, {Names.Column_GridPerSignature}, {Names.Column_Signature}) VALUES (@difficulty, @index, @grid, @signature);"; - command.Parameters.Add("difficulty", DbType.Int32); - command.Parameters.Add("index", DbType.Int32); - command.Parameters.Add("grid", DbType.Int32); - command.Parameters.Add("signature", DbType.Int32); - } - command.Parameters["difficulty"].Value = (int)bar.Score.Difficulty; - command.Parameters["index"].Value = bar.Index; - command.Parameters["grid"].Value = bar.Params.UserDefinedGridPerSignature; - command.Parameters["signature"].Value = bar.Params.UserDefinedSignature; - command.ExecuteNonQuery(); - } - - public static void InsertSpecialNote(SQLiteTransaction transaction, Note note, ref SQLiteCommand command) { - InsertSpecialNote(transaction.Connection, note, ref command); - } - - public static void InsertSpecialNote(SQLiteConnection connection, Note note, ref SQLiteCommand command) { - if (command == null) { - command = connection.CreateCommand(); - command.CommandText = $"INSERT INTO {Names.Table_SpecialNotes} ({Names.Column_ID}, {Names.Column_Difficulty}, {Names.Column_BarIndex}, {Names.Column_IndexInGrid}, {Names.Column_NoteType}, {Names.Column_ParamValues}) VALUES (@id, @diff, @bar, @grid, @type, @pv);"; - command.Parameters.Add("id", DbType.Int32); - command.Parameters.Add("diff", DbType.Int32); - command.Parameters.Add("bar", DbType.Int32); - command.Parameters.Add("grid", DbType.Int32); - command.Parameters.Add("type", DbType.Int32); - // Parameter values - command.Parameters.Add("pv", DbType.AnsiString); - } - command.Parameters["id"].Value = note.ID; - command.Parameters["diff"].Value = note.Bar.Score.Difficulty; - command.Parameters["bar"].Value = note.Bar.Index; - command.Parameters["grid"].Value = note.IndexInGrid; - command.Parameters["type"].Value = (int)note.Type; - command.Parameters["pv"].Value = note.ExtraParams.GetDataString(); - command.ExecuteNonQuery(); - } - - public static void ReadNotesTable(SQLiteConnection connection, Difficulty difficulty, DataTable table) { - using (var command = connection.CreateCommand()) { - command.CommandText = $"SELECT * FROM {Names.Table_Notes} WHERE {Names.Column_Difficulty} = @difficulty;"; - command.Parameters.Add("difficulty", DbType.Int32).Value = (int)difficulty; - using (var adapter = new SQLiteDataAdapter(command)) { - adapter.Fill(table); - } - } - } - - public static void ReadBarParamsTable(SQLiteConnection connection, Difficulty difficulty, DataTable dataTable) { - using (var command = connection.CreateCommand()) { - command.CommandText = $"SELECT * FROM {Names.Table_BarParams} WHERE {Names.Column_Difficulty} = @difficulty;"; - command.Parameters.Add("difficulty", DbType.Int32).Value = (int)difficulty; - using (var adapter = new SQLiteDataAdapter(command)) { - adapter.Fill(dataTable); - } - } - } - - public static void ReadSpecialNotesTable(SQLiteConnection connection, Difficulty difficulty, DataTable dataTable) { - using (var command = connection.CreateCommand()) { - command.CommandText = $"SELECT * FROM {Names.Table_SpecialNotes} WHERE {Names.Column_Difficulty} = @difficulty;"; - command.Parameters.Add("difficulty", DbType.Int32).Value = (int)difficulty; - using (var adapter = new SQLiteDataAdapter(command)) { - adapter.Fill(dataTable); - } - } - } - - } - - } -} diff --git a/StarlightDirector/StarlightDirector.Exchange/ProjectIO.cs b/StarlightDirector/StarlightDirector.Exchange/ProjectIO.cs deleted file mode 100644 index 6c04f45..0000000 --- a/StarlightDirector/StarlightDirector.Exchange/ProjectIO.cs +++ /dev/null @@ -1,371 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.SQLite; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Linq; -using StarlightDirector.Entities; - -namespace StarlightDirector.Exchange { - public static partial class ProjectIO { - - public static void Save(Project project) { - Save(project, project.SaveFileName); - } - - public static void Save(Project project, string fileName) { - var fileInfo = new FileInfo(fileName); - var newDatabase = !fileInfo.Exists; - Save(project, fileName, newDatabase, false); - } - - public static void SaveAsBackup(Project project, string fileName) { - Save(project, fileName, true, true); - } - - public static Project Load(string fileName) { - var version = CheckProjectFileVersion(fileName); - return Load(fileName, version); - } - - internal static Project Load(string fileName, int versionOverride) { - Project project = null; - switch (versionOverride) { - case ProjectVersion.Unknown: - throw new ArgumentOutOfRangeException(nameof(versionOverride)); - case ProjectVersion.V0_1: - project = LoadFromV01(fileName); - break; - case ProjectVersion.V0_2: - project = LoadFromV02(fileName); - break; - case ProjectVersion.V0_3: - // Note (2017-Feb-28): - // Slide note is added to CGSS a month before. SLDPROJ format v0.3.1 uses the "prev_flick" and "next_flick" fields to - // store slide notes relation info, because slide and flick notes have similar behaviors and they can be distinguished - // by the "type" field. So v0.3.1 is a super set of v0.3. The exceptions are handled in ReadScore() (see below). - break; - } - - if (project == null) - project = LoadFromV03x(fileName); - - // Update bar timings, sort notes - foreach (var difficulty in Difficulties) { - var score = project.GetScore(difficulty); - foreach (var bar in score.Bars) { - bar.UpdateTimings(); - bar.Notes.Sort(Note.TimingThenPositionComparison); - } - - score.Notes.Sort(Note.TimingThenPositionComparison); - } - - return project; - } - - private static void Save(Project project, string fileName, bool createNewDatabase, bool isBackup) { - var fileInfo = new FileInfo(fileName); - fileName = fileInfo.FullName; - if (createNewDatabase) { - SQLiteConnection.CreateFile(fileName); - } else { - File.Delete(fileName); - } - var builder = new SQLiteConnectionStringBuilder(); - builder.DataSource = fileName; - using (var connection = new SQLiteConnection(builder.ToString())) { - connection.Open(); - SQLiteCommand setValue = null, insertNote = null, insertNoteID = null, insertBarParams = null, insertSpecialNote = null; - - using (var transaction = connection.BeginTransaction()) { - // Table structure - SQLiteHelper.CreateKeyValueTable(transaction, Names.Table_Main); - SQLiteHelper.CreateScoresTable(transaction); - SQLiteHelper.CreateKeyValueTable(transaction, Names.Table_ScoreSettings); - SQLiteHelper.CreateKeyValueTable(transaction, Names.Table_Metadata); - SQLiteHelper.CreateBarParamsTable(transaction); - SQLiteHelper.CreateSpecialNotesTable(transaction); - - // Main - SQLiteHelper.InsertValue(transaction, Names.Table_Main, Names.Field_MusicFileName, project.MusicFileName ?? string.Empty, ref setValue); - SQLiteHelper.InsertValue(transaction, Names.Table_Main, Names.Field_Version, project.Version, ref setValue); - - // Notes - SQLiteHelper.InsertNoteID(transaction, EntityID.Invalid, ref insertNoteID); - foreach (var difficulty in Difficulties) { - var score = project.GetScore(difficulty); - foreach (var note in score.Notes) { - if (note.IsGamingNote) { - SQLiteHelper.InsertNoteID(transaction, note.ID, ref insertNoteID); - } - } - } - foreach (var difficulty in Difficulties) { - var score = project.GetScore(difficulty); - foreach (var note in score.Notes) { - if (note.IsGamingNote) { - SQLiteHelper.InsertNote(transaction, note, ref insertNote); - } - } - } - - // Score settings - var settings = project.Settings; - SQLiteHelper.InsertValue(transaction, Names.Table_ScoreSettings, Names.Field_GlobalBpm, settings.GlobalBpm.ToString(CultureInfo.InvariantCulture), ref setValue); - SQLiteHelper.InsertValue(transaction, Names.Table_ScoreSettings, Names.Field_StartTimeOffset, settings.StartTimeOffset.ToString(CultureInfo.InvariantCulture), ref setValue); - SQLiteHelper.InsertValue(transaction, Names.Table_ScoreSettings, Names.Field_GlobalGridPerSignature, settings.GlobalGridPerSignature.ToString(), ref setValue); - SQLiteHelper.InsertValue(transaction, Names.Table_ScoreSettings, Names.Field_GlobalSignature, settings.GlobalSignature.ToString(), ref setValue); - - // Bar params && Special notes - foreach (var difficulty in Difficulties) { - var score = project.GetScore(difficulty); - foreach (var bar in score.Bars) { - if (bar.Params != null) { - SQLiteHelper.InsertBarParams(transaction, bar, ref insertBarParams); - } - } - foreach (var note in score.Notes.Where(note => !note.IsGamingNote)) { - SQLiteHelper.InsertNoteID(transaction, note.ID, ref insertNoteID); - SQLiteHelper.InsertSpecialNote(transaction, note, ref insertSpecialNote); - } - } - - // Metadata (none for now) - - // Commit! - transaction.Commit(); - } - - // Cleanup - insertNoteID?.Dispose(); - insertNote?.Dispose(); - setValue?.Dispose(); - connection.Close(); - } - if (!isBackup) { - project.SaveFileName = fileName; - project.IsChanged = false; - } - } - - private static Project LoadFromV03x(string fileName) { - var fileInfo = new FileInfo(fileName); - if (!fileInfo.Exists) { - throw new FileNotFoundException(string.Empty, fileName); - } - fileName = fileInfo.FullName; - var project = new Project { - IsChanged = false, - SaveFileName = fileName - }; - var builder = new SQLiteConnectionStringBuilder(); - builder.DataSource = fileName; - using (var connection = new SQLiteConnection(builder.ToString())) { - connection.Open(); - SQLiteCommand getValues = null; - - // Main - var mainValues = SQLiteHelper.GetValues(connection, Names.Table_Main, ref getValues); - project.MusicFileName = mainValues[Names.Field_MusicFileName]; - var projectVersionString = mainValues[Names.Field_Version]; - float fProjectVersion; - float.TryParse(projectVersionString, out fProjectVersion); - if (fProjectVersion <= 0) { - Debug.Print("WARNING: incorrect project version: {0}", projectVersionString); - fProjectVersion = ProjectVersion.Current; - } - if (fProjectVersion < 1) { - fProjectVersion *= 1000; - } - var projectVersion = (int)fProjectVersion; - // Keep project.Version property having the newest project version. - - // Scores - foreach (var difficulty in Difficulties) { - var score = new Score(project, difficulty); - ReadScore(connection, score, projectVersion); - score.ResolveReferences(project); - score.FixSyncNotes(); - score.Difficulty = difficulty; - project.Scores.Add(difficulty, score); - } - - // Score settings - var scoreSettingsValues = SQLiteHelper.GetValues(connection, Names.Table_ScoreSettings, ref getValues); - var settings = project.Settings; - settings.GlobalBpm = double.Parse(scoreSettingsValues[Names.Field_GlobalBpm]); - settings.StartTimeOffset = double.Parse(scoreSettingsValues[Names.Field_StartTimeOffset]); - settings.GlobalGridPerSignature = int.Parse(scoreSettingsValues[Names.Field_GlobalGridPerSignature]); - settings.GlobalSignature = int.Parse(scoreSettingsValues[Names.Field_GlobalSignature]); - - // Bar params - if (SQLiteHelper.DoesTableExist(connection, Names.Table_BarParams)) { - foreach (var difficulty in Difficulties) { - var score = project.GetScore(difficulty); - ReadBarParams(connection, score); - } - } - - // Special notes - if (SQLiteHelper.DoesTableExist(connection, Names.Table_SpecialNotes)) { - foreach (var difficulty in Difficulties) { - var score = project.GetScore(difficulty); - ReadSpecialNotes(connection, score); - } - } - - // Metadata (none for now) - - // Cleanup - getValues.Dispose(); - connection.Close(); - } - - GridLineFixup(project); - return project; - } - - private static void GridLineFixup(Project project) { - // Signature fix-up - var newGrids = ScoreSettings.DefaultGlobalGridPerSignature * ScoreSettings.DefaultGlobalSignature; - var oldGrids = project.Settings.GlobalGridPerSignature * project.Settings.GlobalSignature; - if (newGrids == oldGrids) { - return; - } - project.Settings.GlobalGridPerSignature = ScoreSettings.DefaultGlobalGridPerSignature; - project.Settings.GlobalSignature = ScoreSettings.DefaultGlobalSignature; - if (newGrids % oldGrids == 0) { - // Expanding (e.g. 48 -> 96) - var k = newGrids / oldGrids; - foreach (var difficulty in Difficulties) { - if (!project.Scores.ContainsKey(difficulty)) { - continue; - } - var score = project.GetScore(difficulty); - foreach (var note in score.Notes) { - note.SetIndexInGridWithoutSorting(note.IndexInGrid * k); - } - } - } else if (oldGrids % newGrids == 0) { - // Shrinking (e.g. 384 -> 96) - var k = oldGrids / newGrids; - var incompatibleNotes = new List(); - foreach (var difficulty in Difficulties) { - if (!project.Scores.ContainsKey(difficulty)) { - continue; - } - var score = project.GetScore(difficulty); - foreach (var note in score.Notes) { - if (note.IndexInGrid % k != 0) { - incompatibleNotes.Add(note); - } else { - note.SetIndexInGridWithoutSorting(note.IndexInGrid / k); - } - } - } - if (incompatibleNotes.Count > 0) { - Debug.Print("Notes on incompatible grid lines are found. Removing."); - foreach (var note in incompatibleNotes) { - note.Bar.RemoveNote(note); - } - } - } - } - - private static void ReadScore(SQLiteConnection connection, Score score, int projectVersion) { - using (var table = new DataTable()) { - SQLiteHelper.ReadNotesTable(connection, score.Difficulty, table); - // v0.3.1: "note_type" - // Only flick existed when there is a flick-alike relation. Now, both flick and slide are possible. - var hasNoteTypeColumn = projectVersion >= ProjectVersion.V0_3_1; - foreach (DataRow row in table.Rows) { - var id = (int)(long)row[Names.Column_ID]; - var barIndex = (int)(long)row[Names.Column_BarIndex]; - var grid = (int)(long)row[Names.Column_IndexInGrid]; - var start = (NotePosition)(long)row[Names.Column_StartPosition]; - var finish = (NotePosition)(long)row[Names.Column_FinishPosition]; - var flick = (NoteFlickType)(long)row[Names.Column_FlickType]; - var prevFlick = (int)(long)row[Names.Column_PrevFlickNoteID]; - var nextFlick = (int)(long)row[Names.Column_NextFlickNoteID]; - var hold = (int)(long)row[Names.Column_HoldTargetID]; - var noteType = hasNoteTypeColumn ? (NoteType)(long)row[Names.Column_NoteType] : NoteType.TapOrFlick; - - EnsureBarIndex(score, barIndex); - var bar = score.Bars[barIndex]; - var note = bar.AddNoteWithoutUpdatingGlobalNotes(id); - if (note != null) { - note.IndexInGrid = grid; - note.StartPosition = start; - note.FinishPosition = finish; - note.Type = noteType; - note.FlickType = flick; - note.PrevFlickOrSlideNoteID = prevFlick; - note.NextFlickOrSlideNoteID = nextFlick; - note.HoldTargetID = hold; - } else { - Debug.Print("Note with ID '{0}' already exists.", id); - } - } - } - } - - private static void ReadBarParams(SQLiteConnection connection, Score score) { - using (var table = new DataTable()) { - SQLiteHelper.ReadBarParamsTable(connection, score.Difficulty, table); - foreach (DataRow row in table.Rows) { - var index = (int)(long)row[Names.Column_BarIndex]; - var grid = (int?)(long?)row[Names.Column_GridPerSignature]; - var signature = (int?)(long?)row[Names.Column_Signature]; - if (index < score.Bars.Count) { - score.Bars[index].Params = new BarParams { - UserDefinedGridPerSignature = grid, - UserDefinedSignature = signature - }; - } - } - } - } - - private static void ReadSpecialNotes(SQLiteConnection connection, Score score) { - using (var table = new DataTable()) { - SQLiteHelper.ReadSpecialNotesTable(connection, score.Difficulty, table); - foreach (DataRow row in table.Rows) { - var id = (int)(long)row[Names.Column_ID]; - var barIndex = (int)(long)row[Names.Column_BarIndex]; - var grid = (int)(long)row[Names.Column_IndexInGrid]; - var type = (int)(long)row[Names.Column_NoteType]; - var paramsString = (string)row[Names.Column_ParamValues]; - if (barIndex < score.Bars.Count) { - var bar = score.Bars[barIndex]; - // Special notes are not added during the ReadScores() process, so we call AddNote() rather than AddNoteWithoutUpdatingGlobalNotes(). - var note = bar.Notes.FirstOrDefault(n => n.Type == (NoteType)type && n.IndexInGrid == grid); - if (note == null) { - note = bar.AddNote(id); - note.SetSpecialType((NoteType)type); - note.IndexInGrid = grid; - note.ExtraParams = NoteExtraParams.FromDataString(paramsString, note); - } else { - note.ExtraParams.UpdateByDataString(paramsString); - } - } - } - } - } - - private static void EnsureBarIndex(Score score, int index) { - if (score.Bars.Count > index) { - return; - } - for (var i = score.Bars.Count; i <= index; ++i) { - var bar = new Bar(score, i); - score.Bars.Add(bar); - } - } - - private static readonly Difficulty[] Difficulties = { Difficulty.Debut, Difficulty.Regular, Difficulty.Pro, Difficulty.Master, Difficulty.MasterPlus }; - - } -} diff --git a/StarlightDirector/StarlightDirector.Exchange/Properties/AssemblyInfo.cs b/StarlightDirector/StarlightDirector.Exchange/Properties/AssemblyInfo.cs deleted file mode 100644 index fb3a1b1..0000000 --- a/StarlightDirector/StarlightDirector.Exchange/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// 有关程序集的一般信息由以下 -// 控制。更改这些特性值可修改 -// 与程序集关联的信息。 -[assembly: AssemblyTitle("StarlightDirector.Exchange")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("StarlightDirector.Exchange")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -//将 ComVisible 设置为 false 将使此程序集中的类型 -//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, -//请将此类型的 ComVisible 特性设置为 true。 -[assembly: ComVisible(false)] - -// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID -[assembly: Guid("3ecdd0bb-215a-4437-b162-fc9d9285303d")] - -// 程序集的版本信息由下列四个值组成: -// -// 主版本 -// 次版本 -// 生成号 -// 修订号 -// -//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, -// 方法是按如下所示使用“*”: : -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] - -[assembly: InternalsVisibleTo("StarlightDirector")] diff --git a/StarlightDirector/StarlightDirector.Exchange/Properties/Resources.Designer.cs b/StarlightDirector/StarlightDirector.Exchange/Properties/Resources.Designer.cs deleted file mode 100644 index a8245c2..0000000 --- a/StarlightDirector/StarlightDirector.Exchange/Properties/Resources.Designer.cs +++ /dev/null @@ -1,99 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 此代码由工具生成。 -// 运行时版本:4.0.30319.42000 -// -// 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 -// -//------------------------------------------------------------------------------ - -namespace StarlightDirector.Exchange.Properties { - using System; - - - /// - /// 一个强类型的资源类,用于查找本地化的字符串等。 - /// - // 此类是由 StronglyTypedResourceBuilder - // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 - // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen - // (以 /str 作为命令选项),或重新生成 VS 项目。 - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// 返回此类使用的缓存的 ResourceManager 实例。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StarlightDirector.Exchange.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// 使用此强类型资源类,为所有资源查找 - /// 重写当前线程的 CurrentUICulture 属性。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// 查找类似 Entry #{0}: Deleste command '{1}' is not supported yet. Ignoring this entry. 的本地化字符串。 - /// - internal static string DelesteCommandIsNotYetSupportedPromptTemplate { - get { - return ResourceManager.GetString("DelesteCommandIsNotYetSupportedPromptTemplate", resourceCulture); - } - } - - /// - /// 查找类似 Entry #{0} @ Measure #{1}: Note counts are inconsistent ({2}/{3}/{4}). Ignoring this entry. 的本地化字符串。 - /// - internal static string DelesteNoteCountInconsistentPromptTemplate { - get { - return ResourceManager.GetString("DelesteNoteCountInconsistentPromptTemplate", resourceCulture); - } - } - - /// - /// 查找类似 ERROR: Deleste beatmap format 2 is not supported. Please select a format 1 beatmap. 的本地化字符串。 - /// - internal static string DelesteTxtFormat2IsNotSupportedPrompt { - get { - return ResourceManager.GetString("DelesteTxtFormat2IsNotSupportedPrompt", resourceCulture); - } - } - - /// - /// 查找类似 Measure #{0}: Grid size {1} of current measure cannot fit in Starlight Director's grid size {2}. Ignoring some or all notes in this measure. 的本地化字符串。 - /// - internal static string DelesteUnfitGridSizePromptTemplate { - get { - return ResourceManager.GetString("DelesteUnfitGridSizePromptTemplate", resourceCulture); - } - } - } -} diff --git a/StarlightDirector/StarlightDirector.Exchange/Properties/Resources.resx b/StarlightDirector/StarlightDirector.Exchange/Properties/Resources.resx deleted file mode 100644 index f01c02e..0000000 --- a/StarlightDirector/StarlightDirector.Exchange/Properties/Resources.resx +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Entry #{0}: Deleste command '{1}' is not supported yet. Ignoring this entry. - - - Entry #{0} @ Measure #{1}: Note counts are inconsistent ({2}/{3}/{4}). Ignoring this entry. - - - ERROR: Deleste beatmap format 2 is not supported. Please select a format 1 beatmap. - - - Measure #{0}: Grid size {1} of current measure cannot fit in Starlight Director's grid size {2}. Ignoring some or all notes in this measure. - - \ No newline at end of file diff --git a/StarlightDirector/StarlightDirector.Exchange/ScoreIO.cs b/StarlightDirector/StarlightDirector.Exchange/ScoreIO.cs deleted file mode 100644 index 6dde998..0000000 --- a/StarlightDirector/StarlightDirector.Exchange/ScoreIO.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Text; -using StarlightDirector.Entities; -using StarlightDirector.Exchange.Deleste; - -namespace StarlightDirector.Exchange { - public static class ScoreIO { - - public static Score LoadFromDelesteBeatmap(Project temporaryProject, Difficulty difficulty, string fileName, out string[] warnings, out bool hasErrors) { - warnings = null; - hasErrors = false; - var encoding = DelesteHelper.TryDetectBeatmapEncoding(fileName); - using (var fileStream = File.Open(fileName, FileMode.Open, FileAccess.Read)) { - using (var streamReader = new StreamReader(fileStream, encoding, true)) { - if (streamReader.EndOfStream) { - return null; - } - var score = new Score(temporaryProject, difficulty); - var noteCache = new List(); - var entryCache = new List(); - var warningList = new List(); - var entryCounter = 0; - do { - var line = streamReader.ReadLine(); - if (line.Length == 0 || line[0] != '#') { - continue; - } - ++entryCounter; - var entry = DelesteHelper.ReadEntry(temporaryProject, line, entryCounter, noteCache, warningList, ref hasErrors); - if (hasErrors) { - warnings = warningList.ToArray(); - return null; - } - if (entry != null) { - entryCache.Add(entry); - } - } while (!streamReader.EndOfStream); - var delesteState = new DelesteState { - BPM = temporaryProject.Settings.GlobalBpm, - Signature = Constants.DefaultSignature - }; - DelesteHelper.AnalyzeBeatmap(score, entryCache, delesteState, warningList); - if (warningList.Count > 0) { - warnings = warningList.ToArray(); - } - return score; - } - } - } - - public static void ExportToDelesteBeatmap(Score score, string fileName) { - using (var fileStream = File.Open(fileName, FileMode.Create, FileAccess.Write)) { - using (var streamWriter = new StreamWriter(fileStream, Encoding.UTF8)) { - streamWriter.NewLine = Constants.NewLine; - DelesteHelper.WriteBeatmapHeader(score, streamWriter); - DelesteHelper.WriteEntries(score, streamWriter); - } - } - } - - } -} diff --git a/StarlightDirector/StarlightDirector.Exchange/StarlightDirector.Exchange.csproj b/StarlightDirector/StarlightDirector.Exchange/StarlightDirector.Exchange.csproj deleted file mode 100644 index e4a5c99..0000000 --- a/StarlightDirector/StarlightDirector.Exchange/StarlightDirector.Exchange.csproj +++ /dev/null @@ -1,128 +0,0 @@ - - - - - Debug - AnyCPU - {3ECDD0BB-215A-4437-B162-FC9D9285303D} - Library - Properties - StarlightDirector.Exchange - StarlightDirector.Exchange - v4.0 - 512 - - - - - true - bin\x64\Debug\ - DEBUG;TRACE - full - x64 - prompt - MinimumRecommendedRules.ruleset - - - bin\x64\Release\ - TRACE - true - pdbonly - x64 - prompt - MinimumRecommendedRules.ruleset - - - true - bin\x86\Debug\ - DEBUG;TRACE - full - x86 - prompt - MinimumRecommendedRules.ruleset - - - bin\x86\Release\ - TRACE - true - pdbonly - x86 - prompt - MinimumRecommendedRules.ruleset - - - - - - - - - - - - - - - - - - - True - True - Resources.resx - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - - {DBD0DA4A-0057-4D04-AD69-0E7267D72793} - DereTore.Common - - - {7FB2A631-88C4-4C6B-9E8B-8EEEB40575D0} - StarlightDirector.Core - - - {D78A4080-34F4-45EC-A8EF-87F95815E3BD} - StarlightDirector.Entities - - - - - ..\..\packages\Newtonsoft.Json.9.0.1\lib\net40\Newtonsoft.Json.dll - True - - - - - ..\..\packages\System.Data.SQLite.Core.1.0.104.0\lib\net40\System.Data.SQLite.dll - True - - - - - - - - - - - - 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 - - - - - \ No newline at end of file diff --git a/StarlightDirector/StarlightDirector.Exchange/packages.config b/StarlightDirector/StarlightDirector.Exchange/packages.config deleted file mode 100644 index e96307f..0000000 --- a/StarlightDirector/StarlightDirector.Exchange/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/StarlightDirector/StarlightDirector/App.DirectorPath.cs b/StarlightDirector/StarlightDirector/App.DirectorPath.cs deleted file mode 100644 index 160f0d1..0000000 --- a/StarlightDirector/StarlightDirector/App.DirectorPath.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace StarlightDirector { - partial class App { - - public enum DirectorPath { - - AutoBackup - - } - - } -} diff --git a/StarlightDirector/StarlightDirector/App.xaml b/StarlightDirector/StarlightDirector/App.xaml deleted file mode 100644 index f1d153b..0000000 --- a/StarlightDirector/StarlightDirector/App.xaml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/StarlightDirector/StarlightDirector/App.xaml.cs b/StarlightDirector/StarlightDirector/App.xaml.cs deleted file mode 100644 index 4874b76..0000000 --- a/StarlightDirector/StarlightDirector/App.xaml.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.IO; -using System.Threading; -using System.Windows; -using System.Windows.Threading; -using StarlightDirector.Entities; -using StarlightDirector.Extensions; - -namespace StarlightDirector { - public partial class App { - - public static readonly ResourceKeys ResourceKeys = new ResourceKeys(); - - public static string Title => "Starlight Director"; - - public static string LocalDataDirectory { - get { - if (_localDataDirectory != null) { - return _localDataDirectory; - } - var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), LocalDataDirectoryName); - _localDataDirectory = path; - return _localDataDirectory; - } - } - - public static string GetDirectoryPath(DirectorPath path) { - switch (path) { - case DirectorPath.AutoBackup: - return Path.Combine(LocalDataDirectory, "AutoBackup"); - default: - throw new ArgumentOutOfRangeException(nameof(path), path, null); - } - } - - private void App_OnStartup(object sender, StartupEventArgs e) { - bool createdNewMutex; - var mutex = new Mutex(true, DirectorMutexName, out createdNewMutex); - if (!createdNewMutex) { - MessageBox.Show(Application.Current.FindResource(ResourceKeys.ApplicationIsAlreadyRunningPrompt), Title, MessageBoxButton.OK, MessageBoxImage.Exclamation); - Shutdown(); - } - _singleInstanceMutex = mutex; - Project.Current = new Project(); - } - - private void App_OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { - var message = e.Exception.Message + Environment.NewLine + e.Exception.StackTrace; - MessageBox.Show(message, Title, MessageBoxButton.OK, MessageBoxImage.Error); - // No need to set e.Handled. - } - - private void App_OnExit(object sender, ExitEventArgs e) { - if (_singleInstanceMutex != null) { - _singleInstanceMutex.Dispose(); - _singleInstanceMutex = null; - } - } - - private Mutex _singleInstanceMutex; - - private static readonly string DirectorMutexName = "StarlightDirector"; - - private static readonly string LocalDataDirectoryName = "StarlightDirector"; - - private static string _localDataDirectory; - - } -} diff --git a/StarlightDirector/StarlightDirector/CommandHelper.cs b/StarlightDirector/StarlightDirector/CommandHelper.cs deleted file mode 100644 index 9d1356e..0000000 --- a/StarlightDirector/StarlightDirector/CommandHelper.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using System.Linq; -using System.Reflection; -using System.Windows; -using System.Windows.Input; -using StarlightDirector.UI.Windows; - -namespace StarlightDirector { - public static class CommandHelper { - - public static RoutedCommand RegisterCommand(params string[] gestures) { - var command = new RoutedCommand(Guid.NewGuid().ToString(), typeof(MainWindow)); - if (gestures.Length <= 0) { - return command; - } - foreach (var gesture in gestures) { - Key key; - var modifierKeys = ModifierKeys.None; - var parts = gesture.Split('+'); - if (parts.Length > 1) { - foreach (var part in parts.Take(parts.Length - 1)) { - var lowerCasePart = part.ToLowerInvariant(); - switch (lowerCasePart) { - case "ctrl": - modifierKeys |= ModifierKeys.Control; - break; - case "win": - modifierKeys |= ModifierKeys.Windows; - break; - default: - var mod = (ModifierKeys)Enum.Parse(typeof(ModifierKeys), lowerCasePart, true); - modifierKeys |= mod; - break; - } - } - } - var lastPart = parts[parts.Length - 1]; - uint dummy; - if (uint.TryParse(lastPart, out dummy) && dummy <= 9) { - key = (Key)((int)Key.D0 + dummy); - } else { - key = (Key)Enum.Parse(typeof(Key), lastPart, true); - } - command.InputGestures.Add(new KeyGesture(key, modifierKeys)); - } - return command; - } - - public static void InitializeCommandBindings(FrameworkElement element) { - var cb = element.CommandBindings; - - var thisType = element.GetType(); - var icommandType = typeof(ICommand); - var commandFields = thisType.GetFields(BindingFlags.Static | BindingFlags.Public); - foreach (var commandField in commandFields) { - if (commandField.FieldType != icommandType && !commandField.FieldType.IsSubclassOf(icommandType)) { - continue; - } - var command = (ICommand)commandField.GetValue(null); - var name = commandField.Name; - var executedHandlerInfo = thisType.GetMethod(name + "_Executed", BindingFlags.NonPublic | BindingFlags.Instance); - var executedHandler = (ExecutedRoutedEventHandler)Delegate.CreateDelegate(typeof(ExecutedRoutedEventHandler), element, executedHandlerInfo); - var canExecuteHandlerInfo = thisType.GetMethod(name + "_CanExecute", BindingFlags.NonPublic | BindingFlags.Instance); - var canExecuteHandler = (CanExecuteRoutedEventHandler)Delegate.CreateDelegate(typeof(CanExecuteRoutedEventHandler), element, canExecuteHandlerInfo); - cb.Add(new CommandBinding(command, executedHandler, canExecuteHandler)); - } - } - - } -} diff --git a/StarlightDirector/StarlightDirector/Extensions/ApplicationExtensions.cs b/StarlightDirector/StarlightDirector/Extensions/ApplicationExtensions.cs deleted file mode 100644 index 8d5cd9c..0000000 --- a/StarlightDirector/StarlightDirector/Extensions/ApplicationExtensions.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Windows; - -namespace StarlightDirector.Extensions { - public static class ApplicationExtensions { - - public static T FindResource(this Application application, string key) { - return (T)application.FindResource(key); - } - - public static T TryFindResource(this Application application, string key) where T : class { - return application.TryFindResource(key) as T; - } - - } -} diff --git a/StarlightDirector/StarlightDirector/Extensions/CommandExtensions.cs b/StarlightDirector/StarlightDirector/Extensions/CommandExtensions.cs deleted file mode 100644 index 13f4a9a..0000000 --- a/StarlightDirector/StarlightDirector/Extensions/CommandExtensions.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Windows.Input; - -namespace StarlightDirector.Extensions { - public static class CommandExtensions { - - public static void RaiseCanExecuteChanged(this T command) where T : ICommand { - //var type = typeof(T); - //var ev = type.GetEvent("CanExecute"); - //var method = ev?.GetRaiseMethod(true); - //method?.Invoke(command, NullObjects); - // TODO: This method is quite "heavy". It causes all commands to reevaluate their CanExecute status. - CommandManager.InvalidateRequerySuggested(); - } - - //private static readonly object[] NullObjects = new object[0]; - - } -} diff --git a/StarlightDirector/StarlightDirector/Extensions/ComparisonExtensions.cs b/StarlightDirector/StarlightDirector/Extensions/ComparisonExtensions.cs deleted file mode 100644 index e1ff36b..0000000 --- a/StarlightDirector/StarlightDirector/Extensions/ComparisonExtensions.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace StarlightDirector.Extensions { - public static class ComparisonExtensions { - - public static ComparisonChain Then(this Comparison comparison, Comparison anotherComparison) { - var t = new ComparisonChain(); - t.Add(comparison); - t.Add(anotherComparison); - return t; - } - - public static ComparisonChain Then(this ComparisonChain comparisonChain, Comparison comparison) { - comparisonChain.Add(comparison); - return comparisonChain; - } - - public sealed class ComparisonChain { - - public Comparison Comparison => Compare; - - internal void Add(Comparison comparison) { - _comparisons.Add(comparison); - } - - private int Compare(T x, T y) { - var value = 0; - foreach (var comparison in _comparisons) { - if (comparison != null) { - value = comparison(x, y); - } - if (value != 0) { - break; - } - } - return value; - } - - private readonly List> _comparisons = new List>(); - - } - - } -} diff --git a/StarlightDirector/StarlightDirector/Extensions/NotifyPropertyChangedExtensions.cs b/StarlightDirector/StarlightDirector/Extensions/NotifyPropertyChangedExtensions.cs deleted file mode 100644 index 7be1e77..0000000 --- a/StarlightDirector/StarlightDirector/Extensions/NotifyPropertyChangedExtensions.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq.Expressions; - -namespace StarlightDirector.Extensions { - public static class NotifyPropertyChangedExtensions { - - // http://www.wpftutorial.net/INotifyPropertyChanged.html - public static bool ChangeAndNotify(this PropertyChangedEventHandler handler, ref T field, T value, Expression> memberExpression) { - if (memberExpression == null) { - throw new ArgumentNullException(nameof(memberExpression)); - } - var body = memberExpression.Body as MemberExpression; - if (body == null) { - throw new ArgumentException("Lambda must return a property."); - } - if (EqualityComparer.Default.Equals(field, value)) { - return false; - } - - var vmExpression = body.Expression as ConstantExpression; - if (vmExpression != null) { - var lambda = Expression.Lambda(vmExpression); - var vmFunc = lambda.Compile(); - var sender = vmFunc.DynamicInvoke(); - handler?.Invoke(sender, new PropertyChangedEventArgs(body.Member.Name)); - } - - field = value; - return true; - } - - } -} diff --git a/StarlightDirector/StarlightDirector/Extensions/VisualExtensions.cs b/StarlightDirector/StarlightDirector/Extensions/VisualExtensions.cs deleted file mode 100644 index aa7d375..0000000 --- a/StarlightDirector/StarlightDirector/Extensions/VisualExtensions.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Reflection; -using System.Windows; -using System.Windows.Controls; -using StarlightDirector.UI.Controls.Pages; -using StarlightDirector.UI.Windows; - -namespace StarlightDirector.Extensions { - internal static class VisualExtensions { - - public static TParent FindVisualParent(this FrameworkElement element) where TParent : FrameworkElement { - var mainWindowType = typeof(TParent); - var parent = element.GetVisualParent(); - while (parent != null) { - if (parent.GetType() == mainWindowType) { - return parent as TParent; - } - parent = parent.GetVisualParent(); - } - return null; - } - - public static MainWindow GetMainWindow(this T page) where T : UserControl, IDirectorPage { - return FindVisualParent(page); - } - - private static FrameworkElement GetVisualParent(this FrameworkElement element) { - return VisualParentPropInfo.GetValue(element, null) as FrameworkElement; - } - - private static readonly PropertyInfo VisualParentPropInfo = typeof(FrameworkElement).GetProperty("VisualParent", BindingFlags.Instance | BindingFlags.NonPublic); - - } -} diff --git a/StarlightDirector/StarlightDirector/Properties/Annotations.cs b/StarlightDirector/StarlightDirector/Properties/Annotations.cs deleted file mode 100644 index 060a778..0000000 --- a/StarlightDirector/StarlightDirector/Properties/Annotations.cs +++ /dev/null @@ -1,1039 +0,0 @@ -/* MIT License - -Copyright (c) 2016 JetBrains http://www.jetbrains.com - -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; - -#pragma warning disable 1591 -// ReSharper disable UnusedMember.Global -// ReSharper disable MemberCanBePrivate.Global -// ReSharper disable UnusedAutoPropertyAccessor.Global -// ReSharper disable IntroduceOptionalParameters.Global -// ReSharper disable MemberCanBeProtected.Global -// ReSharper disable InconsistentNaming - -namespace DereTore.Applications.StarlightDirector.Annotations -{ - /// - /// Indicates that the value of the marked element could be null sometimes, - /// so the check for null is necessary before its usage. - /// - /// - /// [CanBeNull] object Test() => null; - /// - /// void UseTest() { - /// var p = Test(); - /// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException' - /// } - /// - [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event | - AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)] - public sealed class CanBeNullAttribute : Attribute { } - - /// - /// Indicates that the value of the marked element could never be null. - /// - /// - /// [NotNull] object Foo() { - /// return null; // Warning: Possible 'null' assignment - /// } - /// - [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event | - AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)] - public sealed class NotNullAttribute : Attribute { } - - /// - /// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task - /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property - /// or of the Lazy.Value property can never be null. - /// - [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field)] - public sealed class ItemNotNullAttribute : Attribute { } - - /// - /// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task - /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property - /// or of the Lazy.Value property can be null. - /// - [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field)] - public sealed class ItemCanBeNullAttribute : Attribute { } - - /// - /// Implicitly apply [NotNull]/[ItemNotNull] annotation to all the of type members and parameters - /// in particular scope where this annotation is used (type declaration or whole assembly). - /// - [AttributeUsage( - AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface | AttributeTargets.Assembly)] - public sealed class ImplicitNotNullAttribute : Attribute { } - - /// - /// Indicates that the marked method builds string by format pattern and (optional) arguments. - /// Parameter, which contains format string, should be given in constructor. The format string - /// should be in -like form. - /// - /// - /// [StringFormatMethod("message")] - /// void ShowError(string message, params object[] args) { /* do something */ } - /// - /// void Foo() { - /// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string - /// } - /// - [AttributeUsage( - AttributeTargets.Constructor | AttributeTargets.Method | - AttributeTargets.Property | AttributeTargets.Delegate)] - public sealed class StringFormatMethodAttribute : Attribute - { - /// - /// Specifies which parameter of an annotated method should be treated as format-string - /// - public StringFormatMethodAttribute([NotNull] string formatParameterName) - { - FormatParameterName = formatParameterName; - } - - [NotNull] public string FormatParameterName { get; private set; } - } - - /// - /// For a parameter that is expected to be one of the limited set of values. - /// Specify fields of which type should be used as values for this parameter. - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)] - public sealed class ValueProviderAttribute : Attribute - { - public ValueProviderAttribute([NotNull] string name) - { - Name = name; - } - - [NotNull] public string Name { get; private set; } - } - - /// - /// Indicates that the function argument should be string literal and match one - /// of the parameters of the caller function. For example, ReSharper annotates - /// the parameter of . - /// - /// - /// void Foo(string param) { - /// if (param == null) - /// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol - /// } - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class InvokerParameterNameAttribute : Attribute { } - - /// - /// Indicates that the method is contained in a type that implements - /// System.ComponentModel.INotifyPropertyChanged interface and this method - /// is used to notify that some property value changed. - /// - /// - /// The method should be non-static and conform to one of the supported signatures: - /// - /// NotifyChanged(string) - /// NotifyChanged(params string[]) - /// NotifyChanged{T}(Expression{Func{T}}) - /// NotifyChanged{T,U}(Expression{Func{T,U}}) - /// SetProperty{T}(ref T, T, string) - /// - /// - /// - /// public class Foo : INotifyPropertyChanged { - /// public event PropertyChangedEventHandler PropertyChanged; - /// - /// [NotifyPropertyChangedInvocator] - /// protected virtual void NotifyChanged(string propertyName) { ... } - /// - /// string _name; - /// - /// public string Name { - /// get { return _name; } - /// set { _name = value; NotifyChanged("LastName"); /* Warning */ } - /// } - /// } - /// - /// Examples of generated notifications: - /// - /// NotifyChanged("Property") - /// NotifyChanged(() => Property) - /// NotifyChanged((VM x) => x.Property) - /// SetProperty(ref myField, value, "Property") - /// - /// - [AttributeUsage(AttributeTargets.Method)] - public sealed class NotifyPropertyChangedInvocatorAttribute : Attribute - { - public NotifyPropertyChangedInvocatorAttribute() { } - public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName) - { - ParameterName = parameterName; - } - - [CanBeNull] public string ParameterName { get; private set; } - } - - /// - /// Describes dependency between method input and output. - /// - /// - ///

Function Definition Table syntax:

- /// - /// FDT ::= FDTRow [;FDTRow]* - /// FDTRow ::= Input => Output | Output <= Input - /// Input ::= ParameterName: Value [, Input]* - /// Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value} - /// Value ::= true | false | null | notnull | canbenull - /// - /// If method has single input parameter, it's name could be omitted.
- /// Using halt (or void/nothing, which is the same) - /// for method output means that the methos doesn't return normally.
- /// canbenull annotation is only applicable for output parameters.
- /// You can use multiple [ContractAnnotation] for each FDT row, - /// or use single attribute with rows separated by semicolon.
- ///
- /// - /// - /// [ContractAnnotation("=> halt")] - /// public void TerminationMethod() - /// - /// - /// [ContractAnnotation("halt <= condition: false")] - /// public void Assert(bool condition, string text) // regular assertion method - /// - /// - /// [ContractAnnotation("s:null => true")] - /// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty() - /// - /// - /// // A method that returns null if the parameter is null, - /// // and not null if the parameter is not null - /// [ContractAnnotation("null => null; notnull => notnull")] - /// public object Transform(object data) - /// - /// - /// [ContractAnnotation("s:null=>false; =>true,result:notnull; =>false, result:null")] - /// public bool TryParse(string s, out Person result) - /// - /// - [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] - public sealed class ContractAnnotationAttribute : Attribute - { - public ContractAnnotationAttribute([NotNull] string contract) - : this(contract, false) { } - - public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates) - { - Contract = contract; - ForceFullStates = forceFullStates; - } - - [NotNull] public string Contract { get; private set; } - public bool ForceFullStates { get; private set; } - } - - /// - /// Indicates that marked element should be localized or not. - /// - /// - /// [LocalizationRequiredAttribute(true)] - /// class Foo { - /// string str = "my string"; // Warning: Localizable string - /// } - /// - [AttributeUsage(AttributeTargets.All)] - public sealed class LocalizationRequiredAttribute : Attribute - { - public LocalizationRequiredAttribute() : this(true) { } - public LocalizationRequiredAttribute(bool required) - { - Required = required; - } - - public bool Required { get; private set; } - } - - /// - /// Indicates that the value of the marked type (or its derivatives) - /// cannot be compared using '==' or '!=' operators and Equals() - /// should be used instead. However, using '==' or '!=' for comparison - /// with null is always permitted. - /// - /// - /// [CannotApplyEqualityOperator] - /// class NoEquality { } - /// - /// class UsesNoEquality { - /// void Test() { - /// var ca1 = new NoEquality(); - /// var ca2 = new NoEquality(); - /// if (ca1 != null) { // OK - /// bool condition = ca1 == ca2; // Warning - /// } - /// } - /// } - /// - [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)] - public sealed class CannotApplyEqualityOperatorAttribute : Attribute { } - - /// - /// When applied to a target attribute, specifies a requirement for any type marked - /// with the target attribute to implement or inherit specific type or types. - /// - /// - /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement - /// class ComponentAttribute : Attribute { } - /// - /// [Component] // ComponentAttribute requires implementing IComponent interface - /// class MyComponent : IComponent { } - /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] - [BaseTypeRequired(typeof(Attribute))] - public sealed class BaseTypeRequiredAttribute : Attribute - { - public BaseTypeRequiredAttribute([NotNull] Type baseType) - { - BaseType = baseType; - } - - [NotNull] public Type BaseType { get; private set; } - } - - /// - /// Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library), - /// so this symbol will not be marked as unused (as well as by other usage inspections). - /// - [AttributeUsage(AttributeTargets.All)] - public sealed class UsedImplicitlyAttribute : Attribute - { - public UsedImplicitlyAttribute() - : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { } - - public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags) - : this(useKindFlags, ImplicitUseTargetFlags.Default) { } - - public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags) - : this(ImplicitUseKindFlags.Default, targetFlags) { } - - public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) - { - UseKindFlags = useKindFlags; - TargetFlags = targetFlags; - } - - public ImplicitUseKindFlags UseKindFlags { get; private set; } - public ImplicitUseTargetFlags TargetFlags { get; private set; } - } - - /// - /// Should be used on attributes and causes ReSharper to not mark symbols marked with such attributes - /// as unused (as well as by other usage inspections) - /// - [AttributeUsage(AttributeTargets.Class | AttributeTargets.GenericParameter)] - public sealed class MeansImplicitUseAttribute : Attribute - { - public MeansImplicitUseAttribute() - : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { } - - public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags) - : this(useKindFlags, ImplicitUseTargetFlags.Default) { } - - public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags) - : this(ImplicitUseKindFlags.Default, targetFlags) { } - - public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) - { - UseKindFlags = useKindFlags; - TargetFlags = targetFlags; - } - - [UsedImplicitly] public ImplicitUseKindFlags UseKindFlags { get; private set; } - [UsedImplicitly] public ImplicitUseTargetFlags TargetFlags { get; private set; } - } - - [Flags] - public enum ImplicitUseKindFlags - { - Default = Access | Assign | InstantiatedWithFixedConstructorSignature, - /// Only entity marked with attribute considered used. - Access = 1, - /// Indicates implicit assignment to a member. - Assign = 2, - /// - /// Indicates implicit instantiation of a type with fixed constructor signature. - /// That means any unused constructor parameters won't be reported as such. - /// - InstantiatedWithFixedConstructorSignature = 4, - /// Indicates implicit instantiation of a type. - InstantiatedNoFixedConstructorSignature = 8, - } - - /// - /// Specify what is considered used implicitly when marked - /// with or . - /// - [Flags] - public enum ImplicitUseTargetFlags - { - Default = Itself, - Itself = 1, - /// Members of entity marked with attribute are considered used. - Members = 2, - /// Entity marked with attribute and all its members considered used. - WithMembers = Itself | Members - } - - /// - /// This attribute is intended to mark publicly available API - /// which should not be removed and so is treated as used. - /// - [MeansImplicitUse(ImplicitUseTargetFlags.WithMembers)] - public sealed class PublicAPIAttribute : Attribute - { - public PublicAPIAttribute() { } - public PublicAPIAttribute([NotNull] string comment) - { - Comment = comment; - } - - [CanBeNull] public string Comment { get; private set; } - } - - /// - /// Tells code analysis engine if the parameter is completely handled when the invoked method is on stack. - /// If the parameter is a delegate, indicates that delegate is executed while the method is executed. - /// If the parameter is an enumerable, indicates that it is enumerated while the method is executed. - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class InstantHandleAttribute : Attribute { } - - /// - /// Indicates that a method does not make any observable state changes. - /// The same as System.Diagnostics.Contracts.PureAttribute. - /// - /// - /// [Pure] int Multiply(int x, int y) => x * y; - /// - /// void M() { - /// Multiply(123, 42); // Waring: Return value of pure method is not used - /// } - /// - [AttributeUsage(AttributeTargets.Method)] - public sealed class PureAttribute : Attribute { } - - /// - /// Indicates that the return value of method invocation must be used. - /// - [AttributeUsage(AttributeTargets.Method)] - public sealed class MustUseReturnValueAttribute : Attribute - { - public MustUseReturnValueAttribute() { } - public MustUseReturnValueAttribute([NotNull] string justification) - { - Justification = justification; - } - - [CanBeNull] public string Justification { get; private set; } - } - - /// - /// Indicates the type member or parameter of some type, that should be used instead of all other ways - /// to get the value that type. This annotation is useful when you have some "context" value evaluated - /// and stored somewhere, meaning that all other ways to get this value must be consolidated with existing one. - /// - /// - /// class Foo { - /// [ProvidesContext] IBarService _barService = ...; - /// - /// void ProcessNode(INode node) { - /// DoSomething(node, node.GetGlobalServices().Bar); - /// // ^ Warning: use value of '_barService' field - /// } - /// } - /// - [AttributeUsage( - AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.Method | - AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.GenericParameter)] - public sealed class ProvidesContextAttribute : Attribute { } - - /// - /// Indicates that a parameter is a path to a file or a folder within a web project. - /// Path can be relative or absolute, starting from web root (~). - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class PathReferenceAttribute : Attribute - { - public PathReferenceAttribute() { } - public PathReferenceAttribute([NotNull, PathReference] string basePath) - { - BasePath = basePath; - } - - [CanBeNull] public string BasePath { get; private set; } - } - - /// - /// An extension method marked with this attribute is processed by ReSharper code completion - /// as a 'Source Template'. When extension method is completed over some expression, it's source code - /// is automatically expanded like a template at call site. - /// - /// - /// Template method body can contain valid source code and/or special comments starting with '$'. - /// Text inside these comments is added as source code when the template is applied. Template parameters - /// can be used either as additional method parameters or as identifiers wrapped in two '$' signs. - /// Use the attribute to specify macros for parameters. - /// - /// - /// In this example, the 'forEach' method is a source template available over all values - /// of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block: - /// - /// [SourceTemplate] - /// public static void forEach<T>(this IEnumerable<T> xs) { - /// foreach (var x in xs) { - /// //$ $END$ - /// } - /// } - /// - /// - [AttributeUsage(AttributeTargets.Method)] - public sealed class SourceTemplateAttribute : Attribute { } - - /// - /// Allows specifying a macro for a parameter of a source template. - /// - /// - /// You can apply the attribute on the whole method or on any of its additional parameters. The macro expression - /// is defined in the property. When applied on a method, the target - /// template parameter is defined in the property. To apply the macro silently - /// for the parameter, set the property value = -1. - /// - /// - /// Applying the attribute on a source template method: - /// - /// [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")] - /// public static void forEach<T>(this IEnumerable<T> collection) { - /// foreach (var item in collection) { - /// //$ $END$ - /// } - /// } - /// - /// Applying the attribute on a template method parameter: - /// - /// [SourceTemplate] - /// public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) { - /// /*$ var $x$Id = "$newguid$" + x.ToString(); - /// x.DoSomething($x$Id); */ - /// } - /// - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, AllowMultiple = true)] - public sealed class MacroAttribute : Attribute - { - /// - /// Allows specifying a macro that will be executed for a source template - /// parameter when the template is expanded. - /// - public string Expression { get; set; } - - /// - /// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed. - /// - /// - /// If the target parameter is used several times in the template, only one occurrence becomes editable; - /// other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence, - /// use values >= 0. To make the parameter non-editable when the template is expanded, use -1. - /// > - public int Editable { get; set; } - - /// - /// Identifies the target parameter of a source template if the - /// is applied on a template method. - /// - public string Target { get; set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - public sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute - { - public AspMvcAreaMasterLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - public sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute - { - public AspMvcAreaPartialViewLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - public sealed class AspMvcAreaViewLocationFormatAttribute : Attribute - { - public AspMvcAreaViewLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - public sealed class AspMvcMasterLocationFormatAttribute : Attribute - { - public AspMvcMasterLocationFormatAttribute(string format) - { - Format = format; - } - - public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - public sealed class AspMvcPartialViewLocationFormatAttribute : Attribute - { - public AspMvcPartialViewLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - public sealed class AspMvcViewLocationFormatAttribute : Attribute - { - public AspMvcViewLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] public string Format { get; private set; } - } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - /// is an MVC action. If applied to a method, the MVC action name is calculated - /// implicitly from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - public sealed class AspMvcActionAttribute : Attribute - { - public AspMvcActionAttribute() { } - public AspMvcActionAttribute([NotNull] string anonymousProperty) - { - AnonymousProperty = anonymousProperty; - } - - [CanBeNull] public string AnonymousProperty { get; private set; } - } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC area. - /// Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class AspMvcAreaAttribute : Attribute - { - public AspMvcAreaAttribute() { } - public AspMvcAreaAttribute([NotNull] string anonymousProperty) - { - AnonymousProperty = anonymousProperty; - } - - [CanBeNull] public string AnonymousProperty { get; private set; } - } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is - /// an MVC controller. If applied to a method, the MVC controller name is calculated - /// implicitly from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - public sealed class AspMvcControllerAttribute : Attribute - { - public AspMvcControllerAttribute() { } - public AspMvcControllerAttribute([NotNull] string anonymousProperty) - { - AnonymousProperty = anonymousProperty; - } - - [CanBeNull] public string AnonymousProperty { get; private set; } - } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC Master. Use this attribute - /// for custom wrappers similar to System.Web.Mvc.Controller.View(String, String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class AspMvcMasterAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC model type. Use this attribute - /// for custom wrappers similar to System.Web.Mvc.Controller.View(String, Object). - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class AspMvcModelTypeAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC - /// partial view. If applied to a method, the MVC partial view name is calculated implicitly - /// from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - public sealed class AspMvcPartialViewAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method. - /// - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] - public sealed class AspMvcSuppressViewErrorAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template. - /// Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class AspMvcDisplayTemplateAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC editor template. - /// Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class AspMvcEditorTemplateAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC template. - /// Use this attribute for custom wrappers similar to - /// System.ComponentModel.DataAnnotations.UIHintAttribute(System.String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class AspMvcTemplateAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - /// is an MVC view component. If applied to a method, the MVC view name is calculated implicitly - /// from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Controller.View(Object). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - public sealed class AspMvcViewAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - /// is an MVC view component name. - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class AspMvcViewComponentAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - /// is an MVC view component view. If applied to a method, the MVC view component view name is default. - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - public sealed class AspMvcViewComponentViewAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. When applied to a parameter of an attribute, - /// indicates that this parameter is an MVC action name. - /// - /// - /// [ActionName("Foo")] - /// public ActionResult Login(string returnUrl) { - /// ViewBag.ReturnUrl = Url.Action("Foo"); // OK - /// return RedirectToAction("Bar"); // Error: Cannot resolve action - /// } - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)] - public sealed class AspMvcActionSelectorAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)] - public sealed class HtmlElementAttributesAttribute : Attribute - { - public HtmlElementAttributesAttribute() { } - public HtmlElementAttributesAttribute([NotNull] string name) - { - Name = name; - } - - [CanBeNull] public string Name { get; private set; } - } - - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)] - public sealed class HtmlAttributeValueAttribute : Attribute - { - public HtmlAttributeValueAttribute([NotNull] string name) - { - Name = name; - } - - [NotNull] public string Name { get; private set; } - } - - /// - /// Razor attribute. Indicates that a parameter or a method is a Razor section. - /// Use this attribute for custom wrappers similar to - /// System.Web.WebPages.WebPageBase.RenderSection(String). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - public sealed class RazorSectionAttribute : Attribute { } - - /// - /// Indicates how method, constructor invocation or property access - /// over collection type affects content of the collection. - /// - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property)] - public sealed class CollectionAccessAttribute : Attribute - { - public CollectionAccessAttribute(CollectionAccessType collectionAccessType) - { - CollectionAccessType = collectionAccessType; - } - - public CollectionAccessType CollectionAccessType { get; private set; } - } - - [Flags] - public enum CollectionAccessType - { - /// Method does not use or modify content of the collection. - None = 0, - /// Method only reads content of the collection but does not modify it. - Read = 1, - /// Method can change content of the collection but does not add new elements. - ModifyExistingContent = 2, - /// Method can add new elements to the collection. - UpdatedContent = ModifyExistingContent | 4 - } - - /// - /// Indicates that the marked method is assertion method, i.e. it halts control flow if - /// one of the conditions is satisfied. To set the condition, mark one of the parameters with - /// attribute. - /// - [AttributeUsage(AttributeTargets.Method)] - public sealed class AssertionMethodAttribute : Attribute { } - - /// - /// Indicates the condition parameter of the assertion method. The method itself should be - /// marked by attribute. The mandatory argument of - /// the attribute is the assertion type. - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class AssertionConditionAttribute : Attribute - { - public AssertionConditionAttribute(AssertionConditionType conditionType) - { - ConditionType = conditionType; - } - - public AssertionConditionType ConditionType { get; private set; } - } - - /// - /// Specifies assertion type. If the assertion method argument satisfies the condition, - /// then the execution continues. Otherwise, execution is assumed to be halted. - /// - public enum AssertionConditionType - { - /// Marked parameter should be evaluated to true. - IS_TRUE = 0, - /// Marked parameter should be evaluated to false. - IS_FALSE = 1, - /// Marked parameter should be evaluated to null value. - IS_NULL = 2, - /// Marked parameter should be evaluated to not null value. - IS_NOT_NULL = 3, - } - - /// - /// Indicates that the marked method unconditionally terminates control flow execution. - /// For example, it could unconditionally throw exception. - /// - [Obsolete("Use [ContractAnnotation('=> halt')] instead")] - [AttributeUsage(AttributeTargets.Method)] - public sealed class TerminatesProgramAttribute : Attribute { } - - /// - /// Indicates that method is pure LINQ method, with postponed enumeration (like Enumerable.Select, - /// .Where). This annotation allows inference of [InstantHandle] annotation for parameters - /// of delegate type by analyzing LINQ method chains. - /// - [AttributeUsage(AttributeTargets.Method)] - public sealed class LinqTunnelAttribute : Attribute { } - - /// - /// Indicates that IEnumerable, passed as parameter, is not enumerated. - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class NoEnumerationAttribute : Attribute { } - - /// - /// Indicates that parameter is regular expression pattern. - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class RegexPatternAttribute : Attribute { } - - /// - /// XAML attribute. Indicates the type that has ItemsSource property and should be treated - /// as ItemsControl-derived type, to enable inner items DataContext type resolve. - /// - [AttributeUsage(AttributeTargets.Class)] - public sealed class XamlItemsControlAttribute : Attribute { } - - /// - /// XAML attribute. Indicates the property of some BindingBase-derived type, that - /// is used to bind some item of ItemsControl-derived type. This annotation will - /// enable the DataContext type resolve for XAML bindings for such properties. - /// - /// - /// Property should have the tree ancestor of the ItemsControl type or - /// marked with the attribute. - /// - [AttributeUsage(AttributeTargets.Property)] - public sealed class XamlItemBindingOfItemsControlAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] - public sealed class AspChildControlTypeAttribute : Attribute - { - public AspChildControlTypeAttribute([NotNull] string tagName, [NotNull] Type controlType) - { - TagName = tagName; - ControlType = controlType; - } - - [NotNull] public string TagName { get; private set; } - [NotNull] public Type ControlType { get; private set; } - } - - [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] - public sealed class AspDataFieldAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] - public sealed class AspDataFieldsAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Property)] - public sealed class AspMethodPropertyAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] - public sealed class AspRequiredAttributeAttribute : Attribute - { - public AspRequiredAttributeAttribute([NotNull] string attribute) - { - Attribute = attribute; - } - - [NotNull] public string Attribute { get; private set; } - } - - [AttributeUsage(AttributeTargets.Property)] - public sealed class AspTypePropertyAttribute : Attribute - { - public bool CreateConstructorReferences { get; private set; } - - public AspTypePropertyAttribute(bool createConstructorReferences) - { - CreateConstructorReferences = createConstructorReferences; - } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - public sealed class RazorImportNamespaceAttribute : Attribute - { - public RazorImportNamespaceAttribute([NotNull] string name) - { - Name = name; - } - - [NotNull] public string Name { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - public sealed class RazorInjectionAttribute : Attribute - { - public RazorInjectionAttribute([NotNull] string type, [NotNull] string fieldName) - { - Type = type; - FieldName = fieldName; - } - - [NotNull] public string Type { get; private set; } - [NotNull] public string FieldName { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - public sealed class RazorDirectiveAttribute : Attribute - { - public RazorDirectiveAttribute([NotNull] string directive) - { - Directive = directive; - } - - [NotNull] public string Directive { get; private set; } - } - - [AttributeUsage(AttributeTargets.Method)] - public sealed class RazorHelperCommonAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Property)] - public sealed class RazorLayoutAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Method)] - public sealed class RazorWriteLiteralMethodAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Method)] - public sealed class RazorWriteMethodAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class RazorWriteMethodParameterAttribute : Attribute { } - - /// - /// Prevents the Member Reordering feature from tossing members of the marked class. - /// - /// - /// The attribute must be mentioned in your member reordering patterns - /// - [AttributeUsage(AttributeTargets.All)] - public sealed class NoReorder : Attribute { } -} \ No newline at end of file diff --git a/StarlightDirector/StarlightDirector/Properties/AssemblyInfo.cs b/StarlightDirector/StarlightDirector/Properties/AssemblyInfo.cs deleted file mode 100644 index 6daf701..0000000 --- a/StarlightDirector/StarlightDirector/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; -using System.Windows; - -// 有关程序集的一般信息由以下 -// 控制。更改这些特性值可修改 -// 与程序集关联的信息。 -[assembly: AssemblyTitle("StarlightDirector")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("StarlightDirector")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -//将 ComVisible 设置为 false 将使此程序集中的类型 -//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, -//请将此类型的 ComVisible 特性设置为 true。 -[assembly: ComVisible(false)] - -//若要开始生成可本地化的应用程序,请 -// 中的 .csproj 文件中 -//例如,如果您在源文件中使用的是美国英语, -//使用的是美国英语,请将 设置为 en-US。 然后取消 -//对以下 NeutralResourceLanguage 特性的注释。 更新 -//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。 - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //主题特定资源词典所处位置 - //(当资源未在页面 - //或应用程序资源字典中找到时使用) - ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置 - //(当资源未在页面 - //、应用程序或任何主题专用资源字典中找到时使用) -)] - - -// 程序集的版本信息由下列四个值组成: -// -// 主版本 -// 次版本 -// 生成号 -// 修订号 -// -//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, -// 方法是按如下所示使用“*”: : -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.4.0.0")] -[assembly: AssemblyFileVersion("0.7.1.0")] -[assembly: Guid("de69897a-be1b-410a-a159-814b5f4033b4")] - diff --git a/StarlightDirector/StarlightDirector/Properties/Resources.Designer.cs b/StarlightDirector/StarlightDirector/Properties/Resources.Designer.cs deleted file mode 100644 index c2d4937..0000000 --- a/StarlightDirector/StarlightDirector/Properties/Resources.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 此代码由工具生成。 -// 运行时版本:4.0.30319.42000 -// -// 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 -// -//------------------------------------------------------------------------------ - -namespace StarlightDirector.Properties { - using System; - - - /// - /// 一个强类型的资源类,用于查找本地化的字符串等。 - /// - // 此类是由 StronglyTypedResourceBuilder - // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 - // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen - // (以 /str 作为命令选项),或重新生成 VS 项目。 - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// 返回此类使用的缓存的 ResourceManager 实例。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StarlightDirector.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// 使用此强类型资源类,为所有资源查找 - /// 重写当前线程的 CurrentUICulture 属性。 - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/StarlightDirector/StarlightDirector/Properties/Resources.resx b/StarlightDirector/StarlightDirector/Properties/Resources.resx deleted file mode 100644 index 7080a7d..0000000 --- a/StarlightDirector/StarlightDirector/Properties/Resources.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/StarlightDirector/StarlightDirector/Properties/Settings.Designer.cs b/StarlightDirector/StarlightDirector/Properties/Settings.Designer.cs deleted file mode 100644 index 1d05421..0000000 --- a/StarlightDirector/StarlightDirector/Properties/Settings.Designer.cs +++ /dev/null @@ -1,26 +0,0 @@ -//------------------------------------------------------------------------------ -// -// 此代码由工具生成。 -// 运行时版本:4.0.30319.42000 -// -// 对此文件的更改可能会导致不正确的行为,并且如果 -// 重新生成代码,这些更改将会丢失。 -// -//------------------------------------------------------------------------------ - -namespace StarlightDirector.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - } -} diff --git a/StarlightDirector/StarlightDirector/Properties/Settings.settings b/StarlightDirector/StarlightDirector/Properties/Settings.settings deleted file mode 100644 index 033d7a5..0000000 --- a/StarlightDirector/StarlightDirector/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/StarlightDirector/StarlightDirector/ResourceKeys.cs b/StarlightDirector/StarlightDirector/ResourceKeys.cs deleted file mode 100644 index 8ef94ef..0000000 --- a/StarlightDirector/StarlightDirector/ResourceKeys.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System.Reflection; - -namespace StarlightDirector { - public sealed class ResourceKeys { - - public readonly string NeutralStrokeColor; - public readonly string CuteStrokeColor; - public readonly string CoolStrokeColor; - public readonly string PassionStrokeColor; - public readonly string NeutralStrokeBrush; - public readonly string CuteStrokeBrush; - public readonly string CoolStrokeBrush; - public readonly string PassionStrokeBrush; - public readonly string NeutralFillColor; - public readonly string CuteFillColor; - public readonly string CoolFillColor; - public readonly string PassionFillColor; - public readonly string NeutralFillBrush; - public readonly string CuteFillBrush; - public readonly string CoolFillBrush; - public readonly string PassionFillBrush; - - public readonly string SyncNoteBorderBrush; - public readonly string FlickNoteBorderBrush; - public readonly string HoldNoteBorderBrush; - public readonly string RelationBorderBrush; - - public readonly string ProjectFileFilter; - public readonly string ProjectFileV01Filter; - public readonly string CsvFileFilter; - public readonly string WaveFileFilter; - public readonly string AcbFileFilter; - public readonly string BdbFileFilter; - public readonly string DelesteTxtFileFilter; - - public readonly string ProjectChangedPrompt; - public readonly string PreviewNotImplementedPrompt; - public readonly string ConfirmDeleteBarPrompt; - public readonly string NoteRelationAlreadyExistsPrompt; - public readonly string InvalidSyncCreationPrompt; - public readonly string InvalidFlickCreationPrompt; - public readonly string FlickRelationIsFullPrompt; - public readonly string InvalidHoldCreationPrompt; - public readonly string ExportToCsvCompletePromptTemplate; - public readonly string ExportToDelesteBeatmapCompletePromptTemplate; - public readonly string ConvertSaveFormatCompletePromptTemplate; - public readonly string ProjectUpgradeNeededPromptTemplate; - public readonly string ProjectVersionInvalidPromptTemplate; - public readonly string ProjectVersionUpToDatePrompt; - public readonly string NoCorrespondingDifficultyExistsPromptTemplate; - public readonly string ExportAndReplaceBdbCompletePromptTemplate; - public readonly string ErrorOccurredPrompt; - public readonly string ApplicationIsAlreadyRunningPrompt; - public readonly string BdbBuildingCompletePromptTemplate1; - public readonly string BdbBuildingCompletePromptTemplate2; - public readonly string ProjectAutoSavedToPromptTemplate; - public readonly string LoadedProjectFromAutoSavPromptTemplate; - public readonly string AutoSaveFileFoundPromptTemplate; - public readonly string AutoSaveRestorationFailedPromptTemplate; - - public readonly string AcbEnvironmentFilesMissing; - public readonly string AcbEnvironmentLogErrorTemplate; - public readonly string AcbEnvironmentRechecking; - - public readonly string DelesteWarningsAppearedPrompt; - public readonly string DelesteImportingWillReplaceCurrentScorePrompt; - - public readonly string SummaryTotalNotes; - public readonly string SummaryTotalBars; - public readonly string SummaryMusicFile; - - internal ResourceKeys() { - var thisType = GetType(); - var fields = thisType.GetFields(BindingFlags.Public | BindingFlags.Instance); - var stringType = typeof(string); - foreach (var field in fields) { - if (field.FieldType == stringType) { - field.SetValue(this, field.Name); - } - } - } - - } -} diff --git a/StarlightDirector/StarlightDirector/Resources/Directories/Booleans.xaml b/StarlightDirector/StarlightDirector/Resources/Directories/Booleans.xaml deleted file mode 100644 index 0d43a77..0000000 --- a/StarlightDirector/StarlightDirector/Resources/Directories/Booleans.xaml +++ /dev/null @@ -1,6 +0,0 @@ - - True - False - \ No newline at end of file diff --git a/StarlightDirector/StarlightDirector/Resources/Directories/Converters.xaml b/StarlightDirector/StarlightDirector/Resources/Directories/Converters.xaml deleted file mode 100644 index 527b88b..0000000 --- a/StarlightDirector/StarlightDirector/Resources/Directories/Converters.xaml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/StarlightDirector/StarlightDirector/Resources/Directories/Icons.xaml b/StarlightDirector/StarlightDirector/Resources/Directories/Icons.xaml deleted file mode 100644 index d013d42..0000000 --- a/StarlightDirector/StarlightDirector/Resources/Directories/Icons.xaml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/StarlightDirector/StarlightDirector/Resources/Directories/Images.xaml b/StarlightDirector/StarlightDirector/Resources/Directories/Images.xaml deleted file mode 100644 index b927242..0000000 --- a/StarlightDirector/StarlightDirector/Resources/Directories/Images.xaml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - diff --git a/StarlightDirector/StarlightDirector/Resources/Directories/Painting.xaml b/StarlightDirector/StarlightDirector/Resources/Directories/Painting.xaml deleted file mode 100644 index af5797c..0000000 --- a/StarlightDirector/StarlightDirector/Resources/Directories/Painting.xaml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/StarlightDirector/StarlightDirector/Resources/Directories/Strings.xaml b/StarlightDirector/StarlightDirector/Resources/Directories/Strings.xaml deleted file mode 100644 index d1cfe46..0000000 --- a/StarlightDirector/StarlightDirector/Resources/Directories/Strings.xaml +++ /dev/null @@ -1,49 +0,0 @@ - - Starlight Director Project (*.sldproj)|*.sldproj - Starlight Director Project v0.1 (*.sldproj)|*.sldproj - Comma Separated Values (*.csv)|*.csv - Wave Audio (*.wav)|*.wav - CRI ACB Archive (*.acb)|*.acb - Score Database (*.bdb)|*.bdb - Deleste Beatmap (*.txt)|*.txt - - The project is changed. Do you want to save it first? - The Preview function is not implemented yet. For now you can export the score to a Deleste beatmap and use Deleste to view it. - You are going to delete a measure. This operation cannot be reverted. Proceed? - There is already a relation between these notes. Please clear it before adding new relations. - Sync notes should be on the same row. - Flick notes should be on different rows and different columns (start AND finish). Also, both notes cannot be the start note of a hold pair. - At least one of the flick relations is already complete. This error happens when trying to set the next/previous flick note of a note that already has a successor/predecessor. - Hold note should be on the same column. One note can only have one hold target. There should be no other notes between two hold notes. Also, you cannot put a hold start on a flick note. - Score exported to CSV file '{0}'. - Score exported to Deleste TXT beatmap file '{0}'. - Save file '{0}' converted to '{1}'. - The file '{0}' is of an obsolete version. Starlight Director will try to perform an auto upgrade. - Cannot detect the version of '{0}' as a project save file. - The version of the project is up to date. - The difficulty '{0}' does not exist in score '{1}'. - Export to score file '{0}' difficulty '{1}' completed. - An error occurred from the last operation. - Another Starlight Director instance is running. Please edit scores in that instance. - Project is built and written to BDB file '{0}'. - Project is built and written to BDB file '{0}'. Created an LZ4-compressed copy '{1}'. - The project is auto saved to '{0}'. - Loaded project from auto save file '{0}'. - An autosave project was found at '{0}'. It usually means an error occurred during last edition. Do you want to load it? - An error occurred while trying to restore from an autosave file. This means that autosave file is corrupted. A new project will be loaded. Detailed information: {0} - - There are missing file(s): - ERROR: {0} - Rechecking... - - Importing a Delestue beatmap will replace current score and change your project settings like BPM or start time offset. Do you want to save your work first? - Some warnings were raised during the importing process. You can stop and try to edit the source file to eliminate those warnings, or continue and let Starlight Director modify the measures/notes automatically. Automatic modification may cause unexpected results in note positions or relations. Do you want to continue loading the modified score? - - Total notes in current score - Total measures in current score - Music file - - Unsaved - diff --git a/StarlightDirector/StarlightDirector/Resources/GameData/master.mdb b/StarlightDirector/StarlightDirector/Resources/GameData/master.mdb deleted file mode 100644 index d880d04..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/GameData/master.mdb and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/BarAppend.png b/StarlightDirector/StarlightDirector/Resources/Icons/BarAppend.png deleted file mode 100644 index 205d661..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/BarAppend.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/BarAppendMany.png b/StarlightDirector/StarlightDirector/Resources/Icons/BarAppendMany.png deleted file mode 100644 index 53515be..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/BarAppendMany.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/BarDelete.png b/StarlightDirector/StarlightDirector/Resources/Icons/BarDelete.png deleted file mode 100644 index 4236095..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/BarDelete.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/BarEdit.png b/StarlightDirector/StarlightDirector/Resources/Icons/BarEdit.png deleted file mode 100644 index 3172dc6..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/BarEdit.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/BarInsert.png b/StarlightDirector/StarlightDirector/Resources/Icons/BarInsert.png deleted file mode 100644 index 73d1034..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/BarInsert.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/EditMode.png b/StarlightDirector/StarlightDirector/Resources/Icons/EditMode.png deleted file mode 100644 index f1009b4..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/EditMode.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/EditModeClear.png b/StarlightDirector/StarlightDirector/Resources/Icons/EditModeClear.png deleted file mode 100644 index e465066..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/EditModeClear.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/EditModeFlick.png b/StarlightDirector/StarlightDirector/Resources/Icons/EditModeFlick.png deleted file mode 100644 index d67536a..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/EditModeFlick.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/EditModeHold.png b/StarlightDirector/StarlightDirector/Resources/Icons/EditModeHold.png deleted file mode 100644 index a55b7b6..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/EditModeHold.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/EditModeSelect.png b/StarlightDirector/StarlightDirector/Resources/Icons/EditModeSelect.png deleted file mode 100644 index 3e5623c..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/EditModeSelect.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/EditModeSync.png b/StarlightDirector/StarlightDirector/Resources/Icons/EditModeSync.png deleted file mode 100644 index 2e0e97a..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/EditModeSync.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/EditSelectAll.png b/StarlightDirector/StarlightDirector/Resources/Icons/EditSelectAll.png deleted file mode 100644 index 612f18b..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/EditSelectAll.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/FileExit.png b/StarlightDirector/StarlightDirector/Resources/Icons/FileExit.png deleted file mode 100644 index cea36c0..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/FileExit.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/FileNew.png b/StarlightDirector/StarlightDirector/Resources/Icons/FileNew.png deleted file mode 100644 index 2985b8d..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/FileNew.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/FileOpen.png b/StarlightDirector/StarlightDirector/Resources/Icons/FileOpen.png deleted file mode 100644 index fe913d3..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/FileOpen.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/FilePreferences.png b/StarlightDirector/StarlightDirector/Resources/Icons/FilePreferences.png deleted file mode 100644 index 8d59960..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/FilePreferences.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/FileSave.png b/StarlightDirector/StarlightDirector/Resources/Icons/FileSave.png deleted file mode 100644 index 5ca4d10..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/FileSave.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/FileSaveAs.png b/StarlightDirector/StarlightDirector/Resources/Icons/FileSaveAs.png deleted file mode 100644 index 0603c33..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/FileSaveAs.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/MusicPlay.png b/StarlightDirector/StarlightDirector/Resources/Icons/MusicPlay.png deleted file mode 100644 index 9f4ca15..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/MusicPlay.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/MusicSelectWaveFile.png b/StarlightDirector/StarlightDirector/Resources/Icons/MusicSelectWaveFile.png deleted file mode 100644 index cb7c660..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/MusicSelectWaveFile.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/MusicStop.png b/StarlightDirector/StarlightDirector/Resources/Icons/MusicStop.png deleted file mode 100644 index de3acd5..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/MusicStop.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/NoteAdd.png b/StarlightDirector/StarlightDirector/Resources/Icons/NoteAdd.png deleted file mode 100644 index 205d661..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/NoteAdd.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/NoteDelete.png b/StarlightDirector/StarlightDirector/Resources/Icons/NoteDelete.png deleted file mode 100644 index 4236095..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/NoteDelete.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/NoteEdit.png b/StarlightDirector/StarlightDirector/Resources/Icons/NoteEdit.png deleted file mode 100644 index e63314f..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/NoteEdit.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/NoteInsert.png b/StarlightDirector/StarlightDirector/Resources/Icons/NoteInsert.png deleted file mode 100644 index db7d331..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/NoteInsert.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/PreviewStart.png b/StarlightDirector/StarlightDirector/Resources/Icons/PreviewStart.png deleted file mode 100644 index fa741c7..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/PreviewStart.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/ScoreDifficulty.png b/StarlightDirector/StarlightDirector/Resources/Icons/ScoreDifficulty.png deleted file mode 100644 index f8dae63..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/ScoreDifficulty.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/ViewMiscInvertScrollDirection.png b/StarlightDirector/StarlightDirector/Resources/Icons/ViewMiscInvertScrollDirection.png deleted file mode 100644 index 2f18194..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/ViewMiscInvertScrollDirection.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/ViewMiscRelationIndicatorVisibility.png b/StarlightDirector/StarlightDirector/Resources/Icons/ViewMiscRelationIndicatorVisibility.png deleted file mode 100644 index 6dedadd..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/ViewMiscRelationIndicatorVisibility.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/ViewZoomIn.png b/StarlightDirector/StarlightDirector/Resources/Icons/ViewZoomIn.png deleted file mode 100644 index 1c10a6f..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/ViewZoomIn.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/ViewZoomOut.png b/StarlightDirector/StarlightDirector/Resources/Icons/ViewZoomOut.png deleted file mode 100644 index a07c825..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/ViewZoomOut.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Icons/ViewZoomToBeat.png b/StarlightDirector/StarlightDirector/Resources/Icons/ViewZoomToBeat.png deleted file mode 100644 index b62912a..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Icons/ViewZoomToBeat.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Mayu/mayu-01.png b/StarlightDirector/StarlightDirector/Resources/Mayu/mayu-01.png deleted file mode 100644 index 5f5305f..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Mayu/mayu-01.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Mayu/mayu-02.png b/StarlightDirector/StarlightDirector/Resources/Mayu/mayu-02.png deleted file mode 100644 index db12a41..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Mayu/mayu-02.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Mayu/mayu-03.png b/StarlightDirector/StarlightDirector/Resources/Mayu/mayu-03.png deleted file mode 100644 index d01048f..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Mayu/mayu-03.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Mayu/mayu-04.png b/StarlightDirector/StarlightDirector/Resources/Mayu/mayu-04.png deleted file mode 100644 index cb5b28d..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Mayu/mayu-04.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Mayu/mayu-05.png b/StarlightDirector/StarlightDirector/Resources/Mayu/mayu-05.png deleted file mode 100644 index 20c0417..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Mayu/mayu-05.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/Mayu/mayu-06.png b/StarlightDirector/StarlightDirector/Resources/Mayu/mayu-06.png deleted file mode 100644 index 1b91076..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/Mayu/mayu-06.png and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/SFX/director/se_live_flic_perfect.wav b/StarlightDirector/StarlightDirector/Resources/SFX/director/se_live_flic_perfect.wav deleted file mode 100644 index 66fc983..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/SFX/director/se_live_flic_perfect.wav and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/Resources/SFX/director/se_live_tap_perfect.wav b/StarlightDirector/StarlightDirector/Resources/SFX/director/se_live_tap_perfect.wav deleted file mode 100644 index 14fb30d..0000000 Binary files a/StarlightDirector/StarlightDirector/Resources/SFX/director/se_live_tap_perfect.wav and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/SD-Icon.ico b/StarlightDirector/StarlightDirector/SD-Icon.ico deleted file mode 100644 index 84e2886..0000000 Binary files a/StarlightDirector/StarlightDirector/SD-Icon.ico and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/StarlightDirector.csproj b/StarlightDirector/StarlightDirector/StarlightDirector.csproj deleted file mode 100644 index 6ba8890..0000000 --- a/StarlightDirector/StarlightDirector/StarlightDirector.csproj +++ /dev/null @@ -1,458 +0,0 @@ - - - - - Debug - AnyCPU - {EA6039D9-CFDA-44B5-BE32-F1256A649E18} - WinExe - Properties - StarlightDirector - StarlightDirector - v4.0 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - - - - - - true - bin\x86\Debug\ - DEBUG;TRACE - full - x86 - prompt - MinimumRecommendedRules.ruleset - false - - - bin\x86\Release\ - TRACE - true - pdbonly - x86 - prompt - MinimumRecommendedRules.ruleset - false - - - true - bin\x64\Debug\ - DEBUG;TRACE - full - x64 - prompt - MinimumRecommendedRules.ruleset - false - - - bin\x64\Release\ - TRACE - true - pdbonly - x64 - prompt - MinimumRecommendedRules.ruleset - false - - - app.manifest - - - StarlightDirector.App - - - SD-Icon.ico - - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - - App.xaml - Code - - - - - - - - - - - - - - - - LineLayer.xaml - - - - AboutPage.xaml - - - - - BuildPage.xaml - - - - - ExportPage.xaml - - - - ImportPage.xaml - - - RecentPage.xaml - - - SummaryPage.xaml - - - - - - - - - - - - - - - - ScorePreviewer.xaml - - - - - - ScrollViewerThumbnail.xaml - - - - - SpecialNotePointer.xaml - - - - - - - - - - - - - - - - - - - - - - - - - - - ScoreBar.xaml - - - - ScoreEditor.xaml - - - ScoreNote.xaml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MainWindow.xaml - Code - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Always - - - - - - - - - - - - Always - - - Always - - - Always - - - Always - - - - - {ABD7F1B5-C4E3-4200-8E44-98B183DFEE2C} - DereTore.Common.StarlightStage - - - {DBD0DA4A-0057-4D04-AD69-0E7267D72793} - DereTore.Common - - - {BEA07A30-C611-4D1C-9632-6CC103722BAA} - DereTore.Compression.LZ4 - - - {3A0D1281-A503-4E5D-9765-D7BF56F89266} - DereTore.Interop.OS - - - {7fb2a631-88c4-4c6b-9e8b-8eeeb40575d0} - StarlightDirector.Core - - - {d78a4080-34f4-45ec-a8ef-87f95815e3bd} - StarlightDirector.Entities - - - {3ecdd0bb-215a-4437-b162-fc9d9285303d} - StarlightDirector.Exchange - - - - - ..\..\packages\ControlzEx.2.2.0.4\lib\net40\ControlzEx.dll - True - - - ..\..\packages\CsvHelper.2.16.3.0\lib\net40\CsvHelper.dll - True - - - ..\..\packages\Fluent.Ribbon.4.0.3.394\lib\net40\Fluent.dll - True - - - ..\..\packages\NAudio.1.8.0\lib\net35\NAudio.dll - True - - - ..\..\packages\Newtonsoft.Json.9.0.1\lib\net40\Newtonsoft.Json.dll - True - - - - - - - ..\..\packages\System.Data.SQLite.Core.1.0.104.0\lib\net40\System.Data.SQLite.dll - True - - - ..\..\packages\ControlzEx.2.2.0.4\lib\net40\System.Windows.Interactivity.dll - True - - - - - - - - - - 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 - - - - - \ No newline at end of file diff --git a/StarlightDirector/StarlightDirector/UI/Controls/Models/DrawingBar.cs b/StarlightDirector/StarlightDirector/UI/Controls/Models/DrawingBar.cs deleted file mode 100644 index 38ebc4c..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/Models/DrawingBar.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace StarlightDirector.UI.Controls.Models -{ - /// - /// Internal representation of bars for drawing - /// - internal sealed class DrawingBar - { - public int DrawType { get; set; } - public int Timing { get; set; } - public double T { get; set; } - public double Y { get; set; } - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/Models/DrawingNote.cs b/StarlightDirector/StarlightDirector/UI/Controls/Models/DrawingNote.cs deleted file mode 100644 index b56a72a..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/Models/DrawingNote.cs +++ /dev/null @@ -1,25 +0,0 @@ -using StarlightDirector.Entities; - -namespace StarlightDirector.UI.Controls.Models -{ - /// - /// Internal representation of notes for drawing - /// - internal sealed class DrawingNote - { - public Note Note { get; set; } - public DrawingNote HoldTarget { get; set; } - public DrawingNote SyncTarget { get; set; } - public DrawingNote GroupTarget { get; set; } - public int Timing { get; set; } - public bool Done { get; set; } - public int Duration { get; set; } - public bool IsHoldStart { get; set; } - public double LastT { get; set; } - public double X { get; set; } - public double Y { get; set; } - public NoteDrawType DrawType { get; set; } - public int HitPosition { get; set; } - public bool EffectShown { get; set; } - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/Models/NoteDrawType.cs b/StarlightDirector/StarlightDirector/UI/Controls/Models/NoteDrawType.cs deleted file mode 100644 index d0d96be..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/Models/NoteDrawType.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace StarlightDirector.UI.Controls.Models { - internal enum NoteDrawType { - - Tap = 0, - FlickLeft = 1, - FlickRight = 2, - Hold = 3, - Slide = 4 - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/Pages/AboutPage.Commands.cs b/StarlightDirector/StarlightDirector/UI/Controls/Pages/AboutPage.Commands.cs deleted file mode 100644 index 4d20781..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/Pages/AboutPage.Commands.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Diagnostics; -using System.Windows; -using System.Windows.Input; -using System.Windows.Media.Imaging; -using DereTore.Common; -using StarlightDirector.Extensions; - -namespace StarlightDirector.UI.Controls.Pages { - partial class AboutPage { - - public static readonly ICommand CmdOpenLink = CommandHelper.RegisterCommand(); - public static readonly ICommand CmdEasterEgg = CommandHelper.RegisterCommand(); - - private void CmdOpenLink_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = true; - } - - private void CmdOpenLink_Executed(object sender, ExecutedRoutedEventArgs e) { - var link = e.Parameter as string; - if (link != null) { - var startInfo = new ProcessStartInfo(link); - Process.Start(startInfo); - } - } - - private void CmdEasterEgg_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = true; - } - - private void CmdEasterEgg_Executed(object sender, ExecutedRoutedEventArgs e) { - // #01-#05 are "normal" facial expressions, #06 is yandere. (yeah my favorite!) - // So let's play a mini gacha game. I set the probability to see #06 as 1.5%, which is the CGSS SSR drop rate. - var n = MathHelper.NextRandomInt32(1000); - string iconResourceName; - if (n >= 985) { - iconResourceName = "Mayu-06"; - } else { - n = n % 5 + 1; - iconResourceName = "Mayu-0" + n; - } - var newIcon = Application.Current.FindResource(iconResourceName); - IconPlaceholder.Source = newIcon; - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/Pages/AboutPage.xaml b/StarlightDirector/StarlightDirector/UI/Controls/Pages/AboutPage.xaml deleted file mode 100644 index ef78706..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/Pages/AboutPage.xaml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - version - - "" - - - Score and music creator for Idolmaster Cinderella Girls: Starlight Stage - - - Originally developed by hozuki, now maintained at - OpenCGSS/DereTore. - - - - - Powered by the open source projects: - SQLite - NAudio - Json.NET - CsvHelper - Fluent.Ribbon - lz4net - UnityStudio (and its fork) - - - - Special thanks to (in character ordinal order): - - - several others, and you. - - - The copyright of CGSS and its related content are held by Bandai Namco Entertainment, Inc. - - Feedback and issue report: click here. - - - - - - - - - - diff --git a/StarlightDirector/StarlightDirector/UI/Controls/Pages/AboutPage.xaml.cs b/StarlightDirector/StarlightDirector/UI/Controls/Pages/AboutPage.xaml.cs deleted file mode 100644 index 609129f..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/Pages/AboutPage.xaml.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System.Collections.Generic; -using System.Reflection; -using System.Windows; -using System.Windows.Documents; - -namespace StarlightDirector.UI.Controls.Pages { - public partial class AboutPage : IDirectorPage { - - public AboutPage() { - InitializeComponent(); - CommandHelper.InitializeCommandBindings(this); - } - - private void AboutPage_OnLoaded(object sender, RoutedEventArgs e) { - if (_pageLoaded) { - return; - } - OnLoaded(); - _pageLoaded = true; - } - - private void OnLoaded() { - var mainAssembly = Assembly.GetEntryAssembly(); - var attributes = mainAssembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false); - var fileVersionAttribute = attributes.Length > 0 ? attributes[0] as AssemblyFileVersionAttribute : null; - VersionText.Text = fileVersionAttribute?.Version; - Contributors.Sort((kv1, kv2) => string.CompareOrdinal(kv1.Key, kv2.Key)); - foreach (var contributor in Contributors) { - if (!string.IsNullOrEmpty(contributor.Value)) { - var hyperlink = new Hyperlink(); - hyperlink.Inlines.Add(contributor.Key); - hyperlink.CommandParameter = contributor.Value; - ContributorsBlock.Inlines.Add(hyperlink); - } else { - var run = new Run(); - run.Text = contributor.Key; - ContributorsBlock.Inlines.Add(run); - } - ContributorsBlock.Inlines.Add(", "); - } - } - - public static string VersionPrerelease => "alpha"; - public static string CodeName => "Miku"; - - private static readonly List> Contributors = new List> { - new KeyValuePair("2GM2A", null), - new KeyValuePair("CaiMiao", "https://github.com/CaiMiao"), - new KeyValuePair("Ki2317", null), - new KeyValuePair("M.cy★幻光\"", null), - new KeyValuePair("MinamiKaze", null), - new KeyValuePair("Osiris", "https://twitter.com/axiaosiris"), - new KeyValuePair("chieri", "https://github.com/laurencedu"), - new KeyValuePair("dante", null), - new KeyValuePair("hyspace", "https://github.com/hyspace"), - new KeyValuePair("logchan", "https://github.com/logchan"), - new KeyValuePair("statementreply", "https://github.com/statementreply"), - new KeyValuePair("だいずP", "https://twitter.com/DICE__game"), - new KeyValuePair("のんのん", "https://twitter.com/blueapple25130"), - new KeyValuePair("山杉", "https://twitter.com/ymsgu"), - new KeyValuePair("羽田皐月", "https://twitter.com/iinosuke01") - }; - - private bool _pageLoaded; - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/Pages/BuildPage.Commands.cs b/StarlightDirector/StarlightDirector/UI/Controls/Pages/BuildPage.Commands.cs deleted file mode 100644 index 78f205b..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/Pages/BuildPage.Commands.cs +++ /dev/null @@ -1,300 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.SQLite; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Input; -using DereTore.Common; -using DereTore.Common.StarlightStage; -using DereTore.Compression.LZ4; -using Microsoft.Win32; -using StarlightDirector.Entities; -using StarlightDirector.Entities.Extensions; -using StarlightDirector.Extensions; - -namespace StarlightDirector.UI.Controls.Pages { - partial class BuildPage { - - public static readonly ICommand CmdBuildMusicArchive = CommandHelper.RegisterCommand(); - public static readonly ICommand CmdRecheckAcbBuildEnvironment = CommandHelper.RegisterCommand(); - public static readonly ICommand CmdBuildScoreDatabase = CommandHelper.RegisterCommand(); - - private void CmdBuildMusicArchive_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Project?.HasMusic ?? false; - } - - private void CmdBuildMusicArchive_Executed(object sender, ExecutedRoutedEventArgs e) { - var selectedRecord = (LiveMusicRecord)((ComboBoxItem)CboSongList.SelectedItem).Tag; - var songName = $"song_{selectedRecord.MusicID:0000}"; - var standardFileName = $"{songName}.acb"; - var saveDialog = new SaveFileDialog { - OverwritePrompt = true, - ValidateNames = true, - Filter = Application.Current.FindResource(App.ResourceKeys.AcbFileFilter), - FileName = standardFileName - }; - var saveResult = saveDialog.ShowDialog(); - if (saveResult ?? false) { - var so = new StartOptions { - AcbFileName = saveDialog.FileName, - SongName = songName, - Key1 = CgssCipher.Key1.ToString("x8"), - Key2 = CgssCipher.Key2.ToString("x8"), - WaveFileName = Project.MusicFileName - }; - var thread = new Thread(BuildAcb) { - IsBackground = true - }; - thread.Start(so); - } - } - - private void CmdRecheckAcbBuildEnvironment_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = true; - } - - private void CmdRecheckAcbBuildEnvironment_Executed(object sender, ExecutedRoutedEventArgs e) { - AcbBuildLog.Items.Clear(); - Log(Application.Current.FindResource(App.ResourceKeys.AcbEnvironmentRechecking)); - CheckAcbBuildingEnvironment(); - } - - private void CmdBuildScoreDatabase_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = (Project?.Scores?.Count ?? 0) > 0; - } - - private void CmdBuildScoreDatabase_Executed(object sender, ExecutedRoutedEventArgs e) { - var selectedRecord = (LiveMusicRecord)((ComboBoxItem)CboSongList.SelectedItem).Tag; - var standardFileName = $"musicscores_m{selectedRecord.LiveID:000}.bdb"; - string lz4FileName = null; - if (CreateLz4CompressedBdbFile) { - lz4FileName = standardFileName + ".lz4"; - } - var saveDialog = new SaveFileDialog { - OverwritePrompt = true, - ValidateNames = true, - Filter = Application.Current.FindResource(App.ResourceKeys.BdbFileFilter), - FileName = standardFileName - }; - var saveResult = saveDialog.ShowDialog(); - if (!(saveResult ?? false)) { - return; - } - if (lz4FileName != null) { - lz4FileName = Path.Combine((new FileInfo(saveDialog.FileName)).DirectoryName ?? string.Empty, lz4FileName); - } - try { - var difficultyMappings = new Dictionary { - { Difficulty.Debut, MappingDebut }, - { Difficulty.Regular, MappingRegular }, - { Difficulty.Pro, MappingPro }, - { Difficulty.Master, MappingMaster }, - { Difficulty.MasterPlus, MappingMasterPlus } - }; - BuildBdb(Project, saveDialog.FileName, selectedRecord, difficultyMappings); - if (lz4FileName != null) { - var fileData = File.ReadAllBytes(saveDialog.FileName); - var compressedFileData = CgssLz4.Compress(fileData); - using (var compressedFileStream = File.Open(lz4FileName, FileMode.Create, FileAccess.Write)) { - compressedFileStream.WriteBytes(compressedFileData); - } - } - var format = lz4FileName == null ? - Application.Current.FindResource(App.ResourceKeys.BdbBuildingCompletePromptTemplate1) : - Application.Current.FindResource(App.ResourceKeys.BdbBuildingCompletePromptTemplate2); - var message = string.IsNullOrEmpty(lz4FileName) ? string.Format(format, saveDialog.FileName) : string.Format(format, saveDialog.FileName, lz4FileName); - MessageBox.Show(message, App.Title, MessageBoxButton.OK, MessageBoxImage.Information); - } catch (Exception ex) { - MessageBox.Show(ex.Message, App.Title, MessageBoxButton.OK, MessageBoxImage.Exclamation); - } - } - - private static void BuildBdb(Project project, string bdbFileName, LiveMusicRecord record, Dictionary difficultyMappings) { - var connectionString = $"Data Source={bdbFileName}"; - if (File.Exists(bdbFileName)) { - File.Delete(bdbFileName); - } else { - SQLiteConnection.CreateFile(bdbFileName); - } - using (var connection = new SQLiteConnection(connectionString)) { - connection.Open(); - using (var transaction = connection.BeginTransaction()) { - SQLiteCommand command; - using (command = transaction.Connection.CreateCommand()) { - command.CommandText = "CREATE TABLE blobs (name TEXT PRIMARY KEY, data BLOB NOT NULL);"; - command.ExecuteNonQuery(); - } - using (command = transaction.Connection.CreateCommand()) { - command.CommandText = "INSERT INTO blobs (name, data) VALUES (@name, @data);"; - var nameParam = command.Parameters.Add("name", DbType.AnsiString); - var dataParam = command.Parameters.Add("data", DbType.Binary); - // update: Create Master+ entry, regardless of its existence in original BDB. - for (var i = (int)Difficulty.Debut; i <= (int)Difficulty.MasterPlus; ++i) { - var entryDifficulty = (Difficulty)i; - var userDifficulty = difficultyMappings[entryDifficulty]; - var score = project.GetScore(userDifficulty); - var compiledScore = score.Compile(); - var csv = compiledScore.GetCsvString(); - var csvData = Encoding.ASCII.GetBytes(csv); - nameParam.Value = string.Format(ScoreRecordFormat, record.LiveID, i); - dataParam.Value = csvData; - command.ExecuteNonQuery(); - } - nameParam.Value = string.Format(Score2DCharaFormat, record.LiveID); - dataParam.Value = Encoding.ASCII.GetBytes(Score2DCharaText); - command.ExecuteNonQuery(); - nameParam.Value = string.Format(ScoreCyalumeFormat, record.LiveID); - dataParam.Value = Encoding.ASCII.GetBytes(ScoreCyalumeText); - command.ExecuteNonQuery(); - nameParam.Value = string.Format(ScoreLyricsFormat, record.LiveID); - dataParam.Value = Encoding.ASCII.GetBytes(ScoreLyricsText); - command.ExecuteNonQuery(); - } - transaction.Commit(); - } - connection.Close(); - } - } - - private void BuildAcb(object paramObject) { - var options = (StartOptions)paramObject; - string temp1 = null, temp2 = null; - try { - int code; - var startInfo = new ProcessStartInfo(); - startInfo.WindowStyle = ProcessWindowStyle.Hidden; - - Log("Encoding HCA..."); - startInfo.FileName = "hcaenc.exe"; - temp1 = Path.GetTempFileName(); - Log($"Target: {temp1}"); - startInfo.Arguments = GetArgsString(SanitizeString(options.WaveFileName), SanitizeString(temp1)); - using (var proc = Process.Start(startInfo)) { - proc.WaitForExit(); - code = proc.ExitCode; - } - if (code != 0) { - LogError($"hcaenc exited with code {code}."); - if (File.Exists(temp1)) { - File.Delete(temp1); - } - EnableAcbBuildButton(true); - return; - } - Log("Encoding finished."); - - Log("Converting HCA..."); - if (options.Key1.Length > 0 && options.Key2.Length > 0) { - startInfo.FileName = "hcacc.exe"; - temp2 = Path.GetTempFileName(); - Log($"Target: {temp2}"); - startInfo.Arguments = GetArgsString(SanitizeString(temp1), SanitizeString(temp2), "-ot", "56", "-o1", options.Key1, "-o2", options.Key2); - using (var proc = Process.Start(startInfo)) { - proc.WaitForExit(); - code = proc.ExitCode; - } - if (code != 0) { - LogError($"hcacc exited with code {code}."); - if (File.Exists(temp1)) { - File.Delete(temp1); - } - if (File.Exists(temp2)) { - File.Delete(temp2); - } - EnableAcbBuildButton(true); - return; - } - Log("Conversion finished."); - } else { - temp2 = temp1; - Log("Unnecessary."); - } - - Log("Packing ACB..."); - startInfo.FileName = "AcbMaker.exe"; - Log($"Target: {options.AcbFileName}"); - startInfo.Arguments = GetArgsString(SanitizeString(temp2), SanitizeString(options.AcbFileName), "-n", options.SongName); - using (var proc = Process.Start(startInfo)) { - proc.WaitForExit(); - code = proc.ExitCode; - } - if (code != 0) { - LogError($"AcbMaker exited with code {code}."); - if (File.Exists(temp1)) { - File.Delete(temp1); - } - if (File.Exists(temp2)) { - File.Delete(temp2); - } - EnableAcbBuildButton(true); - return; - } - Log("ACB packing finished."); - if (File.Exists(temp1)) { - File.Delete(temp1); - } - if (File.Exists(temp2)) { - File.Delete(temp2); - } - } catch (Exception ex) when (!(ex is ThreadAbortException)) { - MessageBox.Show(ex.Message, App.Title, MessageBoxButton.OK, MessageBoxImage.Error); - } finally { - if (temp1 != null && File.Exists(temp1)) { - File.Delete(temp1); - } - if (temp2 != null && File.Exists(temp2)) { - File.Delete(temp2); - } - EnableAcbBuildButton(true); - } - } - - private static readonly string ScoreRecordFormat = "musicscores/m{0:000}/{0}_{1}.csv"; - private static readonly string Score2DCharaFormat = "musicscores/m{0:000}/m{0:000}_2dchara.csv"; - private static readonly string ScoreCyalumeFormat = "musicscores/m{0:000}/m{0:000}_cyalume.csv"; - private static readonly string ScoreLyricsFormat = "musicscores/m{0:000}/m{0:000}_lyrics.csv"; - private static readonly string Score2DCharaText = "0.03333,1,w1,,\n0.03333,2,w1,,\n0.03333,3,w1,,\n0.03333,4,w1,,\n0.03333,5,w1,,\n0.03333,MOT_mc_bg_black_00,seat100-0,,"; - private static readonly string ScoreCyalumeText = "time,move_type,BPM,color_pattern,color1,color2,color3,color4,color5,width1,width2,width3,width4,width5,3D_move_type,3D_BPM\n0,Uhoi,5,Random3,Pink01,Blue01,Yellow01,,,,,,,,Uhoi,5"; - private static readonly string ScoreLyricsText = "time,lyrics,size\n0,,"; - - private static readonly char[] CommandlineEscapeChars = { ' ', '&', '%', '#', '@', '!', ',', '~', '+', '=', '(', ')' }; - private readonly Action _logDelegate; - private readonly Action _enableAcbBuildButtoDelegate; - - private static string GetArgsString(params string[] args) { - return args.Aggregate((total, next) => total + " " + next); - } - - private static string SanitizeString(string s) { - var shouldCoverWithQuotes = false; - if (s.IndexOf('"') >= 0) { - s = s.Replace("\"", "\"\"\""); - shouldCoverWithQuotes = true; - } - if (s.IndexOfAny(CommandlineEscapeChars) >= 0) { - shouldCoverWithQuotes = true; - } - if (s.Any(c => c > 127)) { - shouldCoverWithQuotes = true; - } - return shouldCoverWithQuotes ? "\"" + s + "\"" : s; - } - - private sealed class StartOptions { - - public string WaveFileName { get; set; } - public string Key1 { get; set; } - public string Key2 { get; set; } - public string AcbFileName { get; set; } - public string SongName { get; set; } - - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/Pages/BuildPage.DependencyProperties.cs b/StarlightDirector/StarlightDirector/UI/Controls/Pages/BuildPage.DependencyProperties.cs deleted file mode 100644 index 6b7430b..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/Pages/BuildPage.DependencyProperties.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System.Windows; -using StarlightDirector.Entities; - -namespace StarlightDirector.UI.Controls.Pages { - partial class BuildPage { - - public Project Project { - get { return (Project)GetValue(ProjectProperty); } - internal set { SetValue(ProjectProperty, value); } - } - - public bool CreateLz4CompressedBdbFile { - get { return (bool)GetValue(CreateLz4CompressedBdbFileProperty); } - private set { SetValue(CreateLz4CompressedBdbFileProperty, value); } - } - - public bool IsAcbBuildingEnvironmentOK { - get { return (bool)GetValue(IsAcbBuildingEnvironmentOKProperty); } - private set { SetValue(IsAcbBuildingEnvironmentOKProperty, value); } - } - - public Difficulty MappingDebut { - get { return (Difficulty)GetValue(MappingDebutProperty); } - private set { SetValue(MappingDebutProperty, value); } - } - - public Difficulty MappingRegular { - get { return (Difficulty)GetValue(MappingRegularProperty); } - private set { SetValue(MappingRegularProperty, value); } - } - - public Difficulty MappingPro { - get { return (Difficulty)GetValue(MappingProProperty); } - private set { SetValue(MappingProProperty, value); } - } - - public Difficulty MappingMaster { - get { return (Difficulty)GetValue(MappingMasterProperty); } - private set { SetValue(MappingMasterProperty, value); } - } - - public Difficulty MappingMasterPlus { - get { return (Difficulty)GetValue(MappingMasterPlusProperty); } - private set { SetValue(MappingMasterPlusProperty, value); } - } - - public static readonly DependencyProperty ProjectProperty = DependencyProperty.Register(nameof(Project), typeof(Project), typeof(BuildPage), - new PropertyMetadata(null)); - - public static readonly DependencyProperty CreateLz4CompressedBdbFileProperty = DependencyProperty.Register(nameof(CreateLz4CompressedBdbFile), typeof(bool), typeof(BuildPage), - new PropertyMetadata(false)); - - public static readonly DependencyProperty IsAcbBuildingEnvironmentOKProperty = DependencyProperty.Register(nameof(IsAcbBuildingEnvironmentOK), typeof(bool), typeof(BuildPage), - new PropertyMetadata(false)); - - public static readonly DependencyProperty MappingDebutProperty = DependencyProperty.Register(nameof(MappingDebut), typeof(Difficulty), typeof(BuildPage), - new PropertyMetadata(Difficulty.Debut)); - - public static readonly DependencyProperty MappingRegularProperty = DependencyProperty.Register(nameof(MappingRegular), typeof(Difficulty), typeof(BuildPage), - new PropertyMetadata(Difficulty.Debut)); - - public static readonly DependencyProperty MappingProProperty = DependencyProperty.Register(nameof(MappingPro), typeof(Difficulty), typeof(BuildPage), - new PropertyMetadata(Difficulty.Debut)); - - public static readonly DependencyProperty MappingMasterProperty = DependencyProperty.Register(nameof(MappingMaster), typeof(Difficulty), typeof(BuildPage), - new PropertyMetadata(Difficulty.Debut)); - - public static readonly DependencyProperty MappingMasterPlusProperty = DependencyProperty.Register(nameof(MappingMasterPlus), typeof(Difficulty), typeof(BuildPage), - new PropertyMetadata(Difficulty.Debut)); - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/Pages/BuildPage.LiveMusicRecord.cs b/StarlightDirector/StarlightDirector/UI/Controls/Pages/BuildPage.LiveMusicRecord.cs deleted file mode 100644 index 39d3976..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/Pages/BuildPage.LiveMusicRecord.cs +++ /dev/null @@ -1,17 +0,0 @@ -using StarlightDirector.Entities.Gaming; - -namespace StarlightDirector.UI.Controls.Pages { - partial class BuildPage { - - private class LiveMusicRecord { - - public int LiveID { get; set; } - public int MusicID { get; set; } - public string MusicName { get; set; } - public bool[] DifficultyExists { get; internal set; } - public MusicAttribute Attribute { get; set; } - - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/Pages/BuildPage.xaml b/StarlightDirector/StarlightDirector/UI/Controls/Pages/BuildPage.xaml deleted file mode 100644 index 1a8c7bb..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/Pages/BuildPage.xaml +++ /dev/null @@ -1,199 +0,0 @@ - - - - - - - - - - - - - - - - Build - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/StarlightDirector/StarlightDirector/UI/Controls/Primitives/SpecialNotePointer.xaml.cs b/StarlightDirector/StarlightDirector/UI/Controls/Primitives/SpecialNotePointer.xaml.cs deleted file mode 100644 index c70e372..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/Primitives/SpecialNotePointer.xaml.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Windows; -using StarlightDirector.Extensions; - -namespace StarlightDirector.UI.Controls.Primitives { - public partial class SpecialNotePointer { - - public SpecialNotePointer() { - InitializeComponent(); - CommandHelper.InitializeCommandBindings(this); - } - - private void SetEditingState(bool editing) { - BpmDisplay.Visibility = editing ? Visibility.Collapsed : Visibility.Visible; - BpmEditor.Visibility = editing ? Visibility.Visible : Visibility.Collapsed; - _isEditing = editing; - } - - private void Note_ExtraParamsChanged(object sender, EventArgs e) { - var editor = this.FindVisualParent(); - editor?.UpdateBarTexts(); - } - - private bool _isEditing; - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.DependencyProperties.cs b/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.DependencyProperties.cs deleted file mode 100644 index 0fccab2..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.DependencyProperties.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System.Windows; -using System.Windows.Controls; -using System.Windows.Input; -using StarlightDirector.Entities; - -namespace StarlightDirector.UI.Controls { - partial class ScoreEditor { - - public EditMode EditMode { - get { return (EditMode)GetValue(EditModeProperty); } - set { SetValue(EditModeProperty, value); } - } - - public Project Project { - get { return (Project)GetValue(ProjectProperty); } - set { SetValue(ProjectProperty, value); } - } - - public TextBlock NoteInfoBlock { - get { return (TextBlock)GetValue(NoteInfoBlockProperty); } - set { SetValue(NoteInfoBlockProperty, value); } - } - - public ContextMenu ExtraNotesContextMenu { - get { return (ContextMenu)GetValue(ExtraNotesContextMenuProperty); } - set { SetValue(ExtraNotesContextMenuProperty, value); } - } - - public static readonly DependencyProperty EditModeProperty = DependencyProperty.Register(nameof(EditMode), typeof(EditMode), typeof(ScoreEditor), - new PropertyMetadata(EditMode.CreateRelations)); - - public static readonly DependencyProperty ProjectProperty = DependencyProperty.Register(nameof(Project), typeof(Project), typeof(ScoreEditor), - new PropertyMetadata(null, OnProjectChanged)); - - public static readonly DependencyProperty NoteInfoBlockProperty = DependencyProperty.Register(nameof(NoteInfoBlock), typeof(TextBlock), typeof(ScoreEditor), - new PropertyMetadata(null)); - - public static readonly DependencyProperty ExtraNotesContextMenuProperty = DependencyProperty.Register(nameof(ExtraNotesContextMenu), typeof(ContextMenu), typeof(ScoreEditor), - new PropertyMetadata(null, OnExtraNotesContextMenuChanged)); - - private static void OnProjectChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { - var editor = (ScoreEditor)obj; - var oldproject = (Project)e.OldValue; - var newProject = (Project)e.NewValue; - if (oldproject != null) { - oldproject.GlobalSettingsChanged -= editor.OnScoreGlobalSettingsChanged; - } - if (newProject != null) { - newProject.GlobalSettingsChanged += editor.OnScoreGlobalSettingsChanged; - } - CommandManager.InvalidateRequerySuggested(); - } - - private static void OnExtraNotesContextMenuChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { - var editor = (ScoreEditor)obj; - editor.SpecialNoteLayer.ContextMenu = (ContextMenu)e.NewValue; - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.Editing.cs b/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.Editing.cs deleted file mode 100644 index 1f784a0..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.Editing.cs +++ /dev/null @@ -1,333 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using StarlightDirector.Entities; -using StarlightDirector.UI.Controls.Primitives; - -namespace StarlightDirector.UI.Controls { - partial class ScoreEditor { - - public ScoreBar AppendScoreBar() { - return AddScoreBar(null, true, null); - } - - public ScoreBar[] AppendScoreBars(int count) { - var added = new List(); - for (var i = 0; i < count; ++i) { - added.Add(AddScoreBar(null, false, null)); - } - UpdateBarTexts(); - RecalcEditorLayout(); - return added.ToArray(); - } - - public ScoreBar InsertScoreBar(ScoreBar before) { - return AddScoreBar(before, true, null); - } - - public ScoreBar[] InsertScoreBars(ScoreBar before, int count) { - var added = new List(); - for (var i = 0; i < count; ++i) { - added.Add(AddScoreBar(before, false, null)); - } - UpdateBarTexts(); - RecalcEditorLayout(); - return added.ToArray(); - } - - public void RemoveScoreBar(ScoreBar scoreBar) { - RemoveScoreBar(scoreBar, true, true); - } - - public void RemoveScoreBars(IEnumerable scoreBars) { - RemoveScoreBars(scoreBars, true, true); - } - - public ScoreNote AddScoreNote(ScoreBar scoreBar, int row, NotePosition position) { - return AddScoreNote(scoreBar, row, (int)position - 1, null); - } - - public void RemoveScoreNote(ScoreNote scoreNote) { - RemoveScoreNote(scoreNote, true, true); - } - - public void RemoveScoreNotes(IEnumerable scoreNotes) { - RemoveScoreNotes(scoreNotes, true, true); - } - - public SpecialNotePointer AddSpecialNote(ScoreBar scoreBar, ScoreBarHitTestInfo info, bool isFromPrevBar, NoteType type) { - if (!info.IsInNextBar) { - var row = info.Row; - if (isFromPrevBar && row < 0) { - row = 0; - } - return AddSpecialNote(scoreBar, row, type); - } - if (isFromPrevBar) { - return null; - } - var nextBar = ScoreBars.FirstOrDefault(b => b.Bar.Index > scoreBar.Bar.Index); - if (nextBar == null) { - return null; - } - var point = scoreBar.TranslatePoint(info.HitPoint, nextBar); - return AddSpecialNote(nextBar, nextBar.HitTest(point), true, type); - } - - public SpecialNotePointer AddSpecialNote(ScoreBar scoreBar, int row, NoteType type) { - return AddSpecialNote(scoreBar, row, type, null, true); - } - - public bool RemoveSpecialNote(SpecialNotePointer specialNotePointer) { - return RemoveSpecialNote(specialNotePointer, true); - } - - private ScoreNote AddScoreNote(ScoreBar scoreBar, int row, NotePosition column, Note dataTemplate) { - return AddScoreNote(scoreBar, row, (int)column - 1, dataTemplate); - } - - private ScoreNote AddScoreNote(ScoreBar scoreBar, int row, int column, Note dataTemplate) { - if (row < 0 || column < 0 || column >= 5) { - return null; - } - var gridCount = scoreBar.Bar.TotalGridCount; - if (row >= gridCount) { - return null; - } - var bar = scoreBar.Bar; - var scoreNote = AnyNoteExistOnPosition(bar.Index, column, row); - if (scoreNote != null) { - return null; - } - var barHeight = ScoreBars[0].Height; - var baseY = -MinimumScrollOffset + bar.Index * barHeight; - var extraY = barHeight * row / bar.TotalGridCount; - scoreNote = new ScoreNote(); - Note note; - if (dataTemplate != null) { - note = dataTemplate; - } else { - note = bar.AddNote(); - note.StartPosition = note.FinishPosition = (NotePosition)(column + 1); - note.IndexInGrid = row; - note.FixSync(); - } - scoreNote.Note = note; - EditableScoreNotes.Add(scoreNote); - NoteLayer.Children.Add(scoreNote); - scoreNote.X = NoteLayer.ActualWidth * (TrackCenterXPositions[column] - TrackCenterXPositions[0]) / (TrackCenterXPositions[4] - TrackCenterXPositions[0]); - scoreNote.Y = baseY + extraY; - scoreNote.MouseDown += ScoreNote_MouseDown; - scoreNote.MouseUp += ScoreNote_MouseUp; - scoreNote.MouseDoubleClick += ScoreNote_MouseDoubleClick; - scoreNote.MouseEnter += ScoreNote_MouseEnter; - scoreNote.MouseLeave += ScoreNote_MouseLeave; - if (dataTemplate == null) { - Project.IsChanged = true; - } - return scoreNote; - } - - private ScoreNote AddScoreNote(ScoreBar scoreBar, ScoreBarHitTestInfo info, bool isFromPrevBar, Note dataTemplate) { - if (info.IsInNextBar) { - if (isFromPrevBar) { - return null; - } - var nextBar = ScoreBars.FirstOrDefault(b => b.Bar.Index > scoreBar.Bar.Index); - if (nextBar == null) { - return null; - } - var point = scoreBar.TranslatePoint(info.HitPoint, nextBar); - return AddScoreNote(nextBar, nextBar.HitTest(point), true, dataTemplate); - } - var row = info.Row; - if (isFromPrevBar && row < 0) { - row = 0; - } - if (!info.IsValid || row < 0 || info.Column < 0) { - return null; - } - return AddScoreNote(scoreBar, row, info.Column, dataTemplate); - } - - private void RemoveScoreNote(ScoreNote scoreNote, bool modifiesModel, bool repositionLines) { - if (!ScoreNotes.Contains(scoreNote)) { - throw new ArgumentException("Invalid ScoreNote.", nameof(scoreNote)); - } - scoreNote.MouseDown -= ScoreNote_MouseDown; - scoreNote.MouseUp -= ScoreNote_MouseUp; - scoreNote.MouseDoubleClick -= ScoreNote_MouseDoubleClick; - scoreNote.MouseEnter -= ScoreNote_MouseEnter; - scoreNote.MouseLeave -= ScoreNote_MouseLeave; - scoreNote.ContextMenu = null; - EditableScoreNotes.Remove(scoreNote); - LineLayer.NoteRelations.RemoveAll(scoreNote); - if (modifiesModel) { - var note = scoreNote.Note; - if (Score.Bars.Contains(note.Bar)) { - // Remove note from sync group - // See Note.RemoveSync() - if (note.HasPrevSync && note.HasNextSync) { - var prevNote = note.PrevSyncTarget; - var nextNote = note.NextSyncTarget; - var prevScoreNote = FindScoreNote(prevNote); - var nextScoreNote = FindScoreNote(nextNote); - LineLayer.NoteRelations.Add(prevScoreNote, nextScoreNote, NoteRelation.Sync); - } - note.RemoveSync(); - // The Reset() call is necessary. - note.Reset(); - note.Bar.RemoveNote(note); - } - } - NoteLayer.Children.Remove(scoreNote); - // TODO: Query if there is a need to do that. - if (repositionLines) { - RepositionLineLayer(); - } - if (modifiesModel) { - Project.IsChanged = true; - } - } - - private void RemoveScoreNotes(IEnumerable scoreNotes, bool modifiesModel, bool recalcLayout) { - // Avoid 'the collection has been modified' exception. - var backup = scoreNotes.ToArray(); - foreach (var scoreNote in backup) { - RemoveScoreNote(scoreNote, modifiesModel, false); - } - if (recalcLayout) { - RepositionLineLayer(); - } - if (modifiesModel) { - Project.IsChanged = true; - } - } - - private ScoreBar AddScoreBar(ScoreBar before, bool recalculateLayout, Bar dataTemplate) { - var project = Project; - Debug.Assert(project != null, "project != null"); - var score = Score; - var bar = dataTemplate ?? (before == null ? score.AddBar() : score.InsertBar(before.Bar.Index)); - if (bar == null) { - return null; - } - var scoreBar = new ScoreBar(); - scoreBar.Bar = bar; - if (ScoreBars.Count == 0) { - scoreBar.Height = ScoreBar.DefaultHeight; - } else { - scoreBar.Height = ScoreBars[0].Height; - } - scoreBar.MouseUp += ScoreBar_MouseUp; - scoreBar.MouseDown += ScoreBar_MouseDown; - if (before == null) { - BarLayer.Children.Add(scoreBar); - EditableScoreBars.Add(scoreBar); - } else { - BarLayer.Children.Add(scoreBar); - EditableScoreBars.Insert(ScoreBars.IndexOf(before), scoreBar); - } - if (recalculateLayout) { - UpdateBarTexts(); - RecalcEditorLayout(); - } - if (dataTemplate == null) { - Project.IsChanged = true; - } - return scoreBar; - } - - private void RemoveScoreBar(ScoreBar scoreBar, bool modifiesModel, bool recalcLayout) { - if (!ScoreBars.Contains(scoreBar)) { - throw new ArgumentException("Invalid ScoreBar.", nameof(scoreBar)); - } - scoreBar.MouseUp -= ScoreBar_MouseUp; - scoreBar.MouseDown -= ScoreBar_MouseDown; - if (modifiesModel) { - Score.RemoveBarAt(scoreBar.Bar.Index); - } - EditableScoreBars.Remove(scoreBar); - BarLayer.Children.Remove(scoreBar); - TrimScoreNotes(scoreBar, modifiesModel); - if (recalcLayout) { - UpdateBarTexts(); - RecalcEditorLayout(); - } - if (modifiesModel) { - Project.IsChanged = true; - } - } - - private void RemoveScoreBars(IEnumerable scoreBars, bool modifiesModel, bool recalcLayout) { - var backup = scoreBars.ToArray(); - foreach (var scoreBar in backup) { - RemoveScoreBar(scoreBar, modifiesModel, false); - } - if (recalcLayout) { - UpdateBarTexts(); - RecalcEditorLayout(); - } - if (modifiesModel) { - Project.IsChanged = true; - } - } - - private SpecialNotePointer AddSpecialNote(ScoreBar scoreBar, int row, NoteType type, Note dataTemplate, bool updateBarText) { - if (!Note.IsTypeSpecial(type)) { - throw new ArgumentOutOfRangeException(nameof(type)); - } - var existingNote = scoreBar.Bar.Notes.SingleOrDefault(n => n.Type == type && n.IndexInGrid == row); - if (existingNote != null) { - if (dataTemplate == null) { - // Manual editing, not from a ReloadScore() call. - return SpecialScoreNotes.First(sn => sn.Note.Equals(existingNote)); - } - } - var specialNotePointer = new SpecialNotePointer(); - EditableSpecialScoreNotes.Add(specialNotePointer); - SpecialNoteLayer.Children.Add(specialNotePointer); - var bar = scoreBar.Bar; - Note note; - if (dataTemplate == null) { - note = bar.AddNote(); - note.IndexInGrid = row; - note.SetSpecialType(type); - note.ExtraParams = new NoteExtraParams { - Note = note - }; - } else { - // We assume that this *is* a special note. After all this method is private. - note = dataTemplate; - } - specialNotePointer.Note = note; - var barHeight = ScoreBars[0].Height; - var baseY = -MinimumScrollOffset + bar.Index * barHeight; - var extraY = barHeight * row / bar.TotalGridCount; - specialNotePointer.Y = baseY + extraY; - Project.IsChanged = true; - if (updateBarText) { - UpdateBarTexts(); - } - return specialNotePointer; - } - - private bool RemoveSpecialNote(SpecialNotePointer specialNotePointer, bool updateBarText) { - var exists = SpecialScoreNotes.Contains(specialNotePointer); - if (!exists) { - return false; - } - var note = specialNotePointer.Note; - note.Bar.RemoveNote(note); - SpecialNoteLayer.Children.Remove(specialNotePointer); - Project.IsChanged = true; - var b = EditableSpecialScoreNotes.Remove(specialNotePointer); - if (updateBarText) { - UpdateBarTexts(); - } - return b; - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.EventHandlers.cs b/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.EventHandlers.cs deleted file mode 100644 index 2b26413..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.EventHandlers.cs +++ /dev/null @@ -1,328 +0,0 @@ -using System; -using System.Diagnostics; -using System.Linq; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using DereTore.Common; -using StarlightDirector.Entities; -using StarlightDirector.Entities.Extensions; -using StarlightDirector.Extensions; -using StarlightDirector.UI.Controls.Primitives; - -namespace StarlightDirector.UI.Controls { - partial class ScoreEditor { - - private void BarLayer_OnSizeChanged(object sender, SizeChangedEventArgs e) { - ResizeBars(); - RepositionBars(); - } - - private void NoteLayer_OnSizeChanged(object sender, SizeChangedEventArgs e) { - RepositionNotes(); - // We have to be sure the lines reposition after the notes did. - RepositionLineLayer(); - } - - private void ScoreBar_MouseUp(object sender, MouseButtonEventArgs e) { - var scoreBar = (ScoreBar)sender; - var hitTestInfo = scoreBar.HitTest(e.GetPosition(scoreBar)); - if (e.ChangedButton == MouseButton.Left) { - if (hitTestInfo.IsValid) { - var scoreNote = AddScoreNote(scoreBar, hitTestInfo, false, null); - if (scoreNote != null) { - var note = scoreNote.Note; - if (note.IsSync) { - ScoreNote prevScoreNote = null; - ScoreNote nextScoreNote = null; - if (note.HasPrevSync) { - var prevNote = note.PrevSyncTarget; - prevScoreNote = FindScoreNote(prevNote); - LineLayer.NoteRelations.Add(scoreNote, prevScoreNote, NoteRelation.Sync); - } - if (note.HasNextSync) { - var nextNote = note.NextSyncTarget; - nextScoreNote = FindScoreNote(nextNote); - LineLayer.NoteRelations.Add(scoreNote, nextScoreNote, NoteRelation.Sync); - } - if (note.HasPrevSync && note.HasNextSync) { - LineLayer.NoteRelations.Remove(prevScoreNote, nextScoreNote); - } - LineLayer.InvalidateVisual(); - } - } - } else { - UnselectAllScoreNotes(); - SelectScoreBar(scoreBar); - } - e.Handled = true; - } else { - if (HasSelectedScoreNotes) { - UnselectAllScoreNotes(); - e.Handled = true; - } - } - } - - private void ScoreBar_MouseDown(object sender, MouseButtonEventArgs e) { - e.Handled = true; - } - - private void ScoreNote_MouseDown(object sender, MouseButtonEventArgs e) { - if (e.ChangedButton != MouseButton.Left) { - e.Handled = true; - return; - } - var scoreNote = (ScoreNote)sender; - var isControlPressed = Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl); - if (isControlPressed) { - scoreNote.IsSelected = !scoreNote.IsSelected; - } else { - var originalSelected = scoreNote.IsSelected; - var originalMoreThanOneSelectedNotes = GetSelectedScoreNotes().CountMoreThan(1); - UnselectAllScoreNotes(); - // !originalSelected || (originalSelected && originalAnySelectedNotes) - if (!originalSelected || originalMoreThanOneSelectedNotes) { - scoreNote.IsSelected = true; - } - } - if (scoreNote.IsSelected && EditMode != EditMode.ResetNote) { - switch (EditMode) { - case EditMode.CreateRelations: - EditingLine.Stroke = LineLayer.RelationBrush; - break; - default: - throw new ArgumentOutOfRangeException(nameof(EditMode)); - } - EditingLine.X1 = EditingLine.X2 = scoreNote.X; - EditingLine.Y1 = EditingLine.Y2 = scoreNote.Y; - EditingLine.Visibility = Visibility.Visible; - } - var note = scoreNote.Note; - var barIndex = note.Bar.Index; - var row = note.IndexInGrid; - var column = note.IndexInTrack; - Debug.Print($"Note @ bar#{barIndex}, row={row}, column={column}"); - DraggingStartNote = scoreNote; - // Prevent broadcasting this event to ScoreEditor. - e.Handled = true; - } - - private void ScoreNote_MouseUp(object sender, MouseButtonEventArgs e) { - if (e.ChangedButton != MouseButton.Left) { - UnselectAllScoreNotes(); - e.Handled = true; - return; - } - DraggingEndNote = sender as ScoreNote; - Debug.Assert(DraggingEndNote != null, "DraggingEndNote != null"); - if (DraggingStartNote != null && DraggingEndNote != null) { - var mode = EditMode; - var start = DraggingStartNote; - var end = DraggingEndNote; - var ns = start.Note; - var ne = end.Note; - if (mode == EditMode.ResetNote) { - ns.Reset(); - LineLayer.NoteRelations.RemoveAll(start, NoteRelation.Hold); - LineLayer.NoteRelations.RemoveAll(start, NoteRelation.FlickOrSlide); - if (!start.Equals(end)) { - ne.Reset(); - LineLayer.NoteRelations.RemoveAll(end, NoteRelation.Hold); - LineLayer.NoteRelations.RemoveAll(end, NoteRelation.FlickOrSlide); - } - LineLayer.InvalidateVisual(); - Project.IsChanged = true; - } else if (!start.Equals(end)) { - if (LineLayer.NoteRelations.ContainsPair(start, end)) { - MessageBox.Show(Application.Current.FindResource(App.ResourceKeys.NoteRelationAlreadyExistsPrompt), App.Title, MessageBoxButton.OK, MessageBoxImage.Exclamation); - return; - } - if (mode != EditMode.CreateRelations) { - throw new ArgumentOutOfRangeException(nameof(mode)); - } - var first = ns < ne ? ns : ne; - var second = first.Equals(ns) ? ne : ns; - if (ns.Bar == ne.Bar && ns.IndexInGrid == ne.IndexInGrid && !ns.IsSync && !ne.IsSync) { - // sync - Note.ConnectSync(ns, ne); - LineLayer.NoteRelations.Add(start, end, NoteRelation.Sync); - LineLayer.InvalidateVisual(); - } else if (ns.FinishPosition != ne.FinishPosition && (ns.Bar != ne.Bar || ns.IndexInGrid != ne.IndexInGrid) && (!ns.IsHoldStart && !ne.IsHoldStart) && (first.IsSlide == second.IsSlide)) { - // flick - if (first.HasNextFlickOrSlide || second.HasPrevFlickOrSlide) { - MessageBox.Show(Application.Current.FindResource(App.ResourceKeys.FlickRelationIsFullPrompt), App.Title, MessageBoxButton.OK, MessageBoxImage.Exclamation); - return; - } - Note.ConnectFlick(first, second); - LineLayer.NoteRelations.Add(start, end, NoteRelation.FlickOrSlide); - LineLayer.InvalidateVisual(); - } else if (ns.FinishPosition == ne.FinishPosition && !ns.IsHold && !ne.IsHold && !first.IsFlick && !first.IsSlide && !second.IsSlide) { - // hold - var anyObstacles = Score.Notes.AnyNoteBetween(ns, ne); - if (anyObstacles) { - MessageBox.Show(Application.Current.FindResource(App.ResourceKeys.InvalidHoldCreationPrompt), App.Title, MessageBoxButton.OK, MessageBoxImage.Exclamation); - return; - } - Note.ConnectHold(ns, ne); - LineLayer.NoteRelations.Add(start, end, NoteRelation.Hold); - LineLayer.InvalidateVisual(); - } else { - DraggingStartNote = DraggingEndNote = null; - e.Handled = true; - return; - } - - Project.IsChanged = true; - end.IsSelected = true; - } - } - DraggingStartNote = DraggingEndNote = null; - e.Handled = true; - } - - private void ScoreNote_MouseDoubleClick(object sender, MouseButtonEventArgs e) { - if (e.ChangedButton != MouseButton.Left) { - e.Handled = true; - return; - } - var scoreNote = (ScoreNote)sender; - var note = scoreNote.Note; - if (note.IsHoldEnd || note.IsSlideEnd) { - switch (note.FlickType) { - case NoteFlickType.Tap: - note.FlickType = NoteFlickType.FlickLeft; - Project.IsChanged = true; - break; - case NoteFlickType.FlickLeft: - note.FlickType = NoteFlickType.FlickRight; - Project.IsChanged = true; - break; - case NoteFlickType.FlickRight: - note.FlickType = NoteFlickType.Tap; - Project.IsChanged = true; - break; - default: - throw new ArgumentOutOfRangeException(nameof(note.FlickType)); - } - } - e.Handled = true; - } - - private void ScoreNote_MouseEnter(object sender, MouseEventArgs e) { - var block = NoteInfoBlock; - if (block == null) { - return; - } - var scoreNote = (ScoreNote)sender; - var note = scoreNote.Note; - - block.Inlines.Add($"ID: {note.ID}"); - block.Inlines.Add(new LineBreak()); - block.Inlines.Add($"Timing: {note.HitTiming:0.000000}s"); - - string noteTypeString; - if (note.IsTap) { - noteTypeString = "Tap"; - } else if (note.IsFlick) { - noteTypeString = "Flick"; - } else if (note.IsHold) { - noteTypeString = "Hold"; - } else if (note.IsSlide) { - noteTypeString = "Slide"; - if (note.IsSlideStart) { - noteTypeString += " (start)"; - } else if (note.IsSlideContinuation) { - noteTypeString += " (continued)"; - } else if (note.IsSlideEnd) { - noteTypeString += " (end)"; - } - } else { - noteTypeString = "#ERR"; - } - string noteExtra = null; - if (note.IsSync || note.IsHoldEnd) { - var syncStr = note.IsSync ? "sync" : null; - var holdEndStr = note.IsHoldEnd ? "hold-end" : null; - var extras = new[] { syncStr, holdEndStr }; - noteExtra = extras.Aggregate((prev, val) => { - if (string.IsNullOrEmpty(prev)) { - return val; - } - if (string.IsNullOrEmpty(val)) { - return prev; - } - return prev + ", " + val; - }); - } - var flickStr = note.FlickType != NoteFlickType.Tap ? (note.FlickType == NoteFlickType.FlickLeft ? "left" : "right") : null; - block.Inlines.Add(new LineBreak()); - block.Inlines.Add($"Type: {noteTypeString}"); - if (!string.IsNullOrEmpty(noteExtra)) { - block.Inlines.Add(new LineBreak()); - block.Inlines.Add(noteExtra); - } - if (!string.IsNullOrEmpty(flickStr)) { - block.Inlines.Add(new LineBreak()); - block.Inlines.Add($"Flick: {flickStr}"); - } - - block.Inlines.Add(new LineBreak()); - block.Inlines.Add($"Start: {(int)note.StartPosition}"); - block.Inlines.Add(new LineBreak()); - block.Inlines.Add($"Finish: {(int)note.FinishPosition}"); - } - - private void ScoreNote_MouseLeave(object sender, MouseEventArgs e) { - NoteInfoBlock?.Inlines.Clear(); - } - - private void ScoreEditor_OnMouseDown(object sender, MouseButtonEventArgs e) { - UnselectAllScoreNotes(); - UnselectAllScoreBars(); - } - - private void ScoreEditor_OnMouseUp(object sender, MouseButtonEventArgs e) { - DraggingStartNote = DraggingEndNote = null; - if (e.ChangedButton == MouseButton.Right) { - var myPosition = e.GetPosition(this); - var result = VisualTreeHelper.HitTest(this, myPosition); - var element = result.VisualHit as FrameworkElement; - element = element?.FindVisualParent(); - if (element != null) { - var hitTestInfo = ((ScoreBar)element).HitTest(e.GetPosition(element)); - LastHitTestInfo = hitTestInfo; - } else { - var s = (from scoreBar in ScoreBars - let pos = e.GetPosition(scoreBar) - where pos.Y >= 0 && pos.Y < scoreBar.ActualHeight - select scoreBar) - .FirstOrDefault(); - if (s != null) { - var hitTestInfo = s.HitTest(e.GetPosition(s)); - LastHitTestInfo = hitTestInfo; - } - } - } - } - - private void ScoreEditor_OnPreviewMouseDown(object sender, MouseButtonEventArgs e) { - Focus(); - } - - private void ScoreEditor_OnPreviewMouseUp(object sender, MouseButtonEventArgs e) { - EditingLine.Visibility = Visibility.Hidden; - } - - private void ScoreEditor_OnPreviewMouseMove(object sender, MouseEventArgs e) { - if (EditingLine.Visibility == Visibility.Visible) { - var position = e.GetPosition(EditingLineLayer); - EditingLine.X2 = position.X; - EditingLine.Y2 = position.Y; - } - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.Helpers.cs b/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.Helpers.cs deleted file mode 100644 index 242246d..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.Helpers.cs +++ /dev/null @@ -1,168 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Windows; -using System.Windows.Media; -using StarlightDirector.Entities; -using StarlightDirector.Extensions; -using StarlightDirector.UI.Controls.Primitives; - -namespace StarlightDirector.UI.Controls { - partial class ScoreEditor { - - public bool HasSelectedScoreNotes => ScoreNotes.Any(scoreNote => scoreNote.IsSelected); - - public bool HasSingleSelectedScoreNote { - get { - var i = 0; - foreach (var scoreNote in ScoreNotes) { - if (!scoreNote.IsSelected) { - continue; - } - ++i; - if (i > 1) { - return false; - } - } - return i == 1; - } - } - - public int GetSelectedScoreNoteCount() { - return ScoreNotes.Count(scoreNote => scoreNote.IsSelected); - } - - public ScoreNote GetSelectedScoreNote() { - return ScoreNotes.FirstOrDefault(scoreNote => scoreNote.IsSelected); - } - - public IEnumerable GetSelectedScoreNotes() { - return ScoreNotes.Where(scoreNote => scoreNote.IsSelected); - } - - public IEnumerable SelectAllScoreNotes() { - foreach (var scoreNote in ScoreNotes) { - scoreNote.IsSelected = true; - } - return ScoreNotes; - } - - public IEnumerable UnselectAllScoreNotes() { - foreach (var scoreNote in ScoreNotes) { - scoreNote.IsSelected = false; - } - return Enumerable.Empty(); - } - - public IEnumerable UnselectAllScoreBars() { - foreach (var scoreBar in ScoreBars) { - scoreBar.IsSelected = false; - } - return Enumerable.Empty(); - } - - public bool HasSelectedScoreBars => ScoreBars.Any(scoreBar => scoreBar.IsSelected); - - public bool HasSingleSelectedScoreBar { - get { - var i = 0; - foreach (var scoreBar in ScoreBars) { - if (!scoreBar.IsSelected) { - continue; - } - ++i; - if (i > 1) { - return false; - } - } - return i == 1; - } - } - - public ScoreBar GetSelectedScoreBar() { - return ScoreBars.FirstOrDefault(scoreBar => scoreBar.IsSelected); - } - - public IEnumerable GetSelectedScoreBars() { - return ScoreBars.Where(scoreBar => scoreBar.IsSelected); - } - - public void ScrollToScoreBar(ScoreBar scoreBar) { - var point = scoreBar.TranslatePoint(new Point(scoreBar.Width / 2, scoreBar.Height / 2), ScrollViewer); - var newVertical = (ScoreBars.Count - scoreBar.Bar.Index - 1) * scoreBar.Height + scoreBar.Height * 0.5 - point.Y; - ScrollViewer.ScrollToVerticalOffset(newVertical); - } - - public double GetBarsTotalHeight() { - var height = ScoreBars.Sum(scoreBar => scoreBar.ActualHeight); - return height; - } - - public void SelectScoreBar(ScoreBar scoreBar) { - var previousSelected = GetSelectedScoreBar(); - if (previousSelected != null) { - previousSelected.IsSelected = false; - } - var current = scoreBar; - if (current != null) { - current.IsSelected = true; - } - } - - public ScoreBar GetScoreBarAtPosition(Point position, UIElement sourceElement) { - var hitPosition = sourceElement.TranslatePoint(position, BarLayer); - var hitResult = VisualTreeHelper.HitTest(BarLayer, hitPosition); - var visual = hitResult.VisualHit as FrameworkElement; - ScoreBar hitScoreBar = null; - while (visual != null) { - if (visual is ScoreBar) { - hitScoreBar = visual as ScoreBar; - break; - } - visual = visual.Parent as FrameworkElement; - } - return hitScoreBar; - } - - private ScoreNote FindScoreNote(Note note) { - return (from sn in ScoreNotes - where sn.Note.Equals(note) - select sn).FirstOrDefault(); - } - - private ScoreNote AnyNoteExistOnPosition(int barIndex, int column, int row) { - return (from scoreNote in ScoreNotes - let note = scoreNote.Note - where note.Bar.Index == barIndex && (int)note.FinishPosition == column + 1 && note.IndexInGrid == row - select scoreNote - ).FirstOrDefault(); - } - - private ScoreBar GetScoreBarGeomInfoForZooming(Point pointRelativeToThis, out double heightPercentage, out double height) { - heightPercentage = 0; - height = 0; - var pt = pointRelativeToThis; - pt = TranslatePoint(pt, BarLayer); - var hit = VisualTreeHelper.HitTest(BarLayer, pt); - var scoreBar = (hit?.VisualHit as FrameworkElement)?.FindVisualParent(); - if (scoreBar == null) { - return null; - } - pt = BarLayer.TranslatePoint(pt, scoreBar); - height = scoreBar.Height; - heightPercentage = pt.Y / height; - return scoreBar; - } - - private void TrimScoreNotes(ScoreBar willBeDeleted, bool modifiesModel) { - // Reposition after calling this function. - var bar = willBeDeleted.Bar; - Func matchFunc = scoreNote => scoreNote.Note.Bar == bar; - var processing = ScoreNotes.Where(matchFunc).ToArray(); - foreach (var scoreNote in processing) { - RemoveScoreNote(scoreNote, modifiesModel, false); - } - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.Layout.cs b/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.Layout.cs deleted file mode 100644 index c5f6487..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.Layout.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System.Linq; -using System.Windows.Controls; -using StarlightDirector.UI.Controls.Primitives; - -namespace StarlightDirector.UI.Controls { - partial class ScoreEditor { - - private void RecalcEditorLayout() { - ResizeBars(); - RepositionBars(); - RepositionNotes(); - RepositionSpecialNotes(); - RepositionLineLayer(); - ResizeEditorHeight(); - } - - private void ResizeEditorHeight() { - var height = -MinimumScrollOffset; - if (ScoreBars.Count > 0) { - height += ScoreBars.Sum(scoreBar => scoreBar.Height); - height += ScoreBar.GridStrokeThickness; - } - Height = height; - } - - private void ResizeBars() { - var barLayerWidth = BarLayer.ActualWidth; - foreach (var scoreBar in ScoreBars) { - scoreBar.BarColumnWidth = barLayerWidth; - } - } - - private void RepositionBars() { - if (ScoreBars.Count == 0) { - return; - } - var currentY = -MinimumScrollOffset; - foreach (var scoreBar in ScoreBars) { - Canvas.SetLeft(scoreBar, -scoreBar.TextColumnWidth - scoreBar.SpaceColumnWidth); - Canvas.SetTop(scoreBar, currentY); - currentY += scoreBar.Height; - } - } - - private void RepositionNotes() { - if (ScoreNotes.Count == 0) { - return; - } - var scrollOffset = -MinimumScrollOffset; - var barHeight = ScoreBars[0].Height; - foreach (var scoreNote in ScoreNotes) { - var note = scoreNote.Note; - var bar = note.Bar; - var baseY = scrollOffset + bar.Index * barHeight; - var extraY = barHeight * note.IndexInGrid / bar.TotalGridCount; - // ScoreNote.X property is not required to recalc since v0.6.0. From this version the width of ScoreEditor is fixed. - scoreNote.Y = baseY + extraY; - } - } - - private void RepositionSpecialNotes() { - if (SpecialScoreNotes.Count == 0 || ScoreBars.Count == 0) { - return; - } - var scrollOffset = -MinimumScrollOffset; - var barHeight = ScoreBars[0].Height; - foreach (var specialNotePointer in SpecialScoreNotes) { - var note = specialNotePointer.Note; - var bar = note.Bar; - var baseY = scrollOffset + bar.Index * barHeight; - var extraY = barHeight * note.IndexInGrid / bar.TotalGridCount; - specialNotePointer.Y = baseY + extraY; - } - } - - private void RepositionLineLayer() { - LineLayer.Width = NoteLayer.ActualWidth; - LineLayer.Height = NoteLayer.ActualHeight; - LineLayer.InvalidateVisual(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.Logic.Misc.cs b/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.Logic.Misc.cs deleted file mode 100644 index 96b58b7..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.Logic.Misc.cs +++ /dev/null @@ -1,121 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using StarlightDirector.Entities; -using StarlightDirector.UI.Controls.Primitives; - -namespace StarlightDirector.UI.Controls { - partial class ScoreEditor { - - internal void UpdateBarTexts() { - var startTime = ScoreBars?.FirstOrDefault()?.Bar?.StartTime ?? 0d; - foreach (var scoreBar in ScoreBars) { - scoreBar.UpdateBarIndexText(); - scoreBar.UpdateBarTimeText(TimeSpan.FromSeconds(startTime)); - startTime += scoreBar.Bar.TimeLength; - } - } - - protected override void ReloadScore(Score toBeSet) { - // First, clean up the room before inviting guests. XD (You know where this sentense comes from.) - // These are presentation layer of the program, just clear them, and let the GC do the rest of the work. - // Clearing these objects will not affect the underlying model. - RemoveScoreBars(ScoreBars, false, true); - LineLayer.NoteRelations.Clear(); - while (SpecialScoreNotes.Count > 0) { - RemoveSpecialNote(SpecialScoreNotes[0], false); - } - if (toBeSet == null) { - return; - } - - var temporaryMap = new Dictionary(); - var allGamingNotes = new List(); - var noteProcessed = new Dictionary(); - // OK the fun part is here. - foreach (var bar in toBeSet.Bars) { - var scoreBar = AddScoreBar(null, false, bar); - foreach (var note in bar.Notes) { - if (!note.IsGamingNote) { - continue; - } - var scoreNote = AddScoreNote(scoreBar, note.IndexInGrid, note.FinishPosition, note); - if (scoreNote == null) { - Debug.Print("Error creating ScoreNote. Please check project content."); - } else { - temporaryMap.Add(note.ID, scoreNote); - allGamingNotes.Add(note); - noteProcessed[note.ID] = false; - } - } - } - - foreach (var note in allGamingNotes) { - if (!noteProcessed[note.ID]) { - ProcessNoteRelations(note, noteProcessed, temporaryMap, LineLayer.NoteRelations); - } - } - - // Variant BPM indicators - foreach (var note in toBeSet.Notes.Where(n => n.Type == NoteType.VariantBpm)) { - var specialNote = AddSpecialNote(ScoreBars[note.Bar.Index], note.IndexInGrid, note.Type, note, false); - specialNote.Note = note; - } - - UpdateBarTexts(); - RecalcEditorLayout(); - Debug.Print("Done: ScoreEditor.ReloadScore()."); - } - - private static void ProcessNoteRelations(Note root, IDictionary noteProcessed, IDictionary map, NoteRelationCollection relations) { - var waitingList = new Queue(); - waitingList.Enqueue(root); - while (waitingList.Count > 0) { - var note = waitingList.Dequeue(); - if (noteProcessed[note.ID]) { - continue; - } - noteProcessed[note.ID] = true; - - if (note.HasPrevSync) { - if (!relations.ContainsPair(map[note.ID], map[note.PrevSyncTarget.ID])) { - relations.Add(map[note.ID], map[note.PrevSyncTarget.ID], NoteRelation.Sync); - waitingList.Enqueue(note.PrevSyncTarget); - } - } - if (note.HasNextSync) { - if (!relations.ContainsPair(map[note.ID], map[note.NextSyncTarget.ID])) { - relations.Add(map[note.ID], map[note.NextSyncTarget.ID], NoteRelation.Sync); - waitingList.Enqueue(note.NextSyncTarget); - } - } - if (note.HasNextFlickOrSlide) { - if (!relations.ContainsPair(map[note.ID], map[note.NextFlickOrSlideNote.ID])) { - relations.Add(map[note.ID], map[note.NextFlickOrSlideNote.ID], NoteRelation.FlickOrSlide); - waitingList.Enqueue(note.NextFlickOrSlideNote); - } - } - if (note.HasPrevFlickOrSlide) { - if (!relations.ContainsPair(map[note.ID], map[note.PrevFlickOrSlideNote.ID])) { - relations.Add(map[note.ID], map[note.PrevFlickOrSlideNote.ID], NoteRelation.FlickOrSlide); - waitingList.Enqueue(note.PrevFlickOrSlideNote); - } - } - if (note.IsHoldStart) { - if (!relations.ContainsPair(map[note.ID], map[note.HoldTarget.ID])) { - relations.Add(map[note.ID], map[note.HoldTarget.ID], NoteRelation.Hold); - waitingList.Enqueue(note.HoldTarget); - } - } - } - } - - private void OnScoreGlobalSettingsChanged(object sender, EventArgs e) { - UpdateBarTexts(); - } - - private static readonly double[] TrackCenterXPositions = { 0.2, 0.35, 0.5, 0.65, 0.8 }; - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.Properties.cs b/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.Properties.cs deleted file mode 100644 index 1584fe5..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.Properties.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Windows.Controls; -using StarlightDirector.UI.Controls.Primitives; - -namespace StarlightDirector.UI.Controls { - partial class ScoreEditor { - - public ReadOnlyCollection ScoreBars { get; } - - public ReadOnlyCollection SpecialScoreNotes { get; } - - public ScoreBarHitTestInfo LastHitTestInfo { get; private set; } - - public Grid ContentsGridControl => ContentsGrid; - - private List EditableScoreBars { get; } - - private List EditableSpecialScoreNotes { get; } - - private ScoreNote DraggingStartNote { get; set; } - - private ScoreNote DraggingEndNote { get; set; } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.Viewing.cs b/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.Viewing.cs deleted file mode 100644 index 7d61972..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.Viewing.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System.Windows; -using System.Windows.Input; - -namespace StarlightDirector.UI.Controls { - partial class ScoreEditor { - - public void ZoomOutByCenter() { - var pt = new Point(ActualWidth / 2, ActualHeight / 2); - ZoomOut(pt); - } - - public void ZoomInByCenter() { - var pt = new Point(ActualWidth / 2, ActualHeight / 2); - ZoomIn(pt); - } - - public void ZoomOut() { - ZoomOut(null); - } - - public void ZoomIn() { - ZoomIn(null); - } - - public void ZoomTo(int oneNthBeat) { - var centerPoint = new Point(ActualWidth / 2, ActualHeight / 2); - double heightPercentage, scoreBarHeight; - var originalScoreBar = GetScoreBarGeomInfoForZooming(centerPoint, out heightPercentage, out scoreBarHeight); - const double conflictAvoidingLevel = 1.05; - foreach (var scoreBar in ScoreBars) { - var expectedHeight = scoreBar.NoteRadius * 2 * oneNthBeat / 4 * scoreBar.Bar.Signature; - expectedHeight *= conflictAvoidingLevel; - scoreBar.ZoomToHeight(expectedHeight); - } - RecalcEditorLayout(); - if (originalScoreBar != null && ScrollViewer != null) { - var point = TranslatePoint(centerPoint, ScrollViewer); - var newVertical = (ScoreBars.Count - originalScoreBar.Bar.Index - 1) * originalScoreBar.Height + originalScoreBar.Height * (1 - heightPercentage) - point.Y; - ScrollViewer.ScrollToVerticalOffset(newVertical); - } - } - - private void ZoomOut(Point? specifiedPoint) { - double heightPercentage, scoreBarHeight; - var point = specifiedPoint ?? Mouse.GetPosition(this); - var originalScoreBar = GetScoreBarGeomInfoForZooming(point, out heightPercentage, out scoreBarHeight); - foreach (var scoreBar in ScoreBars) { - scoreBar.ZoomOut(); - } - RecalcEditorLayout(); - if (originalScoreBar != null && ScrollViewer != null) { - point = TranslatePoint(point, ScrollViewer); - var newVertical = (ScoreBars.Count - originalScoreBar.Bar.Index - 1) * originalScoreBar.Height + originalScoreBar.Height * (1 - heightPercentage) - point.Y; - ScrollViewer.ScrollToVerticalOffset(newVertical); - } - } - - private void ZoomIn(Point? specifiedPoint) { - double heightPercentage, scoreBarHeight; - var point = specifiedPoint ?? Mouse.GetPosition(this); - var originalScoreBar = GetScoreBarGeomInfoForZooming(point, out heightPercentage, out scoreBarHeight); - foreach (var scoreBar in ScoreBars) { - scoreBar.ZoomIn(); - } - RecalcEditorLayout(); - if (originalScoreBar != null && ScrollViewer != null) { - point = TranslatePoint(point, ScrollViewer); - var newVertical = (ScoreBars.Count - originalScoreBar.Bar.Index - 1) * originalScoreBar.Height + originalScoreBar.Height * (1 - heightPercentage) - point.Y; - ScrollViewer.ScrollToVerticalOffset(newVertical); - } - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.xaml b/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.xaml deleted file mode 100644 index 14028d2..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.xaml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.xaml.cs b/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.xaml.cs deleted file mode 100644 index a2aa3c1..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/ScoreEditor.xaml.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Collections.Generic; -using StarlightDirector.UI.Controls.Primitives; - -namespace StarlightDirector.UI.Controls { - public partial class ScoreEditor { - - public ScoreEditor() { - EditableScoreBars = new List(); - EditableSpecialScoreNotes = new List(); - ScoreBars = EditableScoreBars.AsReadOnly(); - SpecialScoreNotes = EditableSpecialScoreNotes.AsReadOnly(); - - InitializeComponent(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/ScorePreviewer.DependencyProperties.cs b/StarlightDirector/StarlightDirector/UI/Controls/ScorePreviewer.DependencyProperties.cs deleted file mode 100644 index 51a42fd..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/ScorePreviewer.DependencyProperties.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Windows; - -namespace StarlightDirector.UI.Controls { - partial class ScorePreviewer { - - public bool IsPreviewing { - get { - if (CheckAccess()) { - return (bool)GetValue(IsPreviewingProperty); - } else { - if (_getIsPreviewing == null) { - _getIsPreviewing = () => (bool)GetValue(IsPreviewingProperty); - } - return (bool)Dispatcher.Invoke(_getIsPreviewing); - } - } - internal set { - if (CheckAccess()) { - SetValue(IsPreviewingProperty, value); - } else { - if (_setIsPreviewing == null) { - _setIsPreviewing = v => SetValue(IsPreviewingProperty, v); - } - Dispatcher.Invoke(_setIsPreviewing, value); - } - } - } - - public static readonly DependencyProperty IsPreviewingProperty = DependencyProperty.Register(nameof(IsPreviewing), typeof(bool), typeof(ScorePreviewer), - new PropertyMetadata(false, OnIsPreviewingChanged)); - - private static void OnIsPreviewingChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { - var previewer = (ScorePreviewer)obj; - previewer._isPreviewing = (bool)e.NewValue; - } - - private Func _getIsPreviewing; - private Action _setIsPreviewing; - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/ScorePreviewer.xaml b/StarlightDirector/StarlightDirector/UI/Controls/ScorePreviewer.xaml deleted file mode 100644 index 5918c65..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/ScorePreviewer.xaml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - diff --git a/StarlightDirector/StarlightDirector/UI/Controls/ScorePreviewer.xaml.cs b/StarlightDirector/StarlightDirector/UI/Controls/ScorePreviewer.xaml.cs deleted file mode 100644 index 6f98299..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/ScorePreviewer.xaml.cs +++ /dev/null @@ -1,379 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using System.Windows; -using NAudio.CoreAudioApi; -using NAudio.Wave; -using StarlightDirector.Entities; -using StarlightDirector.UI.Controls.Models; -using StarlightDirector.UI.Windows; - -namespace StarlightDirector.UI.Controls { - /// - /// Interaction logic for ScorePreviewer.xaml - /// - public partial class ScorePreviewer { - - // first-time loading - private bool _loaded; - private readonly EventWaitHandle _loadHandle = new EventWaitHandle(false, EventResetMode.AutoReset); - - // used by frame update thread - private Score _score; - private Task _task; - private readonly List _notes = new List(); - private double _targetFps; - private int _startTime; - private volatile bool _isPreviewing; - private readonly List _bars = new List(); - - // hit sound - private static readonly string HitSoundFile = "Resources/SFX/director/se_live_tap_perfect.wav"; - private static readonly string FlickSoundFile = "Resources/SFX/director/se_live_flic_perfect.wav"; - private readonly WasapiOut[] _hitAudios = { null, null }; - private readonly DateTime[] _hitModifiedTimes = { new DateTime(), new DateTime() }; - private readonly WaveFileReader[] _hitWaves = { null, null }; - private readonly MemoryStream[] _hitMem = { null, null }; - private readonly EventWaitHandle _hitsoundHandle = new EventWaitHandle(false, EventResetMode.AutoReset); - - // music time fixing - private int _lastMusicTime; - private int _lastComputedSongTime; - private DateTime _lastFrameEndtime; - - // window-related - private readonly MainWindow _window; - private bool _shouldPlayMusic; - - public ScorePreviewer() { - InitializeComponent(); - _window = Application.Current.MainWindow as MainWindow; - } - - public void BeginPreview(Score score, double targetFps, int startTime, double approachTime) { - // wait if not loaded yet - if (!_loaded) { - new Task(() => { - _loadHandle.WaitOne(); - Dispatcher.BeginInvoke( - new Action(BeginPreview), - score, targetFps, startTime, approachTime); - }).Start(); - return; - } - - // setup parameters - - _score = score; - _targetFps = targetFps; - _startTime = startTime; - - // prepare notes - - foreach (var note in _score.Notes) { - // can I draw it? - if (note.Type != NoteType.TapOrFlick && note.Type != NoteType.Hold && note.Type != NoteType.Slide) { - continue; - } - - var pos = (int)note.FinishPosition; - if (pos == 0) - pos = (int)note.StartPosition; - - if (pos == 0) - continue; - - NoteDrawType drawType; - if (note.IsHoldStart || (note.IsHoldEnd && note.IsTap)) { - drawType = NoteDrawType.Hold; - } else if (note.ShouldBeRenderedAsFlick) { - drawType = (NoteDrawType)note.FlickType; - } else if (note.ShouldBeRenderedAsSlide) { - drawType = NoteDrawType.Slide; - } else { - drawType = NoteDrawType.Tap; - } - - var snote = new DrawingNote { - Note = note, - Done = false, - Duration = 0, - IsHoldStart = note.IsHoldStart, - Timing = (int)(note.HitTiming * 1000), - LastT = 0, - HitPosition = pos - 1, - DrawType = drawType - }; - - if (note.IsHoldStart) { - snote.Duration = (int)(note.HoldTarget.HitTiming * 1000) - (int)(note.HitTiming * 1000); - } - - // skip notes that are done before start time - if (snote.Timing + snote.Duration < startTime) { - continue; - } - - // skip hit effect of hold note start if started before - if (snote.IsHoldStart && snote.Timing < startTime) { - snote.EffectShown = true; - } - - _notes.Add(snote); - } - - // end if no notes - if (_notes.Count == 0) { - // TODO: alert user? - IsPreviewing = false; - return; - } - - _notes.Sort((a, b) => a.Timing - b.Timing); - - // prepare note relationships - - foreach (var snote in _notes) { - if (snote.IsHoldStart) { - snote.HoldTarget = _notes.FirstOrDefault(note => note.Note.ID == snote.Note.HoldTargetID); - } - - if (snote.Note.HasNextSync) { - snote.SyncTarget = _notes.FirstOrDefault(note => note.Note.ID == snote.Note.NextSyncTarget.ID); - } - - if (snote.Note.HasNextFlickOrSlide) { - snote.GroupTarget = _notes.FirstOrDefault(note => note.Note.ID == snote.Note.NextFlickOrSlideNoteID); - } - } - - // music - - _shouldPlayMusic = _window != null && _window.MusicLoaded; - - // prepare bars - - if (_window != null && _window.PreviewBarLevel > 0) { - var level = _window.PreviewBarLevel; - - foreach (var bar in score.Bars) { - _bars.Add(new DrawingBar { DrawType = 0, Timing = (int)(bar.StartTime * 1000) }); - if (level > 1) { - for (int sig = 0; sig < bar.Signature; ++sig) { - if (sig > 0) - _bars.Add(new DrawingBar { DrawType = 1, Timing = (int)(bar.TimeAtSignature(sig) * 1000) }); - - if (level > 2 && bar.GridPerSignature % 4 == 0) { - for (int grid = bar.GridPerSignature / 4; grid < bar.GridPerSignature; grid += bar.GridPerSignature / 4) { - _bars.Add(new DrawingBar { - DrawType = 2, - Timing = (int)(bar.TimeAtGrid(sig * bar.GridPerSignature + grid) * 1000) - }); - } - } - } - } - } - } - - // prepare canvas - - approachTime *= ActualHeight / 484.04; - MainCanvas.Initialize(_notes, _bars, approachTime); - - // hit sound - - LoadHitSounds(); - new Task(HitSoundTask).Start(); - - // go - - if (_shouldPlayMusic) { - StartMusic(_startTime); - } - - _task = new Task(DrawPreviewFrames); - _task.Start(); - } - - public void EndPreview() { - if (_shouldPlayMusic) { - StopMusic(); - } - - IsPreviewing = false; - _hitsoundHandle.Set(); - - // ensure responding to dimension change - _loaded = false; - - // clear canvas - MainCanvas.Stop(); - MainCanvas.InvalidateVisual(); - } - - // These methods invokes the main thread and perform the tasks - #region Multithreading Invoke - - private void StartMusic(double milliseconds) { - Dispatcher.Invoke(new Action(() => _window.PlayMusic(milliseconds))); - } - - private void StopMusic() { - Dispatcher.Invoke(new Action(() => _window.StopMusic())); - } - - #endregion - - /// - /// Running in a background thread, refresh the locations of notes periodically. It tries to keep the target frame rate. - /// - private void DrawPreviewFrames() { - // frame rate - double targetFrameTime = 0; - if (!double.IsInfinity(_targetFps)) { - targetFrameTime = 1000 / _targetFps; - } - - MainCanvas.HitEffectMilliseconds = 200; - - // drawing and timing - var startTime = DateTime.UtcNow; - TimeSpan? musicCurrentTime = null; - TimeSpan? musicTotalTime = null; - if (_shouldPlayMusic) - musicTotalTime = _window.GetMusicTotalTime(); - - while (_isPreviewing) { - if (_shouldPlayMusic) { - musicCurrentTime = _window.GetCurrentMusicTime(); - if (musicCurrentTime.HasValue && musicTotalTime.HasValue && musicCurrentTime.Value >= musicTotalTime.Value) { - EndPreview(); - break; - } - } - - var frameStartTime = DateTime.UtcNow; - - // compute time - - int musicTimeInMillis; - if (_shouldPlayMusic) { - if (musicCurrentTime == null) { - EndPreview(); - break; - } - - musicTimeInMillis = (int)musicCurrentTime.Value.TotalMilliseconds; - if (musicTimeInMillis > 0 && musicTimeInMillis == _lastMusicTime) { - // music time not updated, add frame time - _lastComputedSongTime += (int)(frameStartTime - _lastFrameEndtime).TotalMilliseconds; - musicTimeInMillis = _lastComputedSongTime; - } else { - // music time updated - _lastComputedSongTime = musicTimeInMillis; - _lastMusicTime = musicTimeInMillis; - } - } else { - musicTimeInMillis = (int)(frameStartTime - startTime).TotalMilliseconds + _startTime; - } - - // wait for rendering - - MainCanvas.RenderFrameBlocked(musicTimeInMillis); - - // play hitsound - - _hitsoundHandle.Set(); - - // wait for next frame - - _lastFrameEndtime = DateTime.UtcNow; - if (targetFrameTime > 0) { - var frameEllapsedTime = (_lastFrameEndtime - frameStartTime).TotalMilliseconds; - if (frameEllapsedTime < targetFrameTime) { - Thread.Sleep((int)(targetFrameTime - frameEllapsedTime)); - } else { - Debug.WriteLine($"[Warning] Frame ellapsed time {frameEllapsedTime:N2} exceeds target."); - } - } - } - - _notes.Clear(); - _bars.Clear(); - } - - private void ScorePreviewer_OnLayoutUpdated(object sender, EventArgs e) { - if (_isPreviewing && !_loaded && ActualWidth > 0 && ActualHeight > 0) { - _loaded = true; - _loadHandle.Set(); - } - } - - #region Hit Sound - - private MemoryStream MsFromFile(string file) { - var ms = new MemoryStream(); - using (var fs = new FileStream(file, FileMode.Open)) { - fs.CopyTo(ms); - } - ms.Seek(0, SeekOrigin.Begin); - return ms; - } - - private void SetHitsoundAudio(int index, MemoryStream ms) { - _hitAudios[index]?.Stop(); - _hitAudios[index]?.Dispose(); - _hitWaves[index]?.Close(); - - _hitMem[index] = ms; - _hitWaves[index] = new WaveFileReader(ms); - _hitAudios[index] = new WasapiOut(AudioClientShareMode.Shared, 0); - _hitAudios[index].Init(_hitWaves[index]); - } - - private void LoadHitSounds() { - try { - if (File.Exists(HitSoundFile) && _hitModifiedTimes[0] != File.GetLastWriteTime(HitSoundFile)) { - SetHitsoundAudio(0, MsFromFile(HitSoundFile)); - } - - if (File.Exists(FlickSoundFile) && _hitModifiedTimes[1] != File.GetLastWriteTime(FlickSoundFile)) { - SetHitsoundAudio(1, MsFromFile(FlickSoundFile)); - } - } catch (Exception ex) { - MessageBox.Show($"Failed to load hitsounds:{Environment.NewLine}{ex.Message}", "Error", - MessageBoxButton.OK, MessageBoxImage.Error); - } - } - - /// - /// Runs in a separate thread to play hitsound - /// - private void HitSoundTask() { - _hitsoundHandle.WaitOne(); - - while (_isPreviewing) { - for (int i = 0; i < 2; ++i) { - if (!MainCanvas.ShallPlaySoundEffect[i]) - continue; - - // note: no need to stop audio - - if (_hitWaves[i] != null) { - _hitWaves[i].Seek(0, SeekOrigin.Begin); - _hitAudios[i].Play(); - } - } - - _hitsoundHandle.WaitOne(); - } - } - - #endregion - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/ScoreViewerBase.DependencyProperties.cs b/StarlightDirector/StarlightDirector/UI/Controls/ScoreViewerBase.DependencyProperties.cs deleted file mode 100644 index eb8e635..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/ScoreViewerBase.DependencyProperties.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Windows; -using System.Windows.Controls; -using StarlightDirector.Entities; - -namespace StarlightDirector.UI.Controls { - partial class ScoreViewerBase { - - public bool AreRelationIndicatorsVisible { - get { return (bool)GetValue(AreRelationIndicatorsVisibleProperty); } - set { SetValue(AreRelationIndicatorsVisibleProperty, value); } - } - - public Score Score { - get { return (Score)GetValue(ScoreProperty); } - set { SetValue(ScoreProperty, value); } - } - - public ScrollViewer ScrollViewer { - get { return (ScrollViewer)GetValue(ScrollViewerProperty); } - set { SetValue(ScrollViewerProperty, value); } - } - - public double MinimumScrollOffset { - get { return (double)GetValue(MinimumScrollOffsetProperty); } - protected set { SetValue(MinimumScrollOffsetProperty, value); } - } - - public static readonly DependencyProperty MinimumScrollOffsetProperty = DependencyProperty.Register(nameof(MinimumScrollOffset), typeof(double), typeof(ScoreViewerBase), - new PropertyMetadata(-45d)); - - public static readonly DependencyProperty AreRelationIndicatorsVisibleProperty = DependencyProperty.Register(nameof(AreRelationIndicatorsVisible), typeof(bool), typeof(ScoreViewerBase), - new PropertyMetadata(false)); - - public static readonly DependencyProperty ScoreProperty = DependencyProperty.Register(nameof(Score), typeof(Score), typeof(ScoreViewerBase), - new PropertyMetadata(null, OnScoreChanged)); - - public static readonly DependencyProperty ScrollViewerProperty = DependencyProperty.Register(nameof(ScrollViewer), typeof(ScrollViewer), typeof(ScoreViewerBase), - new PropertyMetadata(null)); - - private static void OnScoreChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { - var viewerBase = (ScoreViewerBase)obj; - var newScore = (Score)e.NewValue; - viewerBase.ReloadScore(newScore); - } - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/ScoreViewerBase.Properties.cs b/StarlightDirector/StarlightDirector/UI/Controls/ScoreViewerBase.Properties.cs deleted file mode 100644 index bf8396a..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/ScoreViewerBase.Properties.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Collections.Generic; -using System.Collections.ObjectModel; -using StarlightDirector.UI.Controls.Primitives; - -namespace StarlightDirector.UI.Controls { - partial class ScoreViewerBase { - - public ReadOnlyCollection ScoreNotes { get; } - - protected List EditableScoreNotes { get; } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Controls/ScoreViewerBase.cs b/StarlightDirector/StarlightDirector/UI/Controls/ScoreViewerBase.cs deleted file mode 100644 index 9903888..0000000 --- a/StarlightDirector/StarlightDirector/UI/Controls/ScoreViewerBase.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections.Generic; -using System.Windows.Controls; -using StarlightDirector.Entities; -using StarlightDirector.UI.Controls.Primitives; - -namespace StarlightDirector.UI.Controls { - public partial class ScoreViewerBase : UserControl { - - public ScoreViewerBase() { - EditableScoreNotes = new List(); - ScoreNotes = EditableScoreNotes.AsReadOnly(); - } - - protected virtual void ReloadScore(Score toBeSet) { - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/BooleanToValuesConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/BooleanToValuesConverter.cs deleted file mode 100644 index 524eab9..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/BooleanToValuesConverter.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Globalization; -using System.Windows.Data; - -namespace StarlightDirector.UI.Converters -{ - public class BooleanToValuesConverter : IValueConverter - { - public object TrueValue { get; set; } - public object FalseValue { get; set; } - public object NullValue { get; set; } - - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - var b = value as bool?; - return b.HasValue ? (b.Value ? TrueValue : FalseValue) : NullValue; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/ConverterGroupParameters.cs b/StarlightDirector/StarlightDirector/UI/Converters/ConverterGroupParameters.cs deleted file mode 100644 index 0e0d4e0..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/ConverterGroupParameters.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System.Collections.Generic; - -namespace StarlightDirector.UI.Converters { - public sealed class ConverterGroupParameters : List { - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/DescribedEnumToStringConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/DescribedEnumToStringConverter.cs deleted file mode 100644 index bc7eb0f..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/DescribedEnumToStringConverter.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.ComponentModel; -using System.Globalization; -using System.Windows.Data; - -namespace StarlightDirector.UI.Converters { - public sealed class DescribedEnumToStringConverter : IValueConverter { - - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - var enumType = (Type)parameter; - var fieldInfo = enumType.GetField(Enum.GetName(enumType, value)); - var descriptionAttribute = (DescriptionAttribute)Attribute.GetCustomAttribute(fieldInfo, typeof(DescriptionAttribute)); - return descriptionAttribute != null ? descriptionAttribute.Description : value.ToString(); - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - throw new NotSupportedException(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/DifficultyToIndexConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/DifficultyToIndexConverter.cs deleted file mode 100644 index 0d8c831..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/DifficultyToIndexConverter.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Globalization; -using System.Windows.Data; -using StarlightDirector.Entities; - -namespace StarlightDirector.UI.Converters { - public sealed class DifficultyToIndexConverter : IValueConverter { - - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - var e = (Difficulty)value; - return (int)e - 1; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - var n = (int)value; - return (Difficulty)(n + 1); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/DifficultyToIsCheckedConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/DifficultyToIsCheckedConverter.cs deleted file mode 100644 index 89e531f..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/DifficultyToIsCheckedConverter.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Globalization; -using System.Windows.Data; -using StarlightDirector.Entities; - -namespace StarlightDirector.UI.Converters { - public sealed class DifficultyToIsCheckedConverter : IValueConverter { - - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - Difficulty e, p; - e = (Difficulty)value; - p = (Difficulty)parameter; - return e == p; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - throw new NotSupportedException(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/DoubleToStringConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/DoubleToStringConverter.cs deleted file mode 100644 index 9a2b211..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/DoubleToStringConverter.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Diagnostics; -using System.Globalization; -using System.Windows; -using System.Windows.Data; - -namespace StarlightDirector.UI.Converters { - public sealed class DoubleToStringConverter : IValueConverter { - - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - return ((double)value).ToString("F3"); - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - string stringValue; - try { - stringValue = (string)value; - } catch (InvalidCastException) { - return DependencyProperty.UnsetValue; - } - double d; - var b = double.TryParse(stringValue, out d); - if (!b) { - Debug.Print($"Object '{value}' is not a double."); - return DependencyProperty.UnsetValue; - } - return d; - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/EditModeToIsCheckedConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/EditModeToIsCheckedConverter.cs deleted file mode 100644 index c7b0857..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/EditModeToIsCheckedConverter.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Globalization; -using System.Windows.Data; - -namespace StarlightDirector.UI.Converters { - public sealed class EditModeToIsCheckedConverter : IValueConverter { - - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - EditMode e, p; - e = (EditMode)value; - p = (EditMode)parameter; - return e == p; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - throw new NotSupportedException(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/EquityConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/EquityConverter.cs deleted file mode 100644 index b253f64..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/EquityConverter.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Windows.Data; - -namespace StarlightDirector.UI.Converters { - // http://stackoverflow.com/questions/1350598/passing-two-command-parameters-using-a-wpf-binding - public sealed class EquityConverter : IMultiValueConverter { - - public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture) { - if (value.Length != 2) { - throw new ArgumentException("There should be 2 objects for EquityConverter."); - } - var b = EqualityComparer.Default.Equals(value[0], value[1]); - var negate = (bool?)parameter; - if (negate.HasValue && negate.Value) { - b = !b; - } - return b; - } - - public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { - throw new NotSupportedException(); - } - - public static readonly bool Negate = true; - public static readonly bool True = true; - public static readonly bool False = false; - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/BinaryOpConverterBase.cs b/StarlightDirector/StarlightDirector/UI/Converters/MathOp/BinaryOpConverterBase.cs deleted file mode 100644 index a43acd1..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/BinaryOpConverterBase.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Globalization; -using System.Linq; -using System.Windows.Data; - -namespace StarlightDirector.UI.Converters.MathOp { - public abstract class BinaryOpConverterBase : MathConverterBase, IMultiValueConverter { - - public abstract object Convert(object[] values, Type targetType, object parameter, CultureInfo culture); - - public abstract object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture); - - public static double[] GetObjectValues(object[] values) { - if (values.Length < 2) { - throw new ArgumentException("At least 2 values are required for BinaryOpConverterBase converting without parameter."); - } - var v1 = GetObjectValue(values[0]); - var v2 = GetObjectValue(values[1]); - return new[] { v1, v2 }; - } - - public static object[] ConcatResult(object[] values, double result) { - var r = new[] { (object)result }; - return r.Concat(values.Skip(2)).ToArray(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/LeftParenConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/MathOp/LeftParenConverter.cs deleted file mode 100644 index f332368..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/LeftParenConverter.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Globalization; -using System.Windows; - -namespace StarlightDirector.UI.Converters.MathOp { - public sealed class LeftParenConverter : OpSymbolConverterBase { - - public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - return DependencyProperty.UnsetValue; - } - - public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - return DependencyProperty.UnsetValue; - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/MathAddConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/MathOp/MathAddConverter.cs deleted file mode 100644 index f1eb6c3..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/MathAddConverter.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Globalization; - -namespace StarlightDirector.UI.Converters.MathOp { - public sealed class MathAddConverter : BinaryOpConverterBase { - - public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - var v1 = GetObjectValue(value); - var v2 = GetObjectValue(parameter); - return v1 + v2; - } - - public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - var v1 = GetObjectValue(value); - var v2 = GetObjectValue(parameter); - return v1 - v2; - } - - public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { - var v = GetObjectValues(values); - var result = v[0] + v[1]; - //return ConcatResult(values, result); - return result; - } - - public override object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { - throw new NotSupportedException(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/MathConstantConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/MathOp/MathConstantConverter.cs deleted file mode 100644 index 3e6c3eb..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/MathConstantConverter.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Globalization; - -namespace StarlightDirector.UI.Converters.MathOp { - public sealed class MathConstantConverter : MathConverterBase { - - public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - return GetObjectValue(parameter); - } - - public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - throw new NotSupportedException(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/MathConverterBase.cs b/StarlightDirector/StarlightDirector/UI/Converters/MathOp/MathConverterBase.cs deleted file mode 100644 index 5f9ba8f..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/MathConverterBase.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Globalization; -using System.Windows; -using System.Windows.Data; -using SysConvert = System.Convert; - -namespace StarlightDirector.UI.Converters.MathOp { - public abstract class MathConverterBase : IValueConverter { - - public abstract object Convert(object value, Type targetType, object parameter, CultureInfo culture); - - public abstract object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture); - - public static double GetObjectValue(object value) { - if (value == null || value == DependencyProperty.UnsetValue) { - return 0d; - } - if (value is double) { - return (double)value; - } else if (value is string) { - double d; - double.TryParse((string)value, out d); - return d; - } else { - return SysConvert.ToDouble(value); - } - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/MathDivideConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/MathOp/MathDivideConverter.cs deleted file mode 100644 index 6042557..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/MathDivideConverter.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Globalization; - -namespace StarlightDirector.UI.Converters.MathOp { - public sealed class MathDivideConverter : BinaryOpConverterBase { - - public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - var v1 = GetObjectValue(value); - var v2 = GetObjectValue(parameter); - if (v2.Equals(0d)) { - return v1 >= 0d ? double.PositiveInfinity : double.NegativeInfinity; - } else { - return v1 / v2; - } - } - - public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - var v1 = GetObjectValue(value); - var v2 = GetObjectValue(parameter); - return v1 * v2; - } - - public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { - var v = GetObjectValues(values); - double result; - if (v[1].Equals(0d)) { - result = v[0] >= 0d ? double.PositiveInfinity : double.NegativeInfinity; - } else { - result = v[0] / v[1]; - } - //return ConcatResult(values, result); - return result; - } - - public override object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { - throw new NotSupportedException(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/MathExpressionConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/MathOp/MathExpressionConverter.cs deleted file mode 100644 index 7ccd2fa..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/MathExpressionConverter.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Windows.Data; - -namespace StarlightDirector.UI.Converters.MathOp { - public sealed class MathExpressionConverter : List, IMultiValueConverter { - /// - /// - /// - /// - /// - /// Ignored. - /// - /// - // TODO: Implement priorities. - public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { - var resultStack = new Stack(); - var valueIndex = 0; - var converters = this; - var hasValue = new List { false }; - var level = 0; - - for (var converterIndex = 0; converterIndex < Count; ++converterIndex) { - var converter = converters[converterIndex]; - var valueExistsInCurrentLevel = hasValue[level]; - if (converter is OpSymbolConverterBase) { - if (converter is LeftParenConverter) { - ++level; - if (hasValue.Count <= level) { - hasValue.Add(false); - } else { - hasValue[level] = false; - } - } else if (converter is RightParenConverter) { - var b = hasValue[level]; - --level; - if (b) { - hasValue[level] = true; - } - } else { - throw new ArgumentException("Unknown math symbol converter type."); - } - } else if (converter is UnaryOpConverterBase) { - var unaryConverter = (UnaryOpConverterBase)converter; - if (valueExistsInCurrentLevel) { - // Consume 0 value - var current = (double)unaryConverter.Convert(resultStack.Pop(), null, null, culture); - resultStack.Push(current); - } else { - // Consume 1 value - var current = (double)unaryConverter.Convert(values[valueIndex], null, null, culture); - ++valueIndex; - resultStack.Push(current); - } - hasValue[level] = true; - } else if (converter is BinaryOpConverterBase) { - var binaryConverter = (BinaryOpConverterBase)converter; - var binaryValues = new object[2]; - if (valueExistsInCurrentLevel) { - // Prefer the ones in value array - if (valueIndex < values.Length) { - // Consume 1 value - binaryValues[0] = resultStack.Pop(); - binaryValues[1] = values[valueIndex]; - ++valueIndex; - } else { - // Consume 0 value - // Remember to reverse the order. - binaryValues[1] = resultStack.Pop(); - binaryValues[0] = resultStack.Pop(); - } - var current = (double)binaryConverter.Convert(binaryValues, null, null, culture); - resultStack.Push(current); - } else { - // Consume 2 values - binaryValues[0] = values[valueIndex]; - ++valueIndex; - binaryValues[1] = values[valueIndex]; - ++valueIndex; - var current = (double)binaryConverter.Convert(binaryValues, null, null, culture); - resultStack.Push(current); - } - hasValue[level] = true; - } else { - throw new ArgumentException("Unknown math converter type."); - } - } - - return resultStack.Pop(); - } - - public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { - throw new NotSupportedException(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/MathMultiplyConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/MathOp/MathMultiplyConverter.cs deleted file mode 100644 index 9f32b7e..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/MathMultiplyConverter.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Globalization; - -namespace StarlightDirector.UI.Converters.MathOp { - public sealed class MathMultiplyConverter : BinaryOpConverterBase { - - public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - var v1 = GetObjectValue(value); - var v2 = GetObjectValue(parameter); - return v1 * v2; - } - - public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - var v1 = GetObjectValue(value); - var v2 = GetObjectValue(parameter); - if (v2.Equals(0d)) { - return v1 >= 0d ? double.PositiveInfinity : double.NegativeInfinity; - } else { - return v1 / v2; - } - } - - public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { - var v = GetObjectValues(values); - var result = v[0] * v[1]; - //return ConcatResult(values, result); - return result; - } - - public override object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { - throw new NotSupportedException(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/MathSubtractConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/MathOp/MathSubtractConverter.cs deleted file mode 100644 index d8e413d..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/MathSubtractConverter.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Globalization; - -namespace StarlightDirector.UI.Converters.MathOp { - public sealed class MathSubtractConverter : BinaryOpConverterBase { - - public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - var v1 = GetObjectValue(value); - var v2 = GetObjectValue(parameter); - return v1 - v2; - } - - public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - var v1 = GetObjectValue(value); - var v2 = GetObjectValue(parameter); - return v1 + v2; - } - - public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { - var v = GetObjectValues(values); - var result = v[0] - v[1]; - //return ConcatResult(values, result); - return result; - } - - public override object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { - throw new NotSupportedException(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/NegateConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/MathOp/NegateConverter.cs deleted file mode 100644 index 60ffc15..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/NegateConverter.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Globalization; -using System.Windows; - -namespace StarlightDirector.UI.Converters.MathOp { - public sealed class NegateConverter : UnaryOpConverterBase { - - public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - if (value is double) { - return -(double)value; - } else if (value is bool) { - return !(bool)value; - } else { - return DependencyProperty.UnsetValue; - } - } - - public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - if (value is double) { - return -(double)value; - } else if (value is bool) { - return !(bool)value; - } else { - return DependencyProperty.UnsetValue; - } - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/OpSymbolConverterBase.cs b/StarlightDirector/StarlightDirector/UI/Converters/MathOp/OpSymbolConverterBase.cs deleted file mode 100644 index 4d0642c..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/OpSymbolConverterBase.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace StarlightDirector.UI.Converters.MathOp { - public abstract class OpSymbolConverterBase : MathConverterBase { - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/RightParenConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/MathOp/RightParenConverter.cs deleted file mode 100644 index 00dd41f..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/RightParenConverter.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Globalization; -using System.Windows; - -namespace StarlightDirector.UI.Converters.MathOp { - public sealed class RightParenConverter : OpSymbolConverterBase { - - public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - return DependencyProperty.UnsetValue; - } - - public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - return DependencyProperty.UnsetValue; - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/UnaryOpConverterBase.cs b/StarlightDirector/StarlightDirector/UI/Converters/MathOp/UnaryOpConverterBase.cs deleted file mode 100644 index 083df13..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/MathOp/UnaryOpConverterBase.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace StarlightDirector.UI.Converters.MathOp { - public abstract class UnaryOpConverterBase : MathConverterBase { - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/MultiValueConverterGroup.cs b/StarlightDirector/StarlightDirector/UI/Converters/MultiValueConverterGroup.cs deleted file mode 100644 index 3738f82..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/MultiValueConverterGroup.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Windows.Data; - -namespace StarlightDirector.UI.Converters { - public sealed class MultiValueConverterGroup : List, IMultiValueConverter { - - public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { - if (!(parameter is ConverterGroupParameters)) { - throw new ArgumentException("Converter parameter should be ConverterGroupParameter.", nameof(parameter)); - } - var param = (ConverterGroupParameters)parameter; - if (param.Count != Count) { - throw new ArgumentException($"The number of parameters ({param.Count}) does not equal to the number of converters ({Count})."); - } - var current = (object)values; - var i = -1; - foreach (var converter in this) { - ++i; - var multiValueConverter = converter as IMultiValueConverter; - if (multiValueConverter != null) { - if (current is object[]) { - current = multiValueConverter.Convert((object[])current, targetType, param[i], culture); - } else { - current = multiValueConverter.Convert(new[] { current }, targetType, param[i], culture); - } - continue; - } - var valueConverter = converter as IValueConverter; - if (valueConverter != null) { - if (current is object[]) { - current = valueConverter.Convert(((object[])current)[0], targetType, param[i], culture); - } else { - current = valueConverter.Convert(current, targetType, param[i], culture); - } - continue; - } - throw new ArgumentException("One of the converters is not IValueConverter or IMultiValueConverter."); - } - return current; - } - - public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { - throw new NotSupportedException(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/NoteFlickTypeToHorizontalMirrorConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/NoteFlickTypeToHorizontalMirrorConverter.cs deleted file mode 100644 index 49af5ed..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/NoteFlickTypeToHorizontalMirrorConverter.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Globalization; -using System.Windows; -using System.Windows.Data; -using StarlightDirector.Entities; - -namespace StarlightDirector.UI.Converters { - public sealed class NoteFlickTypeToHorizontalMirrorConverter : IValueConverter { - - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - var flickType = (NoteFlickType)value; - NoteFlickType standard; - if (parameter == null || parameter == DependencyProperty.UnsetValue || !(parameter is NoteFlickType)) { - standard = Standard; - } else { - standard = (NoteFlickType)parameter; - } - return flickType == standard ? 1d : -1d; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - throw new NotSupportedException(); - } - - public static readonly NoteFlickType Standard = NoteFlickType.FlickRight; - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/NoteFlickTypeToVisibilityConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/NoteFlickTypeToVisibilityConverter.cs deleted file mode 100644 index 3ff1519..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/NoteFlickTypeToVisibilityConverter.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Globalization; -using System.Windows; -using System.Windows.Data; -using StarlightDirector.Entities; - -namespace StarlightDirector.UI.Converters { - public sealed class NoteFlickTypeToVisibilityConverter : IValueConverter { - - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - if (parameter == DependencyProperty.UnsetValue) { - return Visibility.Hidden; - } - var s = (NoteFlickType)value; - var e = (NoteFlickType)parameter; - return s == e ? Visibility.Visible : Visibility.Hidden; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - throw new NotSupportedException(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/NotePositionToTextConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/NotePositionToTextConverter.cs deleted file mode 100644 index 2aa4087..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/NotePositionToTextConverter.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Globalization; -using System.Windows.Data; -using StarlightDirector.Entities; - -namespace StarlightDirector.UI.Converters { - public sealed class NotePositionToTextConverter : IValueConverter { - - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - var v = (int)(NotePosition)value; - return v != 0 ? v.ToString() : string.Empty; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - throw new NotSupportedException(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/NullableBooleanToVisibilityConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/NullableBooleanToVisibilityConverter.cs deleted file mode 100644 index 1960f6c..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/NullableBooleanToVisibilityConverter.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Globalization; -using System.Windows; -using System.Windows.Data; - -namespace StarlightDirector.UI.Converters { - public sealed class NullableBooleanToVisibilityConverter : IValueConverter { - - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - var negate = (bool?)parameter; - if (negate == null) { - negate = false; - } - var b = (bool?)value; - if (b.HasValue) { - return (negate.Value ? !b.Value : b.Value) ? Visibility.Visible : Visibility.Collapsed; - } else { - return negate.Value ? Visibility.Visible : Visibility.Collapsed; - } - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - var b = (Visibility)value; - switch (b) { - case Visibility.Visible: - return true; - case Visibility.Hidden: - return null; - case Visibility.Collapsed: - return false; - default: - throw new ArgumentOutOfRangeException(); - } - } - - public static readonly bool Negate = true; - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/PositiveDoubleToStringConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/PositiveDoubleToStringConverter.cs deleted file mode 100644 index 29d6fee..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/PositiveDoubleToStringConverter.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Diagnostics; -using System.Globalization; -using System.Windows; -using System.Windows.Data; - -namespace StarlightDirector.UI.Converters { - public sealed class PositiveDoubleToStringConverter : IValueConverter { - - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - return ((double)value).ToString("F3"); - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - string stringValue; - try { - stringValue = (string)value; - } catch (InvalidCastException) { - return DependencyProperty.UnsetValue; - } - double d; - var b = double.TryParse(stringValue, out d); - if (!b) { - Debug.Print($"Object '{value}' is not a double."); - return DependencyProperty.UnsetValue; - } - if (d <= 0) { - Debug.Print($"Error: value {d:F2} is negative."); - return DependencyProperty.UnsetValue; - } - return d; - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/PositiveInt32ToStringConverter.cs b/StarlightDirector/StarlightDirector/UI/Converters/PositiveInt32ToStringConverter.cs deleted file mode 100644 index 21011d6..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/PositiveInt32ToStringConverter.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Diagnostics; -using System.Globalization; -using System.Windows; -using System.Windows.Data; - -namespace StarlightDirector.UI.Converters { - public sealed class PositiveInt32ToStringConverter : IValueConverter { - - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - string stringValue; - try { - stringValue = (string)value; - } catch (InvalidCastException) { - return DependencyProperty.UnsetValue; - } - double d; - var b = double.TryParse(stringValue, out d); - if (!b) { - Debug.Print($"Object '{value}' is not a number."); - return 0.0; - } - var n = (int)d; - if (n <= 0) { - Debug.Print($"Error: value {n} is negative."); - return 0.0; - } - return (double)n; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - return ((int)(double)value).ToString(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Converters/ValueConverterGroup.cs b/StarlightDirector/StarlightDirector/UI/Converters/ValueConverterGroup.cs deleted file mode 100644 index 7238d21..0000000 --- a/StarlightDirector/StarlightDirector/UI/Converters/ValueConverterGroup.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Windows.Data; - -namespace StarlightDirector.UI.Converters { - // http://stackoverflow.com/questions/2607490/is-there-a-way-to-chain-multiple-value-converters-in-xaml - public sealed class ValueConverterGroup : List, IValueConverter { - - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - if (!(parameter is ConverterGroupParameters)) { - throw new ArgumentException("Converter parameter should be ConverterGroupParameter.", nameof(parameter)); - } - var param = (ConverterGroupParameters)parameter; - if (param.Count != Count) { - throw new ArgumentException($"The number of parameters ({param.Count}) does not equal to the number of converters ({Count})."); - } - var current = value; - var i = -1; - foreach (var converter in this) { - ++i; - current = converter.Convert(value, targetType, param[i], culture); - } - return current; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - if (!(parameter is ConverterGroupParameters)) { - throw new ArgumentException("Converter parameter should be ConverterGroupParameter.", nameof(parameter)); - } - var param = (ConverterGroupParameters)parameter; - if (param.Count != Count) { - throw new ArgumentException($"The number of parameters ({param.Count}) does not equal to the number of converters ({Count})."); - } - var current = value; - var i = -1; - foreach (var converter in this) { - ++i; - current = converter.ConvertBack(value, targetType, param[i], culture); - } - return current; - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/CustomScroll.cs b/StarlightDirector/StarlightDirector/UI/CustomScroll.cs deleted file mode 100644 index b2f718f..0000000 --- a/StarlightDirector/StarlightDirector/UI/CustomScroll.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System.Diagnostics; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Input; -using System.Windows.Media; - -namespace StarlightDirector.UI { - // http://stackoverflow.com/questions/876994/adjust-flowdocumentreaders-scroll-increment-when-viewingmode-set-to-scroll - public static class CustomScroll { - - public static double GetScrollSpeed(DependencyObject obj) { - return (double)obj.GetValue(ScrollSpeedProperty); - } - - public static void SetScrollSpeed(DependencyObject obj, double value) { - obj.SetValue(ScrollSpeedProperty, value); - } - - public static bool GetIsScrollDirectionInverted(DependencyObject obj) { - return (bool)obj.GetValue(IsScrollDirectionInvertedProperty); - } - - public static void SetIsScrollDirectionInverted(DependencyObject obj, bool value) { - obj.SetValue(IsScrollDirectionInvertedProperty, value); - } - - public static readonly DependencyProperty ScrollSpeedProperty = DependencyProperty.RegisterAttached("ScrollSpeed", typeof(double), typeof(CustomScroll), - new FrameworkPropertyMetadata(1d, FrameworkPropertyMetadataOptions.Inherits | FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnScrollSpeedChanged)); - - public static readonly DependencyProperty IsScrollDirectionInvertedProperty = DependencyProperty.RegisterAttached("IsScrollDirectionInverted", typeof(bool), typeof(CustomScroll), - new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.Inherits)); - - private static DependencyObject GetScrollViewer(DependencyObject obj) { - // Return the DependencyObject if it is a ScrollViewer - if (obj is ScrollViewer) { - return obj; - } - var childrenCount = VisualTreeHelper.GetChildrenCount(obj); - for (var i = 0; i < childrenCount; i++) { - var child = VisualTreeHelper.GetChild(obj, i); - var result = GetScrollViewer(child); - if (result != null) { - return result; - } - } - return null; - } - - private static void OnScrollSpeedChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { - var host = obj as UIElement; - if (host != null) { - host.PreviewMouseWheel += OnPreviewMouseWheelScrolled; - } - } - - private static void OnPreviewMouseWheelScrolled(object sender, MouseWheelEventArgs e) { - var scrollHost = sender as DependencyObject; - if (scrollHost == null) { - return; - } - var scrollViewer = GetScrollViewer(scrollHost) as ScrollViewer; - if (scrollViewer == null) { - Debug.Print("ScrollSpeed attached property is not attached to an element containing a ScrollViewer."); - return; - } - var scrollSpeed = (double)scrollViewer.GetValue(ScrollSpeedProperty); - var invertDirection = (bool)scrollViewer.GetValue(IsScrollDirectionInvertedProperty); - if (invertDirection) { - scrollSpeed = -scrollSpeed; - } - var offset = scrollViewer.VerticalOffset - (e.Delta * scrollSpeed / 6); - if (offset < 0) { - scrollViewer.ScrollToVerticalOffset(0); - } else if (offset > scrollViewer.ExtentHeight) { - scrollViewer.ScrollToVerticalOffset(scrollViewer.ExtentHeight); - } else { - scrollViewer.ScrollToVerticalOffset(offset); - } - e.Handled = true; - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/EditMode.cs b/StarlightDirector/StarlightDirector/UI/EditMode.cs deleted file mode 100644 index 6a25a54..0000000 --- a/StarlightDirector/StarlightDirector/UI/EditMode.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.ComponentModel; - -namespace StarlightDirector.UI { - public enum EditMode { - - [Description("Mode: Create relations")] - CreateRelations, - [Description("Mode: Reset note")] - ResetNote - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/NoteRelationCollection.cs b/StarlightDirector/StarlightDirector/UI/NoteRelationCollection.cs deleted file mode 100644 index d981503..0000000 --- a/StarlightDirector/StarlightDirector/UI/NoteRelationCollection.cs +++ /dev/null @@ -1,140 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using StarlightDirector.Entities; -using StarlightDirector.UI.Controls.Primitives; -using TupleType = System.Tuple; -using InternalEntryType = System.Collections.Generic.KeyValuePair, StarlightDirector.Entities.NoteRelation>; - -namespace StarlightDirector.UI { - public sealed class NoteRelationCollection : IEnumerable { - - public NoteRelationCollection() { - InternalDictionary = new Dictionary(); - } - - public void Add(ScoreNote scoreNote1, ScoreNote scoreNote2, NoteRelation relation) { - var tuple = new TupleType(scoreNote1, scoreNote2); - InternalDictionary.Add(tuple, relation); - } - - public void Remove(ScoreNote scoreNote1, ScoreNote scoreNote2) { - var tuple = new TupleType(scoreNote1, scoreNote2); - var revTuple = new TupleType(scoreNote2, scoreNote1); - InternalDictionary.Remove(tuple); - InternalDictionary.Remove(revTuple); - } - - public int RemoveAll(ScoreNote oneOf) { - var contained = InternalDictionary.Where(kv => kv.Key.Item1.Equals(oneOf) || kv.Key.Item2.Equals(oneOf)).ToArray(); - var n = 0; - foreach (var kv in contained) { - InternalDictionary.Remove(kv.Key); - ++n; - } - return n; - } - - public int RemoveAll(ScoreNote oneOf, NoteRelation relation) { - var contained = InternalDictionary.Where(kv => (kv.Key.Item1.Equals(oneOf) || kv.Key.Item2.Equals(oneOf)) && kv.Value == relation).ToArray(); - var n = 0; - foreach (var kv in contained) { - InternalDictionary.Remove(kv.Key); - ++n; - } - return n; - } - - public void RemoveAll(Predicate match) { - if (match == null) { - throw new ArgumentNullException(nameof(match)); - } - var keys = InternalDictionary.Keys.ToArray(); - foreach (var key in keys) { - if (match(key.Item1) || match(key.Item2)) { - InternalDictionary.Remove(key); - } - } - } - - public bool ContainsNote(ScoreNote oneOf) { - return InternalDictionary.Any(kv => kv.Key.Item1.Equals(oneOf) || kv.Key.Item2.Equals(oneOf)); - } - - public bool ContainsPair(ScoreNote scoreNote1, ScoreNote scoreNote2) { - if (scoreNote1.Equals(scoreNote2)) { - return false; - } - return InternalDictionary.Any(kv => { - var i1 = kv.Key.Item1; - var i2 = kv.Key.Item2; - return (i1.Equals(scoreNote1) && i2.Equals(scoreNote2)) || (i1.Equals(scoreNote2) && i2.Equals(scoreNote1)); - }); - } - - public bool ContainsRelation(NoteRelation relation) { - return InternalDictionary.Any(kv => kv.Value == relation); - } - - public void Clear() { - InternalDictionary.Clear(); - } - - public IEnumerator GetEnumerator() { - return new NoteRelationEnumerator(InternalDictionary.GetEnumerator()); - } - - IEnumerator IEnumerable.GetEnumerator() { - return GetEnumerator(); - } - - public sealed class Entry { - - internal Entry(ScoreNote note1, ScoreNote note2, NoteRelation relation) { - ScoreNote1 = note1; - ScoreNote2 = note2; - Relation = relation; - } - - public ScoreNote ScoreNote1 { get; } - public ScoreNote ScoreNote2 { get; } - public NoteRelation Relation { get; } - - } - - private Dictionary InternalDictionary { get; } - - private class NoteRelationEnumerator : IEnumerator { - - public NoteRelationEnumerator(IEnumerator enumerator) { - Enumerator = enumerator; - } - - public void Dispose() { - Enumerator.Dispose(); - } - - public bool MoveNext() { - return Enumerator.MoveNext(); - } - - public void Reset() { - Enumerator.Reset(); - } - - public Entry Current { - get { - var current = Enumerator.Current; - return new Entry(current.Key.Item1, current.Key.Item2, current.Value); - } - } - - object IEnumerator.Current => Current; - - private IEnumerator Enumerator { get; } - - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/ScoreBarHitTestEventArgs.cs b/StarlightDirector/StarlightDirector/UI/ScoreBarHitTestEventArgs.cs deleted file mode 100644 index 25cef3b..0000000 --- a/StarlightDirector/StarlightDirector/UI/ScoreBarHitTestEventArgs.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Windows.Input; - -namespace StarlightDirector.UI { - public sealed class ScoreBarHitTestEventArgs : EventArgs { - - public ScoreBarHitTestEventArgs(ScoreBarHitTestInfo info, MouseButtonEventArgs buttonEventArgs) { - Info = info; - ButtonEventArgs = buttonEventArgs; - } - - public ScoreBarHitTestInfo Info { get; } - - public MouseButtonEventArgs ButtonEventArgs { get; } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/ScoreBarHitTestInfo.cs b/StarlightDirector/StarlightDirector/UI/ScoreBarHitTestInfo.cs deleted file mode 100644 index dd091d6..0000000 --- a/StarlightDirector/StarlightDirector/UI/ScoreBarHitTestInfo.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Windows; -using StarlightDirector.Entities; -using StarlightDirector.UI.Controls.Primitives; - -namespace StarlightDirector.UI { - public sealed class ScoreBarHitTestInfo { - - public ScoreBarHitTestInfo(ScoreBar scoreBar, Bar bar, Point hitPoint, int column, int row, bool isInNextBar, bool isValid) { - ScoreBar = scoreBar; - Bar = bar; - HitPoint = hitPoint; - Column = column; - Row = row; - IsInNextBar = isInNextBar; - IsValid = isValid; - } - - public ScoreBar ScoreBar { get; } - public Bar Bar { get; } - public int Column { get; } - public int Row { get; } - public Point HitPoint { get; } - public bool IsInNextBar { get; } - public bool IsValid { get; } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.AutoSave.cs b/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.AutoSave.cs deleted file mode 100644 index 7258b1f..0000000 --- a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.AutoSave.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Windows; -using StarlightDirector.Entities; -using StarlightDirector.Exchange; -using StarlightDirector.Extensions; - -namespace StarlightDirector.UI.Windows { - partial class MainWindow { - - private void SaveBackup() { - if (Project == null) { - return; - } - var path = App.GetDirectoryPath(App.DirectorPath.AutoBackup); - if (!Directory.Exists(path)) { - Directory.CreateDirectory(path); - } - string name; - if (!string.IsNullOrEmpty(Project.SaveFileName)) { - var fileInfo = new FileInfo(Project.SaveFileName); - name = fileInfo.Name; - } else { - name = "unnamed"; - } - path = Path.Combine(path, name); - ProjectIO.SaveAsBackup(Project, path); - var format = Application.Current.FindResource(App.ResourceKeys.ProjectAutoSavedToPromptTemplate); - var message = string.Format(format, path); - ShowTemporaryMessage(message); - } - - private static void ClearBackup() { - var directoryPath = App.GetDirectoryPath(App.DirectorPath.AutoBackup); - if (!Directory.Exists(directoryPath)) { - Directory.CreateDirectory(directoryPath); - } - var directory = new DirectoryInfo(directoryPath); - var files = directory.GetFiles(); - foreach (var fileInfo in files) { - if (!fileInfo.Exists) { - continue; - } - try { - // It happens sometimes. E.g., when Starlight Director is writing the autosave file at the same time. - fileInfo.Delete(); - } catch (IOException ex) { - MessageBox.Show(ex.Message, App.Title, MessageBoxButton.OK, MessageBoxImage.Exclamation); - } - } - } - - private void LoadBackup() { - var path = App.GetDirectoryPath(App.DirectorPath.AutoBackup); - if (!Directory.Exists(path)) { - Directory.CreateDirectory(path); - } - var directory = new DirectoryInfo(path); - var fileInfo = directory.EnumerateFiles().FirstOrDefault(); - if (fileInfo == null) { - return; - } - Project project; - string format, message; - try { - project = ProjectIO.Load(fileInfo.FullName); - } catch (Exception ex) { - // In case the autosave also failed. - var detailedMessage = ex.Message + Environment.NewLine + ex.StackTrace; - format = Application.Current.FindResource(App.ResourceKeys.AutoSaveRestorationFailedPromptTemplate); - message = string.Format(format, detailedMessage); - MessageBox.Show(message, App.Title, MessageBoxButton.OK, MessageBoxImage.Exclamation); - project = new Project(); - } - Project = Editor.Project = Project.Current = project; - project.IsChanged = true; - project.SaveFileName = null; - Editor.Score = project.GetScore(project.Difficulty); - format = Application.Current.FindResource(App.ResourceKeys.LoadedProjectFromAutoSavPromptTemplate); - message = string.Format(format, fileInfo.FullName); - ShowTemporaryMessage(message); - } - - private string GetBackupFileNameIfExists() { - var path = App.GetDirectoryPath(App.DirectorPath.AutoBackup); - if (!Directory.Exists(path)) { - Directory.CreateDirectory(path); - } - var directory = new DirectoryInfo(path); - return directory.EnumerateFiles().FirstOrDefault()?.FullName; - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Background.cs b/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Background.cs deleted file mode 100644 index a84a843..0000000 --- a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Background.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System.Windows.Input; - -namespace StarlightDirector.UI.Windows { - partial class MainWindow { - - public static readonly ICommand CmdBgScrollUpSmall = CommandHelper.RegisterCommand("Up"); - public static readonly ICommand CmdBgScrollDownSmall = CommandHelper.RegisterCommand("Down"); - public static readonly ICommand CmdBgScrollUpLarge = CommandHelper.RegisterCommand("PageUp"); - public static readonly ICommand CmdBgScrollDownLarge = CommandHelper.RegisterCommand("PageDown"); - public static readonly ICommand CmdBgScrollToStart = CommandHelper.RegisterCommand("Home"); - public static readonly ICommand CmdBgScrollToEnd = CommandHelper.RegisterCommand("End"); - - private void CmdBgScrollUpSmall_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.Score != null; - } - - private void CmdBgScrollUpSmall_Executed(object sender, ExecutedRoutedEventArgs e) { - ScrollViewer.ScrollToVerticalOffset(ScrollViewer.VerticalOffset - CustomScroll.GetScrollSpeed(ScrollViewer)); - } - - private void CmdBgScrollDownSmall_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.Score != null; - } - - private void CmdBgScrollDownSmall_Executed(object sender, ExecutedRoutedEventArgs e) { - ScrollViewer.ScrollToVerticalOffset(ScrollViewer.VerticalOffset + CustomScroll.GetScrollSpeed(ScrollViewer)); - } - - private void CmdBgScrollUpLarge_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.Score != null; - } - - private void CmdBgScrollUpLarge_Executed(object sender, ExecutedRoutedEventArgs e) { - ScrollViewer.ScrollToVerticalOffset(ScrollViewer.VerticalOffset - CustomScroll.GetScrollSpeed(ScrollViewer) * 10); - } - - private void CmdBgScrollDownLarge_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.Score != null; - } - - private void CmdBgScrollDownLarge_Executed(object sender, ExecutedRoutedEventArgs e) { - ScrollViewer.ScrollToVerticalOffset(ScrollViewer.VerticalOffset + CustomScroll.GetScrollSpeed(ScrollViewer) * 10); - } - - private void CmdBgScrollToStart_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.Score != null; - } - - private void CmdBgScrollToStart_Executed(object sender, ExecutedRoutedEventArgs e) { - ScrollViewer.ScrollToHome(); - } - - private void CmdBgScrollToEnd_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.Score != null; - } - - private void CmdBgScrollToEnd_Executed(object sender, ExecutedRoutedEventArgs e) { - ScrollViewer.ScrollToEnd(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.ContextMenu.cs b/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.ContextMenu.cs deleted file mode 100644 index 9407948..0000000 --- a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.ContextMenu.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Windows.Input; -using StarlightDirector.Entities; - -namespace StarlightDirector.UI.Windows { - partial class MainWindow { - - public static readonly ICommand CmdContextAddSpecialNoteVariantBpm = CommandHelper.RegisterCommand(); - - private void CmdContextAddSpecialNoteVariantBpm_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.Score != null && Editor.LastHitTestInfo != null && Editor.LastHitTestInfo.ScoreBar != null; - } - - private void CmdContextAddSpecialNoteVariantBpm_Executed(object sender, ExecutedRoutedEventArgs e) { - var hitTestInfo = Editor.LastHitTestInfo; - if (hitTestInfo == null) { - return; - } - Editor.AddSpecialNote(hitTestInfo.ScoreBar, hitTestInfo, false, NoteType.VariantBpm); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Edit.Bar.cs b/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Edit.Bar.cs deleted file mode 100644 index 4096c94..0000000 --- a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Edit.Bar.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; -using System.Diagnostics; -using System.Windows; -using System.Windows.Input; -using StarlightDirector.Extensions; - -namespace StarlightDirector.UI.Windows { - partial class MainWindow { - - public static readonly ICommand CmdEditBarAppend = CommandHelper.RegisterCommand("Ctrl+Alt+U"); - public static readonly ICommand CmdEditBarAppendMany = CommandHelper.RegisterCommand(); - public static readonly ICommand CmdEditBarInsert = CommandHelper.RegisterCommand("Ctrl+Alt+I"); - public static readonly ICommand CmdEditBarEdit = CommandHelper.RegisterCommand(); - public static readonly ICommand CmdEditBarDelete = CommandHelper.RegisterCommand("Ctrl+Delete"); - - private void CmdEditBarAppend_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.Score != null; - } - - private void CmdEditBarAppend_Executed(object sender, ExecutedRoutedEventArgs e) { - Editor.AppendScoreBar(); - NotifyProjectChanged(); - } - - private void CmdEditBarAppendMany_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.Score != null; - } - - private void CmdEditBarAppendMany_Executed(object sender, ExecutedRoutedEventArgs e) { - var count = (int)(double)e.Parameter; - Editor.AppendScoreBars(count); - NotifyProjectChanged(); - } - - private void CmdEditBarInsert_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.HasSingleSelectedScoreBar; - } - - private void CmdEditBarInsert_Executed(object sender, ExecutedRoutedEventArgs e) { - var scoreBar = Editor.GetSelectedScoreBar(); - if (scoreBar != null) { - var newScoreBar = Editor.InsertScoreBar(scoreBar); - Editor.SelectScoreBar(newScoreBar); - Editor.ScrollToScoreBar(newScoreBar); - NotifyProjectChanged(); - } - } - - private void CmdEditBarEdit_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.HasSingleSelectedScoreBar && false; - } - - private void CmdEditBarEdit_Executed(object sender, ExecutedRoutedEventArgs e) { - Debug.Print("Not implemented: edit bar"); - NotifyProjectChanged(); - } - - private void CmdEditBarDelete_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.HasSingleSelectedScoreBar; - } - - private void CmdEditBarDelete_Executed(object sender, ExecutedRoutedEventArgs e) { - var scoreBar = Editor.GetSelectedScoreBar(); - if (scoreBar != null) { - var result = MessageBox.Show(Application.Current.FindResource(App.ResourceKeys.ConfirmDeleteBarPrompt), App.Title, MessageBoxButton.YesNo, MessageBoxImage.Exclamation); - switch (result) { - case MessageBoxResult.Yes: - Editor.RemoveScoreBar(scoreBar); - NotifyProjectChanged(); - break; - case MessageBoxResult.No: - break; - default: - throw new ArgumentOutOfRangeException(nameof(result)); - } - } - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Edit.Mode.cs b/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Edit.Mode.cs deleted file mode 100644 index e03f918..0000000 --- a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Edit.Mode.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Diagnostics; -using System.Windows.Input; - -namespace StarlightDirector.UI.Windows { - partial class MainWindow { - - public static readonly ICommand CmdEditModeCreateRelations = CommandHelper.RegisterCommand("Alt+1", "Alt+NumPad1"); - public static readonly ICommand CmdEditModeResetNote = CommandHelper.RegisterCommand("Alt+2", "Alt+NumPad2"); - - private void CmdEditModeCreateRelations_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.EditMode != EditMode.CreateRelations; - } - - private void CmdEditModeCreateRelations_Executed(object sender, ExecutedRoutedEventArgs e) { - Editor.EditMode = EditMode.CreateRelations; - } - - private void CmdEditModeResetNote_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.EditMode != EditMode.ResetNote; - } - - private void CmdEditModeResetNote_Executed(object sender, ExecutedRoutedEventArgs e) { - Editor.EditMode = EditMode.ResetNote; - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Edit.Note.cs b/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Edit.Note.cs deleted file mode 100644 index 39bdbd9..0000000 --- a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Edit.Note.cs +++ /dev/null @@ -1,174 +0,0 @@ -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Windows.Input; -using StarlightDirector.Entities; -using StarlightDirector.UI.Controls.Primitives; - -namespace StarlightDirector.UI.Windows { - partial class MainWindow { - - public static readonly ICommand CmdEditNoteAdd = CommandHelper.RegisterCommand(); - public static readonly ICommand CmdEditNoteStartPosition1 = CommandHelper.RegisterCommand("Ctrl+1"); - public static readonly ICommand CmdEditNoteStartPosition2 = CommandHelper.RegisterCommand("Ctrl+2"); - public static readonly ICommand CmdEditNoteStartPosition3 = CommandHelper.RegisterCommand("Ctrl+3"); - public static readonly ICommand CmdEditNoteStartPosition4 = CommandHelper.RegisterCommand("Ctrl+4"); - public static readonly ICommand CmdEditNoteStartPosition5 = CommandHelper.RegisterCommand("Ctrl+5"); - public static readonly ICommand CmdEditNoteDelete = CommandHelper.RegisterCommand("Delete"); - public static readonly ICommand CmdEditNoteSetSlideTypeToFlick = CommandHelper.RegisterCommand("Ctrl+Shift+L"); - public static readonly ICommand CmdEditNoteSetSlideTypeToSlide = CommandHelper.RegisterCommand("Ctrl+L"); - - private void CmdEditNoteAdd_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.HasSingleSelectedScoreBar && false; - } - - private void CmdEditNoteAdd_Executed(object sender, ExecutedRoutedEventArgs e) { - Debug.Print("Not implemented: add note"); - NotifyProjectChanged(); - } - - private void CmdEditNoteStartPosition1_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.HasSelectedScoreNotes; - } - - private void CmdEditNoteStartPosition1_Executed(object sender, ExecutedRoutedEventArgs e) { - var scoreNotes = Editor.GetSelectedScoreNotes(); - ChangeNoteStartPositionTo(scoreNotes, NotePosition.Left); - Editor.UnselectAllScoreNotes(); - NotifyProjectChanged(); - } - - private void CmdEditNoteStartPosition2_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.HasSelectedScoreNotes; - } - - private void CmdEditNoteStartPosition2_Executed(object sender, ExecutedRoutedEventArgs e) { - var scoreNotes = Editor.GetSelectedScoreNotes(); - ChangeNoteStartPositionTo(scoreNotes, NotePosition.CenterLeft); - Editor.UnselectAllScoreNotes(); - NotifyProjectChanged(); - } - - private void CmdEditNoteStartPosition3_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.HasSelectedScoreNotes; - } - - private void CmdEditNoteStartPosition3_Executed(object sender, ExecutedRoutedEventArgs e) { - var scoreNotes = Editor.GetSelectedScoreNotes(); - ChangeNoteStartPositionTo(scoreNotes, NotePosition.Center); - Editor.UnselectAllScoreNotes(); - NotifyProjectChanged(); - } - - private void CmdEditNoteStartPosition4_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.HasSelectedScoreNotes; - } - - private void CmdEditNoteStartPosition4_Executed(object sender, ExecutedRoutedEventArgs e) { - var scoreNotes = Editor.GetSelectedScoreNotes(); - ChangeNoteStartPositionTo(scoreNotes, NotePosition.CenterRight); - Editor.UnselectAllScoreNotes(); - NotifyProjectChanged(); - } - - private void CmdEditNoteStartPosition5_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.HasSelectedScoreNotes; - } - - private void CmdEditNoteStartPosition5_Executed(object sender, ExecutedRoutedEventArgs e) { - var scoreNotes = Editor.GetSelectedScoreNotes(); - ChangeNoteStartPositionTo(scoreNotes, NotePosition.Right); - Editor.UnselectAllScoreNotes(); - NotifyProjectChanged(); - } - - private void CmdEditNoteDelete_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.HasSelectedScoreNotes; - } - - private void CmdEditNoteDelete_Executed(object sender, ExecutedRoutedEventArgs e) { - var scoreNotes = Editor.GetSelectedScoreNotes(); - Editor.RemoveScoreNotes(scoreNotes); - NotifyProjectChanged(); - } - - private static void ChangeNoteStartPositionTo(IEnumerable scoreNotes, NotePosition startPosition) { - foreach (var scoreNote in scoreNotes) { - var note = scoreNote.Note; - // A rule: in a hold pair, the latter one always follows the trail of the former one. - if (note.IsHoldStart) { - note.HoldTarget.StartPosition = note.StartPosition = startPosition; - } else if (note.IsHoldEnd) { - note.StartPosition = note.HoldTarget.StartPosition; - } else { - note.StartPosition = startPosition; - } - } - } - - private void CmdEditNoteSetSlideTypeToFlick_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - var notes = Editor.GetSelectedScoreNotes(); - // The problem is that, in Note.UpdateFlickTypeStep2(), if we check n2.IsFlick from the first to the end in temporal - // order, we will always get 'true'. Therefore we must calculate IsFlick in reversed temporal order. - var scoreNotes = notes as ScoreNote[] ?? notes.ToArray(); - e.CanExecute = scoreNotes.Any() && scoreNotes.All(t => t.Note.IsFlick || t.Note.IsSlide); - } - - private void CmdEditNoteSetSlideTypeToFlick_Executed(object sender, ExecutedRoutedEventArgs e) { - var notes = Editor.GetSelectedScoreNotes(); - var scoreNotes = notes as List ?? notes.ToList(); - scoreNotes.Sort((c1, c2) => Note.TimingThenPositionComparison(c1.Note, c2.Note)); - scoreNotes.Reverse(); - foreach (var scoreNote in scoreNotes) { - scoreNote.Note.Type = NoteType.TapOrFlick; - } - NotifyProjectChanged(); - } - - private void CmdEditNoteSetSlideTypeToSlide_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - var notes = Editor.GetSelectedScoreNotes(); - var scoreNotes = notes as List ?? notes.ToList(); - switch (scoreNotes.Count) { - case 0: - e.CanExecute = false; - return; - case 1: - var note = scoreNotes[0].Note; - if (note.HasPrevFlickOrSlide || note.HasNextFlickOrSlide) { - e.CanExecute = false; - return; - } - break; - } - - Note groupPrevNote = null; - scoreNotes.Sort((c1, c2) => Note.TimingThenPositionComparison(c1.Note, c2.Note)); - foreach (var scoreNote in scoreNotes) { - var note = scoreNote.Note; - if ((!note.IsFlick && !note.IsSlide) || note.IsHoldEnd) { - e.CanExecute = false; - return; - } - var prevNote = note.PrevFlickOrSlideNote; - if (prevNote != null && prevNote != groupPrevNote && !prevNote.IsSlide) { - e.CanExecute = false; - return; - } - groupPrevNote = note; - } - e.CanExecute = true; - } - - private void CmdEditNoteSetSlideTypeToSlide_Executed(object sender, ExecutedRoutedEventArgs e) { - var notes = Editor.GetSelectedScoreNotes(); - var scoreNotes = notes as List ?? notes.ToList(); - scoreNotes.Sort((c1, c2) => Note.TimingThenPositionComparison(c1.Note, c2.Note)); - scoreNotes.Reverse(); - foreach (var scoreNote in scoreNotes) { - scoreNote.Note.Type = NoteType.Slide; - } - NotifyProjectChanged(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Edit.cs b/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Edit.cs deleted file mode 100644 index cae5ff0..0000000 --- a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Edit.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Windows.Input; - -namespace StarlightDirector.UI.Windows { - partial class MainWindow { - - public static readonly ICommand CmdEditSelectAll = CommandHelper.RegisterCommand("Ctrl+A"); - - private void CmdEditSelectAll_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.ScoreNotes.Count > 0; - } - - private void CmdEditSelectAll_Executed(object sender, ExecutedRoutedEventArgs e) { - Editor.SelectAllScoreNotes(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.File.cs b/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.File.cs deleted file mode 100644 index b928c45..0000000 --- a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.File.cs +++ /dev/null @@ -1,165 +0,0 @@ -using System; -using System.Diagnostics; -using System.Windows; -using System.Windows.Input; -using Microsoft.Win32; -using StarlightDirector.Entities; -using StarlightDirector.Exchange; -using StarlightDirector.Extensions; - -namespace StarlightDirector.UI.Windows { - partial class MainWindow { - - public static readonly ICommand CmdFileNewProject = CommandHelper.RegisterCommand("Ctrl+N"); - public static readonly ICommand CmdFileOpenProject = CommandHelper.RegisterCommand("Ctrl+O"); - public static readonly ICommand CmdFileSaveProject = CommandHelper.RegisterCommand("Ctrl+S"); - public static readonly ICommand CmdFileSaveProjectAs = CommandHelper.RegisterCommand("F12"); - public static readonly ICommand CmdFilePreferences = CommandHelper.RegisterCommand(); - public static readonly ICommand CmdFileExit = CommandHelper.RegisterCommand("Ctrl+W", "Ctrl+Shift+Q"); - - private void CmdFileNewProject_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = true; - } - - private void CmdFileNewProject_Executed(object sender, ExecutedRoutedEventArgs e) { - if (ShouldPromptSaving) { - var result = MessageBox.Show(Application.Current.FindResource(App.ResourceKeys.ProjectChangedPrompt), App.Title, MessageBoxButton.YesNoCancel, MessageBoxImage.Exclamation); - switch (result) { - case MessageBoxResult.Yes: - CmdFileSaveProject.Execute(null); - return; - case MessageBoxResult.No: - break; - case MessageBoxResult.Cancel: - return; - default: - throw new ArgumentOutOfRangeException(nameof(result), result, null); - } - } - var project = new Project(); - Project.Current = project; - Project = project; - _autoSaveTimer.Stop(); - _autoSaveTimer.Start(); - ClearBackup(); - ScrollViewer.ScrollToEnd(); - } - - private void CmdFileOpenProject_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = true; - } - - private void CmdFileOpenProject_Executed(object sender, ExecutedRoutedEventArgs e) { - if (ShouldPromptSaving) { - var result = MessageBox.Show(Application.Current.FindResource(App.ResourceKeys.ProjectChangedPrompt), App.Title, MessageBoxButton.YesNoCancel, MessageBoxImage.Exclamation); - switch (result) { - case MessageBoxResult.Yes: - CmdFileSaveProject.Execute(null); - return; - case MessageBoxResult.No: - break; - case MessageBoxResult.Cancel: - return; - default: - throw new ArgumentOutOfRangeException(nameof(result), result, null); - } - } - var openDialog = new OpenFileDialog(); - openDialog.CheckPathExists = true; - openDialog.Multiselect = false; - openDialog.ShowReadOnly = false; - openDialog.ReadOnlyChecked = false; - openDialog.ValidateNames = true; - openDialog.Filter = Application.Current.FindResource(App.ResourceKeys.ProjectFileFilter); - var dialogResult = openDialog.ShowDialog(); - if (!(dialogResult ?? false)) { - return; - } - var fileName = openDialog.FileName; - var projectVersion = ProjectIO.CheckProjectFileVersion(fileName); - string prompt; - var projectChanged = false; - switch (projectVersion) { - case ProjectVersion.Unknown: - prompt = string.Format(Application.Current.FindResource(App.ResourceKeys.ProjectVersionInvalidPromptTemplate), fileName); - MessageBox.Show(prompt, Title, MessageBoxButton.OK, MessageBoxImage.Exclamation); - return; - case ProjectVersion.V0_1: - case ProjectVersion.V0_2: - prompt = string.Format(Application.Current.FindResource(App.ResourceKeys.ProjectUpgradeNeededPromptTemplate), fileName); - MessageBox.Show(prompt, Title, MessageBoxButton.OK, MessageBoxImage.Information); - projectChanged = true; - break; - } - var project = ProjectIO.Load(fileName, projectVersion); - Project = Editor.Project = Project.Current = project; - project.IsChanged = projectChanged; - Editor.Score = project.GetScore(project.Difficulty); - _autoSaveTimer.Stop(); - _autoSaveTimer.Start(); - ClearBackup(); - SaveBackup(); - ScrollViewer.ScrollToEnd(); - } - - private void CmdFileSaveProject_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = ShouldPromptSaving; - } - - private void CmdFileSaveProject_Executed(object sender, ExecutedRoutedEventArgs e) { - var project = Project; - if (!project.IsSaved) { - if (CmdFileSaveProjectAs.CanExecute(e.Parameter)) { - CmdFileSaveProjectAs.Execute(e.Parameter); - } else { - throw new InvalidOperationException(); - } - } else { - ProjectIO.Save(project); - CmdFileSaveProject.RaiseCanExecuteChanged(); - _autoSaveTimer.Stop(); - _autoSaveTimer.Start(); - ClearBackup(); - SaveBackup(); - } - } - - private void CmdFileSaveProjectAs_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = true; - } - - private void CmdFileSaveProjectAs_Executed(object sender, ExecutedRoutedEventArgs e) { - var saveDialog = new SaveFileDialog(); - saveDialog.OverwritePrompt = true; - saveDialog.ValidateNames = true; - saveDialog.Filter = Application.Current.FindResource(App.ResourceKeys.ProjectFileFilter); - var result = saveDialog.ShowDialog(); - if (!(result ?? false)) { - return; - } - ProjectIO.Save(Project, saveDialog.FileName); - CmdFileSaveProjectAs.RaiseCanExecuteChanged(); - _autoSaveTimer.Stop(); - _autoSaveTimer.Start(); - ClearBackup(); - SaveBackup(); - } - - private void CmdFilePreferences_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = false; - } - - private void CmdFilePreferences_Executed(object sender, ExecutedRoutedEventArgs e) { - Debug.Print("Not implemented: Preferences"); - } - - private void CmdFileExit_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = true; - } - - private void CmdFileExit_Executed(object sender, ExecutedRoutedEventArgs e) { - Close(); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Misc.cs b/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Misc.cs deleted file mode 100644 index ae05dba..0000000 --- a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Misc.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Windows.Input; -using StarlightDirector.Entities; - -namespace StarlightDirector.UI.Windows { - partial class MainWindow { - - public static readonly ICommand CmdScoreSwitchDifficulty = CommandHelper.RegisterCommand(); - - private void CmdScoreSwitchDifficulty_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - if (Project == null) { - e.CanExecute = false; - } else { - e.CanExecute = Project.Difficulty != (Difficulty)e.Parameter; - } - } - - private void CmdScoreSwitchDifficulty_Executed(object sender, ExecutedRoutedEventArgs e) { - if (Project != null) { - Project.Difficulty = (Difficulty)e.Parameter; - } - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Music.cs b/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Music.cs deleted file mode 100644 index 7036b98..0000000 --- a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Music.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System; -using System.IO; -using System.Windows; -using System.Windows.Input; -using Microsoft.Win32; -using NAudio.CoreAudioApi; -using NAudio.Wave; -using StarlightDirector.Extensions; -using AudioOut = NAudio.Wave.WasapiOut; - -namespace StarlightDirector.UI.Windows { - partial class MainWindow { - - public static readonly ICommand CmdMusicSelectWaveFile = CommandHelper.RegisterCommand(); - public static readonly ICommand CmdMusicPlay = CommandHelper.RegisterCommand(); - public static readonly ICommand CmdMusicStop = CommandHelper.RegisterCommand(); - - private void CmdMusicSelectWaveFile_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.Project != null; - } - - private void CmdMusicSelectWaveFile_Executed(object sender, ExecutedRoutedEventArgs e) { - var openDialog = new OpenFileDialog(); - openDialog.CheckPathExists = true; - openDialog.Multiselect = false; - openDialog.ShowReadOnly = false; - openDialog.ReadOnlyChecked = false; - openDialog.ValidateNames = true; - openDialog.Filter = Application.Current.FindResource(App.ResourceKeys.WaveFileFilter); - var dialogResult = openDialog.ShowDialog(); - if (dialogResult ?? false) { - Editor.Project.MusicFileName = openDialog.FileName; - CmdMusicSelectWaveFile.RaiseCanExecuteChanged(); - NotifyProjectChanged(); - } - } - - private void CmdMusicPlay_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - var r = Editor.Project?.HasMusic ?? false; - if (r) { - if (_selectedWaveOut != null) { - r = _selectedWaveOut.PlaybackState != PlaybackState.Playing; - } else { - r = Project.HasMusic; - } - } - e.CanExecute = r; - } - - private void CmdMusicPlay_Executed(object sender, ExecutedRoutedEventArgs e) { - PlayMusic(0); - } - - private void CmdMusicStop_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - var r = Editor.Project?.HasMusic ?? false; - if (r) { - r = _selectedWaveOut != null && _selectedWaveOut.PlaybackState == PlaybackState.Playing; - } - e.CanExecute = r; - } - - private void CmdMusicStop_Executed(object sender, ExecutedRoutedEventArgs e) { - StopMusic(); - } - - private void SelectedWaveOut_PlaybackStopped(object sender, EventArgs e) { - var waveOut = _selectedWaveOut; - if (waveOut != null) { - waveOut.PlaybackStopped -= SelectedWaveOut_PlaybackStopped; - waveOut.Dispose(); - _selectedWaveOut = null; - } - _waveReader?.Dispose(); - _waveReader = null; - } - - internal bool MusicLoaded => Editor.Project?.HasMusic ?? false; - - internal void PlayMusic(double startOffsetInMillis) { - var o = _selectedWaveOut; - if (o == null) { - o = new AudioOut(AudioClientShareMode.Shared, 0); - var fileStream = new FileStream(Project.MusicFileName, FileMode.Open, FileAccess.Read); - _waveReader = new WaveFileReader(fileStream); - o.PlaybackStopped += SelectedWaveOut_PlaybackStopped; - o.Init(_waveReader); - _selectedWaveOut = o; - } - - if (o.PlaybackState == PlaybackState.Playing) { - o.Stop(); - } - - _waveReader.CurrentTime = TimeSpan.FromMilliseconds(startOffsetInMillis); - o.Play(); - CmdMusicPlay.RaiseCanExecuteChanged(); - } - - internal void StopMusic() { - var o = _selectedWaveOut; - o?.Stop(); - SelectedWaveOut_PlaybackStopped(o, EventArgs.Empty); - CmdMusicStop.RaiseCanExecuteChanged(); - } - - internal TimeSpan? GetCurrentMusicTime() { - return _waveReader?.CurrentTime; - } - - internal TimeSpan? GetMusicTotalTime() { - return _waveReader?.TotalTime; - } - - private AudioOut _selectedWaveOut; - private WaveFileReader _waveReader; - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Preview.cs b/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Preview.cs deleted file mode 100644 index d74e60f..0000000 --- a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.Preview.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Linq; -using System.Windows.Input; - -namespace StarlightDirector.UI.Windows { - partial class MainWindow { - - public static readonly ICommand CmdPreviewToggle = CommandHelper.RegisterCommand("F5"); - - // Speed (Approach Rate, in [0, 10]) -> Approach Time (ms) - // Adapted from osu! - private static readonly int[] ArTable = { 1800, 1680, 1560, 1440, 1320, 1200, 1050, 900, 750, 600, 450 }; - - private void CmdPreviewToggle_Executed(object sender, ExecutedRoutedEventArgs e) { - ScorePreviewer.IsPreviewing = !ScorePreviewer.IsPreviewing; - if (ScorePreviewer.IsPreviewing) { - var fps = PreviewFps; - var startTime = 0; - var score = Project.Scores[Project.Difficulty]; - - // find start time, accurate even if BPM is variant - if (!PreviewFromStart && ScrollViewer.ExtentHeight > 0) - { - /* - * First, we find the percentage of scroll - * Since bar margin is constant, we can compute targetGrid = total #grids * percentage, which is the grid we should start at - * Then, we find where this grid is and set startTime to be its time - */ - var perc = (ScrollViewer.ExtentHeight - ScrollViewer.VerticalOffset - ScrollViewer.ViewportHeight)/ScrollViewer.ExtentHeight; - var lastBar = Editor.ScoreBars.LastOrDefault(); - - var totalGrids = 0; - foreach (var bar in score.Bars) - { - totalGrids += bar.TotalGridCount; - } - - if (perc > 0 && lastBar != null) - { - var projectOffset = Project.Settings.StartTimeOffset; - var targetGrid = totalGrids * perc; - var bar = score.Bars[0]; - var gridSum = 0; - for (int i = 1; i < score.Bars.Count; ++i) - { - gridSum += score.Bars[i].TotalGridCount; - if (gridSum > targetGrid) - { - gridSum -= score.Bars[i].TotalGridCount; - bar = score.Bars[i - 1]; - break; - } - } - - for (int i = 1; i < bar.TotalGridCount; ++i) - { - ++gridSum; - if (gridSum > targetGrid) - { - startTime = (int) (1000*(bar.TimeAtGrid(i - 1) - projectOffset) + 1000*projectOffset); - break; - } - } - } - } - - startTime += (int)(PreviewStartOffset*1000); - if (startTime < 0) - startTime = 0; - - double approachTime = ArTable[PreviewSpeed]; - ScorePreviewer.BeginPreview(score, fps, startTime, approachTime); - } else { - ScorePreviewer.EndPreview(); - } - } - - private void CmdPreviewToggle_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.Score != null; - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.View.cs b/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.View.cs deleted file mode 100644 index 2ea9795..0000000 --- a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.Commands.View.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Windows.Input; - -namespace StarlightDirector.UI.Windows { - partial class MainWindow { - - public static readonly ICommand CmdViewZoomIn = CommandHelper.RegisterCommand(); - public static readonly ICommand CmdViewZoomOut = CommandHelper.RegisterCommand(); - public static readonly ICommand CmdViewZoomToBeat = CommandHelper.RegisterCommand(); - public static readonly ICommand CmdViewMiscSetRelationIndicatorsVisibility = CommandHelper.RegisterCommand(); - public static readonly ICommand CmdViewMiscInvertScrollDirection = CommandHelper.RegisterCommand(); - - private void CmdViewZoomIn_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.Score != null; - } - - private void CmdViewZoomIn_Executed(object sender, ExecutedRoutedEventArgs e) { - Editor.ZoomInByCenter(); - } - - private void CmdViewZoomOut_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.Score != null; - } - - private void CmdViewZoomOut_Executed(object sender, ExecutedRoutedEventArgs e) { - Editor.ZoomOutByCenter(); - } - - private void CmdViewZoomToBeat_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = Editor.Score != null; - } - - private void CmdViewZoomToBeat_Executed(object sender, ExecutedRoutedEventArgs e) { - // 4, 8, 16, 24, etc. - var oneNthBeat = int.Parse((string)e.Parameter); - Editor.ZoomTo(oneNthBeat); - } - - private void CmdViewMiscSetRelationIndicatorsVisibility_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = true; - } - - private void CmdViewMiscSetRelationIndicatorsVisibility_Executed(object sender, ExecutedRoutedEventArgs e) { - Editor.AreRelationIndicatorsVisible = (bool)e.Parameter; - } - - private void CmdViewMiscInvertScrollDirection_CanExecute(object sender, CanExecuteRoutedEventArgs e) { - e.CanExecute = true; - } - - private void CmdViewMiscInvertScrollDirection_Executed(object sender, ExecutedRoutedEventArgs e) { - CustomScroll.SetIsScrollDirectionInverted(ScrollViewer, (bool)e.Parameter); - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.DependencyProperties.cs b/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.DependencyProperties.cs deleted file mode 100644 index 221a174..0000000 --- a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.DependencyProperties.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System.Diagnostics; -using System.Windows; -using System.Windows.Media; -using StarlightDirector.Entities; - -namespace StarlightDirector.UI.Windows { - partial class MainWindow { - - public Project Project { - get { return (Project)GetValue(ProjectProperty); } - set { SetValue(ProjectProperty, value); } - } - - public Brush AccentColorBrush { - get { return (Brush)GetValue(AccentColorBrushProperty); } - private set { SetValue(AccentColorBrushProperty, value); } - } - - public bool IsTemporaryMessageVisible { - get { return (bool)GetValue(IsTemporaryMessageVisibleProperty); } - private set { SetValue(IsTemporaryMessageVisibleProperty, value); } - } - - public string TemporaryMessage { - get { return (string)GetValue(TemporaryMessageProperty); } - private set { SetValue(TemporaryMessageProperty, value); } - } - - public double PreviewFps - { - get { return (double)GetValue(PreviewFpsProperty); } - set { SetValue(PreviewFpsProperty, value); } - } - - public bool PreviewFromStart - { - get { return (bool)GetValue(PreviewFromStartProperty); } - set { SetValue(PreviewFromStartProperty, value); } - } - - public int PreviewSpeed - { - get { return (int)GetValue(PreviewSpeedProperty); } - set { SetValue(PreviewSpeedProperty, value); } - } - - public double PreviewStartOffset - { - get { return (double)GetValue(PreviewStartOffsetProperty); } - set { SetValue(PreviewStartOffsetProperty, value); } - } - - public int PreviewBarLevel - { - get { return (int)GetValue(PreviewBarLevelProperty); } - set { SetValue(PreviewBarLevelProperty, value); } - } - - public static readonly DependencyProperty PreviewBarLevelProperty = - DependencyProperty.Register("PreviewBarLevel", typeof(int), typeof(MainWindow), new PropertyMetadata(1)); - - public static readonly DependencyProperty PreviewStartOffsetProperty = - DependencyProperty.Register("PreviewStartOffset", typeof(double), typeof(MainWindow), new PropertyMetadata(0.0)); - - public static readonly DependencyProperty PreviewSpeedProperty = - DependencyProperty.Register("PreviewSpeed", typeof(int), typeof(MainWindow), new PropertyMetadata(8)); - - public static readonly DependencyProperty PreviewFromStartProperty = - DependencyProperty.Register("PreviewFromStart", typeof(bool), typeof(MainWindow), new PropertyMetadata(false)); - - public static readonly DependencyProperty PreviewFpsProperty = - DependencyProperty.Register("PreviewFps", typeof(double), typeof(MainWindow), new PropertyMetadata(60.0)); - - public static readonly DependencyProperty ProjectProperty = DependencyProperty.Register(nameof(Project), typeof(Project), typeof(MainWindow), - new PropertyMetadata(null, OnProjectChanged)); - - public static readonly DependencyProperty AccentColorBrushProperty = DependencyProperty.Register(nameof(AccentColorBrush), typeof(Brush), typeof(MainWindow), - new PropertyMetadata(UIHelper.GetWindowColorizationBrush())); - - public static readonly DependencyProperty IsTemporaryMessageVisibleProperty = DependencyProperty.Register(nameof(IsTemporaryMessageVisible), typeof(bool), typeof(MainWindow), - new PropertyMetadata(false)); - - public static readonly DependencyProperty TemporaryMessageProperty = DependencyProperty.Register(nameof(TemporaryMessage), typeof(string), typeof(MainWindow), - new PropertyMetadata(string.Empty)); - - private static void OnProjectChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { - var window = obj as MainWindow; - var newProject = e.NewValue as Project; - var oldProject = e.OldValue as Project; - Debug.Assert(window != null); - window.Editor.Project = newProject; - window.Editor.Score = newProject?.GetScore(newProject.Difficulty); - - if (oldProject != null) { - oldProject.DifficultyChanged -= window.Project_DifficultyChanged; - } - if (newProject != null) { - newProject.DifficultyChanged += window.Project_DifficultyChanged; - } - } - - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.EventHandlers.cs b/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.EventHandlers.cs deleted file mode 100644 index 8baeceb..0000000 --- a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.EventHandlers.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.ComponentModel; -using System.Timers; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Input; -using StarlightDirector.Entities; -using StarlightDirector.Extensions; - -namespace StarlightDirector.UI.Windows { - partial class MainWindow { - - private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) { - var backupFileName = GetBackupFileNameIfExists(); - if (backupFileName != null) { - var format = Application.Current.FindResource(App.ResourceKeys.AutoSaveFileFoundPromptTemplate); - var message = string.Format(format, backupFileName); - var messageResult = MessageBox.Show(message, App.Title, MessageBoxButton.YesNo, MessageBoxImage.Question); - switch (messageResult) { - case MessageBoxResult.Yes: - LoadBackup(); - ScrollViewer.ScrollToEnd(); - break; - case MessageBoxResult.No: - Project = Project.Current; - break; - default: - throw new ArgumentOutOfRangeException(nameof(messageResult)); - } - } else { - Project = Project.Current; - } - _autoSaveTimer.Start(); - } - - private void MainWindow_OnClosing(object sender, CancelEventArgs e) { - if (ShouldPromptSaving) { - var result = MessageBox.Show(Application.Current.FindResource(App.ResourceKeys.ProjectChangedPrompt), App.Title, MessageBoxButton.YesNoCancel, MessageBoxImage.Exclamation); - switch (result) { - case MessageBoxResult.Yes: - if (CmdFileSaveProject.CanExecute(null)) { - CmdFileSaveProject.Execute(null); - } - if (!Project.IsSaved) { - e.Cancel = true; - return; - } - break; - case MessageBoxResult.No: - break; - case MessageBoxResult.Cancel: - e.Cancel = true; - return; - default: - throw new ArgumentOutOfRangeException(nameof(result), result, null); - } - } - _autoSaveTimer.Stop(); - ClearBackup(); - if (ScorePreviewer.IsPreviewing) { - ScorePreviewer.EndPreview(); - } - - _temporaryMessageTimer.Elapsed -= TemporaryMessageTimer_OnElapsed; - _temporaryMessageTimer?.Dispose(); - _temporaryMessageTimer = null; - _autoSaveTimer.Elapsed -= AutoSaveTimer_OnElapsed; - _autoSaveTimer?.Dispose(); - _autoSaveTimer = null; - } - - private void MainWindow_OnSourceInitialized(object sender, EventArgs e) { - this.RegisterWndProc(WndProc); - } - - private void ScrollViewer_OnPreviewMouseWheel(object sender, MouseWheelEventArgs e) { - if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { - if (e.Delta > 0) { - Editor.ZoomIn(); - } else { - Editor.ZoomOut(); - } - e.Handled = true; - } - } - - private void ScrollSpeedComboBoxItem_OnSelected(object sender, RoutedEventArgs e) { - var item = (ComboBoxItem)e.OriginalSource; - var newValue = double.Parse((string)item.Content); - if (ScrollViewer != null) { - CustomScroll.SetScrollSpeed(ScrollViewer, newValue); - } - } - - private void Project_DifficultyChanged(object sender, EventArgs e) { - var project = Project; - Editor.Score = project?.GetScore(project.Difficulty); - } - - private void TemporaryMessageTimer_OnElapsed(object sender, ElapsedEventArgs e) { - Dispatcher.Invoke(new Action(() => { - _temporaryMessageTimer.Stop(); - IsTemporaryMessageVisible = false; - TemporaryMessage = string.Empty; - })); - } - - private void AutoSaveTimer_OnElapsed(object sender, ElapsedEventArgs e) { - Dispatcher.Invoke(new Action(SaveBackup)); - } - - private void PreviewFpsComboBoxItem_Selected(object sender, RoutedEventArgs e) { - var item = e.OriginalSource as ComboBoxItem; - double fps; - var s = item?.Content?.ToString(); - if (s == "Unlimited") { - PreviewFps = double.PositiveInfinity; - return; - } - - if (double.TryParse(item?.Content?.ToString(), out fps)) { - PreviewFps = fps; - } - } - - private void PreviewSpeedComboBoxItem_Selected(object sender, RoutedEventArgs e) { - var item = e.OriginalSource as ComboBoxItem; - int speed; - if (int.TryParse(item?.Content?.ToString(), out speed)) { - PreviewSpeed = speed; - } - } - } -} diff --git a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.xaml b/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.xaml deleted file mode 100644 index 6c772c9..0000000 --- a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.xaml +++ /dev/null @@ -1,268 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ - - - - ] - - - - - - - - - diff --git a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.xaml.cs b/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.xaml.cs deleted file mode 100644 index 9250e9f..0000000 --- a/StarlightDirector/StarlightDirector/UI/Windows/MainWindow.xaml.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Timers; -using DereTore.Interop.OS; - -namespace StarlightDirector.UI.Windows { - public partial class MainWindow { - - public MainWindow() { - InitializeComponent(); - CommandHelper.InitializeCommandBindings(this); - _temporaryMessageTimer = new Timer(TemporaryMessageTimeout) { - AutoReset = true - }; - _temporaryMessageTimer.Elapsed += TemporaryMessageTimer_OnElapsed; - _autoSaveTimer = new Timer(AutoSaveInterval); - _autoSaveTimer.Elapsed += AutoSaveTimer_OnElapsed; - } - - public void ShowTemporaryMessage(string message) { - if (string.IsNullOrEmpty(message)) { - return; - } - TemporaryMessage = message; - if (IsTemporaryMessageVisible) { - _temporaryMessageTimer.Stop(); - _temporaryMessageTimer.Start(); - } else { - IsTemporaryMessageVisible = true; - _temporaryMessageTimer.Start(); - } - } - - internal void NotifyProjectChanged() { - if (Project != null) { - Project.IsChanged = true; - } - } - - private void OnDwmColorizationColorChanged(object sender, EventArgs e) { - AccentColorBrush = UIHelper.GetWindowColorizationBrush(); - } - - private IntPtr WndProc(IntPtr hWnd, int uMsg, IntPtr wParam, IntPtr lParam, ref bool handled) { - switch (uMsg) { - case NativeConstants.WM_DWMCOLORIZATIONCOLORCHANGED: - OnDwmColorizationColorChanged(this, EventArgs.Empty); - return IntPtr.Zero; - default: - return IntPtr.Zero; - } - } - - private bool ShouldPromptSaving => Project != null && Project.IsChanged; - - private Timer _temporaryMessageTimer; - private Timer _autoSaveTimer; - - private static readonly double TemporaryMessageTimeout = TimeSpan.FromSeconds(6).TotalMilliseconds; - private static readonly double AutoSaveInterval = TimeSpan.FromMinutes(3).TotalMilliseconds; - - } -} diff --git a/StarlightDirector/StarlightDirector/UIHelper.cs b/StarlightDirector/StarlightDirector/UIHelper.cs deleted file mode 100644 index 3427a20..0000000 --- a/StarlightDirector/StarlightDirector/UIHelper.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Windows; -using System.Windows.Interop; -using System.Windows.Media; -using DereTore.Interop.OS; - -namespace StarlightDirector { - public static class UIHelper { - - public static void RegisterWndProc(this Window window, HwndSourceHook hook) { - var interopHelper = new WindowInteropHelper(window); - var hWnd = interopHelper.Handle; - if (hWnd == IntPtr.Zero) { - throw new InvalidOperationException("Cannot get the window handle."); - } - var hwndSource = HwndSource.FromHwnd(hWnd); - if (hwndSource == null) { - throw new InvalidOperationException("Cannot construct a HwndSource from known window handle."); - } - hwndSource.AddHook(hook); - } - - public static SolidColorBrush GetWindowColorizationBrush() { - return new SolidColorBrush(GetWindowColorizationColor()); - } - - public static SolidColorBrush GetWindowColorizationBrush(bool opaque) { - return new SolidColorBrush(GetWindowColorizationColor(opaque)); - } - - public static Color GetWindowColorizationColor() { - return GetWindowColorizationColor(true); - } - - public static Color GetWindowColorizationColor(bool opaque) { - if (!GetColorizationAvailability()) { - return SystemColors.HighlightColor; - } - NativeStructures.DWMCOLORIZATIONPARAMS colorParams; - NativeMethods.DwmGetColorizationParameters(out colorParams); - var alpha = (byte)(opaque ? 255 : (colorParams.ColorizationColor >> 24) & 0xff); - var red = (byte)((colorParams.ColorizationColor >> 16) & 0xff); - var green = (byte)((colorParams.ColorizationColor >> 8) & 0xff); - var blue = (byte)(colorParams.ColorizationColor & 0xff); - return Color.FromArgb(alpha, red, green, blue); - } - - private static bool GetColorizationAvailability() { - var hLibrary = NativeMethods.LoadLibrary(NativeMethods.DWMAPI_LIB); - if (hLibrary == IntPtr.Zero) { - return false; - } - var procAddress = NativeMethods.GetProcAddress(hLibrary, (IntPtr)NativeMethods.DwmGetColorizationParameters_ORD); - var result = procAddress != IntPtr.Zero; - NativeMethods.FreeLibrary(hLibrary); - return result; - } - - } -} diff --git a/StarlightDirector/StarlightDirector/app.config b/StarlightDirector/StarlightDirector/app.config deleted file mode 100644 index 73b1379..0000000 --- a/StarlightDirector/StarlightDirector/app.config +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/StarlightDirector/StarlightDirector/app.manifest b/StarlightDirector/StarlightDirector/app.manifest deleted file mode 100644 index 22bbcbb..0000000 --- a/StarlightDirector/StarlightDirector/app.manifest +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/StarlightDirector/StarlightDirector/docs/user-guide_zh-CN.md b/StarlightDirector/StarlightDirector/docs/user-guide_zh-CN.md deleted file mode 100644 index 4efd934..0000000 --- a/StarlightDirector/StarlightDirector/docs/user-guide_zh-CN.md +++ /dev/null @@ -1,76 +0,0 @@ -# 简单操作说明 - -## Ribbon - -### 编辑 - -在编辑模式下可以切换编辑模式,这个模式用于创建滑条、双押等特殊note。 - -### 小节和音符 - -小节和音符的基本操作。 - -### 预览 - -预计以后会在软件内预览。现在请使用 *ScoreViewer*(`CgssScoreViewer.exe`,附于发行压缩包中)加载预览。 - -### 音乐 - -预计以后会在软件内直接生成 ACB。现在请使用 *MusicToolchain*(`MTC.exe`,附于发行压缩包中)创建 ACB。 - -### 谱面信息 - -切换不同难度谱面;调整**所有谱面**的**全局** BPM;调整**所有谱面**相对音乐起始偏移时间(秒)。 - -### 视图 - -缩放编辑器细分程度。最高可以到每节拍24分。 - -### 构建 - -将来的构建命令,现在暂未完全实现。 - -### 转换 - -导出当前谱面(可以在未保存的情况下进行)到 CSV 文件;从老版本的存档中导入工程(会自动修正细分级别)。 - -## 谱面编辑 - -添加小节后,编辑区会显示小节。 - -- 双击小节中无note的格点添加note(无视编辑模式)。 -- 按住 `Shift` 滚动滚轮可以快速滚动。 -- 按住 `Ctrl` 滚动滚轮可以缩放。 -- 如果跨小节的note长押难以连接,可以按住鼠标按键*并*滚动滚轮(`Shift` 仍然有效)。 -- note和小节周围发光表示已经选中。 -- `Delete` 键快速删除已选择的note(也可以用 Ribbon)。 - -切换到对应的编辑模式: - -- 选择:基本的选择功能,不会修改note的连接属性。 -- 双押(蓝色):在同一行上的两个note,在一个note上按下并拖放到另一个上创建双押。注意这个操作目前并不会自动完成(即,自动认为在同一行上的两个note就是双押)。 -- 滑条(紫色):在不同行不同列上的一组note,在其中一个note上按下并拖放到另一个上创建滑条。滑条起始、结束顺序和滑动方向会自动识别。在滑条的一端继续添加滑条可以添加为一组滑条。 - - 创建组时并不会更改已有的滑动顺序,请按顺序添加。 -- 长押(黄色):在同一列上的两个note,在一个note上按下并拖放到另一个上创建长押。 - - 双击长押的抬起note可以切换note结束时的滑动方向:无滑动、向左、向右。 -- 清除:单击一个note清除该note的所有特殊连接属性;在一个note上按下并拖放到另一个则清除二者对外部和相互之间**所有的**连接。 - -每个note的连接属性在它其中个3角上有所表示,有对应颜色的小圆圈则该note有该属性的对外连接。(人工查错使用) - -选中一个或多个note后,选择“Note” Ribbon 组中的“起始位置”命令可以修改所选择的note的起始位置。要注意的是,CGSS中有一条规则,长押抬起的note一定和按下的note起始和终止位置都一致。所以 Director 会忽略对长押抬起note的起始位置设置,并在设置长押按下note起始位置后自动调整对应的抬起note的起始位置。 - -> **创作完成后,不要忘了保存!**\_(:з」∠)\_ - -*MusicToolchain* 和 *ScoreViewer* 的使用方式很简单,自己摸索一下很快就知道了。 - -## 替换曲目 - -使用“工具”-“导出到 BDB 并替换”快速导出并替换所选择 BDB 中的谱面,自动导出到**制谱时所选择的难度**,如果没有对应难度存在则会报错。 - -在接下来的方法中,假设你用 `Resources/Testing/musicscores_m001.bdb`(お願い!シンデレラ)进行了替换。 - -1. 准备 `song_1001.acb`,这可以通过 *MusicToolchain* 制作。注意**制作时曲目编号填写“1001”**。制作完成后直接改名为 `song_1001.acb.lz4`(不要压缩)。 -2. 将 `song_1001.acb.lz4` 放到 IdolProxy 的 `dl/resources/High/Sound/Common/l`(看清楚是小写“l”不是数字“1”)目录下,如果没有这个目录则需要新建。 -3. 将替换后的 `musicscores_m001.bdb` 拖放到工具中的 `LZ4.exe` 上,生成 `musicscores_m001.bdb.lz4`。 -4. 将 `musicscores_m001.bdb.lz4` 放到 IdolProxy 的 `dl/resources/Generic` 目录下。 -5. 启动 IdolProxy,进入游戏。此时《お願い!シンデレラ》的曲目,和对应难度谱面应该已经被替换并可以自由玩。 diff --git a/StarlightDirector/StarlightDirector/packages.config b/StarlightDirector/StarlightDirector/packages.config deleted file mode 100644 index 2961316..0000000 --- a/StarlightDirector/StarlightDirector/packages.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/StarlightDirector/StarlightDirector/x64/sqlite3.dll b/StarlightDirector/StarlightDirector/x64/sqlite3.dll deleted file mode 100644 index 7b5d137..0000000 Binary files a/StarlightDirector/StarlightDirector/x64/sqlite3.dll and /dev/null differ diff --git a/StarlightDirector/StarlightDirector/x86/sqlite3.dll b/StarlightDirector/StarlightDirector/x86/sqlite3.dll deleted file mode 100644 index 468ee82..0000000 Binary files a/StarlightDirector/StarlightDirector/x86/sqlite3.dll and /dev/null differ diff --git a/appveyor.yml b/appveyor.yml index 2d42ccd..380f999 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,11 +1,11 @@ -# https://www.appveyor.com/docs/appveyor-yml/ +# https://www.appveyor.com/docs/appveyor-yml/ version: 0.7.6.{build} branches: only: - master skip_tags: true -image: Visual Studio 2015 +image: Visual Studio 2017 platform: - x86 - x64 @@ -19,8 +19,6 @@ environment: before_build: nuget restore after_build: - - 7z a deretore-toolkit.zip -r %APPVEYOR_BUILD_FOLDER%/StarlightDirector/StarlightDirector/bin/%PLATFORM%/%CONFIGURATION%/*.exe - - 7z a deretore-toolkit.zip -r %APPVEYOR_BUILD_FOLDER%/StarlightDirector/StarlightDirector/bin/%PLATFORM%/%CONFIGURATION%/*.dll - 7z a deretore-toolkit.zip -r %APPVEYOR_BUILD_FOLDER%/Apps/AcbMaker/bin/%PLATFORM%/%CONFIGURATION%/*.exe - 7z a deretore-toolkit.zip -r %APPVEYOR_BUILD_FOLDER%/Apps/AcbMaker/bin/%PLATFORM%/%CONFIGURATION%/*.dll - 7z a deretore-toolkit.zip -r %APPVEYOR_BUILD_FOLDER%/Apps/AcbUnzip/bin/%PLATFORM%/%CONFIGURATION%/*.exe @@ -39,9 +37,6 @@ after_build: - 7z a deretore-toolkit.zip -r %APPVEYOR_BUILD_FOLDER%/Apps/MusicToolchain/bin/%PLATFORM%/%CONFIGURATION%/*.dll - 7z a deretore-toolkit.zip -r %APPVEYOR_BUILD_FOLDER%/Apps/ScoreViewer/bin/%PLATFORM%/%CONFIGURATION%/*.exe - 7z a deretore-toolkit.zip -r %APPVEYOR_BUILD_FOLDER%/Apps/ScoreViewer/bin/%PLATFORM%/%CONFIGURATION%/*.dll - - 7z a deretore-toolkit.zip %APPVEYOR_BUILD_FOLDER%/StarlightDirector/StarlightDirector/bin/%PLATFORM%/%CONFIGURATION%/StarlightDirector.exe.config - - 7z a deretore-toolkit.zip -r %APPVEYOR_BUILD_FOLDER%/StarlightDirector/StarlightDirector/bin/%PLATFORM%/%CONFIGURATION%/*.mdb - - 7z a deretore-toolkit.zip -r %APPVEYOR_BUILD_FOLDER%/StarlightDirector/StarlightDirector/bin/%PLATFORM%/%CONFIGURATION%/*.wav - 7z a deretore-toolkit.zip -r %APPVEYOR_BUILD_FOLDER%/Apps/ScoreViewer/bin/%PLATFORM%/%CONFIGURATION%/*.wav - copy deretore-toolkit.zip deretore-toolkit-%PLATFORM%-v%APPVEYOR_BUILD_VERSION%-alpha-b%APPVEYOR_BUILD_NUMBER%.zip - copy deretore-toolkit.zip deretore-toolkit-%PLATFORM%.zip