mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 03:24:06 +09:00
moved white box tex to AppLoader; textButton now has alignment option
This commit is contained in:
@@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user