brlyt

package module
v0.0.0-...-c08d5ac Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2025 License: MIT Imports: 8 Imported by: 0

README

brlytlib

Conversion tool for .brlyt to XML

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidFileMagic         = errors.New("file is not a BRLYT")
	ErrFileSizeMismatch         = errors.New("file size is mismatched")
	ErrInvalidTXLHeader         = errors.New("txl1 header magic is invalid")
	ErrMisMatchedTXT1StringSize = func(stringSize int, correctSize uint16) error {
		return fmt.Errorf("string Size (%d) does not match the size found (%d)", stringSize, correctSize)
	}
)

Functions

func BitExtract

func BitExtract(num uint32, start int, end int) int

func WriteBRLYT

func WriteBRLYT(data []byte) ([]byte, error)

Types

type BRLYTWriter

type BRLYTWriter struct {
	*bytes.Buffer
}

func (*BRLYTWriter) WriteBND

func (b *BRLYTWriter) WriteBND(pan XMLPane) error

func (*BRLYTWriter) WriteChildren

func (b *BRLYTWriter) WriteChildren(children []Children) error

func (*BRLYTWriter) WriteFNL

func (b *BRLYTWriter) WriteFNL(data Root) error

func (*BRLYTWriter) WriteGRE

func (b *BRLYTWriter) WriteGRE() error

func (*BRLYTWriter) WriteGRP

func (b *BRLYTWriter) WriteGRP(data XMLGRP) error

func (*BRLYTWriter) WriteGRS

func (b *BRLYTWriter) WriteGRS() error

func (*BRLYTWriter) WriteGroupChildren

func (b *BRLYTWriter) WriteGroupChildren(children []Children) error

func (*BRLYTWriter) WriteLYT

func (b *BRLYTWriter) WriteLYT(data Root) error

func (*BRLYTWriter) WriteMAT

func (b *BRLYTWriter) WriteMAT(data Root) error

func (*BRLYTWriter) WritePAE

func (b *BRLYTWriter) WritePAE() error

func (*BRLYTWriter) WritePAS

func (b *BRLYTWriter) WritePAS() error

func (*BRLYTWriter) WritePIC

func (b *BRLYTWriter) WritePIC(pic XMLPIC) error

func (*BRLYTWriter) WritePane

func (b *BRLYTWriter) WritePane(pan XMLPane) error

func (*BRLYTWriter) WriteTXL

func (b *BRLYTWriter) WriteTXL(data Root) error

func (*BRLYTWriter) WriteTXT

func (b *BRLYTWriter) WriteTXT(txt XMLTXT) error

func (*BRLYTWriter) WriteWND

func (b *BRLYTWriter) WriteWND(data XMLWND) error

type ChanControlXML

type ChanControlXML struct {
	ColorMaterialSource uint8
	AlphaMaterialSource uint8
}

type Children

type Children struct {
	Pane *XMLPane `xml:"pan1"`
	GRP  *XMLGRP  `xml:"grp1"`
	PIC  *XMLPIC  `xml:"pic1"`
	TXT  *XMLTXT  `xml:"txt1"`
	WND  *XMLWND  `xml:"wnd1"`
	BND  *XMLPane `xml:"bnd1"`
}

type Color16

type Color16 struct {
	R int16
	G int16
	B int16
	A int16
}

type Color8

type Color8 struct {
	R uint8
	G uint8
	B uint8
	A uint8
}

type Coord2D

type Coord2D struct {
	X float32 `xml:"x"`
	Y float32 `xml:"y"`
}

type Coord3D

type Coord3D struct {
	X float32 `xml:"x"`
	Y float32 `xml:"y"`
	Z float32 `xml:"z"`
}

type FNL

type FNL struct {
	NumOfFonts uint16
	// contains filtered or unexported fields
}

FNL represents the header of the fnl1 section

type FNLNames

type FNLNames struct {
	FNLName []string `xml:"font_name"`
}

type FNLTable

type FNLTable struct {
	// OffSet is relative to the beginning of the fnl1 section
	Offset uint32
	// contains filtered or unexported fields
}

type GRP

