From 3d36d1d0254b8aeecc889a2a49cbcced458cbe9c Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sat, 25 Feb 2023 23:08:47 +0100 Subject: intermediate commit * Implement move artifact action * Fix widget update memory leak * update the highlights not during on each frame * do not update the unchanged label of a button * Allow to exit the game by pressing 'q' * Implement some cards from the magic set * Improve permanent formatting * Some tweaks to UnitAI code --- go/ui/button.go | 6 ++++-- go/ui/hoverable.go | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'go/ui') diff --git a/go/ui/button.go b/go/ui/button.go index 50f78a3d..e882d39c 100644 --- a/go/ui/button.go +++ b/go/ui/button.go @@ -46,6 +46,8 @@ func (b *SimpleButton) Click(x, y int) { } func (b *SimpleButton) UpdateLabel(label string) { - b.label = label - b.ForceRedraw() + if b.label != label { + b.label = label + b.ForceRedraw() + } } diff --git a/go/ui/hoverable.go b/go/ui/hoverable.go index 54d4ec15..30415c8d 100644 --- a/go/ui/hoverable.go +++ b/go/ui/hoverable.go @@ -62,11 +62,13 @@ type hoverCardView struct { func (h *hoverCardView) init(w Widget) { h.createHint = func(x, y int) Widget { - card := w.FindObjectAt(x, y).(*game.Card) - if card == nil { + obj := w.FindObjectAt(x, y) + if obj == nil { return nil } + card := obj.(*game.Card) + wx, wy := x, y if x+HOVER_CARD_WIDTH > h.xMax || y+HOVER_CARD_HEIGHT > h.yMax { wx = x - HOVER_CARD_WIDTH -- cgit v1.2.3