diff --git a/include/d/d_textunk.h b/include/d/d_textunk.h index 90e2a4d4..a76d5c99 100644 --- a/include/d/d_textunk.h +++ b/include/d/d_textunk.h @@ -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; diff --git a/include/d/lyt/msg_window/d_lyt_msg_window_link.h b/include/d/lyt/msg_window/d_lyt_msg_window_link.h index ffb99c91..f392c417 100644 --- a/include/d/lyt/msg_window/d_lyt_msg_window_link.h +++ b/include/d/lyt/msg_window/d_lyt_msg_window_link.h @@ -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; diff --git a/include/d/lyt/msg_window/d_lyt_msg_window_sword.h b/include/d/lyt/msg_window/d_lyt_msg_window_sword.h index 268a5bf5..ae9a40b8 100644 --- a/include/d/lyt/msg_window/d_lyt_msg_window_sword.h +++ b/include/d/lyt/msg_window/d_lyt_msg_window_sword.h @@ -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; diff --git a/include/d/lyt/msg_window/d_lyt_msg_window_talk.h b/include/d/lyt/msg_window/d_lyt_msg_window_talk.h index f7770bfa..3cbed7e2 100644 --- a/include/d/lyt/msg_window/d_lyt_msg_window_talk.h +++ b/include/d/lyt/msg_window/d_lyt_msg_window_talk.h @@ -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; diff --git a/src/d/d_message.cpp b/src/d/d_message.cpp index f0c01978..8b6d7669 100644 --- a/src/d/d_message.cpp +++ b/src/d/d_message.cpp @@ -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; diff --git a/src/d/d_textunk.cpp b/src/d/d_textunk.cpp index 49cbc58f..6df9b060 100644 --- a/src/d/d_textunk.cpp +++ b/src/d/d_textunk.cpp @@ -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; } diff --git a/src/d/lyt/msg_window/d_lyt_msg_window.cpp b/src/d/lyt/msg_window/d_lyt_msg_window.cpp index cd8f210c..2e043f0b 100644 --- a/src/d/lyt/msg_window/d_lyt_msg_window.cpp +++ b/src/d/lyt/msg_window/d_lyt_msg_window.cpp @@ -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(""); } diff --git a/src/d/lyt/msg_window/d_lyt_msg_window_link.cpp b/src/d/lyt/msg_window/d_lyt_msg_window_link.cpp index e966279c..a53f0345 100644 --- a/src/d/lyt/msg_window/d_lyt_msg_window_link.cpp +++ b/src/d/lyt/msg_window/d_lyt_msg_window_link.cpp @@ -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); diff --git a/src/d/lyt/msg_window/d_lyt_msg_window_sword.cpp b/src/d/lyt/msg_window/d_lyt_msg_window_sword.cpp index e74bde12..7a7e755c 100644 --- a/src/d/lyt/msg_window/d_lyt_msg_window_sword.cpp +++ b/src/d/lyt/msg_window/d_lyt_msg_window_sword.cpp @@ -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]; diff --git a/src/d/lyt/msg_window/d_lyt_msg_window_talk.cpp b/src/d/lyt/msg_window/d_lyt_msg_window_talk.cpp index 8cdf182e..56565beb 100644 --- a/src/d/lyt/msg_window/d_lyt_msg_window_talk.cpp +++ b/src/d/lyt/msg_window/d_lyt_msg_window_talk.cpp @@ -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);