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:
38 files changed
+2663
-8
No files matched your search
+11
-1
@@ -34,7 +34,7 @@ func CountUp(c *ui.Context, value int, o CountUpOptions) *ui.Element {
|
||||
if !k.Reduce() {
|
||||
step = k.Since(c, s.at, 15, 8)
|
||||
}
|
||||
return s.from + (s.to-s.from)*step/8
|
||||
return lerp(s.from, s.to, step)
|
||||
}
|
||||
if value != s.to {
|
||||
s.from, s.to, s.at = shown(), value, k.Now()
|
||||
@@ -45,3 +45,13 @@ func CountUp(c *ui.Context, value int, o CountUpOptions) *ui.Element {
|
||||
k.Canvas(p, r).Text(0, 0, n, o.Slot, sc)
|
||||
})
|
||||
}
|
||||
|
||||
// lerp moves step eighths from a toward b, overflow-free.
|
||||
func lerp(a, b, step int) int {
|
||||
if b >= a {
|
||||
d := uint64(b) - uint64(a)
|
||||
return int(uint64(a) + d/8*uint64(step) + d%8*uint64(step)/8)
|
||||
}
|
||||
d := uint64(a) - uint64(b)
|
||||
return int(uint64(a) - (d/8*uint64(step) + d%8*uint64(step)/8))
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package feedback_test
|
||||
|
||||
import (
|
||||
"math"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -30,6 +32,36 @@ func TestCountUpStepsOrJumps(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCountUpReachesAHugeValue(t *testing.T) {
|
||||
clk := newClock()
|
||||
v := 0
|
||||
tt := view(600, 100, clk, false, func(c *ui.Context) {
|
||||
feedback.CountUp(c, v, feedback.CountUpOptions{Slot: pixel.Ink})
|
||||
pixel.Text(c, strconv.Itoa(math.MaxInt64), pixel.TextOptions{})
|
||||
})
|
||||
v = math.MaxInt64
|
||||
wait(tt, clk, 0)
|
||||
wait(tt, clk, time.Second)
|
||||
// The count ends on the same digits as plain text.
|
||||
img := tt.Image()
|
||||
if !equal(slots(t, img, ui.Rect{W: 600, H: 32}), slots(t, img, ui.Rect{Y: 32, W: 600, H: 32})) {
|
||||
t.Fatal("the count ended on other digits")
|
||||
}
|
||||
// From -1, halfway is 4611686018427387903, across the sign.
|
||||
half := -1
|
||||
tt = view(600, 100, clk, false, func(c *ui.Context) {
|
||||
feedback.CountUp(c, half, feedback.CountUpOptions{Slot: pixel.Ink})
|
||||
pixel.Text(c, "4611686018427387903", pixel.TextOptions{})
|
||||
})
|
||||
half = math.MaxInt64
|
||||
wait(tt, clk, 0)
|
||||
wait(tt, clk, 4*time.Second/15+time.Millisecond)
|
||||
img = tt.Image()
|
||||
if !equal(slots(t, img, ui.Rect{W: 600, H: 32}), slots(t, img, ui.Rect{Y: 32, W: 600, H: 32})) {
|
||||
t.Fatal("halfway the count drew other digits")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPulseStopsUnderReduceMotion(t *testing.T) {
|
||||
for _, reduce := range []bool{false, true} {
|
||||
clk := newClock()
|
||||
|
||||
Reference in new issue
Block a user