musicplayer: album list scroll

This commit is contained in:
minjaesong
2024-01-08 01:42:13 +09:00
parent fe598c4e4d
commit a94a4f9824

View File

@@ -339,11 +339,16 @@ class MusicPlayer(private val ingame: TerrarumIngame) : UICanvas() {
ingame.musicGovernor.startMusic() // required for "intermittent" mode ingame.musicGovernor.startMusic() // required for "intermittent" mode
} }
} }
// prev page in the list // prev page in the playlist
else { else if (listViewPanelScroll == 1f) {
val scrollMax = ((currentlySelectedAlbum?.length ?: 0).toFloat() / PLAYLIST_LINES).ceilToInt() * PLAYLIST_LINES val scrollMax = ((currentlySelectedAlbum?.length ?: 0).toFloat() / PLAYLIST_LINES).ceilToInt() * PLAYLIST_LINES
playlistScroll = (playlistScroll - PLAYLIST_LINES) fmod scrollMax playlistScroll = (playlistScroll - PLAYLIST_LINES) fmod scrollMax
} }
// prev page in the albumlist
else if (listViewPanelScroll == 0f) {
val scrollMax = (albumsList.size.toFloat() / PLAYLIST_LINES).ceilToInt() * PLAYLIST_LINES
albumlistScroll = (albumlistScroll - PLAYLIST_LINES) fmod scrollMax
}
} }
2 -> { // stop 2 -> { // stop
if (mode < MODE_SHOW_LIST) { // disable stop button entirely on MODE_SHOW_LIST if (mode < MODE_SHOW_LIST) { // disable stop button entirely on MODE_SHOW_LIST
@@ -366,11 +371,16 @@ class MusicPlayer(private val ingame: TerrarumIngame) : UICanvas() {
ingame.musicGovernor.startMusic() // required for "intermittent" mode, does seemingly nothing on "continuous" mode ingame.musicGovernor.startMusic() // required for "intermittent" mode, does seemingly nothing on "continuous" mode
} }
} }
// next page in the list // next page in the playlist
else { else if (listViewPanelScroll == 1f) {
val scrollMax = ((currentlySelectedAlbum?.length ?: 0).toFloat() / PLAYLIST_LINES).ceilToInt() * PLAYLIST_LINES val scrollMax = ((currentlySelectedAlbum?.length ?: 0).toFloat() / PLAYLIST_LINES).ceilToInt() * PLAYLIST_LINES
playlistScroll = (playlistScroll + PLAYLIST_LINES) fmod scrollMax playlistScroll = (playlistScroll + PLAYLIST_LINES) fmod scrollMax
} }
// next page in the albumlist
else if (listViewPanelScroll == 0f) {
val scrollMax = (albumsList.size.toFloat() / PLAYLIST_LINES).ceilToInt() * PLAYLIST_LINES
albumlistScroll = (albumlistScroll + PLAYLIST_LINES) fmod scrollMax
}
} }
4 -> { // playlist 4 -> { // playlist
if (mode < MODE_SHOW_LIST) { if (mode < MODE_SHOW_LIST) {
@@ -959,10 +969,14 @@ class MusicPlayer(private val ingame: TerrarumIngame) : UICanvas() {
batch.draw(controlButtons.get(i, iconY), btnX, btnY) batch.draw(controlButtons.get(i, iconY), btnX, btnY)
// page number // page number
batch.color = Color(1f, 1f, 1f, alphaBase2 * buttonFadePerc) // don't use mouse-up effect batch.color = Color(1f, 1f, 1f, alphaBase2 * buttonFadePerc) // don't use mouse-up effect
val (thisPage, totalPage) = if (listViewPanelScroll >= 0.5f)
playlistScroll.div(PLAYLIST_LINES).plus(1) to (currentlySelectedAlbum?.length ?: 0).toFloat().div(PLAYLIST_LINES).ceilToInt()
else
albumlistScroll.div(PLAYLIST_LINES).plus(1) to albumsList.size.toFloat().div(PLAYLIST_LINES).ceilToInt()
Toolkit.drawTextCentered( Toolkit.drawTextCentered(
batch, App.fontSmallNumbers, batch, App.fontSmallNumbers,
"${(playlistScroll.div(PLAYLIST_LINES).plus(1).toString().padStart(4,' '))}/" + "${thisPage.toString().padStart(4,' ')}/" +
"${((currentlySelectedAlbum?.length ?: 0).toFloat().div(PLAYLIST_LINES).ceilToInt().toString().padEnd(4,' '))}", "${totalPage.toString().padEnd(4,' ')}",
120, anchorX.toInt() - 60, btnY.toInt() + 14 120, anchorX.toInt() - 60, btnY.toInt() + 14
) )
} }