From 50b9a042435b324be281b78ceb87dd63fd24acba Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 17 Feb 2023 14:36:06 +0100 Subject: use prompt for target selection of all actions --- go/ui/button.go | 13 +++++++++---- go/ui/cardGrid.go | 1 - go/ui/prompt.go | 8 ++++---- 3 files changed, 13 insertions(+), 9 deletions(-) (limited to 'go/ui') 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 } -- cgit v1.2.3