wz

package
v0.0.0-...-57a8655 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2015 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package wz contains various utilities to parse Wz data 90% of this package is ported directly from OdinMS, so credits to them

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDouble

func GetDouble(d MapleData) *float64

GetDouble returns a pointer to the data's value as a float64. returns nil if the value is not a valid float64.

func GetDoubleD

func GetDoubleD(d MapleData, defval float64) float64

GetDoubleD returns the data's value as a float64. If the value can't be retrieved, defval will be returned.

func GetFloat

func GetFloat(d MapleData) *float32

GetFloat returns a pointer to the data's value as a float32. returns nil if the value is not a valid float32.

func GetFloatD

func GetFloatD(d MapleData, defval float32) float32

GetFloatD returns the data's value as a float32. If the value can't be retrieved, defval will be returned.

func GetFullDataPath

func GetFullDataPath(d MapleData) string

GetFullDataPath returns the full, absolute path to the data by walking the mapledata backwards to the root node.

func GetImage

func GetImage(d MapleData) *image.Image

GetImage returns a pointer to the data's value as a pointer to image.Image. returns nil if the value is not a valid maple canvas.

func GetImageD

func GetImageD(d MapleData, defval *image.Image) *image.Image

GetImageD returns the data's value as a pointer to image.Image. If the value can't be retrieved, defval will be returned.

func GetInt

func GetInt(d MapleData) *int32

GetInt returns a pointer to the data's value as an int32. returns nil if the value is not a valid int32.

func GetIntConvert

func GetIntConvert(d MapleData) *int32

GetIntConvert returns a pointer to the data's value as an int32. If the data's value is a string, it will convert the string to int32. returns nil if the value is not a valid int32.

func GetIntConvertD

func GetIntConvertD(d MapleData, defval int32) int32

GetIntConvertD returns the data's value as an int32. If the data's value is a string, it will convert the string to int32. If the value can't be retrieved, defval will be returned.

func GetIntD

func GetIntD(d MapleData, defval int32) int32

GetIntD returns the data's value as an int32. If the value can't be retrieved, defval will be returned.

func GetPoint

func GetPoint(d MapleData) *image.Point

GetPoint returns a pointer to the data's value as an image.Point. returns nil if the value is not a valid image.Point.

func GetPointD

func GetPointD(d MapleData, defval image.Point) image.Point

GetPointD returns the data's value as an image.Point. If the value can't be retrieved, defval will be returned.

func GetString

func GetString(d MapleData) *string

GetString returns a pointer to the data's value as a string. returns nil if the value is not a valid string.

func GetStringD

func GetStringD(d MapleData, defval string) string

GetStringD returns the data's value as a string. If the value can't be retrieved, defval will be returned.

Types

type DirectoryEntry

type DirectoryEntry struct {
	*Entry
	// contains filtered or unexported fields
}

A DirectoryEntry holds the information for a wz directory

func EmptyDirectoryEntry

func EmptyDirectoryEntry() *DirectoryEntry

EmptyDirectoryEntry initializes a zeroed wz directory entry object

func NewDirectoryEntry

func NewDirectoryEntry(name string, size, checksum int,
	parent MapleDataEntry) *DirectoryEntry

NewDirectoryEntry initializes a wz directory entry with the given data

func (*DirectoryEntry) AddDirectory

func (e *DirectoryEntry) AddDirectory(dir MapleDataDirectoryEntry)

AddDirectory adds a wz subdirectory to the wz directory

func (*DirectoryEntry) AddFile

func (e *DirectoryEntry) AddFile(file MapleDataFileEntry)

AddFile adds a file to the wz directory

func (*DirectoryEntry) Files

func (e *DirectoryEntry) Files() []MapleDataFileEntry

Files returns a slice of the wz files inside the wz directory

func (*DirectoryEntry) GetEntry

func (e *DirectoryEntry) GetEntry(name string) MapleDataEntry

GetEntry returns the wz entry inside this folder that matches the given name

func (*DirectoryEntry) Subdirectories

func (e *DirectoryEntry) Subdirectories() []MapleDataDirectoryEntry

Subdirectories returns a slice of the wz subdirectories inside the wz directory

type Entry

type Entry struct {
	// contains filtered or unexported fields
}

An Entry is a generic wz entry and holds data common to all types of wz entries

func NewEntry

func NewEntry(ename string, esize, echecksum int, eparent MapleDataEntity,
) *Entry

NewEntry initializes a generic wz entry object NOTE: esize and echecksum are not used in wx xml reading and can be left zeroed

func (*Entry) Checksum

func (e *Entry) Checksum() int

func (*Entry) Name

func (e *Entry) Name() string

func (*Entry) Offset

func (e *Entry) Offset() int

func (*Entry) Parent

func (e *Entry) Parent() MapleDataEntity

func (*Entry) Size

func (e *Entry) Size() int

type FileEntry

type FileEntry struct {
	*Entry
	// contains filtered or unexported fields
}

A FileEntry holds the information for a wz file entry

func NewFileEntry

func NewFileEntry(name string, size, checksum int, parent MapleDataEntity,
) *FileEntry

NewFileEntry initializes a new wz file entry object NOTE: size and checksum are not used in wz xml parsing and can be left zeroed

func (*FileEntry) Offset

func (e *FileEntry) Offset() int

func (*FileEntry) SetOffset

func (e *FileEntry) SetOffset(offset int)

type FileStoredPngMapleCanvas

