simplified a structure of UIs a bit

This commit is contained in:
minjaesong
2017-07-16 23:15:32 +09:00
parent 942971f456
commit 485cbe1206
29 changed files with 321 additions and 371 deletions

View File

@@ -10,7 +10,7 @@ import net.torvald.terrarum.fillRect
/**
* Created by minjaesong on 2017-07-16.
*/
class UIItemImageButton(
open class UIItemImageButton(
parent: UICanvas,
val image: TextureRegion,
@@ -18,20 +18,19 @@ class UIItemImageButton(
val buttonBackCol: Color = Color(0),
val buttonBackBlendMode: String = BlendMode.NORMAL,
val activeCol: Color = Color(0x00f8ff_ff),
val activeCol: Color = Color(0xfff066_ff.toInt()),
val activeBackCol: Color = Color(0xb0b0b0_ff.toInt()),
val activeBackBlendMode: String = BlendMode.MULTIPLY,
override var posX: Int,
override var posY: Int,
override val width: Int,
override val height: Int
override val width: Int = image.regionWidth,
override val height: Int = image.regionHeight
) : UIItem(parent) {
override fun update(delta: Float) {
}
override fun render(batch: SpriteBatch) {
// draw background
if (mouseUp) {
BlendMode.resolve(activeBackBlendMode)
batch.color = activeBackCol
@@ -43,41 +42,15 @@ class UIItemImageButton(
batch.fillRect(posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat())
// draw image
blendNormal()
batch.color = if (mouseUp) activeCol else buttonCol
batch.draw(image, (posX - (image.regionWidth / 2)).toFloat(), (posY - (image.regionHeight / 2)).toFloat())
batch.draw(image, (posX + (width - image.regionWidth) / 2).toFloat(), (posY + (height - image.regionHeight) / 2).toFloat())
}
override fun dispose() {
image.texture.dispose()
}
override fun keyDown(keycode: Int): Boolean {
return false
}
override fun keyUp(keycode: Int): Boolean {
return false
}
override fun mouseMoved(screenX: Int, screenY: Int): Boolean {
return false
}
override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean {
return false
}
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
return false
}
override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
return false
}
override fun scrolled(amount: Int): Boolean {
return false
}
}