From 98f3ce5b397d2c70cdd17553a58ba16199170401 Mon Sep 17 00:00:00 2001 From: robojumper Date: Tue, 23 Dec 2025 22:51:06 +0100 Subject: [PATCH] More deposit --- config/SOUE01/splits.txt | 4 +- config/SOUE01/symbols.txt | 82 +- include/d/d_cs_base.h | 11 + include/d/d_pouch.h | 4 + include/d/lyt/d_lyt_common_arrow.h | 3 +- include/d/lyt/d_lyt_cursor_stick.h | 3 + include/d/lyt/d_lyt_deposit.h | 100 ++- include/d/lyt/d_lyt_deposit_box_cursor.h | 10 +- include/d/lyt/d_lyt_deposit_stock.h | 74 +- include/d/lyt/d_lyt_util_items.h | 2 + src/d/lyt/d_lyt_common_arrow.cpp | 7 +- src/d/lyt/d_lyt_deposit.cpp | 931 +++++++++++++++++++++-- src/d/lyt/d_lyt_deposit_box_cursor.cpp | 1 + src/d/lyt/d_lyt_deposit_stock.cpp | 56 +- 14 files changed, 1147 insertions(+), 141 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 223e95e4..029135b6 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -1664,7 +1664,7 @@ d/lyt/d_lyt_demo_dowsing.cpp: d/lyt/d_lyt_shop.cpp: .text start:0x802A17D0 end:0x802A7FD8 align:16 .ctors start:0x804DB884 end:0x804DB888 - .rodata start:0x804EF130 end:0x804EF970 + .rodata start:0x804EF130 end:0x804EF8B0 .data start:0x8053BF50 end:0x8053CFC8 .sbss start:0x805759B0 end:0x805759B8 .bss start:0x805B67C0 end:0x805B6C18 @@ -1672,7 +1672,7 @@ d/lyt/d_lyt_shop.cpp: d/lyt/d_lyt_deposit.cpp: .text start:0x802A7FE0 end:0x802B02C8 align:16 .ctors start:0x804DB888 end:0x804DB88C - .rodata start:0x804EF970 end:0x804EFA90 + .rodata start:0x804EF8B0 end:0x804EFA90 .data start:0x8053CFC8 end:0x8053DFC8 .sdata start:0x80573C10 end:0x80573C30 .sbss start:0x805759B8 end:0x805759D0 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index c4fc0d68..d7d68eea 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -9121,7 +9121,7 @@ __sinit_\d_lyt_save_msg_window_cpp = .text:0x80166540; // type:function size:0x3 __dt__34sFStateID_c<19dLytSaveMsgWindow_c>Fv = .text:0x80166880; // type:function size:0x58 scope:weak isSameName__34sFStateID_c<19dLytSaveMsgWindow_c>CFPCc = .text:0x801668E0; // type:function size:0x88 scope:weak fn_80166970 = .text:0x80166970; // type:function size:0x58 -fn_801669D0 = .text:0x801669D0; // type:function size:0x4 +convertLytPouchSlot2__Fl = .text:0x801669D0; // type:function size:0x4 hasPouchSlot__Flb = .text:0x801669E0; // type:function size:0x50 getPouchItemIdForIndex__Flb = .text:0x80166A30; // type:function size:0x5C getPouchItemForSlot__Flb = .text:0x80166A90; // type:function size:0x70 @@ -9204,7 +9204,7 @@ executeState__86sStateMgr_c<17dLytCommonArrow_c,20sStateMethodUsr_FI_c,12sFState getStateID__86sStateMgr_c<17dLytCommonArrow_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x801685C0; // type:function size:0x10 scope:weak draw__17dLytCommonArrow_cFv = .text:0x801685D0; // type:function size:0x34 setState__17dLytCommonArrow_cFl = .text:0x80168610; // type:function size:0x24 -setTranslate__17dLytCommonArrow_cFPC3Vec = .text:0x80168640; // type:function size:0x34 +setTranslate__17dLytCommonArrow_cFPC7mVec2_c = .text:0x80168640; // type:function size:0x34 requestIn__17dLytCommonArrow_cFv = .text:0x80168680; // type:function size:0x70 requestOut__17dLytCommonArrow_cFv = .text:0x801686F0; // type:function size:0x70 fn_80168760__17dLytCommonArrow_cFv = .text:0x80168760; // type:function size:0x2C @@ -10091,9 +10091,9 @@ changeItemPouchExtensionCounter = .text:0x8018AA20; // type:function size:0x10C getExtraAmmoInPouchByType = .text:0x8018AB30; // type:function size:0x98 getExtraAmmoCapacityByType = .text:0x8018ABD0; // type:function size:0x98 getAdditionalCapacitySizeForItem = .text:0x8018AC70; // type:function size:0x60 -fn_8018ACD0 = .text:0x8018ACD0; // type:function size:0xC4 -fn_8018ADA0 = .text:0x8018ADA0; // type:function size:0xA0 -trySwapAdventurePouchItems = .text:0x8018AE40; // type:function size:0x120 +swapStockAndPouchItems__Fll = .text:0x8018ACD0; // type:function size:0xC4 +swapStockItems__Fll = .text:0x8018ADA0; // type:function size:0xA0 +swapAdventurePouchItems__Fll = .text:0x8018AE40; // type:function size:0x120 fn_8018AF60 = .text:0x8018AF60; // type:function size:0x204 itemCheckFindItemSlot__F7ITEM_ID = .text:0x8018B170; // type:function size:0x60 fn_8018B1D0 = .text:0x8018B1D0; // type:function size:0x60 @@ -16002,49 +16002,49 @@ __dt__86sStateMgr_c<17dLytDepositMain_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13 __dt__33sFStateFct_c<17dLytDepositMain_c>Fv = .text:0x802A9400; // type:function size:0x6C __dt__30sFState_c<17dLytDepositMain_c>Fv = .text:0x802A9470; // type:function size:0x58 __ct__18dLytDepositStock_cFv = .text:0x802A94D0; // type:function size:0x138 -fn_802A9610 = .text:0x802A9610; // type:function size:0x468 -fn_802A9A80 = .text:0x802A9A80; // type:function size:0x1EC +build__17dLytDepositMain_cFPQ23d2d10ResAccIf_c = .text:0x802A9610; // type:function size:0x468 +execute__17dLytDepositMain_cFv = .text:0x802A9A80; // type:function size:0x1EC executeState__86sStateMgr_c<17dLytDepositMain_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x802A9C70; // type:function size:0x10 -fn_802A9C80 = .text:0x802A9C80; // type:function size:0x4C -fn_802A9CD0 = .text:0x802A9CD0; // type:function size:0x1A8 -fn_802A9E80 = .text:0x802A9E80; // type:function size:0x50 +draw__17dLytDepositMain_cFv = .text:0x802A9C80; // type:function size:0x4C +remove__17dLytDepositMain_cFv = .text:0x802A9CD0; // type:function size:0x1A8 +setModeNone__17dLytDepositMain_cFv = .text:0x802A9E80; // type:function size:0x50 changeState__86sStateMgr_c<17dLytDepositMain_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x802A9ED0; // type:function size:0x10 -fn_802A9EE0 = .text:0x802A9EE0; // type:function size:0x19C -fn_802AA080 = .text:0x802AA080; // type:function size:0x84 -fn_802AA110 = .text:0x802AA110; // type:function size:0xE4 -fn_802AA200 = .text:0x802AA200; // type:function size:0x90 +setModeIn__17dLytDepositMain_cFv = .text:0x802A9EE0; // type:function size:0x19C +setModeCheck__17dLytDepositMain_cFv = .text:0x802AA080; // type:function size:0x84 +setModeChange__17dLytDepositMain_cFb = .text:0x802AA110; // type:function size:0xE4 +setModeArrangement__17dLytDepositMain_cFv = .text:0x802AA200; // type:function size:0x90 fn_802AA290 = .text:0x802AA290; // type:function size:0x13C fn_802AA3D0 = .text:0x802AA3D0; // type:function size:0xFC fn_802AA4D0 = .text:0x802AA4D0; // type:function size:0xEC fn_802AA5C0 = .text:0x802AA5C0; // type:function size:0xB0 fn_802AA670 = .text:0x802AA670; // type:function size:0xF8 getStateID__86sStateMgr_c<17dLytDepositMain_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x802AA770; // type:function size:0x10 -fn_802AA780 = .text:0x802AA780; // type:function size:0x5C -fn_802AA7E0 = .text:0x802AA7E0; // type:function size:0x348 -fn_802AAB30 = .text:0x802AAB30; // type:function size:0x388 -fn_802AAEC0 = .text:0x802AAEC0; // type:function size:0xF8 -fn_802AAFC0 = .text:0x802AAFC0; // type:function size:0xB4 -fn_802AB080 = .text:0x802AB080; // type:function size:0x188 -fn_802AB210 = .text:0x802AB210; // type:function size:0x474 +loadItems__17dLytDepositMain_cFl = .text:0x802AA780; // type:function size:0x5C +fn_802AA7E0__17dLytDepositMain_cFv = .text:0x802AA7E0; // type:function size:0x348 +fn_802AAB30__17dLytDepositMain_cFv = .text:0x802AAB30; // type:function size:0x388 +fn_802AAEC0__17dLytDepositMain_cFl = .text:0x802AAEC0; // type:function size:0xF8 +fn_802AAFC0__17dLytDepositMain_cFv = .text:0x802AAFC0; // type:function size:0xB4 +fn_802AB080__17dLytDepositMain_cFv = .text:0x802AB080; // type:function size:0x188 +fn_802AB210__17dLytDepositMain_cFv = .text:0x802AB210; // type:function size:0x474 fn_802AB690 = .text:0x802AB690; // type:function size:0xB8 fn_802AB750 = .text:0x802AB750; // type:function size:0x2E8 -fn_802ABA40 = .text:0x802ABA40; // type:function size:0x114 -fn_802ABB60 = .text:0x802ABB60; // type:function size:0x580 -fn_802AC0E0 = .text:0x802AC0E0; // type:function size:0x1A8 -fn_802AC290 = .text:0x802AC290; // type:function size:0xC4 +loadItemText__17dLytDepositMain_cFll = .text:0x802ABA40; // type:function size:0x114 +fn_802ABB60__17dLytDepositMain_cFv = .text:0x802ABB60; // type:function size:0x580 +fn_802AC0E0__17dLytDepositMain_cFl = .text:0x802AC0E0; // type:function size:0x1A8 +fn_802AC290__17dLytDepositMain_cFl = .text:0x802AC290; // type:function size:0xC4 fn_802AC360 = .text:0x802AC360; // type:function size:0x58 -fn_802AC3C0 = .text:0x802AC3C0; // type:function size:0x234 +fn_802AC3C0__17dLytDepositMain_cFv = .text:0x802AC3C0; // type:function size:0x234 fn_802AC600 = .text:0x802AC600; // type:function size:0x64 -fn_802AC670 = .text:0x802AC670; // type:function size:0x304 +fn_802AC670__17dLytDepositMain_cFv = .text:0x802AC670; // type:function size:0x304 fn_802AC980 = .text:0x802AC980; // type:function size:0x54 fn_802AC9E0 = .text:0x802AC9E0; // type:function size:0x90 setPouchItemsVisible__17dLytDepositMain_cFb = .text:0x802ACA70; // type:function size:0x80 -fn_802ACAF0 = .text:0x802ACAF0; // type:function size:0x85C -fn_802AD350 = .text:0x802AD350; // type:function size:0x18 -fn_802AD370 = .text:0x802AD370; // type:function size:0x8C -fn_802AD400 = .text:0x802AD400; // type:function size:0x5C -fn_802AD460 = .text:0x802AD460; // type:function size:0x60 -fn_802AD4C0 = .text:0x802AD4C0; // type:function size:0x5C +checkForItemPickupOrDrop__17dLytDepositMain_cFv = .text:0x802ACAF0; // type:function size:0x85C +getItemSellValueFrame__17dLytDepositMain_cFl = .text:0x802AD350; // type:function size:0x18 +fn_802AD370__17dLytDepositMain_cFv = .text:0x802AD370; // type:function size:0x8C +fn_802AD400__17dLytDepositMain_cFv = .text:0x802AD400; // type:function size:0x5C +fn_802AD460__17dLytDepositMain_cFv = .text:0x802AD460; // type:function size:0x60 +fn_802AD4C0__17dLytDepositMain_cFv = .text:0x802AD4C0; // type:function size:0x5C initializeState_None__13dLytDeposit_cFv = .text:0x802AD520; // type:function size:0x4 executeState_None__13dLytDeposit_cFv = .text:0x802AD530; // type:function size:0x68 changeState__82sStateMgr_c<13dLytDeposit_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x802AD5A0; // type:function size:0x10 @@ -16082,16 +16082,16 @@ __dt__29sFStateFct_c<13dLytDeposit_c>Fv = .text:0x802ADF30; // type:function siz __dt__82sStateMgr_c<13dLytDeposit_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x802ADFA0; // type:function size:0xA0 __dt__52sFStateMgr_c<13dLytDeposit_c,20sStateMethodUsr_FI_c>Fv = .text:0x802AE040; // type:function size:0xA4 __dt__17dLytDepositMain_cFv = .text:0x802AE0F0; // type:function size:0x390 -fn_802AE480 = .text:0x802AE480; // type:function size:0x54 -fn_802AE4E0 = .text:0x802AE4E0; // type:function size:0x70 -fn_802AE550 = .text:0x802AE550; // type:function size:0xB0 +build__13dLytDeposit_cFv = .text:0x802AE480; // type:function size:0x54 +create__13dLytDeposit_cFv = .text:0x802AE4E0; // type:function size:0x70 +execute__13dLytDeposit_cFv = .text:0x802AE550; // type:function size:0xB0 getStateID__82sStateMgr_c<13dLytDeposit_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x802AE600; // type:function size:0x10 executeState__82sStateMgr_c<13dLytDeposit_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x802AE610; // type:function size:0x10 -fn_802AE620 = .text:0x802AE620; // type:function size:0x78 -fn_802AE6A0 = .text:0x802AE6A0; // type:function size:0x50 -fn_802AE6F0 = .text:0x802AE6F0; // type:function size:0xE0 -fn_802AE7D0 = .text:0x802AE7D0; // type:function size:0x10C -fn_802AE8E0 = .text:0x802AE8E0; // type:function size:0x434 +draw__13dLytDeposit_cFv = .text:0x802AE620; // type:function size:0x78 +doDelete__13dLytDeposit_cFv = .text:0x802AE6A0; // type:function size:0x50 +checkForNavRight__13dLytDeposit_cFv = .text:0x802AE6F0; // type:function size:0xE0 +checkForNavLeft__13dLytDeposit_cFv = .text:0x802AE7D0; // type:function size:0x10C +__dt__13dLytDeposit_cFv = .text:0x802AE8E0; // type:function size:0x434 build__29sFStateFct_c<13dLytDeposit_c>FRC12sStateIDIf_c = .text:0x802AED20; // type:function size:0x60 dispose__29sFStateFct_c<13dLytDeposit_c>FRP10sStateIf_c = .text:0x802AED80; // type:function size:0xC build__33sFStateFct_c<17dLytDepositMain_c>FRC12sStateIDIf_c = .text:0x802AED90; // type:function size:0x60 diff --git a/include/d/d_cs_base.h b/include/d/d_cs_base.h index b7c54201..b27832bc 100644 --- a/include/d/d_cs_base.h +++ b/include/d/d_cs_base.h @@ -26,6 +26,9 @@ public: void setVisible(bool val) { mVisible = val; } + bool isVisible() const { + return mVisible; + } void setDrawDirectly(bool val) { mDrawDirectly = val; } @@ -52,6 +55,14 @@ public: mCursorStick.setShouldBeOn(visible); } + void setCursorStickPriority(u8 priority) { + mCursorStick.setPriority(priority); + } + + void setCursorStickPriority2(u8 priority) { + mCursorStick.setPriority2(priority); + } + bool isCursorStickVisible() const { return mCursorStick.getShouldBeOn(); } diff --git a/include/d/d_pouch.h b/include/d/d_pouch.h index feacc53d..b7ca10cb 100644 --- a/include/d/d_pouch.h +++ b/include/d/d_pouch.h @@ -19,6 +19,10 @@ bool isItemShield(s32 item); u8 adventurePouchFindItemSlot(ITEM_ID item); u32 adventurePouchCountItem(ITEM_ID itemId); +bool swapAdventurePouchItems(s32 slot1, s32 slot2); +bool swapStockAndPouchItems(s32 pouchSlot, s32 stockSlot); +bool swapStockItems(s32 slot1, s32 slot2); + #define ITEM_CHECK_SLOT_NONE 60 u16 itemCheckFindItemSlot(ITEM_ID item); diff --git a/include/d/lyt/d_lyt_common_arrow.h b/include/d/lyt/d_lyt_common_arrow.h index c2e60b02..21a65fb7 100644 --- a/include/d/lyt/d_lyt_common_arrow.h +++ b/include/d/lyt/d_lyt_common_arrow.h @@ -6,6 +6,7 @@ // vtable order #include "d/d_cursor_hit_check.h" // clang-format on +#include "m/m_vec.h" #include "nw4r/lyt/lyt_bounding.h" #include "s/s_State.hpp" @@ -59,9 +60,9 @@ public: mBackwards = b; } bool fn_80168760(); + void setTranslate(const mVec2_c *); private: - void setTranslate(const Vec *); void displayElement(s32, f32); void unbindAt(s32); void tickDown(d2d::AnmGroup_c *); diff --git a/include/d/lyt/d_lyt_cursor_stick.h b/include/d/lyt/d_lyt_cursor_stick.h index 7f5fef42..80670a58 100644 --- a/include/d/lyt/d_lyt_cursor_stick.h +++ b/include/d/lyt/d_lyt_cursor_stick.h @@ -23,6 +23,9 @@ public: static bool drawDirectly(); void setPriority(u8 priority); + void setPriority2(u8 priority) { + mLyt.setPriority(priority); + } void setTargetPane(const nw4r::lyt::Pane *pane); void setShouldBeOn(bool value) { diff --git a/include/d/lyt/d_lyt_deposit.h b/include/d/lyt/d_lyt_deposit.h index a8a94d02..9e437649 100644 --- a/include/d/lyt/d_lyt_deposit.h +++ b/include/d/lyt/d_lyt_deposit.h @@ -23,18 +23,71 @@ public: } bool build(d2d::ResAccIf_c *resAcc); + bool execute(); + bool draw(); + bool remove(); + + void setModeNone(); + void setModeIn(); + void setModeCheck(); + void setModeChange(bool unk); + void setModeArrangement(); + + bool isSellableItem() const { + return field_0x19524 && mItemSellValue > 0; + } + + s32 getArrowDirection() const { + return mStock[STOCK_ACTIVE].getArrowDirection(); + } + + void setField_0x1952C(bool b) { + field_0x1952C = b; + } + + s32 getStateStep() const { + return mStateStep; + } + + bool isIdle() const { + return mIsIdle; + } private: + static const s32 NUM_STOCKS = 3; + static const s32 STOCK_ACTIVE = 0; + + static const s32 RING_NUM_ITEMS = 8; + + static const s32 SLOT_STOCK_OFFSET = 8; + + static const s32 NUM_ICONS_PER_PAGE = 12; + static const s32 NUM_PAGES = 5; + void setPouchItemsVisible(bool visible); void fn_802AA7E0(); void fn_802AD370(); - void fn_802A9E80(); void fn_802AAFC0(); void fn_802AB210(); - void fn_802ACAF0(); + void checkForItemPickupOrDrop(); void fn_802ABB60(); + void fn_802AB080(); + void fn_802AC3C0(); + void fn_802AD4C0(); + void loadItemText(s32 itemId, s32 where); + void fn_802AC670(); + void fn_802AC290(s32); + void fn_802AD460(); + void loadItems(s32 hiddenSlot); + s32 getItemSellValueFrame(s32 value); + void fn_802AC0E0(s32); + void fn_802AAEC0(s32); + void fn_8018ADA0(s32); + void fn_802AAB30(); + void fn_802AD400(); + STATE_FUNC_DECLARE(dLytDepositMain_c, ModeNone); STATE_FUNC_DECLARE(dLytDepositMain_c, ModeIn); STATE_FUNC_DECLARE(dLytDepositMain_c, ModeCheck); @@ -65,15 +118,15 @@ private: u8 _0x00002[0x8]; - /* 0x00A7C */ dLytDepositStock_c mStock[3]; + /* 0x00A7C */ dLytDepositStock_c mStock[NUM_STOCKS]; /* 0x143F0 */ dLytDepositBoxCursor_c mCursor; - /* 0x14D48 */ dLytCommonIconItem_c mPouchItems[8]; + /* 0x14D48 */ dLytCommonIconItem_c mPouchItems[RING_NUM_ITEMS]; /* 0x18D88 */ dLytCommonArrow_c mArrow; - /* 0x19458 */ d2d::SubPaneList mSubpaneList1; - /* 0x19464 */ d2d::SubPaneListNode mNodes1[3]; - /* 0x19494 */ d2d::SubPaneList mSubpaneList2; - /* 0x194A0 */ d2d::SubPaneListNode mNodes2[8]; - /* 0x19520 */ bool field_0x19520; + /* 0x19458 */ d2d::SubPaneList mStockList; + /* 0x19464 */ d2d::SubPaneListNode mStockNodes[NUM_STOCKS]; + /* 0x19494 */ d2d::SubPaneList mRingList; + /* 0x194A0 */ d2d::SubPaneListNode mRingNodes[RING_NUM_ITEMS]; + /* 0x19520 */ bool mIsIdle; /* 0x19521 */ bool field_0x19521; /* 0x19522 */ bool field_0x19522; /* 0x19523 */ bool field_0x19523; @@ -82,32 +135,44 @@ private: /* 0x19526 */ bool field_0x19526; /* 0x19527 */ bool field_0x19527; /* 0x19528 */ bool field_0x19528; - /* 0x19529 */ bool field_0x19529; + /* 0x19529 */ bool mHasScrolledOtherStocks; /* 0x1952A */ bool field_0x1952A; /* 0x1952B */ bool field_0x1952B; /* 0x1952C */ bool field_0x1952C; - /* 0x19530 */ UNKWORD field_0x19530; - /* 0x19534 */ UNKWORD field_0x19534; - /* 0x19538 */ UNKWORD field_0x19538; - /* 0x1953C */ UNKWORD field_0x1953C; + /* 0x19530 */ s32 mCurrentPouchNavTarget; + /* 0x19534 */ s32 mCurrentlyHoldingItemSlot; + /* 0x19538 */ s32 mStateStep; + /* 0x1953C */ s32 mCursorLocation; /* 0x19540 */ UNKWORD field_0x19540; - /* 0x19544 */ UNKWORD field_0x19544; + /* 0x19544 */ s32 mItemSellValue; /* 0x19548 */ UNKWORD field_0x19548; /* 0x1954C */ UNKWORD field_0x1954C; /* 0x19550 */ UNKWORD field_0x19550; /* 0x19554 */ UNKWORD field_0x19554; - /* 0x19558 */ u8 mPouchItemIds[8]; + /* 0x19558 */ u8 mPouchItemIds[RING_NUM_ITEMS]; }; class dLytDeposit_c : public dLytBase_c { public: dLytDeposit_c() : mStateMgr(*this) {} + virtual ~dLytDeposit_c() { + removeLyt(); + } static dLytDeposit_c *GetInstance() { return sInstance; } + virtual bool build() override; + virtual int create() override; + virtual int execute() override; + virtual int draw() override; + virtual int doDelete() override; + private: + bool checkForNavRight(); + bool checkForNavLeft(); + static dLytDeposit_c *sInstance; STATE_FUNC_DECLARE(dLytDeposit_c, None); @@ -124,6 +189,9 @@ private: /* 0x08C */ UI_STATE_MGR_DECLARE(dLytDeposit_c); /* 0x0C8 */ d2d::ResAccIf_c mResAcc; /* 0x438 */ dLytDepositMain_c mMain; + /* 0x19998 */ bool field_0x19998; + /* 0x19999 */ bool field_0x19999; + /* 0x1999A */ bool field_0x1999A; }; #endif diff --git a/include/d/lyt/d_lyt_deposit_box_cursor.h b/include/d/lyt/d_lyt_deposit_box_cursor.h index 7278d42e..4c403b48 100644 --- a/include/d/lyt/d_lyt_deposit_box_cursor.h +++ b/include/d/lyt/d_lyt_deposit_box_cursor.h @@ -10,7 +10,7 @@ class dLytDepositBoxCursor_c : public d2d::dSubPane { public: enum ItemLocation_e { LOC_POUCH, - LOC_DEPOSIT, + LOC_STOCK, }; public: @@ -36,6 +36,14 @@ public: void updateSlot(s32 location, s32 slot, s32 unk, bool unk2); void fn_801580A0(); + bool isVisible() const { + return mIsVisible; + } + + void setVisible(bool b) { + mIsVisible = b; + } + private: void initIcon(); void realizeNav(); diff --git a/include/d/lyt/d_lyt_deposit_stock.h b/include/d/lyt/d_lyt_deposit_stock.h index 414654cb..faf8eb85 100644 --- a/include/d/lyt/d_lyt_deposit_stock.h +++ b/include/d/lyt/d_lyt_deposit_stock.h @@ -67,7 +67,67 @@ public: return mCurrentNavTarget; } -private: + bool isModeSort() const { + return mIsModeSort; + } + + bool isModePouch() const { + return mIsModePouch; + } + + bool isModeSell() const { + return mIsModeSell; + } + + void disableModeSort() { + mIsModeSort = false; + } + + void disableModePouch() { + mIsModePouch = false; + } + + void disableModeSell() { + mIsModeSell = false; + } + + void returnToNormalMode() { + mIsModeFinish = false; + mIsModeSell = false; + mIsModeSort = false; + mIsModePouch = false; + mSavedArrowDirection = ARROW_NONE; + } + + u8 getItem(s32 idx) const { + return mItemIds[idx]; + } + + u8 getPage() const { + return mItemPage; + } + + void setPage(u8 page) { + mItemPage = page; + } + + s32 getActiveItem() const { + return mItemIds[mCurrentNavTarget]; + } + + void setSellBlocked(bool v) { + mIsSellBlocked = v; + } + + void setSortBlocked(bool v) { + mIsSortBlocked = v; + } + + s32 getArrowDirection() const { + return mArrowDirection; + } + +//private: static const s32 NUM_ICONS_PER_PAGE = 12; static const s32 NUM_PAGES = 5; @@ -93,12 +153,12 @@ private: /* 0x6778 */ d2d::SubPaneList mSubpaneList; /* 0x6784 */ d2d::SubPaneListNode mNodes[NUM_ICONS_PER_PAGE]; /* 0x6844 */ bool field_0x6844; - /* 0x6845 */ bool field_0x6845; - /* 0x6846 */ bool field_0x6846; - /* 0x6847 */ bool field_0x6847; - /* 0x6848 */ bool field_0x6848; - /* 0x6849 */ bool field_0x6849; - /* 0x684A */ bool field_0x684A; + /* 0x6845 */ bool mIsModePouch; + /* 0x6846 */ bool mIsModeSell; + /* 0x6847 */ bool mIsModeSort; + /* 0x6848 */ bool mIsModeFinish; + /* 0x6849 */ bool mIsSellBlocked; + /* 0x684A */ bool mIsSortBlocked; /* 0x684B */ bool field_0x684B; /* 0x684C */ bool field_0x684C; /* 0x684D */ bool field_0x684D; diff --git a/include/d/lyt/d_lyt_util_items.h b/include/d/lyt/d_lyt_util_items.h index e384e10a..d6bf4819 100644 --- a/include/d/lyt/d_lyt_util_items.h +++ b/include/d/lyt/d_lyt_util_items.h @@ -18,6 +18,8 @@ enum SongLifeTreeSeedStatus_e { SONG_LIFETREE_HAS_SOTH = 2, }; +s32 convertLytPouchSlot2(s32 fileSlot); + u8 getSongLifeTreeStatus(); /** 0: no sword, 6: TMS */ diff --git a/src/d/lyt/d_lyt_common_arrow.cpp b/src/d/lyt/d_lyt_common_arrow.cpp index 8801b033..f328cd12 100644 --- a/src/d/lyt/d_lyt_common_arrow.cpp +++ b/src/d/lyt/d_lyt_common_arrow.cpp @@ -4,6 +4,7 @@ #include "d/d_cursor_hit_check.h" #include "d/d_pad_nav.h" #include "d/snd/d_snd_small_effect_mgr.h" +#include "m/m_vec.h" #include "rvl/MTX/mtx.h" #include "toBeSorted/arc_managers/layout_arc_manager.h" @@ -96,8 +97,10 @@ void dLytCommonArrow_c::setState(s32 state) { } } -void dLytCommonArrow_c::setTranslate(const Vec *arg) { - nw4r::math::VEC3 v(*arg); +void dLytCommonArrow_c::setTranslate(const mVec2_c *arg) { + nw4r::math::VEC3 v; + v.x = arg->x; + v.y = arg->y; v.z = 0.0f; mLytBase.getLayout()->GetRootPane()->SetTranslate(v); } diff --git a/src/d/lyt/d_lyt_deposit.cpp b/src/d/lyt/d_lyt_deposit.cpp index e2a657bb..8548de8d 100644 --- a/src/d/lyt/d_lyt_deposit.cpp +++ b/src/d/lyt/d_lyt_deposit.cpp @@ -2,10 +2,95 @@ #include "common.h" #include "d/d_cs_base.h" +#include "d/d_cs_game.h" #include "d/d_cursor_hit_check.h" +#include "d/d_message.h" +#include "d/d_pad.h" +#include "d/d_pad_nav.h" +#include "d/d_pouch.h" #include "d/lyt/d2d.h" +#include "d/lyt/d_lyt_deposit_box_cursor.h" +#include "d/lyt/d_lyt_deposit_stock.h" +#include "d/lyt/d_lyt_util_items.h" +#include "d/lyt/d_textbox.h" +#include "d/snd/d_snd_small_effect_mgr.h" +#include "d/snd/d_snd_wzsound.h" #include "f/f_profile.h" #include "f/f_profile_name.h" +#include "m/m_pad.h" +#include "m/m_vec.h" +#include "nw4r/math/math_types.h" +#include "sized_string.h" +#include "toBeSorted/arc_managers/layout_arc_manager.h" +#include "toBeSorted/file_manager.h" + +struct DepositSellValues { + /* 0x00 */ u8 itemId; + /* 0x02 */ u16 sellValue; //< 0 -> unsellable +}; + +static const DepositSellValues sItemData[] = { + { ITEM_HEART_POTION, 0}, + { ITEM_HEART_POTION_PLUS, 0}, + { ITEM_HEART_POTION_PLUS_PLUS, 0}, + + { ITEM_AIR_POTION, 0}, + { ITEM_AIR_POTION_PLUS, 0}, + + { ITEM_STAMINA_POTION, 0}, + { ITEM_STAMINA_POTION_PLUS, 0}, + + { ITEM_GUARDIAN_POTION, 0}, + { ITEM_GUARDIAN_POTION_PLUS, 0}, + + { ITEM_REVITALIZING_POTION, 0}, + { ITEM_REVITALIZING_POTION_PLUS, 0}, + {ITEM_REVITALIZING_POTION_PLUS_PLUS, 0}, + + { ITEM_FAIRY, 0}, + { ITEM_WATER, 0}, + { ITEM_SACRED_WATER, 0}, + { ITEM_MUSHROOM_SPORES, 0}, + { ITEM_GLITTERING_SPORES, 0}, + { ITEM_HOT_SOUP, 0}, + { ITEM_COLD_SOUP, 0}, + { ITEM_BOTTLE, 0}, + + { ITEM_WOODEN_SHIELD, 20}, + { ITEM_BANDED_SHIELD, 50}, + { ITEM_BRACED_SHIELD, 100}, + + { ITEM_IRON_SHIELD, 50}, + { ITEM_REINFORCED_SHIELD, 80}, + { ITEM_FORTIFIED_SHIELD, 150}, + + { ITEM_SACRED_SHIELD, 300}, + { ITEM_DIVINE_SHIELD, 400}, + { ITEM_GODDESS_SHIELD, 500}, + + { ITEM_HYLIAN_SHIELD, 0}, + + { ITEM_SMALL_SEED_SATCHEL, 50}, + { ITEM_MEDIUM_SEED_SATCHEL, 80}, + { ITEM_LARGE_SEED_SATCHEL, 150}, + + { ITEM_SMALL_QUIVER, 50}, + { ITEM_MEDIUM_QUIVER, 80}, + { ITEM_LARGE_QUIVER, 150}, + + { ITEM_SMALL_BOMB_BAG, 50}, + { ITEM_MEDIUM_BOMB_BAG, 80}, + { ITEM_LARGE_BOMB_BAG, 150}, + + { ITEM_RUPEE_MEDAL_ALSO, 100}, + { ITEM_HEART_MEDAL, 0}, + { ITEM_RUPEE_MEDAL, 0}, + { ITEM_TREASURE_MEDAL, 0}, + { ITEM_POTION_MEDAL, 0}, + { ITEM_LIFE_MEDAL, 0}, + { ITEM_CURSED_MEDAL, 0}, + { ITEM_BUG_MEDAL, 0}, +}; STATE_DEFINE(dLytDepositMain_c, ModeNone); STATE_DEFINE(dLytDepositMain_c, ModeIn); @@ -20,24 +105,39 @@ STATE_DEFINE(dLytDepositMain_c, ModeOut); #define DEPOSIT_ANIM_IN 0 #define DEPOSIT_ANIM_IN_BOX 1 +#define DEPOSIT_ANIM_CHANGE 2 +#define DEPOSIT_ANIM_SELECT_ON_BOX 3 +#define DEPOSIT_ANIM_SELECT_ON_POUCH 4 #define DEPOSIT_ANIM_FLASH_OFFSET 5 -#define DEPOSIT_ANIM_INPUT 22 +#define DEPOSIT_ANIM_SCROLL_R 13 +#define DEPOSIT_ANIM_SCROLL_L 14 +#define DEPOSIT_ANIM_BTN_DECIDE_00 15 +#define DEPOSIT_ANIM_BTN_DECIDE_01 16 +#define DEPOSIT_ANIM_BTN_DECIDE_02 17 +#define DEPOSIT_ANIM_OUT 18 +#define DEPOSIT_ANIM_BTN_ON_OFF_00 19 +#define DEPOSIT_ANIM_BTN_ON_OFF_01 20 +#define DEPOSIT_ANIM_RECYCLE 21 +#define DEPOSIT_ANIM_INPUT_00 22 +#define DEPOSIT_ANIM_INPUT_01 23 #define DEPOSIT_ANIM_ARROW_LOOP 24 #define DEPOSIT_ANIM_BTN_LOOP 25 #define DEPOSIT_ANIM_LOOP 26 +#define DEPOSIT_ANIM_HAVE_OFFSET 27 +#define DEPOSIT_ANIM_KETA 35 -#define DEPOSIT_NUM_RING_ITEMS 8 +#define DEPOSIT_NUM_ANIMS 36 void dLytDepositMain_c::initializeState_ModeNone() {} void dLytDepositMain_c::executeState_ModeNone() { - field_0x19520 = true; + mIsIdle = true; } void dLytDepositMain_c::finalizeState_ModeNone() {} void dLytDepositMain_c::initializeState_ModeIn() {} void dLytDepositMain_c::executeState_ModeIn() { - if (field_0x19538 == 0) { - if (!field_0x19520) { + if (mStateStep == 0) { + if (!mIsIdle) { if (mAnm[DEPOSIT_ANIM_IN].isEndReached()) { mAnm[DEPOSIT_ANIM_IN].setAnimEnable(false); mpBoundingBox->SetVisible(true); @@ -45,16 +145,16 @@ void dLytDepositMain_c::executeState_ModeIn() { mpBoundingItem12->SetVisible(true); mpBoundingCleanUp->SetVisible(false); setPouchItemsVisible(true); - mStock[0].navigateToItem(); - mStock[0].fn_80156530(false); - field_0x19530 = -DEPOSIT_NUM_RING_ITEMS; + mStock[STOCK_ACTIVE].navigateToItem(); + mStock[STOCK_ACTIVE].fn_80156530(false); + mCurrentPouchNavTarget = -RING_NUM_ITEMS; dCsBase_c::GetInstance()->setCursorStickTargetPane(mpRingBoundings[0]); field_0x1954C = 0; - field_0x19520 = true; + mIsIdle = true; } } } else { - if (!field_0x19520) { + if (!mIsIdle) { if (mAnm[DEPOSIT_ANIM_IN_BOX].isEndReached() && mArrow.isChangingState()) { mAnm[DEPOSIT_ANIM_IN_BOX].setAnimEnable(false); mpBoundingBox->SetVisible(false); @@ -62,15 +162,15 @@ void dLytDepositMain_c::executeState_ModeIn() { mpBoundingItem12->SetVisible(true); mpBoundingCleanUp->SetVisible(true); setPouchItemsVisible(false); - mStock[0].navigateToItem(); - mStock[0].fn_80156530(true); - s32 target = mStock[0].getCurrentNavTarget(); + mStock[STOCK_ACTIVE].navigateToItem(); + mStock[STOCK_ACTIVE].fn_80156530(true); + s32 target = mStock[STOCK_ACTIVE].getCurrentNavTarget(); if (target < 0) { - target += 12; + target += NUM_ICONS_PER_PAGE; } dCsBase_c::GetInstance()->setCursorStickTargetPane(mpItemBoundings[target]); field_0x1954C = 1; - field_0x19520 = true; + mIsIdle = true; } } } @@ -84,9 +184,9 @@ void dLytDepositMain_c::initializeState_ModeCheck() { void dLytDepositMain_c::executeState_ModeCheck() { fn_802AAFC0(); fn_802AB210(); - fn_802ACAF0(); + checkForItemPickupOrDrop(); fn_802ABB60(); - field_0x19520 = true; + mIsIdle = true; } void dLytDepositMain_c::finalizeState_ModeCheck() {} @@ -94,31 +194,246 @@ void dLytDepositMain_c::initializeState_ModeChange() { field_0x19521 = false; field_0x19522 = false; } -void dLytDepositMain_c::executeState_ModeChange() {} +void dLytDepositMain_c::executeState_ModeChange() { + if (mIsIdle) { + fn_802AC3C0(); + fn_802AB080(); + if (field_0x19550 != 0) { + field_0x19550--; + } else { + mStock[STOCK_ACTIVE].handleNavOrPoint(); + if (!mStock[STOCK_ACTIVE].isModeSort()) { + checkForItemPickupOrDrop(); + } + } + + if (!dPadNav::isPointerVisible()) { + if (!mCursor.isVisible() && mCurrentlyHoldingItemSlot >= 0) { + mCursor.setVisible(true); + } + + if (mStock[STOCK_ACTIVE].isModePouch()) { + mStock[STOCK_ACTIVE].disableModePouch(); + field_0x19522 = true; + } + } + + if (mStock[STOCK_ACTIVE].getCurrentNavTarget() >= 0) { + dCsBase_c::GetInstance()->setCursorStickTargetPane( + mpItemBoundings[mStock[STOCK_ACTIVE].getCurrentNavTarget()] + ); + fn_802AD4C0(); + } + s32 slot = mStock[STOCK_ACTIVE].getCurrentSlot(); + s32 v; + if (mCurrentlyHoldingItemSlot >= 8 && slot == mCurrentlyHoldingItemSlot - 8) { + v = -1; + } else if (mStock[STOCK_ACTIVE].getCurrentNavTarget() < 0) { + v = -1; + } else { + s32 item = mStock[STOCK_ACTIVE].getItem(mStock[STOCK_ACTIVE].getCurrentNavTarget()); + if (item != 12 && item != 50 && slot >= 0 && slot < NUM_ICONS_PER_PAGE * NUM_PAGES) { + v = FileManager::GetInstance()->getItemCheckItem(slot); + if (v == 0) { + v = -1; + } + } else { + v = -1; + } + } + loadItemText(v, true); + fn_802ABB60(); + fn_802AC670(); + } else { + if (mAnm[DEPOSIT_ANIM_CHANGE].isStop() && mArrow.isChangingState()) { + mAnm[DEPOSIT_ANIM_CHANGE].setAnimEnable(false); + mAnm[DEPOSIT_ANIM_SELECT_ON_BOX].setAnimEnable(false); + mpBoundingBox->SetVisible(false); + mpBoundingCleanUp->SetVisible(true); + mStock[STOCK_ACTIVE].fn_80156530(true); + setPouchItemsVisible(false); + field_0x1954C = 1; + mStock[STOCK_ACTIVE].returnToNormalMode(); + s32 target = mStock[STOCK_ACTIVE].getCurrentNavTarget(); + if (target < 0) { + target += NUM_ICONS_PER_PAGE; + } + dCsBase_c::GetInstance()->setCursorStickTargetPane(mpItemBoundings[target]); + if (!dPadNav::isPointerVisible()) { + fn_802AC290(target); + } + fn_802AD460(); + fn_802AD4C0(); + field_0x19550 = 1; + mIsIdle = true; + } + } +} void dLytDepositMain_c::finalizeState_ModeChange() {} void dLytDepositMain_c::initializeState_ModeArrangement() {} -void dLytDepositMain_c::executeState_ModeArrangement() {} +void dLytDepositMain_c::executeState_ModeArrangement() { + if (!mIsIdle) { + if (mAnm[DEPOSIT_ANIM_BTN_DECIDE_01].isEndReached()) { + mAnm[DEPOSIT_ANIM_BTN_DECIDE_01].setAnimEnable(false); + loadItems(mCurrentlyHoldingItemSlot - SLOT_STOCK_OFFSET); + mStock[STOCK_ACTIVE].fn_80156530(true); + field_0x1954C = 1; + mIsIdle = true; + } + } +} void dLytDepositMain_c::finalizeState_ModeArrangement() {} void dLytDepositMain_c::initializeState_ModeReverseChange() {} -void dLytDepositMain_c::executeState_ModeReverseChange() {} +void dLytDepositMain_c::executeState_ModeReverseChange() { + if (mStateStep == 0) { + if (!mIsIdle && mAnm[DEPOSIT_ANIM_CHANGE].isStop() && mArrow.isChangingState()) { + mAnm[DEPOSIT_ANIM_CHANGE].setAnimEnable(false); + mAnm[DEPOSIT_ANIM_SELECT_ON_POUCH].setAnimEnable(false); + mpBoundingBox->SetVisible(true); + mpBoundingCleanUp->SetVisible(false); + setPouchItemsVisible(true); + mStock[STOCK_ACTIVE].fn_80156530(false); + field_0x1954C = 0; + mStateStep = 1; + } + } else { + fn_802AD460(); + fn_802AC0E0(4); + mIsIdle = true; + } +} void dLytDepositMain_c::finalizeState_ModeReverseChange() {} void dLytDepositMain_c::initializeState_ModeScroll() {} -void dLytDepositMain_c::executeState_ModeScroll() {} +void dLytDepositMain_c::executeState_ModeScroll() { + s32 currentlyHeldSlot = mCurrentlyHoldingItemSlot - SLOT_STOCK_OFFSET; + dPadNav::scrollRelated(); + if (mAnm[DEPOSIT_ANIM_SCROLL_R].isEnabled()) { + if (!mIsIdle && mAnm[DEPOSIT_ANIM_SCROLL_R].isEndReached()) { + mAnm[DEPOSIT_ANIM_SCROLL_R].setFrame(0.0f); + mLyt.calc(); + mAnm[DEPOSIT_ANIM_SCROLL_R].setAnimEnable(false); + for (int i = 0; i < NUM_STOCKS; i++) { + mStock[i].nextPage(field_0x1952C); + mStock[i].loadItems(currentlyHeldSlot); + } + mStock[STOCK_ACTIVE].fn_80156530(true); + field_0x1954C = 1; + fn_802AD370(); + fn_802AD460(); + if (mStock[STOCK_ACTIVE].getArrowDirection() >= dLytDepositStock_c::ARROW_NONE) { + fn_802AD4C0(); + } + field_0x1952C = true; + mIsIdle = true; + } else if (!mHasScrolledOtherStocks && mAnm[DEPOSIT_ANIM_SCROLL_R].getFrame() >= 2.0f) { + mHasScrolledOtherStocks = true; + u8 oldPage = mStock[2].getPage(); + mStock[2].setPage(mStock[1].getPage()); + mStock[2].nextPage(false); + mStock[2].loadItems(currentlyHeldSlot); + mStock[2].setPage(oldPage); + } + } else { + if (!mIsIdle && mAnm[DEPOSIT_ANIM_SCROLL_L].isEndReached()) { + mAnm[DEPOSIT_ANIM_SCROLL_L].setFrame(0.0f); + mLyt.calc(); + mAnm[DEPOSIT_ANIM_SCROLL_L].setAnimEnable(false); + for (int i = 0; i < NUM_STOCKS; i++) { + mStock[i].prevPage(field_0x1952C); + mStock[i].loadItems(currentlyHeldSlot); + } + mStock[STOCK_ACTIVE].fn_80156530(true); + field_0x1954C = 1; + fn_802AD370(); + fn_802AD460(); + if (mStock[STOCK_ACTIVE].getArrowDirection() >= dLytDepositStock_c::ARROW_NONE) { + fn_802AD4C0(); + } + field_0x1952C = true; + mIsIdle = true; + } else if (!mHasScrolledOtherStocks && mAnm[DEPOSIT_ANIM_SCROLL_L].getFrame() >= 2.0f) { + mHasScrolledOtherStocks = true; + u8 oldPage = mStock[1].getPage(); + mStock[1].setPage(mStock[2].getPage()); + mStock[1].prevPage(false); + mStock[1].loadItems(currentlyHeldSlot); + mStock[1].setPage(oldPage); + } + } +} void dLytDepositMain_c::finalizeState_ModeScroll() {} void dLytDepositMain_c::initializeState_ModeRecycle() {} -void dLytDepositMain_c::executeState_ModeRecycle() {} +void dLytDepositMain_c::executeState_ModeRecycle() { + if (mStateStep == 0) { + if (mAnm[DEPOSIT_ANIM_BTN_DECIDE_02].isEndReached()) { + mAnm[DEPOSIT_ANIM_BTN_DECIDE_02].setAnimEnable(false); + mAnm[DEPOSIT_ANIM_OUT].setAnimEnable(true); + mAnm[DEPOSIT_ANIM_OUT].setFrame(0.0f); + mLyt.calc(); + dCsBase_c::GetInstance()->setVisible(false); + dPadNav::setNavEnabled(false, false); + if (field_0x1954C != 0) { + mArrow.requestOut(); + mStateStep = 2; + } else { + mStateStep = 1; + } + } + } else { + bool b = mStateStep != 2 || mArrow.isChangingState(); + if (mAnm[DEPOSIT_ANIM_OUT].isEndReached() && b) { + mAnm[DEPOSIT_ANIM_OUT].setAnimEnable(false); + mAnm[DEPOSIT_ANIM_RECYCLE].setAnimEnable(true); + mAnm[DEPOSIT_ANIM_RECYCLE].setFrame(0.0f); + mLyt.calc(); + mAnm[DEPOSIT_ANIM_RECYCLE].setAnimEnable(false); + mCurrentlyHoldingItemSlot = -1; + mIsIdle = true; + } + } +} void dLytDepositMain_c::finalizeState_ModeRecycle() {} void dLytDepositMain_c::initializeState_ModeArrangementOut() {} -void dLytDepositMain_c::executeState_ModeArrangementOut() {} +void dLytDepositMain_c::executeState_ModeArrangementOut() { + if (mStateStep == 0) { + if (mAnm[DEPOSIT_ANIM_BTN_DECIDE_01].isEndReached()) { + mAnm[DEPOSIT_ANIM_BTN_DECIDE_01].setAnimEnable(false); + mAnm[DEPOSIT_ANIM_OUT].setAnimEnable(true); + mAnm[DEPOSIT_ANIM_OUT].setFrame(0.0f); + mLyt.calc(); + dCsBase_c::GetInstance()->setVisible(false); + dPadNav::setNavEnabled(false, false); + mArrow.requestOut(); + mStateStep = 1; + } + } else { + if (mAnm[DEPOSIT_ANIM_OUT].isEndReached() && mArrow.isChangingState()) { + mAnm[DEPOSIT_ANIM_OUT].setAnimEnable(false); + mAnm[DEPOSIT_ANIM_BTN_ON_OFF_01].setAnimEnable(true); + mAnm[DEPOSIT_ANIM_BTN_ON_OFF_01].setFrame(0.0f); + mLyt.calc(); + mAnm[DEPOSIT_ANIM_BTN_ON_OFF_01].setAnimEnable(false); + field_0x19528 = true; + mStock[STOCK_ACTIVE].disableModeSort(); + mStock[STOCK_ACTIVE].navigateToItem(); + mIsIdle = true; + } + } +} void dLytDepositMain_c::finalizeState_ModeArrangementOut() {} void dLytDepositMain_c::initializeState_ModeOut() {} -void dLytDepositMain_c::executeState_ModeOut() {} +void dLytDepositMain_c::executeState_ModeOut() { + if (mAnm[DEPOSIT_ANIM_BTN_DECIDE_00].isEndReached()) { + mAnm[DEPOSIT_ANIM_BTN_DECIDE_00].setAnimEnable(false); + mIsIdle = true; + } +} void dLytDepositMain_c::finalizeState_ModeOut() {} dLytDepositMain_c::dLytDepositMain_c() : mStateMgr(*this) {} @@ -162,8 +477,6 @@ static const d2d::LytBrlanMapping brlanMap[] = { { "depositBox_00_keta.brlan", "G_keta_00"}, }; -#define DEPOSIT_NUM_ANIMS 36 - static const char *sRingBoundingNames[] = { "B_ringA_00", "B_ringB_00", "B_ringC_00", "B_ringD_00", "B_ringE_00", "B_ringF_00", "B_ringG_00", "B_ringH_00", }; @@ -233,11 +546,11 @@ bool dLytDepositMain_c::build(d2d::ResAccIf_c *resAcc) { mAnm[DEPOSIT_ANIM_LOOP].setAnimEnable(true); mAnm[DEPOSIT_ANIM_LOOP].setFrame(0.0f); - mAnm[DEPOSIT_ANIM_INPUT].setAnimEnable(true); - mAnm[DEPOSIT_ANIM_INPUT].setForwardOnce(); - mAnm[DEPOSIT_ANIM_INPUT].setFrame(mAnm[DEPOSIT_ANIM_INPUT].getLastFrame()); + mAnm[DEPOSIT_ANIM_INPUT_00].setAnimEnable(true); + mAnm[DEPOSIT_ANIM_INPUT_00].setForwardOnce(); + mAnm[DEPOSIT_ANIM_INPUT_00].setFrame(mAnm[DEPOSIT_ANIM_INPUT_00].getLastFrame()); - for (int i = 0; i < DEPOSIT_NUM_RING_ITEMS; i++) { + for (int i = 0; i < RING_NUM_ITEMS; i++) { mAnm[i + DEPOSIT_ANIM_FLASH_OFFSET].setAnimEnable(true); mAnm[i + DEPOSIT_ANIM_FLASH_OFFSET].setToEnd(); } @@ -246,9 +559,9 @@ bool dLytDepositMain_c::build(d2d::ResAccIf_c *resAcc) { mAnm[DEPOSIT_ANIM_IN].setAnimEnable(false); mAnm[DEPOSIT_ANIM_ARROW_LOOP].setAnimEnable(false); - mAnm[DEPOSIT_ANIM_INPUT].setAnimEnable(false); + mAnm[DEPOSIT_ANIM_INPUT_00].setAnimEnable(false); - for (int i = 0; i < DEPOSIT_NUM_RING_ITEMS; i++) { + for (int i = 0; i < RING_NUM_ITEMS; i++) { mAnm[i + DEPOSIT_ANIM_FLASH_OFFSET].setAnimEnable(false); } @@ -262,7 +575,7 @@ bool dLytDepositMain_c::build(d2d::ResAccIf_c *resAcc) { mArrow.build(); mArrow.setState(1); - fn_802A9E80(); + setModeNone(); field_0x19521 = false; field_0x19522 = false; @@ -272,17 +585,17 @@ bool dLytDepositMain_c::build(d2d::ResAccIf_c *resAcc) { field_0x19526 = false; field_0x19527 = false; field_0x19528 = false; - field_0x19529 = false; + mHasScrolledOtherStocks = false; field_0x1952A = true; field_0x1952B = false; field_0x1952C = true; - field_0x19530 = -1; - field_0x19534 = -1; - field_0x19538 = 0; - field_0x1953C = 0; + mCurrentPouchNavTarget = -1; + mCurrentlyHoldingItemSlot = -1; + mStateStep = 0; + mCursorLocation = dLytDepositBoxCursor_c::LOC_POUCH; field_0x19540 = 0; - field_0x19544 = 0; + mItemSellValue = 0; field_0x19548 = -1; field_0x1954C = 0; field_0x19550 = 0; @@ -291,6 +604,430 @@ bool dLytDepositMain_c::build(d2d::ResAccIf_c *resAcc) { return true; } +bool dLytDepositMain_c::execute() { + field_0x1952B = false; + mCsHitCheck.resetCachedHitboxes(); + mCsHitCheck.execute(); + + for (int i = 0; i < NUM_STOCKS; i++) { + mStockNodes[i].mpLytPane->execute(); + } + + mStock[STOCK_ACTIVE].setSellBlocked(mItemSellValue <= 0); + mStock[STOCK_ACTIVE].setSortBlocked(mCurrentlyHoldingItemSlot >= 0); + + mStateMgr.executeState(); + mCursor.execute(); + + for (int i = 0; i < RING_NUM_ITEMS; i++) { + if (mPouchItemIds[i] < 50) { + mRingNodes[i].mpLytPane->execute(); + } + } + + for (int i = 0; i < DEPOSIT_ANIM_HAVE_OFFSET; i++) { + if (mAnm[i].isEnabled()) { + if (i >= 19 && i <= 23) { + if (mAnm[i].isStop()) { + mAnm[i].setAnimEnable(false); + } + } + mAnm[i].play(); + } + } + + mLyt.calc(); + + nw4r::math::VEC3 t = mpPaneCommonArrow->GetTranslate(); + mVec2_c v; + v.x = t.x; + v.y = t.y; + mArrow.setTranslate(&v); + mArrow.execute(); + + field_0x1952A = dPadNav::isPointerVisible(); + + return true; +} + +bool dLytDepositMain_c::draw() { + mLyt.addToDrawList(); + mCursor.draw(); + mArrow.draw(); + return true; +} + +bool dLytDepositMain_c::remove() { + dCsMgr_c::GetInstance()->unregistCursorTarget(&mCsHitCheck); + + // Okay this one does need temps to avoid regswaps, the others probably should use temps too for consistency + d2d::SubPaneList::Iterator it = mStockList.GetBeginIter(); + d2d::SubPaneList::Iterator end = mStockList.GetEndIter(); + for (; it != end; ++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 < NUM_STOCKS; i++) { + mStockNodes[i].mpLytPane->remove(); + } + + it = mRingList.GetBeginIter(); + end = mRingList.GetEndIter(); + for (; it != end; ++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 < RING_NUM_ITEMS; i++) { + mRingNodes[i].mpLytPane->remove(); + } + + mLyt.unbindAnims(); + + for (int i = 0; i < DEPOSIT_NUM_ANIMS; i++) { + mAnm[i].remove(); + } + + mCursor.remove(); + + mArrow.remove(); + + return true; +} + +void dLytDepositMain_c::setModeNone() { + mStateMgr.changeState(StateID_ModeNone); + mIsIdle = false; +} + +void dLytDepositMain_c::setModeIn() { + s32 loc; + if (field_0x19527) { + loc = mCursorLocation; + } else { + loc = dLytDepositBoxCursor_c::LOC_POUCH; + } + fn_802AAB30(); + + if (loc == dLytDepositBoxCursor_c::LOC_POUCH) { + mAnm[DEPOSIT_ANIM_IN].setAnimEnable(true); + + mAnm[DEPOSIT_ANIM_INPUT_00].setAnimEnable(true); + mAnm[DEPOSIT_ANIM_INPUT_00].setForwardOnce(); + mAnm[DEPOSIT_ANIM_INPUT_00].setFrame(mAnm[DEPOSIT_ANIM_INPUT_00].getLastFrame()); + mLyt.calc(); + mAnm[DEPOSIT_ANIM_INPUT_00].setAnimEnable(false); + + mStateStep = 0; + } else { + mStock[STOCK_ACTIVE].fn_80156530(true); + mAnm[DEPOSIT_ANIM_IN_BOX].setAnimEnable(true); + mAnm[DEPOSIT_ANIM_IN_BOX].setFrame(0.0f); + + mAnm[DEPOSIT_ANIM_INPUT_00].setAnimEnable(true); + mAnm[DEPOSIT_ANIM_INPUT_00].setForwardOnce(); + mAnm[DEPOSIT_ANIM_INPUT_00].setFrame(mAnm[DEPOSIT_ANIM_INPUT_00].getLastFrame()); + mLyt.calc(); + mAnm[DEPOSIT_ANIM_INPUT_00].setAnimEnable(false); + + mArrow.requestIn(); + mStateStep = 1; + } + + dPadNav::setNavEnabled(false, false); + mStateMgr.changeState(StateID_ModeIn); + mIsIdle = false; +} + +void dLytDepositMain_c::setModeCheck() { + s32 slot = mCurrentPouchNavTarget; + if (slot < 0) { + slot += RING_NUM_ITEMS; + } + dCsBase_c::GetInstance()->setCursorStickTargetPane(mpRingBoundings[slot]); + fn_802AD460(); + mStateMgr.changeState(StateID_ModeCheck); + mIsIdle = false; +} + +void dLytDepositMain_c::setModeChange(bool unk) { + if (unk) { + mAnm[DEPOSIT_ANIM_CHANGE].setAnimEnable(true); + mAnm[DEPOSIT_ANIM_CHANGE].setFrame(0.0f); + mAnm[DEPOSIT_ANIM_CHANGE].setForwardOnce(); + + mAnm[DEPOSIT_ANIM_SELECT_ON_BOX].setAnimEnable(true); + mAnm[DEPOSIT_ANIM_SELECT_ON_BOX].setFrame(0.0f); + mAnm[DEPOSIT_ANIM_SELECT_ON_BOX].setForwardOnce(); + mLyt.calc(); + + mIsIdle = false; + fn_802AD400(); + mArrow.requestIn(); + mStateStep = 0; + } + mStateMgr.changeState(StateID_ModeChange); +} + +void dLytDepositMain_c::setModeArrangement() { + mAnm[DEPOSIT_ANIM_BTN_DECIDE_01].setAnimEnable(true); + mAnm[DEPOSIT_ANIM_BTN_DECIDE_01].setFrame(0.0f); + mLyt.calc(); + mIsIdle = false; + dPadNav::setNavEnabled(true, false); + mStateMgr.changeState(StateID_ModeArrangement); +} + +void dLytDepositMain_c::loadItemText(s32 itemId, s32 where) { + dTextBox_c *box1, *box2; + + if (where == 0) { + box1 = mLyt.getTextBox("T_message_08"); + box2 = mLyt.getTextBox("T_messageS_08"); + } else { + box1 = mLyt.getTextBox("T_nameSpace_00"); + box2 = mLyt.getTextBox("T_nameSpaceS_00"); + } + + if (itemId < 0) { + static wchar_t empty[] = L""; + box1->setTextWithGlobalTextProcessor(empty); + box2->setTextWithGlobalTextProcessor(empty); + } else { + const wchar_t *str; + if (where == 0) { + SizedString<32> msg; + msg.sprintf("TRUSTEE_ITEM_%03d", itemId); + str = dMessage_c::getTextMessageByLabel(msg, true, nullptr, 0); + } else { + // TODO check if we can avoid this cast... + // getItemText has a bunch of other users as well + str = getItemText((u16)itemId); + } + box1->setTextWithGlobalTextProcessor(str); + box2->setTextWithGlobalTextProcessor(str); + } +} + +void dLytDepositMain_c::checkForItemPickupOrDrop() { + bool anyPickup = false; + + if (dPad::getDownTrigA()) { + s32 item; + if (mCurrentlyHoldingItemSlot < 0) { + // Not holding an item... + if (mCurrentPouchNavTarget >= 0 && mPouchItemIds[mCurrentPouchNavTarget] != 12 && + // ... and picking up an item from the pouch + mPouchItemIds[mCurrentPouchNavTarget] != 50) { + mCursorLocation = dLytDepositBoxCursor_c::LOC_POUCH; + field_0x19540 = convertLytPouchSlot2(mCurrentPouchNavTarget); + item = getPouchItemIdForIndex(mCurrentPouchNavTarget, false); + mCurrentlyHoldingItemSlot = mCurrentPouchNavTarget; + mCursor.init(mCursorLocation, mCurrentPouchNavTarget, mPouchItemIds[mCurrentPouchNavTarget], false); + mRingNodes[mCurrentPouchNavTarget].mpPane->SetVisible(false); + mAnm[mCurrentPouchNavTarget + DEPOSIT_ANIM_FLASH_OFFSET].setAnimEnable(true); + mAnm[mCurrentPouchNavTarget + DEPOSIT_ANIM_FLASH_OFFSET].setFrame(0.0f); + mLyt.calc(); + mAnm[mCurrentPouchNavTarget + DEPOSIT_ANIM_FLASH_OFFSET].setAnimEnable(false); + + mPouchItems[mCurrentPouchNavTarget].setOff(); + loadItemText(-1, false); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_SHOP_STK_POUCH_CHACH_ITEM); + anyPickup = true; + } else if (mStock[STOCK_ACTIVE].getCurrentNavTarget() >= 0) { + s32 activeItem = mStock[STOCK_ACTIVE].getItem(mStock[STOCK_ACTIVE].getCurrentNavTarget()); + if (activeItem != 12) { + // ... and picking up an item from the stock + s32 stockSlot = mStock[STOCK_ACTIVE].getCurrentSlot(); + mCursorLocation = dLytDepositBoxCursor_c::LOC_STOCK; + field_0x19540 = stockSlot; + item = FileManager::GetInstance()->getItemCheckItem(stockSlot); + mCurrentlyHoldingItemSlot = stockSlot + SLOT_STOCK_OFFSET; + mCursor.init( + mCursorLocation, stockSlot, + mStock[STOCK_ACTIVE].getItem(mStock[STOCK_ACTIVE].getCurrentNavTarget()), false + ); + mStock[STOCK_ACTIVE].pickUpItem(stockSlot, 0); + loadItemText(-1, true); + field_0x19554 = 0; + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_SHOP_STK_STOCK_CHACH_ITEM); + anyPickup = true; + } + } + + if (!anyPickup) { + // didn't pick anything up + return; + } + + mAnm[DEPOSIT_ANIM_ARROW_LOOP].setAnimEnable(true); + mAnm[DEPOSIT_ANIM_ARROW_LOOP].setFrame(0.0f); + + for (int i = 0; i < (s32)ARRAY_LENGTH(sItemData); i++) { + if (item == sItemData[i].itemId) { + mItemSellValue = sItemData[i].sellValue; + if (mItemSellValue == 0) { + mAnm[DEPOSIT_ANIM_INPUT_00].setAnimEnable(true); + mAnm[DEPOSIT_ANIM_INPUT_00].setForwardOnce(); + } else { + s32 frame = getItemSellValueFrame(mItemSellValue); + mAnm[DEPOSIT_ANIM_INPUT_00].setAnimEnable(true); + mAnm[DEPOSIT_ANIM_INPUT_00].setBackwardsOnce(); + mAnm[DEPOSIT_ANIM_KETA].setAnimEnable(true); + mAnm[DEPOSIT_ANIM_KETA].setFrame(frame); + } + break; + } + } + + mAnm[DEPOSIT_ANIM_INPUT_01].setAnimEnable(true); + mAnm[DEPOSIT_ANIM_INPUT_01].setForwardOnce(); + } else { + // Currently holding an item... + bool b2 = false; + if (mCurrentPouchNavTarget >= 0 && mPouchItemIds[mCurrentPouchNavTarget] != 50) { + // ... and dropping the item onto the pouch + s32 oldItem = mPouchItemIds[mCurrentPouchNavTarget]; + if (mCurrentlyHoldingItemSlot < SLOT_STOCK_OFFSET) { + // Source item is from pouch, swap pouch items + mPouchItemIds[mCurrentPouchNavTarget] = mPouchItemIds[mCurrentlyHoldingItemSlot]; + mPouchItemIds[mCurrentlyHoldingItemSlot] = oldItem; + swapAdventurePouchItems( + convertLytPouchSlot(mCurrentPouchNavTarget), convertLytPouchSlot(mCurrentlyHoldingItemSlot) + ); + fn_802AAEC0(mCurrentPouchNavTarget); + mPouchItems[mCurrentlyHoldingItemSlot].reset(); + fn_802AAEC0(mCurrentlyHoldingItemSlot); + if (mCurrentlyHoldingItemSlot == mCurrentPouchNavTarget) { + b2 = true; + } + } else { + // Source item is from stock, move item from stock to pouch + s32 actualSlot = mCurrentlyHoldingItemSlot - SLOT_STOCK_OFFSET; + mPouchItemIds[mCurrentPouchNavTarget] = getDepositItemForSlot(actualSlot); + swapStockAndPouchItems(convertLytPouchSlot(mCurrentPouchNavTarget), actualSlot); + loadItems(-1); + fn_802AAEC0(mCurrentPouchNavTarget); + + mStock[STOCK_ACTIVE].field_0x684E = false; + for (int i = 0; i < NUM_STOCKS; i++) { + mStock[i].field_0x684E = false; + } + } + + if (oldItem != 12 && !b2) { + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_SHOP_STK_POUCH_RELEASE_ITEM_CHANGE); + } else { + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_SHOP_STK_POUCH_RELEASE_ITEM); + } + mItemSellValue = 0; + anyPickup = true; + } else if (mStock[STOCK_ACTIVE].getCurrentNavTarget() >= 0 && mStock[STOCK_ACTIVE].getActiveItem() != 50) { + // ... and dropping the item into the stock + s32 slot = mStock[STOCK_ACTIVE].getCurrentSlot(); + field_0x19554 = slot; + s32 item = mStock[STOCK_ACTIVE].getActiveItem(); + if (mCurrentlyHoldingItemSlot < SLOT_STOCK_OFFSET) { + // Source item is from pouch, so move item from pouch to stock + swapStockAndPouchItems(convertLytPouchSlot(mCurrentlyHoldingItemSlot), field_0x19554); + mStock[STOCK_ACTIVE].setItem( + mStock[STOCK_ACTIVE].getCurrentNavTarget(), mPouchItemIds[mCurrentlyHoldingItemSlot] + ); + mPouchItemIds[mCurrentlyHoldingItemSlot] = item; + mPouchItems[mCurrentlyHoldingItemSlot].reset(); + fn_802AAEC0(mCurrentlyHoldingItemSlot); + } else { + // Source item is from stock, so swap stock items + swapStockItems(mCurrentlyHoldingItemSlot - SLOT_STOCK_OFFSET, slot); + loadItems(-1); + if (!dPadNav::isPointerVisible()) { + mStock[STOCK_ACTIVE].field_0x684B = true; + } + mStock[STOCK_ACTIVE].fn_80156530(true); + field_0x1954C = 1; + if (field_0x19554 == mCurrentlyHoldingItemSlot - SLOT_STOCK_OFFSET) { + b2 = true; + } + } + + for (int i = 0; i < NUM_STOCKS; i++) { + mStock[i].field_0x684E = false; + } + + if (item != 12 && !b2) { + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_SHOP_STK_STOCK_RELEASE_ITEM_CHANGE); + } else { + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_SHOP_STK_STOCK_RELEASE_ITEM); + } + mItemSellValue = 0; + anyPickup = true; + } + if (anyPickup) { + if (mCurrentlyHoldingItemSlot < SLOT_STOCK_OFFSET) { + mRingNodes[mCurrentlyHoldingItemSlot].mpPane->SetVisible(true); + } + mCurrentlyHoldingItemSlot = -1; + mAnm[DEPOSIT_ANIM_ARROW_LOOP].setAnimEnable(false); + mAnm[DEPOSIT_ANIM_INPUT_00].setAnimEnable(true); + mAnm[DEPOSIT_ANIM_INPUT_00].setForwardOnce(); + mAnm[DEPOSIT_ANIM_INPUT_01].setAnimEnable(true); + mAnm[DEPOSIT_ANIM_INPUT_01].setBackwardsOnce(); + mCursor.setVisible(false); + } + } + + } else { + if (dPad::getDownTrigB() && mCurrentlyHoldingItemSlot >= 0) { + if (mStock[STOCK_ACTIVE].isModeSell()) { + // cancel while item over sell button + mAnm[DEPOSIT_ANIM_RECYCLE].setAnimEnable(true); + mAnm[DEPOSIT_ANIM_RECYCLE].setBackwardsOnce(); + mStock[STOCK_ACTIVE].disableModeSell(); + field_0x19524 = false; + if (field_0x1954C == 0) { + // TODO: Why is this not >= ... + if (mCurrentlyHoldingItemSlot > SLOT_STOCK_OFFSET) { + fn_802AC0E0(0); + } else { + fn_802AC0E0(mCurrentlyHoldingItemSlot); + } + } else { + if ((mCurrentlyHoldingItemSlot < SLOT_STOCK_OFFSET) || + ((mCurrentlyHoldingItemSlot - SLOT_STOCK_OFFSET) / 12) != mStock[STOCK_ACTIVE].getPage()) { + fn_802AC290(0); + } else { + fn_802AC290((mCurrentlyHoldingItemSlot - SLOT_STOCK_OFFSET) % 12); + } + } + } + if (mCurrentlyHoldingItemSlot < SLOT_STOCK_OFFSET) { + mRingNodes[mCurrentlyHoldingItemSlot].mpPane->SetVisible(true); + } else { + mStock[STOCK_ACTIVE].pickUpItem(mCurrentlyHoldingItemSlot - SLOT_STOCK_OFFSET, true); + loadItems(-1); + mStock[STOCK_ACTIVE].field_0x684B = true; + mStock[STOCK_ACTIVE].fn_80156530(true); + } + mCurrentlyHoldingItemSlot = -1; + mAnm[DEPOSIT_ANIM_ARROW_LOOP].setAnimEnable(false); + mAnm[DEPOSIT_ANIM_INPUT_00].setAnimEnable(true); + mAnm[DEPOSIT_ANIM_INPUT_00].setForwardOnce(); + mAnm[DEPOSIT_ANIM_INPUT_01].setAnimEnable(true); + mAnm[DEPOSIT_ANIM_INPUT_01].setBackwardsOnce(); + mCursor.setVisible(false); + mItemSellValue = 0; + field_0x1952B = 1; + } + } +} + STATE_DEFINE(dLytDeposit_c, None); STATE_DEFINE(dLytDeposit_c, In); STATE_DEFINE(dLytDeposit_c, Check); @@ -302,14 +1039,32 @@ STATE_DEFINE(dLytDeposit_c, Recycle); STATE_DEFINE(dLytDeposit_c, ArrangementOut); STATE_DEFINE(dLytDeposit_c, Out); -SPECIAL_BASE_PROFILE(LYT_DEPOSIT, dLytDeposit_c, fProfile::LYT_DEPOSIT, 0x2B9, 0); - void dLytDeposit_c::initializeState_None() {} -void dLytDeposit_c::executeState_None() {} +void dLytDeposit_c::executeState_None() { + if (field_0x19998) { + mMain.setModeIn(); + mStateMgr.changeState(StateID_In); + field_0x19998 = false; + } +} void dLytDeposit_c::finalizeState_None() {} void dLytDeposit_c::initializeState_In() {} -void dLytDeposit_c::executeState_In() {} +void dLytDeposit_c::executeState_In() { + if (mMain.isIdle()) { + if (mMain.getStateStep() == 0) { + mMain.setModeCheck(); + mStateMgr.changeState(StateID_Check); + } else { + mMain.setModeChange(false); + mStateMgr.changeState(StateID_Change); + } + + dCsBase_c::GetInstance()->setVisible(true); + dPadNav::setNavEnabled(true, false); + dCsBase_c::GetInstance()->setCursorStickPriority(0x86); + } +} void dLytDeposit_c::finalizeState_In() {} void dLytDeposit_c::initializeState_Check() {} @@ -343,3 +1098,93 @@ void dLytDeposit_c::finalizeState_ArrangementOut() {} void dLytDeposit_c::initializeState_Out() {} void dLytDeposit_c::executeState_Out() {} void dLytDeposit_c::finalizeState_Out() {} + +SPECIAL_BASE_PROFILE(LYT_DEPOSIT, dLytDeposit_c, fProfile::LYT_DEPOSIT, 0x2B9, 0); + +bool dLytDeposit_c::build() { + void *data = LayoutArcManager::GetInstance()->getLoadedData("Shop"); + mResAcc.attach(data, ""); + mMain.build(&mResAcc); + return true; +} + +int dLytDeposit_c::create() { + sInstance = this; + allocateLytWork1Heap("dLytDeposit_c::m_allocator", false); + mStateMgr.changeState(StateID_None); + field_0x19998 = false; + field_0x19999 = false; + field_0x1999A = false; + return SUCCEEDED; +} + +int dLytDeposit_c::execute() { + if (*mStateMgr.getStateID() != StateID_None) { + if (dPad::getDownTrigDown()) { + dPad::ex_c::getInstance()->centerCursor(mPad::getCurrentCoreID(), true); + } + if (dCsBase_c::GetInstance()->isVisible()) { + dCsGame_c::GetInstance()->pointerDefSet(); + } + mMain.execute(); + } + mStateMgr.executeState(); + return SUCCEEDED; +} + +int dLytDeposit_c::draw() { + if (*mStateMgr.getStateID() != StateID_None || field_0x19999) { + mMain.draw(); + } + return SUCCEEDED; +} + +int dLytDeposit_c::doDelete() { + dCsBase_c::GetInstance()->setCursorStickPriority2(0x8A); + mMain.remove(); + mResAcc.detach(); + sInstance = nullptr; + return SUCCEEDED; +} + +bool dLytDeposit_c::checkForNavRight() { + if (dPad::getDownTrigRight()) { + if (!mMain.isSellableItem()) { + field_0x1999A = false; + return true; + } + } + + if (dPad::getDownTrigA() && mMain.getArrowDirection() == dLytDepositStock_c::ARROW_RIGHT) { + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_SHOP_STK_STOCK_SELECT_TURN_PAGE_RIGHT); + field_0x1999A = true; + return true; + } else if (dPadNav::isPointerVisible() && dPadNav::isMplsNavRightGesture()) { + mMain.setField_0x1952C(false); + field_0x1999A = false; + return true; + } + + return false; +} + +bool dLytDeposit_c::checkForNavLeft() { + if (dPad::getDownTrigLeft()) { + if (!mMain.isSellableItem()) { + field_0x1999A = false; + return true; + } + } + + if (dPad::getDownTrigA() && mMain.getArrowDirection() == dLytDepositStock_c::ARROW_LEFT) { + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_SHOP_STK_STOCK_SELECT_TURN_PAGE_LEFT); + field_0x1999A = true; + return true; + } else if (dPadNav::isPointerVisible() && !mMain.isSellableItem() && dPadNav::isMplsNavLeftGesture()) { + mMain.setField_0x1952C(false); + field_0x1999A = false; + return true; + } + + return false; +} diff --git a/src/d/lyt/d_lyt_deposit_box_cursor.cpp b/src/d/lyt/d_lyt_deposit_box_cursor.cpp index 3a42105c..7ba91dfa 100644 --- a/src/d/lyt/d_lyt_deposit_box_cursor.cpp +++ b/src/d/lyt/d_lyt_deposit_box_cursor.cpp @@ -119,6 +119,7 @@ void dLytDepositBoxCursor_c::realizeNav() { } else if (field_0x949) { s = 6; } else if (mItemLocation == LOC_POUCH) { + // Flip the cursor for pouch slot 0 so that it's not above the screen edge s = mSlot == 0 ? 1 : 0; if (field_0x950 == 12) { s += 2; diff --git a/src/d/lyt/d_lyt_deposit_stock.cpp b/src/d/lyt/d_lyt_deposit_stock.cpp index 1dacffba..4bb60172 100644 --- a/src/d/lyt/d_lyt_deposit_stock.cpp +++ b/src/d/lyt/d_lyt_deposit_stock.cpp @@ -93,18 +93,18 @@ bool dLytDepositStock_c::build(d2d::ResAccIf_c *resAcc) { mSelectedItemId = -1; field_0x685C = -1; - field_0x6849 = false; - field_0x684A = false; + mIsSellBlocked = false; + mIsSortBlocked = false; field_0x684B = false; field_0x684C = true; field_0x684E = false; mArrowDirection = ARROW_NONE; - field_0x6845 = false; - field_0x6846 = false; - field_0x6847 = false; - field_0x6848 = false; + mIsModePouch = false; + mIsModeSell = false; + mIsModeSort = false; + mIsModeFinish = false; mSavedArrowDirection = ARROW_NONE; @@ -271,13 +271,13 @@ void dLytDepositStock_c::fn_80156530(bool unk) { } field_0x684B = false; - field_0x6845 = false; - field_0x6846 = false; - if (!field_0x6847) { + mIsModePouch = false; + mIsModeSell = false; + if (!mIsModeSort) { // okay - field_0x6847 = false; + mIsModeSort = false; } - field_0x6848 = false; + mIsModeFinish = false; if (mArrowDirection >= ARROW_NONE) { handleSpecialNavMode(); } @@ -298,7 +298,7 @@ void dLytDepositStock_c::handleNavOrPoint() { s32 dir = checkNav(); if (!isNavModeItem()) { handleSpecialNavMode(); - } else if (!field_0x6845 && !field_0x6846 && !field_0x6847 && !field_0x6848 && mSavedArrowDirection >= 2) { + } else if (!mIsModePouch && !mIsModeSell && !mIsModeSort && !mIsModeFinish && mSavedArrowDirection >= 2) { s32 target = mCurrentNavTarget; if (target < 0 || field_0x684C) { if (dir != dPadNav::FS_STICK_NONE || dCsBase_c::GetInstance()->isCursorStickVisible()) { @@ -397,9 +397,9 @@ void dLytDepositStock_c::handleNavOrPoint() { mAnm[anmIdx].setAnimEnable(false); dRumble_c::start(dRumble_c::sRumblePreset1, dRumble_c::FLAG_SLOT0); mCurrentNavTarget = nextTarget; - field_0x6846 = false; - field_0x6847 = false; - field_0x6848 = false; + mIsModeSell = false; + mIsModeSort = false; + mIsModeFinish = false; navigateToItem(); } mNavMode = 0; @@ -446,7 +446,7 @@ s32 dLytDepositStock_c::checkNav() { direction = dPadNav::FS_STICK_DOWN; } else if (target >= 6) { if (target >= 10) { - if (field_0x684A) { + if (mIsSortBlocked) { if (target == 11) { direction = dPadNav::FS_STICK_NONE; } else { @@ -464,11 +464,11 @@ s32 dLytDepositStock_c::checkNav() { case dPadNav::FS_STICK_DOWN: if (target >= 6) { if (target < 8) { - if (field_0x6849) { + if (mIsSellBlocked) { direction = dPadNav::FS_STICK_NONE; } } else if (target >= 10) { - if (field_0x684A) { + if (mIsSortBlocked) { direction = dPadNav::FS_STICK_NONE; } } else { @@ -478,14 +478,14 @@ s32 dLytDepositStock_c::checkNav() { break; case dPadNav::FS_STICK_DOWN_LEFT: if (target == 0 || target == 11) { - if (target == 11 && field_0x684A) { + if (target == 11 && mIsSortBlocked) { direction = dPadNav::FS_STICK_LEFT; } else { direction = dPadNav::FS_STICK_DOWN; } } else if (target >= 6) { if (target <= 7) { - if (field_0x6849) { + if (mIsSellBlocked) { if (target == 6) { direction = dPadNav::FS_STICK_NONE; } else { @@ -495,7 +495,7 @@ s32 dLytDepositStock_c::checkNav() { direction = dPadNav::FS_STICK_DOWN; } } else if (target == 11) { - if (field_0x684A) { + if (mIsSortBlocked) { direction = dPadNav::FS_STICK_NONE; } else { direction = dPadNav::FS_STICK_DOWN; @@ -611,33 +611,33 @@ void dLytDepositStock_c::pickUpItem(s32 slot, bool unk) { } void dLytDepositStock_c::navigateToPouch() { - field_0x6845 = true; + mIsModePouch = true; mSavedArrowDirection = ARROW_NONE; } void dLytDepositStock_c::navigateToSell() { - if (!field_0x6846) { + if (!mIsModeSell) { dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_SHOP_STK_POINT_SELL); } - field_0x6846 = true; + mIsModeSell = true; mNavMode = NAV_SELL; mSavedArrowDirection = ARROW_NONE; } void dLytDepositStock_c::navigateToSort() { - if (!field_0x6847) { + if (!mIsModeSort) { dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_SHOP_STK_STOCK_POINT_TRIM); } - field_0x6847 = true; + mIsModeSort = true; mNavMode = NAV_SORT; mSavedArrowDirection = ARROW_NONE; } void dLytDepositStock_c::navigateToFinish() { - if (!field_0x6848) { + if (!mIsModeFinish) { dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_SHOP_STK_POINT_DECIDE); } - field_0x6848 = true; + mIsModeFinish = true; mNavMode = NAV_FINISH; mSavedArrowDirection = ARROW_NONE; }