type GRP struct {
	Name         [16]byte
	NumOfEntries uint16
	// contains filtered or unexported fields
}
type Header struct {
	Magic        [4]byte
	BOM          uint32
	FileSize     uint32
	HeaderLen    uint16
	SectionCount uint16
}

Header represents the header of our BRLYT

type LYT

type LYT struct {
	Centered [1]byte
	Padding  [3]byte
	Width    float32
	Height   float32
}

LYT defines the main layout of the BRLYT

type LYTNode

type LYTNode struct {
	XMLName  xml.Name `xml:"lyt1"`
	Centered uint16   `xml:"is_centered"`
	Width    float32  `xml:"width"`
	Height   float32  `xml:"height"`
}

LYTNode specifies the values that LYT contains

type MAT

type MAT struct {
	NumOfMats uint16
	// contains filtered or unexported fields
}

type MATAlphaCompareXML

type MATAlphaCompareXML struct {
	Comp0   uint8 `xml:"comp0"`
	Comp1   uint8 `xml:"comp1"`
	AlphaOP uint8 `xml:"alphaOP"`
	Ref0    uint8 `xml:"ref0"`
	Ref1    uint8 `xml:"ref1"`
}

type MATBlendMode

type MATBlendMode struct {
	Type        uint8 `xml:"type"`
	Source      uint8 `xml:"source"`
	Destination uint8 `xml:"destination"`
	Operator    uint8 `xml:"operator"`
}

type MATChanControl

type MATChanControl struct {
	ColorMaterialSource uint8
	AlphaMaterialSource uint8
	// contains filtered or unexported fields
}

type MATColor

type MATColor struct {
	R uint8
	G uint8
	B uint8
	A uint8
}

type MATCoordGen

type MATCoordGen struct {
	Type         uint8 `xml:"type"`
	Source       uint8 `xml:"source"`
	MatrixSource uint8 `xml:"matrixSource"`
}

type MATEntries

type MATEntries struct {
	Name                 string                     `xml:"name,attr"`
	ForeColor            Color16                    `xml:"foreColor"`
	BackColor            Color16                    `xml:"backColor"`
	ColorReg3            Color16                    `xml:"colorReg3"`
	TevColor1            Color8                     `xml:"tevColor1"`
	TevColor2            Color8                     `xml:"tevColor2"`
	TevColor3            Color8                     `xml:"tevColor3"`
	TevColor4            Color8                     `xml:"tevColor4"`
	BitFlag              uint32                     `xml:"bitFlag"`
	Textures             []MATTexture               `xml:"texture"`
	SRT                  []MATSRT                   `xml:"textureSRT"`
	CoordGen             []MATCoordGen              `xml:"coordGen"`
	ChanControl          *ChanControlXML            `xml:"chanControl"`
	MatColor             *Color8                    `xml:"matColor"`
	TevSwapMode          *TevSwapModeTableXML       `xml:"tevSwapMode"`
	IndirectSRT          []MATSRT                   `xml:"indirectSRT"`
	IndirectTextureOrder []MATIndirectOrderEntryXML `xml:"indirectTextureOrder"`
	TevStageEntry        []MATTevStageEntryXML      `xml:"tevStageEntry"`
	AlphaCompare         *MATAlphaCompareXML        `xml:"alphaCompare"`
	BlendMode            *MATBlendMode              `xml:"blendMode"`
}

type MATIndirectOrderEntryXML

type MATIndirectOrderEntryXML struct {
	TexCoord uint8 `xml:"texCoord"`
	TexMap   uint8 `xml:"texMap"`
	ScaleS   uint8 `xml:"scaleS"`
	ScaleT   uint8 `xml:"scaleT"`
}

type MATIndirectTextureOrderEntry

type MATIndirectTextureOrderEntry struct {
	TexCoord uint8
	TexMap   uint8
	ScaleS   uint8
	ScaleT   uint8
}

type MATMaterials

type MATMaterials struct {
	Name      [20]byte
	ForeColor [4]int16
	BackColor [4]int16
	ColorReg3 [4]int16
	TevColor1 [4]uint8
	TevColor2 [4]uint8
	TevColor3 [4]uint8
	TevColor4 [4]uint8
	BitFlag   uint32
}

type MATNode

