dirs
ci/woodpecker/push/ebitengine Pipeline was successful

This commit is contained in:
2026-08-30 23:21:06 +02:00
parent 28b1662195
commit c5c0c02c03
115 changed files with 1083 additions and 950 deletions
+89
View File
@@ -0,0 +1,89 @@
package world
import (
inkwell "git.teletypegames.org/engines/inkwell"
"git.teletypegames.org/games/realworld/inc"
)
func Do(a inkwell.Action) { game.Do(a) }
type fnAction struct{ fn func(*inkwell.Ctx) }
func (a *fnAction) Start() inkwell.Runner {
return &fnRunner{
spec: a,
}
}
type fnRunner struct{ spec *fnAction }
func (r *fnRunner) Tick(ctx *inkwell.Ctx) inkwell.Status {
r.spec.fn(ctx)
return inkwell.StatusDone
}
func Fn(f func(*inkwell.Ctx)) inkwell.Action {
return &fnAction{
fn: f,
}
}
func UseTheme(name string) inkwell.Action {
return Fn(func(ctx *inkwell.Ctx) { ctx.Game.UseTheme(name) })
}
func SetMode(m Mode) inkwell.Action {
return Fn(func(*inkwell.Ctx) { setMode(m) })
}
func TapeOffer(line inkwell.Action) inkwell.Action {
return Fn(func(*inkwell.Ctx) {
tapeLine = line
tapeWaiting = true
})
}
func TakeTapeOffer() {
if !tapeWaiting {
return
}
tapeWaiting = false
line := tapeLine
tapeLine = nil
Do(line)
}
func Paused(inner inkwell.Action) inkwell.Action {
return &pausedAction{
inner: inner,
}
}
type pausedAction struct {
inner inkwell.Action
}
func (a *pausedAction) Start() inkwell.Runner {
return &pausedRunner{
spec: a,
inner: a.inner.Start(),
}
}
type pausedRunner struct {
spec *pausedAction
inner inkwell.Runner
started bool
}
func (r *pausedRunner) Tick(ctx *inkwell.Ctx) inkwell.Status {
if !r.started {
r.started = true
setNote(inc.NotePaused)
}
s := r.inner.Tick(ctx)
if s != inkwell.StatusRunning {
setNote("")
}
return s
}
+57
View File
@@ -0,0 +1,57 @@
package world
import (
inkwell "git.teletypegames.org/engines/inkwell"
"git.teletypegames.org/games/realworld/inc"
)
type Mode string
const (
ModePlay Mode = "play"
ModeCutscene Mode = "cutscene"
ModeMenu Mode = "menu"
)
var (
game *inkwell.Game
pending string
tapeWaiting bool
tapeLine inkwell.Action
)
func Attach(g *inkwell.Game) {
game = g
pending = ""
tapeWaiting = false
tapeLine = nil
setMode(ModePlay)
setNote("")
}
func Game() *inkwell.Game { return game }
func setMode(m Mode) { game.State.SetVar(inc.VarMode, string(m)) }
func setNote(text string) { game.State.SetVar(inc.VarNote, text) }
func Slot2() string {
if v, ok := game.State.Var(inc.VarSlot2).(string); ok {
return v
}
return ""
}
func SetSlot2(item string) { game.State.SetVar(inc.VarSlot2, item) }
func SetPending(item string) { pending = item }
func TakePending() string {
item := pending
pending = ""
return item
}
func TapeWaiting() bool { return tapeWaiting }