work in progress on dc6 sprite dump tool
This commit is contained in:
parent
2bacae3c01
commit
0d8210e26c
@ -43,7 +43,7 @@ type Sprite struct {
|
||||
Directions []Direction
|
||||
}
|
||||
|
||||
func New(reader io.ReadSeeker) (*Sprite, error) {
|
||||
func NewFromReader(reader io.ReadSeeker) (*Sprite, error) {
|
||||
sprite := new(Sprite)
|
||||
|
||||
var fileHead fileHeader
|
||||
|
67
tools/dc6/dc6.go
Normal file
67
tools/dc6/dc6.go
Normal file
@ -0,0 +1,67 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/FooSoft/lazarus/formats/dat"
|
||||
"github.com/FooSoft/lazarus/formats/dc6"
|
||||
)
|
||||
|
||||
func loadPalette(path string) (*dat.Palette, error) {
|
||||
fp, err := os.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer fp.Close()
|
||||
return dat.NewFromReader(fp)
|
||||
}
|
||||
|
||||
func loadSprite(path string) (*dc6.Sprite, error) {
|
||||
fp, err := os.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer fp.Close()
|
||||
return dc6.NewFromReader(fp)
|
||||
}
|
||||
|
||||
func extractSprite(palettePath, spritePath, targetDir string) error {
|
||||
_, err := loadPalette(palettePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = loadSprite(spritePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
var (
|
||||
targetDir = flag.String("target", ".", "target directory")
|
||||
)
|
||||
|
||||
flag.Usage = func() {
|
||||
fmt.Fprintf(os.Stderr, "Usage: %s [options] palette_file dc6_file\n", path.Base(os.Args[0]))
|
||||
fmt.Fprintf(os.Stderr, "Parameters:\n\n")
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
flag.Parse()
|
||||
|
||||
if flag.NArg() < 2 {
|
||||
flag.Usage()
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
if err := extractSprite(flag.Arg(0), flag.Arg(1), *targetDir); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user