diff --git a/Assets/Plugins/Microsoft.IO.RecyclableMemoryStream.dll.meta b/Assets/Plugins/Microsoft.IO.RecyclableMemoryStream.dll.meta index d492bd2..2c144c6 100644 --- a/Assets/Plugins/Microsoft.IO.RecyclableMemoryStream.dll.meta +++ b/Assets/Plugins/Microsoft.IO.RecyclableMemoryStream.dll.meta @@ -48,7 +48,7 @@ PluginImporter: second: enabled: 1 settings: - CPU: x86_64 + CPU: AnyCPU - first: Standalone: OSXUniversal second: diff --git a/Assets/Plugins/System.Buffers.dll.meta b/Assets/Plugins/System.Buffers.dll.meta index db5d27a..76341a1 100644 --- a/Assets/Plugins/System.Buffers.dll.meta +++ b/Assets/Plugins/System.Buffers.dll.meta @@ -48,7 +48,7 @@ PluginImporter: second: enabled: 1 settings: - CPU: x86_64 + CPU: AnyCPU - first: Standalone: OSXUniversal second: diff --git a/Assets/Plugins/System.Data.dll.meta b/Assets/Plugins/System.Data.dll.meta index 1e35cb2..933eb05 100644 --- a/Assets/Plugins/System.Data.dll.meta +++ b/Assets/Plugins/System.Data.dll.meta @@ -48,7 +48,7 @@ PluginImporter: second: enabled: 1 settings: - CPU: x86_64 + CPU: AnyCPU - first: Standalone: OSXUniversal second: diff --git a/Assets/Plugins/System.Memory.dll.meta b/Assets/Plugins/System.Memory.dll.meta index 392859c..4032372 100644 --- a/Assets/Plugins/System.Memory.dll.meta +++ b/Assets/Plugins/System.Memory.dll.meta @@ -48,7 +48,7 @@ PluginImporter: second: enabled: 1 settings: - CPU: x86_64 + CPU: AnyCPU - first: Standalone: OSXUniversal second: diff --git a/Assets/Plugins/System.Numerics.Vectors.dll.meta b/Assets/Plugins/System.Numerics.Vectors.dll.meta index 98c0614..f87d0e4 100644 --- a/Assets/Plugins/System.Numerics.Vectors.dll.meta +++ b/Assets/Plugins/System.Numerics.Vectors.dll.meta @@ -48,7 +48,7 @@ PluginImporter: second: enabled: 1 settings: - CPU: x86_64 + CPU: AnyCPU - first: Standalone: OSXUniversal second: diff --git a/Assets/Plugins/System.Runtime.CompilerServices.Unsafe.dll.meta b/Assets/Plugins/System.Runtime.CompilerServices.Unsafe.dll.meta index aa8d226..82d1e47 100644 --- a/Assets/Plugins/System.Runtime.CompilerServices.Unsafe.dll.meta +++ b/Assets/Plugins/System.Runtime.CompilerServices.Unsafe.dll.meta @@ -48,7 +48,7 @@ PluginImporter: second: enabled: 1 settings: - CPU: x86_64 + CPU: AnyCPU - first: Standalone: OSXUniversal second: diff --git a/Assets/Scripts/BGAPlayer.cs b/Assets/Scripts/BGAPlayer.cs index 9938a80..e93ef90 100644 --- a/Assets/Scripts/BGAPlayer.cs +++ b/Assets/Scripts/BGAPlayer.cs @@ -44,13 +44,13 @@ public void Load(int id, string path) var ext = path.Substring(path.LastIndexOf('.') + 1); if (Array.IndexOf(extensions, ext) == -1) { - Debug.Log("Unsupported BGA file extension: " + ext); + Logger.Log("Unsupported BGA file extension: " + ext); return; } var player = Camera.main.gameObject.AddComponent(); - Debug.Log("Loading BGA player " + id + " from " + path); - Debug.Log(player); + Logger.Log("Loading BGA player " + id + " from " + path); + Logger.Log(player); try { player.playOnAwake = false; @@ -67,7 +67,7 @@ public void Load(int id, string path) player.errorReceived += (source, message) => { player.Stop(); - Debug.Log("BGA player " + id + " error: " + message); + Logger.Log("BGA player " + id + " error: " + message); players.Remove(id); OnPrepareCompleted(player); }; @@ -76,8 +76,8 @@ public void Load(int id, string path) TotalPlayers++; } catch (Exception e) { - Debug.Log("Failed to load BGA player " + id + " from " + path); - Debug.Log(e); + Logger.Log("Failed to load BGA player " + id + " from " + path); + Logger.Log(e); OnPrepareCompleted(player); } } @@ -93,7 +93,7 @@ private void OnPrepareCompleted(VideoPlayer source) player.skipOnDrop = true; } - Debug.Log("All BGA players are prepared"); + Logger.Log("All BGA players are prepared"); OnAllPlayersLoaded?.Invoke(this, EventArgs.Empty); } } @@ -105,7 +105,7 @@ public void Update(long timeMicro) foreach (var id in ids) { if (!players.ContainsKey(id)) continue; - // Debug.Log("updating " + id + " at " + timeMicro); + // Logger.Log("updating " + id + " at " + timeMicro); if (timeMicro >= time) { players[id].skipOnDrop = true; @@ -146,7 +146,7 @@ public void PauseAll() public void Schedule(int id, long time) { if(!players.ContainsKey(id)) return; - Debug.Log("Scheduling " + id + " at " + time); + Logger.Log("Scheduling " + id + " at " + time); if (!state.Schedules.ContainsKey(time)) state.Schedules.Add(time, new List()); diff --git a/Assets/Scripts/BMPLoader.cs b/Assets/Scripts/BMPLoader.cs index a070a81..a24c14d 100644 --- a/Assets/Scripts/BMPLoader.cs +++ b/Assets/Scripts/BMPLoader.cs @@ -188,12 +188,12 @@ public BMPImage LoadBMP(BinaryReader aReader) BMPImage bmp = new BMPImage(); if (!ReadFileHeader(aReader, ref bmp.header)) { - Debug.LogError("Not a BMP file"); + Logger.LogError("Not a BMP file"); return null; } if (!ReadInfoHeader(aReader, ref bmp.info)) { - Debug.LogError("Unsupported header format"); + Logger.LogError("Unsupported header format"); return null; } if (bmp.info.compressionMethod != BMPComressionMode.BI_RGB @@ -203,7 +203,7 @@ public BMPImage LoadBMP(BinaryReader aReader) && bmp.info.compressionMethod != BMPComressionMode.BI_RLE8 ) { - Debug.LogError("Unsupported image format: " + bmp.info.compressionMethod); + Logger.LogError("Unsupported image format: " + bmp.info.compressionMethod); return null; } long offset = 14 + bmp.info.size; @@ -249,7 +249,7 @@ public BMPImage LoadBMP(BinaryReader aReader) ReadIndexedImage(aReader, bmp); else { - Debug.LogError("Unsupported file format: " + bmp.info.compressionMethod + " BPP: " + bmp.info.nBitsPerPixel); + Logger.LogError("Unsupported file format: " + bmp.info.compressionMethod + " BPP: " + bmp.info.nBitsPerPixel); return null; } return bmp; @@ -263,7 +263,7 @@ private static void Read32BitImage(BinaryReader aReader, BMPImage bmp) Color32[] data = bmp.imageData = new Color32[w * h]; if (aReader.BaseStream.Position + w * h * 4 > aReader.BaseStream.Length) { - Debug.LogError("Unexpected end of file."); + Logger.LogError("Unexpected end of file."); return; } int shiftR = GetShiftCount(bmp.rMask); @@ -294,7 +294,7 @@ private static void Read24BitImage(BinaryReader aReader, BMPImage bmp) Color32[] data = bmp.imageData = new Color32[w * h]; if (aReader.BaseStream.Position + count > aReader.BaseStream.Length) { - Debug.LogError("Unexpected end of file. (Have " + (aReader.BaseStream.Position + count) + " bytes, expected " + aReader.BaseStream.Length + " bytes)"); + Logger.LogError("Unexpected end of file. (Have " + (aReader.BaseStream.Position + count) + " bytes, expected " + aReader.BaseStream.Length + " bytes)"); return; } int shiftR = GetShiftCount(bmp.rMask); @@ -325,7 +325,7 @@ private static void Read16BitImage(BinaryReader aReader, BMPImage bmp) Color32[] data = bmp.imageData = new Color32[w * h]; if (aReader.BaseStream.Position + count > aReader.BaseStream.Length) { - Debug.LogError("Unexpected end of file. (Have " + (aReader.BaseStream.Position + count) + " bytes, expected " + aReader.BaseStream.Length + " bytes)"); + Logger.LogError("Unexpected end of file. (Have " + (aReader.BaseStream.Position + count) + " bytes, expected " + aReader.BaseStream.Length + " bytes)"); return; } int shiftR = GetShiftCount(bmp.rMask); @@ -361,7 +361,7 @@ private static void ReadIndexedImage(BinaryReader aReader, BMPImage bmp) Color32[] data = bmp.imageData = new Color32[w * h]; if (aReader.BaseStream.Position + count > aReader.BaseStream.Length) { - Debug.LogError("Unexpected end of file. (Have " + (aReader.BaseStream.Position + count) + " bytes, expected " + aReader.BaseStream.Length + " bytes)"); + Logger.LogError("Unexpected end of file. (Have " + (aReader.BaseStream.Position + count) + " bytes, expected " + aReader.BaseStream.Length + " bytes)"); return; } BitStreamReader bitReader = new BitStreamReader(aReader); @@ -372,7 +372,7 @@ private static void ReadIndexedImage(BinaryReader aReader, BMPImage bmp) int v = (int)bitReader.ReadBits(bitCount); if (v >= bmp.palette.Count) { - Debug.LogError("Indexed bitmap has indices greater than it's color palette"); + Logger.LogError("Indexed bitmap has indices greater than it's color palette"); return; } data[x + y * w] = bmp.palette[v]; diff --git a/Assets/Scripts/BMSParser.cs b/Assets/Scripts/BMSParser.cs index 6006200..35c4fe0 100644 --- a/Assets/Scripts/BMSParser.cs +++ b/Assets/Scripts/BMSParser.cs @@ -17,7 +17,7 @@ // ReSharper disable once InconsistentNaming public class BMSParser { - private const int TempKey = 8; + private const int TempKey = 16; public const int NoWav = -1; public const int MetronomeWav = -2; @@ -62,7 +62,7 @@ public void Parse(string path, bool addReadyMeasure = false, bool metaOnly = fal stopwatch.Start(); var bytes = File.ReadAllBytes(path); stopwatch.Stop(); - //Debug.Log($"Read file: {stopwatch.ElapsedMilliseconds}ms"); + //Logger.Log($"Read file: {stopwatch.ElapsedMilliseconds}ms"); var result = CharsetDetector.DetectFromBytes(bytes); var encoding = Encoding.GetEncoding(932); // 932: Shift-JIS if (result?.Detected?.Encoding != null) @@ -87,16 +87,13 @@ public void Parse(string path, bool addReadyMeasure = false, bool metaOnly = fal // read bytes line by line stopwatch.Reset(); stopwatch.Start(); - using (var br = new StreamReader(GameManager.Instance.GetMemoryStream(bytes), encoding)) + using (var ms = GameManager.Instance.GetMemoryStream(bytes)) + using (var br = new StreamReader(ms, encoding)) { string line; while ((line=br.ReadLine()) != null) { - if (cancellationToken.IsCancellationRequested) - { - return; - } - + cancellationToken.ThrowIfCancellationRequested(); if (!line.StartsWith("#")) continue; if (char.IsDigit(line[1]) && char.IsDigit(line[2]) && char.IsDigit(line[3]) && char.IsDigit(line[4]) && char.IsDigit(line[5]) && line[6] == ':') @@ -161,14 +158,11 @@ public void Parse(string path, bool addReadyMeasure = false, bool metaOnly = fal } } - LinkedList<(int channel, string data)>[] measures = new LinkedList<(int channel, string data)>[lastMeasure + 1]; + List<(int channel, string data)>[] measures = new List<(int channel, string data)>[lastMeasure + 1]; foreach (var line in mainDatas) { - if (cancellationToken.IsCancellationRequested) - { - return; - } + cancellationToken.ThrowIfCancellationRequested(); var measure = int.Parse(line.Substring(1, 3)) + (addReadyMeasure ? 1 : 0); @@ -176,25 +170,25 @@ public void Parse(string path, bool addReadyMeasure = false, bool metaOnly = fal var value = line.Substring(7); if (measures[measure] == null) { - var list = new LinkedList<(int channel, string data)>(); - list.AddLast((channel, value)); + var list = new List<(int channel, string data)>(); + list.Add((channel, value)); measures[measure] = list; } else { - measures[measure].AddLast((channel, value)); + measures[measure].Add((channel, value)); } } stopwatch.Stop(); - //Debug.Log($"Parsing took {stopwatch.ElapsedMilliseconds}ms"); + Logger.Log($"Parsing took {stopwatch.Elapsed.TotalMilliseconds}ms"); - // Debug.Log($"Parsing took {stopwatch.ElapsedMilliseconds}ms"); + // Logger.Log($"Parsing took {stopwatch.ElapsedMilliseconds}ms"); if (addReadyMeasure) { - measures[0] = new LinkedList<(int channel, string data)>(); - measures[0].AddLast((Channel.LaneAutoplay, "********")); + measures[0] = new List<(int channel, string data)>(); + measures[0].Add((Channel.LaneAutoplay, "********")); } @@ -203,27 +197,29 @@ public void Parse(string path, bool addReadyMeasure = false, bool metaOnly = fal var currentBpm = chart.ChartMeta.Bpm; var lastNote = new Note[TempKey]; var lnStart = new LongNote[TempKey]; - + for (var i = 0; i <= lastMeasure; ++i) { - if(cancellationToken.IsCancellationRequested) return; + cancellationToken.ThrowIfCancellationRequested(); if (measures[i] == null) { - measures[i] = new LinkedList<(int channel, string data)>(); + measures[i] = new List<(int channel, string data)>(); } // gcd (int, int) Measure measure = new(); SortedDictionary timelines = new(); - - foreach (var (channel, data) in measures[i]) + var measureRaw = measures[i]; + for (var m = 0; m < measureRaw.Count; m++) { - if(cancellationToken.IsCancellationRequested) return; + + var (channel, data) = measureRaw[m]; + cancellationToken.ThrowIfCancellationRequested(); var _channel = channel; if (channel == Channel.SectionRate) { measure.Scale = double.Parse(data); - // Debug.Log($"measure.scale: {measure.scale}, on measure {i}"); + // Logger.Log($"measure.scale: {measure.scale}, on measure {i}"); continue; } @@ -268,6 +264,10 @@ public void Parse(string path, bool addReadyMeasure = false, bool metaOnly = fal laneNumber = KeyAssign.Beat7[channel - Channel.P2MineKeyBase + 9]; _channel = Channel.P1MineKeyBase; } + if (_channel is Channel.LaneAutoplay or Channel.P1InvisibleKeyBase) + { + if(metaOnly) continue; + } if (laneNumber == -1) continue; if (laneNumber is 5 or 6 or 13 or 14) @@ -275,9 +275,12 @@ public void Parse(string path, bool addReadyMeasure = false, bool metaOnly = fal chart.ChartMeta.KeyMode = 7; } var dataCount = data.Length / 2; + for (var j = 0; j < dataCount; ++j) { + cancellationToken.ThrowIfCancellationRequested(); var val = data.Substring(j * 2, 2); + if (val == "00") { if (timelines.Count == 0 && j == 0) @@ -295,10 +298,7 @@ public void Parse(string path, bool addReadyMeasure = false, bool metaOnly = fal if (!timelines.ContainsKey(position)) timelines.Add(position, new TimeLine(TempKey)); var timeline = timelines[position]; - if (_channel is Channel.LaneAutoplay or Channel.P1InvisibleKeyBase) - { - if(metaOnly) break; - } + switch (_channel) { case Channel.LaneAutoplay: @@ -316,7 +316,7 @@ public void Parse(string path, bool addReadyMeasure = false, bool metaOnly = fal break; case Channel.BpmChange: timeline.Bpm = Convert.ToInt32(val, 16); - // Debug.Log($"BPM_CHANGE: {timeline.Bpm}, on measure {i}"); + // Logger.Log($"BPM_CHANGE: {timeline.Bpm}, on measure {i}"); timeline.BpmChange = true; @@ -333,14 +333,14 @@ public void Parse(string path, bool addReadyMeasure = false, bool metaOnly = fal case Channel.BpmChangeExtend: timeline.Bpm = bpmTable[DecodeBase36(val)]; - // Debug.Log($"BPM_CHANGE_EXTEND: {timeline.Bpm}, on measure {i}, {val}"); + // Logger.Log($"BPM_CHANGE_EXTEND: {timeline.Bpm}, on measure {i}, {val}"); timeline.BpmChange = true; break; case Channel.Stop: timeline.StopLength = StopLengthTable[DecodeBase36(val)]; - // Debug.Log($"STOP: {timeline.StopLength}, on measure {i}"); + // Logger.Log($"STOP: {timeline.StopLength}, on measure {i}"); break; case Channel.P1KeyBase: var ch = DecodeBase36(val); @@ -421,6 +421,7 @@ public void Parse(string path, bool addReadyMeasure = false, bool metaOnly = fal } } } + chart.TotalNotes = totalNotes; @@ -433,7 +434,7 @@ public void Parse(string path, bool addReadyMeasure = false, bool metaOnly = fal { if(cancellationToken.IsCancellationRequested) return; - // Debug.Log($"measure: {i}, position: {position}, lastPosition: {lastPosition} bpm: {bpm} scale: {measure.scale} interval: {240 * 1000 * 1000 * (position - lastPosition) * measure.scale / bpm}"); + // Logger.Log($"measure: {i}, position: {position}, lastPosition: {lastPosition} bpm: {bpm} scale: {measure.scale} interval: {240 * 1000 * 1000 * (position - lastPosition) * measure.scale / bpm}"); double interval = 240 * 1000 * 1000 * (position - lastPosition) * measure.Scale / currentBpm; timePassed += interval; timeline.Timing = (long)timePassed; @@ -445,7 +446,7 @@ public void Parse(string path, bool addReadyMeasure = false, bool metaOnly = fal } else timeline.Bpm = currentBpm; - // Debug.Log($"measure: {i}, position: {position}, lastPosition: {lastPosition}, bpm: {currentBpm} scale: {measure.Scale} interval: {interval} stop: {timeline.GetStopDuration()}"); + // Logger.Log($"measure: {i}, position: {position}, lastPosition: {lastPosition}, bpm: {currentBpm} scale: {measure.Scale} interval: {interval} stop: {timeline.GetStopDuration()}"); if(!metaOnly) measure.Timelines.Add(timeline); timePassed += timeline.GetStopDuration(); @@ -472,7 +473,7 @@ public void Parse(string path, bool addReadyMeasure = false, bool metaOnly = fal timePassed += (long)(240 * 1000 * 1000 * (1 - lastPosition) * measure.Scale / currentBpm); } - // Debug.Log($"Postprocessing took: "+ stopwatch.ElapsedMilliseconds + "ms"); + // Logger.Log($"Postprocessing took: "+ stopwatch.ElapsedMilliseconds + "ms"); @@ -562,7 +563,7 @@ private int DecodeBase36(string str) private void ParseHeader(string cmd, string xx, string value) { - // Debug.Log($"cmd: {cmd}, xx: {xx} isXXNull: {xx == null}, value: {value}"); + // Logger.Log($"cmd: {cmd}, xx: {xx} isXXNull: {xx == null}, value: {value}"); switch (cmd.ToUpper()) { case "PLAYER": @@ -593,7 +594,7 @@ private void ParseHeader(string cmd, string xx, string value) chart.ChartMeta.Bpm = double.Parse(value); else { - // Debug.Log($"BPM: {DecodeBase36(xx)} = {double.Parse(value)}"); + // Logger.Log($"BPM: {DecodeBase36(xx)} = {double.Parse(value)}"); bpmTable[DecodeBase36(xx)] = double.Parse(value); } @@ -614,7 +615,7 @@ private void ParseHeader(string cmd, string xx, string value) } catch (Exception e) { - Debug.LogWarning($"invalid playlevel: {value}"); + Logger.LogWarning($"invalid playlevel: {value}"); } break; @@ -640,7 +641,7 @@ private void ParseHeader(string cmd, string xx, string value) case "WAV": if (xx == null || value == null) { - Debug.LogWarning("WAV command requires two arguments"); + Logger.LogWarning("WAV command requires two arguments"); break; } @@ -649,7 +650,7 @@ private void ParseHeader(string cmd, string xx, string value) case "BMP": if (xx == null || value == null) { - Debug.LogWarning("WAV command requires two arguments"); + Logger.LogWarning("WAV command requires two arguments"); break; } @@ -675,7 +676,7 @@ private void ParseHeader(string cmd, string xx, string value) // case "ExtChr": // break; default: - Debug.LogWarning("Unknown command: " + cmd); + Logger.LogWarning("Unknown command: " + cmd); break; } } diff --git a/Assets/Scripts/BMSRenderer.cs b/Assets/Scripts/BMSRenderer.cs index 4a69ecb..b3d1695 100644 --- a/Assets/Scripts/BMSRenderer.cs +++ b/Assets/Scripts/BMSRenderer.cs @@ -127,7 +127,7 @@ private void Start() laneBeamSr.sortingLayerName = "LaneBeam"; laneBeamSr.drawMode = SpriteDrawMode.Sliced; laneBeamSr.size = new Vector2(laneWidth, NoteArea.transform.localScale.y); - Debug.Log("keys: " + GameManager.Instance.KeyMode); + Logger.Log("keys: " + GameManager.Instance.KeyMode); keyBombs = new GameObject[8]; laneBeamEffects = new LaneBeamEffect[8]; for (int i = 0; i < 8; i++) @@ -217,7 +217,7 @@ public void Draw(long currentTime) double currentPos = (currentTime < lastTimeline.Timing + lastTimeline.GetStopDuration()) ? lastTimeline.Pos : lastTimeline.Pos + (currentTime - (lastTimeline.Timing + lastTimeline.GetStopDuration())) * lastTimeline.Bpm / chart.ChartMeta.Bpm; - // Debug.Log($"lastTimeline.Timing: {lastTimeline.Timing}, lastTimtline.Pos: {lastTimeline.Pos}, currentTime: {currentTime}, currentPos: {currentPos}"); + // Logger.Log($"lastTimeline.Timing: {lastTimeline.Timing}, lastTimtline.Pos: {lastTimeline.Pos}, currentTime: {currentTime}, currentPos: {currentPos}"); for (int i = state.passedMeasureCount; i < measures.Count; i++) { @@ -237,7 +237,7 @@ public void Draw(long currentTime) if (shouldDestroyTimeline && isFirstMeasure) { state.passedTimelineCount++; - // Debug.Log($"Destroying timeline, passedTimelineCount: {passedTimelineCount}, total timeline count: {measure.Timelines.Count}"); + // Logger.Log($"Destroying timeline, passedTimelineCount: {passedTimelineCount}, total timeline count: {measure.Timelines.Count}"); } foreach (var note in timeline.Notes) @@ -301,7 +301,7 @@ public void Draw(long currentTime) state.passedTimelineCount = 0; state.passedMeasureCount++; DestroyMeasureLine(measure); - // Debug.Log($"Skipping measure since all {measure.Timelines.Count} timelines are passed, passedMeasureCount: {passedMeasureCount}"); + // Logger.Log($"Skipping measure since all {measure.Timelines.Count} timelines are passed, passedMeasureCount: {passedMeasureCount}"); } } diff --git a/Assets/Scripts/ChartDBHelper.cs b/Assets/Scripts/ChartDBHelper.cs index c4da772..5a302f4 100644 --- a/Assets/Scripts/ChartDBHelper.cs +++ b/Assets/Scripts/ChartDBHelper.cs @@ -170,7 +170,7 @@ public List SelectAll(SqliteConnection connection) } catch (Exception e) { - Debug.LogError("Invalid chart data: " + e.Message); + Logger.LogError("Invalid chart data: " + e.Message); } } return chartMetas; @@ -243,7 +243,7 @@ public List Search(SqliteConnection connection, string text) } catch (Exception e) { - Debug.LogError("Invalid chart data: " + e.Message); + Logger.LogError("Invalid chart data: " + e.Message); } } return chartMetas; diff --git a/Assets/Scripts/ChartSelectScreen.cs b/Assets/Scripts/ChartSelectScreen.cs index 95e3d35..6ad70cc 100644 --- a/Assets/Scripts/ChartSelectScreen.cs +++ b/Assets/Scripts/ChartSelectScreen.cs @@ -58,7 +58,7 @@ private void OnEnable() // chartButton.GetComponent().ChartTitle.text = chartFile.Name; // chartButton.GetComponent