Every change here started life as a workaround in a game and is really the same finding: a fact about an entity had nowhere to live, so the domain built machinery around the gap. Character.Label / Character.Voice — a tape is a character that speaks into the log, not a second spelling of Say. VoiceOf and CharacterLabel read them; Say obeys them. Game.Do — a real action queue, in order, so a widget can start an action. queueAction no longer drops what arrives while the runner is busy; it queues it. Widget.When + Gated + WidgetVisible — a widget declares when it is on screen. Nothing ticks, draws or blocks a click while its condition is false, so a HUD is hidden for a cutscene without a wrapper per widget. TopBar.NoteVar — the title was already discovered; the note beside it no longer needs a domain widget to push it in. Game.UseWithFail — the pair nobody authored is content, and belongs to the domain, exactly like ExitLook and ExitTake. Game.Player / Game.Walkboxes — a scene that names no cast and no floor means "the usual", instead of a defaults pass rewriting every scene. Game.WindowScale — Run's 4× is now a default, not a decision. SceneNav — the dev widget every game was writing. Colour text: DrawText paints in the colour it is handed, and GlyphW/H, TextWidth, WrapText and ClipText are the library's, not each game's. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+17
-5
@@ -12,6 +12,7 @@ import (
|
||||
// string on the right. Empty fields are skipped.
|
||||
type TopBar struct {
|
||||
Name string
|
||||
When Condition
|
||||
Height int
|
||||
|
||||
// LeftText overrides the auto-discovered scene Title/Name.
|
||||
@@ -24,11 +25,17 @@ type TopBar struct {
|
||||
// TimeVar is a State Var key whose value is printed at the right
|
||||
// edge (e.g. "Day 2 - 14:32"); empty = nothing on the right.
|
||||
TimeVar string
|
||||
|
||||
// NoteVar is a State Var key whose value is appended to the left
|
||||
// text after an em dash — "ALLEY — paused". Empty or unset = no
|
||||
// note, and the title stands alone.
|
||||
NoteVar string
|
||||
}
|
||||
|
||||
func (t *TopBar) GetName() string { return t.Name }
|
||||
func (t *TopBar) Layer() Layer { return LayerHUD }
|
||||
func (t *TopBar) Tick(ctx *UICtx) {}
|
||||
func (t *TopBar) GetName() string { return t.Name }
|
||||
func (t *TopBar) VisibleWhen() Condition { return t.When }
|
||||
func (t *TopBar) Layer() Layer { return LayerHUD }
|
||||
func (t *TopBar) Tick(ctx *UICtx) {}
|
||||
|
||||
func (t *TopBar) Draw(dst *ebiten.Image, ctx *UICtx) {
|
||||
g := ctx.Game
|
||||
@@ -48,6 +55,11 @@ func (t *TopBar) Draw(dst *ebiten.Image, ctx *UICtx) {
|
||||
left = s.Name
|
||||
}
|
||||
}
|
||||
if t.NoteVar != "" {
|
||||
if note := fmt.Sprint(g.State.Var(t.NoteVar)); note != "" && note != "<nil>" {
|
||||
left += " — " + note
|
||||
}
|
||||
}
|
||||
if left != "" {
|
||||
g.DrawText(dst, left, 4, -1, th.TopBarText)
|
||||
}
|
||||
@@ -60,13 +72,13 @@ func (t *TopBar) Draw(dst *ebiten.Image, ctx *UICtx) {
|
||||
} else {
|
||||
sc = fmt.Sprintf("Score: %v", v)
|
||||
}
|
||||
x := (g.Width - textWidth(sc)) / 2
|
||||
x := (g.Width - TextWidth(sc)) / 2
|
||||
g.DrawText(dst, sc, x, -1, th.TopBarAccent)
|
||||
}
|
||||
|
||||
if t.TimeVar != "" {
|
||||
tm := fmt.Sprint(g.State.Var(t.TimeVar))
|
||||
x := g.Width - textWidth(tm) - 4
|
||||
x := g.Width - TextWidth(tm) - 4
|
||||
g.DrawText(dst, tm, x, -1, th.TopBarText)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user