NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
lyt_textBox.h
1#ifndef NW4R_LYT_TEXTBOX_H
2#define NW4R_LYT_TEXTBOX_H
3#include <nw4r/types_nw4r.h>
4
5#include <nw4r/lyt/lyt_common.h>
6#include <nw4r/lyt/lyt_pane.h>
7#include <nw4r/lyt/lyt_types.h>
8
9#include <nw4r/ut.h>
10
11namespace nw4r {
12namespace lyt {
13
14// Forward declarations
15struct ResBlockSet;
16
17/******************************************************************************
18 *
19 * TextColor
20 *
21 ******************************************************************************/
22enum TextColor {
23 TEXTCOLOR_TOP,
24 TEXTCOLOR_BOTTOM,
25
26 TEXTCOLOR_MAX
27};
28
29namespace res {
30
31/******************************************************************************
32 *
33 * TXT1 binary layout
34 *
35 ******************************************************************************/
36struct TextBox : Pane {
37 static const ulong SIGNATURE = 'txt1';
38
39 u16 textBufBytes; // at 0x4C
40 u16 textStrBytes; // at 0x4E
41 u16 materialIdx; // at 0x50
42 u16 fontIdx; // at 0x52
43 u8 textPosition; // at 0x54
44 u8 textAlignment; // at 0x55
45 u8 PADDING_0x56[0x58 - 0x56]; // at 0x56
46 ulong textStrOffset; // at 0x58
47 ulong textCols[TEXTCOLOR_MAX]; // at 0x5C
48 Size fontSize; // at 0x64
49 f32 charSpace; // at 0x6C
50 f32 lineSpace; // at 0x70
51};
52
53} // namespace res
54
55/******************************************************************************
56 *
57 * TextBox
58 *
59 ******************************************************************************/
60class TextBox : public Pane {
61public:
62 NW4R_UT_RTTI_DECL(TextBox);
63
64public:
65 TextBox(const res::TextBox* pRes, const ResBlockSet& rBlockSet);
66 virtual ~TextBox(); // at 0x8
67
68 virtual void DrawSelf(const DrawInfo& rInfo); // at 0x18
69
70 virtual ut::Color GetVtxColor(ulong idx) const; // at 0x24
71 virtual void SetVtxColor(ulong idx, ut::Color color); // at 0x28
72
73 virtual u8 GetVtxColorElement(ulong idx) const; // at 0x34
74 virtual void SetVtxColorElement(ulong idx, u8 value); // at 0x38
75
76 virtual void AllocStringBuffer(u16 len); // at 0x64
77 virtual void FreeStringBuffer(); // at 0x68
78 u16 GetStringBufferLength() const;
79
80 virtual u16 SetString(const wchar_t* pStr, u16 pos); // at 0x6C
81 virtual u16 SetString(const wchar_t* pStr, u16 pos, u16 len); // at 0x70
82
83 ut::Rect GetTextDrawRect(const DrawInfo& rInfo) const;
84 ut::Rect GetTextDrawRect(ut::WideTextWriter* pWriter) const;
85
86 const wchar_t* GetString() const {
87 return mTextBuf;
88 }
89 const wchar_t* GetStringBuffer() const {
90 return mTextBuf;
91 }
92
93 const ut::Font* GetFont() const;
94 void SetFont(const ut::Font* pFont);
95
96 ut::Color GetTextColor(ulong idx) const {
97 return mTextColors[idx];
98 }
99 void SetTextColor(ulong idx, ut::Color color) {
100 mTextColors[idx] = color;
101 }
102
103 const Size& GetFontSize() const {
104 return mFontSize;
105 }
106 void SetFontSize(const Size& rFontSize) {
107 mFontSize = rFontSize;
108 }
109
110 f32 GetLineSpace() const {
111 return mLineSpace;
112 }
113 void SetLineSpace(f32 space) {
114 mLineSpace = space;
115 }
116
117 f32 GetCharSpace() const {
118 return mCharSpace;
119 }
120 void SetCharSpace(f32 space) {
121 mCharSpace = space;
122 }
123
124 ut::WideTagProcessor* GetTagProcessor() const {
125 return mpTagProcessor;
126 }
127 void SetTagProcessor(ut::WideTagProcessor* pProcessor) {
128 mpTagProcessor = pProcessor;
129 }
130
131 u8 GetTextPositionH() const {
132 return detail::GetHorizontalPosition(mTextPosition);
133 }
134 void SetTextPositionH(u8 value) {
135 detail::SetHorizontalPosition(&mTextPosition, value);
136 }
137
138 u8 GetTextPositionV() const {
139 return detail::GetVerticalPosition(mTextPosition);
140 }
141 void SetTextPositionV(u8 value) {
142 detail::SetVerticalPosition(&mTextPosition, value);
143 }
144
145 f32 GetTextMagH() const;
146 f32 GetTextMagV() const;
147
148 ulong MakeDrawFlag() const;
149
150protected:
151 wchar_t* mTextBuf; // at 0xD4
152 ut::Color mTextColors[TEXTCOLOR_MAX]; // at 0xD8
153
154 const ut::Font* mpFont; // at 0xE0
155 Size mFontSize; // at 0xE4
156 f32 mLineSpace; // at 0xEC
157 f32 mCharSpace; // at 0xF0
158
159 ut::WideTagProcessor* mpTagProcessor; // at 0xF4
160 u16 mTextBufBytes; // at 0xF8
161 u16 mTextLen; // at 0xFA
162 u8 mTextPosition; // at 0xFC
163
164 struct {
165 u8 bAllocFont : 1;
166 } mBits; // at 0xFD
167
168private:
169 void Init(u16 len);
170};
171
172} // namespace lyt
173} // namespace nw4r
174
175#endif
2D graphics drawing library.