mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-09-10 13:34:36 -04:00
* move asset manager initialization logic to d2app * updating to loogger printf statements
38 lines
1.1 KiB
Go
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
|
|
}
|