diff --git a/app/src/main/java/com/kyhsgeekcode/dereinfo/FumenRenderer.kt b/app/src/main/java/com/kyhsgeekcode/dereinfo/FumenRenderer.kt index 0e4b65d..f27c06b 100644 --- a/app/src/main/java/com/kyhsgeekcode/dereinfo/FumenRenderer.kt +++ b/app/src/main/java/com/kyhsgeekcode/dereinfo/FumenRenderer.kt @@ -63,12 +63,12 @@ class FumenRenderer( } val pkgName = context.packageName for (note in notes) { - fun calcPos(theNote: Note): Pair { + fun calcPos(theNote: Note): Triple { val totalHeightPos = heightPerSec * theNote.time val linenumber = (totalHeightPos / maxHeight).toInt() val realWidthPos = calcNoteX(linenumber, widthPerSubLane, theNote) val realHeightPos = calcNoteY(totalHeightPos) - return Pair(realWidthPos, realHeightPos) + return Triple(realWidthPos, realHeightPos, linenumber) } val realX: Float @@ -80,13 +80,50 @@ class FumenRenderer( if (!note.nextNotes.isNullOrEmpty()) { val nextNote = note.nextNotes[0] val nextNoteCoord = calcPos(nextNote) - canvas.drawLine( - realX, - realY, - nextNoteCoord.first, - nextNoteCoord.second, - connectPaint - ) + var leftDy = (nextNote.time - note.time) * heightPerSec + if (coord.third < nextNoteCoord.third) { + // stop & cut and continue + val dxdy = (widthPerSubLane * (nextNote.endline - note.endline)).rem(width.toFloat()) / leftDy + var beforeX = realX + val destX = nextNoteCoord.first + var afterX: Float = beforeX + realY * dxdy + canvas.drawLine( + realX, + realY, + afterX, + 0.0f, + connectPaint + ) + leftDy -= realY + beforeX = afterX + width + while (leftDy >= maxHeight) { + afterX = beforeX + maxHeight * dxdy + canvas.drawLine( + beforeX, + maxHeight.toFloat(), + afterX, + 0.0f, + connectPaint + ) + leftDy -= maxHeight + beforeX = afterX + width + } + canvas.drawLine( + beforeX, // x dest just before + maxHeight.toFloat(), + nextNoteCoord.first, + nextNoteCoord.second, + connectPaint + ) + } else { + canvas.drawLine( + realX, + realY, + nextNoteCoord.first, + nextNoteCoord.second, + connectPaint + ) + } } } // if(note.isLong() || note.isSlide()) { diff --git a/app/src/main/java/com/kyhsgeekcode/dereinfo/model/Note.kt b/app/src/main/java/com/kyhsgeekcode/dereinfo/model/Note.kt index 22488d4..118ac03 100644 --- a/app/src/main/java/com/kyhsgeekcode/dereinfo/model/Note.kt +++ b/app/src/main/java/com/kyhsgeekcode/dereinfo/model/Note.kt @@ -13,7 +13,7 @@ class Note( val startline: Float, val endline: Float, val previds: Array, - val sync : Boolean = false, + val sync: Boolean = false, val tick: Int = 10 ) { val nextNotes = arrayListOf()