type MATNode struct {
	Entries []MATEntries `xml:"entries"`
}

type MATOffset

type MATOffset struct {
	Offset uint32
}

type MATSRT

type MATSRT struct {
	XTrans   float32 `xml:"XTrans"`
	YTrans   float32 `xml:"YTrans"`
	Rotation float32 `xml:"Rotation"`
	XScale   float32 `xml:"XScale"`
	YScale   float32 `xml:"YScale"`
}

type MATTevStageEntry

type MATTevStageEntry struct {
	TexCoor uint8
	Color   uint8
	U16     uint16
	B1      uint8
	B2      uint8
	B3      uint8
	B4      uint8
	B5      uint8
	B6      uint8
	B7      uint8
	B8      uint8
	B9      uint8
	B10     uint8
	B11     uint8
	B12     uint8
}

type MATTevStageEntryXML

type MATTevStageEntryXML struct {
	TexCoor          uint8  `xml:"texCoor"`
	Color            uint8  `xml:"color"`
	TexMap           uint16 `xml:"texMap"`
	RasSel           uint8  `xml:"rasSel"`
	TexSel           uint8  `xml:"texSel"`
	ColorA           uint8  `xml:"colorA"`
	ColorB           uint8  `xml:"colorB"`
	ColorC           uint8  `xml:"colorC"`
	ColorD           uint8  `xml:"colorD"`
	ColorOP          uint8  `xml:"colorOP"`
	ColorBias        uint8  `xml:"colorBias"`
	ColorScale       uint8  `xml:"colorScale"`
	ColorClamp       uint8  `xml:"colorClamp"`
	ColorRegID       uint8  `xml:"colorRegID"`
	ColorConstantSel uint8  `xml:"colorConstantSel"`
	AlphaA           uint8  `xml:"alphaA"`
	AlphaB           uint8  `xml:"alphaB"`
	AlphaC           uint8  `xml:"alphaC"`
	AlphaD           uint8  `xml:"alphaD"`
	AlphaOP          uint8  `xml:"alphaOP"`
	AlphaBias        uint8  `xml:"alphaBias"`
	AlphaScale       uint8  `xml:"alphaScale"`
	AlphaClamp       uint8  `xml:"alphaClamp"`
	AlphaRegID       uint8  `xml:"alphaRegID"`
	AlphaConstantSel uint8  `xml:"alphaConstantSel"`
	TexID            uint8  `xml:"texID"`
	Bias             uint8  `xml:"bias"`
	Matrix           uint8  `xml:"matrix"`
	WrapS            uint8  `xml:"wrapS"`
	WrapT            uint8  `xml:"wrapT"`
	Format           uint8  `xml:"format"`
	AddPrevious      uint8  `xml:"addPrevious"`
	UTCLod           uint8  `xml:"utcLod"`
	Alpha            uint8  `xml:"alpha"`
}

type MATTexCoordGenEntry

type MATTexCoordGenEntry struct {
	Type         uint8
	Source       uint8
	MatrixSource uint8
	// contains filtered or unexported fields
}

type MATTexture

type MATTexture struct {
	Name  string `xml:"name,attr"`
	SWrap uint8
	TWrap uint8
}

type MATTextureEntry

type MATTextureEntry struct {
	TexIndex uint16
	SWrap    uint8
	TWrap    uint8
}

type MATTextureSRTEntry

type MATTextureSRTEntry struct {
	XTrans   float32
	YTrans   float32
	Rotation float32
	XScale   float32
	YScale   float32
}

type MatAlphaCompare

type MatAlphaCompare struct {
	Temp    uint8
	AlphaOP uint8
	Ref0    uint8
	Ref1    uint8
}

type PIC

type PIC struct {
	Flag   uint8
	Origin uint8
	Alpha  uint8

	PaneName         [16]byte
	UserData         [8]byte
	XTranslation     float32
	YTranslation     float32
	ZTranslation     float32
	XRotate          float32
	YRotate          float32
	ZRotate          float32
	XScale           float32
	YScale           float32
	Width            float32
	Height           float32
	TopLeftColor     [4]uint8
	TopRightColor    [4]uint8
	BottomLeftColor  [4]uint8
	BottomRightColor [4]uint8
	MatIndex         uint16
	NumOfUVSets      uint8
	// contains filtered or unexported fields
}

