Documentation ¶
Overview ¶
Package levelpack handles ZIP archives for level packs.
Index ¶
- func ListFiles() ([]string, error)
- func LoadAllAvailable() ([]string, map[string]*LevelPack, error)
- type Level
- type LevelPack
- func (l LevelPack) GetFile(filename string) ([]byte, error)
- func (l LevelPack) GetJSON(v interface{}, filename string) error
- func (l LevelPack) GetLevel(filename string) (*level.Level, error)
- func (l LevelPack) ListFiles(prefix string) []string
- func (l LevelPack) WriteFile(filename string) error
- func (l LevelPack) WriteZipfile(filename string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Level ¶
type Level struct { UUID string `json:"uuid"` Title string `json:"title"` Author string `json:"author"` Filename string `json:"filename"` }
Level holds metadata about the levels in the levelpack.
type LevelPack ¶
type LevelPack struct { Title string `json:"title"` Description string `json:"description"` Author string `json:"author"` Created time.Time `json:"created"` // Cached metadata about the (displayed) levels. Levels []Level `json:"levels"` // Number of levels unlocked by default. // 0 = all levels unlocked FreeLevels int `json:"freeLevels"` // The loaded zip file for reading an existing levelpack. Zipfile *zip.Reader `json:"-"` // A reference to the original filename, not stored in json. Filename string `json:"-"` // Signature to allow free versions of the game to load embedded // custom doodads inside this levelpack for its levels. Signature []byte `json:"signature,omitempty"` }
LevelPack describes the contents of a levelpack file.
func (LevelPack) GetFile ¶
GetFile returns file data from inside the loaded zipfile of a levelpack.
This also implements the Embeddable interface.
func (LevelPack) GetJSON ¶
GetJSON loads a JSON file from the zipfile and marshals it into your struct.
func (LevelPack) ListFiles ¶
ListFiles returns the files in the zipfile that match the prefix given.
func (LevelPack) WriteZipfile ¶
WriteZipfile saves a levelpack back into a zip file.
Click to show internal directories.
Click to hide internal directories.