From 1a458aaafe1a3315ce34f441e56cc9517b582496 Mon Sep 17 00:00:00 2001 From: yojohanshinwataikei Date: Mon, 18 Sep 2023 23:16:29 +0800 Subject: [PATCH] Fix RenderingBeatlineInfo update --- Assets/Misc/BuildTimestamp.txt | 2 +- .../GameplayRenderTexture.renderTexture | 4 +- .../Compose/Editing/Cursor/AdeGridManager.cs | 62 ++++++++++++------- 3 files changed, 43 insertions(+), 25 deletions(-) diff --git a/Assets/Misc/BuildTimestamp.txt b/Assets/Misc/BuildTimestamp.txt index e2501fa..36c7c23 100644 --- a/Assets/Misc/BuildTimestamp.txt +++ b/Assets/Misc/BuildTimestamp.txt @@ -1 +1 @@ -638301101700940049 \ No newline at end of file +638306756311392052 \ No newline at end of file diff --git a/Assets/Rendering/GameplayRenderTexture.renderTexture b/Assets/Rendering/GameplayRenderTexture.renderTexture index 657f48c..4a4d575 100644 --- a/Assets/Rendering/GameplayRenderTexture.renderTexture +++ b/Assets/Rendering/GameplayRenderTexture.renderTexture @@ -14,8 +14,8 @@ RenderTexture: m_DownscaleFallback: 0 m_IsAlphaChannelOptional: 0 serializedVersion: 5 - m_Width: 1864 - m_Height: 1049 + m_Width: 1860 + m_Height: 1047 m_AntiAliasing: 1 m_MipCount: -1 m_DepthStencilFormat: 94 diff --git a/Assets/Scripts/Compose/Editing/Cursor/AdeGridManager.cs b/Assets/Scripts/Compose/Editing/Cursor/AdeGridManager.cs index 4ad370e..ba3e676 100644 --- a/Assets/Scripts/Compose/Editing/Cursor/AdeGridManager.cs +++ b/Assets/Scripts/Compose/Editing/Cursor/AdeGridManager.cs @@ -53,7 +53,8 @@ public string PreferencesSavePath private List verticalXPositions = new List(); private List verticalYPositions = new List(); - private struct RenderingBeatlineInfo{ + private class RenderingBeatlineInfo + { public LineRenderer renderer; public int timing; }; @@ -148,11 +149,13 @@ private LineRenderer GetBeatlineInstance(int timing) { while (beatlineInstances.Count < beatlineInUse + 1) { - beatlineInstances.Add(new RenderingBeatlineInfo{ - renderer=Instantiate(BeatlinePrefab, transform).GetComponent(), - timing=timing, + beatlineInstances.Add(new RenderingBeatlineInfo + { + renderer = Instantiate(BeatlinePrefab, transform).GetComponent(), + timing = timing, }); } + beatlineInstances[beatlineInUse].timing = timing; return beatlineInstances[beatlineInUse++].renderer; } private LineRenderer GetVerticalInstance() @@ -285,7 +288,7 @@ private void CalculateMeasureTimes() for (int i = 0; i < Timings.Count; ++i) { int nextTiming = i + 1 >= Timings.Count ? ArcGameplayManager.Instance.Length : Timings[i + 1].Timing; - float segment = Timings[i].Bpm == 0 ? (nextTiming - Timings[i].Timing) : (60000 / Mathf.Abs(Timings[i].Bpm)*Timings[i].BeatsPerLine); + float segment = Timings[i].Bpm == 0 ? (nextTiming - Timings[i].Timing) : (60000 / Mathf.Abs(Timings[i].Bpm) * Timings[i].BeatsPerLine); if (segment < 1 || float.IsNaN(segment)) segment = Math.Max(nextTiming - Timings[i].Timing, 1); int primaryCount = 0; while (true) @@ -310,7 +313,7 @@ private void CalculateMeasureTimes() { var firstTiming = Timings[0]; int primaryCount = 1; - float segment = firstTiming.Bpm == 0 ? (firstTiming.Timing) : (60000 / Mathf.Abs(firstTiming.Bpm)*firstTiming.BeatsPerLine); + float segment = firstTiming.Bpm == 0 ? (firstTiming.Timing) : (60000 / Mathf.Abs(firstTiming.Bpm) * firstTiming.BeatsPerLine); if (segment < 1 || float.IsNaN(segment)) segment = Math.Max(firstTiming.Timing, 1); while (true) { @@ -453,7 +456,7 @@ private void UpdateVertical() public int AttachBeatlineTimingFromFos(float z) { var timingGroup = AdeTimingEditor.Instance.currentTimingGroup; - int defaultTiming=ArcTimingManager.Instance.CalculateTimingByPosition(-z * 1000, timingGroup) - ArcAudioManager.Instance.AudioOffset; + int defaultTiming = ArcTimingManager.Instance.CalculateTimingByPosition(-z * 1000, timingGroup) - ArcAudioManager.Instance.AudioOffset; if (!EnableBeatline) return defaultTiming; if (beatlineInUse == 0) return defaultTiming; List deltas = new List(); @@ -507,15 +510,20 @@ public int AttachScroll(int t, float scroll) deltas.Add(Mathf.Abs(beatlineTimings[i].Timing - t)); } int index = deltas.IndexOf(deltas.Min()); - if(deltas[index]<=1f || ArcGameplayManager.Instance.IsPlaying){ + if (deltas[index] <= 1f || ArcGameplayManager.Instance.IsPlaying) + { index += (scroll > 0 ? 1 : -1); - }else if(t>beatlineTimings[index].Timing){ + } + else if (t > beatlineTimings[index].Timing) + { index += (scroll > 0 ? 1 : 0); - }else{ + } + else + { index += (scroll > 0 ? 0 : -1); } - if (index >= deltas.Count) return Mathf.Max(t,beatlineTimings[deltas.Count-1].Timing); - else if (index < 0) return Mathf.Min(t,beatlineTimings[0].Timing); + if (index >= deltas.Count) return Mathf.Max(t, beatlineTimings[deltas.Count - 1].Timing); + else if (index < 0) return Mathf.Min(t, beatlineTimings[0].Timing); return beatlineTimings[index].Timing; } public int AttachBeatScroll(int t, float scroll) @@ -527,15 +535,20 @@ public int AttachBeatScroll(int t, float scroll) deltas.Add(Mathf.Abs(beatTimings[i] - t)); } int index = deltas.IndexOf(deltas.Min()); - if(deltas[index]<=1f || ArcGameplayManager.Instance.IsPlaying){ + if (deltas[index] <= 1f || ArcGameplayManager.Instance.IsPlaying) + { index += (scroll > 0 ? 1 : -1); - }else if(t>beatTimings[index]){ + } + else if (t > beatTimings[index]) + { index += (scroll > 0 ? 1 : 0); - }else{ + } + else + { index += (scroll > 0 ? 0 : -1); } - if (index >= deltas.Count) return Mathf.Max(t,beatTimings[deltas.Count-1]); - else if (index < 0) return Mathf.Min(t,beatTimings[0]); + if (index >= deltas.Count) return Mathf.Max(t, beatTimings[deltas.Count - 1]); + else if (index < 0) return Mathf.Min(t, beatTimings[0]); return beatTimings[index]; } public int AttachMeasureScroll(int t, float scroll) @@ -547,15 +560,20 @@ public int AttachMeasureScroll(int t, float scroll) deltas.Add(Mathf.Abs(measureTimings[i] - t)); } int index = deltas.IndexOf(deltas.Min()); - if(deltas[index]<=1f || ArcGameplayManager.Instance.IsPlaying){ + if (deltas[index] <= 1f || ArcGameplayManager.Instance.IsPlaying) + { index += (scroll > 0 ? 1 : -1); - }else if(t>measureTimings[index]){ + } + else if (t > measureTimings[index]) + { index += (scroll > 0 ? 1 : 0); - }else{ + } + else + { index += (scroll > 0 ? 0 : -1); } - if (index >= deltas.Count) return Mathf.Max(t,measureTimings[deltas.Count-1]); - else if (index < 0) return Mathf.Min(t,measureTimings[0]); + if (index >= deltas.Count) return Mathf.Max(t, measureTimings[deltas.Count - 1]); + else if (index < 0) return Mathf.Min(t, measureTimings[0]); return measureTimings[index]; } public int AttachTiming(int t)