Files
inkwell/ui.hotspot_debug.go
T
mr.zeroandClaude Opus 5 f9745e4266
ci/woodpecker/push/woodpecker Pipeline was successful
Scene exits, Back(), and the current/previous scene accessors
A connection between two scenes had to be hand-built as a hotspot: an area,
a cursor, a GoTo, and a flag check written out again for every door. Scene
now carries Exits, and the engine expands each one into a hotspot.

- Exit{To, Label, Side, Area, Needs, Blocked, OnLook, OnTake} in scene.exit.go.
  With no Area an exit is an edge strip, sized as a fraction of Game.SceneArea()
  so a game whose HUD covers the foot of the window gets strips inside the
  painting. Game.ExitLook / Game.ExitTake supply the look and take responses
  once for the whole game, so the phrasing is not repeated per exit.
- Game.SceneHotspots(name) is the scene's own hotspots followed by its exits,
  cached per scene. Authored hotspots come first, so a painted thing beats the
  edge strip wherever the two overlap. HotspotAt and HotspotDebug read it.
- Game.CurrentScene() / PreviousScene(), both persisted in the save file. The
  engine tracked the current scene but exposed no accessor, so every game had
  to shadow it to know where it was.
- Back() returns to the previous scene — what an exit with an empty To binds
  to, for a scene reachable from several rooms whose way out is a direction
  rather than a place.
- Validate rejects an exit naming a scene nobody registered.

Generated hotspots are named ExitName(To) ("exit:street", "exit:back"), so the
location graph can be read straight back out of the registered scenes.

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

47 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) 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)
}
}
}