assetstore

package
v0.0.0-...-55c2232 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOutOfBounds = errors.New("Out of bounds")
)

Functions

This section is empty.

Types

type Animation

type Animation struct {
	Frames []*Sprite
}

type AssetStore

type AssetStore struct {
	RootDir string
	Palette color.Palette
	// contains filtered or unexported fields
}

type AssetStore is responsible for lazily loading game data when it is required. Applications shouldn't need to do anything except set one of these up, pointing at the game dir root, to access all assets for that game.

Assets should be loaded on-demand to keep memory costs as low as possible. Cross-platform differences such as filename case sensitivity are also dealt with here.

We assume the directory is read-only. You can run Refresh() if you make a change.

To mix assets from different games, either construct a synthetic directory or instantiate two separate asset stores.

func New

func New(engine *config.Engine) (*AssetStore, error)

New returns a new AssetStore

func (*AssetStore) Animation

func (a *AssetStore) Animation(groupIdx int, recId int, compass int) (*Animation, error)

func (*AssetStore) AnimationsIndex

func (a *AssetStore) AnimationsIndex() (*idx.Idx, error)

func (*AssetStore) AnimationsObject

func (a *AssetStore) AnimationsObject() (*Object, error)

func (*AssetStore) CharacterAnimation

func (a *AssetStore) CharacterAnimation(ctype data.CharacterType, action data.AnimAction, compass int) (*Animation, error)

func (*AssetStore) Cursor

func (a *AssetStore) Cursor(name CursorName) (*Cursor, error)

func (*AssetStore) DefaultOptions

func (a *AssetStore) DefaultOptions() (*config.Options, error)

func (*AssetStore) Font

func (a *AssetStore) Font(name string) (*Font, error)

func (*AssetStore) Generic

func (a *AssetStore) Generic() (*data.Generic, error)

Generic returns a struct containing a grab-bag of otherwise-unrelated data TODO: it would be nice if this could be cleaner

func (*AssetStore) HasAction

func (a *AssetStore) HasAction() (*data.HasAction, error)

func (*AssetStore) Image

func (a *AssetStore) Image(name string) (*ebiten.Image, error)

func (*AssetStore) Map

func (a *AssetStore) Map(name string) (*Map, error)

Map loads a game map with the given name (e.g. "Chapter01")

func (*AssetStore) Menu

func (a *AssetStore) Menu(name string) (*Menu, error)

func (*AssetStore) Object

func (a *AssetStore) Object(name string) (*Object, error)

func (*AssetStore) ObjectByPath

func (a *AssetStore) ObjectByPath(path string) (*Object, error)

FIXME: Objects loaded by path are not cached

func (*AssetStore) Refresh

func (a *AssetStore) Refresh() error

func (*AssetStore) Set

func (a *AssetStore) Set(name string) (*Set, error)

func (*AssetStore) Sound

func (a *AssetStore) Sound(name string) (*Sound, error)

type Cursor

type Cursor struct {
	Hotspot image.Point
	Image   *ebiten.Image
}

type CursorName

type CursorName int

These are just offsets into the Cursors.cur file

const (
	UltPointer   CursorName = 0
	ChaosPointer CursorName = 1
	UltWaiter    CursorName = 2
	ChaosWaiter  CursorName = 3

	// I think these cursors are used in drag + drop
	ChaosMarine1 CursorName = 4
	ChaosMarine2 CursorName = 5
	ChaosMarine3 CursorName = 6

	UltMarine1 CursorName = 7
	UltMarine2 CursorName = 8
	UltMarine3 CursorName = 9
	UltMarine4 CursorName = 10
	UltMarine5 CursorName = 11

	ChaosHeavy1 CursorName = 12
	ChaosHeavy2 CursorName = 13

	UltHeavy1 CursorName = 14
	UltHeavy2 CursorName = 15
	UltHeavy3 CursorName = 16
	UltHeavy4 CursorName = 17
	UltHeavy5 CursorName = 18
	UltHeavy6 CursorName = 19

	ChaosTerminator1 CursorName = 20
	ChaosTerminator2 CursorName = 21

	UltTerminator1 CursorName = 22
	UltTerminator2 CursorName = 23
	UltTerminator3 CursorName = 24
	UltTerminator4 CursorName = 25
	UltTerminator5 CursorName = 26

	Deny CursorName = 27 // Red X

	UltSquadMarine  CursorName = 29
	UltSquadHeavy   CursorName = 30
	UltSquadAssault CursorName = 31

	UltCaptain    CursorName = 32
	UltChaplain   CursorName = 33 // (maybe?)
	UltApothecary CursorName = 34
	UltTechmarine CursorName = 35
	UltLibrarian  CursorName = 36

	DenyAgain CursorName = 37 // Identical to Deny as far as I can see *shrug*
)

type Font

type Font struct {
	Name string
	// contains filtered or unexported fields
}

func (*Font) CalculateBounds

func (f *Font) CalculateBounds(text string) image.Rectangle

CalculateBounds tries to work out what sort of size the string will be when rendered

func (*Font) Glyph

func (f *Font) Glyph(r rune) (*Sprite, error)

type Map

type Map struct {
	Rect image.Rectangle
	// contains filtered or unexported fields
}

func (*Map) Cell

func (m *Map) Cell(x, y, z int) *maps.Cell

FIXME: get rid of this

func (*Map) CharacterAt

func (m *Map) CharacterAt(x, y, z int) *maps.Character

func (*Map) LoadSprites

func (m *Map) LoadSprites() error

func (*Map) SpritesForCell

func (m *Map) SpritesForCell(x, y, z int) ([]*Sprite, error)

SpritesForCell returns the sprites needed to correctly render this cell. They should be rendered from first to last to get the correct ordering

type Menu struct {
	Name string
	// contains filtered or unexported fields
}
func (m *Menu) Font(idx int) *Font

FIXME: don't expose this

func (m *Menu) Groups() []*menus.Group

FIXME: don't expose this

func (m *Menu) Images(objIdx, start, count int) ([]*ebiten.Image, error)
func (m *Menu) Sprite(objIdx, idx int) (*Sprite, error)
func (m *Menu) Sprites(objIdx, start, count int) ([]*Sprite, error)

type Object

type Object struct {
	NumSprites int
	Name       string
	// contains filtered or unexported fields
}

func (*Object) LoadSprites

func (o *Object) LoadSprites() error

Loads all sprites in the object eagerly

func (*Object) Sprite

func (o *Object) Sprite(idx int) (*Sprite, error)

func (*Object) Sprites

func (o *Object) Sprites(start, count int) ([]*Sprite, error)

type Set

type Set struct {
	NumObjects int
	// contains filtered or unexported fields
}

func (*Set) Object

func (s *Set) Object(idx int) (*Object, error)

type Sound

type Sound struct {
	Name string
	// contains filtered or unexported fields
}

func (*Sound) InfinitePlayer

func (s *Sound) InfinitePlayer() (*audio.Player, error)

func (*Sound) Player

func (s *Sound) Player() (*audio.Player, error)

type Sprite

type Sprite struct {
	XOffset int // TODO: replace these everywhere with Rect
	YOffset int
	Width   int
	Height  int

	ID    string
	Rect  image.Rectangle
	Image *ebiten.Image
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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