NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
multi.hpp
1#pragma once
2#include <types.h>
3#include <game/bases/d_2d/resource.hpp>
4#include <game/mLib/m_2d.hpp>
5#include <game/mLib/m_vec.hpp>
6
7namespace d2d {
8
9/// @brief Stores clipping settings for a layout.
10/// @unofficial
11struct ScissorMask {
12 ScissorMask() {}
13 ScissorMask(const mVec2_c &pos, const mVec2_c &size) : mPos(pos), mSize(size) {
14 mEnabled = true;
15 }
16 void setPos(const mVec2_c &pos) { mPos = pos; }
17 void setSize(const mVec2_c &size) { mSize = size; }
18 void set(const mVec2_c &pos, const mVec2_c &size) {
19 mPos = pos;
20 mSize = size;
21 }
22 void enable() { mEnabled = true; }
23
24 ScissorMask &operator=(const ScissorMask &other) {
25 mPos = other.mPos;
26 mSize = other.mSize;
27 mEnabled = other.mEnabled;
28 return *this;
29 }
30
31 mVec2_c mPos;
32 mVec2_c mSize;
33 bool mEnabled;
34};
35
36/// @brief A base 2D layout class.
37class Multi_c : public m2d::Base_c {
38public:
39 Multi_c(); ///< Creates a layout.
40 virtual ~Multi_c(); ///< Destroys the layout.
41 virtual void draw(); ///< Draws the layout.
42 virtual void calc(); ///< Applies the view matrix.
43
44 /// @brief Builds the layout from a binary layout file.
45 /// @param name The name of the binary layout file.
46 /// @param resAcc The resource accessor to use. If nullptr, uses the internal accessor.
47 /// @return Whether the layout was built successfully.
48 virtual bool build(const char *name, ResAccMult_c *resAcc);
49
50 void entry(); ///< Registers the layout to be drawn.
51 void calcBefore(); ///< Calculates an animation step before the main calculation.
52 void calcAfter(); ///< Calculates the view rectangle and view matrix after the main calculation.
53 nw4r::lyt::Pane *getRootPane(); ///< Gets the root pane of the layout.
54 nw4r::lyt::Pane *findPaneByName(const char *name); ///< Finds a pane by name.
55 nw4r::lyt::TextBox *findTextBoxByName(const char *name); ///< Finds a text box pane by name.
56 nw4r::lyt::Picture *findPictureByName(const char *name); ///< Finds a picture pane by name.
57 nw4r::lyt::Window *findWindowByName(const char *name); ///< Finds a window pane by name.
58
59protected:
60 m2d::Layout_c mLayout; ///< The layout instance.
61 nw4r::lyt::DrawInfo mDrawInfo; ///< The parameters for drawing the layout.
62
63public:
64 ResAccMult_c *mpResAccessor; ///< The resource accessor for the layout.
65 mVec2_c mPos; ///< The position of the layout.
66
67 ScissorMask mScissorMask; ///< The scissor mask for the layout.
68
69private:
70 u32 mFlags; ///< The flags for the layout.
71 u32 m_98; ///< @unused
72};
73
74} // namespace d2d
virtual ~Multi_c()
Destroys the layout.
Definition d_2d.cpp:119
void calcAfter()
Calculates the view rectangle and view matrix after the main calculation.
Definition d_2d.cpp:143
m2d::Layout_c mLayout
The layout instance.
Definition multi.hpp:60
ScissorMask mScissorMask
The scissor mask for the layout.
Definition multi.hpp:67
virtual void draw()
Draws the layout.
Definition d_2d.cpp:148
void entry()
Registers the layout to be drawn.
Definition d_2d.cpp:121
nw4r::lyt::Picture * findPictureByName(const char *name)
Finds a picture pane by name.
Definition d_2d.cpp:216
virtual void calc()
Applies the view matrix.
Definition d_2d.cpp:125
nw4r::lyt::DrawInfo mDrawInfo
The parameters for drawing the layout.
Definition multi.hpp:61
u32 mFlags
The flags for the layout.
Definition multi.hpp:70
nw4r::lyt::TextBox * findTextBoxByName(const char *name)
Finds a text box pane by name.
Definition d_2d.cpp:207
nw4r::lyt::Pane * getRootPane()
Gets the root pane of the layout.
Definition d_2d.cpp:178
ResAccMult_c * mpResAccessor
The resource accessor for the layout.
Definition multi.hpp:64
void calcBefore()
Calculates an animation step before the main calculation.
Definition d_2d.cpp:135
nw4r::lyt::Pane * findPaneByName(const char *name)
Finds a pane by name.
Definition d_2d.cpp:203
Multi_c()
Creates a layout.
Definition d_2d.cpp:107
virtual bool build(const char *name, ResAccMult_c *resAcc)
Builds the layout from a binary layout file.
Definition d_2d.cpp:182
mVec2_c mPos
The position of the layout.
Definition multi.hpp:65
nw4r::lyt::Window * findWindowByName(const char *name)
Finds a window pane by name.
Definition d_2d.cpp:225
A two-dimensional floating point vector.
Definition m_vec.hpp:16
2D engine namespace. Deals with drawing anything 2D, like the HUD and small scores.
Definition global.hpp:9
Stores clipping settings for a layout.
Definition multi.hpp:11