Files
inkwell/ui.status.go
T
mr.zeroandClaude Opus 5 2429ada090
ci/woodpecker/push/woodpecker Pipeline was successful
A widget declares its layer
Registration order was the only thing deciding what a widget was drawn
over, which forced a domain to keep one ordered list of every widget it
owns — the one shape that cannot be split into a file per widget.

A widget now says where it belongs: Layer, the eight LayerScene..LayerCursor
constants, the optional Layered interface and LayerOf for wrappers. Draw
runs from the bottom layer up, Tick from the top down, and registration
order only breaks ties inside a layer. Every built-in declares its own;
anything that stays quiet sits on LayerHUD, so existing HUDs come out where
they were.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-30 22:19:17 +02:00

56 lines
1.0 KiB
Go

package inkwell
import "github.com/hajimehoshi/ebiten/v2"
// StatusLine renders a single line: either the active flash message (set
// by FlashLine) or the hover-hint (verb + target under the cursor).
type StatusLine struct {
Name string
Y int
Align Align
// ScreenWidth, if 0, uses Game.Width.
ScreenWidth int
}
func (s *StatusLine) GetName() string { return s.Name }
func (s *StatusLine) Layer() Layer { return LayerHUD }
func (s *StatusLine) Tick(ctx *UICtx) {
g := ctx.Game
if g.flashTimer > 0 {
g.flashTimer -= ctx.DT
if g.flashTimer <= 0 {
g.flash = ""
}
}
}
func (s *StatusLine) Draw(dst *ebiten.Image, ctx *UICtx) {
g := ctx.Game
th := g.Theme()
w := s.ScreenWidth
if w == 0 {
w = g.Width
}
text := g.flash
col := th.FlashText
if text == "" {
text = g.HoverHint()
col = th.StatusText
}
if text == "" {
return
}
tw := textWidth(text)
var x int
switch s.Align {
case AlignLeft:
x = 2
case AlignRight:
x = w - tw - 2
default:
x = (w - tw) / 2
}
g.DrawText(dst, text, x, s.Y, col)
}