MCPcopy Create free account
hub / github.com/doldecomp/mkdd / printReturn

Method printReturn

libs/JSystem/J2DGraph/J2DPrint.cpp:175–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175void J2DPrint::printReturn(const char* str, f32 x, f32 y, J2DTextBoxHBinding hbind, J2DTextBoxVBinding vbind, f32 x2, f32 y2, u8 alpha)
176{
177 if (!mFont) {
178 return;
179 }
180
181 initchar();
182 mPositionX = mCursorX;
183 mPositionY = mCursorY;
184 u32 len = strlen(str);
185 if (len >= mStrBuffSize) {
186 len = mStrBuffSize - 1;
187 mBufferNotEnough = true;
188 }
189 u16 buffer[260]; // needs to be more than 256
190 TSize size;
191 f32 a2 = parse((const u8*)str, len, (int)x, buffer, size, alpha, false);
192 f32 height = mFont->getAscent() * (mGlyphHeight / mFont->getCellHeight());
193 f32 sum = a2 + height;
194
195 switch (vbind) {
196 case J2DVBIND_Top:
197 break;
198 case J2DVBIND_Bottom:
199 y2 += (int)((y - sum) - 0.5f);
200 break;
201 case J2DVBIND_Center:
202 y2 += (int)(((y - sum) - 0.5f)) / 2;
203 break;
204 default:
205 break;
206 }
207 for (int i = 0; buffer[i] != 0xFFFF; i++) {
208 switch (hbind) {
209 case J2DHBIND_Left:
210 buffer[i] = 0;
211 break;
212 case J2DHBIND_Right:
213 buffer[i] = int(x - buffer[i]);
214 break;
215 case J2DHBIND_Center:
216 buffer[i] = (x - buffer[i]) / 2;
217 break;
218 }
219 }
220 initchar();
221 mCursorX += x2;
222 mCursorY += y2 + height;
223 mPositionX = mCursorX;
224 mPositionY = mCursorY;
225 parse((const u8*)str, len, x, buffer, size, alpha, true);
226}
227
228f32 J2DPrint::parse(const u8* inputString, int inputLength, int maxWidth, u16* outputBuffer, J2DPrint::TSize& textSize, u8 alpha,
229 bool isDrawing)

Callers 4

drawSelfMethod · 0.80
drawMethod · 0.80
drawMethod · 0.80
drawSelfMethod · 0.80

Calls 2

getAscentMethod · 0.45
getCellHeightMethod · 0.45

Tested by

no test coverage detected