Merge pull request #290 from robojumper/d_lyt_deposit

d_lyt_deposit OK
This commit is contained in:
robojumper
2026-01-24 11:10:18 +01:00
committed by GitHub
20 changed files with 4403 additions and 486 deletions
+20 -1
View File
@@ -26,6 +26,9 @@ public:
void setVisible(bool val) {
mVisible = val;
}
bool isVisible() const {
return mVisible;
}
void setDrawDirectly(bool val) {
mDrawDirectly = val;
}
@@ -36,7 +39,7 @@ public:
mCalibrationPointCenterEnabled = val;
}
dCursorHitCheck_c *getHitCheck() {
dCursorHitCheck_c *getHitCheck() const {
return mCursorIf.getHit();
}
@@ -52,10 +55,26 @@ public:
mCursorStick.setShouldBeOn(visible);
}
void setCursorStickPriority(u8 priority) {
mCursorStick.setPriority(priority);
}
void setCursorStickPriority2(u8 priority) {
mCursorStick.setPriority2(priority);
}
bool isCursorStickVisible() const {
return mCursorStick.getShouldBeOn();
}
void setCursorStickTargetPane(const nw4r::lyt::Pane *target) {
mCursorStick.setTargetPane(target);
}
const nw4r::lyt::Pane *getCursorStickAllPane() const {
return mCursorStick.getAllPane();
}
private:
static dCsBase_c *sInstance;
void setCurrentLyt(int lyt);
+6
View File
@@ -19,6 +19,12 @@ 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);
void sortStock();
#define ITEM_CHECK_SLOT_NONE 60
u16 itemCheckFindItemSlot(ITEM_ID item);
+1 -1
View File
@@ -1520,7 +1520,7 @@ enum StoryFlags_e {
/** [Set when talking to Strich]
* Story Flag #300 (0x012C) - JP 805ACD7D 0x40 / US 805A9AFD 0x40
*/
STORYFLAG_300,
STORYFLAG_TALKED_TO_STRICH,
/** [Kukiel screams]
* Story Flag #301 (0x012D) - JP 805ACD7D 0x80 / US 805A9AFD 0x80
+17 -12
View File
@@ -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"
@@ -35,34 +36,38 @@ public:
bool requestIn();
bool requestOut();
void unk() {
field_0x6B8 = mPointedAtArrow;
s32 getPointedAtArrow() const {
return mPointedAtArrow;
}
s32 getField_0x6B8() const {
return field_0x6B8;
bool isChangingState() const {
return mIsChangingState;
}
nw4r::lyt::Bounding *getArrowBounding(s32 idx) const {
return mpBoundings[idx];
}
void setField_0x6B8(s32 v) {
field_0x6B8 = v;
s32 getActiveArrow() const {
return mActiveArrow;
}
void setActiveArrow(s32 v) {
mActiveArrow = v;
}
void setBackwards(bool b) {
mBackwards = b;
}
bool fn_80168760();
bool triggerArrowPress();
void setTranslate(const mVec2_c *);
private:
void setTranslate(const Vec *);
void displayElement(s32, f32);
void unbindAt(s32);
void tickDown(d2d::AnmGroup_c *);
void checkPointAtPane();
/* 0x04 */ UI_STATE_MGR_DECLARE(dLytCommonArrow_c);
/* 0x40 */ d2d::LytBase_c mLytBase;
d2d::ResAccIf_c mResAcc;
@@ -71,9 +76,9 @@ private:
/* 0x6A8 */ nw4r::lyt::Bounding *mpBoundings[2];
/* 0x6B0 */ s32 mType;
/* 0x6B4 */ s32 mPointedAtArrow;
/* 0x6B8 */ s32 field_0x6B8;
/* 0x6BC */ s32 field_0x6BC;
/* 0x6C0 */ s32 field_0x6C0;
/* 0x6B8 */ s32 mActiveArrow;
/* 0x6BC */ s32 mLastActiveArrow;
/* 0x6C0 */ s32 mTriggeredArrow;
/* 0x6C4 */ s32 mTimer;
/* 0x6C8 */ bool mInRequested;
/* 0x6C9 */ bool mOutRequested;
+11
View File
@@ -23,16 +23,27 @@ 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) {
mShouldBeOn = value;
}
bool getShouldBeOn() const {
return mShouldBeOn;
}
static dLytCursorStick_c *GetInstance() {
return sInstance;
}
const nw4r::lyt::Pane *getAllPane() const {
return mpPanes[0];
}
private:
bool build_();
bool remove_();
+227 -1
View File
@@ -1,14 +1,240 @@
#ifndef D_LYT_DEPOSIT_H
#define D_LYT_DEPOSIT_H
class dLytDeposit_c {
#include "d/d_cursor_hit_check.h"
#include "d/d_pad_nav.h"
#include "d/lyt/d2d.h"
#include "d/lyt/d_lyt_base.h"
#include "d/lyt/d_lyt_common_arrow.h"
#include "d/lyt/d_lyt_common_icon_item.h"
#include "d/lyt/d_lyt_deposit_box_cursor.h"
#include "d/lyt/d_lyt_deposit_stock.h"
#include "d/lyt/d_textbox.h"
#include "d/lyt/d_window.h"
#include "m/m_vec.h"
#include "nw4r/lyt/lyt_bounding.h"
#include "nw4r/lyt/lyt_pane.h"
#include "s/s_State.hpp"
class dLytDepositMain_c {
public:
dLytDepositMain_c();
virtual ~dLytDepositMain_c() {
dPadNav::setNavEnabled(false, false);
}
bool build(d2d::ResAccIf_c *resAcc);
bool execute();
bool draw();
bool remove();
void setModeNone();
void setModeIn();
void setModeCheck();
void setModeChange(bool unk);
void setModeArrangement();
void setModeReverseChange();
void setModeScroll(bool leftRight, bool viaButton);
void setModeRecycle();
void setModeArrangementOut();
void setModeOut();
bool isSellableItem() const {
return mIsSellActive && mItemSellValue > 0;
}
s32 getArrowDirection() const {
return mStock[STOCK_ACTIVE].getArrowDirection();
}
void setField_0x1952C(bool b) {
mPreventCancellingSelection = b;
}
s32 getStateStep() const {
return mStateStep;
}
bool isIdle() const {
return mIsIdle;
}
bool isPointingAtToStockBounding() const {
return mIsPointingAtToStockBounding;
}
bool isPointingAtToPouchBounding() const {
return mIsPointingAtToPouchBounding;
}
bool getField_0x19523() const {
return mIsFinishActive;
}
bool getField_0x19525() const {
return mIsSortActive;
}
bool getField_0x1952B() const {
return mDidDropCancelItem;
}
bool isHoldingItem() const {
return mCurrentlyHoldingItemSlot >= 0;
}
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 buildSubpanes();
void loadInitialState();
void checkPouchItems();
void checkPointToStock();
void checkForItemPickupOrDrop();
void checkSellOrFinish();
void checkPointToPouch();
void checkSort();
void checkArrows();
s32 checkNav();
void loadItemText(s32 itemId, s32 where);
void loadStockItems(s32 hiddenSlot);
void loadPouchItem(s32 slot);
void loadPageText();
void setPouchItemsVisible(bool visible);
void selectPouchSlot(s32 slot);
void navigateOffIcon();
void updateStockCursor();
void showCursor();
void hideCursor();
void loadCursor();
void returnCursorAfterCancellingSell(s32 idx);
void returnCursorAfterCancellingSort(s32 idx);
void returnCursorAfterCancellingArrow(s32 idx);
s32 getItemSellValueFrame(s32 value);
s32 calcNumDigits(s32 value);
STATE_FUNC_DECLARE(dLytDepositMain_c, ModeNone);
STATE_FUNC_DECLARE(dLytDepositMain_c, ModeIn);
STATE_FUNC_DECLARE(dLytDepositMain_c, ModeCheck);
STATE_FUNC_DECLARE(dLytDepositMain_c, ModeChange);
STATE_FUNC_DECLARE(dLytDepositMain_c, ModeArrangement);
STATE_FUNC_DECLARE(dLytDepositMain_c, ModeReverseChange);
STATE_FUNC_DECLARE(dLytDepositMain_c, ModeScroll);
STATE_FUNC_DECLARE(dLytDepositMain_c, ModeRecycle);
STATE_FUNC_DECLARE(dLytDepositMain_c, ModeArrangementOut);
STATE_FUNC_DECLARE(dLytDepositMain_c, ModeOut);
STATE_MGR_DEFINE_UTIL_CHANGESTATE(dLytDepositMain_c);
/* 0x00004 */ UI_STATE_MGR_DECLARE(dLytDepositMain_c);
/* 0x00040 */ d2d::LytBase_c mLyt;
/* 0x000D0 */ d2d::AnmGroup_c mAnm[36];
/* 0x009D0 */ nw4r::lyt::Bounding *mpBoundingBox;
/* 0x009D4 */ nw4r::lyt::Bounding *mpBoundingChoices;
/* 0x009D8 */ nw4r::lyt::Bounding *mpBoundingCleanUp;
/* 0x009DC */ nw4r::lyt::Bounding *mpBoundingItem12;
/* 0x009E0 */ nw4r::lyt::Bounding *mpItemBoundings[12];
/* 0x00A10 */ nw4r::lyt::Bounding *mpRingBoundings[8];
/* 0x00A30 */ nw4r::lyt::Pane *mpPaneABtn;
/* 0x00A34 */ nw4r::lyt::Pane *mpPanePrice;
/* 0x00A38 */ nw4r::lyt::Pane *mpPaneCommonArrow;
/* 0x00A3C */ dWindow_c *mpWindows[2];
/* 0x00A44 */ dTextBox_c *mpSizeBoxes[2];
/* 0x00A4C */ dCursorHitCheckLyt_c mCsHitCheck;
/* 0x00A74 */ mVec2_c mCsPosition;
/* 0x00A7C */ dLytDepositStock_c mStock[NUM_STOCKS];
/* 0x143F0 */ dLytDepositBoxCursor_c mCursor;
/* 0x14D48 */ dLytCommonIconItem_c mPouchItems[RING_NUM_ITEMS];
/* 0x18D88 */ dLytCommonArrow_c mArrow;
/* 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 mIsPointingAtToStockBounding;
/* 0x19522 */ bool mIsPointingAtToPouchBounding;
/* 0x19523 */ bool mIsFinishActive;
/* 0x19524 */ bool mIsSellActive;
/* 0x19525 */ bool mIsSortActive;
/* 0x19526 */ bool mIsRecycleActive;
/* 0x19527 */ bool field_0x19527;
/* 0x19528 */ bool mIsArrangementDone;
/* 0x19529 */ bool mHasHandledScrollTempItems;
/* 0x1952A */ bool mPrevPointerVisible;
/* 0x1952B */ bool mDidDropCancelItem;
/* 0x1952C */ bool mPreventCancellingSelection;
/* 0x19530 */ s32 mCurrentPouchNavTarget;
/* 0x19534 */ s32 mCurrentlyHoldingItemSlot; // encoded with SLOT_STOCK_OFFSET
/* 0x19538 */ s32 mStateStep;
/* 0x1953C */ s32 mCursorLocation;
/* 0x19540 */ s32 mCurrentlyHoldingStockOrPouchSlot; // always raw slot
/* 0x19544 */ s32 mItemSellValue;
/* 0x19548 */ UNKWORD field_0x19548; // always -1
/* 0x1954C */ s32 mNextLocation;
/* 0x19550 */ s32 mChangeCooldown;
/* 0x19554 */ s32 mDroppedStockSlot;
/* 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);
STATE_FUNC_DECLARE(dLytDeposit_c, In);
STATE_FUNC_DECLARE(dLytDeposit_c, Check);
STATE_FUNC_DECLARE(dLytDeposit_c, Change);
STATE_FUNC_DECLARE(dLytDeposit_c, Arrangement);
STATE_FUNC_DECLARE(dLytDeposit_c, ReverseChange);
STATE_FUNC_DECLARE(dLytDeposit_c, Scroll);
STATE_FUNC_DECLARE(dLytDeposit_c, Recycle);
STATE_FUNC_DECLARE(dLytDeposit_c, ArrangementOut);
STATE_FUNC_DECLARE(dLytDeposit_c, Out);
STATE_MGR_DEFINE_UTIL_ISSTATE(dLytDeposit_c);
STATE_MGR_DEFINE_UTIL_CHANGESTATE(dLytDeposit_c);
/* 0x0008C */ UI_STATE_MGR_DECLARE(dLytDeposit_c);
/* 0x000C8 */ d2d::ResAccIf_c mResAcc;
/* 0x00438 */ dLytDepositMain_c mMain;
/* 0x19998 */ bool mInRequest;
/* 0x19999 */ bool mIsMovingOut;
/* 0x1999A */ bool mScrollViaArrowButton;
};
#endif
+67
View File
@@ -0,0 +1,67 @@
#ifndef D_LYT_DEPOSIT_BOX_CURSOR_H
#define D_LYT_DEPOSIT_BOX_CURSOR_H
#include "d/lyt/d2d.h"
#include "d/lyt/d_lyt_common_icon_item.h"
#include "nw4r/lyt/lyt_pane.h"
// made up name
class dLytDepositBoxCursor_c : public d2d::dSubPane {
public:
enum ItemLocation_e {
LOC_POUCH,
LOC_STOCK,
};
public:
dLytDepositBoxCursor_c() : mSlot(-1), mItem(0), mItemLocation(0) {}
/* vt 0x0C */ virtual bool build(d2d::ResAccIf_c *resAcc) override;
/* vt 0x10 */ virtual bool remove() override;
/* vt 0x14 */ virtual bool execute() override;
/* vt 0x18 */ virtual nw4r::lyt::Pane *getPane() override {
return mLyt.getLayout()->GetRootPane();
}
/* vt 0x1C */ virtual d2d::LytBase_c *getLyt() override {
return &mLyt;
}
/* vt 0x20 */ virtual const char *getName() const override {
return mLyt.getName();
}
/* vt 0x08 */ virtual ~dLytDepositBoxCursor_c() {}
bool draw();
void init(s32 location, s32 slot, s32 item, bool isSell);
void updateSlot(s32 location, s32 slot, s32 item, bool isSell);
void activateSell();
bool isVisible() const {
return mIsVisible;
}
void setVisible(bool b) {
mIsVisible = b;
}
private:
static const s32 NUM_ICONS_PER_PAGE = 12;
void initIcon();
void realizeNav();
/* 0x008 */ d2d::dLytSub mLyt;
/* 0x09C */ d2d::AnmGroup_c mAnm[2];
/* 0x11C */ nw4r::lyt::Pane *mpStickCursorPane;
/* 0x120 */ nw4r::lyt::Pane *mpGetIconPane;
/* 0x124 */ dLytCommonIconItem_c mIcon;
/* 0x930 */ d2d::SubPaneList mSubpaneList;
/* 0x938 */ d2d::SubPaneListNode mNode;
/* 0x948 */ bool mIsVisible;
/* 0x949 */ bool mIsSellMode;
/* 0x94C */ s32 mSlot;
/* 0x950 */ s32 mItem;
/* 0x954 */ s32 mItemLocation;
};
#endif
+206
View File
@@ -0,0 +1,206 @@
#ifndef D_LYT_DEPOSIT_STOCK_H
#define D_LYT_DEPOSIT_STOCK_H
#include "d/lyt/d2d.h"
#include "d/lyt/d_lyt_common_arrow.h"
#include "d/lyt/d_lyt_common_icon_item.h"
#include "nw4r/lyt/lyt_pane.h"
#include "s/s_State.hpp"
class dLytDepositStock_c : public d2d::dSubPane {
public:
enum NavMode_e {
NAV_ITEM,
NAV_SELL,
NAV_SORT,
NAV_FINISH,
NAV_ARROW,
};
public:
dLytDepositStock_c() : mStateMgr(*this) {}
virtual ~dLytDepositStock_c() {}
/* vt 0x0C */ virtual bool build(d2d::ResAccIf_c *resAcc) override;
/* vt 0x10 */ virtual bool remove() override;
/* vt 0x14 */ virtual bool execute() override;
/* vt 0x18 */ virtual nw4r::lyt::Pane *getPane() override {
return mLyt.getLayout()->GetRootPane();
}
/* vt 0x1C */ virtual d2d::LytBase_c *getLyt() override {
return &mLyt;
}
/* vt 0x20 */ virtual const char *getName() const override {
return mLyt.getName();
}
void nextPage(bool preventCancellingSelection);
void prevPage(bool preventCancellingSelection);
void fn_80156530(bool unk);
void navigateToItem();
void navigateToSell();
void navigateToSort();
void navigateToFinish();
void saveArrowDirection();
void navigateToArrow(s32 arrowDirection);
s32 restoreArrowDirection();
void handleSpecialNavMode();
bool isNavModeItem() const;
void navigateOffIcon();
void handleNavOrPoint();
void pickUpOrPlaceItem(s32 slot, bool place);
void selectNavTarget(s32 idx);
void setItem(s32 idx, s32 item);
s32 getCurrentSlot() const;
void loadItems(s32 hiddenSlot);
STATE_MGR_DEFINE_UTIL_EXECUTESTATE(dLytDepositStock_c);
s32 getCurrentNavTarget() const {
return mCurrentNavTarget;
}
bool isModeSort() const {
return mIsModeSort;
}
bool isModePouch() const {
return mIsModePouch;
}
bool isModeSell() const {
return mIsModeSell;
}
bool isModeFinish() const {
return mIsModeFinish;
}
void disableModeSort() {
mIsModeSort = false;
}
void disableModePouch() {
mIsModePouch = false;
}
void disableModeSell() {
mIsModeSell = false;
}
void disableModeFinish() {
mIsModeFinish = false;
}
void returnToNoneMode() {
mIsModeFinish = false;
mIsModeSell = false;
mIsModeSort = false;
mIsModePouch = false;
mSavedArrowDirection = dLytCommonArrow_c::ARROW_NONE;
}
void disableSpecialModes() {
mIsModeSell = false;
mIsModeFinish = false;
mIsModeSort = false;
mSavedArrowDirection = dLytCommonArrow_c::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;
}
s32 getSavedArrowDirection() const {
return mSavedArrowDirection;
}
void setSavedArrowDirection(s32 dir) {
mSavedArrowDirection = dir;
}
void setMainStock(bool b) {
mIsMainStock = b;
}
void onDropItem() {
mPickedUpItemOnThisPage = false;
}
void setPreventCancellingSelection() {
mPreventCancellingSelection = true;
}
private:
static const s32 NUM_ICONS_PER_PAGE = 12;
static const s32 NUM_PAGES = 5;
void initIcons();
void loadIcon(s32 idx);
void navigateToPouch();
void realizeItem(s32 idx);
/**
* Check if the FS stick is pushed in a direction. Diagonal movements
* are adjusted to horizontal and vertical navigations if necessary.
* @returns FS stick direction
*/
s32 checkNav();
STATE_FUNC_DECLARE(dLytDepositStock_c, None);
/* 0x0008 */ UI_STATE_MGR_DECLARE(dLytDepositStock_c);
/* 0x0044 */ d2d::dLytSub mLyt;
/* 0x00D8 */ d2d::AnmGroup_c mAnm[25];
/* 0x0718 */ dLytCommonIconItem_c mIcons[NUM_ICONS_PER_PAGE];
/* 0x6778 */ d2d::SubPaneList mSubpaneList;
/* 0x6784 */ d2d::SubPaneListNode mNodes[NUM_ICONS_PER_PAGE];
/* 0x6844 */ bool mIsIdle;
/* 0x6845 */ bool mIsModePouch;
/* 0x6846 */ bool mIsModeSell;
/* 0x6847 */ bool mIsModeSort;
/* 0x6848 */ bool mIsModeFinish;
/* 0x6849 */ bool mIsSellBlocked;
/* 0x684A */ bool mIsSortBlocked;
/* 0x684B */ bool mPreventCancellingSelection;
/* 0x684C */ bool mPrevPointerVisible;
/* 0x684D */ bool mIsMainStock;
/* 0x684E */ bool mPickedUpItemOnThisPage;
/* 0x6850 */ s32 mCurrentNavTarget;
/* 0x6854 */ s32 mNumSlots;
/* 0x6858 */ s32 mSelectedItemId;
/* 0x685C */ s32 mPickedUpIdx;
/* 0x6860 */ s32 mArrowDirection;
/* 0x6864 */ s32 mSavedArrowDirection;
/* 0x6868 */ s32 mNavMode;
/* 0x686C */ u8 mItemIds[NUM_ICONS_PER_PAGE];
/* 0x6878 */ u8 mItemPage;
};
#endif
+8 -1
View File
@@ -18,6 +18,8 @@ enum SongLifeTreeSeedStatus_e {
SONG_LIFETREE_HAS_SOTH = 2,
};
s32 convertLytPouchSlot2(s32 fileSlot);
u8 getSongLifeTreeStatus();
/** 0: no sword, 6: TMS */
@@ -74,9 +76,14 @@ u8 getPouchItemForSlot(s32 slot, bool unk);
bool hasPouchSlot(s32 slot, bool unk);
s32 getPouchItemAmount(s32 slot, bool unk);
u8 getPouchItemNumberColor(s32 slot, bool unk);
f32 getShieldDurability(s32 slot, bool unk);
f32 getPouchShieldDurability(s32 slot, bool unk);
u32 getPouchItemIdForIndex(s32 slot, bool unk);
u8 getDepositItemForSlot(s32 slot);
s32 getDepositItemAmount(s32 slot);
u8 getDepositItemNumberColor(s32 slot);
f32 getDepositShieldDurability(s32 slot);
// TODO - rename and make sense of these
DowsingTarget::DowsingSlot dowsingSlotForIndex(s32 index);
u8 getLytIndexForDowsingIndex(s32 index);