-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxml.go
326 lines (294 loc) · 9.68 KB
/
xml.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
package brlyt
import (
"bytes"
"encoding/xml"
)
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"`
reader *bytes.Reader
count uint16
}
// LYTNode specifies the values that LYT contains
type LYTNode struct {
XMLName xml.Name `xml:"lyt1"`
Centered uint16 `xml:"is_centered"`
Width float32 `xml:"width"`
Height float32 `xml:"height"`
}
// TPLNames represents the structure of the txl1 section.
type TPLNames struct {
TPLName []string `xml:"tpl_name"`
}
type FNLNames struct {
FNLName []string `xml:"font_name"`
}
type MATNode struct {
Entries []MATEntries `xml:"entries"`
}
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 MATBlendMode struct {
Type uint8 `xml:"type"`
Source uint8 `xml:"source"`
Destination uint8 `xml:"destination"`
Operator uint8 `xml:"operator"`
}
type MATAlphaCompareXML struct {
Comp0 uint8 `xml:"comp0"`
Comp1 uint8 `xml:"comp1"`
AlphaOP uint8 `xml:"alphaOP"`
Ref0 uint8 `xml:"ref0"`
Ref1 uint8 `xml:"ref1"`
}
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 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 ChanControlXML struct {
ColorMaterialSource uint8
AlphaMaterialSource uint8
}
type MATTexture struct {
Name string `xml:"name,attr"`
SWrap uint8
TWrap uint8
}
type MATSRT struct {
XTrans float32 `xml:"XTrans"`
YTrans float32 `xml:"YTrans"`
Rotation float32 `xml:"Rotation"`
XScale float32 `xml:"XScale"`
YScale float32 `xml:"YScale"`
}
type MATIndirectOrderEntryXML struct {
TexCoord uint8 `xml:"texCoord"`
TexMap uint8 `xml:"texMap"`
ScaleS uint8 `xml:"scaleS"`
ScaleT uint8 `xml:"scaleT"`
}
type MATCoordGen struct {
Type uint8 `xml:"type"`
Source uint8 `xml:"source"`
MatrixSource uint8 `xml:"matrixSource"`
}
type Color8 struct {
R uint8
G uint8
B uint8
A uint8
}
type Color16 struct {
R int16
G int16
B int16
A int16
}
type Coord3D struct {
X float32 `xml:"x"`
Y float32 `xml:"y"`
Z float32 `xml:"z"`
}
type Coord2D struct {
X float32 `xml:"x"`
Y float32 `xml:"y"`
}
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 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 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 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 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 struct {
MatIndex uint16 `xml:"matIndex"`
Index uint8 `xml:"index"`
}
type XMLWindowMats struct {
Mats []XMLWindowMat `xml:"mats"`
}
type XMLUVSets struct {
Set []XMLUVSet `xml:"set"`
}
type XMLUVSet struct {
CoordTL STCoordinates `xml:"coordTL"`
CoordTR STCoordinates `xml:"coordTR"`
CoordBL STCoordinates `xml:"coordBL"`
CoordBR STCoordinates `xml:"coordBR"`
}
type STCoordinates struct {
S float32 `xml:"s"`
T float32 `xml:"t"`
}
type XMLGRP struct {
Name string `xml:"name,attr"`
Entries []string `xml:"entries"`
Children []Children `xml:"children"`
}