add stub for dcc extractor
This commit is contained in:
parent
579b14d600
commit
a3671ae172
@ -1,8 +1,11 @@
|
||||
package dcc
|
||||
|
||||
import "io"
|
||||
import (
|
||||
"encoding/binary"
|
||||
"io"
|
||||
)
|
||||
|
||||
type DccSprite struct {
|
||||
type Sprite struct {
|
||||
}
|
||||
|
||||
type extents struct {
|
||||
@ -46,6 +49,11 @@ type frameHeader struct {
|
||||
Extents extents
|
||||
}
|
||||
|
||||
func NewFromReader(reader io.ReadSeeker) (*DccSprite, error) {
|
||||
func NewFromReader(reader io.ReadSeeker) (*Sprite, error) {
|
||||
var fileHead fileHeader
|
||||
if err := binary.Read(reader, binary.LittleEndian, &fileHead); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
67
tools/dcc/dcc.go
Normal file
67
tools/dcc/dcc.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/dcc"
|
||||
)
|
||||
|
||||
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) (*dcc.Sprite, error) {
|
||||
fp, err := os.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer fp.Close()
|
||||
return dcc.NewFromReader(fp)
|
||||
}
|
||||
|
||||
func extractSprite(spritePath string, palette *dat.Palette, targetDir string) error {
|
||||
_, err := loadSprite(spritePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
targetDir := flag.String("target", ".", "target directory")
|
||||
flag.Usage = func() {
|
||||
fmt.Fprintf(os.Stderr, "Usage: %s [options] palette_file [dcc_files]\n", path.Base(os.Args[0]))
|
||||
fmt.Fprintf(os.Stderr, "Parameters:\n\n")
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
flag.Parse()
|
||||
|
||||
if flag.NArg() < 1 {
|
||||
flag.Usage()
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
palette, err := loadPalette(flag.Arg(0))
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for i := 1; i < flag.NArg(); i++ {
|
||||
if err := extractSprite(flag.Arg(1), palette, *targetDir); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user