ci/woodpecker/push/woodpecker Pipeline was successful
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>
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package inkwell
|
|
|
|
import (
|
|
"github.com/hajimehoshi/ebiten/v2"
|
|
"github.com/hajimehoshi/ebiten/v2/inpututil"
|
|
"github.com/hajimehoshi/ebiten/v2/vector"
|
|
)
|
|
|
|
// HotspotDebug overlays a colored outline on every hotspot of the current
|
|
// scene. F1 toggles it at runtime; the default is off.
|
|
type HotspotDebug struct {
|
|
Name string
|
|
Enabled bool
|
|
// ToggleKey, if non-zero, overrides the default F1 toggle.
|
|
ToggleKey ebiten.Key
|
|
}
|
|
|
|
func (h *HotspotDebug) GetName() string { return h.Name }
|
|
func (h *HotspotDebug) Layer() Layer { return LayerScene }
|
|
|
|
func (h *HotspotDebug) Tick(ctx *UICtx) {
|
|
key := h.ToggleKey
|
|
if key == 0 {
|
|
key = ebiten.KeyF1
|
|
}
|
|
if inpututil.IsKeyJustPressed(key) {
|
|
h.Enabled = !h.Enabled
|
|
}
|
|
}
|
|
|
|
func (h *HotspotDebug) Draw(dst *ebiten.Image, ctx *UICtx) {
|
|
if !h.Enabled {
|
|
return
|
|
}
|
|
g := ctx.Game
|
|
if g.currentScene == "" {
|
|
return
|
|
}
|
|
col := g.Theme().HotspotOutline
|
|
for _, hs := range g.SceneHotspots(g.currentScene) {
|
|
b := hs.Area.Bounds()
|
|
vector.StrokeRect(dst, float32(b.X), float32(b.Y), float32(b.W), float32(b.H), 1, col, false)
|
|
if hs.Label != "" {
|
|
g.DrawText(dst, hs.Label, int(b.X)+1, int(b.Y)+1, col)
|
|
}
|
|
}
|
|
}
|