diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-02-15 13:13:06 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-01-27 16:43:49 +0100 |
| commit | f9ab2cfdb25eb3fcd85868a2e375326a9c8b6022 (patch) | |
| tree | b96f16e6cf4a6dcf93b9557a7219179ab2f46c8d /go/ui/textBox.go | |
| parent | 805cbf397589e5cb861f866713c2eb4bec9ce40b (diff) | |
| download | muhqs-game-f9ab2cfdb25eb3fcd85868a2e375326a9c8b6022.tar.gz muhqs-game-f9ab2cfdb25eb3fcd85868a2e375326a9c8b6022.zip | |
intermediate commit
* fix a lot of target and action bugs
* check target selection before adding it to the prompt
* use the store view for stores on the map
* fix card highlighting in CardGrid
* Only prompt for Upkeep-/DiscardActions if appropriate
* Add helper for areaEffects granting new FullActions
* Add Target() helper selecting the first target to the Action interface
* Fix BuyAction and DiscardAction targets
* Remember the stores a player has seen
Diffstat (limited to 'go/ui/textBox.go')
| -rw-r--r-- | go/ui/textBox.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/go/ui/textBox.go b/go/ui/textBox.go index 7f1ab98c..2635535c 100644 --- a/go/ui/textBox.go +++ b/go/ui/textBox.go @@ -153,15 +153,26 @@ func (w *PocList) setText() { w.Y = w.bottomY - b.Dy() - w.YMargin } -func (w *PocList) FindObjectAt(x, y int) interface{} { +func (w *PocList) FindObjectAt(_x, _y int) interface{} { + if !w.Contains(_x, _y) { + return nil + } + cards := w.poc.Cards() if len(cards) == 0 { return nil } - // b := text.BoundString(font.Font, w.Text) - // i := b.Dy() / w.poc.Size() - return cards[0] + y := _y - w.Y + + b := text.BoundString(font.Font24, w.text) + i := y / (b.Dy() / w.poc.Size()) + + if i >= len(cards) { + return nil + } + + return cards[i] } type TextInput struct { |
