Documentation ¶
Overview ¶
Package d2asset has behaviors to load and save assets from disk.
Index ¶
- type Animation
- func (a *Animation) Advance(elapsed float64) error
- func (a *Animation) BindRenderer(r d2interface.Renderer)
- func (a *Animation) Clone() d2interface.Animation
- func (a *Animation) GetCurrentFrame() int
- func (a *Animation) GetCurrentFrameSize() (width, height int)
- func (a *Animation) GetCurrentFrameSurface() d2interface.Surface
- func (a *Animation) GetDirection() int
- func (a *Animation) GetDirectionCount() int
- func (a *Animation) GetFrameBounds() (maxWidth, maxHeight int)
- func (a *Animation) GetFrameCount() int
- func (a *Animation) GetFrameSize(frameIndex int) (width, height int, err error)
- func (a *Animation) GetPlayedCount() int
- func (a *Animation) IsOnFirstFrame() bool
- func (a *Animation) IsOnLastFrame() bool
- func (a *Animation) Pause()
- func (a *Animation) PlayBackward()
- func (a *Animation) PlayForward()
- func (a *Animation) Render(target d2interface.Surface)
- func (a *Animation) RenderFromOrigin(target d2interface.Surface, shadow bool)
- func (a *Animation) RenderSection(target d2interface.Surface, bound image.Rectangle)
- func (a *Animation) ResetPlayedCount()
- func (a *Animation) Rewind()
- func (a *Animation) SetColorMod(colorMod color.Color)
- func (a *Animation) SetCurrentFrame(frameIndex int) error
- func (a *Animation) SetDirection(directionIndex int) error
- func (a *Animation) SetEffect(e d2enum.DrawEffect)
- func (a *Animation) SetPlayLength(playLength float64)
- func (a *Animation) SetPlayLoop(loop bool)
- func (a *Animation) SetPlaySpeed(playSpeed float64)
- func (a *Animation) SetShadow(shadow bool)
- func (a *Animation) SetSubLoop(startFrame, endFrame int)
- type AssetManager
- func (am *AssetManager) BindTerminalCommands(term d2interface.Terminal) error
- func (am *AssetManager) FileExists(filePath string) (bool, error)
- func (am *AssetManager) LoadAnimation(animationPath, palettePath string) (d2interface.Animation, error)
- func (am *AssetManager) LoadAnimationWithEffect(animationPath, palettePath string, effect d2enum.DrawEffect) (d2interface.Animation, error)
- func (am *AssetManager) LoadAsset(filePath string) (io.ReadSeeker, error)
- func (am *AssetManager) LoadCOF(cofPath string) (*d2cof.COF, error)
- func (am *AssetManager) LoadComposite(baseType d2enum.ObjectType, token, palettePath string) (*Composite, error)
- func (am *AssetManager) LoadDCC(dccPath string) (*d2dcc.DCC, error)
- func (am *AssetManager) LoadDS1(ds1Path string) (*d2ds1.DS1, error)
- func (am *AssetManager) LoadDT1(dt1Path string) (*d2dt1.DT1, error)
- func (am *AssetManager) LoadDataDictionary(path string) (*d2txt.DataDictionary, error)
- func (am *AssetManager) LoadFile(filePath string) ([]byte, error)
- func (am *AssetManager) LoadFileStream(filePath string) (io.ReadSeeker, error)
- func (am *AssetManager) LoadFont(tablePath, spritePath, palettePath string) (*d2font.Font, error)
- func (am *AssetManager) LoadLanguage(languagePath string) string
- func (am *AssetManager) LoadPalette(palettePath string) (d2interface.Palette, error)
- func (am *AssetManager) LoadPaletteTransform(path string) (*d2pl2.PL2, error)
- func (am *AssetManager) LoadRecords(path string) error
- func (am *AssetManager) LoadStringTable(tablePath string) (d2tbl.TextDictionary, error)
- func (am *AssetManager) SetLogLevel(level d2util.LogLevel)
- func (am *AssetManager) TranslateString(input interface{}) string
- func (am *AssetManager) UnbindTerminalCommands(term d2interface.Terminal) error
- type Composite
- func (c *Composite) Advance(elapsed float64) error
- func (c *Composite) Equip(equipment *[d2enum.CompositeTypeMax]string) error
- func (c *Composite) GetAnimationMode() string
- func (c *Composite) GetCurrentFrame() int
- func (c *Composite) GetDirection() int
- func (c *Composite) GetFrameCount() int
- func (c *Composite) GetPlayedCount() int
- func (c *Composite) GetSize() (w, h int)
- func (c *Composite) GetWeaponClass() string
- func (c *Composite) ObjectAnimationMode() d2enum.ObjectAnimationMode
- func (c *Composite) Render(target d2interface.Surface) error
- func (c *Composite) SetAnimSpeed(speed int)
- func (c *Composite) SetCurrentFrame(frame int)
- func (c *Composite) SetDirection(direction int)
- func (c *Composite) SetMode(animationMode animationMode, weaponClass string) error
- func (c *Composite) SetPlayLoop(loop bool)
- func (c *Composite) SetSubLoop(startFrame, endFrame int)
- type DC6Animation
- type DCCAnimation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Animation ¶
type Animation struct {
// contains filtered or unexported fields
}
Animation has directionality, play modes, and frame counting
func (*Animation) BindRenderer ¶
func (a *Animation) BindRenderer(r d2interface.Renderer)
BindRenderer binds the given renderer to the animation so that it can initialize the required surfaces
func (*Animation) Clone ¶
func (a *Animation) Clone() d2interface.Animation
Clone creates a copy of the Animation
func (*Animation) GetCurrentFrame ¶
GetCurrentFrame gets index of current frame in animation
func (*Animation) GetCurrentFrameSize ¶
GetCurrentFrameSize gets the Size(width, height) of the current frame.
func (*Animation) GetCurrentFrameSurface ¶
func (a *Animation) GetCurrentFrameSurface() d2interface.Surface
GetCurrentFrameSurface returns the surface for the current frame of the animation
func (*Animation) GetDirection ¶
GetDirection get the current animation direction
func (*Animation) GetDirectionCount ¶
GetDirectionCount gets the number of animation direction
func (*Animation) GetFrameBounds ¶
GetFrameBounds gets maximum Size(width, height) of all frame.
func (*Animation) GetFrameCount ¶
GetFrameCount gets number of frames in animation
func (*Animation) GetFrameSize ¶
GetFrameSize gets the Size(width, height) of a indexed frame.
func (*Animation) GetPlayedCount ¶
GetPlayedCount gets the number of times the application played
func (*Animation) IsOnFirstFrame ¶
IsOnFirstFrame gets if the animation on its first frame
func (*Animation) IsOnLastFrame ¶
IsOnLastFrame gets if the animation on its last frame
func (*Animation) PlayBackward ¶
func (a *Animation) PlayBackward()
PlayBackward plays animation backward
func (*Animation) PlayForward ¶
func (a *Animation) PlayForward()
PlayForward plays animation forward
func (*Animation) Render ¶
func (a *Animation) Render(target d2interface.Surface)
Render renders the animation to the given surface
func (*Animation) RenderFromOrigin ¶
func (a *Animation) RenderFromOrigin(target d2interface.Surface, shadow bool)
RenderFromOrigin renders the animation from the animation origin
func (*Animation) RenderSection ¶
func (a *Animation) RenderSection(target d2interface.Surface, bound image.Rectangle)
RenderSection renders the section of the animation frame enclosed by bounds
func (*Animation) ResetPlayedCount ¶
func (a *Animation) ResetPlayedCount()
ResetPlayedCount resets the play count
func (*Animation) SetColorMod ¶
SetColorMod sets the Animation's color mod
func (*Animation) SetCurrentFrame ¶
SetCurrentFrame sets animation at a specific frame
func (*Animation) SetDirection ¶
SetDirection places the animation in the direction of an animation
func (*Animation) SetEffect ¶
func (a *Animation) SetEffect(e d2enum.DrawEffect)
SetEffect sets the draw effect for the animation
func (*Animation) SetPlayLength ¶
SetPlayLength sets the Animation's play length in seconds
func (*Animation) SetPlayLoop ¶
SetPlayLoop sets whether to loop the animation
func (*Animation) SetPlaySpeed ¶
SetPlaySpeed sets play speed of the animation
func (*Animation) SetSubLoop ¶
SetSubLoop sets a sub loop for the animation
type AssetManager ¶
type AssetManager struct { *d2util.Logger *d2loader.Loader Records *d2records.RecordManager // contains filtered or unexported fields }
AssetManager loads files and game objects
func NewAssetManager ¶
func NewAssetManager(logLevel d2util.LogLevel) (*AssetManager, error)
NewAssetManager creates and assigns all necessary dependencies for the AssetManager top-level functions to work correctly
func (*AssetManager) BindTerminalCommands ¶
func (am *AssetManager) BindTerminalCommands(term d2interface.Terminal) error
BindTerminalCommands binds the in-game terminal comands for the asset manager.
func (*AssetManager) FileExists ¶
func (am *AssetManager) FileExists(filePath string) (bool, error)
FileExists checks if a file exists on the underlying file system at the given file path.
func (*AssetManager) LoadAnimation ¶
func (am *AssetManager) LoadAnimation(animationPath, palettePath string) (d2interface.Animation, error)
LoadAnimation loads an Animation by its resource path and its palette path
func (*AssetManager) LoadAnimationWithEffect ¶
func (am *AssetManager) LoadAnimationWithEffect(animationPath, palettePath string, effect d2enum.DrawEffect) (d2interface.Animation, error)
LoadAnimationWithEffect loads an Animation by its resource path and its palette path with a given transparency value
func (*AssetManager) LoadAsset ¶
func (am *AssetManager) LoadAsset(filePath string) (io.ReadSeeker, error)
LoadAsset loads an asset
func (*AssetManager) LoadCOF ¶
func (am *AssetManager) LoadCOF(cofPath string) (*d2cof.COF, error)
LoadCOF loads and returns the given path as a COF
func (*AssetManager) LoadComposite ¶
func (am *AssetManager) LoadComposite(baseType d2enum.ObjectType, token, palettePath string) (*Composite, error)
LoadComposite creates a composite object from a ObjectLookupRecord and palettePath describing it
func (*AssetManager) LoadDCC ¶
func (am *AssetManager) LoadDCC(dccPath string) (*d2dcc.DCC, error)
LoadDCC loads and returns the given path as a DCC
func (*AssetManager) LoadDS1 ¶
func (am *AssetManager) LoadDS1(ds1Path string) (*d2ds1.DS1, error)
LoadDS1 loads and returns the given path as a DS1
func (*AssetManager) LoadDT1 ¶
func (am *AssetManager) LoadDT1(dt1Path string) (*d2dt1.DT1, error)
LoadDT1 loads and returns the given path as a DT1
func (*AssetManager) LoadDataDictionary ¶
func (am *AssetManager) LoadDataDictionary(path string) (*d2txt.DataDictionary, error)
LoadDataDictionary loads a txt data file
func (*AssetManager) LoadFile ¶
func (am *AssetManager) LoadFile(filePath string) ([]byte, error)
LoadFile loads an entire file from a source file path as a []byte
func (*AssetManager) LoadFileStream ¶
func (am *AssetManager) LoadFileStream(filePath string) (io.ReadSeeker, error)
LoadFileStream streams an MPQ file from a source file path
func (*AssetManager) LoadFont ¶
func (am *AssetManager) LoadFont(tablePath, spritePath, palettePath string) (*d2font.Font, error)
LoadFont loads a font the resource files
func (*AssetManager) LoadLanguage ¶
func (am *AssetManager) LoadLanguage(languagePath string) string
LoadLanguage loads language from resource path
func (*AssetManager) LoadPalette ¶
func (am *AssetManager) LoadPalette(palettePath string) (d2interface.Palette, error)
LoadPalette loads a palette from a given palette path
func (*AssetManager) LoadPaletteTransform ¶
func (am *AssetManager) LoadPaletteTransform(path string) (*d2pl2.PL2, error)
LoadPaletteTransform loads a palette transform file
func (*AssetManager) LoadRecords ¶
func (am *AssetManager) LoadRecords(path string) error
LoadRecords will load the records for the given path into the record manager. This is dependant on the record manager having bound a loader for the given path.
func (*AssetManager) LoadStringTable ¶
func (am *AssetManager) LoadStringTable(tablePath string) (d2tbl.TextDictionary, error)
LoadStringTable loads a string table from the given path
func (*AssetManager) SetLogLevel ¶
func (am *AssetManager) SetLogLevel(level d2util.LogLevel)
SetLogLevel sets the log level for the asset manager, record manager, and file loader
func (*AssetManager) TranslateString ¶
func (am *AssetManager) TranslateString(input interface{}) string
TranslateString returns the translation of the given string. The string is retrieved from the loaded string tables. If input value is int (e.g. from d2enum/numeric_labels.go) output string is translation for # + input
func (*AssetManager) UnbindTerminalCommands ¶
func (am *AssetManager) UnbindTerminalCommands(term d2interface.Terminal) error
UnbindTerminalCommands unbinds commands from the terminal
type Composite ¶
type Composite struct { *AssetManager // contains filtered or unexported fields }
Composite is a composite entity animation
func (*Composite) Advance ¶
Advance moves the composite animation forward for a given elapsed time in nanoseconds.
func (*Composite) Equip ¶
func (c *Composite) Equip(equipment *[d2enum.CompositeTypeMax]string) error
Equip changes the current layer configuration
func (*Composite) GetAnimationMode ¶
GetAnimationMode returns the animation mode the Composite should render with.
func (*Composite) GetCurrentFrame ¶
GetCurrentFrame returns the frame index in the current animation mode.
func (*Composite) GetDirection ¶
GetDirection returns the current direction the composite is facing
func (*Composite) GetFrameCount ¶
GetFrameCount returns the number of frames in the current animation mode.
func (*Composite) GetPlayedCount ¶
GetPlayedCount returns the number of times the current animation mode has completed all its distinct frames
func (*Composite) GetWeaponClass ¶
GetWeaponClass returns the currently loaded weapon class
func (*Composite) ObjectAnimationMode ¶
func (c *Composite) ObjectAnimationMode() d2enum.ObjectAnimationMode
ObjectAnimationMode returns the object animation mode
func (*Composite) Render ¶
func (c *Composite) Render(target d2interface.Surface) error
Render performs drawing of the Composite on the rendered d2interface.Surface.
func (*Composite) SetAnimSpeed ¶
SetAnimSpeed sets the speed at which the Composite's animation should advance through its frames
func (*Composite) SetCurrentFrame ¶
SetCurrentFrame sets the current frame index of the animation
func (*Composite) SetDirection ¶
SetDirection sets the direction of the composite and its layers
func (*Composite) SetPlayLoop ¶
SetPlayLoop turns on or off animation looping
func (*Composite) SetSubLoop ¶
SetSubLoop sets a loop to be between the specified frame indices
type DC6Animation ¶
type DC6Animation struct { Animation // contains filtered or unexported fields }
DC6Animation is an animation made from a DC6 file
func (*DC6Animation) Clone ¶
func (a *DC6Animation) Clone() d2interface.Animation
Clone creates a copy of the animation
func (*DC6Animation) SetDirection ¶
func (a *DC6Animation) SetDirection(directionIndex int) error
SetDirection decodes and sets the direction
type DCCAnimation ¶
type DCCAnimation struct { Animation // contains filtered or unexported fields }
DCCAnimation represents an animation decoded from DCC
func (*DCCAnimation) Clone ¶
func (a *DCCAnimation) Clone() d2interface.Animation
Clone creates a copy of the animation
func (*DCCAnimation) SetDirection ¶
func (a *DCCAnimation) SetDirection(directionIndex int) error
SetDirection places the animation in the direction of an animation