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
|
//
// Generated by dtk
// Translation Unit: J2DTextBox.cpp
//
#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/J2DGraph/J2DTextBox.h"
#include "JSystem/JKernel/JKRFileLoader.h"
#include "JSystem/JSupport/JSURandomInputStream.h"
#include "JSystem/JUtility/JUTResource.h"
#include "JSystem/J2DGraph/J2DPrint.h"
#include "dolphin/gx/GXTransform.h"
#include "stdarg.h"
/* 802D51D8-802D5268 .text __ct__10J2DTextBoxFPCcPCc */
J2DTextBox::J2DTextBox(const char* font, const char* str) : mpFont(NULL), mStringPtr(NULL) {
void * font_res = JKRFileLoader::getGlbResource(font, NULL);
initiate((ResFONT*) font_res, str, HBIND_LEFT, VBIND_TOP);
}
/* 802D5268-802D55D4 .text __ct__10J2DTextBoxFP7J2DPaneP20JSURandomInputStream */
J2DTextBox::J2DTextBox(J2DPane* parent, JSURandomInputStream* stream) : mpFont(NULL), mStringPtr(NULL) {
s32 streamPos = stream->getPosition();
J2DPaneHeader header;
s32 endPos;
u8 num;
stream->read(&header, sizeof(header));
mMagic = header.mMagic;
endPos = streamPos + header.mSize;
makePaneStream(parent, stream);
JUTResReference resRef;
num = stream->readU8();
ResFONT * font_res = (ResFONT *) resRef.getResource(stream, 'FONT', NULL);
if (font_res != NULL)
mpFont = new JUTResFont(font_res, NULL);
mCharColor.set(stream->readU32());
mGradColor.set(stream->readU32());
u8 bindingFlag = stream->readU8();
mBindingH = (bindingFlag >> 2) & 0x03;
mBindingV = (bindingFlag >> 0) & 0x03;
mCharSpace = stream->readS16();
mLineSpace = stream->readS16();
mFontSizeX = stream->readU16();
mFontSizeY = stream->readU16();
s16 stringLen = stream->readU16();
mStringPtr = new char[stringLen + 1];
stream->read(mStringPtr, stringLen);
mStringPtr[stringLen] = '\0';
num -= 10;
if (num) {
u8 isConnectParent = stream->readU8();
if (isConnectParent)
setConnectParent(true);
num--;
}
mBlack = JUtility::TColor(0);
mWhite = JUtility::TColor(0xffffffff);
if (num) {
mBlack.set(stream->readU32());
num--;
}
if (num) {
mWhite.set(stream->readU32());
num--;
}
field_0xd8 = 0.0f;
field_0xdc = 0.0f;
stream->seek(endPos, JSUStreamSeekFrom_SET);
mTextFontOwned = true;
}
/* 802D55D4-802D5660 .text __ct__10J2DTextBoxFUlRCQ29JGeometry8TBox2<f>PC7ResFONTPCc18J2DTextBoxHBinding18J2DTextBoxVBinding */
J2DTextBox::J2DTextBox(u32 tag, const JGeometry::TBox2<f32>& bounds, const ResFONT* font_res, const char* str, J2DTextBoxHBinding hbind, J2DTextBoxVBinding vbind) : J2DPane(tag, bounds), mpFont(NULL), mStringPtr(NULL) {
initiate(font_res, str, hbind, vbind);
}
/* 802D5660-802D5820 .text initiate__10J2DTextBoxFPC7ResFONTPCc18J2DTextBoxHBinding18J2DTextBoxVBinding */
void J2DTextBox::initiate(const ResFONT* font, const char* str, J2DTextBoxHBinding bindingH, J2DTextBoxVBinding bindingV) {
if (font != NULL)
mpFont = new JUTResFont(font, NULL);
mCharColor.set(0xFFFFFFFF);
mGradColor.set(0xFFFFFFFF);
mBlack = JUtility::TColor(0x00000000);
mWhite = JUtility::TColor(0xFFFFFFFF);
mBindingH = bindingH;
mBindingV = bindingV;
size_t temp = strlen(str);
mStringPtr = new char[temp + 1];
strcpy(mStringPtr, str);
field_0xd8 = 0.0f;
field_0xdc = 0.0f;
mCharSpace = 0.0f;
if (mpFont == NULL) {
mLineSpace = 0.0f;
mFontSizeX = 0.0f;
mFontSizeY = 0.0f;
} else {
mLineSpace = mpFont->getLeading();
mFontSizeX = mpFont->getWidth();
mFontSizeY = mpFont->getHeight();
}
mMagic = 'TBX1';
mTextFontOwned = true;
}
/* 802D5820-802D58B8 .text __dt__10J2DTextBoxFv */
J2DTextBox::~J2DTextBox() {
if (mTextFontOwned)
delete mpFont;
delete[] mStringPtr;
}
/* 802D58B8-802D5928 .text setFont__10J2DTextBoxFP7JUTFont */
void J2DTextBox::setFont(JUTFont* font) {
if (font) {
if (mTextFontOwned)
delete mpFont;
mpFont = font;
mTextFontOwned = false;
}
}
/* 802D5928-802D5AA4 .text draw__10J2DTextBoxFfff18J2DTextBoxHBinding */
void J2DTextBox::draw(f32 x, f32 y, f32 f31, J2DTextBoxHBinding hbind) {
if (!mVisible) {
return;
}
J2DPrint print(mpFont, mCharSpace, mLineSpace, mCharColor, mGradColor, mBlack, mWhite);
print.setFontSize(mFontSizeX, mFontSizeY);
makeMatrix(x, y);
GXLoadPosMtxImm(mMtx, 0);
GXSetCurrentMtx(0);
print.printReturn(mStringPtr, f31, 0.0f, hbind, VBIND_TOP, 0.0f, -mFontSizeY, mDrawAlpha);
Mtx mtx;
MTXIdentity(mtx);
GXLoadPosMtxImm(mtx, 0);
}
/* 802D5AA4-802D5AAC .text getStringPtr__10J2DTextBoxCFv */
char* J2DTextBox::getStringPtr() const {
return mStringPtr;
}
/* 802D5AAC-802D5B6C .text setString__10J2DTextBoxFPCce */
s32 J2DTextBox::setString(const char* str, ...) {
va_list args;
va_start(args, str);
delete[] mStringPtr;
u32 strLen = strlen(str);
mStringPtr = new char[strLen + 1];
strcpy(mStringPtr, str);
va_end(args);
return strLen;
}
/* 802D5B6C-802D5BE4 .text setConnectParent__10J2DTextBoxFb */
bool J2DTextBox::setConnectParent(bool v) {
if (getPaneTree()->getParent() == NULL)
return false;
if (getPaneTree()->getParent()->getObject()->getTypeID() != 17)
return false;
mIsConnectParent = v;
return v;
}
/* 802D5BE4-802D5C4C .text drawSelf__10J2DTextBoxFff */
void J2DTextBox::drawSelf(f32 x, f32 y) {
Mtx mtx;
MTXIdentity(mtx);
drawSelf(x, y, &mtx);
}
/* 802D5C4C-802D5DA4 .text drawSelf__10J2DTextBoxFffPA3_A4_f */
void J2DTextBox::drawSelf(f32 x, f32 y, Mtx* pMtx) {
J2DPrint print(mpFont, mCharSpace, mLineSpace, mCharColor, mGradColor, mBlack, mWhite);
print.setFontSize(mFontSizeX, mFontSizeY);
Mtx mtx;
MTXConcat(*pMtx, mDrawMtx, mtx);
GXLoadPosMtxImm(mtx, 0);
print.locate(x, y);
print.printReturn(mStringPtr, mBounds.getWidth() + 0.0001f, mBounds.getHeight(),
(J2DTextBoxHBinding)mBindingH, (J2DTextBoxVBinding)mBindingV, field_0xd8, field_0xdc, mDrawAlpha);
}
/* 802D5DA4-802D5EB0 .text resize__10J2DTextBoxFff */
void J2DTextBox::resize(f32 w, f32 h) {
if (mIsConnectParent && getPaneTree() != NULL && getPaneTree()->getParent() != NULL) {
J2DPane * pane = getPaneTree()->getParent()->getObject();
if (pane->getTypeID() == 17) {
f32 newW = pane->getWidth() + (w - getWidth());
f32 newH = pane->getHeight() + (h - getHeight());
pane->resize(newW, newH);
return;
}
}
J2DPane::resize(w, h);
}
|