aboutsummaryrefslogtreecommitdiff
path: root/go/ui
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-08-19 15:32:17 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:57:40 +0200
commitedf89db6fc28931ca59f6c9acfd0a561d68145c7 (patch)
treefe2961223279d16f5d9952f2e9d4aa6d1a5fcf66 /go/ui
parent97a80cc2cf2a5b5a8334fc42f65863651516d4cf (diff)
downloadmuhqs-game-edf89db6fc28931ca59f6c9acfd0a561d68145c7.tar.gz
muhqs-game-edf89db6fc28931ca59f6c9acfd0a561d68145c7.zip
add discard2 icon and button to trigger the free action
Diffstat (limited to 'go/ui')
-rw-r--r--go/ui/button.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/go/ui/button.go b/go/ui/button.go
index 9afa8c05..6e8fd8b7 100644
--- a/go/ui/button.go
+++ b/go/ui/button.go
@@ -83,3 +83,18 @@ func (b *SimpleButton) UpdateLabel(label string) {
b.ForceRedraw()
}
}
+
+type ImageButton struct {
+ WidgetBase
+ img *ebiten.Image
+}
+
+func NewImageButton(x, y int, img *ebiten.Image, onClick func(b *ImageButton)) *ImageButton {
+ bounds := img.Bounds()
+ sb := &ImageButton{NewWidgetBase(x, y, bounds.Dx(), bounds.Dy()), img}
+ sb.EventHandlersMap["click"] = func(int, int) { onClick(sb) }
+ sb.renderImpl = func() *ebiten.Image {
+ return sb.img
+ }
+ return sb
+}