Add game components 269-290; CommandMenu AutoFocus

Press start, title screen, save slots, options menu, game over with
CONTINUE, credits roll, ending card, loading tips, letterbox, mission
brief, achievements, result screen, crafting grid, loot popup,
treasure chest, gacha reel, interact prompt, turn order, battle log,
target selector, ATB gauge and stamina bar. Cued effects count runs,
so each cue change plays once and reports once. CommandMenu takes
AutoFocus when enabled. HealthBar, ManaBar and CountUp keep exact
colors, ticks and counts for the largest ints.
This commit is contained in:
ZacharyZhang-NY committed 2026-10-12 02:48:20 -04:00
1 parent f48075230f
commit 86a6901333
38 files changed
+2663 -8

No files matched your search

+19 -1
View File
@@ -4,6 +4,7 @@ package game
import (
"fmt"
"strconv"
"time"
"github.com/egoist/mygo/ui"
@@ -55,7 +56,7 @@ func ratio(v, most int) string { return strconv.Itoa(v) + "/" + strconv.Itoa(mos
// fits fails when a bar is narrower than its labels.
func fits(name string, w int, text, value string) {
if need := tagW(text) + 4 + pixel.MicroWidth(value); w < need {
if need := tagW(text) + 4 + tagW(value); w < need {
panic(fmt.Sprintf("game: %s Width %d is under the %d its labels need", name, w, need))
}
}
@@ -104,3 +105,20 @@ func abs(n int) int {
}
return n
}
type startKey struct{}
// begun is a cue, its start and its run count.
type begun struct {
cue, run int
at time.Time
}
// start is e's first showing, or its last cue change.
func start(k pixel.Kit, e *ui.Element, cue int) begun {
s := ui.Local(e, startKey{}, func() begun { return begun{cue: cue, at: k.Now()} })
if s.cue != cue {
s.cue, s.at, s.run = cue, k.Now(), s.run+1
}
return *s
}