-
Notifications
You must be signed in to change notification settings - Fork 0
/
lyt.go
50 lines (42 loc) · 825 Bytes
/
lyt.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"bytes"
"encoding/binary"
"encoding/xml"
)
// LYT defines the main layout of the BRLYT
type LYT struct {
Centered [1]byte
Padding [3]byte
Width float32
Height float32
}
func (r *Root) ParseLYT(data []byte) {
// Parse LYT section
readable := bytes.NewReader(data)
var lyt LYT
err := binary.Read(readable, binary.BigEndian, &lyt)
if err != nil {
panic(err)
}
r.LYT = LYTNode{
XMLName: xml.Name{},
Centered: uint16(lyt.Centered[0]),
Width: lyt.Width,
Height: lyt.Height,
}
}
func (b *BRLYTWriter) WriteLYT(data Root) {
header := SectionHeader{
Type: SectionTypeLYT,
Size: 20,
}
lyt := LYT{
Centered: [1]byte{byte(data.LYT.Centered)},
Padding: [3]byte{},
Width: data.LYT.Width,
Height: data.LYT.Height,
}
write(b, header)
write(b, lyt)
}