mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-06 08:38:30 +09:00
queueing prev/specific song will keep the internal playlist shuffled
This commit is contained in:
@@ -228,8 +228,16 @@ class TerrarumMusicGovernor : MusicGovernor() {
|
|||||||
if (indexAtMusicBin < 0) throw IllegalArgumentException("The music does not exist on the internal songs list ($music)")
|
if (indexAtMusicBin < 0) throw IllegalArgumentException("The music does not exist on the internal songs list ($music)")
|
||||||
|
|
||||||
// rewrite musicBin
|
// rewrite musicBin
|
||||||
// TODO take shuffing into account
|
val newMusicBin = if (shuffled) songs.shuffled().toTypedArray().also {
|
||||||
val newMusicBin = Array(songs.size - indexAtMusicBin) { offset ->
|
// if shuffled,
|
||||||
|
// 1. create a shuffled version of songlist
|
||||||
|
// 2. swap two songs such that the songs[indexAtMusicBin] comes first
|
||||||
|
val swapTo = it.indexOf(songs[indexAtMusicBin])
|
||||||
|
val tmp = it[swapTo]
|
||||||
|
it[swapTo] = it[0]
|
||||||
|
it[0] = tmp
|
||||||
|
}
|
||||||
|
else Array(songs.size - indexAtMusicBin) { offset ->
|
||||||
val k = offset + indexAtMusicBin
|
val k = offset + indexAtMusicBin
|
||||||
songs[k]
|
songs[k]
|
||||||
}
|
}
|
||||||
@@ -241,8 +249,16 @@ class TerrarumMusicGovernor : MusicGovernor() {
|
|||||||
if (indexAtMusicBin !in songs.indices) throw IndexOutOfBoundsException("The index is outside of the internal songs list ($indexAtMusicBin/${songs.size})")
|
if (indexAtMusicBin !in songs.indices) throw IndexOutOfBoundsException("The index is outside of the internal songs list ($indexAtMusicBin/${songs.size})")
|
||||||
|
|
||||||
// rewrite musicBin
|
// rewrite musicBin
|
||||||
// TODO take shuffing into account
|
val newMusicBin = if (shuffled) songs.shuffled().toTypedArray().also {
|
||||||
val newMusicBin = Array(songs.size - indexAtMusicBin) { offset ->
|
// if shuffled,
|
||||||
|
// 1. create a shuffled version of songlist
|
||||||
|
// 2. swap two songs such that the songs[indexAtMusicBin] comes first
|
||||||
|
val swapTo = it.indexOf(songs[indexAtMusicBin])
|
||||||
|
val tmp = it[swapTo]
|
||||||
|
it[swapTo] = it[0]
|
||||||
|
it[0] = tmp
|
||||||
|
}
|
||||||
|
else Array(songs.size - indexAtMusicBin) { offset ->
|
||||||
val k = offset + indexAtMusicBin
|
val k = offset + indexAtMusicBin
|
||||||
songs[k]
|
songs[k]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user