NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_lytbase.hpp
1#pragma once
2#include <game/bases/d_2d.hpp>
3#include <game/bases/d_lyttextBox.hpp>
4#include <game/bases/d_tag_processor.hpp>
5#include <game/mLib/m_2d.hpp>
6#include <nw4r/lyt.h>
7
8/// @brief A 2D layout.
9class LytBase_c : public d2d::Multi_c {
10public:
11 LytBase_c(); ///< Constructs a new layout.
12 virtual ~LytBase_c(); ///< Destroys the layout.
13 virtual bool build(const char *name, d2d::ResAccMult_c *resAcc);
14
15 /// @brief Finds a text box by name.
16 LytTextBox_c *findTextBox(const char *name);
17
18 /// @brief Recursively allocates string buffers for all text boxes in the layout.
19 void allocStringBuffer(nw4r::lyt::Pane *pane);
20
21 /// @brief Reads an .arc file which contains the layout.
22 /// @param name The name of the archive.
23 /// @param allocDirection The allocation direction.
24 /// @param isLocalized Whether the layout is in a localized folder (`/<Region>/<Language>/`).
25 bool ReadResourceEx(const char *name, int allocDirection, bool isLocalized);
26
27 /// @brief Reads an .arc file which contains the layout.
28 /// @param name The name of the archive.
29 /// @param isLocalized Whether the layout is in a localized folder (`/<Region>/<Language>/`).
30 bool ReadResource(const char *name, bool isLocalized);
31
32 /// @brief Reads an .arc file which contains the layout.
33 /// @note Use this function for layouts placed in `/<Region>/Layout/`.
34 /// @param name The name of the archive.
35 /// @param allocDirection The allocation direction.
36 bool ReadResource2(const char *name, int allocDirection);
37
38 /// @brief Reads an .arc file which contains the layout.
39 /// @note Use this function for layouts localized in Dutch (`/EU/NedEU/Layout/`).
40 /// @decompnote{Not in Shield version.}
41 /// @unofficial
42 /// @param name The name of the archive.
43 /// @param allocDirection The allocation direction.
44 bool ReadResource3(const char *name, int allocDirection);
45
46 /// @brief Finds null panes by name and registers them to the list.
47 /// @param paneNames The names of the panes to find.
48 /// @param panes The list to register the panes to.
49 /// @param count The number of panes in paneNames.
50 void NPaneRegister(const char **paneNames, nw4r::lyt::Pane **panes, int count);
51
52 /// @brief Finds windows by name and registers them to the list.
53 /// @param windowPaneNames The names of the windows to find.
54 /// @param panes The list to register the windows to.
55 /// @param count The number of windows in windowPaneNames.
56 void WPaneRegister(const char **windowPaneNames, nw4r::lyt::Window **panes, int count);
57
58 /// @brief Finds picture panes by name and registers them to the list.
59 /// @param picPaneNames The names of the picture panes to find.
60 /// @param panes The list to register the picture panes to.
61 /// @param count The number of picture panes in picPaneNames.
62 void PPaneRegister(const char **picPaneNames, nw4r::lyt::Picture **panes, int count);
63
64 /// @brief Finds text boxes by name and registers them to the list.
65 /// @param textboxNames The names of the text boxes to find.
66 /// @param panes The list to register the text boxes to.
67 /// @param count The number of text boxes in textboxNames.
68 void TPaneRegister(const char **textboxNames, LytTextBox_c **panes, int count);
69
70 /// @brief Finds text boxes by name, sets their messages, and registers them to the list.
71 /// @param textboxNames The names of the text boxes to find.
72 /// @param messageIDs The message IDs of the messages to set for the text boxes.
73 /// @param messageGroup The message group of the messages to set for the text boxes.
74 /// @param count The number of text boxes in textboxNames.
75 void TPaneNameRegister(const char **textboxNames, const int *messageIDs, int messageGroup, int count);
76
77 /// @brief Loads animation resources given by their names.
78 /// @param animeNames The names of the animation resources to load.
79 /// @param count The number of animations in animeNames.
80 void AnimeResRegister(const char **animeNames, int count);
81
82 /// @brief Registers animation groups to the layout.
83 /// @param groupNames The names of the animation groups to register.
84 /// @param animeIdxs The indices of the animations to use for the animation groups.
85 /// @param count The number of animation groups in groupNames.
86 void GroupRegister(const char **groupNames, const int *animeIdxs, int count);
87
88 /// @brief Base setup for starting an animation.
89 /// @param animeIdx The index of the animation to start.
90 void AnimeStartBaseSetup(int animeIdx);
91
92 /// @brief Prepares an animation to be played.
93 /// @param animeIdx The index of the animation to start.
94 /// @param startAtEnd Whether to skip to the end of the animation.
95 void AnimeStartSetup(int animeIdx, bool startAtEnd);
96
97 /// @brief Prepares a looping animation to be played.
98 /// @param animeIdx The index of the animation to start.
99 void LoopAnimeStartSetup(int animeIdx);
100
101 /// @brief Prepares a reverse animation to be played.
102 /// @param animeIdx The index of the animation to start.
103 /// @param startAtEnd Whether to skip to the end of the animation.
104 void ReverseAnimeStartSetup(int animeIdx, bool startAtEnd);
105
106 /// @brief Prepares an animation to be stopped.
107 /// @param animeIdx The index of the animation to be stopped.
108 void AnimeEndSetup(int animeIdx);
109
110 /// @brief Prepares all animations to be stopped.
111 void AllAnimeEndSetup();
112
113 /// @brief Starts playing all enabled animations.
114 void AnimePlay();
115
116 /// @brief Returns whether the specified animation is currently playing.
117 /// @param animeIdx The index of the animation to check.
118 /// @note If animeIdx is negative, returns whether the most recently started animation is playing.
119 bool isAnime(int animeIdx);
120
121 bool isAllAnime(); ///< Returns whether any animation is currently playing.
122
123 void SetScissorMask(const nw4r::lyt::Pane *pane, d2d::ScissorMask &scissorMask); ///< @unofficial
124
125 /// @brief Cleans up all resources used by the layout.
126 bool doDelete();
127
128public:
129 m2d::AnmGroup_c &getAnmGroup(int index) const { return mpAnimGroup[index]; }
130
131private:
132 d2d::ResAccMultLoader_c mResAccessorLoader; ///< The resource loader used to load the layout's resources.
133
134 m2d::AnmResV2_c *mpAnimRes; ///< The animations used by the layout.
135 m2d::AnmGroup_c *mpAnimGroup; ///< The animation groups used by the layout.
136
137 bool *mpEnabledAnims; ///< A list of the enabled animations.
138 int mAnimCount; ///< The number of animations used by the layout.
139 int mAnimGroupCount; ///< The number of animation groups used by the layout.
140
141 int mLastStartedAnimNum; ///< The number of the most recently started animation.
142
143public:
144 static TagProcessor_c s_TagPrc; ///< The tag processor for layouts.
145};
LytTextBox_c * findTextBox(const char *name)
Finds a text box by name.
Definition d_lytbase.cpp:24
bool isAnime(int animeIdx)
Returns whether the specified animation is currently playing.
bool ReadResource3(const char *name, int allocDirection)
Reads an .arc file which contains the layout.
Definition d_lytbase.cpp:83
void AnimeResRegister(const char **animeNames, int count)
Loads animation resources given by their names.
bool ReadResourceEx(const char *name, int allocDirection, bool isLocalized)
Reads an .arc file which contains the layout.
Definition d_lytbase.cpp:46
void NPaneRegister(const char **paneNames, nw4r::lyt::Pane **panes, int count)
Finds null panes by name and registers them to the list.
Definition d_lytbase.cpp:96
bool * mpEnabledAnims
A list of the enabled animations.
void TPaneNameRegister(const char **textboxNames, const int *messageIDs, int messageGroup, int count)
Finds text boxes by name, sets their messages, and registers them to the list.
void GroupRegister(const char **groupNames, const int *animeIdxs, int count)
Registers animation groups to the layout.
void TPaneRegister(const char **textboxNames, LytTextBox_c **panes, int count)
Finds text boxes by name and registers them to the list.
static TagProcessor_c s_TagPrc
The tag processor for layouts.
void AnimePlay()
Starts playing all enabled animations.
bool ReadResource(const char *name, bool isLocalized)
Reads an .arc file which contains the layout.
Definition d_lytbase.cpp:65
int mAnimGroupCount
The number of animation groups used by the layout.
bool isAllAnime()
Returns whether any animation is currently playing.
void LoopAnimeStartSetup(int animeIdx)
Prepares a looping animation to be played.
int mAnimCount
The number of animations used by the layout.
m2d::AnmResV2_c * mpAnimRes
The animations used by the layout.
m2d::AnmGroup_c * mpAnimGroup
The animation groups used by the layout.
void WPaneRegister(const char **windowPaneNames, nw4r::lyt::Window **panes, int count)
Finds windows by name and registers them to the list.
void allocStringBuffer(nw4r::lyt::Pane *pane)
Recursively allocates string buffers for all text boxes in the layout.
Definition d_lytbase.cpp:28
void SetScissorMask(const nw4r::lyt::Pane *pane, d2d::ScissorMask &scissorMask)
void ReverseAnimeStartSetup(int animeIdx, bool startAtEnd)
Prepares a reverse animation to be played.
virtual ~LytBase_c()
Destroys the layout.
Definition d_lytbase.cpp:13
virtual bool build(const char *name, d2d::ResAccMult_c *resAcc)
Builds the layout from a binary layout file.
Definition d_lytbase.cpp:15
LytBase_c()
Constructs a new layout.
Definition d_lytbase.cpp:11
void PPaneRegister(const char **picPaneNames, nw4r::lyt::Picture **panes, int count)
Finds picture panes by name and registers them to the list.
void AllAnimeEndSetup()
Prepares all animations to be stopped.
bool ReadResource2(const char *name, int allocDirection)
Reads an .arc file which contains the layout.
Definition d_lytbase.cpp:69
bool doDelete()
Cleans up all resources used by the layout.
d2d::ResAccMultLoader_c mResAccessorLoader
The resource loader used to load the layout's resources.
void AnimeEndSetup(int animeIdx)
Prepares an animation to be stopped.
void AnimeStartBaseSetup(int animeIdx)
Base setup for starting an animation.
int mLastStartedAnimNum
The number of the most recently started animation.
void AnimeStartSetup(int animeIdx, bool startAtEnd)
Prepares an animation to be played.
A text box class with BMG message support.
A base 2D layout class.
Definition multi.hpp:37
Stores clipping settings for a layout.
Definition multi.hpp:11