match ut_TagProcessorBase. thanks ogws

This commit is contained in:
elijah-thomas774
2024-05-04 23:29:06 -04:00
parent e1f491d2d1
commit 498660cf6b
6 changed files with 110 additions and 13 deletions
+4
View File
@@ -6,6 +6,10 @@ mw_comment_version: 8
quick_analysis: true
force_active: [
"searchBaseByID__10fManager_cF9fBaseID_e",
"ProcessLinefeed__Q34nw4r2ut19TagProcessorBase<c>FPQ34nw4r2ut15PrintContext<c>",
"ProcessTab__Q34nw4r2ut19TagProcessorBase<c>FPQ34nw4r2ut15PrintContext<c>",
"ProcessLinefeed__Q34nw4r2ut19TagProcessorBase<w>FPQ34nw4r2ut15PrintContext<w>",
"ProcessTab__Q34nw4r2ut19TagProcessorBase<w>FPQ34nw4r2ut15PrintContext<w>",
]
# modules:
# - object: orig/SOUE01/rels/d_a_asura_bulletNP.rel
+2
View File
@@ -181,6 +181,8 @@ nw4r/ut/ut_CharStrmReader.cpp:
nw4r/ut/ut_TagProcessorBase.cpp:
.text start:0x8042AB80 end:0x8042B4D4
.data start:0x8056BD50 end:0x8056BD78
.sdata2 start:0x8057EB68 end:0x8057EB70
nw4r/ut/ut_IOStream.cpp:
.text start:0x8042B4E0 end:0x8042B55C
+3 -3
View File
@@ -23946,7 +23946,7 @@ ReadNextCharCP1252__Q34nw4r2ut14CharStrmReaderFv = .text:0x8042AB00; // type:fun
ReadNextCharSJIS__Q34nw4r2ut14CharStrmReaderFv = .text:0x8042AB20; // type:function size:0x60
__ct__Q34nw4r2ut19TagProcessorBase<c>Fv = .text:0x8042AB80; // type:function size:0x10
__dt__Q34nw4r2ut19TagProcessorBase<c>Fv = .text:0x8042AB90; // type:function size:0x40
Process__Q34nw4r2ut19TagProcessorBase = .text:0x8042ABD0; // type:function size:0x12C
Process__Q34nw4r2ut19TagProcessorBase<c>FUsPQ34nw4r2ut15PrintContext<c> = .text:0x8042ABD0; // type:function size:0x12C
CalcRect__Q34nw4r2ut19TagProcessorBase<c>FPQ34nw4r2ut4RectUsPQ34nw4r2ut15PrintContext<c> = .text:0x8042AD00; // type:function size:0x1E4
ProcessLinefeed__Q34nw4r2ut19TagProcessorBase<c>FPQ34nw4r2ut15PrintContext<c> = .text:0x8042AEF0; // type:function size:0x64
ProcessTab__Q34nw4r2ut19TagProcessorBase<c>FPQ34nw4r2ut15PrintContext<c> = .text:0x8042AF60; // type:function size:0xC4
@@ -36943,8 +36943,8 @@ jumptable_8056BCB8 = .data:0x8056BCB8; // type:object size:0x20 scope:local
jumptable_8056BCD8 = .data:0x8056BCD8; // type:object size:0x20 scope:local
@1687 = .data:0x8056BCF8; // type:object size:0x21 scope:local data:string
lbl_8056BD20 = .data:0x8056BD20; // type:object size:0x30
lbl_8056BD50 = .data:0x8056BD50; // type:object size:0x14
lbl_8056BD64 = .data:0x8056BD64; // type:object size:0x14
__vt__Q34nw4r2ut19TagProcessorBase<w> = .data:0x8056BD50; // type:object size:0x14 scope:weak
__vt__Q34nw4r2ut19TagProcessorBase<c> = .data:0x8056BD64; // type:object size:0x14 scope:weak
lbl_8056BD78 = .data:0x8056BD78; // type:object size:0x68
lbl_8056BDE0 = .data:0x8056BDE0; // type:object size:0x68
lbl_8056BE48 = .data:0x8056BE48; // type:object size:0x60
+2 -1
View File
@@ -201,6 +201,7 @@ cflags_egg = [
cflags_nw4r = [
*cflags_base,
"-ipa file",
"-fp_contract off",
]
# REL flags
@@ -321,7 +322,7 @@ config.libs = [
Object(Matching, "nw4r/ut/ut_LinkList.cpp"),
Object(Matching, "nw4r/ut/ut_binaryFileFormat.cpp"),
Object(NonMatching, "nw4r/ut/ut_CharStrmReader.cpp"),
Object(NonMatching, "nw4r/ut/ut_TagProcessorBase.cpp"),
Object(Matching, "nw4r/ut/ut_TagProcessorBase.cpp"),
Object(NonMatching, "nw4r/ut/ut_IOStream.cpp"),
Object(NonMatching, "nw4r/ut/ut_FileStream.cpp"),
Object(NonMatching, "nw4r/ut/ut_DvdFileStream.cpp"),
+11 -9
View File
@@ -10,9 +10,10 @@ enum PrintFlags {
PRINTFLAGS_CHARSPACE = (1 << 0),
};
template <typename T> struct PrintContext {
TextWriterBase<T>* writer; // at 0x0
const T* str; // at 0x4
template <typename T>
struct PrintContext {
TextWriterBase<T> *writer; // at 0x0
const T *str; // at 0x4
f32 x; // at 0x8
f32 y; // at 0xC
u32 flags; // at 0x10
@@ -26,17 +27,18 @@ enum Operation {
OPERATION_END_DRAW
};
template <typename T> class TagProcessorBase {
template <typename T>
class TagProcessorBase {
public:
TagProcessorBase();
virtual ~TagProcessorBase(); // at 0x8
virtual Operation Process(u16 ch, PrintContext<T>* ctx); // at 0xC
virtual Operation CalcRect(Rect* rect, u16 ch,
PrintContext<T>* ctx); // at 0x10
virtual Operation Process(u16 ch, PrintContext<T> *ctx); // at 0xC
virtual Operation CalcRect(Rect *rect, u16 ch,
PrintContext<T> *ctx); // at 0x10
void ProcessTab(PrintContext<T>* ctx);
void ProcessLinefeed(PrintContext<T>* ctx);
void ProcessLinefeed(PrintContext<T> *ctx);
void ProcessTab(PrintContext<T> *ctx);
};
} // namespace ut
+88
View File
@@ -0,0 +1,88 @@
#include <nw4r/ut.h>
namespace nw4r {
namespace ut {
template <typename T>
TagProcessorBase<T>::TagProcessorBase() {}
template <typename T>
TagProcessorBase<T>::~TagProcessorBase() {}
template <typename T>
Operation TagProcessorBase<T>::Process(u16 ch, PrintContext<T> *ctx) {
switch (ch) {
case '\n':
ProcessLinefeed(ctx);
return OPERATION_NEXT_LINE;
case '\t':
ProcessTab(ctx);
return OPERATION_NO_CHAR_SPACE;
}
return OPERATION_DEFAULT;
}
template <typename T>
Operation TagProcessorBase<T>::CalcRect(Rect *rect, u16 ch, PrintContext<T> *ctx) {
switch (ch) {
case '\n': {
const TextWriterBase<T> &writer = *ctx->writer;
rect->right = writer.GetCursorX();
rect->top = writer.GetCursorY();
ProcessLinefeed(ctx);
rect->left = writer.GetCursorX();
rect->bottom = writer.GetCursorY() + ctx->writer->GetFontHeight();
rect->Normalize();
return OPERATION_NEXT_LINE;
}
case '\t': {
const TextWriterBase<T> &writer = *ctx->writer;
rect->left = writer.GetCursorX();
ProcessTab(ctx);
rect->right = writer.GetCursorX();
rect->top = writer.GetCursorY();
rect->bottom = rect->top + writer.GetFontHeight();
rect->Normalize();
return OPERATION_NO_CHAR_SPACE;
}
}
return OPERATION_DEFAULT;
}
template <typename T>
void TagProcessorBase<T>::ProcessTab(PrintContext<T> *ctx) {
TextWriterBase<T> &writer = *ctx->writer;
int tabWidth = writer.GetTabWidth();
if (tabWidth <= 0) {
return;
}
f32 charWidth = writer.IsWidthFixed() ? writer.GetFixedWidth() : writer.GetFontWidth();
f32 dx = writer.GetCursorX() - ctx->x;
f32 tabPixel = tabWidth * charWidth;
int numTab = static_cast<int>(dx / tabPixel) + 1;
f32 x = ctx->x + (tabPixel * numTab);
writer.SetCursorX(x);
}
template <typename T>
void TagProcessorBase<T>::ProcessLinefeed(PrintContext<T> *ctx) {
TextWriterBase<T> &writer = *ctx->writer;
f32 x = ctx->x;
f32 y = writer.GetCursorY() + writer.GetLineHeight();
writer.SetCursorX(x);
writer.SetCursorY(y);
}
template class TagProcessorBase<char>;
template class TagProcessorBase<wchar_t>;
} // namespace ut
} // namespace nw4r