Documentation
¶
Overview ¶
Package dialoguebox is an Ebiten game that shows a dialogue: a dark screen with a box at the bottom, the speaker's name, the text typing out in the speaker's voice, and a hint. Space, Enter or a click skips the typing or goes on to the next line. It plays a dialogue.Script through a dialogue.Player.
The box knows nothing about the browser or the audio device: the caller makes the synth.Stream and plays it (for example with the parent package's Player), and runs the box with ebiten.RunGame.
Index ¶
- Constants
- func Wrap(text string, width int) string
- type Box
- func (b *Box) Draw(screen *ebiten.Image)
- func (b *Box) Layout(int, int) (int, int)
- func (b *Box) Player() *dialogue.Player
- func (b *Box) Script() *dialogue.Script
- func (b *Box) SetAutoAdvance(on bool)
- func (b *Box) SetLanguages(f func(name string) *voice.Language)
- func (b *Box) SetSamples(l synth.SampleLoader)
- func (b *Box) SetScript(s *dialogue.Script, voices map[string]*voice.Voice, start int) error
- func (b *Box) Step(dt time.Duration)
- func (b *Box) Update() error
- type Options
Constants ¶
const ( ScreenWidth = 480 ScreenHeight = 270 )
The size of the box's screen; Layout always returns it, and Ebiten scales it to the window.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Box ¶
type Box struct {
// contains filtered or unexported fields
}
Box is an ebiten.Game around a dialogue player. Use it from Ebiten's goroutine only (Update, Draw, SetScript).
func New ¶
New returns a box that speaks on stream. It shows nothing until Box.SetScript.
func (*Box) SetAutoAdvance ¶
SetAutoAdvance changes hands-free play for the next SetScript.
func (*Box) SetLanguages ¶
SetLanguages changes the language resolver for the next SetScript.
func (*Box) SetSamples ¶
func (b *Box) SetSamples(l synth.SampleLoader)
SetSamples changes the sample loader for the next SetScript.
func (*Box) SetScript ¶
SetScript swaps the dialogue: the running player is closed (its notes released), the speakers' voices are set on the stream, and line start is played. It returns an error for a missing voice, an invalid start line or a voice the stream rejects, and then keeps the old dialogue.
type Options ¶
type Options struct {
// Languages resolves a voice's language name, see
// [dialogue.Options].Languages.
Languages func(name string) *voice.Language
// AutoAdvance plays hands-free, see [dialogue.Options].AutoAdvance.
AutoAdvance bool
// Samples loads the sample files that voices name; nil means none, and a
// voice with a sample instrument is then rejected by SetScript.
Samples synth.SampleLoader
}
Options tune a Box.