diff --git a/config/43U/symbols.txt b/config/43U/symbols.txt index 2ab7fbb1..ac0c840e 100644 --- a/config/43U/symbols.txt +++ b/config/43U/symbols.txt @@ -4837,48 +4837,48 @@ onEvent__Q33ipl5scene22SDMenuEventHandlerBaseFUlUlPv = .text:0x813EB51C; // type onEventDerived__Q33ipl5scene22SDMenuEventHandlerBaseFUlUlPCQ33ipl10controller9Interface = .text:0x813EB5E8; // type:function size:0x4 __ct__Q33ipl5scene8SDMemoryFv = .text:0x813EB5EC; // type:function size:0x48 __dt__Q33ipl5scene8SDMemoryFv = .text:0x813EB634; // type:function size:0x5C -iplSDMemory_813EB690 = .text:0x813EB690; // type:function size:0x10A0 -iplSDMemory_813EC730 = .text:0x813EC730; // type:function size:0xD4 -iplSDMemory_813EC804 = .text:0x813EC804; // type:function size:0x144 -iplSDMemory_813EC948 = .text:0x813EC948; // type:function size:0x20 -iplSDMemory_813EC968 = .text:0x813EC968; // type:function size:0x84 -iplSDMemory_813EC9EC = .text:0x813EC9EC; // type:function size:0x9C -iplSDMemory_813ECA88 = .text:0x813ECA88; // type:function size:0x74 -iplSDMemory_813ECAFC = .text:0x813ECAFC; // type:function size:0x74 -iplSDMemory_813ECB70 = .text:0x813ECB70; // type:function size:0x78 -iplSDMemory_813ECBE8 = .text:0x813ECBE8; // type:function size:0x78 -iplSDMemory_813ECC60 = .text:0x813ECC60; // type:function size:0x160 -iplSDMemory_813ECDC0 = .text:0x813ECDC0; // type:function size:0x60 -iplSDMemory_813ECE20 = .text:0x813ECE20; // type:function size:0x60 -iplSDMemory_813ECE80 = .text:0x813ECE80; // type:function size:0x64 -iplSDMemory_813ECEE4 = .text:0x813ECEE4; // type:function size:0x64 -iplSDMemory_813ECF48 = .text:0x813ECF48; // type:function size:0x13C -iplSDMemory_813ED084 = .text:0x813ED084; // type:function size:0x268 -iplSDMemory_813ED2EC = .text:0x813ED2EC; // type:function size:0x4CC -iplSDMemory_813ED7B8 = .text:0x813ED7B8; // type:function size:0xA4 -iplSDMemory_813ED85C = .text:0x813ED85C; // type:function size:0xC4 -iplSDMemory_813ED920 = .text:0x813ED920; // type:function size:0x124 -iplSDMemory_813EDA44 = .text:0x813EDA44; // type:function size:0x110 -iplSDMemory_813EDB54 = .text:0x813EDB54; // type:function size:0x78 -iplSDMemory_813EDBCC = .text:0x813EDBCC; // type:function size:0xC0 -iplSDMemory_813EDC8C = .text:0x813EDC8C; // type:function size:0x278 -iplSDMemory_813EDF04 = .text:0x813EDF04; // type:function size:0xA4 -iplSDMemory_813EDFA8 = .text:0x813EDFA8; // type:function size:0x130 -iplSDMemory_813EE0D8 = .text:0x813EE0D8; // type:function size:0xE0 -iplSDMemory_813EE1B8 = .text:0x813EE1B8; // type:function size:0x1A0 +create__Q33ipl5scene8SDMemoryFPQ23EGG4HeapPQ33ipl4nand10LayoutFilePQ33ipl5scene17NandSDCardManager = .text:0x813EB690; // type:function size:0x10A0 +setTitleLists__Q33ipl5scene8SDMemoryFRCQ43ipl5scene8SDMemory10TitleRangeRCQ43ipl5scene8SDMemory10TitleRange = .text:0x813EC730; // type:function size:0xD4 +setScrollLimit__Q33ipl5scene8SDMemoryFv = .text:0x813EC804; // type:function size:0x144 +init__Q33ipl7utility8ScrollerFv = .text:0x813EC948; // type:function size:0x20 +resetScrollArrows__Q33ipl5scene8SDMemoryFv = .text:0x813EC968; // type:function size:0x84 +updateScrollArrows__Q33ipl5scene8SDMemoryFUlUlUlUl = .text:0x813EC9EC; // type:function size:0x9C +showDownArrow__Q33ipl5scene8SDMemoryFv = .text:0x813ECA88; // type:function size:0x74 +showUpArrow__Q33ipl5scene8SDMemoryFv = .text:0x813ECAFC; // type:function size:0x74 +hideDownArrow__Q33ipl5scene8SDMemoryFv = .text:0x813ECB70; // type:function size:0x78 +hideUpArrow__Q33ipl5scene8SDMemoryFv = .text:0x813ECBE8; // type:function size:0x78 +updateSideArrows__Q33ipl5scene8SDMemoryFv = .text:0x813ECC60; // type:function size:0x160 +showLeftArrow__Q33ipl5scene8SDMemoryFv = .text:0x813ECDC0; // type:function size:0x60 +showRightArrow__Q33ipl5scene8SDMemoryFv = .text:0x813ECE20; // type:function size:0x60 +hideLeftArrow__Q33ipl5scene8SDMemoryFv = .text:0x813ECE80; // type:function size:0x64 +hideRightArrow__Q33ipl5scene8SDMemoryFv = .text:0x813ECEE4; // type:function size:0x64 +resetDialogPaneAnimations__Q33ipl5scene8SDMemoryFv = .text:0x813ECF48; // type:function size:0x13C +calc__Q33ipl5scene8SDMemoryFv = .text:0x813ED084; // type:function size:0x268 +updateState__Q33ipl5scene8SDMemoryFv = .text:0x813ED2EC; // type:function size:0x4CC +onDialogState0__Q33ipl5scene8SDMemoryFv = .text:0x813ED7B8; // type:function size:0xA4 +onDialogState2__Q33ipl5scene8SDMemoryFv = .text:0x813ED85C; // type:function size:0xC4 +onDialogState3__Q33ipl5scene8SDMemoryFv = .text:0x813ED920; // type:function size:0x124 +onDialogState4__Q33ipl5scene8SDMemoryFv = .text:0x813EDA44; // type:function size:0x110 +onDialogState6__Q33ipl5scene8SDMemoryFv = .text:0x813EDB54; // type:function size:0x78 +onDialogState7__Q33ipl5scene8SDMemoryFv = .text:0x813EDBCC; // type:function size:0xC0 +onDialogState8__Q33ipl5scene8SDMemoryFv = .text:0x813EDC8C; // type:function size:0x278 +onDialogState9__Q33ipl5scene8SDMemoryFv = .text:0x813EDF04; // type:function size:0xA4 +onDialogState10__Q33ipl5scene8SDMemoryFv = .text:0x813EDFA8; // type:function size:0x130 +onDialogState11__Q33ipl5scene8SDMemoryFv = .text:0x813EE0D8; // type:function size:0xE0 +onDialogState12__Q33ipl5scene8SDMemoryFv = .text:0x813EE1B8; // type:function size:0x1A0 iplSDMemory_813EE358 = .text:0x813EE358; // type:function size:0x44 -iplSDMemory_813EE39C = .text:0x813EE39C; // type:function size:0xEC -iplSDMemory_813EE488 = .text:0x813EE488; // type:function size:0x1C4 -iplSDMemory_813EE64C = .text:0x813EE64C; // type:function size:0x12C -iplSDMemory_813EE778 = .text:0x813EE778; // type:function size:0xA0 -iplSDMemory_813EE818 = .text:0x813EE818; // type:function size:0x128 -iplSDMemory_813EE940 = .text:0x813EE940; // type:function size:0xE8 -iplSDMemory_813EEA28 = .text:0x813EEA28; // type:function size:0x84 -iplSDMemory_813EEAAC = .text:0x813EEAAC; // type:function size:0xE8 -iplSDMemory_813EEB94 = .text:0x813EEB94; // type:function size:0x148 -iplSDMemory_813EECDC = .text:0x813EECDC; // type:function size:0x11C -iplSDMemory_813EEDF8 = .text:0x813EEDF8; // type:function size:0x78 -iplSDMemory_813EEE70 = .text:0x813EEE70; // type:function size:0xC0 +onDialogState13__Q33ipl5scene8SDMemoryFv = .text:0x813EE39C; // type:function size:0xEC +onDialogState14__Q33ipl5scene8SDMemoryFv = .text:0x813EE488; // type:function size:0x1C4 +onDialogState15__Q33ipl5scene8SDMemoryFv = .text:0x813EE64C; // type:function size:0x12C +onDialogState16__Q33ipl5scene8SDMemoryFv = .text:0x813EE778; // type:function size:0xA0 +onDialogState17__Q33ipl5scene8SDMemoryFv = .text:0x813EE818; // type:function size:0x128 +onDialogState18__Q33ipl5scene8SDMemoryFv = .text:0x813EE940; // type:function size:0xE8 +onDialogState19__Q33ipl5scene8SDMemoryFv = .text:0x813EEA28; // type:function size:0x84 +onDialogState20__Q33ipl5scene8SDMemoryFv = .text:0x813EEAAC; // type:function size:0xE8 +onDialogState21__Q33ipl5scene8SDMemoryFv = .text:0x813EEB94; // type:function size:0x148 +onDialogState22__Q33ipl5scene8SDMemoryFv = .text:0x813EECDC; // type:function size:0x11C +onDialogState23__Q33ipl5scene8SDMemoryFv = .text:0x813EEDF8; // type:function size:0x78 +onDialogState24__Q33ipl5scene8SDMemoryFv = .text:0x813EEE70; // type:function size:0xC0 iplSDMemory_813EEF30 = .text:0x813EEF30; // type:function size:0x88 iplSDMemory_813EEFB8 = .text:0x813EEFB8; // type:function size:0x70C iplSDMemory_813EF6C4 = .text:0x813EF6C4; // type:function size:0x14 diff --git a/include/scene/sdChannelMemory/iplSDMemory.h b/include/scene/sdChannelMemory/iplSDMemory.h new file mode 100644 index 00000000..6352f88c --- /dev/null +++ b/include/scene/sdChannelMemory/iplSDMemory.h @@ -0,0 +1,115 @@ +#ifndef IPL_SCENE_SD_MEMORY_H +#define IPL_SCENE_SD_MEMORY_H + +#include + +#include "layout/iplLayout.h" +#include "layout/iplGuiManager.h" +#include "scene/board/iplFocusObject.h" +#include "scene/channelEdit/iplNandSDCardManager.h" + +namespace ipl { + namespace scene { + class SDMemory { + public: + struct TitleRange { + ESTitleId* mpTitles; + u32 mCount; + }; + + SDMemory(); + ~SDMemory(); + + void create(EGG::Heap* heap, nand::LayoutFile* layoutFile, NandSDCardManager* manager); + void setTitleLists(const TitleRange& nandTitles, const TitleRange& sdTitles); + bool calc(); + void setScrollLimit(); + void updateSideArrows(); + void resetScrollArrows(); + void updateScrollArrows(u32 previousDownEnd, u32 previousUpEnd, u32 downEnd, u32 upEnd); + void showDownArrow(); + void showUpArrow(); + void hideDownArrow(); + void hideUpArrow(); + void showLeftArrow(); + void showRightArrow(); + void hideLeftArrow(); + void hideRightArrow(); + + private: + s32 updateState(); + void onDialogState0(); + void onDialogState2(); + bool onDialogState3(); + void onDialogState4(); + void onDialogState6(); + void onDialogState7(); + void onDialogState8(); + void onDialogState9(); + void onDialogState10(); + void onDialogState11(); + void onDialogState12(); + void onDialogState13(); + void onDialogState14(); + void onDialogState15(); + void onDialogState16(); + void onDialogState17(); + void onDialogState18(); + void onDialogState19(); + bool onDialogState20(); + void onDialogState21(); + bool onDialogState22(); + void onDialogState23(); + bool onDialogState24(); + void resetDialogPaneAnimations(); + + layout::Object* mpMainLayout; + layout::Object* mpTitleLayout; + layout::Object* mpDialogLayout; + layout::Object* mpProgressLayout; + gui::PaneManager* mpPaneManagers[3]; + s32 mDialogState; + s32 mProcessState; + s32 mDisplayMode; + s32 mMessageId; + u32 mErrorCode; + u32 mPanelStates[3]; + u32 mTitlePanelStates[5]; + u32 mPanelAnimationStates[4]; + NandSDCardManager* mpNandSDCardManager; + TitleRange mNandTitleRange; + TitleRange mSDTitleRange; + u32 mTitleCount; + u32 mCurrentTitle; + u32 mTitleFlags; + ESTitleId mTitleIds[96]; + wchar_t mTitleNames[96][21]; + u32 mTitleNameCount; + u32 mNandTitleNameCount; + ESTitleId mNandTitleIds[96]; + u32 mNandTitleCount; + u32 mSDTitleCount; + ESTitleId mSDTitleIds[96]; + wchar_t mCurrentTitleName[0x840]; + u8 mTransferFlags[4]; + u32 mTransferStatus; + u64 mTransferStartTime; + s32 mTransferFrame; + struct TitleListState { + ESTitleId* mpTitles; + u32 mCount; + ESTitleId* mpSecondaryTitles; + u32 mSecondaryCount; + ESTitleId* mpNames; + u32 mNameCount; + } mTitleListState; + scroller mScroller; + s32 mButtonState; + u8 mControllerFlags[4]; + u32 mFinalState[3]; + u8 mFinalFlags[4]; + }; + } // namespace scene +} // namespace ipl + +#endif diff --git a/include/system/iplDialogWindow.h b/include/system/iplDialogWindow.h index 4a2498df..5fe75217 100644 --- a/include/system/iplDialogWindow.h +++ b/include/system/iplDialogWindow.h @@ -118,6 +118,10 @@ namespace ipl { int getLastResult() { return mLastResult; } /** @return If the dialog is moving onto the next state. */ bool doingNextState() { return mbNextState; } +#ifdef IPL_SDMEMORY_DIALOG_STATE_ACCESSOR + int getStateForSDMemory() const { return mState; } + int getResultForSDMemory() const { return mResult; } +#endif /*=================*/ /* DIALOG BUTTON 0 */ diff --git a/include/utility/iplScroller.h b/include/utility/iplScroller.h index bbcd685e..fe39e065 100644 --- a/include/utility/iplScroller.h +++ b/include/utility/iplScroller.h @@ -49,6 +49,9 @@ namespace ipl { public: Scroller(); +#ifdef IPL_SDMEMORY_SCROLLER_INIT_OUT_OF_LINE + void init(); +#else void init() { mState = 0; mScroll = 0.0f; @@ -56,6 +59,7 @@ namespace ipl { mUpLimit = 0.0f; mDownLimit = 0.0f; } +#endif void calc(); f32 get() const; diff --git a/libs/NW4R/include/nw4r/lyt/pane.h b/libs/NW4R/include/nw4r/lyt/pane.h index 4f0519af..3bff5dc5 100644 --- a/libs/NW4R/include/nw4r/lyt/pane.h +++ b/libs/NW4R/include/nw4r/lyt/pane.h @@ -88,7 +88,11 @@ namespace nw4r { PaneList& GetChildList() { return mChildList; } const math::VEC3& GetTranslate() { return mTranslate; } +#ifdef IPL_SDMEMORY_SET_TRANSLATE_OUT_OF_LINE + void SetTranslate(const math::VEC3& translate); +#else void SetTranslate(const math::VEC3& translate) { mTranslate = translate; } +#endif void SetTranslate(const math::VEC2& translate) { SetTranslate(math::VEC3(translate.x, translate.y, 0.0f)); } const math::VEC3& GetRotate() const { return mRotate; } diff --git a/src/scene/sdChannelMemory/iplSDMemory.cpp b/src/scene/sdChannelMemory/iplSDMemory.cpp new file mode 100644 index 00000000..eb7cd7d3 --- /dev/null +++ b/src/scene/sdChannelMemory/iplSDMemory.cpp @@ -0,0 +1,681 @@ +#define IPL_SDMEMORY_SCROLLER_INIT_OUT_OF_LINE +#define IPL_SDMEMORY_SET_TRANSLATE_OUT_OF_LINE +#define IPL_SDMEMORY_DIALOG_STATE_ACCESSOR +#include "scene/sdChannelMemory/iplSDMemory.h" +#undef IPL_SDMEMORY_DIALOG_STATE_ACCESSOR +#undef IPL_SDMEMORY_SET_TRANSLATE_OUT_OF_LINE +#undef IPL_SDMEMORY_SCROLLER_INIT_OUT_OF_LINE + +#include "system/iplSystem.h" +#include "sound/iplSound.h" + +namespace ipl { + namespace utility { + void Scroller::init() { + mState = 0; + mScroll = 0.0f; + unk_0x3C = 0.0f; + mUpLimit = 0.0f; + mDownLimit = 0.0f; + } + } + + namespace scene { + static const char* const sControlPaneNames[] = { + "A", "B", "B_BtnA", "A", "B", "C", "D", "B_BtnA", "B_00", "C_00", "D_00", "B_BtnA", + }; + + static const char* const sDialogPaneNames[] = {"B_ArwR", "B_ArwL", "B_CalExit", "B_CalExit_00"}; + + SDMemory::SDMemory() : mScroller() {} + + SDMemory::~SDMemory() {} + + void SDMemory::create(EGG::Heap* heap, nand::LayoutFile* layoutFile, NandSDCardManager* manager) { + mpNandSDCardManager = manager; + + mpMainLayout = new (heap) layout::Object(heap, layoutFile, "arc", "mn_DialogWindow_ChChange_a.brlyt"); + mpMainLayout->bindToGroup("mn_DialogWindow_ChChange_a_DialogIn.brlan", "G_InOut", false, true); + mpMainLayout->bindToGroup("mn_DialogWindow_ChChange_a_DialogOut.brlan", "G_InOut", false, true); + mpMainLayout->bindToGroup("mn_DialogWindow_ChChange_a_FocusBtn_on.brlan", "G_FocusBtnA", false, true); + mpMainLayout->bindToGroup("mn_DialogWindow_ChChange_a_FocusBtn_off.brlan", "G_FocusBtnA", false, true); + mpMainLayout->bindToGroup("mn_DialogWindow_ChChange_a_SelectBtn_Ac.brlan", "G_SelectBtnA", false, true); + mpMainLayout->bindToGroup("mn_DialogWindow_ChChange_a_BtnA_Rollover.brlan", "G_BtnA", false, true); + mpMainLayout->bindToGroup("mn_DialogWindow_ChChange_a_BtnA_Rollout.brlan", "G_BtnA", false, true); + mpMainLayout->bindToGroup("mn_DialogWindow_ChChange_a_BtnA_On.brlan", "G_BtnA", false, true); + mpMainLayout->bindToGroup("mn_DialogWindow_ChChange_a_BtnB_Rollover.brlan", "G_BtnB", false, true); + mpMainLayout->bindToGroup("mn_DialogWindow_ChChange_a_BtnB_Rollout.brlan", "G_BtnB", false, true); + mpMainLayout->bindToGroup("mn_DialogWindow_ChChange_a_BtnB_On.brlan", "G_BtnB", false, true); + mpMainLayout->finishBinding(); + mpMainLayout->getAnim(0)->initAnmFrame(); + mpMainLayout->getAnim(2)->initAnmFrame(); + mpMainLayout->getAnim(5)->initAnmFrame(); + mpMainLayout->getAnim(8)->initAnmFrame(); + + nw4r::lyt::TextBox* textBox = nw4r::ut::DynamicCast(mpMainLayout->FindPaneByName("T_Dialog_00")); + textBox->SetString(System::getMessage(0xB0)); + textBox = nw4r::ut::DynamicCast(mpMainLayout->FindPaneByName("TextBox_05")); + textBox->SetString(System::getMessage(0xBB)); + textBox = nw4r::ut::DynamicCast(mpMainLayout->FindPaneByName("TextBox_06")); + textBox->SetString(System::getMessage(0xBC)); + textBox = nw4r::ut::DynamicCast(mpMainLayout->FindPaneByName("T_BtnA")); + textBox->SetString(System::getMessage(0x25)); + + mpTitleLayout = new (heap) layout::Object(heap, layoutFile, "arc", "mn_DialogWindow_ChChange_b.brlyt"); + mpTitleLayout->bindToGroup("mn_DialogWindow_ChChange_b_DialogIn.brlan", "G_InOut", false, true); + mpTitleLayout->bindToGroup("mn_DialogWindow_ChChange_b_DialogOut.brlan", "G_InOut", false, true); + mpTitleLayout->bindToGroup("mn_DialogWindow_ChChange_b_FocusBtn_on.brlan", "G_FocusBtnA", false, true); + mpTitleLayout->bindToGroup("mn_DialogWindow_ChChange_b_FocusBtn_off.brlan", "G_FocusBtnA", false, true); + mpTitleLayout->bindToGroup("mn_DialogWindow_ChChange_b_SelectBtn_Ac.brlan", "G_SelectBtnA", false, true); + mpTitleLayout->bindToGroup("mn_DialogWindow_ChChange_b_BtnA_Rollover.brlan", "G_BtnA", false, true); + mpTitleLayout->bindToGroup("mn_DialogWindow_ChChange_b_BtnA_Rollout.brlan", "G_BtnA", false, true); + mpTitleLayout->bindToGroup("mn_DialogWindow_ChChange_b_BtnA_On.brlan", "G_BtnA", false, true); + mpTitleLayout->bindToGroup("mn_DialogWindow_ChChange_b_BtnB_Rollover.brlan", "G_BtnB", false, true); + mpTitleLayout->bindToGroup("mn_DialogWindow_ChChange_b_BtnB_Rollout.brlan", "G_BtnB", false, true); + mpTitleLayout->bindToGroup("mn_DialogWindow_ChChange_b_BtnB_On.brlan", "G_BtnB", false, true); + mpTitleLayout->bindToGroup("mn_DialogWindow_ChChange_b_BtnC_Rollover.brlan", "G_BtnC", false, true); + mpTitleLayout->bindToGroup("mn_DialogWindow_ChChange_b_BtnC_Rollout.brlan", "G_BtnC", false, true); + mpTitleLayout->bindToGroup("mn_DialogWindow_ChChange_b_BtnC_On.brlan", "G_BtnC", false, true); + mpTitleLayout->bindToGroup("mn_DialogWindow_ChChange_b_BtnD_Rollover.brlan", "G_BtnD", false, true); + mpTitleLayout->bindToGroup("mn_DialogWindow_ChChange_b_BtnD_Rollout.brlan", "G_BtnD", false, true); + mpTitleLayout->bindToGroup("mn_DialogWindow_ChChange_b_BtnD_On.brlan", "G_BtnD", false, true); + mpTitleLayout->finishBinding(); + mpTitleLayout->getAnim(0)->initAnmFrame(); + mpTitleLayout->getAnim(2)->initAnmFrame(); + mpTitleLayout->getAnim(5)->initAnmFrame(); + mpTitleLayout->getAnim(8)->initAnmFrame(); + mpTitleLayout->getAnim(11)->initAnmFrame(); + mpTitleLayout->getAnim(14)->initAnmFrame(); + + textBox = nw4r::ut::DynamicCast(mpTitleLayout->FindPaneByName("T_Dialog")); + textBox->SetString(System::getMessage(0xB6)); + textBox = nw4r::ut::DynamicCast(mpTitleLayout->FindPaneByName("TextBox_00")); + textBox->SetString(System::getMessage(0xB7)); + textBox = nw4r::ut::DynamicCast(mpTitleLayout->FindPaneByName("TextBox_01")); + textBox->SetString(System::getMessage(0xB8)); + textBox = nw4r::ut::DynamicCast(mpTitleLayout->FindPaneByName("TextBox_02")); + textBox->SetString(System::getMessage(0xB9)); + textBox = nw4r::ut::DynamicCast(mpTitleLayout->FindPaneByName("TextBox_03")); + textBox->SetString(System::getMessage(0xBA)); + textBox = nw4r::ut::DynamicCast(mpTitleLayout->FindPaneByName("T_Dialog_00")); + textBox->SetString(System::getMessage(0xB6)); + textBox = nw4r::ut::DynamicCast(mpTitleLayout->FindPaneByName("TextBox_05")); + textBox->SetString(System::getMessage(0xB8)); + textBox = nw4r::ut::DynamicCast(mpTitleLayout->FindPaneByName("TextBox_06")); + textBox->SetString(System::getMessage(0xB9)); + textBox = nw4r::ut::DynamicCast(mpTitleLayout->FindPaneByName("TextBox_07")); + textBox->SetString(System::getMessage(0xBA)); + + mpDialogLayout = new (heap) layout::Object(heap, layoutFile, "arc", "mn_DialogWindow_ChChange_c.brlyt"); + static_cast(mpDialogLayout->FindPaneByName("T_Letter"))->AllocStringBuffer(0x840); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_Dialog_FadeIn.brlan", "G_Fede", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_Dialog_FadeOut.brlan", "G_Fede", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_Back_RollOver.brlan", "G_Back_Focus", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_Back_Rollout.brlan", "G_Back_Focus", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_Back_On.brlan", "G_Back_Ac", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_Move_RollOver.brlan", "G_Move_Focus", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_Move_Rollout.brlan", "G_Move_Focus", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_Move_On.brlan", "G_Move_Ac", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_FocusOn.brlan", "G_ArwL_Focus", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_FocusOff.brlan", "G_ArwL_Focus", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_Select.brlan", "G_ArwL_Ac", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_FocusOn.brlan", "G_ArwR_Focus", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_FocusOff.brlan", "G_ArwR_Focus", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_Select.brlan", "G_ArwR_Ac", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_Appear.brlan", "G_ArwL_End", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_Lost.brlan", "G_ArwL_End", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_Appear.brlan", "G_ArwR_End", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_Lost.brlan", "G_ArwR_End", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_Loop.brlan", "G_ArwRoop", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_HDActionStart.brlan", "G_ArwL_HDAc", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_HDActionEnd.brlan", "G_ArwL_HDAc", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_HDActionStart.brlan", "G_ArwR_HDAc", false, true); + mpDialogLayout->bindToGroup("mn_DialogWindow_ChChange_c_HDActionEnd.brlan", "G_ArwR_HDAc", false, true); + mpDialogLayout->finishBinding(); + mpDialogLayout->getAnim(0)->initAnmFrame(); + mpDialogLayout->getAnim(2)->initAnmFrame(); + mpDialogLayout->getAnim(5)->initAnmFrame(); + mpDialogLayout->getAnim(11)->initAnmFrame(); + mpDialogLayout->getAnim(8)->initAnmFrame(); + mpDialogLayout->getAnim(18)->initAnmFrame(); + mpDialogLayout->getAnim(18)->initFrame(); + mpDialogLayout->getAnim(18)->restart(); + + textBox = nw4r::ut::DynamicCast(mpDialogLayout->FindPaneByName("T_CalExit")); + textBox->SetString(System::getMessage(0xA5)); + textBox = nw4r::ut::DynamicCast(mpDialogLayout->FindPaneByName("T_CalExit_00")); + textBox->SetString(System::getMessage(0xC4)); + + mpProgressLayout = new (heap) layout::Object(heap, layoutFile, "arc", "mn_DialogWindow_Background.brlyt"); + mpProgressLayout->bindToGroup("mn_DialogWindow_Background_DialogIn.brlan", "G_InOut", false, true); + mpProgressLayout->bindToGroup("mn_DialogWindow_Background_DialogOut.brlan", "G_InOut", false, true); + mpProgressLayout->finishBinding(); + mpProgressLayout->getAnim(0)->initAnmFrame(); + + } + + void SDMemory::setTitleLists(const TitleRange& nandTitles, const TitleRange& sdTitles) { + mNandTitleRange = nandTitles; + mSDTitleRange = sdTitles; + mTransferFlags[0] = 1; + mDialogState = 0; + mpMainLayout->getAnim(0)->initAnmFrame(); + mpMainLayout->getAnim(0)->play(); + mpProgressLayout->getAnim(0)->initAnmFrame(); + mpProgressLayout->getAnim(0)->play(); + snd::getSystem()->startSE("WIPL_SE_INFO_WINDOW"); + mTransferFlags[1] = 1; + mErrorCode = 0; + } + + void SDMemory::setScrollLimit() { + nw4r::lyt::Pane* headerPane = mpDialogLayout->FindPaneByName("N_Header"); + nw4r::lyt::Pane* buttonPane = mpDialogLayout->FindPaneByName("T_BtnA"); + nw4r::lyt::Pane* footerPane = mpDialogLayout->FindPaneByName("N_Footer"); + + nw4r::ut::Rect projection; + System::getProjectionRect(&projection); + + f32 itemCount = static_cast(mButtonState); + f32 buttonHeight = buttonPane->GetSize().height; + f32 headerHeight = headerPane->GetSize().height; + f32 footerHeight = footerPane->GetSize().height; + f32 contentHeight = headerHeight + footerHeight; + f32 itemHeight = itemCount * buttonHeight; + f32 contentHeightWithItems = itemHeight + contentHeight; + f32 downLimit = contentHeightWithItems - projection.GetHeight() + 1.0f; + if (downLimit < 0.0f) { + downLimit = 0.0f; + } + + mScroller.init(); + mScroller.setDownLimit(downLimit); + } + + void SDMemory::updateSideArrows() { + controller::Interface* masterController = System::getMasterController(); + + if (mScroller.getBInst().isActive() ? false : true) { + if (masterController->down(controller::BTN_UP)) { + showLeftArrow(); + } + if (!masterController->down(controller::BTN_UP)) { + hideLeftArrow(); + } + if (masterController->down(controller::BTN_DOWN)) { + showRightArrow(); + } + if (!masterController->down(controller::BTN_DOWN)) { + hideRightArrow(); + } + } else { + if (mScroller.getBInst().isUp()) { + showLeftArrow(); + } + if (!mScroller.getBInst().isUp()) { + hideLeftArrow(); + } + if (mScroller.getBInst().isDown()) { + showRightArrow(); + } + if (!mScroller.getBInst().isDown()) { + hideRightArrow(); + } + } + } + + void SDMemory::resetScrollArrows() { + mControllerFlags[0] = 0; + mControllerFlags[1] = 0; + mControllerFlags[2] = 0; + mControllerFlags[3] = 0; + mpDialogLayout->getAnim(16)->initAnmFrame(); + mpDialogLayout->getAnim(14)->initAnmFrame(); + if (!mScroller.isDownEnd()) { + showUpArrow(); + } + } + + void SDMemory::updateScrollArrows(u32 previousDownEnd, u32 previousUpEnd, u32 downEnd, u32 upEnd) { + if (previousDownEnd != 1 && downEnd == 1) { + hideDownArrow(); + } + if (previousDownEnd == 1 && downEnd != 1) { + showDownArrow(); + } + if (previousUpEnd != 1 && upEnd == 1) { + hideUpArrow(); + } + if (previousUpEnd == 1 && upEnd != 1) { + showUpArrow(); + } + } + + void SDMemory::showDownArrow() { + if (mControllerFlags[0] == 0) { + layout::Animator* initAnimation = mpDialogLayout->getAnim(16); + initAnimation->initAnmFrame(); + layout::Animator* playAnimation = mpDialogLayout->getAnim(16); + playAnimation->initFrame(); + playAnimation->restart(); + mControllerFlags[0] = 1; + } + } + + void SDMemory::showUpArrow() { + if (mControllerFlags[1] == 0) { + layout::Animator* initAnimation = mpDialogLayout->getAnim(14); + initAnimation->initAnmFrame(); + layout::Animator* playAnimation = mpDialogLayout->getAnim(14); + playAnimation->initFrame(); + playAnimation->restart(); + mControllerFlags[1] = 1; + } + } + + void SDMemory::hideDownArrow() { + if (mControllerFlags[0] != 0) { + layout::Animator* initAnimation = mpDialogLayout->getAnim(17); + initAnimation->initAnmFrame(); + layout::Animator* playAnimation = mpDialogLayout->getAnim(17); + playAnimation->initFrame(); + playAnimation->restart(); + mControllerFlags[0] = 0; + } + } + + void SDMemory::hideUpArrow() { + if (mControllerFlags[1] != 0) { + layout::Animator* initAnimation = mpDialogLayout->getAnim(15); + initAnimation->initAnmFrame(); + layout::Animator* playAnimation = mpDialogLayout->getAnim(15); + playAnimation->initFrame(); + playAnimation->restart(); + mControllerFlags[1] = 0; + } + } + + void SDMemory::showLeftArrow() { + if (mControllerFlags[2] == 0) { + layout::Animator* animation = mpDialogLayout->getAnim(19); + animation->initFrame(); + animation->restart(); + mControllerFlags[2] = 1; + } + } + + void SDMemory::showRightArrow() { + if (mControllerFlags[3] == 0) { + layout::Animator* animation = mpDialogLayout->getAnim(21); + animation->initFrame(); + animation->restart(); + mControllerFlags[3] = 1; + } + } + + void SDMemory::hideLeftArrow() { + if (mControllerFlags[2] != 0) { + layout::Animator* animation = mpDialogLayout->getAnim(20); + animation->initFrame(); + animation->restart(); + mControllerFlags[2] = 0; + } + } + + void SDMemory::hideRightArrow() { + if (mControllerFlags[3] != 0) { + layout::Animator* animation = mpDialogLayout->getAnim(22); + animation->initFrame(); + animation->restart(); + mControllerFlags[3] = 0; + } + } + + void SDMemory::resetDialogPaneAnimations() { + for (int i = 0; i < 4; i++) { + if (mPanelAnimationStates[i] != 0) { + mPanelAnimationStates[i] = 0; + nw4r::lyt::Pane* pane = mpDialogLayout->FindPaneByName(sDialogPaneNames[i]); + mpPaneManagers[2]->initPane(pane); + + layout::Animator* animation = NULL; + switch (i) { + case 2: + animation = mpDialogLayout->getAnim(3); + break; + case 3: + animation = mpDialogLayout->getAnim(6); + break; + case 0: + animation = mpDialogLayout->getAnim(12); + break; + case 1: + animation = mpDialogLayout->getAnim(9); + break; + } + + if (animation != NULL) { + animation->initAnmFrame(); + animation->initFrame(); + animation->restart(); + } + } + } + } + + bool SDMemory::calc() { + bool result = false; + s32 stateResult = updateState(); + if (stateResult == 0) { + if (mScroller.calc(mDialogState == 10) == TRUE) { + resetDialogPaneAnimations(); + } + + nw4r::math::VEC3 translation(0.0f, mScroller.get(), 0.0f); + mpDialogLayout->FindPaneByName("N_Memo")->SetTranslate(translation); + + switch (mDialogState) { + case 0: + onDialogState0(); + break; + case 1: + mpPaneManagers[0]->update(); + mpPaneManagers[0]->calc(); + break; + case 2: + onDialogState2(); + break; + case 3: + result = onDialogState3(); + break; + case 4: + onDialogState4(); + break; + case 5: + mpPaneManagers[1]->update(); + mpPaneManagers[1]->calc(); + break; + case 6: + onDialogState6(); + break; + case 7: + onDialogState7(); + break; + case 8: + onDialogState8(); + break; + case 9: + onDialogState9(); + break; + case 10: + onDialogState10(); + break; + case 11: + onDialogState11(); + break; + case 12: + onDialogState12(); + break; + case 13: + onDialogState13(); + break; + case 14: + onDialogState14(); + break; + case 15: + onDialogState15(); + break; + case 16: + onDialogState16(); + break; + case 17: + onDialogState17(); + break; + case 18: + onDialogState18(); + break; + case 19: + onDialogState19(); + break; + case 20: + result = onDialogState20(); + break; + case 21: + onDialogState21(); + break; + case 22: + result = onDialogState22(); + break; + case 23: + onDialogState23(); + break; + case 24: + result = onDialogState24(); + break; + case 25: + result = true; + break; + } + } + + mpMainLayout->calc(); + mpTitleLayout->calc(); + mpDialogLayout->calc(); + mpProgressLayout->calc(); + + return stateResult == 2 ? true : result; + } + + void SDMemory::onDialogState0() { + if (!mpMainLayout->isPlaying(-1)) { + for (int i = 0; i < 3; i++) { + mPanelStates[i] = 0; + mpPaneManagers[0]->initPane(mpMainLayout->getNW4RLyt()->GetRootPane()->FindPaneByName(sControlPaneNames[i], true)); + } + + mDialogState = 1; + } + } + + void SDMemory::onDialogState2() { + if (!mpMainLayout->isPlaying(-1)) { + mpMainLayout->getAnim(1)->initAnmFrame(); + mpMainLayout->getAnim(1)->play(); + + if (mProcessState == 2) { + mpProgressLayout->getAnim(1)->initAnmFrame(); + mpProgressLayout->getAnim(1)->play(); + mTransferFlags[1] = 0; + } + + mDialogState = 3; + } + } + + void SDMemory::onDialogState4() { + if (!mpTitleLayout->isPlaying(-1)) { + if (mDisplayMode == 4) { + for (int i = 0; i < 5; i++) { + mTitlePanelStates[i] = 0; + mpPaneManagers[1]->initPane(mpTitleLayout->FindPaneByName(sControlPaneNames[i + 3])); + } + } else { + for (int i = 1; i < 5; i++) { + mTitlePanelStates[i] = 0; + mpPaneManagers[1]->initPane(mpTitleLayout->FindPaneByName(sControlPaneNames[i + 7])); + } + } + + mDialogState = 5; + } + } + + void SDMemory::onDialogState6() { + if (!mpTitleLayout->isPlaying(-1)) { + mDialogState = 7; + mpTitleLayout->getAnim(1)->initAnmFrame(); + mpTitleLayout->getAnim(1)->play(); + } + } + + void SDMemory::onDialogState7() { + if (!mpTitleLayout->isPlaying(-1)) { + switch (mProcessState) { + case 4: + mDialogState = 0; + mpMainLayout->getAnim(0)->play(); + snd::getSystem()->startSE("WIPL_SE_BT_TARGETTING"); + break; + default: + mTransferStartTime = 0; + mTransferFrame = 0; + System::getDialog()->callBtn0NoShade(0xCC, 0, true); + mDialogState = 8; + break; + } + } + } + + void SDMemory::onDialogState9() { + if (!mpDialogLayout->isPlaying(0)) { + for (int i = 0; i < 4; i++) { + mPanelAnimationStates[i] = 0; + mpPaneManagers[2]->initPane(mpDialogLayout->getNW4RLyt()->GetRootPane()->FindPaneByName(sDialogPaneNames[i], true)); + } + + mDialogState = 10; + } + } + + void SDMemory::onDialogState10() { + controller::Interface* masterController = System::getMasterController(); + if (mScroller.isActive()) { + updateSideArrows(); + if (mScroller.getBInst().isActive() ? false : true) { + if (masterController->down(controller::BTN_UP)) { + mScroller.scrollUpByCon(); + } else if (masterController->down(controller::BTN_DOWN)) { + mScroller.scrollDownByCon(); + } + } + } + + bool previousDownEnd = !!mControllerFlags[0]; + bool previousUpEnd = !!mControllerFlags[1]; + updateScrollArrows(previousDownEnd, previousUpEnd, mScroller.isUpEnd(), mScroller.isDownEnd()); + + if (mScroller.getBInst().isActive() ? false : true) { + mpPaneManagers[2]->update(); + } + mpPaneManagers[2]->calc(); + } + + void SDMemory::onDialogState11() { + if (!mpDialogLayout->isPlaying(4) && !mpDialogLayout->isPlaying(7)) { + if (mProcessState < 4 && mProcessState >= 2) { + mDialogState = 12; + mpDialogLayout->getAnim(1)->initAnmFrame(); + mpDialogLayout->getAnim(1)->play(); + + if (mControllerFlags[0] != 0) { + hideDownArrow(); + } + if (mControllerFlags[1] != 0) { + hideUpArrow(); + } + } else { + mDialogState = 10; + } + } + } + + void SDMemory::onDialogState19() { + if (!mpNandSDCardManager->getWorker()->is_working()) { + if (mpNandSDCardManager->getWorker()->get_async_result() == 0) { + mDialogState = 13; + } else { + System::getDialog()->terminate(); + mDialogState = 20; + mErrorCode = 1; + mMessageId = 0xAE; + } + } + } + + bool SDMemory::onDialogState20() { + DialogWindow* dialog = System::getDialog(); + if (dialog->getStateForSDMemory() == 4 && mTransferFlags[1] && mErrorCode == 0) { + mTransferFlags[1] = 0; + mpProgressLayout->getAnim(1)->initAnmFrame(); + mpProgressLayout->getAnim(1)->play(); + } + + if (System::getDialog()->getLastResult() != -1) { + if (mErrorCode == 0) { + mTransferFlags[0] = 1; + mDialogState = 25; + return true; + } + + mDialogState = 23; + } + + return false; + } + + bool SDMemory::onDialogState22() { + DialogWindow* dialog = System::getDialog(); + if (dialog->getStateForSDMemory() == 3 && dialog->getResultForSDMemory() == 1) { + mpProgressLayout->getAnim(1)->initAnmFrame(); + mpProgressLayout->getAnim(1)->play(); + mTransferFlags[1] = 0; + } + + if (System::getDialog()->getLastResult() != -1) { + if (System::getDialog()->getLastResult() == 1) { + mErrorCode = 4; + mDialogState = 25; + return true; + } + + mpMainLayout->getAnim(0)->initAnmFrame(); + mpMainLayout->getAnim(0)->play(); + snd::getSystem()->startSE("WIPL_SE_CANCEL"); + mDialogState = 0; + } + + return false; + } + + void SDMemory::onDialogState23() { + switch (mMessageId) { + case 0xBF: + case 0xB5: + System::getDialog()->callBtn1NoShade(mMessageId, 0xA5); + break; + default: + System::getDialog()->callBtn1NoShade(mMessageId, 0x2E); + break; + } + + mDialogState = 24; + } + + bool SDMemory::onDialogState24() { + if (System::getDialog()->getStateForSDMemory() == 3) { + mpProgressLayout->getAnim(1)->initAnmFrame(); + mpProgressLayout->getAnim(1)->play(); + mTransferFlags[1] = 0; + } + + if (System::getDialog()->getLastResult() != -1) { + mTransferFlags[0] = 1; + System::getHomeButtonMenu()->enable(); + mDialogState = 25; + return true; + } + + return false; + } + } +}