screenpack

package module
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

screenpack

OpenKakutou screenpack holds the OpenKakutou-specific screenpack format (roadmap decision 029): its specification, the JSON Schemas (root screenpack.json + one per screen), the default screenpack, and a Go library that loads, validates (schemas + cross-file checks), resolves per-screen fallbacks to the default screenpack and writes screenpacks. It compiles to WASM for game's web build and is imported natively by game's native build and by the planned screenpack-editor.

Part of OpenKakutou. Early stage: see .vibe/backlog/ for the planned work.

Go library

sp, err := screenpack.Load(os.DirFS("screenpacks/neon"))
var problems screenpack.Problems
if errors.As(err, &problems) {
	for _, p := range problems {
		fmt.Println(p.File, p.Path, p.Reason) // e.g. screens/pause.json /title/style unknown text style "huge"
	}
}

sp.Screens holds the screens the pack has; sp.Warnings lists what was ignored, such as an unknown file in screens/. screenpack.Resolve(sp, def) then fills every missing screen, and every part a pack screen leaves out, from the default screenpack def; Source(screen, part) tells which pack each one comes from, so its text styles, fonts and assets are looked up there.

License

MIT, see LICENSE.

Documentation

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

View Source
const RootFile = "screenpack.json"

RootFile is the file every screenpack has.

Variables

This section is empty.

Functions

func DefaultFS added in v0.6.0

func DefaultFS() fs.FS

DefaultFS returns the default screenpack's files (the default/ folder), built into the program: a game ships it and falls back on it without depending on a folder on disk.

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

type AnimationFrame struct {
	Frame string `json:"frame"`
	Ms    int    `json:"ms"`
}

AnimationFrame is one step of an animation.

type Arrows

type Arrows struct {
	Left  *Element `json:"left"`
	Right *Element `json:"right"`
}

Arrows show that more items lie on a side.

type ButtonIcons

type ButtonIcons struct {
	Sheet  Path              `json:"sheet"`
	Frames map[string]string `json:"frames"`
}

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

type Cursors struct {
	P1   *Element `json:"p1"`
	P2   *Element `json:"p2"`
	Both *Element `json:"both"`
}

Cursors are the select cursors of each side, and the one shown when both share a cell.

type Dim

type Dim struct {
	Color string `json:"color"`
}

Dim is drawn over the frozen match.

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

type ErrorMessage struct {
	TextPart
	Width float64 `json:"width"`
}

ErrorMessage is the error text, wrapped inside Width units.

type FontID

type FontID string

FontID names a font of the root file.

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

type MatchSetup struct {
	Screen
	Menu  *Menu     `json:"menu"`
	Title *TextPart `json:"title"`
}

MatchSetup is the match setup screen.

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 Outline

type Outline struct {
	Color string  `json:"color"`
	Width float64 `json:"width"`
}

Outline is a text style's outline.

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 Portraits

type Portraits struct {
	Sides[Layout]
	MirrorP2 *bool `json:"mirrorP2"`
}

Portraits places both sides' large portraits.

type PressStart

type PressStart struct {
	TextPart
	Text    string `json:"text"`
	BlinkMs *int   `json:"blinkMs"`
}

PressStart is the title's "press start" prompt.

type Problem

type Problem struct {
	File   string
	Path   string
	Reason string
}

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.

func (Problems) Error

func (ps Problems) Error() string

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.

func (*Resolved) Source added in v0.5.0

func (r *Resolved) Source(screen, part string) Source

Source says where a screen comes from (part "") or, for a pack screen, where one of its parts comes from; screen and part are the names of docs/format.md, e.g. "title" and "logo".

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 Scrollbar

type Scrollbar struct {
	Track *Element `json:"track"`
	Thumb *Element `json:"thumb"`
}

Scrollbar is shown when a list is longer than its visible lines.

type Shadow

type Shadow struct {
	Color  string     `json:"color"`
	Offset [2]float64 `json:"offset"`
}

Shadow is a text style's drop shadow.

type Sides

type Sides[T any] struct {
	P1 *T `json:"p1"`
	P2 *T `json:"p2"`
}

Sides holds one part per player side.

type Sort

type Sort struct {
	By         string `json:"by"`
	Descending bool   `json:"descending"`
}

Sort is a select screen's order rule.

type Sounds

type Sounds map[string]Path

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.

const (
	FromPack Source = iota
	FromDefault
)

func (Source) String added in v0.5.0

func (s Source) String() string

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 StyleID

type StyleID string

StyleID names a text style of the screen or of the root file.

type TextPart

type TextPart struct {
	Layout
	Style StyleID `json:"style"`
}

TextPart is a part showing text the game supplies.

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
	Menu       *Menu       `json:"menu"`
	PressStart *PressStart `json:"pressStart"`
	Version    *TextPart   `json:"version"`
}

Title is the title and main menu screen.

type Transition

type Transition struct {
	In  *Effect `json:"in"`
	Out *Effect `json:"out"`
}

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.

type Victory

type Victory struct {
	Screen
	Portrait   *Layout   `json:"portrait"`
	Name       *TextPart `json:"name"`
	Message    *TextPart `json:"message"`
	DurationMs *int      `json:"durationMs"`
}

Victory is the ending screen.

type Winner

type Winner struct {
	Portrait *Layout   `json:"portrait"`
	Name     *TextPart `json:"name"`
}

Winner shows the match winner.

Directories

Path Synopsis
Package schema holds the JSON Schemas of the screenpack format (docs/format.md) and checks a JSONC document against them.
Package schema holds the JSON Schemas of the screenpack format (docs/format.md) and checks a JSONC document against them.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址