fix: ui width will not take the length truncation

This commit is contained in:
minjaesong
2023-12-25 00:07:59 +09:00
parent 74e7e980b7
commit 8d1d2a1e10

View File

@@ -71,7 +71,7 @@ class MusicPlayer(private val ingame: TerrarumIngame) : UICanvas() {
// test code
val diskJockeyingMode = "continuous" // must be read from the playlist.json
registerPlaylist(App.customDir + "/MusicShort", false, diskJockeyingMode)
registerPlaylist(App.customDir + "/MusicFJ", false, diskJockeyingMode)
}
fun registerPlaylist(path: String, shuffled: Boolean, diskJockeyingMode: String) {
@@ -102,11 +102,12 @@ class MusicPlayer(private val ingame: TerrarumIngame) : UICanvas() {
private fun setMusicName(str: String) {
currentMusicName = str
nameLength = App.fontGameFBO.getWidth(str)
TRANSITION_LENGTH = 0.8f * ((nameLength.coerceAtMost(nameStrMaxLen).toFloat() - nameLengthOld).absoluteValue / nameStrMaxLen)
val realNameLength = App.fontGameFBO.getWidth(str)
nameLength = realNameLength.coerceAtMost(nameStrMaxLen)
TRANSITION_LENGTH = 0.8f * ((nameLength - nameLengthOld).absoluteValue / nameStrMaxLen)
nameOverflown = (nameLength > nameStrMaxLen)
// printdbg(this, "setMusicName $str; strLen = $nameLengthOld -> $nameLength; overflown=$nameOverflown; transitionTime=$TRANSITION_LENGTH")
printdbg(this, "setMusicName $str; strLen = $nameLengthOld -> $nameLength; overflown=$nameOverflown; transitionTime=$TRANSITION_LENGTH")
}
override fun updateUI(delta: Float) {