remove comments
This commit is contained in:
+2
-52
@@ -1,32 +1,18 @@
|
||||
package inc
|
||||
|
||||
// The game's own actions, and the domain action pump.
|
||||
//
|
||||
// inkwell's queueAction is unexported, so domain widgets (TapeSlots) cannot put
|
||||
// an action on the engine's queue — the built-in widgets only manage it because
|
||||
// they live inside the package. inkwell.Ctx, however, is exported with exported
|
||||
// fields, so the domain can drive a Runner itself. That is what the pump does:
|
||||
// it runs HUD-originated actions (starting a dialogue, a tape line) alongside
|
||||
// the engine's own script runner. See README, "Engine workarounds".
|
||||
|
||||
import (
|
||||
inkwell "git.teletypegames.org/engines/inkwell"
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
)
|
||||
|
||||
// ----- pump -------------------------------------------------------------
|
||||
|
||||
// Do queues a HUD-originated action.
|
||||
func (w *World) Do(a inkwell.Action) {
|
||||
if a != nil {
|
||||
w.queue = append(w.queue, a)
|
||||
}
|
||||
}
|
||||
|
||||
// PumpTick advances the pump. The ActionPump widget calls it every frame.
|
||||
func (w *World) PumpTick(dt float64) {
|
||||
// The TopBar's left section: location plus a single word for a stopped
|
||||
// world. No pause overlay, no blur — one word says time has stopped.
|
||||
|
||||
if w.top != nil {
|
||||
title := w.sceneTitle()
|
||||
if w.paused {
|
||||
@@ -62,8 +48,6 @@ func (w *World) sceneTitle() string {
|
||||
return s.Name
|
||||
}
|
||||
|
||||
// ActionPump is an invisible widget that advances the pump. The HUD registers
|
||||
// it; the world itself knows nothing about the widget tree.
|
||||
type ActionPump struct {
|
||||
Name string
|
||||
W *World
|
||||
@@ -73,8 +57,6 @@ func (p *ActionPump) GetName() string { return p.Name
|
||||
func (p *ActionPump) Tick(ctx *inkwell.UICtx) { p.W.PumpTick(ctx.DT) }
|
||||
func (p *ActionPump) Draw(dst *ebiten.Image, ctx *inkwell.UICtx) {}
|
||||
|
||||
// ----- helpers ----------------------------------------------------------
|
||||
|
||||
type fnAction struct{ fn func(*inkwell.Ctx) }
|
||||
|
||||
func (a *fnAction) Start() inkwell.Runner { return &fnRunner{spec: a} }
|
||||
@@ -86,23 +68,16 @@ func (r *fnRunner) Tick(ctx *inkwell.Ctx) inkwell.Status {
|
||||
return inkwell.StatusDone
|
||||
}
|
||||
|
||||
// Fn turns a function into a one-shot action that completes immediately.
|
||||
func Fn(f func(*inkwell.Ctx)) inkwell.Action { return &fnAction{fn: f} }
|
||||
|
||||
// UseTheme switches the theme at runtime. This is the single line that makes
|
||||
// the Nokia-punk texture break in during the finale. inkwell saves ActiveTheme,
|
||||
// so the switch survives a save without needing a flag of its own.
|
||||
func UseTheme(name string) inkwell.Action {
|
||||
return Fn(func(ctx *inkwell.Ctx) { ctx.Game.UseTheme(name) })
|
||||
}
|
||||
|
||||
// SetMode switches the HUD mode (play / cutscene / menu).
|
||||
func SetMode(w *World, m Mode) inkwell.Action {
|
||||
return Fn(func(*inkwell.Ctx) { w.SetMode(m) })
|
||||
}
|
||||
|
||||
// EnterScene tells the domain which scene we are in. inkwell exposes no
|
||||
// CurrentScene accessor, and the pump needs Ctx.Scene.
|
||||
func EnterScene(w *World, name string) inkwell.Action {
|
||||
return Fn(func(*inkwell.Ctx) {
|
||||
if name != w.scene {
|
||||
@@ -112,12 +87,6 @@ func EnterScene(w *World, name string) inkwell.Action {
|
||||
})
|
||||
}
|
||||
|
||||
// Back returns to the screen we came from.
|
||||
//
|
||||
// Most exits name their destination, because a door leads where it leads. A
|
||||
// screen that is reached from several different rooms cannot: the BBS terminal
|
||||
// is the same terminal whether you walked to it from the club, from Norman's
|
||||
// flat or from the roof, so its way out is "back", not a place.
|
||||
func Back(w *World) inkwell.Action {
|
||||
return Fn(func(ctx *inkwell.Ctx) {
|
||||
if w.prev == "" {
|
||||
@@ -127,14 +96,6 @@ func Back(w *World) inkwell.Action {
|
||||
})
|
||||
}
|
||||
|
||||
// ----- TapeSay ----------------------------------------------------------
|
||||
|
||||
// TapeSay is a line spoken by a tape.
|
||||
//
|
||||
// It is deliberately not inkwell.Say: Say puts a SpeechBubble above the
|
||||
// speaker's head, but tapes have no body in the scene — they speak into your
|
||||
// ear. This is the two-channel rule enforced in code: a tape can only reach the
|
||||
// tape channel, never the scene.
|
||||
func TapeSay(speaker, text string) inkwell.Action {
|
||||
return &tapeSayAction{speaker: speaker, text: text}
|
||||
}
|
||||
@@ -153,7 +114,7 @@ type tapeSayRunner struct {
|
||||
func (r *tapeSayRunner) Tick(ctx *inkwell.Ctx) inkwell.Status {
|
||||
if !r.started {
|
||||
r.started = true
|
||||
// Same pacing as Say, so the two breathe together inside a Seq.
|
||||
|
||||
r.duration = 1.2 + float64(len([]rune(r.spec.text)))*0.05
|
||||
ctx.Game.LogResponse(r.spec.speaker, r.spec.text)
|
||||
}
|
||||
@@ -164,11 +125,6 @@ func (r *tapeSayRunner) Tick(ctx *inkwell.Ctx) inkwell.Status {
|
||||
return inkwell.StatusRunning
|
||||
}
|
||||
|
||||
// ----- TapeOffer --------------------------------------------------------
|
||||
|
||||
// TapeOffer offers a tape line during a cutscene: the Letterbox shows that a
|
||||
// tape would speak, but it only speaks if the player asks. A tape never
|
||||
// interrupts — the floor is the player's.
|
||||
func TapeOffer(w *World, line inkwell.Action) inkwell.Action {
|
||||
return Fn(func(*inkwell.Ctx) {
|
||||
w.tapeLine = line
|
||||
@@ -176,7 +132,6 @@ func TapeOffer(w *World, line inkwell.Action) inkwell.Action {
|
||||
})
|
||||
}
|
||||
|
||||
// TakeTapeOffer queues the offered line and clears the prompt.
|
||||
func (w *World) TakeTapeOffer() {
|
||||
if !w.tapeWaiting {
|
||||
return
|
||||
@@ -187,11 +142,6 @@ func (w *World) TakeTapeOffer() {
|
||||
w.Do(line)
|
||||
}
|
||||
|
||||
// ----- Paused -----------------------------------------------------------
|
||||
|
||||
// Paused marks the world as stopped for the duration of the wrapped action.
|
||||
// inkwell exposes no dialogueActive accessor, so we mark it on the content
|
||||
// side: every dialogue start is wrapped in this.
|
||||
func Paused(w *World, inner inkwell.Action) inkwell.Action {
|
||||
return &pausedAction{w: w, inner: inner}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user