Files
Terrarum/src/net/torvald/terrarum/ui/UIItemImageGallery.kt
Song Minjae 03bf6e95e4 TextButtonList working kinematic background
Former-commit-id: 8976d3b3d1e40731adf13430ad747351a6401b24
2017-03-15 01:06:13 +09:00

81 lines
3.2 KiB
Kotlin

package net.torvald.terrarum.ui
import net.torvald.terrarum.gameactors.roundInt
import org.newdawn.slick.GameContainer
import org.newdawn.slick.Graphics
import org.newdawn.slick.Image
import java.util.*
/**
* Image gallery. Images will be equally spaced, counted from top-left to bottom-right.
* Created by minjaesong on 16-08-08.
*/
class UIItemImageGallery(
parentUI: UICanvas,
override var posX: Int,
override var posY: Int,
override val width: Int,
override val height: Int,
val imageList: ArrayList<Image>,
val column: Int = 1
) : UIItem(parentUI) {
override fun update(gc: GameContainer, delta: Int) {
}
override fun render(gc: GameContainer, g: Graphics) {
fun column(i: Int) = i % column
fun row(i: Int) = i / column
fun imagePosY(i: Int): Int {
val gutter = (height - imageList[i].height.times(imageList.size)).toFloat().div(
imageList.size + 1f
)
return row((gutter * i.plus(1) + imageList[i].height * i).roundInt())
}
imageList.forEachIndexed { i, image ->
DrawUtil.drawCentered(g, image,
imagePosY(i),
width.toFloat().div(column).times(column(i).plus(1)).roundInt(),
posX, posY
)
}
}
override fun keyPressed(key: Int, c: Char) {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun keyReleased(key: Int, c: Char) {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun mouseMoved(oldx: Int, oldy: Int, newx: Int, newy: Int) {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun mouseDragged(oldx: Int, oldy: Int, newx: Int, newy: Int) {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun mousePressed(button: Int, x: Int, y: Int) {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun mouseReleased(button: Int, x: Int, y: Int) {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun mouseWheelMoved(change: Int) {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun controllerButtonPressed(controller: Int, button: Int) {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun controllerButtonReleased(controller: Int, button: Int) {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}