NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
ut_CharWriter.h
1#ifndef NW4R_UT_CHAR_WRITER_H
2#define NW4R_UT_CHAR_WRITER_H
3#include <nw4r/types_nw4r.h>
4
5#include <nw4r/ut/ut_Color.h>
6
7#include <nw4r/math.h>
8
9#include <revolution/GX.h>
10
11namespace nw4r {
12namespace ut {
13
14// Forward declarations
15class Font;
16struct Glyph;
17
18class CharWriter {
19public:
20 enum GradationMode {
21 GRADMODE_NONE,
22 GRADMODE_H,
23 GRADMODE_V,
24
25 GRADMODE_MAX
26 };
27
28public:
29 CharWriter();
30 ~CharWriter();
31
32 void SetupGX();
33 void EnableLinearFilter(bool atSmall, bool atLarge);
34 f32 Print(u16 ch);
35
36 void SetColorMapping(Color min, Color max) {
37 mColorMapping.min = min;
38 mColorMapping.max = max;
39 }
40
41 void ResetColorMapping() {
42 SetColorMapping(DEFAULT_COLOR_MAPPING_MIN, DEFAULT_COLOR_MAPPING_MAX);
43 }
44
45 void SetTextColor(Color start) {
46 mTextColor.start = start;
47 UpdateVertexColor();
48 }
49
50 void SetTextColor(Color start, Color end) {
51 mTextColor.start = start;
52 mTextColor.end = end;
53 UpdateVertexColor();
54 }
55
56 void SetGradationMode(GradationMode mode) {
57 mTextColor.gradationMode = mode;
58 UpdateVertexColor();
59 }
60
61 f32 GetScaleH() const {
62 return mScale.x;
63 }
64 f32 GetScaleV() const {
65 return mScale.y;
66 }
67
68 void SetScale(f32 x, f32 y) {
69 mScale.x = x;
70 mScale.y = y;
71 }
72
73 f32 GetCursorX() const {
74 return mCursorPos.x;
75 }
76 void SetCursorX(f32 x) {
77 mCursorPos.x = x;
78 }
79
80 f32 GetCursorY() const {
81 return mCursorPos.y;
82 }
83 void SetCursorY(f32 y) {
84 mCursorPos.y = y;
85 }
86
87 void SetCursor(f32 x, f32 y) {
88 mCursorPos.x = x;
89 mCursorPos.y = y;
90 }
91 void SetCursor(f32 x, f32 y, f32 z) {
92 mCursorPos.x = x;
93 mCursorPos.y = y;
94 mCursorPos.z = z;
95 }
96
97 void MoveCursorX(f32 dx) {
98 mCursorPos.x += dx;
99 }
100 void MoveCursorY(f32 dy) {
101 mCursorPos.y += dy;
102 }
103
104 void EnableFixedWidth(bool enable) {
105 mIsWidthFixed = enable;
106 }
107 bool IsWidthFixed() const {
108 return mIsWidthFixed;
109 }
110
111 void SetFixedWidth(f32 width) {
112 mFixedWidth = width;
113 }
114 f32 GetFixedWidth() const {
115 return mFixedWidth;
116 }
117
118 void SetFont(const Font& rFont) {
119 mFont = &rFont;
120 }
121 const Font* GetFont() const {
122 return mFont;
123 }
124
125 void SetFontSize(f32 width, f32 height);
126
127 f32 GetFontWidth() const;
128 f32 GetFontHeight() const;
129 f32 GetFontAscent() const;
130 f32 GetFontDescent() const;
131
132private:
134 Color min; // at 0x0
135 Color max; // at 0x4
136 };
137
138 struct VertexColor {
139 Color lu; // at 0x0
140 Color ru; // at 0x4
141 Color ld; // at 0x8
142 Color rd; // at 0xC
143 };
144
145 struct TextColor {
146 Color start; // at 0x0
147 Color end; // at 0x4
148 GradationMode gradationMode; // at 0x8
149 };
150
152 GXTexFilter atSmall; // at 0x0
153 GXTexFilter atLarge; // at 0x4
154
155 bool operator!=(const TextureFilter& rOther) const {
156 return atSmall != rOther.atSmall || atLarge != rOther.atLarge;
157 }
158 };
159
161 GXTexMapID slot; // at 0x0
162 void* texture; // at 0x4
163 TextureFilter filter; // at 0x8
164
165 bool operator!=(const LoadingTexture& rOther) const {
166 return slot != rOther.slot || texture != rOther.texture ||
167 filter != rOther.filter;
168 }
169
170 void Reset() {
171 slot = GX_TEXMAP_NULL;
172 texture = NULL;
173 }
174 };
175
176 static const ulong DEFAULT_COLOR_MAPPING_MIN = 0x00000000;
177 static const ulong DEFAULT_COLOR_MAPPING_MAX = 0xFFFFFFFF;
178
179private:
180 static void SetupVertexFormat();
181 static void SetupGXDefault();
182 static void SetupGXWithColorMapping(Color min, Color max);
183 static void SetupGXForI();
184 static void SetupGXForRGBA();
185
186 void UpdateVertexColor();
187 void PrintGlyph(f32 x, f32 y, f32 z, const Glyph& rGlyph);
188
189 void LoadTexture(const Glyph& rGlyph, GXTexMapID slot);
190 void ResetTextureCache() {
191 mLoadingTexture.Reset();
192 }
193
194private:
195 ColorMapping mColorMapping; // at 0x0
196 VertexColor mVertexColor; // at 0x8
197 TextColor mTextColor; // at 0x18
198 math::VEC2 mScale; // at 0x24
199 math::VEC3 mCursorPos; // at 0x2C
200 TextureFilter mFilter; // at 0x38
201 u8 PADDING_0x40[0x42 - 0x40]; // at 0x40
202 u8 mAlpha; // at 0x42
203 bool mIsWidthFixed; // at 0x43
204 f32 mFixedWidth; // at 0x44
205 const Font* mFont; // at 0x48
206
207 static LoadingTexture mLoadingTexture;
208};
209
210} // namespace ut
211} // namespace nw4r
212
213#endif
Debugging library which includes various utilities used by the rest of nw4r.
Definition ut_list.cpp:4