PIC defines the image pane in a brlyt

type Pane

type Pane struct {
	Flag   uint8
	Origin uint8
	Alpha  uint8

	PaneName     [16]byte
	UserData     [8]byte
	XTranslation float32
	YTranslation float32
	ZTranslation float32
	XRotate      float32
	YRotate      float32
	ZRotate      float32
	XScale       float32
	YScale       float32
	Width        float32
	Height       float32
	// contains filtered or unexported fields
}

Pane represents the structure of a pan1 section.

type Root

type Root struct {
	XMLName   xml.Name  `xml:"root"`
	LYT       LYTNode   `xml:"lyt1"`
	TXL       *TPLNames `xml:"txl1"`
	FNL       *FNLNames `xml:"fnt1"`
	MAT       MATNode   `xml:"mat1"`
	RootPane  XMLPane   `xml:"pan1"`
	RootGroup XMLGRP    `xml:"grp1"`
	// contains filtered or unexported fields
}

func ParseBRLYT

func ParseBRLYT(contents []byte) (*Root, error)

func (*Root) HasChildren

func (r *Root) HasChildren() bool

func (*Root) ParseBND

func (r *Root) ParseBND(data []byte) (*XMLPane, error)

func (*Root) ParseChildren

func (r *Root) ParseChildren() ([]Children, error)

func (*Root) ParseFNL

func (r *Root) ParseFNL(data []byte, sectionSize uint32) error

func (*Root) ParseGRP

func (r *Root) ParseGRP(data []byte) (*XMLGRP, error)

func (*Root) ParseLYT

func (r *Root) ParseLYT(data []byte) error

func (*Root) ParseMAT

func (r *Root) ParseMAT(data []byte, sectionSize uint32) error

func (*Root) ParsePAN

func (r *Root) ParsePAN(data []byte) (*XMLPane, error)

func (*Root) ParsePIC

func (r *Root) ParsePIC(data []byte) (*XMLPIC, error)

func (*Root) ParseTXL

func (r *Root) ParseTXL(data []byte, sectionSize uint32) error

func (*Root) ParseTXT

func (r *Root) ParseTXT(data []byte, sectionSize uint32) (*XMLTXT, error)

func (*Root) ParseWND

func (r *Root) ParseWND(data []byte) (*XMLWND, error)

type STCoordinates

type STCoordinates struct {
	S float32 `xml:"s"`
	T float32 `xml:"t"`
}

type SectionHeader

type SectionHeader struct {
	Type SectionTypes
	Size uint32
}

type SectionTypes

type SectionTypes [4]byte

SectionTypes are known parts of a BRLYT.

var (
	SectionTypeLYT SectionTypes = [4]byte{'l', 'y', 't', '1'}
	SectionTypeTXL SectionTypes = [4]byte{'t', 'x', 'l', '1'}
	SectionTypeFNL SectionTypes = [4]byte{'f', 'n', 'l', '1'}
	SectionTypeMAT SectionTypes = [4]byte{'m', 'a', 't', '1'}
	SectionTypePAN SectionTypes = [4]byte{'p', 'a', 'n', '1'}
	SectionTypePAS SectionTypes = [4]byte{'p', 'a', 's', '1'}
	SectionTypePAE SectionTypes = [4]byte{'p', 'a', 'e', '1'}
	SectionTypeBND SectionTypes = [4]byte{'b', 'n', 'd', '1'}
	SectionTypePIC SectionTypes = [4]byte{'p', 'i', 'c', '1'}
	SectionTypeTXT SectionTypes = [4]byte{'t', 'x', 't', '1'}
	SectionTypeWND SectionTypes = [4]byte{'w', 'n', 'd', '1'}
	SectionTypeGRP SectionTypes = [4]byte{'g', 'r', 'p', '1'}
	SectionTypeGRS SectionTypes = [4]byte{'g', 'r', 's', '1'}
	SectionTypeGRE SectionTypes = [4]byte{'g', 'r', 'e', '1'}
)

type TPLNames

type TPLNames struct {
	TPLName []string `xml:"tpl_name"`
}

