datapack

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package datapack allows users to extend Gophercraft with ease. It describes a simple format for loading data into Gophercraft and compatible clients Planned formats include:

3d objects/textures
Map geometry
Sound files
files for patching the server and client databases

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFileNotFound = fmt.Errorf("datapack: file not found")
)

Functions

func RegisterDriver

func RegisterDriver(key string, value func() Driver)

func Timestamp

func Timestamp() string

Types

type Driver

type Driver interface {
	Init(at string) (Opts, error)
	ReadFile(at string) (File, error)
	WriteFile(at string) (WriteFile, error)
	List() []string
	Close() error
}

Driver describes a mechanism for loading a datapack.

type File

type File io.ReadCloser

type List

type List struct {
	// eg.
	//	{
	//		"DB/xxx.txt"
	//	}
	Files []string
}

type Loader

type Loader struct {
	Volumes []*Pack
}

func Open

func Open(directory string) (*Loader, error)

func (*Loader) Close

func (ld *Loader) Close()

func (*Loader) Exists

func (ld *Loader) Exists(path string) bool

func (*Loader) List

func (ld *Loader) List() []string

func (*Loader) NewTextLoader

func (ld *Loader) NewTextLoader(prefix, name string) (*TextLoader, error)

NewTextLoader returns a TextLoader of all text files in all datapacks matching the supplied parameters

func (*Loader) ReadFile

func (ld *Loader) ReadFile(path string) (io.ReadCloser, error)

type Opts

type Opts uint64
const (
	Read Opts = 1 << iota
	Write
)
const None Opts = 0

type Pack

type Pack struct {
	PackConfig
	Opts
	Driver
}

func Author

func Author(cfg PackConfig) (*Pack, error)

func AuthorDir

func AuthorDir(dir string, cfg PackConfig) (*Pack, error)

func OpenPack

func OpenPack(path string) (*Pack, error)

func (*Pack) Delete

func (p *Pack) Delete() error

func (*Pack) Exists

func (p *Pack) Exists(path string) bool

func (*Pack) FolderExists

func (p *Pack) FolderExists(path string) bool

func (*Pack) FolderList

func (p *Pack) FolderList(path string) []string

func (*Pack) ReadBytes

func (p *Pack) ReadBytes(path string) ([]byte, error)

func (*Pack) WriteBytes

func (p *Pack) WriteBytes(path string, data []byte) error

func (*Pack) ZipToFile

func (p *Pack) ZipToFile(filename string) error

type PackConfig

type PackConfig struct {
	Name           string
	Description    string
	Author         string
	Version        string
	OverrideTables []string
	Depends        []string
	ServerScripts  []string
	ClientScripts  []string
}

type TextLoader

type TextLoader struct {
	Loader  *Loader
	Decoder *text.Decoder
	Paths   []packText
}

func (*TextLoader) Scan

func (tl *TextLoader) Scan(out interface{}) error

type WriteFile

type WriteFile io.WriteCloser

Jump to

Keyboard shortcuts

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