Some cleanup

This commit is contained in:
robojumper
2025-04-07 00:00:36 +02:00
parent d14d64ef67
commit fe32ad126e
10 changed files with 83 additions and 96 deletions
+28 -33
View File
@@ -7,6 +7,13 @@
#include "nw4r/ut/ut_Color.h"
#include "sized_string.h"
/**
* This class appears to be the remnant of a sort of "hot-reloading"
* mechanism for the game's user interface. Many of the functions
* affect text formatting, UI layouting, and it also has mechanisms
* for overriding the text and flow files being accessed. The actual
* implementation appears to have been stripped out though.
*/
class UnkTextThing {
public:
UnkTextThing();
@@ -113,44 +120,32 @@ public:
return sInstance;
}
void reset0(const char *str) {
field_0x004 = str;
s16 getMsgWindowWaitDelay() const {
return mMsgWindowWaitDelay;
}
void reset1(const char *str) {
field_0x084 = str;
bool getShouldOverrideData() const {
return mShouldOverrideData;
}
void reset2(const char *str) {
field_0x104 = str;
void *getOverrideZev0() const {
return mOverrideZev0;
}
s16 getField_0x7AE() const {
return field_0x7AE;
void *getOverrideStageZev() const {
return mOverrideStageZev;
}
bool getField_0x7B4() const {
return field_0x7B4;
bool getShouldHookAllocations() const {
return mShouldHookAllocations;
}
void *getField_0x74C() const {
return field_0x74C;
MsbtInfo *getOverrideMsbtInfo(s32 index) const {
return mMsbts[index];
}
void *getField_0x750() const {
return field_0x750;
}
bool getField_0x7B6() const {
return field_0x7B6;
}
MsbtInfo *getMsbtInfo(s32 index) const {
return field_buf2[index];
}
MsbfInfo *getMsbfInfo(s32 index) const {
return field_buf3[index];
MsbfInfo *getOverrideMsbfInfo(s32 index) const {
return mMsbfs[index];
}
const char *getStr1() const {
@@ -204,11 +199,11 @@ private:
/* 0x184 */ void *field_buf0[82];
/* 0x2CC */ void *field_buf4[23];
/* 0x328 */ void *field_buf1[80];
/* 0x468 */ MsbtInfo *field_buf2[82];
/* 0x468 */ MsbtInfo *mMsbts[82];
/* 0x5B0 */ MsbtInfo *field_buf5[23];
/* 0x60C */ MsbfInfo *field_buf3[80];
/* 0x74C */ void *field_0x74C;
/* 0x750 */ void *field_0x750;
/* 0x60C */ MsbfInfo *mMsbfs[80];
/* 0x74C */ void *mOverrideZev0;
/* 0x750 */ void *mOverrideStageZev;
/* 0x754 */ f32 field_0x754;
/* 0x758 */ f32 field_0x758;
/* 0x75C */ f32 field_0x75C;
@@ -235,13 +230,13 @@ private:
/* 0x7A8 */ s16 field_0x7A8;
/* 0x7AA */ s16 field_0x7AA;
/* 0x7AC */ s16 field_0x7AC;
/* 0x7AE */ s16 field_0x7AE;
/* 0x7AE */ s16 mMsgWindowWaitDelay;
/* 0x7B0 */ s16 field_0x7B0;
/* 0x7B2 */ bool field_0x7B2;
/* 0x7B3 */ bool field_0x7B3;
/* 0x7B4 */ bool field_0x7B4;
/* 0x7B4 */ bool mShouldOverrideData;
/* 0x7B5 */ bool field_0x7B5;
/* 0x7B6 */ bool field_0x7B6;
/* 0x7B6 */ bool mShouldHookAllocations;
/* 0x7B6 */ bool field_0x7B7;
/* 0x7B8 */ nw4r::ut::Color field_0x7B8;
/* 0x7BC */ nw4r::ut::Color field_0x7BC;
@@ -63,7 +63,7 @@ private:
/* 0x05AC */ mVec2_c mOffset;
/* 0x05B4 */ dAcObjBase_c *mpActor;
/* 0x05B8 */ s32 mParam;
/* 0x05BC */ s32 field_0x05BC;
/* 0x05BC */ s32 mWaitDelay;
/* 0x05C0 */ dLytCommonABtn_c mBtn;
/* 0x0770 */ dLytTextLight mText;
/* 0x084C */ MsgWindowBlurRelated mBlurRelated;
@@ -67,13 +67,12 @@ private:
/* 0x05CC */ mVec3_c mTranslationTo;
/* 0x05D8 */ mVec3_c mTranslationFrom;
/* 0x05E4 */ f32 field_0x05E4;
/* 0x05E8 */ f32 field_0x05E8;
/* 0x05E4 */ mVec2_c mOffset;
/* 0x05EC */ dAcObjBase_c *mpActor;
/* 0x05F0 */ s32 mParam;
/* 0x05F4 */ s32 field_0x5F4;
/* 0x05F4 */ s32 mWaitDelay;
/* 0x05F8 */ dLytCommonABtn_c mBtn;
@@ -64,7 +64,7 @@ private:
/* 0x05AC */ mVec2_c mOffset;
/* 0x05B4 */ dAcObjBase_c *mpActor;
/* 0x05B8 */ s32 mParam;
/* 0x05BC */ s32 field_0x05BC;
/* 0x05BC */ s32 mWaitDelay;
/* 0x05C0 */ dLytCommonABtn_c mBtn;
/* 0x0770 */ dLytTextLight mText;
/* 0x084C */ MsgWindowBlurRelated mBlurRelated;
+10 -10
View File
@@ -194,7 +194,7 @@ dMessage_c *dMessage_c::sInstance;
dTagProcessor_c *dMessage_c::sTagProcessor;
static void *msbAlloc(size_t size) {
if (UnkTextThing::getInstance()->getField_0x7B6() == false) {
if (UnkTextThing::getInstance()->getShouldHookAllocations() == false) {
return EGG::Heap::alloc(size, 0x20, nullptr);
} else {
return UnkTextThing::getInstance()->allocUnk(size, 0x20);
@@ -202,7 +202,7 @@ static void *msbAlloc(size_t size) {
}
static void msbFree(void *ptr) {
if (UnkTextThing::getInstance()->getField_0x7B6() == false) {
if (UnkTextThing::getInstance()->getShouldHookAllocations() == false) {
EGG::Heap::free(ptr, nullptr);
} else {
UnkTextThing::getInstance()->destroyUnk(ptr);
@@ -454,8 +454,8 @@ MsbtInfo *dMessage_c::getMsbtInfoForIndex(s32 index) {
MsbtInfo *dMessage_c::getMsbtInfoForIndexInternal(s32 index) {
UnkTextThing *thing = UnkTextThing::getInstance();
MsbtInfo *overrideMsbt = thing->getMsbtInfo(index);
if (overrideMsbt != nullptr && thing->getField_0x7B4() == true) {
MsbtInfo *overrideMsbt = thing->getOverrideMsbtInfo(index);
if (overrideMsbt != nullptr && thing->getShouldOverrideData() == true) {
return overrideMsbt;
}
return mpMsgs[index];
@@ -467,8 +467,8 @@ MsbfInfo *dMessage_c::getMsbfInfoForIndex(s32 index) {
MsbfInfo *dMessage_c::getMsbfInfoForIndexInternal(s32 index) {
UnkTextThing *thing = UnkTextThing::getInstance();
MsbfInfo *overrideMsbf = thing->getMsbfInfo(index);
if (overrideMsbf != nullptr && thing->getField_0x7B4() == true) {
MsbfInfo *overrideMsbf = thing->getOverrideMsbfInfo(index);
if (overrideMsbf != nullptr && thing->getShouldOverrideData() == true) {
return overrideMsbf;
}
return mpFlows[index];
@@ -535,8 +535,8 @@ void *dMessage_c::sZevStage;
void *dMessage_c::getZev0Internal() {
UnkTextThing *thing = UnkTextThing::getInstance();
void *overrideZev = thing->getField_0x74C();
if (overrideZev != nullptr && thing->getField_0x7B4() == true) {
void *overrideZev = thing->getOverrideZev0();
if (overrideZev != nullptr && thing->getShouldOverrideData() == true) {
return overrideZev;
}
return sZev0;
@@ -544,8 +544,8 @@ void *dMessage_c::getZev0Internal() {
void *dMessage_c::getZevStageInternal() {
UnkTextThing *thing = UnkTextThing::getInstance();
void *overrideZev = thing->getField_0x750();
if (overrideZev != nullptr && thing->getField_0x7B4() == true) {
void *overrideZev = thing->getOverrideStageZev();
if (overrideZev != nullptr && thing->getShouldOverrideData() == true) {
return overrideZev;
}
return sZevStage;
+25 -31
View File
@@ -36,7 +36,7 @@ UnkTextThing::UnkTextThing() {
for (int i = 0; i < 82; i++) {
field_buf0[i] = 0;
field_buf2[i] = 0;
mMsbts[i] = 0;
}
for (int i = 0; i < 23; i++) {
@@ -46,25 +46,25 @@ UnkTextThing::UnkTextThing() {
for (int i = 0; i < 80; i++) {
field_buf1[i] = 0;
field_buf3[i] = 0;
mMsbfs[i] = 0;
}
field_0x74C = 0;
field_0x750 = 0;
mOverrideZev0 = nullptr;
mOverrideStageZev = nullptr;
field_0x7B4 = false;
mShouldOverrideData = false;
field_0x7B5 = false;
field_0x004 = "";
field_0x084 = "";
field_0x104 = "";
field_0x7B6 = 0;
mShouldHookAllocations = false;
field_0x7A8 = 0;
field_0x788 = 0.45;
field_0x78C = -5.0f;
field_0x7AE = 4;
mMsgWindowWaitDelay = 4;
field_0x7B7 = 0;
field_0x7AA = 5;
field_0x7AC = 15;
@@ -72,14 +72,8 @@ UnkTextThing::UnkTextThing() {
field_0x7B2 = false;
// Weird init order
field_0x7B8.a = 0;
field_0x7B8.b = 0;
field_0x7B8.g = 0;
field_0x7B8.r = 0;
field_0x7BC.a = 0;
field_0x7BC.b = 0;
field_0x7BC.g = 0;
field_0x7BC.r = 0;
field_0x7B8.r = field_0x7B8.g = field_0x7B8.b = field_0x7B8.a = 0;
field_0x7BC.r = field_0x7BC.g = field_0x7BC.b = field_0x7BC.a = 0;
field_0x790 = -1.0f;
field_0x794 = 100.0f;
@@ -92,9 +86,9 @@ void UnkTextThing::destroy() {
field_buf0[i] = nullptr;
}
if (field_buf2[i] != nullptr) {
destroyMsg(field_buf2[i]);
field_buf2[i] = nullptr;
if (mMsbts[i] != nullptr) {
destroyMsg(mMsbts[i]);
mMsbts[i] = nullptr;
}
}
@@ -116,20 +110,20 @@ void UnkTextThing::destroy() {
field_buf1[i] = nullptr;
}
if (field_buf3[i] != nullptr) {
destroyFlow(field_buf3[i]);
field_buf3[i] = nullptr;
if (mMsbfs[i] != nullptr) {
destroyFlow(mMsbfs[i]);
mMsbfs[i] = nullptr;
}
}
if (field_0x74C != nullptr) {
destroyUnk(field_0x74C);
field_0x74C = nullptr;
if (mOverrideZev0 != nullptr) {
destroyUnk(mOverrideZev0);
mOverrideZev0 = nullptr;
}
if (field_0x750 != nullptr) {
destroyUnk(field_0x750);
field_0x750 = nullptr;
if (mOverrideStageZev != nullptr) {
destroyUnk(mOverrideStageZev);
mOverrideStageZev = nullptr;
}
}
@@ -176,13 +170,13 @@ f32 UnkTextThing::fn_800B2040() {
}
void UnkTextThing::destroyMsg(MsbtInfo *msg) {
field_0x7B6 = true;
mShouldHookAllocations = true;
LMS_CloseMessage(msg);
field_0x7B6 = false;
mShouldHookAllocations = false;
}
void UnkTextThing::destroyFlow(MsbfInfo *flow) {
field_0x7B6 = true;
mShouldHookAllocations = true;
LMS_CloseFlow(flow);
field_0x7B6 = false;
mShouldHookAllocations = false;
}
+3 -3
View File
@@ -852,7 +852,7 @@ void dLytMsgWindow_c::removeSubMsgManagers() {
mpCurrentSubtype = nullptr;
field_0x1220 = 0;
UnkTextThing::getInstance()->reset1("");
UnkTextThing::getInstance()->reset0("");
UnkTextThing::getInstance()->reset2("");
UnkTextThing::getInstance()->setStr2("");
UnkTextThing::getInstance()->setStr1("");
UnkTextThing::getInstance()->setStr3("");
}
@@ -99,7 +99,7 @@ bool dLytMsgWindowLink_c::build(d2d::ResAccIf_c *resAcc1, d2d::ResAccIf_c *resAc
mOffset.x = mOffset.y = 0.0f;
field_0x05BC = 0;
mWaitDelay = 0;
mStateMgr.changeState(StateID_Invisible);
return true;
@@ -172,10 +172,10 @@ void dLytMsgWindowLink_c::executeState_In() {
void dLytMsgWindowLink_c::finalizeState_In() {}
void dLytMsgWindowLink_c::initializeState_Wait() {
field_0x05BC = UnkTextThing::getInstance()->getField_0x7AE();
mWaitDelay = UnkTextThing::getInstance()->getMsgWindowWaitDelay();
}
void dLytMsgWindowLink_c::executeState_Wait() {
if (--field_0x05BC > 0) {
if (--mWaitDelay > 0) {
return;
}
mStateMgr.changeState(StateID_Visible);
@@ -117,9 +117,8 @@ bool dLytMsgWindowSword_c::build(d2d::ResAccIf_c *resAcc1, d2d::ResAccIf_c *resA
mTranslationFrom.copyFrom(mpPanes[2]->GetTranslate());
mParam = 0;
field_0x05E8 = 0.0f;
field_0x05E4 = 0.0f;
field_0x5F4 = 0;
mOffset.x = mOffset.y = 0.0f;
mWaitDelay = 0;
mHasDrawnThisTick = false;
@@ -196,10 +195,10 @@ void dLytMsgWindowSword_c::executeState_In() {
void dLytMsgWindowSword_c::finalizeState_In() {}
void dLytMsgWindowSword_c::initializeState_Wait() {
field_0x5F4 = UnkTextThing::getInstance()->getField_0x7AE();
mWaitDelay = UnkTextThing::getInstance()->getMsgWindowWaitDelay();
}
void dLytMsgWindowSword_c::executeState_Wait() {
if (--field_0x5F4 > 0) {
if (--mWaitDelay > 0) {
return;
}
mStateMgr.changeState(StateID_Visible);
@@ -211,8 +210,8 @@ void dLytMsgWindowSword_c::initializeState_Visible() {
nw4r::lyt::Size fontSize = getTextBox()->GetFontSize(); // unused
nw4r::math::MTX34 transform = getTextBox()->GetGlobalMtx();
field_0x05E4 = transform._03 - size.width / 2;
field_0x05E8 = transform._13 + size.height / 2;
mOffset.x = transform._03 - size.width / 2;
mOffset.y = transform._13 + size.height / 2;
getTextBox()->GetTextDrawRect(); // unused
}
@@ -272,7 +271,7 @@ void dLytMsgWindowSword_c::draw() {
mCharacterData[i].displayTimerMaybe += 1;
}
mVec3_c v(
(field_0x05E4 + mCharacterData[i].posX) / get_805751A4(), field_0x05E8 + mCharacterData[i].posY, 0.0f
(mOffset.x + mCharacterData[i].posX) / get_805751A4(), mOffset.y + mCharacterData[i].posY, 0.0f
);
wchar_t str[2];
@@ -99,7 +99,7 @@ bool dLytMsgWindowTalk_c::build(d2d::ResAccIf_c *resAcc1, d2d::ResAccIf_c *resAc
mOffset.x = mOffset.y = 0.0f;
field_0x05BC = 0;
mWaitDelay = 0;
mStateMgr.changeState(StateID_Invisible);
return true;
@@ -172,10 +172,10 @@ void dLytMsgWindowTalk_c::executeState_In() {
void dLytMsgWindowTalk_c::finalizeState_In() {}
void dLytMsgWindowTalk_c::initializeState_Wait() {
field_0x05BC = UnkTextThing::getInstance()->getField_0x7AE();
mWaitDelay = UnkTextThing::getInstance()->getMsgWindowWaitDelay();
}
void dLytMsgWindowTalk_c::executeState_Wait() {
if (--field_0x05BC > 0) {
if (--mWaitDelay > 0) {
return;
}
mStateMgr.changeState(StateID_Visible);