mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-15 04:54:05 +09:00
musicplayer: playlist printing
This commit is contained in:
@@ -117,6 +117,8 @@ class MusicPlayer(private val ingame: TerrarumIngame) : UICanvas() {
|
|||||||
|
|
||||||
private val playlist: List<MusicContainer>
|
private val playlist: List<MusicContainer>
|
||||||
get() = ingame.musicGovernor.extortField<List<MusicContainer>>("songs")!!
|
get() = ingame.musicGovernor.extortField<List<MusicContainer>>("songs")!!
|
||||||
|
private val playlistName: String
|
||||||
|
get() = ingame.musicGovernor.playlistName
|
||||||
|
|
||||||
fun registerPlaylist(path: String, fileToName: JsonValue, shuffled: Boolean, diskJockeyingMode: String) {
|
fun registerPlaylist(path: String, fileToName: JsonValue, shuffled: Boolean, diskJockeyingMode: String) {
|
||||||
ingame.musicGovernor.queueDirectory(path, shuffled, diskJockeyingMode) { filename ->
|
ingame.musicGovernor.queueDirectory(path, shuffled, diskJockeyingMode) { filename ->
|
||||||
@@ -525,8 +527,8 @@ class MusicPlayer(private val ingame: TerrarumIngame) : UICanvas() {
|
|||||||
val drawAlpha = 0.75f * (if (reverse) 1f - alpha0 else alpha0).pow(3f)// + (playListAnimAkku[i].pow(2f) * 1.2f)
|
val drawAlpha = 0.75f * (if (reverse) 1f - alpha0 else alpha0).pow(3f)// + (playListAnimAkku[i].pow(2f) * 1.2f)
|
||||||
|
|
||||||
// assuming both view has the same list dimension
|
// assuming both view has the same list dimension
|
||||||
drawAlbumList(camera, delta, batch, (anchorX + offX2).roundToFloat(), (y + 15).roundToFloat(), drawAlpha * alpha1, width / (widthForList + METERS_WIDTH + maskOffWidth))
|
drawAlbumList(camera, delta, batch, (anchorX + offX2).roundToFloat(), (y + 11).roundToFloat(), drawAlpha * alpha1, width / (widthForList + METERS_WIDTH + maskOffWidth))
|
||||||
drawPlayList(camera, delta, batch, (anchorX + offX1).roundToFloat(), (y + 15).roundToFloat(), drawAlpha * alpha2, width / (widthForList + METERS_WIDTH + maskOffWidth))
|
drawPlayList(camera, delta, batch, (anchorX + offX1).roundToFloat(), (y + 11).roundToFloat(), drawAlpha * alpha2, width / (widthForList + METERS_WIDTH + maskOffWidth))
|
||||||
|
|
||||||
// update playListAnimAkku
|
// update playListAnimAkku
|
||||||
for (i in playListAnimAkku.indices) {
|
for (i in playListAnimAkku.indices) {
|
||||||
@@ -543,14 +545,16 @@ class MusicPlayer(private val ingame: TerrarumIngame) : UICanvas() {
|
|||||||
private val PLAYLIST_LEFT_GAP = METERS_WIDTH.toInt() + maskOffWidth
|
private val PLAYLIST_LEFT_GAP = METERS_WIDTH.toInt() + maskOffWidth
|
||||||
private val PLAYLIST_NAME_LEN = widthForList
|
private val PLAYLIST_NAME_LEN = widthForList
|
||||||
private val PLAYLIST_LINE_HEIGHT = 28f
|
private val PLAYLIST_LINE_HEIGHT = 28f
|
||||||
private val PLAYLIST_LINES = 10
|
private val PLAYLIST_LINES = 8
|
||||||
|
|
||||||
private val widthForMouseUp = (nameStrMaxLen + METERS_WIDTH + maskOffWidth).toInt()
|
private val widthForMouseUp = (nameStrMaxLen + METERS_WIDTH + maskOffWidth).toInt()
|
||||||
private val heightThin = 28
|
private val heightThin = 28
|
||||||
private val heightControl = 80
|
private val heightControl = 80
|
||||||
private val heightList = 113 + PLAYLIST_LINES * PLAYLIST_LINE_HEIGHT.toInt()
|
private val heightList = 109 + PLAYLIST_LINES * PLAYLIST_LINE_HEIGHT.toInt()
|
||||||
|
|
||||||
private val playlistFBOs = Array(10) {
|
private var playlistScroll = 0
|
||||||
|
|
||||||
|
private val playlistFBOs = Array(PLAYLIST_LINES) {
|
||||||
FrameBuffer(Pixmap.Format.RGBA8888, PLAYLIST_NAME_LEN, PLAYLIST_LINE_HEIGHT.toInt(), false)
|
FrameBuffer(Pixmap.Format.RGBA8888, PLAYLIST_NAME_LEN, PLAYLIST_LINE_HEIGHT.toInt(), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -565,7 +569,7 @@ class MusicPlayer(private val ingame: TerrarumIngame) : UICanvas() {
|
|||||||
blendNormalStraightAlpha(batch)
|
blendNormalStraightAlpha(batch)
|
||||||
|
|
||||||
// draw text
|
// draw text
|
||||||
App.fontGameFBO.draw(batch, playlist[i % playlist.size].name, maskOffWidth.toFloat(), (PLAYLIST_LINE_HEIGHT - 24) / 2)
|
App.fontGameFBO.draw(batch, if (i + playlistScroll in playlist.indices) playlist[i].name else "", maskOffWidth.toFloat(), (PLAYLIST_LINE_HEIGHT - 24) / 2)
|
||||||
|
|
||||||
// mask off the area
|
// mask off the area
|
||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
@@ -589,7 +593,7 @@ class MusicPlayer(private val ingame: TerrarumIngame) : UICanvas() {
|
|||||||
// print number
|
// print number
|
||||||
val xoff = maskOffWidth + (if (i < 9) 3 else 0)
|
val xoff = maskOffWidth + (if (i < 9) 3 else 0)
|
||||||
val yoff = 8 + (PLAYLIST_LINE_HEIGHT - 24) / 2
|
val yoff = 8 + (PLAYLIST_LINE_HEIGHT - 24) / 2
|
||||||
App.fontSmallNumbers.draw(batch, "${i + 1}", x + xoff, y + yoff + PLAYLIST_LINE_HEIGHT * i * scale)
|
App.fontSmallNumbers.draw(batch, if (i + playlistScroll in playlist.indices) "${i + playlistScroll + 1}" else "", x + xoff, y + yoff + PLAYLIST_LINE_HEIGHT * i * scale)
|
||||||
// TODO draw playing marker if the song is being played
|
// TODO draw playing marker if the song is being played
|
||||||
|
|
||||||
// print the name
|
// print the name
|
||||||
@@ -599,6 +603,10 @@ class MusicPlayer(private val ingame: TerrarumIngame) : UICanvas() {
|
|||||||
batch.color = Color(1f, 1f, 1f, alpha * 0.25f)
|
batch.color = Color(1f, 1f, 1f, alpha * 0.25f)
|
||||||
Toolkit.drawStraightLine(batch, x, y + PLAYLIST_LINE_HEIGHT * (i + 1) * scale, x + width * scale, 1f, false)
|
Toolkit.drawStraightLine(batch, x, y + PLAYLIST_LINE_HEIGHT * (i + 1) * scale, x + width * scale, 1f, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// print the album name
|
||||||
|
batch.color = Color(1f, 1f, 1f, alpha * 0.75f)
|
||||||
|
Toolkit.drawTextCentered(batch, App.fontGame, playlistName, width, x.roundToInt(), 4 + (y + PLAYLIST_LINE_HEIGHT * PLAYLIST_LINES * scale).roundToInt())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -152,19 +152,21 @@ class TerrarumMusicGovernor : MusicGovernor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var songs: List<MusicContainer> = emptyList()
|
private var songs: List<MusicContainer> = emptyList()
|
||||||
|
var playlistName = ""; private set
|
||||||
private var musicBin: ArrayList<MusicContainer> = ArrayList()
|
private var musicBin: ArrayList<MusicContainer> = ArrayList()
|
||||||
private var shuffled = true
|
private var shuffled = true
|
||||||
private var diskJockeyingMode = "intermittent" // intermittent, continuous
|
private var diskJockeyingMode = "intermittent" // intermittent, continuous
|
||||||
|
|
||||||
private fun registerSongsFromDir(musicDir: String, fileToName: ((String) -> String)?) {
|
private fun registerSongsFromDir(musicDir: String, fileToName: ((String) -> String)?) {
|
||||||
|
val musicDir = musicDir.replace('\\', '/')
|
||||||
printdbg(this, "registerSongsFromDir $musicDir")
|
printdbg(this, "registerSongsFromDir $musicDir")
|
||||||
|
|
||||||
|
|
||||||
val fileToName = if (fileToName == null) {
|
val fileToName = if (fileToName == null) {
|
||||||
{ name: String -> name.substringBeforeLast('.').replace('_', ' ').split(" ").map { it.capitalize() }.joinToString(" ") }
|
{ name: String -> name.substringBeforeLast('.').replace('_', ' ').split(" ").map { it.capitalize() }.joinToString(" ") }
|
||||||
}
|
}
|
||||||
else fileToName
|
else fileToName
|
||||||
|
|
||||||
|
playlistName = musicDir.substringAfterLast('/')
|
||||||
|
|
||||||
songs = File(musicDir).listFiles()?.sortedBy { it.name }?.mapNotNull {
|
songs = File(musicDir).listFiles()?.sortedBy { it.name }?.mapNotNull {
|
||||||
printdbg(this, "Music: ${it.absolutePath}")
|
printdbg(this, "Music: ${it.absolutePath}")
|
||||||
|
|||||||
Reference in New Issue
Block a user