2020-02-01 18:55:56 -05:00
|
|
|
package d2asset
|
|
|
|
|
|
|
|
import (
|
2020-09-12 16:51:30 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2cache"
|
2020-11-03 14:10:11 -05:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2tbl"
|
2020-09-14 14:47:11 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2loader"
|
refactored logging in d2loader, d2record, and d2asset (#898)
* refactored logging in d2config, d2record, and d2asset
* asset manager, record manager, and file loader now utilitize d2util.Logger
* added colored logging to d2util.Logger (excluding windows platforms)
* removed mpq file verification from d2config; d2loader handles this
* record loaders now use the record manager's logger for printing info
* added command line argument for setting log level (`--loglevel 4`, `-l4`, or `-l 4`
* added `LogLevel` parameter to config file
* default log level will show errors, warnings, and info log messages
* specifying log level as an argument overrides setting from config file
* fixed log level tests
2020-11-02 21:23:07 -05:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
|
2020-09-19 14:33:40 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2records"
|
2020-02-01 18:55:56 -05:00
|
|
|
)
|
|
|
|
|
2020-09-12 16:51:30 -04:00
|
|
|
// NewAssetManager creates and assigns all necessary dependencies for the AssetManager top-level functions to work correctly
|
2020-12-16 02:11:28 -05:00
|
|
|
func NewAssetManager(logLevel d2util.LogLevel) (*AssetManager, error) {
|
|
|
|
loader, err := d2loader.NewLoader(logLevel)
|
refactored logging in d2loader, d2record, and d2asset (#898)
* refactored logging in d2config, d2record, and d2asset
* asset manager, record manager, and file loader now utilitize d2util.Logger
* added colored logging to d2util.Logger (excluding windows platforms)
* removed mpq file verification from d2config; d2loader handles this
* record loaders now use the record manager's logger for printing info
* added command line argument for setting log level (`--loglevel 4`, `-l4`, or `-l 4`
* added `LogLevel` parameter to config file
* default log level will show errors, warnings, and info log messages
* specifying log level as an argument overrides setting from config file
* fixed log level tests
2020-11-02 21:23:07 -05:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-12-16 02:11:28 -05:00
|
|
|
records, err := d2records.NewRecordManager(logLevel)
|
refactored logging in d2loader, d2record, and d2asset (#898)
* refactored logging in d2config, d2record, and d2asset
* asset manager, record manager, and file loader now utilitize d2util.Logger
* added colored logging to d2util.Logger (excluding windows platforms)
* removed mpq file verification from d2config; d2loader handles this
* record loaders now use the record manager's logger for printing info
* added command line argument for setting log level (`--loglevel 4`, `-l4`, or `-l 4`
* added `LogLevel` parameter to config file
* default log level will show errors, warnings, and info log messages
* specifying log level as an argument overrides setting from config file
* fixed log level tests
2020-11-02 21:23:07 -05:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-12-16 02:11:28 -05:00
|
|
|
logger := d2util.NewLogger()
|
|
|
|
logger.SetPrefix(logPrefix)
|
|
|
|
logger.SetLevel(logLevel)
|
|
|
|
|
2020-09-14 14:47:11 -04:00
|
|
|
manager := &AssetManager{
|
2020-12-16 02:11:28 -05:00
|
|
|
Logger: logger,
|
2020-11-07 23:08:25 -05:00
|
|
|
Loader: loader,
|
2021-02-02 04:08:32 -05:00
|
|
|
tables: make([]*d2tbl.TextDictionary, 0),
|
2020-11-03 07:54:15 -05:00
|
|
|
animations: d2cache.CreateCache(animationBudget),
|
|
|
|
fonts: d2cache.CreateCache(fontBudget),
|
|
|
|
palettes: d2cache.CreateCache(paletteBudget),
|
|
|
|
transforms: d2cache.CreateCache(paletteTransformBudget),
|
2021-01-10 02:44:42 -05:00
|
|
|
dt1s: d2cache.CreateCache(dt1Budget),
|
|
|
|
ds1s: d2cache.CreateCache(ds1Budget),
|
|
|
|
cofs: d2cache.CreateCache(cofBudget),
|
|
|
|
dccs: d2cache.CreateCache(dccBudget),
|
2020-11-03 07:54:15 -05:00
|
|
|
Records: records,
|
2020-09-19 14:33:40 -04:00
|
|
|
}
|
|
|
|
|
2020-11-03 07:54:15 -05:00
|
|
|
return manager, err
|
2020-02-26 22:46:47 -05:00
|
|
|
}
|