Matched ut_TextWriterBase

This commit is contained in:
elijah-thomas774
2024-05-12 14:23:03 -04:00
parent 8129fcc190
commit 834d0673ea
4 changed files with 57 additions and 51 deletions
+2 -2
View File
@@ -3837,7 +3837,7 @@ fn_800AEB00 = .text:0x800AEB00; // type:function size:0x178
fn_800AEC80 = .text:0x800AEC80; // type:function size:0x108
fn_800AED90 = .text:0x800AED90; // type:function size:0x1E8
fn_800AEF80 = .text:0x800AEF80; // type:function size:0x414
fn_800AF3A0 = .text:0x800AF3A0; // type:function size:0x38
GetCharStrmReader__Q34nw4r2ut4FontCFv = .text:0x800AF3A0; // type:function size:0x38
fn_800AF3E0 = .text:0x800AF3E0; // type:function size:0x8C
fn_800AF470 = .text:0x800AF470; // type:function size:0xCC
fn_800AF540 = .text:0x800AF540; // type:function size:0x8C
@@ -24137,7 +24137,7 @@ CalcStringRectImpl__Q34nw4r2ut17TextWriterBase<w>FPQ34nw4r2ut4RectPCwi = .text:0
PrintImpl__Q34nw4r2ut17TextWriterBase<w>FPCwib = .text:0x804334E0; // type:function size:0x828
AdjustCursor__Q34nw4r2ut17TextWriterBase<w>FPfPfPCwi = .text:0x80433D10; // type:function size:0x4D8
IsDrawFlagSet__Q34nw4r2ut17TextWriterBase<w>CFUlUl = .text:0x804341F0; // type:function size:0x18
__sinit_\ut_TextWriterBase_cpp = .text:0x80434210; // type:function size:0x84
__sinit_\ut_TextWriterBase_cpp = .text:0x80434210; // type:function size:0x84 scope:local
DirectPrint_Init__Q24nw4r2dbFv = .text:0x804342A0; // type:function size:0xB4
DirectPrint_IsActive__Q24nw4r2dbFv = .text:0x80434360; // type:function size:0x28
DirectPrint_EraseXfb__Q24nw4r2dbFiiii = .text:0x80434390; // type:function size:0x190
+3 -3
View File
@@ -230,7 +230,7 @@ def Rel(status, rel_name, cpp_name, extra_cflags=[]):
def DolphinLib(lib_name, objects):
return {
"lib": lib_name,
"mw_version": "GC/1.2.5n",
"mw_version": "Wii/1.0", # from version strings
"cflags": cflags_dolphin,
"host": False,
"objects": objects,
@@ -250,7 +250,7 @@ def EGGLib(lib_name, objects):
def nw4rLib(lib_name, objects):
return {
"lib": lib_name,
"mw_version": "Wii/1.6",
"mw_version": "Wii/1.1", # most seem to be around 1.2, snd is 1.6
"cflags": cflags_nw4r,
"host": False,
"objects": objects,
@@ -343,7 +343,7 @@ config.libs = [
Object(Matching, "nw4r/ut/ut_ResFontBase.cpp"),
Object(Matching, "nw4r/ut/ut_ResFont.cpp"),
Object(Matching, "nw4r/ut/ut_CharWriter.cpp"),
Object(NonMatching, "nw4r/ut/ut_TextWriterBase.cpp"),
Object(Matching, "nw4r/ut/ut_TextWriterBase.cpp"),
],
),
# EGG
+5 -4
View File
@@ -64,9 +64,6 @@ public:
void SetDrawFlag(u32 flag) {
mDrawFlag = flag;
}
bool IsDrawFlagSet(unsigned long mask, u32 flag) const {
return (mDrawFlag & mask) == flag;
}
TagProcessorBase<T> *GetTagProcessor() const {
return mTagProcessor;
@@ -108,11 +105,15 @@ public:
}
f32 CalcLineWidth(const T *format, int len);
bool CalcLineRectImpl(Rect *rect, const T **str, int len);
int CalcLineRectImpl(Rect *rect, const T **str, int len);
void CalcStringRectImpl(Rect *rect, const T *str, int len);
f32 PrintImpl(const T *str, int len, bool m);
f32 AdjustCursor(f32 *x1, f32 *y1, const T *str, int len);
bool IsDrawFlagSet(unsigned long mask, unsigned long flag) const {
return (mDrawFlag & mask) == flag;
}
private:
f32 mWidthLimit; // at 0x4C
f32 mCharSpace; // at 0x50
+47 -42
View File
@@ -179,68 +179,70 @@ f32 TextWriterBase<T>::CalcLineWidth(const T *str, int len) {
}
template <typename T>
bool TextWriterBase<T>::CalcLineRectImpl(Rect *rect, const T **str, int len) {
const T *strBegin = *str;
const T *strEnd = strBegin + len;
int TextWriterBase<T>::CalcLineRectImpl(Rect *pRect, const T **pStr, int length) {
const T *strBegin = *pStr;
const T *strEnd = strBegin + length;
const bool useLimit = mWidthLimit < NW4R_MATH_FLT_MAX;
PrintContext<T> context = {this, strBegin};
f32 x = 0.0f;
bool charSpace = false;
bool overLimit = false;
const T *prevStream = NULL;
Rect prevRect;
CharStrmReader reader = GetFont()->GetCharStrmReader();
rect->left = 0.0f;
rect->right = 0.0f;
rect->top = Min(0.0f, GetLineHeight());
rect->bottom = Max(0.0f, GetLineHeight());
prevRect = *rect;
pRect->left = 0.0f;
pRect->right = 0.0f;
pRect->top = Min(0.0f, GetLineHeight());
pRect->bottom = Max(0.0f, GetLineHeight());
prevRect = *pRect;
reader.Set(strBegin);
prevStream = NULL;
u16 ch = reader.Next();
u16 code = reader.Next();
while (static_cast<const T *>(reader.GetCurrentPos()) <= strEnd) {
if (ch < ' ') {
if (code < ' ') {
Rect r(x, 0.0f, 0.0f, 0.0f);
context.str = static_cast<const T *>(reader.GetCurrentPos());
context.flags = charSpace ? 0 : PRINTFLAGS_CHARSPACE;
SetCursorX(x);
if (useLimit && ch != '\n' && prevStream != NULL) {
if (useLimit && code != '\n' && prevStream != NULL) {
PrintContext<T> context2 = context;
TextWriterBase<T> clone(*this);
Rect r;
context2.writer = &clone;
mTagProcessor->CalcRect(&r, ch, &context2);
mTagProcessor->CalcRect(&r, code, &context2);
if (r.GetWidth() > 0.0f && clone.GetCursorX() - context.x > mWidthLimit) {
overLimit = true;
ch = '\n';
reader.Set(prevStream);
continue;
if (r.GetWidth() > 0.0f) {
if (clone.GetCursorX() - context.x > mWidthLimit) {
overLimit = true;
code = '\n';
reader.Set(prevStream);
continue;
}
}
}
Operation oper = mTagProcessor->CalcRect(&r, ch, &context);
Operation oper = mTagProcessor->CalcRect(&r, code, &context);
reader.Set(context.str);
rect->left = Min(rect->left, r.left);
rect->top = Min(rect->top, r.top);
rect->right = Max(rect->right, r.right);
rect->bottom = Max(rect->bottom, r.bottom);
pRect->left = Min(pRect->left, r.left);
pRect->top = Min(pRect->top, r.top);
pRect->right = Max(pRect->right, r.right);
pRect->bottom = Max(pRect->bottom, r.bottom);
x = GetCursorX();
if (oper == OPERATION_END_DRAW) {
*str += len;
*pStr += length;
return false;
}
@@ -261,19 +263,20 @@ bool TextWriterBase<T>::CalcLineRectImpl(Rect *rect, const T **str, int len) {
if (IsWidthFixed()) {
dx += GetFixedWidth();
} else {
dx += GetFont()->GetCharWidth(ch) * GetScaleH();
dx += GetFont()->GetCharWidth(code) * GetScaleH();
}
if (useLimit && prevStream != NULL && x + dx > mWidthLimit) {
overLimit = true;
ch = '\n';
reader.Set(prevStream);
continue;
if (useLimit && prevStream != NULL) {
if (x + dx > mWidthLimit) {
overLimit = true;
code = '\n';
reader.Set(prevStream);
continue;
}
}
x += dx;
rect->left = Min(rect->left, x);
rect->right = Max(rect->right, x);
pRect->left = Min(pRect->left, x);
pRect->right = Max(pRect->right, x);
charSpace = true;
}
@@ -282,10 +285,10 @@ bool TextWriterBase<T>::CalcLineRectImpl(Rect *rect, const T **str, int len) {
prevStream = static_cast<const T *>(reader.GetCurrentPos());
}
ch = reader.Next();
code = reader.Next();
}
*str = static_cast<const T *>(reader.GetCurrentPos());
*pStr = static_cast<const T *>(reader.GetCurrentPos());
return overLimit;
}
@@ -434,6 +437,10 @@ f32 TextWriterBase<T>::PrintImpl(const T *str, int len, bool m) {
if (IsDrawFlagSet(0x300, 0x100) || IsDrawFlagSet(0x300, 0x200)) {
SetCursorY(orgCursorY);
} else if (m) {
if (IsDrawFlagSet(0x300, 0)) {
SetCursorY(GetCursorY() - GetFontAscent());
}
} else {
MoveCursorY(cursorYAdj);
}
@@ -446,14 +453,12 @@ f32 TextWriterBase<T>::AdjustCursor(f32 *x1, f32 *y1, const T *str, int len) {
f32 textWidth = 0.0f;
f32 textHeight = 0.0f;
if (!IsDrawFlagSet(0x333, 0x300)) {
if (!IsDrawFlagSet(0x333, 0)) {
Rect rect;
CalcStringRect(&rect, str, len);
if (!IsDrawFlagSet(0x333, 0x300) && !IsDrawFlagSet(0x333, 0)) {
Rect rect;
CalcStringRect(&rect, str, len);
textWidth = rect.left + rect.right;
textHeight = rect.top + rect.bottom;
}
textWidth = rect.left + rect.right;
textHeight = rect.top + rect.bottom;
}
if (IsDrawFlagSet(0x30, 0x10)) {