1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
|
//
// Generated By: dol2asm
// Translation Unit: J2DTextBox
//
#include "JSystem/J2DGraph/J2DTextBox.h"
#include "JSystem/J2DGraph/J2DPrint.h"
#include "JSystem/JSupport/JSURandomInputStream.h"
#include "JSystem/JUtility/JUTResFont.h"
#include "dol2asm.h"
/* 802FF660-802FF6D8 2F9FA0 0078+00 0/0 1/1 0/0 .text __ct__10J2DTextBoxFv */
J2DTextBox::J2DTextBox()
: mFont(NULL), mCharColor(), mGradientColor(), mStringPtr(NULL), mWhiteColor(), mBlackColor() {
initiate(NULL, NULL, 0, HBIND_LEFT, VBIND_TOP);
}
/* 802FF6D8-802FF75C 2FA018 0084+00 0/0 1/1 0/0 .text
* __ct__10J2DTextBoxFP7J2DPaneP20JSURandomInputStreamP10JKRArchive */
J2DTextBox::J2DTextBox(J2DPane* p_pane, JSURandomInputStream* p_stream, JKRArchive* p_archive)
: mFont(NULL), mCharColor(), mGradientColor(), mStringPtr(NULL), mWhiteColor(), mBlackColor() {
private_readStream(p_pane, p_stream, p_archive);
}
/* 802FF75C-802FFBC4 2FA09C 0468+00 0/0 1/1 0/0 .text
* __ct__10J2DTextBoxFP7J2DPaneP20JSURandomInputStreamUlP11J2DMaterial */
J2DTextBox::J2DTextBox(J2DPane* p_pane, JSURandomInputStream* p_stream, u32 param_2,
J2DMaterial* p_material)
: mFont(NULL), mCharColor(), mGradientColor(), mStringPtr(NULL), mWhiteColor(), mBlackColor() {
J2DTextBoxInfo info;
int startPos = p_stream->getPosition();
J2DTbxBlockHeader header;
p_stream->read(&header, 8);
mKind = 'TBX1';
int panHeaderPos = p_stream->getPosition();
J2DTbxBlockHeader panHeader;
p_stream->peek(&panHeader, 8);
makePaneExStream(p_pane, p_stream);
p_stream->seek(panHeaderPos + panHeader.mSize, JSUStreamSeekFrom_SET);
p_stream->read(&info, 0x20);
J2DMaterial* mat = NULL;
if (info.mMaterialNum != 0xFFFF) {
mat = &p_material[info.mMaterialNum];
if (mat != NULL) {
if (mat->getTevBlock() != NULL) {
JUTFont* font = mat->getTevBlock()->getFont();
if (font != NULL) {
mFont = font;
mat->getTevBlock()->setFontUndeleteFlag();
}
}
mAlpha = mat->getColorBlock()->getMatColor(0)->a;
}
}
mCharSpacing = info.mCharSpace;
mLineSpacing = info.mLineSpace;
mFontSizeX = info.mFontSizeX;
mFontSizeY = info.mFontSizeY;
mFlags = (info.mHBind << 2) | info.mVBind;
mCharColor = JUtility::TColor(info.mCharColor);
mGradientColor = JUtility::TColor(info.mGradColor);
setConnectParent(info.mConnected);
u16 strLength = 0;
if (!(param_2 & 0x2000000)) {
strLength = info.field_0x1c;
if ((s16)info.field_0x1c == -1) {
strLength = info.field_0x1e + 1;
}
}
mStringLength = 0;
mStringPtr = NULL;
if (strLength != 0) {
mStringPtr = new char[strLength];
}
if (mStringPtr != NULL) {
mStringLength = strLength;
int temp_r0 = (u16)strLength - 1;
u16 var_r26_2 = info.field_0x1e;
if (temp_r0 < var_r26_2) {
var_r26_2 = (u16)temp_r0;
}
p_stream->peek(mStringPtr, var_r26_2);
mStringPtr[var_r26_2] = 0;
}
p_stream->skip(info.field_0x1e);
p_stream->seek(startPos + header.mSize, JSUStreamSeekFrom_SET);
mBlackColor = JUtility::TColor(0);
mWhiteColor = JUtility::TColor(0xFFFFFFFF);
if (mat != NULL && mat->getTevBlock() != NULL) {
if (mat->getTevBlock()->getTevStageNum() != 1) {
J2DGXColorS10* color0p = mat->getTevBlock()->getTevColor(0);
GXColorS10 color0;
color0.r = color0p->r;
color0.g = color0p->g;
color0.b = color0p->b;
color0.a = color0p->a;
J2DGXColorS10* color1p = mat->getTevBlock()->getTevColor(1);
GXColorS10 color1;
color1.r = color1p->r;
color1.g = color1p->g;
color1.b = color1p->b;
color1.a = color1p->a;
mBlackColor = JUtility::TColor(((u8)color0.r << 0x18) | ((u8)color0.g << 0x10) |
((u8)color0.b << 8) | (u8)color0.a);
mWhiteColor = JUtility::TColor(((u8)color1.r << 0x18) | ((u8)color1.g << 0x10) |
((u8)color1.b << 8) | (u8)color1.a);
}
}
field_0x10c = 0.0f;
field_0x110 = 0.0f;
mTextFontOwned = true;
}
/* 802FFBC4-802FFC58 2FA504 0094+00 0/0 1/1 0/0 .text
* __ct__10J2DTextBoxFUxRCQ29JGeometry8TBox2<f>PC7ResFONTPCcs18J2DTextBoxHBinding18J2DTextBoxVBinding
*/
J2DTextBox::J2DTextBox(u64 tag, JGeometry::TBox2<f32> const& bounds, ResFONT const* p_font,
char const* string, s16 strLength, J2DTextBoxHBinding hBind,
J2DTextBoxVBinding vBind)
: J2DPane(tag, bounds), mFont(NULL), mCharColor(), mGradientColor(), mStringPtr(NULL),
mWhiteColor(), mBlackColor() {
initiate(p_font, string, strLength, hBind, vBind);
}
/* 802FFC58-802FFE88 2FA598 0230+00 2/2 1/0 0/0 .text
* initiate__10J2DTextBoxFPC7ResFONTPCcs18J2DTextBoxHBinding18J2DTextBoxVBinding */
void J2DTextBox::initiate(ResFONT const* p_font, char const* string, s16 length,
J2DTextBoxHBinding hBind, J2DTextBoxVBinding vBind) {
if (p_font != NULL) {
mFont = new JUTResFont(p_font, NULL);
}
mCharColor.set(0xFFFFFFFF);
mGradientColor.set(0xFFFFFFFF);
mBlackColor = JUtility::TColor(0);
mWhiteColor = JUtility::TColor(0xFFFFFFFF);
mFlags = (hBind << 2) | vBind;
mStringLength = 0;
mStringPtr = NULL;
if (string != NULL && length != 0) {
u32 len = strlen(string);
u16 stringLen = length;
if (length == -1) {
if (len >= 0xFFFF) {
len = 0xFFFF - 1;
}
stringLen = len + 1;
}
mStringPtr = new char[stringLen];
if (stringLen != 0 && mStringPtr != NULL) {
strncpy(mStringPtr, string, stringLen - 1);
mStringPtr[stringLen - 1] = 0;
mStringLength = stringLen;
}
}
field_0x10c = 0.0f;
field_0x110 = 0.0f;
mCharSpacing = 0.0f;
if (mFont == NULL) {
mLineSpacing = 0.0f;
mFontSizeX = 0.0f;
mFontSizeY = 0.0f;
} else {
mLineSpacing = mFont->getLeading();
mFontSizeX = mFont->getWidth();
mFontSizeY = mFont->getHeight();
}
mKind = 'TBX1';
mTextFontOwned = true;
}
/* 802FFE88-803001E0 2FA7C8 0358+00 1/1 0/0 0/0 .text
* private_readStream__10J2DTextBoxFP7J2DPaneP20JSURandomInputStreamP10JKRArchive */
void J2DTextBox::private_readStream(J2DPane* p_pane, JSURandomInputStream* p_stream,
JKRArchive* p_archive) {
int position = p_stream->getPosition();
J2DTbxBlockHeader header;
p_stream->read(&header, 8);
mKind = header.mTag;
makePaneStream(p_pane, p_stream);
u8 spA = p_stream->readU8();
ResFONT* fontPtr = (ResFONT*)getPointer(p_stream, 'FONT', p_archive);
if (fontPtr != NULL) {
mFont = new JUTResFont(fontPtr, NULL);
}
mCharColor.set(p_stream->read32b());
mGradientColor.set(p_stream->read32b());
mFlags = p_stream->read8b();
mCharSpacing = p_stream->readS16();
mLineSpacing = p_stream->readS16();
mFontSizeX = p_stream->read16b();
mFontSizeY = p_stream->read16b();
s16 stringLen = p_stream->read16b();
mStringPtr = new char[stringLen + 1];
if (mStringPtr != NULL) {
p_stream->read(mStringPtr, stringLen);
mStringPtr[stringLen] = 0;
mStringLength = stringLen + 1;
} else {
p_stream->skip(stringLen);
mStringLength = 0;
}
spA -= 10;
if (spA != 0) {
u8 sp8 = p_stream->read8b();
if (sp8 != 0) {
setConnectParent(true);
}
spA--;
}
mBlackColor = JUtility::TColor(0);
mWhiteColor = JUtility::TColor(0xFFFFFFFF);
if (spA != 0) {
mBlackColor.set(p_stream->read32b());
spA--;
}
if (spA != 0) {
mWhiteColor.set(p_stream->read32b());
}
field_0x10c = 0.0f;
field_0x110 = 0.0f;
p_stream->seek(position + header.mSize, JSUStreamSeekFrom_SET);
mTextFontOwned = true;
}
/* 803001E0-80300278 2FAB20 0098+00 1/0 2/2 0/0 .text __dt__10J2DTextBoxFv */
J2DTextBox::~J2DTextBox() {
if (mTextFontOwned) {
delete mFont;
}
delete[] mStringPtr;
}
/* 80300278-803002E8 2FABB8 0070+00 1/0 0/0 0/0 .text setFont__10J2DTextBoxFP7JUTFont */
void J2DTextBox::setFont(JUTFont* p_font) {
if (p_font) {
if (mTextFontOwned) {
delete mFont;
}
mFont = p_font;
mTextFontOwned = false;
}
}
/* 803002E8-80300490 2FAC28 01A8+00 1/0 0/0 0/0 .text draw__10J2DTextBoxFff */
void J2DTextBox::draw(f32 posX, f32 posY) {
Mtx m;
if (isVisible()) {
J2DPrint print(mFont, mCharSpacing, mLineSpacing, mCharColor, mGradientColor, mBlackColor,
mWhiteColor);
print.setFontSize(mFontSizeX, mFontSizeY);
makeMatrix(posX, posY, 0.0f, 0.0f);
GXLoadPosMtxImm(mPositionMtx, GX_PNMTX0);
GXSetCurrentMtx(0);
GXSetNumIndStages(0);
for (int i = 0; i < 16; i++) {
GXSetTevDirect((GXTevStageID)i);
}
GXSetNumTexGens(1);
GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 60, GX_FALSE, 125);
if (mStringPtr != NULL) {
print.print(0.0f, 0.0f, mAlpha, "%s", mStringPtr);
}
MTXIdentity(m);
GXLoadPosMtxImm(m, 0);
}
}
/* 80300490-80300658 2FADD0 01C8+00 1/0 1/1 0/0 .text draw__10J2DTextBoxFfff18J2DTextBoxHBinding
*/
void J2DTextBox::draw(f32 posX, f32 posY, f32 param_2, J2DTextBoxHBinding hBind) {
Mtx m;
if (isVisible()) {
J2DPrint print(mFont, mCharSpacing, mLineSpacing, mCharColor, mGradientColor, mBlackColor,
mWhiteColor);
print.setFontSize(mFontSizeX, mFontSizeY);
makeMatrix(posX, posY, 0.0f, 0.0f);
GXLoadPosMtxImm(mPositionMtx, GX_PNMTX0);
GXSetCurrentMtx(0);
GXSetNumIndStages(0);
for (int i = 0; i < 16; i++) {
GXSetTevDirect((GXTevStageID)i);
}
GXSetNumTexGens(1);
GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 60, GX_FALSE, 125);
if (mStringPtr != NULL) {
print.printReturn(mStringPtr, param_2, 0.0f, hBind, VBIND_TOP, 0.0f, -mFontSizeY,
mAlpha);
}
MTXIdentity(m);
GXLoadPosMtxImm(m, 0);
}
}
/* 80300658-80300660 2FAF98 0008+00 0/0 62/62 2/2 .text getStringPtr__10J2DTextBoxCFv */
char* J2DTextBox::getStringPtr() const {
return mStringPtr;
}
/* 80300660-8030074C 2FAFA0 00EC+00 0/0 6/6 0/0 .text setString__10J2DTextBoxFPCce */
s32 J2DTextBox::setString(char const* string, ...) {
va_list args;
va_start(args, string);
delete[] mStringPtr;
u32 len = strlen(string);
if (len >= 0xFFFF) {
len = 0xFFFF - 1;
}
mStringLength = 0;
char* tmp = new char[len + 1];
mStringPtr = tmp;
if (mStringPtr) {
mStringLength = len + 1;
strcpy(mStringPtr, string);
}
va_end(args);
return len;
}
/* 8030074C-80300870 2FB08C 0124+00 0/0 41/41 2/2 .text setString__10J2DTextBoxFsPCce */
s32 J2DTextBox::setString(s16 length, char const* string, ...) {
va_list args;
va_start(args, string);
delete[] mStringPtr;
mStringPtr = NULL;
u32 len = strlen(string);
u16 stringLen = length;
if (length == -1) {
if (len >= 0xFFFF) {
len = 0xFFFF - 1;
}
stringLen = len + 1;
}
mStringLength = 0;
if (stringLen != 0) {
mStringPtr = new char[stringLen];
}
if (mStringPtr != NULL) {
strncpy(mStringPtr, string, stringLen - 1);
mStringPtr[stringLen - 1] = 0;
mStringLength = stringLen;
}
va_end(args);
return len;
}
/* 80300870-803008E8 2FB1B0 0078+00 1/0 1/0 0/0 .text setConnectParent__10J2DTextBoxFb */
bool J2DTextBox::setConnectParent(bool connected) {
if (getPaneTree()->getParent() == NULL) {
return false;
}
if (getPaneTree()->getParent()->getObject()->getTypeID() != 0x11) {
return false;
}
mConnected = connected;
return connected;
}
/* 803008E8-80300950 2FB228 0068+00 1/0 1/0 0/0 .text drawSelf__10J2DTextBoxFff */
void J2DTextBox::drawSelf(f32 param_0, f32 param_1) {
Mtx identity;
MTXIdentity(identity);
drawSelf(param_0, param_1, &identity);
}
/* 80300950-80300AF8 2FB290 01A8+00 1/0 0/0 0/0 .text drawSelf__10J2DTextBoxFffPA3_A4_f
*/
void J2DTextBox::drawSelf(f32 param_0, f32 param_1, Mtx* p_mtx) {
Mtx m;
J2DPrint print(mFont, mCharSpacing, mLineSpacing, mCharColor, mGradientColor, mBlackColor,
mWhiteColor);
print.setFontSize(mFontSizeX, mFontSizeY);
MTXConcat(*p_mtx, mGlobalMtx, m);
GXLoadPosMtxImm(m, GX_PNMTX0);
GXSetNumIndStages(0);
for (int i = 0; i < 16; i++) {
GXSetTevDirect((GXTevStageID)i);
}
GXSetNumTexGens(1);
GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 60, GX_FALSE, 125);
print.locate(param_0 + mBounds.i.x, param_1 + mBounds.i.y);
if (mStringPtr != NULL) {
print.printReturn(mStringPtr, mBounds.getWidth() + 0.0001f, mBounds.getHeight(),
getHBinding(), getVBinding(), field_0x10c, field_0x110, mColorAlpha);
}
}
/* 80300AF8-80300BFC 2FB438 0104+00 1/0 1/0 0/0 .text resize__10J2DTextBoxFff */
void J2DTextBox::resize(f32 x, f32 y) {
if (mConnected && getPaneTree() != NULL && getPaneTree()->getParent() != NULL) {
J2DPane* obj = getPaneTree()->getParent()->getObject();
if (obj->getTypeID() == 0x11) {
f32 obj_x = obj->getWidth() + (x - getWidth());
f32 obj_y = obj->getHeight() + (y - getHeight());
obj->resize(obj_x, obj_y);
return;
}
}
J2DPane::resize(x, y);
}
/* 80300BFC-80300C68 2FB53C 006C+00 1/0 0/0 0/0 .text isUsed__10J2DTextBoxFPC7ResFONT */
bool J2DTextBox::isUsed(ResFONT const* p_font) {
if (mFont != NULL && mFont->getResFont() == p_font) {
return true;
}
return J2DPane::isUsed(p_font);
}
/* 80300C68-80300C70 2FB5A8 0008+00 1/0 1/0 0/0 .text getTypeID__10J2DTextBoxCFv */
u16 J2DTextBox::getTypeID() const {
return 19;
}
/* 80300C70-80300C90 2FB5B0 0020+00 1/0 0/0 0/0 .text isUsed__10J2DTextBoxFPC7ResTIMG */
bool J2DTextBox::isUsed(ResTIMG const* p_timg) {
return J2DPane::isUsed(p_timg);
}
/* 80300C90-80300C94 2FB5D0 0004+00 1/0 0/0 0/0 .text rewriteAlpha__10J2DTextBoxFv */
void J2DTextBox::rewriteAlpha() {
/* empty function */
}
/* ############################################################################################## */
/* 803A1C5B-803A1C60 02E2BB 0001+04 0/0 0/0 0/0 .rodata None */
#pragma push
#pragma force_active on
SECTION_DEAD static char const* const stringBase_803A1C5B = "";
/* @stringBase0 padding */
SECTION_DEAD static char const* const pad_803A1C5C = "\0\0\0";
#pragma pop
/* 803A1C58-803A1C58 02E2B8 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */
|