TPLNames represents the structure of the txl1 section.

type TPLOffSet

type TPLOffSet struct {
	// Offset is relative to the beginning of the txl1 section
	Offset  uint32
	Padding uint32
}

type TXL

type TXL struct {
	NumOfTPL uint16
	Unknown  uint16
}

type TXT

type TXT struct {
	Flag   uint8
	Origin uint8
	Alpha  uint8

	PaneName        [16]byte
	UserData        [8]byte
	XTranslation    float32
	YTranslation    float32
	ZTranslation    float32
	XRotate         float32
	YRotate         float32
	ZRotate         float32
	XScale          float32
	YScale          float32
	Width           float32
	Height          float32
	StringLength    uint16
	MaxStringLength uint16
	MatIndex        uint16
	FontIndex       uint16
	StringOrigin    uint8
	LineAlignment   uint8

	TextOffset    uint32
	TopColor      [4]uint8
	BottomColor   [4]uint8
	FontSizeX     float32
	FontSizeY     float32
	CharacterSize float32
	LineSize      float32
	// contains filtered or unexported fields
}

TXT represents the text data of the txt1 section

type TevSwapModeTable

type TevSwapModeTable struct {
	B1 uint8
	B2 uint8
	B3 uint8
	B4 uint8
}

type TevSwapModeTableXML

type TevSwapModeTableXML struct {
	AR uint8
	AG uint8
	AB uint8
	AA uint8
	BR uint8
	BG uint8
	BB uint8
	BA uint8
	CR uint8
	CG uint8
	CB uint8
	CA uint8
	DR uint8
	DG uint8
	DB uint8
	DA uint8
}

type UVSet

type UVSet struct {
	TopLeftS     float32
	TopLeftT     float32
	TopRightS    float32
	TopRightT    float32
	BottomLeftS  float32
	BottomLeftT  float32
	BottomRightS float32
	BottomRightT float32
}

type Window

type Window struct {
	Flag   uint8
	Origin uint8
	Alpha  uint8

	PaneName     [16]byte
	UserData     [8]byte
	XTranslation float32
	YTranslation float32
	ZTranslation float32
	XRotate      float32
	YRotate      float32
	ZRotate      float32
	XScale       float32
	YScale       float32
	Width        float32
	Height       float32
	Coordinate1  float32
	Coordinate2  float32
	Coordinate3  float32
	Coordinate4  float32
	FrameCount   uint8

	WindowOffset      uint32
	WindowFrameOffset uint32
	TopLeftColor      [4]uint8
	TopRightColor     [4]uint8
	BottomLeftColor   [4]uint8
	BottomRightColor  [4]uint8
	MatIndex          uint16
	NumOfUVSets       uint8
	// contains filtered or unexported fields
}

type WindowMat

type WindowMat struct {
	MatIndex uint16
	Index    uint8
	// contains filtered or unexported fields
}

type XMLGRP

type XMLGRP struct {
	Name     string     `xml:"name,attr"`
	Entries  []string   `xml:"entries"`
	Children []Children `xml:"children"`
}

type XMLPIC

type XMLPIC struct {
	Name             string     `xml:"name,attr"`
	UserData         string     `xml:"user_data,attr"`
	Visible          uint8      `xml:"visible"`
	Widescreen       uint8      `xml:"widescreen_affected"`
	Flag             uint8      `xml:"flag"`
	Origin           Coord2D    `xml:"origin"`
	Alpha            uint8      `xml:"alpha"`
	Padding          uint8      `xml:"padding"`
	Translate        Coord3D    `xml:"translate"`
	Rotate           Coord3D    `xml:"rotate"`
	Scale            Coord2D    `xml:"scale"`
	Width            float32    `xml:"width"`
	Height           float32    `xml:"height"`
	TopLeftColor     Color8     `xml:"topLeftColor"`
	TopRightColor    Color8     `xml:"topRightColor"`
	BottomLeftColor  Color8     `xml:"bottomLeftColor"`
	BottomRightColor Color8     `xml:"bottomRightColor"`
	MatIndex         uint16     `xml:"matIndex"`
	UVSets           *XMLUVSets `xml:"uv_sets"`
	Children         []Children `xml:"children"`
}

