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-11-03 07:54:15 -05:00
|
|
|
func NewAssetManager() (*AssetManager, error) {
|
|
|
|
loader, err := d2loader.NewLoader(d2util.LogLevelDefault)
|
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-11-03 07:54:15 -05:00
|
|
|
records, err := d2records.NewRecordManager(d2util.LogLevelDebug)
|
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-09-14 14:47:11 -04:00
|
|
|
manager := &AssetManager{
|
2020-11-07 23:08:25 -05:00
|
|
|
Logger: d2util.NewLogger(),
|
|
|
|
Loader: loader,
|
2020-11-03 14:10:11 -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),
|
|
|
|
Records: records,
|
2020-09-19 14:33:40 -04:00
|
|
|
}
|
|
|
|
|
2020-11-07 23:08:25 -05:00
|
|
|
manager.SetPrefix(logPrefix)
|
2020-02-01 18:55:56 -05:00
|
|
|
|
2020-11-03 07:54:15 -05:00
|
|
|
return manager, err
|
2020-02-26 22:46:47 -05:00
|
|
|
}
|