type FileStoredPngMapleCanvas struct {
	// contains filtered or unexported fields
}

A FileStoredPngMapleCanvas is a wrapper around image.Image that holds info about a png image extracted from a wz file

func NewFileStoredPngMapleCanvas

func NewFileStoredPngMapleCanvas(w, h int, path string,
) *FileStoredPngMapleCanvas

NewFileStoredPngMapleCanvas initializes a new FileStoredPngMapleCanvas object with the given file path and size

func (*FileStoredPngMapleCanvas) Height

func (f *FileStoredPngMapleCanvas) Height() int

func (*FileStoredPngMapleCanvas) Image

func (f *FileStoredPngMapleCanvas) Image() *image.Image

func (*FileStoredPngMapleCanvas) Width

func (f *FileStoredPngMapleCanvas) Width() int

type MapleCanvas

type MapleCanvas interface {
	Height() int
	Width() int
	Image() *image.Image
	// contains filtered or unexported methods
}

A MapleCanvas is a generic interface for png files extracted from wz files

type MapleData

type MapleData interface {
	Name() string
	Parent() MapleDataEntity
	Type() MapleDataType
	Children() []MapleData
	ChildByPath(path string) MapleData
	Get() interface{}
}

A MapleData is a generic interface for a wz file entry with a retrievable value

type MapleDataDirectoryEntry

type MapleDataDirectoryEntry interface {
	Name() string
	Parent() MapleDataEntity
	Size() int
	Checksum() int
	Offset() int
	Subdirectories() []MapleDataDirectoryEntry
	Files() []MapleDataFileEntry
	GetEntry(name string) MapleDataEntry
}

A MapleDataDirectoryEntry is a generic interface for wz directories

type MapleDataEntity

type MapleDataEntity interface {
	Name() string
	Parent() MapleDataEntity
}

A MapleDataEntity is a generic interface for wz entries nodes

type MapleDataEntry

type MapleDataEntry interface {
	Name() string
	Parent() MapleDataEntity
	Size() int
	Checksum() int
	Offset() int
}

A MapleDataEntry is a generic interface for a wz directory's child entry

type MapleDataFileEntry

type MapleDataFileEntry interface {
	Name() string
	Parent() MapleDataEntity
	Size() int
	Checksum() int
	Offset() int
	SetOffset(offset int)
}

A MapleDataFileEntry is a generic interface for wz file entries

type MapleDataProvider

type MapleDataProvider interface {
	Get(path string) (MapleData, error)
	Root() MapleDataDirectoryEntry
}

A MapleDataProvider is a generic interface for an object that parses or provides wz data

func NewMapleDataProvider

func NewMapleDataProvider(path string) (res MapleDataProvider, err error)

NewMapleDataProvider analyzes the given path and provides the appropriate MapleDataProvider for the format if supported. If the format is not supported it will return nil. At the moment, only wz xml files are supported.

type MapleDataType

type MapleDataType int

A MapleDataType is an integer that describes the datatype of a wz entry

const (
	NONE MapleDataType = iota
	IMG_0x00
	SHORT
	INT
	FLOAT
	DOUBLE
	STRING
	EXTENDED
	PROPERTY
	CANVAS
	VECTOR
	CONVEX
	SOUND
	UOL
	UNKNOWN_TYPE
	UNKNOWN_EXTENDED_TYPE
	INVALID
)

Possible values for MapleDataType

type XMLDomMapleData

type XMLDomMapleData struct {
	// contains filtered or unexported fields
}

A XMLDomMapleData is a wrapper around xmlx.Node and holds the data for a parsed wz xml file's node and provides access to all of its children

func NewXMLDomMapleData

func NewXMLDomMapleData(file *os.File, path string) (
	res *XMLDomMapleData, err error)

NewXMLDomMapleData parses the given xml file into a tree and returns the first node

func (*XMLDomMapleData) ChildByPath

func (x *XMLDomMapleData) ChildByPath(path string) MapleData

ChildByPath finds and returns a value by xmlpath relative to the wz xml file

func (*XMLDomMapleData) Children

func (x *XMLDomMapleData) Children() []MapleData

Children returns the children entries of this node

func (*XMLDomMapleData) Get

func (x *XMLDomMapleData) Get() interface{}

Get returns the value of this node as an interface. If the value is invalid or absent, the return value is nil. All the possible types returned by Get are float64, float32, int32, int16, string, image.Point and FileStoredPngMapleCanvas.

func (*XMLDomMapleData) Name

func (x *XMLDomMapleData) Name() string

Name returns the name of the wz xml entry

func (*XMLDomMapleData) Parent

func (x *XMLDomMapleData) Parent() MapleDataEntity

Parent returns the parent node of this wz xml entry

func (*XMLDomMapleData) Type

func (x *XMLDomMapleData) Type() MapleDataType

Type returns the maple data type of this node. See MapleDataType for more information.

type Xml

type Xml struct {
	// contains filtered or unexported fields
}

wz.Xml provides access to the data in a wz xml directory tree

func NewXml

func NewXml(sourcedirpath string) (*Xml, error)

NewXml walks the given root directory and creates a new wx.Xml object that will provide access to the wz xml data

func (*Xml) Get

func (x *Xml) Get(path string) (res MapleData, err error)

Get returns the wz data at the given path

func (*Xml) Root

func (x *Xml) Root() MapleDataDirectoryEntry

Root returns the root directory entry of the xml file

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL