mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-12 06:41:51 +09:00
musicplayer: click on the song title to change the music
This commit is contained in:
@@ -225,9 +225,23 @@ class TerrarumMusicGovernor : MusicGovernor() {
|
||||
*/
|
||||
fun unshiftPlaylist(music: MusicContainer) {
|
||||
val indexAtMusicBin = songs.indexOf(music)
|
||||
if (indexAtMusicBin < 0) throw IllegalArgumentException("The music does not exist on the interal songs list ($music)")
|
||||
if (indexAtMusicBin < 0) throw IllegalArgumentException("The music does not exist on the internal songs list ($music)")
|
||||
|
||||
// rewrite musicBin
|
||||
// TODO take shuffing into account
|
||||
val newMusicBin = Array(songs.size - indexAtMusicBin) { offset ->
|
||||
val k = offset + indexAtMusicBin
|
||||
songs[k]
|
||||
}
|
||||
|
||||
musicBin = ArrayList(newMusicBin.toList())
|
||||
}
|
||||
|
||||
fun queueIndexFromPlaylist(indexAtMusicBin: Int) {
|
||||
if (indexAtMusicBin !in songs.indices) throw IndexOutOfBoundsException("The index is outside of the internal songs list ($indexAtMusicBin/${songs.size})")
|
||||
|
||||
// rewrite musicBin
|
||||
// TODO take shuffing into account
|
||||
val newMusicBin = Array(songs.size - indexAtMusicBin) { offset ->
|
||||
val k = offset + indexAtMusicBin
|
||||
songs[k]
|
||||
|
||||
Reference in New Issue
Block a user