NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
lyt_pane.h
1#ifndef NW4R_LYT_PANE_H
2#define NW4R_LYT_PANE_H
3#include <nw4r/types_nw4r.h>
4
5#include <nw4r/lyt/lyt_animation.h>
6#include <nw4r/lyt/lyt_common.h>
7#include <nw4r/lyt/lyt_resources.h>
8#include <nw4r/lyt/lyt_types.h>
9
10#include <nw4r/math.h>
11#include <nw4r/ut.h>
12
13namespace nw4r {
14namespace lyt {
15
16// Forward declarations
17class DrawInfo;
18class Material;
19
20/******************************************************************************
21 *
22 * AnimOption
23 *
24 ******************************************************************************/
25enum AnimOption {
26 ANIMOPTION_SKIP_INVISIBLE = (1 << 0),
27};
28
29namespace detail {
30
31/******************************************************************************
32 *
33 * PaneBase
34 *
35 ******************************************************************************/
36class PaneBase {
37public:
38 PaneBase();
39 virtual ~PaneBase(); // at 0x8
40
41public:
42 NW4R_UT_LINKLIST_NODE_DECL(); // at 0x4
43};
44
45} // namespace detail
46
47namespace res {
48
49/******************************************************************************
50 *
51 * PAN1 binary layout
52 *
53 ******************************************************************************/
54struct Pane {
55 static const ulong SIGNATURE = 'pan1';
56
57 DataBlockHeader blockHeader; // at 0x0
58 u8 flag; // at 0x8
59 u8 basePosition; // at 0x9
60 u8 alpha; // at 0xA
61 u8 padding; // at 0xB
62 char name[NW4R_LYT_RES_NAME_LEN]; // at 0xC
63 char userData[NW4R_LYT_PANE_USERDATA_LEN]; // at 0x1C
64 math::VEC3 translate; // at 0x24
65 math::VEC3 rotate; // at 0x30
66 math::VEC2 scale; // at 0x3C
67 Size size; // at 0x44
68};
69
70} // namespace res
71
72/******************************************************************************
73 *
74 * Pane
75 *
76 ******************************************************************************/
77class Pane : public detail::PaneBase {
78public:
79 NW4R_UT_RTTI_DECL(Pane);
80
81private:
82 enum {
83 BIT_VISIBLE,
84 BIT_INFLUENCED_ALPHA,
85 BIT_LOCATION_ADJUST,
86 };
87
88 // Need the typedef before the class definition is complete
89 typedef ut::LinkList<Pane, offsetof(PaneBase, node)> PaneList;
90
91public:
92 explicit Pane(const res::Pane* pRes);
93 virtual ~Pane(); // at 0x8
94
95 virtual void CalculateMtx(const DrawInfo& rInfo); // at 0x10
96 void CalculateMtxChild(const DrawInfo& rInfo);
97
98 virtual void Draw(const DrawInfo& rInfo); // at 0x14
99 virtual void DrawSelf(const DrawInfo& rInfo); // at 0x18
100
101 virtual void Animate(ulong option); // at 0x1C
102 virtual void AnimateSelf(ulong option); // at 0x20
103
104 virtual ut::Color GetVtxColor(ulong idx) const; // at 0x24
105 virtual void SetVtxColor(ulong idx, ut::Color color); // at 0x28
106 virtual u8 GetColorElement(ulong idx) const; // at 0x2C
107 virtual void SetColorElement(ulong idx, u8 value); // at 0x30
108 virtual u8 GetVtxColorElement(ulong idx) const; // at 0x34
109 virtual void SetVtxColorElement(ulong idx, u8 value); // at 0x38
110
111 virtual Pane* FindPaneByName(const char* pName, bool recursive); // at 0x3C
112 virtual Material* FindMaterialByName(const char* pName,
113 bool recursive); // at 0x40
114
115 virtual void BindAnimation(AnimTransform* pAnimTrans,
116 bool recursive); // at 0x44
117 virtual void UnbindAnimation(AnimTransform* pAnimTrans,
118 bool recursive); // at 0x48
119
120 virtual void UnbindAllAnimation(bool recursive); // at 0x4C
121 virtual void UnbindAnimationSelf(AnimTransform* pAnimTrans); // at 0x50
122
123 virtual AnimationLink*
124 FindAnimationLinkSelf(AnimTransform* pAnimTrans); // at 0x54
125 virtual AnimationLink*
126 FindAnimationLinkSelf(const AnimResource&); // at 0x58
127
128 virtual void SetAnimationEnable(AnimTransform* pAnimTrans, bool enable,
129 bool recursive); // at 0x5C
130 virtual void SetAnimationEnable(const AnimResource &, bool enable,
131 bool recursive); // at 0x60
132
133 virtual bool GetMaterialNum() const; // at 0x64
134 virtual Material* GetMaterial() const; // at 0x68
135 virtual Material* GetMaterial(ulong) const; // at 0x6C
136 virtual void LoadMtx(const DrawInfo& rInfo); // at 0x70
137
138 void AppendChild(Pane* pChild);
139 void RemoveChild(Pane* pChild);
140
141 ut::Rect GetPaneRect(const DrawInfo& rInfo) const;
142
143 void AddAnimationLink(AnimationLink* pAnimLink);
144
145 math::VEC2 GetVtxPos() const;
146
147 Pane* GetParent() const {
148 return mpParent;
149 }
150
151 PaneList& GetChildList() {
152 return mChildList;
153 }
154
155 void SetSRTElement(ulong idx, f32 value) {
156 reinterpret_cast<f32*>(&mTranslate)[idx] = value;
157 }
158
159 const math::VEC3& GetTranslate() const {
160 return mTranslate;
161 }
162 void SetTranslate(const math::VEC2& rTransXY) {
163 mTranslate.x = rTransXY.x;
164 mTranslate.y = rTransXY.y;
165 }
166 void SetTranslate(const math::VEC3& rTrans) {
167 mTranslate = rTrans;
168 }
169
170 const math::VEC3& GetRotate() const {
171 return mRotate;
172 }
173 void SetRotate(const math::VEC3& rRotate) {
174 mRotate = rRotate;
175 }
176
177 const math::VEC2& GetScale() const {
178 return mScale;
179 }
180 void SetScale(const math::VEC2& rScale) {
181 mScale = rScale;
182 }
183
184 const Size& GetSize() const {
185 return mSize;
186 }
187 void SetSize(const Size& rSize) {
188 mSize = rSize;
189 }
190
191 const math::MTX34& GetMtx() const {
192 return mMtx;
193 }
194 void SetMtx(const math::MTX34& rMtx) {
195 mMtx = rMtx;
196 }
197
198 const math::MTX34& GetGlobalMtx() const {
199 return mGlbMtx;
200 }
201 void SetGlobalMtx(const math::MTX34& rGlbMtx) {
202 mGlbMtx = rGlbMtx;
203 }
204
205 u8 GetAlpha() const {
206 return mAlpha;
207 }
208 void SetAlpha(u8 alpha) {
209 mAlpha = alpha;
210 }
211
212 u8 GetGlbAlpha() const {
213 return mGlbAlpha;
214 }
215 void SetGlbAlpha(u8 alpha) {
216 mGlbAlpha = alpha;
217 }
218
219 u8 GetBasePositionH() const {
220 return detail::GetHorizontalPosition(mBasePosition);
221 }
222 void SetBasePositionH(u8 position) {
223 detail::SetHorizontalPosition(&mBasePosition, position);
224 }
225
226 u8 GetBasePositionV() const {
227 return detail::GetVerticalPosition(mBasePosition);
228 }
229 void SetBasePositionV(u8 position) {
230 detail::SetVerticalPosition(&mBasePosition, position);
231 }
232
233 bool IsVisible() const {
234 return detail::TestBit(mFlag, BIT_VISIBLE);
235 }
236 void SetVisible(bool visible) {
237 detail::SetBit(&mFlag, BIT_VISIBLE, visible);
238 }
239
240 bool IsInfluencedAlpha() const {
241 return detail::TestBit(mFlag, BIT_INFLUENCED_ALPHA);
242 }
243 void SetInfluencedAlpha(bool influenced) {
244 detail::SetBit(&mFlag, BIT_INFLUENCED_ALPHA, influenced);
245 }
246
247 bool IsLocationAdjust() const {
248 return detail::TestBit(mFlag, BIT_LOCATION_ADJUST);
249 }
250 void SetLocationAdjust(bool adjust) {
251 detail::SetBit(&mFlag, BIT_LOCATION_ADJUST, adjust);
252 }
253
254 const char* GetName() const {
255 return mName;
256 }
257 void SetName(const char* pName);
258
259 const char* GetUserData() const {
260 return mUserData;
261 }
262 void SetUserData(const char* pUserData);
263
264 bool IsUserAllocated() const {
265 return mbUserAllocated;
266 }
267
268protected:
269 Pane* mpParent; // at 0xC
270 PaneList mChildList; // at 0x10
271 AnimationLinkList mAnimList; // at 0x1C
272 Material* mpMaterial; // at 0x28
273
274 math::VEC3 mTranslate; // at 0x2C
275 math::VEC3 mRotate; // at 0x38
276 math::VEC2 mScale; // at 0x44
277 Size mSize; // at 0x4C
278
279 math::MTX34 mMtx; // at 0x54
280 math::MTX34 mGlbMtx; // at 0x84
281
282 ulong mExtUserDataNum; // at 0xB4
283
284 u8 mAlpha; // at 0xB8
285 u8 mGlbAlpha; // at 0xB9
286 u8 mBasePosition; // at 0xBA
287 u8 mFlag; // at 0xBB
288
289 char mName[NW4R_LYT_RES_NAME_LEN + 1]; // at 0xBC
290 char mUserData[NW4R_LYT_PANE_USERDATA_LEN + 1]; // at 0xCD
291
292 bool mbUserAllocated; // at 0xD6
293 u8 PADDING_0xD3; // at 0xD7
294
295protected:
296 void InsertChild(PaneList::Iterator next, Pane* pChild);
297
298private:
299 void Init();
300};
301
302NW4R_UT_LINKLIST_TYPEDEF_DECL(Pane);
303
304} // namespace lyt
305} // namespace nw4r
306
307#endif
2D graphics drawing library.