summaryrefslogtreecommitdiff
path: root/src/main/kotlin/de/romjaki/pluggabledino/api/Button.kt
diff options
context:
space:
mode:
authorTyrannova <daniel.sluga@grb-online.net>2019-01-15 16:40:18 +0100
committerTyrannova <daniel.sluga@grb-online.net>2019-01-15 16:40:18 +0100
commite5f3c9ea1a2d79308643d5c2cd70f8ea7bcad394 (patch)
tree8a2dbe562ef35a8aa46b42863fb2c67db2aa73cf /src/main/kotlin/de/romjaki/pluggabledino/api/Button.kt
parent79f63500e90199c44c4f0bc635b4476ccf069b41 (diff)
downloadpluggabledino-e5f3c9ea1a2d79308643d5c2cd70f8ea7bcad394.tar.gz
pluggabledino-e5f3c9ea1a2d79308643d5c2cd70f8ea7bcad394.tar.bz2
pluggabledino-e5f3c9ea1a2d79308643d5c2cd70f8ea7bcad394.zip
Settings
Diffstat (limited to 'src/main/kotlin/de/romjaki/pluggabledino/api/Button.kt')
-rw-r--r--src/main/kotlin/de/romjaki/pluggabledino/api/Button.kt9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main/kotlin/de/romjaki/pluggabledino/api/Button.kt b/src/main/kotlin/de/romjaki/pluggabledino/api/Button.kt
index edced5a..439acb8 100644
--- a/src/main/kotlin/de/romjaki/pluggabledino/api/Button.kt
+++ b/src/main/kotlin/de/romjaki/pluggabledino/api/Button.kt
@@ -6,7 +6,10 @@ import org.newdawn.slick.Input
import java.awt.Rectangle
import kotlin.math.max
-class Button(private val text: String, val x: Float, val y: Float) {
+class Button(private val text: String, val x: Float, val y: Float) : SettingsElement {
+ override fun render(g: Graphics) {
+ draw(g)
+ }
val width = max(buttonImage.width, font.getWidth(text) + 10)
val image = buttonImage.getScaledCopy(width, buttonImage.height)
@@ -40,14 +43,14 @@ class Button(private val text: String, val x: Float, val y: Float) {
override fun toString(): String =
"X: $leftX - $rightX, $topY - $bottomY, width=$width"
- fun enter() {
+ override fun enter() {
lastClicked = true
}
fun isClicked(input: Input): Boolean =
input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON) && isMouseOver(input)
- fun update(input: Input) {
+ override fun update(input: Input) {
val ret = isClicked(input)
if (!lastClicked && ret) {
clickHandlers.forEach({ it() })