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 u16 GetExtUserDataNum() const;
148 const res::ExtUserData *GetExtUserData() const;
149 const res::ExtUserData *FindExtUserDataByName(const char *name);
150
151 Pane* GetParent() const {
152 return mpParent;
153 }
154
155 PaneList& GetChildList() {
156 return mChildList;
157 }
158
159 void SetSRTElement(ulong idx, f32 value) {
160 reinterpret_cast<f32*>(&mTranslate)[idx] = value;
161 }
162
163 const math::VEC3& GetTranslate() const {
164 return mTranslate;
165 }
166 void SetTranslate(const math::VEC2& rTransXY) {
167 mTranslate.x = rTransXY.x;
168 mTranslate.y = rTransXY.y;
169 }
170 void SetTranslate(const math::VEC3& rTrans) {
171 mTranslate = rTrans;
172 }
173
174 const math::VEC3& GetRotate() const {
175 return mRotate;
176 }
177 void SetRotate(const math::VEC3& rRotate) {
178 mRotate = rRotate;
179 }
180
181 const math::VEC2& GetScale() const {
182 return mScale;
183 }
184 void SetScale(const math::VEC2& rScale) {
185 mScale = rScale;
186 }
187
188 const Size& GetSize() const {
189 return mSize;
190 }
191 void SetSize(const Size& rSize) {
192 mSize = rSize;
193 }
194
195 const math::MTX34& GetMtx() const {
196 return mMtx;
197 }
198 void SetMtx(const math::MTX34& rMtx) {
199 mMtx = rMtx;
200 }
201
202 const math::MTX34& GetGlobalMtx() const {
203 return mGlbMtx;
204 }
205 void SetGlobalMtx(const math::MTX34& rGlbMtx) {
206 mGlbMtx = rGlbMtx;
207 }
208
209 u8 GetAlpha() const {
210 return mAlpha;
211 }
212 void SetAlpha(u8 alpha) {
213 mAlpha = alpha;
214 }
215
216 u8 GetGlbAlpha() const {
217 return mGlbAlpha;
218 }
219 void SetGlbAlpha(u8 alpha) {
220 mGlbAlpha = alpha;
221 }
222
223 u8 GetBasePositionH() const {
224 return detail::GetHorizontalPosition(mBasePosition);
225 }
226 void SetBasePositionH(u8 position) {
227 detail::SetHorizontalPosition(&mBasePosition, position);
228 }
229
230 u8 GetBasePositionV() const {
231 return detail::GetVerticalPosition(mBasePosition);
232 }
233 void SetBasePositionV(u8 position) {
234 detail::SetVerticalPosition(&mBasePosition, position);
235 }
236
237 bool IsVisible() const {
238 return detail::TestBit(mFlag, BIT_VISIBLE);
239 }
240 void SetVisible(bool visible) {
241 detail::SetBit(&mFlag, BIT_VISIBLE, visible);
242 }
243
244 bool IsInfluencedAlpha() const {
245 return detail::TestBit(mFlag, BIT_INFLUENCED_ALPHA);
246 }
247 void SetInfluencedAlpha(bool influenced) {
248 detail::SetBit(&mFlag, BIT_INFLUENCED_ALPHA, influenced);
249 }
250
251 bool IsLocationAdjust() const {
252 return detail::TestBit(mFlag, BIT_LOCATION_ADJUST);
253 }
254 void SetLocationAdjust(bool adjust) {
255 detail::SetBit(&mFlag, BIT_LOCATION_ADJUST, adjust);
256 }
257
258 const char* GetName() const {
259 return mName;
260 }
261 void SetName(const char* pName);
262
263 const char* GetUserData() const {
264 return mUserData;
265 }
266 void SetUserData(const char* pUserData);
267
268 bool IsUserAllocated() const {
269 return mbUserAllocated;
270 }
271
272protected:
273 Pane* mpParent; // at 0xC
274 PaneList mChildList; // at 0x10
275 AnimationLinkList mAnimList; // at 0x1C
276 Material* mpMaterial; // at 0x28
277
278 math::VEC3 mTranslate; // at 0x2C
279 math::VEC3 mRotate; // at 0x38
280 math::VEC2 mScale; // at 0x44
281 Size mSize; // at 0x4C
282
283 math::MTX34 mMtx; // at 0x54
284 math::MTX34 mGlbMtx; // at 0x84
285
286 ulong mExtUserDataNum; // at 0xB4
287
288 u8 mAlpha; // at 0xB8
289 u8 mGlbAlpha; // at 0xB9
290 u8 mBasePosition; // at 0xBA
291 u8 mFlag; // at 0xBB
292
293 char mName[NW4R_LYT_RES_NAME_LEN + 1]; // at 0xBC
294 char mUserData[NW4R_LYT_PANE_USERDATA_LEN + 1]; // at 0xCD
295
296 bool mbUserAllocated; // at 0xD6
297 u8 PADDING_0xD3; // at 0xD7
298
299protected:
300 void InsertChild(PaneList::Iterator next, Pane* pChild);
301
302private:
303 void Init();
304};
305
306NW4R_UT_LINKLIST_TYPEDEF_DECL(Pane);
307
308} // namespace lyt
309} // namespace nw4r
310
311#endif
2D graphics drawing library.