Documentation
¶
Overview ¶
Package screenpack loads and validates an OpenKakutou screenpack: the format of docs/format.md, checked against the schemas of package schema and across files.
Index ¶
- Constants
- func DefaultFS() fs.FS
- type Animation
- type AnimationFrame
- type Arrows
- type ButtonIcons
- type CharacterSelect
- type Continue
- type ControlSlots
- type Cursors
- type Dim
- type Effect
- type Element
- type Error
- type ErrorMessage
- type FontID
- type Grid
- type Layout
- type MatchSetup
- type Menu
- type MoveLines
- type MoveList
- type Music
- type Options
- type Outline
- type Path
- type Pause
- type Portraits
- type PressStart
- type Problem
- type Problems
- type Resolved
- type Results
- type Screen
- type Screenpack
- type Screens
- type Scrollbar
- type Shadow
- type Sides
- type Sort
- type Sounds
- type Source
- type SpriteSheet
- type StageSelect
- type StyleID
- type TextPart
- type TextStyle
- type Title
- type Transition
- type Versus
- type Victory
- type Winner
Constants ¶
const RootFile = "screenpack.json"
RootFile is the file every screenpack has.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Animation ¶
type Animation struct {
Frames []AnimationFrame `json:"frames"`
// Loop is true when unset.
Loop *bool `json:"loop"`
}
Animation plays sheet frames in order.
type AnimationFrame ¶
AnimationFrame is one step of an animation.
type ButtonIcons ¶
ButtonIcons map button ids to frames of one sprite sheet.
type CharacterSelect ¶
type CharacterSelect struct {
Screen
Grid *Grid `json:"grid"`
Sort *Sort `json:"sort"`
Cursor *Cursors `json:"cursor"`
Portrait *Portraits `json:"portrait"`
Name *Sides[TextPart] `json:"name"`
Palette *Sides[TextPart] `json:"palette"`
Title *TextPart `json:"title"`
}
CharacterSelect is the character select screen.
type Continue ¶
type Continue struct {
Screen
Portrait *Layout `json:"portrait"`
Countdown *TextPart `json:"countdown"`
Message *TextPart `json:"message"`
Menu *Menu `json:"menu"`
}
Continue is the continue screen.
type ControlSlots ¶
type ControlSlots struct {
TextPart
SlotStyle StyleID `json:"slotStyle"`
WaitingStyle StyleID `json:"waitingStyle"`
}
ControlSlots style the controls page's bindings.
type Cursors ¶
Cursors are the select cursors of each side, and the one shown when both share a cell.
type Effect ¶
type Effect struct {
Kind string `json:"kind"`
Ms int `json:"ms"`
DelayMs int `json:"delayMs"`
Easing string `json:"easing"`
From any `json:"from"`
}
Effect is one half of a transition.
type Element ¶
type Element struct {
Layout
Type string `json:"type"`
Visible *bool `json:"visible"`
Opacity *float64 `json:"opacity"`
Transition *Transition `json:"transition"`
// Image is a still image; Sheet with Animation or Frame shows a sprite
// sheet instead.
Image Path `json:"image"`
Sheet Path `json:"sheet"`
Animation string `json:"animation"`
Frame string `json:"frame"`
Tile string `json:"tile"`
Scroll *[2]float64 `json:"scroll"`
Text string `json:"text"`
Style StyleID `json:"style"`
Color string `json:"color"`
Radius float64 `json:"radius"`
}
Element is one drawn thing: an image, a text or a rectangle (Type).
type Error ¶ added in v0.7.0
type Error struct {
Screen
Title *TextPart `json:"title"`
Message *ErrorMessage `json:"message"`
Hint *TextPart `json:"hint"`
}
Error is the screen showing a problem the game reports.
type ErrorMessage ¶ added in v0.7.0
ErrorMessage is the error text, wrapped inside Width units.
type Grid ¶
type Grid struct {
Layout
Columns int `json:"columns"`
Rows int `json:"rows"`
CellSize *[2]float64 `json:"cellSize"`
Spacing *[2]float64 `json:"spacing"`
Cell *Element `json:"cell"`
EmptyCell *Element `json:"emptyCell"`
Random *Element `json:"random"`
}
Grid is the character select's grid of cells.
type Layout ¶
type Layout struct {
Anchor string `json:"anchor"`
Pivot string `json:"pivot"`
Offset [2]float64 `json:"offset"`
Size *[2]*float64 `json:"size"`
}
Layout places an element or a part: Pivot is set on Anchor, moved by Offset, in units of 1/100 of the screen height. A nil Size side keeps the image's aspect ratio.
type MatchSetup ¶
MatchSetup is the match setup screen.
type Menu ¶
type Menu struct {
Layout
Direction string `json:"direction"`
Spacing float64 `json:"spacing"`
VisibleEntries int `json:"visibleEntries"`
Style StyleID `json:"style"`
ActiveStyle StyleID `json:"activeStyle"`
DisabledStyle StyleID `json:"disabledStyle"`
FlaggedStyle StyleID `json:"flaggedStyle"`
Cursor *Element `json:"cursor"`
Order []string `json:"order"`
Hidden []string `json:"hidden"`
Sounds Sounds `json:"sounds"`
ValueStyle StyleID `json:"valueStyle"`
ValueOffset *[2]float64 `json:"valueOffset"`
// ValueOffsets places each value column of an entry with several values.
ValueOffsets [][2]float64 `json:"valueOffsets"`
}
Menu styles and arranges the entries the game offers.
type MoveLines ¶
type MoveLines struct {
TextPart
VisibleLines int `json:"visibleLines"`
LineSpacing float64 `json:"lineSpacing"`
}
MoveLines is the move list itself.
type MoveList ¶
type MoveList struct {
Screen
Title *TextPart `json:"title"`
List *MoveLines `json:"list"`
Buttons *ButtonIcons `json:"buttons"`
Scrollbar *Scrollbar `json:"scrollbar"`
}
MoveList is the move list screen.
type Music ¶
type Music struct {
File Path `json:"file"`
Volume *float64 `json:"volume"`
LoopStartMs int `json:"loopStartMs"`
}
Music is a looping music track.
type Options ¶
type Options struct {
Screen
Tabs *Menu `json:"tabs"`
Menu *Menu `json:"menu"`
Controls *ControlSlots `json:"controls"`
Hint *TextPart `json:"hint"`
Title *TextPart `json:"title"`
}
Options is the options screen.
type Path ¶
type Path string
Path is an asset path, relative to the screenpack folder (or, in a sprite sheet, to the sheet's folder).
type Pause ¶
type Pause struct {
Screen
Dim *Dim `json:"dim"`
Title *TextPart `json:"title"`
Menu *Menu `json:"menu"`
}
Pause is the pause screen.
type PressStart ¶
PressStart is the title's "press start" prompt.
type Problem ¶
Problem is one thing wrong in a screenpack: the file, the JSON Pointer of the faulty value ("" for the whole file) and the reason.
type Problems ¶
type Problems []Problem
Problems lists every problem found; as an error, one per line.
type Resolved ¶ added in v0.5.0
type Resolved struct {
Pack *Screenpack
Default *Screenpack
Screens Screens
// contains filtered or unexported fields
}
Resolved is a screenpack with every screen present: a screen the pack does not have is the default's, and a part a pack screen leaves out is the default screen's part.
func Resolve ¶ added in v0.5.0
func Resolve(pack, def *Screenpack) (*Resolved, error)
Resolve fills pack's missing screens and parts from def, which must have every screen. Neither screenpack is changed.
type Results ¶
type Results struct {
Screen
Winner *Winner `json:"winner"`
Message *TextPart `json:"message"`
Score *TextPart `json:"score"`
Menu *Menu `json:"menu"`
}
Results is the results screen.
type Screen ¶
type Screen struct {
Background []Element `json:"background"`
Foreground []Element `json:"foreground"`
Music *Music `json:"music"`
Silent bool `json:"-"`
Sounds Sounds `json:"sounds"`
TextStyles map[StyleID]TextStyle `json:"textStyles"`
Transition *Transition `json:"transition"`
}
Screen holds the fields every screen file has. Silent is set when the file asks for no music ("music": null), as opposed to leaving it out.
type Screenpack ¶
type Screenpack struct {
Name string
Author string
Version string
Fonts map[FontID]Path
TextStyles map[StyleID]TextStyle
Sounds Sounds
Music *Music
// WarningColor tints what the game flags as a problem; empty means the
// format's default, #dc3c3c.
WarningColor string
// Screens holds the screens the pack has; a nil one falls back to the
// default screenpack's.
Screens Screens
// Sheets are the sprite sheets the screens use, by path.
Sheets map[Path]*SpriteSheet
// Warnings are problems that do not stop loading, such as an unknown
// file in screens/.
Warnings Problems
}
Screenpack is a loaded screenpack.
func Load ¶
func Load(fsys fs.FS) (*Screenpack, error)
Load reads the screenpack at the root of fsys (os.DirFS of its folder, or an in-memory file set). It checks every file against its schema, then that every referenced file, font, text style, sprite-sheet frame and animation exists. On failure the error is Problems, listing all of them.
type Screens ¶
type Screens struct {
Title *Title
CharacterSelect *CharacterSelect
StageSelect *StageSelect
MatchSetup *MatchSetup
Versus *Versus
Options *Options
Pause *Pause
MoveList *MoveList
Results *Results
Continue *Continue
Victory *Victory
Error *Error
}
Screens are a screenpack's screens; nil means the pack does not have it.
type Sides ¶
type Sides[T any] struct { P1 *T `json:"p1"` P2 *T `json:"p2"` }
Sides holds one part per player side.
type Sounds ¶
Sounds maps a sound name (move, confirm, cancel, error, and a screen's extra ones) to its file.
type Source ¶ added in v0.5.0
type Source int
Source says which screenpack a screen or a part comes from. Text styles, fonts and assets of something from the default screenpack are looked up in the default screenpack.
type SpriteSheet ¶
type SpriteSheet struct {
// Image is relative to the sheet's own folder.
Image Path `json:"image"`
Frames map[string][4]int `json:"frames"`
Animations map[string]Animation `json:"animations"`
}
SpriteSheet is an image cut into frames, and animations over them.
type StageSelect ¶
type StageSelect struct {
Screen
Sort *Sort `json:"sort"`
Preview *Layout `json:"preview"`
Name *TextPart `json:"name"`
Title *TextPart `json:"title"`
Arrows *Arrows `json:"arrows"`
}
StageSelect is the stage select screen.
type TextStyle ¶
type TextStyle struct {
Font FontID `json:"font"`
Size float64 `json:"size"`
Color string `json:"color"`
Align string `json:"align"`
Outline *Outline `json:"outline"`
Shadow *Shadow `json:"shadow"`
Uppercase bool `json:"uppercase"`
}
TextStyle is how a text is drawn.
type Title ¶
type Title struct {
Screen
Logo *Element `json:"logo"`
Menu *Menu `json:"menu"`
PressStart *PressStart `json:"pressStart"`
Version *TextPart `json:"version"`
}
Title is the title and main menu screen.
type Transition ¶
Transition is how a screen or an element enters and leaves.
type Versus ¶
type Versus struct {
Screen
Portrait *Portraits `json:"portrait"`
Name *Sides[TextPart] `json:"name"`
Stage *TextPart `json:"stage"`
DurationMs *int `json:"durationMs"`
}
Versus is the VS screen.