diff options
Diffstat (limited to 'go/ui')
| -rw-r--r-- | go/ui/mapView.go | 8 | ||||
| -rw-r--r-- | go/ui/textBox.go | 10 |
2 files changed, 13 insertions, 5 deletions
diff --git a/go/ui/mapView.go b/go/ui/mapView.go index 83404241..528ce6db 100644 --- a/go/ui/mapView.go +++ b/go/ui/mapView.go @@ -428,6 +428,14 @@ func (vw *MapView) FindObjectAt(screenX, screenY int) any { return nil } +func (vw *MapView) GetScreenPosition(t *game.Tile) (int, int) { + scaled_tile_wdth := int(float64(TILE_WIDTH) * vw.scale) + scaled_tile_hght := int(float64(TILE_HEIGHT) * vw.scale) + x := scaled_tile_wdth * t.Position.X + y := scaled_tile_hght * t.Position.Y + return x, y +} + func (vw *MapView) HighlightPositions(pos []game.Position, col color.Color) { highlights := make(map[game.Position][]color.Color) for _, p := range pos { diff --git a/go/ui/textBox.go b/go/ui/textBox.go index e2238078..1b0cae5e 100644 --- a/go/ui/textBox.go +++ b/go/ui/textBox.go @@ -141,7 +141,7 @@ type PocList struct { hoverCardView centerX int bottomY int - poc game.PileOfCards + Poc game.PileOfCards } func NewPocList(centerX, bottomY int, poc game.PileOfCards, c *Collection) *PocList { @@ -149,7 +149,7 @@ func NewPocList(centerX, bottomY int, poc game.PileOfCards, c *Collection) *PocL TextBox: *(NewAutoTextBox(-1, -1, "").Centering(true)), centerX: centerX, bottomY: bottomY, - poc: poc, + Poc: poc, } w.hoverCardView.init(w, c) @@ -165,7 +165,7 @@ func NewPocList(centerX, bottomY int, poc game.PileOfCards, c *Collection) *PocL func (w *PocList) setText() { w.Width, w.Height = -1, -1 t := "" - for _, c := range w.poc.Cards() { + for _, c := range w.Poc.Cards() { t = fmt.Sprintf("%s%s\n", t, c.Name) } @@ -185,7 +185,7 @@ func (w *PocList) FindObjectAt(_x, _y int) any { return nil } - cards := w.poc.Cards() + cards := w.Poc.Cards() if len(cards) == 0 { return nil } @@ -193,7 +193,7 @@ func (w *PocList) FindObjectAt(_x, _y int) any { y := _y - w.Y _, height := text.Measure(w.text, w.font, w.font.Size*w.lineSpacing) - i := y / (int(height) / w.poc.Size()) + i := y / (int(height) / w.Poc.Size()) if i >= len(cards) { return nil |