type XMLPane

type XMLPane struct {
	Name      string     `xml:"name,attr"`
	UserData  string     `xml:"user_data,attr"`
	Flag      uint8      `xml:"flag"`
	Origin    Coord2D    `xml:"origin"`
	Alpha     uint8      `xml:"alpha"`
	Padding   uint8      `xml:"padding"`
	Translate Coord3D    `xml:"translate"`
	Rotate    Coord3D    `xml:"rotate"`
	Scale     Coord2D    `xml:"scale"`
	Width     float32    `xml:"width"`
	Height    float32    `xml:"height"`
	Children  []Children `xml:"children"`
}

type XMLTXT

type XMLTXT struct {
	Name            string     `xml:"name,attr"`
	UserData        string     `xml:"user_data,attr"`
	Visible         uint8      `xml:"visible"`
	Widescreen      uint8      `xml:"widescreen_affected"`
	Flag            uint8      `xml:"flag"`
	Origin          Coord2D    `xml:"origin"`
	Alpha           uint8      `xml:"alpha"`
	Padding         uint8      `xml:"padding"`
	Translate       Coord3D    `xml:"translate"`
	Rotate          Coord3D    `xml:"rotate"`
	Scale           Coord2D    `xml:"scale"`
	Width           float32    `xml:"width"`
	Height          float32    `xml:"height"`
	StringLength    uint16     `xml:"string_length"`
	MaxStringLength uint16     `xml:"max_string_length"`
	MatIndex        uint16     `xml:"matIndex"`
	StringOrigin    uint8      `xml:"string_origin"`
	LineAlignment   uint8      `xml:"line_alignment"`
	XSize           float32    `xml:"x_size"`
	YSize           float32    `xml:"y_size"`
	CharSize        float32    `xml:"charsize"`
	LineSize        float32    `xml:"linesize"`
	TopColor        Color8     `xml:"top_color"`
	BottomColor     Color8     `xml:"bottom_color"`
	Text            string     `xml:"text"`
	Children        []Children `xml:"children"`
}

type XMLUVSet

type XMLUVSet struct {
	CoordTL STCoordinates `xml:"coordTL"`
	CoordTR STCoordinates `xml:"coordTR"`
	CoordBL STCoordinates `xml:"coordBL"`
	CoordBR STCoordinates `xml:"coordBR"`
}

type XMLUVSets

type XMLUVSets struct {
	Set []XMLUVSet `xml:"set"`
}

type XMLWND

type XMLWND struct {
	Name             string         `xml:"name,attr"`
	UserData         string         `xml:"user_data,attr"`
	Visible          uint8          `xml:"visible"`
	Widescreen       uint8          `xml:"widescreen_affected"`
	Flag             uint8          `xml:"flag"`
	Origin           Coord2D        `xml:"origin"`
	Alpha            uint8          `xml:"alpha"`
	Padding          uint8          `xml:"padding"`
	Translate        Coord3D        `xml:"translate"`
	Rotate           Coord3D        `xml:"rotate"`
	Scale            Coord2D        `xml:"scale"`
	Width            float32        `xml:"width"`
	Height           float32        `xml:"height"`
	Coordinate1      float32        `xml:"coordinate_1"`
	Coordinate2      float32        `xml:"coordinate_2"`
	Coordinate3      float32        `xml:"coordinate_3"`
	Coordinate4      float32        `xml:"coordinate_4"`
	TopLeftColor     Color8         `xml:"topLeftColor"`
	TopRightColor    Color8         `xml:"topRightColor"`
	BottomLeftColor  Color8         `xml:"bottomLeftColor"`
	BottomRightColor Color8         `xml:"bottomRightColor"`
	MatIndex         uint16         `xml:"matIndex"`
	UVSets           *XMLUVSets     `xml:"uv_sets"`
	Materials        *XMLWindowMats `xml:"materials"`
	Children         []Children     `xml:"children"`
}

type XMLWindowMat

type XMLWindowMat struct {
	MatIndex uint16 `xml:"matIndex"`
	Index    uint8  `xml:"index"`
}

type XMLWindowMats

type XMLWindowMats struct {
	Mats []XMLWindowMat `xml:"mats"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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