2020-02-01 18:55:56 -05:00
|
|
|
package d2asset
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2cof"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2dc6"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2dcc"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2020-02-09 14:12:04 -05:00
|
|
|
ErrWasInit = errors.New("asset system is already initialized")
|
|
|
|
ErrNotInit = errors.New("asset system is not initialized")
|
2020-02-01 18:55:56 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type assetManager struct {
|
2020-04-11 14:56:47 -04:00
|
|
|
archiveManager *archiveManager
|
|
|
|
fileManager *fileManager
|
|
|
|
paletteManager *paletteManager
|
|
|
|
paletteTransformManager *paletteTransformManager
|
|
|
|
animationManager *animationManager
|
|
|
|
fontManager *fontManager
|
2020-02-01 18:55:56 -05:00
|
|
|
}
|
|
|
|
|
2020-02-26 08:39:38 -05:00
|
|
|
func loadDC6(dc6Path string) (*d2dc6.DC6File, error) {
|
2020-02-01 18:55:56 -05:00
|
|
|
dc6Data, err := LoadFile(dc6Path)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-02-26 08:39:38 -05:00
|
|
|
dc6, err := d2dc6.LoadDC6(dc6Data)
|
2020-02-01 18:55:56 -05:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-02-26 08:39:38 -05:00
|
|
|
return dc6, nil
|
2020-02-01 18:55:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func loadDCC(dccPath string) (*d2dcc.DCC, error) {
|
|
|
|
dccData, err := LoadFile(dccPath)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return d2dcc.LoadDCC(dccData)
|
|
|
|
}
|
|
|
|
|
|
|
|
func loadCOF(cofPath string) (*d2cof.COF, error) {
|
|
|
|
cofData, err := LoadFile(cofPath)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return d2cof.LoadCOF(cofData)
|
|
|
|
}
|