assetLoader

package
v0.0.0-...-126e10b Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 33 Imported by: 0

README

Unified Asset Loader

The purpose of this Service Mesh service is to provide a single dependency which has all file loading methods available for use by other high-level D2 services.

Dependencies

This service has dependencies on all other Diablo2 file-loader services:

Integration with other services

This service integrates with the following services:

The integration is optional; if neither are added to the servicemesh then the integration methods will never be called.

This service exports an integration interface LoadsDiabloFiles with an alias Dependencncy which are intended to be used by other services for dependency resolution (see servicemesh.HasDependencies), and expose just the methods which other services should use.

type LoadsDiabloFiles interface {
Load(filepath string) (io.Reader, error)
LoadDc6(filepath string) (*dc6.DC6, error)
LoadDcc(filepath string) (*dcc.DCC, error)
LoadDs1(filepath string) (*ds1.DS1, error)
LoadDt1(filepath string) (*dt1.DT1, error)
LoadGpl(filepath string) (*gpl.GPL, error)
LoadPl2(filepath string) (*pl2.PL2, error)
LoadTbl(filepath string) (tbl.TextTable, error)
LoadTsv(filepath string, destination any) error
LoadWav(filepath string) ([]byte, error)
}

Config service integration

This service has a config file asset_loader.json where config options for things like the sprite cache size can be found.

Lua service integration

A global assets variable is exported to lua. At the time of writing, there is a single load function which loads a file from the mpq loader and yields the file data as an array of bytes.

Here is an example of its usage:

data = assets.load("/data/global/ui/Loading/loadingscreen.dc6")

Web router service integration

If the web router service is present at servicemesh, this service will register routes for retrieving data.

The route slug for this service is asset, so all routes defined will be under that route group.

route method purpose
asset/raw/*path GET yields the file for the given path from the mpq's
asset/sprite/png/:palette/*path GET yields a PNG sprite using the specified palette and file
asset/sprite/gif/:palette/*path GET yields an animated GIF using the specified palette and file

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dependency

type Dependency = LoadsDiabloFiles

type LoadsDiabloFiles

type LoadsDiabloFiles interface {
	Load(filepath string) (io.Reader, error)
	LoadDc6(filepath string) (*dc6.DC6, error)
	LoadDcc(filepath string) (*dcc.DCC, error)
	LoadDs1(filepath string) (*ds1.DS1, error)
	LoadDt1(filepath string) (*dt1.DT1, error)
	LoadPl2(filepath string) (*pl2.PL2, error)
	LoadTbl(filepath string) (tbl.TextTable, error)
	UnmarshalTsv(filepath string, destination any) error
	LoadTsv(filepath string) ([]byte, error)
	LoadWav(filepath string) ([]byte, error)
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func (*Service) AddArchive

func (s *Service) AddArchive(filepath string) error

func (*Service) Archives

func (s *Service) Archives() map[string]*mpq.MPQ

func (*Service) DependenciesResolved

func (s *Service) DependenciesResolved() bool

func (*Service) ExportToLua

func (s *Service) ExportToLua(state *lua.LState)

func (*Service) Init

func (s *Service) Init(mesh servicemesh.Mesh)

func (*Service) InitRoutes

func (s *Service) InitRoutes(group *gin.RouterGroup)

func (*Service) Load

func (s *Service) Load(filepath string) (io.Reader, error)

func (*Service) LoadDc6

func (s *Service) LoadDc6(filepath string) (*dc6.DC6, error)

func (*Service) LoadDcc

func (s *Service) LoadDcc(filepath string) (*dcc.DCC, error)

func (*Service) LoadDs1

func (s *Service) LoadDs1(filepath string) (*ds1.DS1, error)

func (*Service) LoadDt1

func (s *Service) LoadDt1(filepath string) (*dt1.DT1, error)

func (*Service) LoadFontTable

func (s *Service) LoadFontTable(filepath string) (*font_table.Font, error)

func (*Service) LoadPl2

func (s *Service) LoadPl2(filepath string) (*pl2.PL2, error)

func (*Service) LoadTbl

func (s *Service) LoadTbl(filepath string) (tbl.TextTable, error)

func (*Service) LoadTsv

func (s *Service) LoadTsv(filepath string) ([]byte, error)

func (*Service) LoadWav

func (s *Service) LoadWav(filepath string) ([]byte, error)

func (*Service) Logger

func (s *Service) Logger() *slog.Logger

func (*Service) Name

func (s *Service) Name() string

func (*Service) Ready

func (s *Service) Ready() bool

func (*Service) ResolveDependencies

func (s *Service) ResolveDependencies(services []servicemesh.Service)

func (*Service) SetLogger

func (s *Service) SetLogger(logger *slog.Logger)

func (*Service) Slug

func (s *Service) Slug() string

func (*Service) UnexportFromLua

func (s *Service) UnexportFromLua(state *lua.LState)

func (*Service) UnmarshalTsv

func (s *Service) UnmarshalTsv(filepath string, destination any) error

Jump to

Keyboard shortcuts

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