From a5b91ef55dbad74c82ffdfee028ff77b8355fe29 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sat, 5 Apr 2025 23:29:00 +0200 Subject: [PATCH] get - idk --- config/SOUE01/symbols.txt | 4 +- .../d/lyt/msg_window/d_lyt_msg_window_get.h | 12 +- src/d/lyt/msg_window/d_lyt_msg_window_get.cpp | 235 ++++++++++++++++++ 3 files changed, 243 insertions(+), 8 deletions(-) create mode 100644 src/d/lyt/msg_window/d_lyt_msg_window_get.cpp diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 598b5153..1e587e2b 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -32214,8 +32214,8 @@ lbl_8051D3A0 = .data:0x8051D3A0; // type:object size:0x10 lbl_8051D3B0 = .data:0x8051D3B0; // type:object size:0x10 lbl_8051D3C0 = .data:0x8051D3C0; // type:object size:0xC lbl_8051D3CC = .data:0x8051D3CC; // type:object size:0x14 -__vt__18dLytMsgWindowGet_c = .data:0x8051D3E0; // type:object size:0x160 -__vt__33sFStateID_c<18dLytMsgWindowGet_c> = .data:0x8051D540; // type:object size:0x38 +__vt__18dLytMsgWindowGet_c = .data:0x8051D3E0; // type:object size:0x44 +__vt__33sFStateID_c<18dLytMsgWindowGet_c> = .data:0x8051D540; // type:object size:0x34 lbl_8051D578 = .data:0x8051D578; // type:object size:0x1C lbl_8051D594 = .data:0x8051D594; // type:object size:0xC lbl_8051D5A0 = .data:0x8051D5A0; // type:object size:0x1C diff --git a/include/d/lyt/msg_window/d_lyt_msg_window_get.h b/include/d/lyt/msg_window/d_lyt_msg_window_get.h index fbfa1f6a..c9109841 100644 --- a/include/d/lyt/msg_window/d_lyt_msg_window_get.h +++ b/include/d/lyt/msg_window/d_lyt_msg_window_get.h @@ -25,16 +25,16 @@ public: /* vt 0x28 */ virtual bool isDoneClosing() const override; /* vt 0x2C */ virtual bool setText(const wchar_t *text) override; /* vt 0x30 */ virtual dTextBox_c *getTextBox() override { - return nullptr; + return mpTextboxes[0]; } /* vt 0x34 */ virtual bool startConfirm() override { - return true; + return mBtn.requestIn(); } /* vt 0x38 */ virtual bool startDecide(bool b) override { - return true; + return mBtn.requestOut(b); } /* vt 0x3C */ virtual bool isDoneDecide() const override { - return true; + return mBtn.isDoneOut(); } STATE_FUNC_DECLARE(dLytMsgWindowGet_c, Invisible); @@ -57,9 +57,9 @@ private: /* 0x0528 */ dTextBox_c *mpTextboxes[2]; /* 0x0530 */ nw4r::lyt::Pane *mpPanes[6]; /* 0x0548 */ dTagProcessor_c *mpTagProcessor; - /* 0x054C */ u8 _0x054C[8]; + /* 0x054C */ LytVec2f mOffset; /* 0x0554 */ dLytCommonABtn_c mBtn; - /* 0x06E8 */ dLytTextLight mText; + /* 0x06E0 */ dLytTextLight mText; /* 0x07C4 */ MsgWindowBlurRelated mBlurRelated; /* 0x55B8 */ bool mShouldBeOpen; diff --git a/src/d/lyt/msg_window/d_lyt_msg_window_get.cpp b/src/d/lyt/msg_window/d_lyt_msg_window_get.cpp new file mode 100644 index 00000000..ca18221a --- /dev/null +++ b/src/d/lyt/msg_window/d_lyt_msg_window_get.cpp @@ -0,0 +1,235 @@ +#include "d/lyt/msg_window/d_lyt_msg_window_get.h" + +#include "common.h" +#include "d/d_tag_processor.h" +#include "d/lyt/d2d.h" +#include "d/lyt/d_textbox.h" +#include "d/lyt/msg_window/d_lyt_msg_window_common.h" +#include "nw4r/lyt/lyt_group.h" +#include "nw4r/lyt/lyt_pane.h" +#include "s/s_State.hpp" + +STATE_DEFINE(dLytMsgWindowGet_c, Invisible); +STATE_DEFINE(dLytMsgWindowGet_c, In); +STATE_DEFINE(dLytMsgWindowGet_c, Visible); +STATE_DEFINE(dLytMsgWindowGet_c, Out); + +static const d2d::LytBrlanMapping brlanMap[] = { + { "getWindow_00_in.brlan", "G_inOut_00"}, + { "getWindow_00_out.brlan", "G_inOut_00"}, + {"getWindow_00_loop.brlan", "G_loop_00"}, +}; + +#define GET_ANIM_IN 0 +#define GET_ANIM_OUT 1 +#define GET_ANIM_LOOP 2 + +#define GET_NUM_ANIMS 3 + +static const char *sPanes[] = { + "N_window_00", "P_light_03", "P_light_02", "N_message_00", "N_aBtn_00", "N_inOut_00", +}; + +static const char *sTextBoxes[] = { + "T_message_00", + "T_messageS_00", +}; + +static const char *sGroupName = "G_ref_00"; + +bool dLytMsgWindowGet_c::build(d2d::ResAccIf_c *resAcc1, d2d::ResAccIf_c *resAcc, dTagProcessor_c *tagProcessor) { + mLyt.setResAcc(resAcc); + mLyt.build("getWindow_00.brlyt", nullptr); + mLyt.setPriority(0x8A); + + for (int i = 0; i < GET_NUM_ANIMS; i++) { + mAnm[i].init(brlanMap[i].mFile, resAcc, mLyt.getLayout(), brlanMap[i].mName); + mAnm[i].bind(false); + mAnm[i].setAnimEnable(false); + } + + mAnm[GET_ANIM_LOOP].setAnimEnable(true); + mAnm[GET_ANIM_OUT].setAnimEnable(true); + mAnm[GET_ANIM_OUT].setToEnd(); + mLyt.calc(); + mAnm[GET_ANIM_OUT].setAnimEnable(false); + + for (int i = 0; i < 6; i++) { + mpPanes[i] = mLyt.findPane(sPanes[i]); + } + + for (int i = 0; i < 2; i++) { + mpTextboxes[i] = mLyt.getTextBox(sTextBoxes[i]); + mpTextboxes[i]->SetTextPositionH(0); + mpTextboxes[i]->SetTextPositionV(0); + } + + mpTextboxes[1]->set0x1F6(1); + + for (int i = 0; i < 1; i++) { + mNodes[i].mpLytPane = &mBtn; + mBtn.build(resAcc); + mSubpaneList.PushBack(&mNodes[i]); + } + + if (mLyt.getLayout()->GetGroupContainer() != nullptr) { + nw4r::lyt::Group *g = mLyt.getLayout()->GetGroupContainer()->FindGroupByName(sGroupName); + if (g != nullptr) { + d2d::dSubPane::linkMeters(g, &mSubpaneList); + } + } + + mText.build(resAcc, dLytTextLight::NORMAL); + mBlurRelated.build(); + + mpPanes[5]->SetVisible(true); + mLyt.calc(); + mpPanes[5]->SetVisible(false); + mpTagProcessor = tagProcessor; + mOffset.x = mOffset.y = 0.0f; + mStateMgr.changeState(StateID_Invisible); + return true; +} + +bool dLytMsgWindowGet_c::remove() { + mText.remove(); + + for (d2d::SubPaneList::Iterator it = mSubpaneList.GetBeginIter(); it != mSubpaneList.GetEndIter(); ++it) { + d2d::dSubPane *subPane = it->mpLytPane; + if (subPane != nullptr) { + nw4r::lyt::Pane *parent = subPane->getPane()->GetParent(); + parent->RemoveChild(subPane->getPane()); + } + } + + for (int i = 0; i < 1; i++) { + mNodes[i].mpLytPane->remove(); + } + mBtn.remove(); + for (int i = 0; i < GET_NUM_ANIMS; i++) { + mAnm[i].remove(); + } + return true; +} + +void dLytMsgWindowGet_c::initializeState_Invisible() { + mBtn.resetToInvisble(); +} +void dLytMsgWindowGet_c::executeState_Invisible() { + if (mShouldBeOpen) { + mStateMgr.changeState(StateID_In); + } +} +void dLytMsgWindowGet_c::finalizeState_Invisible() {} + +void dLytMsgWindowGet_c::initializeState_In() { + mAnm[GET_ANIM_IN].setAnimEnable(true); + mAnm[GET_ANIM_IN].setFrame(0.0f); +} +void dLytMsgWindowGet_c::executeState_In() { + if (mAnm[GET_ANIM_IN].isEndReached()) { + mAnm[GET_ANIM_IN].setAnimEnable(false); + mStateMgr.changeState(StateID_Visible); + } +} +void dLytMsgWindowGet_c::finalizeState_In() {} + +void dLytMsgWindowGet_c::initializeState_Visible() { + nw4r::lyt::Size size = getTextBox()->GetSize(); + nw4r::lyt::Size fontSize = getTextBox()->GetFontSize(); + nw4r::math::MTX34 transform = getTextBox()->GetGlobalMtx(); + + mOffset.x = transform._03 - size.width / 2.0f; + mOffset.y = transform._13 + size.height / 2.0f; +} +void dLytMsgWindowGet_c::executeState_Visible() { + if (!mShouldBeOpen) { + mStateMgr.changeState(StateID_Out); + } +} +void dLytMsgWindowGet_c::finalizeState_Visible() {} + +void dLytMsgWindowGet_c::initializeState_Out() { + mAnm[GET_ANIM_OUT].setAnimEnable(true); + mAnm[GET_ANIM_OUT].setFrame(0.0f); +} +void dLytMsgWindowGet_c::executeState_Out() { + if (mAnm[GET_ANIM_OUT].isEndReached()) { + mAnm[GET_ANIM_OUT].setAnimEnable(false); + mStateMgr.changeState(StateID_Invisible); + } +} +void dLytMsgWindowGet_c::finalizeState_Out() {} + +bool dLytMsgWindowGet_c::execute() { + mStateMgr.executeState(); + for (int i = 0; i < GET_NUM_ANIMS; i++) { + if (mAnm[i].isEnabled()) { + mAnm[i].play(); + } + } + mLyt.calc(); + for (int i = 0; i < 1; i++) { + mNodes[i].mpLytPane->execute(); + } + return true; +} + +void dLytMsgWindowGet_c::draw() { + // NONMATCHING + // The instruction patterns here are the same that EGG::StateGX::Scoped + // generates, but there's no RAII to be found here. What's the missing + // link that makes the compiler generate these? + bool bVis0 = mpPanes[0]->IsVisible(); + bool bVis1 = mpPanes[1]->IsVisible(); + bool bVis2 = mpPanes[2]->IsVisible(); + bool bVis3 = mpPanes[3]->IsVisible(); + bool bVis4 = mpPanes[4]->IsVisible(); + + mpPanes[0]->SetVisible(bVis0); + mpPanes[1]->SetVisible(bVis1); + mpPanes[2]->SetVisible(bVis2); + mpPanes[3]->SetVisible(false); + mpPanes[4]->SetVisible(false); + + mLyt.draw(); + mBlurRelated.drawTextBlur(&mText, mOffset, mpPanes[5]->GetAlpha()); + + mpPanes[0]->SetVisible(false); + mpPanes[1]->SetVisible(false); + mpPanes[2]->SetVisible(false); + mpPanes[3]->SetVisible(bVis3); + mpPanes[4]->SetVisible(bVis4); + + mLyt.draw(); + + mpPanes[0]->SetVisible(bVis0); + mpPanes[1]->SetVisible(bVis1); + mpPanes[2]->SetVisible(bVis2); + mpPanes[3]->SetVisible(bVis3); + mpPanes[4]->SetVisible(bVis4); +} + +void dLytMsgWindowGet_c::open(dAcObjBase_c *obj, u32 param) { + mShouldBeOpen = true; +} + +bool dLytMsgWindowGet_c::isDoneOpening() const { + return !(*mStateMgr.getStateID() == StateID_In); +} + +void dLytMsgWindowGet_c::close() { + mShouldBeOpen = false; +} + +bool dLytMsgWindowGet_c::isDoneClosing() const { + return !(*mStateMgr.getStateID() == StateID_Out); +} + +bool dLytMsgWindowGet_c::setText(const wchar_t *text) { + mpTextboxes[0]->SetTagProcessor(mpTagProcessor); + mpTextboxes[1]->SetTagProcessor(mpTagProcessor); + mpTextboxes[0]->setTextWithTextProcessor(text, mpTagProcessor, 0); + mpTextboxes[1]->setTextWithTextProcessor(text, mpTagProcessor, 0); + return true; +}