nn::ui2d provides the Binary Cafe Layout file format to define the layout of ui elements.
Standard ui2d header.
There are 23 possible section types:
| Name
|
Magic
|
Description
|
| User Data
|
usd1
|
User Data for the previous section, can contain special SystemData structures that extend functionality
|
| Layout
|
lyt1
|
The headlining section for the Layout
|
| Texture List
|
txl1
|
A list of all textures used in the Layout
|
| Font List
|
fnl1
|
A list of all fonts used in the Layout
|
| Material List
|
mat1
|
All the materials used in the Layout
|
| Capture Texture List
|
ctl1
|
A list of all capture textures used in the Layout
|
| Vector Graphics Texture List
|
vgl1
|
A list of all vector graphics textures used in the Layout
|
| Pane Start
|
pas1
|
The start of a tree of panes, panes become children of last pane
|
| Pane End
|
pae1
|
The end of a tree of panes
|
| Pane
|
pan1
|
A default pane
|
| Picture Pane
|
pic1
|
A pane that can contain images
|
| TextBox Pane
|
txt1
|
A pane that can contain text
|
| Window Pane
|
wnd1
|
A pane that contain a frame and multiple images
|
| Parts Pane
|
prt1
|
A pane that can contain a sub layout
|
| Alignment Pane
|
ali1
|
A pane that aligns it's children
|
| Capture Pane
|
cpt1
|
A pane that captures it's children
|
| Bounding Pane
|
bnd1
|
A pane that can be used in hit detection
|
| Scissor Pane
|
scr1
|
A pane that scissors it's children
|
| Group Start
|
grs1
|
The start of a group
|
| Group End
|
gre1
|
The end of a group
|
| Group
|
grp1
|
A group
|
| Control Source
|
cnt1
|
The control source class and related for the layout
|
| State Machine
|
stm1
|
A state machine
|
Layout (lyt1)
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x8
|
Ui2d Section Header
|
Magic: "lyt1"
|
| 0x8
|
0x1
|
u8
|
Is Centered
|
| 0x9
|
0x3
|
u24
|
Unknown/Reserved
|
| 0xc
|
0x4
|
float
|
Width
|
| 0x10
|
0x4
|
float
|
Height
|
| 0x14
|
0x4
|
float
|
PartsWidth
|
| 0x18
|
0x4
|
float
|
PartsHeight
|
| 0x1c
|
variable
|
char[]
|
Name
|
Layout SystemData
| Name
|
EnumValue
|
Description
|
| AnimTagName
|
0x0
|
Animation names?
|
AnimTagName
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x4
|
u32
|
String Count
|
| 0x4
|
0x4 * String Count
|
u32
|
Anim Name String Offset Array
|
Texture List (txl1)
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x8
|
Ui2d Section Header
|
Magic: "txl1"
|
| 0x8
|
0x2
|
u16
|
Texture Count
|
| 0xa
|
0x2
|
u16
|
Unknown/Reserved
|
| 0x4
|
0x4 * Texture Count
|
u32
|
Texture Name Offset Array
|
Font List (fnt1)
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x8
|
Ui2d Section Header
|
Magic: "fnt1"
|
| 0x8
|
0x2
|
u16
|
Font Count
|
| 0xa
|
0x2
|
u16
|
Unknown/Reserved
|
| 0x4
|
0x4 * Font Count
|
u32
|
Font Name Offset Array
|
Material List (mat1)
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x8
|
Ui2d Section Header
|
Magic: "mat1"
|
| 0x8
|
0x2
|
u16
|
Material Count
|
| 0xa
|
0x2
|
u16
|
Unknown/Reserved
|
| 0x4
|
0x4 * Material Count
|
u32
|
Material Data Offset Array
|
Material Memory
The layout of material memory is defined by this bitfield.
| Bitfield Size
|
Description
|
| 0x2
|
Texture Map Count
|
| 0x2
|
Texture SRT (Scale Rotation Translation) Count
|
| 0x2
|
Texture Coordinate Gen Count
|
| 0x3
|
Tev (Texture Environment) Combiner Count
|
| 0x1
|
Alpha Compare Count
|
| 0x1
|
Color Blend Mode Count
|
| 0x1
|
Unknown/Reserved
|
| 0x1
|
Color And Alpha Blend Mode Count
|
| 0x1
|
Unknown/Reserved
|
| 0x1
|
Rotate Vector Count
|
| 0x2
|
Projection Texture Gen Count
|
| 0x1
|
Font Color 2 Count
|
| 0x1
|
Unknown/Reserved
|
| 0x1
|
Detailed Combiner Count
|
| 0x1
|
User Combiner Count
|
| 0x1
|
Texture Extensions Count
|
| 0x2
|
Vector Texture Info Count
|
| 0x2
|
Brick Repeat Shader Info Count
|
| 0x6
|
Unknown/Reserved
|
The order of appearance of Material Data structures are as follows:
| Structure
|
| Material Data
|
| Texture Map
|
| Texture Extensions
|
| Texture SRT
|
| Texture Coordinate Gen
|
| Tev Combiner
|
| Alpha Compare
|
| Blend Mode
|
| Rotate Vector
|
| Projection Texture Gen
|
| Font Color 2
|
| DetailedCombiner
|
| User Combiner
|
| Vector Texture Info
|
| Brick Repeat Shader Info
|
Material Color Type
| Name
|
EnumValue
|
Description
|
| Color4u8
|
0x0
|
Material Color data offsets point to a Color4u8
|
| Color4f
|
0x1
|
Material Color data offsets point to a Color4f
|
Material Color Data
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x1
|
u8
|
Color Type
|
| 0x1
|
0x1
|
u8
|
Color Count
|
| 0x2
|
0x1 * Color Count
|
u8
|
Color Offsets
|
|
|
(Color4u8) 0x4 * Color Count
(Color4f) 0xc * Color Count
|
Color4u8
Color4f
|
Color Array
|
Material Data
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x1c
|
char[0x1c]
|
Material name
|
| 0x1c
|
0x4
|
Material Memory
|
Material memory bitfield
|
| 0x20
|
variable
|
MaterialColorData
|
Material color data
|
Texture Map
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x2
|
u16
|
Texture Index
|
| 0x2
|
0x1
|
Texture UV Options
|
U Options
|
| 0x3
|
0x1
|
Texture UV Options
|
V Options
|
Texture UV Options
| Bitfield Size
|
Description
|
| 0x2
|
Wrap Mode
|
| 0x2
|
Filter
|
| 0x4
|
Unknown/Reserved
|
Texture Extensions
| Bitfield Size
|
Description
|
| 0x1
|
Is Capture Texture
|
| 0x1
|
Is Vector Graphics Texture
|
| 0x1e
|
Unknown/Reserved
|
Texture SRT
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x8
|
Vector2f
|
Translation
|
| 0x8
|
0x4
|
float
|
Rotation
|
| 0xc
|
0x8
|
Vector2f
|
Scale
|
Texture Coordinate Gen (TODO)
Tev Combiner (TODO)
Alpha Compare
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x1
|
u8
|
Alpha Test Function
|
| 0x1
|
0x3
|
u24
|
Unknown/Reserved
|
| 0x4
|
0x1
|
float
|
Alpha Compare Reference
|
Alpha Test Function
| Name
|
Enum Value
|
Description
|
| Never
|
0x0
|
|
| LessThan
|
0x1
|
|
| LessThanEqual
|
0x2
|
|
| Equal
|
0x3
|
|
| NotEqual
|
0x4
|
|
| GreaterEqual
|
0x5
|
|
| Greater
|
0x6
|
|
| Always
|
0x7
|
|
Blend Mode
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x1
|
u8
|
Blend Equation
|
| 0x1
|
0x1
|
u8
|
Blend Function Source
|
| 0x2
|
0x1
|
u8
|
Blend Function Destination
|
| 0x3
|
0x1
|
u8
|
Logic Operation
|
Blend Equation
| Name
|
Enum Value
|
Description
|
| Invalid
|
0x0
|
|
| Add
|
0x1
|
|
| Sub
|
0x2
|
|
| ReverseSub
|
0x3
|
|
| Min
|
0x4
|
|
| Max
|
0x5
|
|
Blend Function
| Name
|
Enum Value
|
Description
|
| Zero
|
0x0
|
|
| One
|
0x1
|
|
| Destination Color
|
0x2
|
|
| Destination Color Minus One
|
0x3
|
|
| Source Alpha
|
0x4
|
|
| Source Alpha Minus One
|
0x5
|
|
| Destination Alpha
|
0x6
|
|
| Destination Alpha Minus One
|
0x7
|
|
| Source Color
|
0x8
|
|
| Source Color Minus One
|
0x9
|
|
Logic Operation
| Name
|
Enum Value
|
Description
|
| Invalid
|
0x0
|
|
| NoOp
|
0x1
|
|
| Clear
|
0x2
|
|
| Set
|
0x3
|
|
| Copy
|
0x4
|
|
| CopyInverted
|
0x5
|
|
| Invert
|
0x6
|
|
| And
|
0x7
|
|
| Nand
|
0x8
|
|
| Or
|
0x9
|
|
| Nor
|
0xa
|
|
| Xor
|
0xb
|
|
| Equivalent
|
0xc
|
|
| AndReverse
|
0xd
|
|
| AndInverted
|
0xe
|
|
| OrReverse
|
0xf
|
|
| OrInverted
|
0x10
|
|
Rotate Vector (TODO)
Projection Texture Gen (TODO)
Font Color 2 (TODO)
Detailed Combiner (TODO)
User Combiner (TODO)
Vector Texture Info (TODO)
Brick Repeat Shader Info (TODO)
Capture Texture List (TODO)
Vector Graphics Texture List (TODO)
Pane Start
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x8
|
Ui2d Section Header
|
Magic: "pas1"
|
Pane End
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x8
|
Ui2d Section Header
|
Magic: "pae1"
|
Pane (pan1)
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x8
|
Ui2d Section Header
|
Magic: "pan1"
|
| 0x8
|
0x1
|
u8
|
Pane Flags
|
| 0x9
|
0x1
|
u8
|
Origin Bitfield
|
| 0xa
|
0x1
|
u8
|
Alpha
|
| 0xb
|
0x1
|
u8
|
FlagEx
|
| 0xc
|
0x18
|
char[0x18]
|
Pane name
|
| 0x24
|
0x8
|
char[0x8]
|
User name
|
| 0x2c
|
0xc
|
Vector3f
|
Translation
|
| 0x28
|
0xc
|
Vector3f
|
Rotation
|
| 0x44
|
0x8
|
Vector2f
|
Scale
|
| 0x4c
|
0x8
|
Vector2f
|
Size
|
Pane System Data
0x10 onwards is runtime appended user data.
Note; 0-2 use unofficial names
| Name
|
Enum Value
|
Description
|
| QuadScale0
|
0
|
|
| QuadScale1
|
1
|
|
| AlignmentOptions
|
2
|
|
| MaskTexture
|
3
|
|
| DropShadow
|
4
|
|
| ProceduralShape
|
6
|
|
| PaneEffect
|
0x11
|
|
| ProceduralShapeRuntime
|
0x12
|
|
| StateMachine
|
0x13
|
|
| Reserve0
|
0x14
|
|
| Root
|
0x15
|
|
Picture Pane (pic1)
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x54
|
Pane
|
Magic: "pic1"
|
| 0x54
|
0x4
|
Color4u8
|
Vertex Color Top Left
|
| 0x58
|
0x4
|
Color4u8
|
Vertex Color Top Right
|
| 0x5c
|
0x4
|
Color4u8
|
Vertex Color Bottom Left
|
| 0x60
|
0x4
|
Color4u8
|
Vertex Color Bottom Right
|
| 0x64
|
0x2
|
u16
|
Material Index
|
| 0x66
|
0x1
|
u8
|
Texture Count
|
| 0x67
|
0x1
|
u8
|
Is Shape
|
| 0x68
|
0x20
|
Texture UV
|
Texture UV Array
|
Texture UV
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x8
|
Vector2f
|
Top Left
|
| 0x8
|
0x8
|
Vector2f
|
Top Right
|
| 0x10
|
0x8
|
Vector2f
|
Bottom Left
|
| 0x18
|
0x8
|
Vector2f
|
Bottom Right
|
TextBox Pane (txt1)
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x54
|
Pane
|
Magic: "pic1"
|
| 0x54
|
0x2
|
u16
|
Text Buffer Size
|
| 0x56
|
0x2
|
u16
|
Text Length
|
| 0x58
|
0x2
|
u16
|
Material Index
|
| 0x5a
|
0x2
|
u16
|
Font Index
|
| 0x5c
|
0x1
|
u8
|
Text Origin
|
| 0x5d
|
0x1
|
u8
|
Line Alignment
|
| 0x5e
|
0x2
|
u16
|
Flags
|
| 0x60
|
0x4
|
float
|
Italic Tilt
|
| 0x64
|
0x4
|
u32
|
Text Offset
|
| 0x68
|
0x4
|
Color4u8
|
Font Top Color
|
| 0x6c
|
0x4
|
Color4u8
|
Font Bottom Color
|
| 0x70
|
0x8
|
Vector2f
|
Font Size
|
| 0x78
|
0x4
|
float
|
Character Space
|
| 0x7c
|
0x4
|
float
|
Line Space
|
| 0x80
|
0x4
|
u32
|
Label Offset
|
| 0x84
|
0x8
|
Vector2f
|
Shadow Translation
|
| 0x8c
|
0x8
|
Vector2f
|
Shadow Size
|
| 0x94
|
0x4
|
Color4u8
|
Shadow Top Color
|
| 0x98
|
0x4
|
Color4u8
|
Shadow Bottom Color
|
| 0x9c
|
0x4
|
float
|
Shadow Italic Tilt
|
| 0xa0
|
0x4
|
u32
|
Line Transform Offset
|
| 0xa4
|
0x4
|
u32
|
Per Character Transform Offset
|
Line Transform (TODO)
Per Character Transform (TODO)
Window Pane (TODO)
Parts Pane
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x54
|
Pane
|
Magic: "prt1"
|
| 0x54
|
0x4
|
u32
|
Property Count
|
| 0x58
|
0x8
|
Vector2f
|
Magnification
|
| 0x60
|
0x28 * Property Count
|
Parts Property
|
Property Array
|
Parts Property
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x18
|
char[0x18]
|
Property Name
|
| 0x18
|
0x1
|
u8
|
Usage Flag
|
| 0x19
|
0x1
|
u8
|
Basic Usage Flag
|
| 0x1a
|
0x1
|
u8
|
Material Usage Flag
|
| 0x1b
|
0x1
|
u8
|
Reserved
|
| 0x1c
|
0x4
|
u32
|
Pane Offset
|
| 0x20
|
0x4
|
u32
|
User Data Offset
|
| 0x24
|
0x4
|
u32
|
Pane Basic Info Offset
|
Parts Pane Basic Info
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x8
|
char[0x8]
|
User Name
|
| 0x8
|
0xc
|
Vector3f
|
Position
|
| 0x14
|
0xc
|
Vector3f
|
Rotation
|
| 0x20
|
0x8
|
Vector2f
|
Scale
|
| 0x28
|
0x8
|
Vector2f
|
Size
|
| 0x30
|
0x1
|
u8
|
Pane Alpha
|
Alignment Pane
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x54
|
Pane
|
Magic: "ali1"
|
Capture Pane
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x54
|
Pane
|
Magic: "cpt1"
|
Bounding Pane
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x54
|
Pane
|
Magic: "bnd1"
|
Scissor Pane
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x54
|
Pane
|
Magic: "scr1"
|
Group Start
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x8
|
Ui2d Section Header
|
Magic: "grs1"
|
Group End
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x8
|
Ui2d Section Header
|
Magic: "gre1"
|
Group
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x8
|
Ui2d Section Header
|
Magic: "grp1"
|
| 0x8
|
0x21
|
char[0x21]
|
Group Name
|
| 0x29
|
0x1
|
u8
|
Reserved
|
| 0x2a
|
0x2
|
u16
|
Pane Count
|
| 0x2c
|
0x18 * Pane Count
|
char[ChildCount][0x18]
|
Pane Name Array
|
Control Source
| Offset
|
Size
|
Type
|
Description
|
| 0x0
|
0x8
|
Ui2d Section Header
|
Magic: "cnt1"
|
| 0x8
|
0x4
|
u32
|
Name Offset
|
| 0xc
|
0x4
|
u32
|
Name Array Offset
|
| 0x10
|
0x2
|
u16
|
Pane Count
|
| 0x12
|
0x2
|
u16
|
Anim Count
|
| 0x14
|
0x4
|
u32
|
Pane Name Offset Array Offset
|
| 0x18
|
0x4
|
u32
|
Anim Name Offset Array Offset
|
| 0x1c
|
|
char[]
|
Control Name
|