summaryrefslogtreecommitdiff
path: root/src/layoutlib.h
blob: 55a30271032d1e66fffdc3e6cccf45c3ab2156bf (plain)
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
#ifndef __NEWER_LAYOUTLIB_H
#define __NEWER_LAYOUTLIB_H

/* Treeki's LayoutLib for New Super Mario Bros Wii */
#include <common.h>

typedef float MTX[3][4];

struct nw4r__lyt__Layout {
	void *vtable;
	void *field_04;
	void *field_08;
	void *field_0C;
	void *rootPane;
	void *field_14;
	void *field_18;
	void *field_1C;
};

struct nw4r__lyt__DrawInfo {
	// 0x00
	void *vtable;
	MTX matrix;
	
	// 0x34
	float left;
	float top;
	float right;
	
	// 0x40
	float bottom;
	float scale_x;
	float scale_y;
	float opacity;
	
	// 0x50
	unsigned char widescreenFlag;
};

struct FrameCtrl_c {
	
};

struct Anm_c {
	FrameCtrl_c *fc_ptr;
	void *brlanHandler;
	void *field_08;
	char field_0C;
	char pad[3];
	FrameCtrl_c fc;
};

struct Layout {
	void *field_00;
	void *field_04;
	void *vtable;
	unsigned char drawOrder; // 0x0C
	char pad1[3];
	
	// offset 0x10
	nw4r__lyt__Layout layout; // Actually m2d::Layout_c, but the struct is the same
	
	// offset 0x30
	nw4r__lyt__DrawInfo drawInfo;
	
	// offset 0x84
	//LayoutHelper *field_84;
	void *field_84;
	float posX; // 0x88
	float posY; // 0x8C
	float clipX; // 0x90
	float clipY; // 0x94
	float clipWidth; // 0x98
	float clipHeight; // 0x9C
	unsigned char clipEnabled; // 0xA0
	char pad2[3];
	unsigned int animEnabled; // 0xA4
	void *field_A8;
	
	// offset 0xAC
	//LayoutHelper lh; // actually a m2d::ResAccLoader_c
	char lh[0xD4]; // don't feel like figuring this one out -_-
	
	// offset 0x180
	//BrlanHandler *brlanHandlers; // 0x180, points to brlan handlers
	void *brlanHandlers;
	//GrpHandler *grpHandlers; // 0x184
	void *grpHandlers;
	char *field_188; // char array, probably "anim enabled"
	int brlanCount; // 0x18C
	int grpCount; // 0x190
	int field_194; // no idea
};


void EmbeddedLayout_ctor(Layout *self); // 0x800C89A0
void EmbeddedLayout_dtor(Layout *self, bool del); // 0x800C89F0
void EmbeddedLayout_Free(Layout *self); // 0x800C9A20
bool EmbeddedLayout_LoadArcOld(Layout *self, const char *path, bool isLangSpecific); // 0x800C8D00

extern "C" {
bool EmbeddedLayout_LoadArc(Layout *self, const char *path); // custom
bool EmbeddedLayout_FreeArc(Layout *self); // custom
};

void EmbeddedLayout_LoadBrlans(Layout *self, const char **names, int count); // 0x800C90A0
void EmbeddedLayout_LoadGroups(Layout *self, const char **names, int *brlanLinkIDs, int count); // 0x800C91E0

void EmbeddedLayout_AddToDrawList(Layout *self); // 0x80163990

void *EmbeddedLayout_FindPaneByName(Layout *self, const char *name);
void *EmbeddedLayout_FindTextBoxByName(Layout *self, const char *name);
void *EmbeddedLayout_FindPictureByName(Layout *self, const char *name);
void *EmbeddedLayout_FindWindowByName(Layout *self, const char *name);

void EmbeddedLayout_EnableNonLoopAnim(Layout *self, int animNum, bool pointlessShit); // 0x800C93E0
void EmbeddedLayout_EnableLoopAnim(Layout *self, int animNum); // 0x800C9470
void EmbeddedLayout_ResetAnimToInitialState(Layout *self, int animNum, bool isLoop_maybe); // 0x800C94C0
void EmbeddedLayout_DisableAnim(Layout *self, int animNum); // 0x800C9580
void EmbeddedLayout_DisableAllAnims(Layout *self); // 0x800C95F0
void EmbeddedLayout_Process(Layout *self); // 0x800C9650
bool EmbeddedLayout_CheckIfAnimationIsOn(Layout *self, int animNum); // 0x800C9700
bool EmbeddedLayout_CheckIfAnyAnimationsAreOn(Layout *self); // 0x800C9730


typedef bool (*__EmbeddedLayout_Build_type)(Layout*, const char*, void*);
inline bool EmbeddedLayout_Build(Layout *self, const char *brlytName, void *lh) {
	VF_BEGIN(__EmbeddedLayout_Build_type, self, 5, 8)
		return VF_CALL(self, brlytName, lh);
	VF_END;
}

typedef void (*__EmbeddedLayout_UpdateMatrix_type)(Layout*);
inline void EmbeddedLayout_UpdateMatrix(Layout *self) {
	VF_BEGIN(__EmbeddedLayout_UpdateMatrix_type, self, 4, 8)
		VF_CALL(self);
	VF_END;
}

typedef void (*__TextBox_SetString_type)(void*, unsigned short const *, unsigned short);
inline void TextBox_SetString(void *self, unsigned short const *str, unsigned short unk) {
	VF_BEGIN(__TextBox_SetString_type, self, 31, 0)
		VF_CALL(self, str, unk);
	VF_END;
}

#define PANE_FLAGS(pane) (*((u8*)(((u32)(pane))+0xBB)))

#endif