diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-02-17 14:36:06 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:50:11 +0200 |
| commit | 50b9a042435b324be281b78ceb87dd63fd24acba (patch) | |
| tree | 06d7436f7cb6963894ddcb767658e472474c9d67 /go/ui | |
| parent | d52a41bdcb587abe57f7d581d260b4be948dcc2a (diff) | |
| download | muhqs-game-50b9a042435b324be281b78ceb87dd63fd24acba.tar.gz muhqs-game-50b9a042435b324be281b78ceb87dd63fd24acba.zip | |
use prompt for target selection of all actions
Diffstat (limited to 'go/ui')
| -rw-r--r-- | go/ui/button.go | 13 | ||||
| -rw-r--r-- | go/ui/cardGrid.go | 1 | ||||
| -rw-r--r-- | go/ui/prompt.go | 8 |
3 files changed, 13 insertions, 9 deletions
diff --git a/go/ui/button.go b/go/ui/button.go index eac3c2e4..50f78a3d 100644 --- a/go/ui/button.go +++ b/go/ui/button.go @@ -19,8 +19,8 @@ type SimpleButton struct { WidgetBase label string OnClick func(b *SimpleButton) - BG color.Color - FG color.Color + Bg color.Color + Fg color.Color } func NewSimpleButton(x, y, w, h int, label string, onClick func(b *SimpleButton)) *SimpleButton { @@ -32,15 +32,20 @@ func NewSimpleButton(x, y, w, h int, label string, onClick func(b *SimpleButton) func (b *SimpleButton) render() *ebiten.Image { img := ebiten.NewImage(b.Width, b.Height) - ebitenutil.DrawRect(img, float64(0), float64(0), float64(b.Width), float64(b.Height), b.BG) + ebitenutil.DrawRect(img, float64(0), float64(0), float64(b.Width), float64(b.Height), b.Bg) bounds := text.BoundString(font.Font24, b.label) x := b.Width/2 - centerTextXOffset(bounds) y := b.Height/2 - centerTextYOffset(bounds) - text.Draw(img, b.label, font.Font24, x, y, b.FG) + text.Draw(img, b.label, font.Font24, x, y, b.Fg) return img } func (b *SimpleButton) Click(x, y int) { b.OnClick(b) } + +func (b *SimpleButton) UpdateLabel(label string) { + b.label = label + b.ForceRedraw() +} diff --git a/go/ui/cardGrid.go b/go/ui/cardGrid.go index f6720ca1..1b86fe35 100644 --- a/go/ui/cardGrid.go +++ b/go/ui/cardGrid.go @@ -98,7 +98,6 @@ func (w *CardGrid) render() *ebiten.Image { op.GeoM.Translate(xOffset, yOffset) if slices.Contains(w.highlights, card) { - log.Println("Highlighting card", card.Name) op.ColorM.Scale(1, 0, 0, 0.5) } diff --git a/go/ui/prompt.go b/go/ui/prompt.go index 93c4b4cd..c0b11d94 100644 --- a/go/ui/prompt.go +++ b/go/ui/prompt.go @@ -28,6 +28,10 @@ func NewPrompt(y, width int, action game.Action, promptText string) *Prompt { return p } +func (p *Prompt) Action() game.Action { + return p.action +} + func (p *Prompt) Add(obj interface{}) error { if handCard, ok := obj.(HandCard); ok { obj = handCard.C @@ -36,10 +40,6 @@ func (p *Prompt) Add(obj interface{}) error { return p.action.Targets().AddSelection(obj) } -func (p *Prompt) Confirm() game.Action { - return p.action -} - func (p *Prompt) Height() int { return PROMPT_HEIGHT } |
