A referência da API é gerada a partir dos comentários de documentação Go no código-fonte e está escrita em inglês.
package storecapture
import "github.com/nsgo-dev/game/pkg/tooling/storecapture"Visão geral
Package storecapture is experimental: its API and documented formats may change in a minor release. See the API stability policy. reads a store capture plan, the YAML file (store/capture.yaml by default) that says which scene, input recording and frame make each store screenshot and cover and at which store sizes, and checks the images it describes against it.
The plan only describes the images: rendering its shots from the game needs the fixed-step movie mode of nsgo-dev/game#1438, which does not exist yet, so the images are captured by other means (the runtime MCP bridge's game_screenshot, or by hand) and Check verifies that every one of them is present as a PNG of its target size.
Índice
Constantes
Funções
func Check(p Plan, project, media string) errorCheck validates the plan and verifies its inputs and images: every shot's scene and recording exist under the project directory, and every image exists under the media directory as a PNG of its target size. It returns every problem found, joined, or nil.
func Presets() map[string]SizePresets returns a copy of the named store sizes a target may use.
Tipos
type Image struct {
// Shot is the shot's name.
Shot string
// Path is the file's path relative to the media directory, in slash form.
Path string
// Size is the size the file must have.
Size Size
}Image is one file a plan describes: a shot at one of its sizes.
type Plan struct {
// Version is the format version, always Version.
Version int `yaml:"version"`
// Shots are the plan's images in the order they are captured.
Shots []Shot `yaml:"shots"`
}Plan is a store capture plan.
func Decode(data []byte) (*Plan, error)Decode parses and validates a plan, refusing unknown fields and more than one YAML document. Its errors are *loaderr.Error values naming the line and field.
func LoadFile(path string) (*Plan, error)LoadFile reads and decodes the plan at path, naming the file in its errors.
func (p *Plan) Encode() ([]byte, error)Encode validates the plan and returns it as YAML with two-space indentation and fields in a fixed order, so a decoded plan encodes back to the same bytes.
func (p *Plan) Images() []ImageImages returns the files the plan describes, shot by shot in plan order and each shot's sizes in order. The plan must be valid.
func (p *Plan) Validate() errorValidate reports the first problem with the plan as a *loaderr.Error naming its field: an unsupported version, no shots, or a shot with a missing or duplicate name, a scene, recording or output outside the project, both a frame and a time, a negative capture point, no sizes or an invalid size, or two images with the same file.
type Shot struct {
// Name identifies the shot, unique within the plan.
Name string `yaml:"name"`
// Scene is the scene file to capture, relative to the project, in slash form.
Scene string `yaml:"scene"`
// Recording is an optional .replay.yaml input recording played before the capture, relative to the project, in slash form.
Recording string `yaml:"recording,omitempty"`
// Frame is the fixed-step frame to capture; at most one of Frame and Time is set, and neither means the first frame.
Frame *int `yaml:"frame,omitempty"`
// Time is the fixed-step time in seconds to capture.
Time *float64 `yaml:"time,omitempty"`
// Output is the image name relative to the media directory, in slash form and without the size suffix: each target is written to <output>-<width>x<height>.png.
Output string `yaml:"output"`
// Sizes are the sizes the shot is delivered at.
Sizes []Target `yaml:"sizes"`
}Shot is one store image: what to capture and the sizes to deliver it at.
type Target struct {
// Preset names one of Presets.
Preset string `yaml:"preset,omitempty"`
// Width and Height are an explicit size in pixels.
Width int `yaml:"width,omitempty"`
Height int `yaml:"height,omitempty"`
}Target is one size a shot is wanted at: a named preset, or an explicit width and height, never both.
func (t Target) Resolve() (Size, error)Resolve returns the target's size.