NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
animation.hpp
1#pragma once
2#include <types.h>
3#include <game/mLib/m_2d/frame_ctrl.hpp>
4#include <game/mLib/m_2d/layout.hpp>
5#include <game/mLib/m_2d/resource.hpp>
6#include <nw4r/lyt.h>
7#include <nw4r/ut.h>
8
9namespace m2d {
10
11/// @unofficial
13 nw4r::lyt::Group *mpGroup;
14 nw4r::lyt::AnimTransform *mpAnimTransform;
15};
16
17class AnmResV2_c {
18public:
19 AnmResV2_c() : mGroupAnim(nullptr), mGroupNum(0) {}
20 virtual ~AnmResV2_c() {}
21
22 bool create(const char *name, m2d::ResAccIf_c *resAcc, m2d::Layout_c *layout, bool useOverride);
23 bool remove();
24 GroupAnimTransform_s *getGroupAnimTransform(const char *name);
25 void setAnmEnable(nw4r::lyt::Group *group, bool enable);
26 void updateFrame(nw4r::lyt::Group *group, float frame);
27 nw4r::lyt::AnimationLink *findAnmLink(nw4r::lyt::Pane *pane, bool recursive);
28 void setAnmFrame(nw4r::lyt::Pane *pane, float frame);
29
30 nw4r::lyt::AnimResource mAnimResource;
31 GroupAnimTransform_s *mGroupAnim;
32 int mGroupNum;
33};
34
35class AnmGroupBase_c {
36public:
37 enum FLAG_e {
38 FLAG_ENABLED = BIT_FLAG(0),
39 };
40
41 AnmGroupBase_c() {}
42 AnmGroupBase_c(FrameCtrl_c *fc) : mpFrameCtrl(fc), mpAnmRes(nullptr), mpGroupAnim(nullptr), mFlags(0) {}
43
44 bool create(AnmResV2_c *anmRes, const char *groupName);
45 void setAnmEnable(bool enable);
46 void updateFrame();
47
48 FrameCtrl_c *mpFrameCtrl;
49 AnmResV2_c *mpAnmRes;
50 GroupAnimTransform_s *mpGroupAnim;
51 u8 mFlags;
52};
53
54class AnmGroup_c : public AnmGroupBase_c {
55public:
56 AnmGroup_c() : AnmGroupBase_c(&mFrameCtrl) {
57 mFrameCtrl.mEndFrame = 0.0f;
58 mFrameCtrl.mCurrFrame = 0.0f;
59 mFrameCtrl.mPrevFrame = 0.0f;
60 mFrameCtrl.mRate = 1.0f;
61 }
62
63 void play() { mpFrameCtrl->play(); updateFrame(); }
64 void setStart() { mpFrameCtrl->setFrame(1.0f); updateFrame(); }
65 void setLast() { mpFrameCtrl->setFrame(mpFrameCtrl->getLastActiveFrame()); updateFrame(); }
66 void setEnd() { mpFrameCtrl->setFrame(mpFrameCtrl->getLastFrame()); updateFrame(); }
67 void setAndUpdate(float frame) { mpFrameCtrl->setFrame(frame); updateFrame(); }
68
69 FrameCtrl_c mFrameCtrl;
70};
71
72} // namespace m2d