moved white box tex to AppLoader; textButton now has alignment option

This commit is contained in:
minjaesong
2018-12-09 04:36:53 +09:00
parent 59c6876849
commit d0e0f8dd8d
6 changed files with 59 additions and 34 deletions

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.floor
import net.torvald.terrarum.ui.UIItemTextButton.Companion.Alignment
class UIItemTextArea(
parentUI: UICanvas,
@@ -13,16 +14,9 @@ class UIItemTextArea(
override val height: Int,
val lineGap: Int = 0,
val lineCount: Int = ((height + lineGap) / Terrarum.fontGame.lineHeight).toInt(),
val align: UIItemTextArea.Align = Align.LEFT
val align: Alignment = Alignment.LEFT
) : UIItem(parentUI) {
enum class Align {
LEFT, CENTRE, RIGHT
}
private var entireText: List<String> = listOf("") // placeholder
var scrollPos = 0
@@ -45,9 +39,9 @@ class UIItemTextArea(
val textWidth = Terrarum.fontGame.getWidth(entireText[i])
when (align) {
Align.LEFT -> Terrarum.fontGame.draw(batch, entireText[i], posX.toFloat(), posY + yPtr * (Terrarum.fontGame.lineHeight + lineGap))
Align.CENTRE -> Terrarum.fontGame.draw(batch, entireText[i], posX + ((width - textWidth) / 2f).floor(), posY + yPtr * (Terrarum.fontGame.lineHeight + lineGap))
Align.RIGHT -> Terrarum.fontGame.draw(batch, entireText[i], posX + width - textWidth.toFloat(), posY + yPtr * (Terrarum.fontGame.lineHeight + lineGap))
Alignment.LEFT -> Terrarum.fontGame.draw(batch, entireText[i], posX.toFloat(), posY + yPtr * (Terrarum.fontGame.lineHeight + lineGap))
Alignment.CENTRE -> Terrarum.fontGame.draw(batch, entireText[i], posX + ((width - textWidth) / 2f).floor(), posY + yPtr * (Terrarum.fontGame.lineHeight + lineGap))
Alignment.RIGHT -> Terrarum.fontGame.draw(batch, entireText[i], posX + width - textWidth.toFloat(), posY + yPtr * (Terrarum.fontGame.lineHeight + lineGap))
}
}
}