1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-19 02:46:35 -05:00
OpenDiablo2/d2core/d2asset/d2asset.go
gravestench f2ab13afae
moved asset manager initialization logic to d2app (#905)
* move asset manager initialization logic to d2app

* updating to loogger printf statements
2020-11-07 23:08:25 -05:00

38 lines
1.1 KiB
Go

package d2asset
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2cache"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2tbl"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2loader"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2records"
)
// NewAssetManager creates and assigns all necessary dependencies for the AssetManager top-level functions to work correctly
func NewAssetManager() (*AssetManager, error) {
loader, err := d2loader.NewLoader(d2util.LogLevelDefault)
if err != nil {
return nil, err
}
records, err := d2records.NewRecordManager(d2util.LogLevelDebug)
if err != nil {
return nil, err
}
manager := &AssetManager{
Logger: d2util.NewLogger(),
Loader: loader,
tables: make([]d2tbl.TextDictionary, 0),
animations: d2cache.CreateCache(animationBudget),
fonts: d2cache.CreateCache(fontBudget),
palettes: d2cache.CreateCache(paletteBudget),
transforms: d2cache.CreateCache(paletteTransformBudget),
Records: records,
}
manager.SetPrefix(logPrefix)
return manager, err
}