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
@@ -0,0 +1,38 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
|
||||
"github.com/egoist/mygo/ui"
|
||||
|
||||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
||||
)
|
||||
|
||||
type PressStartOptions struct {
|
||||
Disabled bool
|
||||
}
|
||||
|
||||
type PressStartResult struct {
|
||||
Element *ui.Element
|
||||
Pressed bool
|
||||
}
|
||||
|
||||
// PressStart blinks PRESS START until pressed.
|
||||
func PressStart(c *ui.Context, o PressStartOptions) PressStartResult {
|
||||
k := pixel.K(c)
|
||||
s := k.Msg("press_start")
|
||||
shell, base, st := pixel.Shell(c, func() *ui.Element { return ui.ButtonBase(c).Label(s).Disabled(o.Disabled) })
|
||||
res := PressStartResult{Element: shell, Pressed: base.Clicked()}
|
||||
if res.Pressed {
|
||||
slog.Debug("8bit: press start")
|
||||
}
|
||||
shell.Size(k.D(pixel.Measure(s)+8), k.D(pixel.LineHeight+4)).Draw(func(p *ui.Painter, r ui.Rect) {
|
||||
g := k.Canvas(p, r)
|
||||
// It blinks at 1 Hz; reduced, it holds still.
|
||||
if g.Step(2)%2 == 0 {
|
||||
g.Text(4, 2, s, pixel.Ink, 1)
|
||||
}
|
||||
g.Finish(st)
|
||||
})
|
||||
return res
|
||||
}
|
||||
Reference in new issue
Block a user