replacing min/max usage with kotlin's

This commit is contained in:
minjaesong
2023-07-11 01:54:46 +09:00
parent d96b7d1b84
commit 79f19120f2
66 changed files with 308 additions and 345 deletions

View File

@@ -3,8 +3,9 @@ package net.torvald.terrarum.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.App
import net.torvald.terrarum.floor
import net.torvald.terrarum.roundToFloat
import net.torvald.terrarum.ui.UIItemTextButton.Companion.Alignment
import kotlin.math.min
class UIItemTextArea(
parentUI: UICanvas,
@@ -33,14 +34,14 @@ class UIItemTextArea(
}
override fun render(batch: SpriteBatch, camera: Camera) {
for (i in scrollPos until minOf(lineCount + scrollPos, entireText.size)) {
for (i in scrollPos until min(lineCount + scrollPos, entireText.size)) {
val yPtr = i - scrollPos
val textWidth = App.fontGame.getWidth(entireText[i])
when (align) {
Alignment.LEFT -> App.fontGame.draw(batch, entireText[i], posX.toFloat(), posY + yPtr * (App.fontGame.lineHeight + lineGap))
Alignment.CENTRE -> App.fontGame.draw(batch, entireText[i], posX + ((width - textWidth) / 2f).floor(), posY + yPtr * (App.fontGame.lineHeight + lineGap))
Alignment.CENTRE -> App.fontGame.draw(batch, entireText[i], posX + ((width - textWidth) / 2f).roundToFloat(), posY + yPtr * (App.fontGame.lineHeight + lineGap))
Alignment.RIGHT -> App.fontGame.draw(batch, entireText[i], posX + width - textWidth.toFloat(), posY + yPtr * (App.fontGame.lineHeight + lineGap))
}
}