From 63ad22242562b1e66353694f2a17df6d1c64a8fd Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Thu, 16 Feb 2023 18:57:15 +0100 Subject: move more ui logic into Collection * Generalize hover detection and move it into ui.Collection * Implement transparencu for the prompt banner --- go/ui/textBox.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'go/ui/textBox.go') diff --git a/go/ui/textBox.go b/go/ui/textBox.go index 2635535c..66b90698 100644 --- a/go/ui/textBox.go +++ b/go/ui/textBox.go @@ -84,11 +84,20 @@ func NewUnitInfo(x, y int, u *game.Unit) *TextBox { return NewAutoTextBox(x, y, info) } -func NewPermInfo(x, y int, p game.Permanent) *TextBox { +func NewGenericPermInfo(x, y int, p game.Permanent) *TextBox { info := fmt.Sprintf("%s\nDamage: %d", p.String(), p.Damage()) return NewAutoTextBox(x, y, info) } +func NewPermInfo(x, y int, p game.Permanent) *TextBox { + switch p := p.(type) { + case *game.Unit: + return NewUnitInfo(x, y, p) + default: + return NewGenericPermInfo(x, y, p) + } +} + func (tb *TextBox) render() *ebiten.Image { var x, y int b := text.BoundString(font.Font24, tb.text) @@ -115,6 +124,7 @@ func (tb *TextBox) render() *ebiten.Image { type PocList struct { TextBox + hoverCardView centerX int bottomY int poc game.PileOfCards @@ -128,6 +138,8 @@ func NewPocList(centerX, bottomY int, poc game.PileOfCards) *PocList { poc: poc, } + w.hoverCardView.init(w) + w.renderImpl = func() *ebiten.Image { w.setText() return w.render() -- cgit v1.2.3