diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index d5744794..82b606cb 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -186,8 +186,10 @@ toBeSorted/arc_callback_handler.cpp: .sdata start:0x80571D10 end:0x80571D20 .sbss start:0x80575250 end:0x80575258 -d/lyt/d_structd.cpp: - .text start:0x80065600 end:0x80066478 +d/d_cursor_hit_check.cpp: + .text start:0x80065600 end:0x800664EC + .data start:0x8050DF60 end:0x8050DFA0 + .sdata2 start:0x80577938 end:0x80577958 toBeSorted/arc_managers/current_stage_arc_manager.cpp: .text start:0x80068FD0 end:0x80069910 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 231ed689..1c644bf3 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -2861,31 +2861,31 @@ DestroyArcEntry__22ArcCallbackHandlerBaseFPCc = .text:0x800653D0; // type:functi __sinit_\arc_callback_handler_cpp = .text:0x80065570; // type:function size:0x20 scope:local create__6mVideoFv = .text:0x80065590; // type:function size:0x54 fn_800655F0 = .text:0x800655F0; // type:function size:0x4 -__ct__Q23d2d15dLytStructDListFv = .text:0x80065600; // type:function size:0x3C -fn_80065640 = .text:0x80065640; // type:function size:0x164 -appendToList1__Q23d2d15dLytStructDListFPQ23d2d11dLytStructC = .text:0x800657B0; // type:function size:0x58 -removeFromList1__Q23d2d15dLytStructDListFPQ23d2d11dLytStructC = .text:0x80065810; // type:function size:0x60 -appendToList2__Q23d2d15dLytStructDListFPQ23d2d11dLytStructD = .text:0x80065870; // type:function size:0x110 -removeFromList2__Q23d2d15dLytStructDListFPQ23d2d11dLytStructD = .text:0x80065980; // type:function size:0xA4 -fn_80065A30__Q23d2d15dLytStructDListFPQ23d2d11dLytStructD = .text:0x80065A30; // type:function size:0x34 -create__Q23d2d15dLytStructDListFPQ23EGG4Heap = .text:0x80065A70; // type:function size:0x38 -fn_80065AB0 = .text:0x80065AB0; // type:function size:0x78 -fn_80065B30 = .text:0x80065B30; // type:function size:0x4C -fn_80065B80 = .text:0x80065B80; // type:function size:0x174 -fn_80065D00 = .text:0x80065D00; // type:function size:0x14 -__dt__Q23d2d11dLytStructDFv = .text:0x80065D20; // type:function size:0x74 -__dt__Q23d2d18dLytStructDInArrayFv = .text:0x80065DA0; // type:function size:0x40 -fn_80065DE0 = .text:0x80065DE0; // type:function size:0x90 -fn_80065E70__Q23d2d11dLytStructDFPQ34nw4r3lyt4Panelll = .text:0x80065E70; // type:function size:0xC4 -fn_80065F40 = .text:0x80065F40; // type:function size:0x28 -fn_80065F70__Q23d2d11dLytStructDFv = .text:0x80065F70; // type:function size:0x328 -fn_800662A0 = .text:0x800662A0; // type:function size:0xD4 +__ct__8dCsMgr_cFv = .text:0x80065600; // type:function size:0x3C +execute__8dCsMgr_cFv = .text:0x80065640; // type:function size:0x164 +registCursor__8dCsMgr_cFP18dCursorInterface_c = .text:0x800657B0; // type:function size:0x58 +unregistCursor__8dCsMgr_cFP18dCursorInterface_c = .text:0x80065810; // type:function size:0x60 +registCursorTarget__8dCsMgr_cFP17dCursorHitCheck_c = .text:0x80065870; // type:function size:0x110 +unregistCursorTarget__8dCsMgr_cFP17dCursorHitCheck_c = .text:0x80065980; // type:function size:0xA4 +isRegist__8dCsMgr_cFP17dCursorHitCheck_c = .text:0x80065A30; // type:function size:0x34 +create__8dCsMgr_cFPQ23EGG4Heap = .text:0x80065A70; // type:function size:0x38 +init__17dCursorHitCheck_cFUcUcUs = .text:0x80065AB0; // type:function size:0x78 +checkOverrideCallback__17dCursorHitCheck_cFb = .text:0x80065B30; // type:function size:0x4C +checkHit__19dCursorHitCheckCC_cFll = .text:0x80065B80; // type:function size:0x174 +init__19dCursorHitCheckCC_cFUsUcUc = .text:0x80065D00; // type:function size:0x14 +__dt__20dCursorHitCheckLyt_cFv = .text:0x80065D20; // type:function size:0x74 +__dt__24dCsCheckLyt_BoundingDataFv = .text:0x80065DA0; // type:function size:0x40 +checkHit__20dCursorHitCheckLyt_cFll = .text:0x80065DE0; // type:function size:0x90 +init__20dCursorHitCheckLyt_cFPQ34nw4r3lyt4PaneUsUcUc = .text:0x80065E70; // type:function size:0xC4 +__ct__24dCsCheckLyt_BoundingDataFv = .text:0x80065F40; // type:function size:0x28 +execute__20dCursorHitCheckLyt_cFv = .text:0x80065F70; // type:function size:0x328 +countBoundings__20dCursorHitCheckLyt_cFPQ34nw4r3lyt4Pane = .text:0x800662A0; // type:function size:0xD4 GetRuntimeTypeInfo__Q34nw4r3lyt4PaneCFv = .text:0x80066380; // type:function size:0x8 scope:weak -fn_80066390 = .text:0x80066390; // type:function size:0xE8 -fn_80066480 = .text:0x80066480; // type:function size:0xC -fn_80066490 = .text:0x80066490; // type:function size:0x40 -fn_800664D0 = .text:0x800664D0; // type:function size:0xC -fn_800664E0 = .text:0x800664E0; // type:function size:0xC +gatherBoundings__20dCursorHitCheckLyt_cFPP24dCsCheckLyt_BoundingDataPQ34nw4r3lyt4Pane = .text:0x80066390; // type:function size:0xE8 +getCursorPos__18dCursorInterface_cFv = .text:0x80066480; // type:function size:0xC +__dt__18dCursorInterface_cFv = .text:0x80066490; // type:function size:0x40 +getType__20dCursorHitCheckLyt_cFv = .text:0x800664D0; // type:function size:0xC +getType__19dCursorHitCheckCC_cFv = .text:0x800664E0; // type:function size:0xC fn_800664F0 = .text:0x800664F0; // type:function size:0x10 fn_80066500 = .text:0x80066500; // type:function size:0x48 fn_80066550 = .text:0x80066550; // type:function size:0x54 @@ -30788,10 +30788,10 @@ lbl_8050DF10 = .data:0x8050DF10; // type:object size:0x18 @9033 = .data:0x8050DF28; // type:object size:0x11 scope:local data:string @9034 = .data:0x8050DF3C; // type:object size:0x11 scope:local data:string __vt__18ArcCallbackHandler = .data:0x8050DF50; // type:object size:0x10 scope:weak -__vt__Q23d2d11dLytStructC = .data:0x8050DF60; // type:object size:0x10 -__vt__Q23d2d11dLytStructD = .data:0x8050DF70; // type:object size:0x14 -lbl_8050DF84 = .data:0x8050DF84; // type:object size:0xC -lbl_8050DF90 = .data:0x8050DF90; // type:object size:0x10 +__vt__18dCursorInterface_c = .data:0x8050DF60; // type:object size:0x10 +__vt__20dCursorHitCheckLyt_c = .data:0x8050DF70; // type:object size:0x14 +__vt__24dCsCheckLyt_BoundingData = .data:0x8050DF84; // type:object size:0xC +__vt__19dCursorHitCheckCC_c = .data:0x8050DF90; // type:object size:0x10 lbl_8050DFA0 = .data:0x8050DFA0; // type:object size:0x10 lbl_8050DFB0 = .data:0x8050DFB0; // type:object size:0xC lbl_8050DFBC = .data:0x8050DFBC; // type:object size:0xC @@ -33339,7 +33339,7 @@ __vt__56sFStateMgr_c<17dLytCommonArrow_c,20sStateMethodUsr_FI_c> = .data:0x80527 __vt__86sStateMgr_c<17dLytCommonArrow_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c> = .data:0x80527418; // type:object size:0x30 scope:weak __vt__33sFStateFct_c<17dLytCommonArrow_c> = .data:0x80527448; // type:object size:0x14 scope:weak __vt__30sFState_c<17dLytCommonArrow_c> = .data:0x80527460; // type:object size:0x18 scope:weak -__vt__Q23d2d16dLytStructD_Base = .data:0x80527478; // type:object size:0x10 scope:weak +__vt__17dCursorHitCheck_c = .data:0x80527478; // type:object size:0x10 scope:weak @8395 = .data:0x805274B4; // type:object size:0xC scope:local @8396 = .data:0x805274C0; // type:object size:0xC scope:local @8397 = .data:0x805274CC; // type:object size:0xC scope:local @@ -34325,7 +34325,7 @@ __vt__56sFStateFct_c = .data:0x8052F __vt__53sFState_c = .data:0x8052F270; // type:object size:0x18 lbl_8052F288 = .data:0x8052F288; // type:object size:0x2C lbl_8052F2B4 = .data:0x8052F2B4; // type:object size:0x7C -lbl_8052F330 = .data:0x8052F330; // type:object size:0x10 +__vt__22dCursorInterfaceGame_c = .data:0x8052F330; // type:object size:0x10 lbl_8052F340 = .data:0x8052F340; // type:object size:0xCF4 __vt__58sFStateID_c = .data:0x80530034; // type:object size:0x34 __vt__60sFStateID_c = .data:0x80530068; // type:object size:0x34 @@ -35841,8 +35841,8 @@ __vt__14sStateMethod_c = .data:0x805419A8; // type:object size:0x40 __vt__20DynamicModuleControl = .data:0x80541A10; // type:object size:0x30 __vt__24DynamicModuleControlBase = .data:0x80541A40; // type:object size:0x30 ATAN2_LOOKUP_TABLE = .data:0x80541A70; // type:object size:0x808 -doActorInit = .data:0x80542278; // type:object size:0xB4 data:4byte -FBASE_HEAP_INIT = .data:0x8054232C; // type:object size:0x30 +doActorInit = .data:0x80542278; // type:object size:0xC data:4byte +FBASE_HEAP_INIT = .data:0x8054232C; // type:object size:0x2F __vt__7fBase_c = .data:0x8054235C; // type:object size:0x4C @4470 = .data:0x805423A8; // type:object size:0xC scope:local data:4byte ...data.0 = .data:0x805423A8; // type:label scope:local @@ -39997,7 +39997,7 @@ dSystem__s_NewMEM1ArenaHi = .sbss:0x80575240; // type:object size:0x8 data:4byte dSystem__myDylinkInitPhase = .sbss:0x80575248; // type:object size:0x8 sInstance__18ArcCallbackHandler = .sbss:0x80575250; // type:object size:0x8 data:4byte aspectRatio = .sbss:0x80575258; // type:object size:0x4 data:float -sInstance__Q23d2d15dLytStructDList = .sbss:0x80575260; // type:object size:0x8 data:4byte +sInstance__8dCsMgr_c = .sbss:0x80575260; // type:object size:0x8 data:4byte lbl_80575268 = .sbss:0x80575268; // type:object size:0x8 data:4byte someColor = .sbss:0x80575270; // type:object size:0x1 data:byte reloadColorFaderPtr = .sbss:0x80575274; // type:object size:0x4 data:4byte diff --git a/configure.py b/configure.py index 6a924d56..2af65881 100644 --- a/configure.py +++ b/configure.py @@ -377,7 +377,7 @@ config.libs = [ Object(Matching, "toBeSorted/counters/slingshot_seed_counter.cpp"), Object(Matching, "toBeSorted/counters/key_piece_counter.cpp"), Object(Matching, "toBeSorted/counters/extra_wallet_counter.cpp"), - Object(NonMatching, "d/lyt/d_structd.cpp"), + Object(NonMatching, "d/d_cursor_hit_check.cpp"), Object(Matching, "d/lyt/d2d.cpp"), Object(NonMatching, "d/lyt/d_textbox.cpp"), Object(Matching, "d/lyt/d_window.cpp"), diff --git a/include/d/col/cc/d_cc_s.h b/include/d/col/cc/d_cc_s.h index 06b24d0b..bca37b65 100644 --- a/include/d/col/cc/d_cc_s.h +++ b/include/d/col/cc/d_cc_s.h @@ -65,7 +65,7 @@ public: ChkCameraPoint(const mVec3_c &, const mVec3_c &, mVec3_c &, dAcObjBase_c *, dAcObjBase_c *, dAcObjBase_c *, f32); bool ChkCo(const mVec3_c &, dAcObjBase_c *); - bool fn_80357c90(const mVec3_c &, const mVec3_c &, u32, UNKTYPE **); + bool fn_80357c90(const mVec3_c &, const mVec3_c &, u32, cCcD_ShapeAttr **, f32); void Set(cCcD_Obj *); void MoveAfterCheck(); void RemoveDeadObj(); diff --git a/include/d/d_cs_base.h b/include/d/d_cs_base.h index 4ae0573d..12c83def 100644 --- a/include/d/d_cs_base.h +++ b/include/d/d_cs_base.h @@ -3,9 +3,9 @@ #include "common.h" #include "d/d_cs.h" +#include "d/d_cursor_hit_check.h" #include "d/lyt/d2d.h" #include "d/lyt/d_lyt_cursor_stick.h" -#include "d/lyt/d_structd.h" #include "m/m2d.h" class dCsBase_c : public dCs_c { @@ -24,8 +24,8 @@ public: field_0x703 = val; } - d2d::dLytStructD *getUnk() { - return mStructC.field_0x14; + dCursorHitCheck_c *getHitCheck() { + return mCursorIf.getHit(); } static dCsBase_c *GetInstance() { @@ -40,7 +40,7 @@ private: /* 0x068 */ m2d::ResAccIf_c mResAcc; /* 0x11C */ d2d::LytBase_c mLyts[2]; /* 0x23C */ d2d::LytBase_c *mpCurrLyt; - /* 0x240 */ d2d::dLytStructC mStructC; + /* 0x240 */ dCursorInterface_c mCursorIf; /* 0x254 */ dLytCursorStick_c mCursorStick; /* 0x6F0 */ f32 field_0x6F0; /* 0x6F4 */ f32 field_0x6F4; diff --git a/include/d/d_cs_game.h b/include/d/d_cs_game.h index 75283c23..a090bf97 100644 --- a/include/d/d_cs_game.h +++ b/include/d/d_cs_game.h @@ -3,8 +3,8 @@ #include "common.h" #include "d/d_cs.h" +#include "d/d_cursor_hit_check.h" #include "d/lyt/d2d.h" -#include "d/lyt/d_structd.h" #include "m/m2d.h" #include "s/s_FStateID.hpp" #include "s/s_State.hpp" @@ -135,7 +135,6 @@ public: friend class dCsGame_c; public: - enum CursorType_e { BOW = 6, }; @@ -204,8 +203,12 @@ public: class lytPachinkoCsr_c { public: lytPachinkoCsr_c(dCsGameAnmGroups_c &g, d2d::LytBase_c *lyt) - : mAnm(g.tmp.mAnmGroups, 0x17), mpLyt(lyt), mStateMgr(*this, sStateID::null), field_0x50(0), - field_0x54(0.0f), field_0x58(0.0f) {} + : mAnm(g.tmp.mAnmGroups, 0x17), + mpLyt(lyt), + mStateMgr(*this, sStateID::null), + field_0x50(0), + field_0x54(0.0f), + field_0x58(0.0f) {} virtual ~lytPachinkoCsr_c() {} void init(); @@ -279,8 +282,12 @@ public: public: lytItemCursor_c() - : mStateMgr(*this, sStateID::null), mAnm(mAnmGroups.tmp.mAnmGroups, 0x17), mBow(mAnmGroups, &mLyt), - mDowsing(mAnmGroups, &mLyt), mPachinko(mAnmGroups, &mLyt), mCrawShot(mAnmGroups, &mLyt), + : mStateMgr(*this, sStateID::null), + mAnm(mAnmGroups.tmp.mAnmGroups, 0x17), + mBow(mAnmGroups, &mLyt), + mDowsing(mAnmGroups, &mLyt), + mPachinko(mAnmGroups, &mLyt), + mCrawShot(mAnmGroups, &mLyt), mVacuum(mAnmGroups, &mLyt) {} virtual ~lytItemCursor_c() {} virtual void lytItemCursor0x0C(); @@ -314,7 +321,6 @@ public: STATE_FUNC_DECLARE(lytItemCursor_c, HookShot); STATE_FUNC_DECLARE(lytItemCursor_c, PlayerCam); - /* 0x004 */ f32 field_0x004; /* 0x008 */ f32 field_0x008; /* 0x00C */ UI_STATE_MGR_DECLARE(lytItemCursor_c); @@ -341,7 +347,7 @@ public: /* 0x068 */ m2d::ResAccIf_c mCursorResAcc; /* 0x11C */ m2d::ResAccIf_c mMain2DResAcc; - /* 0x1D0 */ d2d::dLytStructCSub mStructC; + /* 0x1D0 */ dCursorInterfaceGame_c mCursorIf; /* 0x1EC */ s32 mCursorType; /* 0x1F0 */ dCsGameLyt1_c mLyt1; /* 0x290 */ dCsGameLyt2_c mLyt2; diff --git a/include/d/d_cursor_hit_check.h b/include/d/d_cursor_hit_check.h new file mode 100644 index 00000000..8cb73b3e --- /dev/null +++ b/include/d/d_cursor_hit_check.h @@ -0,0 +1,177 @@ +#ifndef D_CURSOR_HIT_CHECK_H +#define D_CURSOR_HIT_CHECK_H + +#include "common.h" +#include "egg/core/eggHeap.h" +#include "m/m_vec.h" +#include "nw4r/lyt/lyt_pane.h" +#include "toBeSorted/tlist.h" + +/** An interface for something that can check what the cursor/pointer is hovering over. */ +class dCursorHitCheck_c { + friend class dCsMgr_c; + +public: + dCursorHitCheck_c() + : mOverrideHitCallback(nullptr), mCallbackData(nullptr), mMask(0), mPriority(0), field_0x017(0) {} + virtual u32 getType() = 0; + virtual bool checkHit(s32, s32) = 0; + + bool init(u8, u8, u16 mask); + bool checkOverrideCallback(bool); + + typedef bool (*overrideHitCallback)(bool, dCursorHitCheck_c *, void *); + +private: + /* 0x04 */ TListNode mLink; + /* 0x0C */ overrideHitCallback mOverrideHitCallback; + /* 0x10 */ void *mCallbackData; + /* 0x14 */ u16 mMask; + /* 0x16 */ u8 mPriority; + /* 0x17 */ u8 field_0x017; +}; + +/** + * Checks which object in the 3D world the cursor is pointing at. + * Purpose unclear, not used for the Sky Keep puzzle. + */ +class dCursorHitCheckCC_c : public dCursorHitCheck_c { + friend class dCsMgr_c; + +public: + bool init(u16 mask, u8, u8); + virtual u32 getType() override { + return 'cc '; + } + virtual bool checkHit(s32, s32) override; +}; + +struct dCsCheckLyt_BoundingData { + dCsCheckLyt_BoundingData() { + mpPane = nullptr; + mMinX = 0; + mMaxY = 0; + mMaxX = 0; + mMinY = 0; + } + virtual ~dCsCheckLyt_BoundingData() {} + /* 0x04 */ nw4r::lyt::Pane *mpPane; + /* 0x08 */ s16 mMinX; + /* 0x0A */ s16 mMaxY; + /* 0x0C */ s16 mMaxX; + /* 0x0E */ s16 mMinY; +}; + +/** + * Checks which 2D UI Pane the cursor is pointing at. Used for + * many interactible UI elements. + */ +class dCursorHitCheckLyt_c : public dCursorHitCheck_c { +public: + dCursorHitCheckLyt_c() + : mpRootPane(nullptr), + mpBoundingData(nullptr), + mNumBoundings(0), + mHasCalculatedBoundingData(false), + field_0x23(0), + mpHitPane(nullptr) {} + + virtual u32 getType() override { + return 'lyt '; + } + virtual bool checkHit(s32, s32) override; + virtual ~dCursorHitCheckLyt_c(); + + bool init(nw4r::lyt::Pane *, u16 mask, u8, u8); + void execute(); + + /** Returns the Pane the cursor is currently hovering over. */ + nw4r::lyt::Pane *getHitPane() const { + return mpHitPane; + } + + /** Must be called if the Lyt panes change their position. */ + void resetCachedHitboxes() { + mHasCalculatedBoundingData = false; + } + +private: + void countBoundings(nw4r::lyt::Pane *); + void gatherBoundings(dCsCheckLyt_BoundingData **pEnd, nw4r::lyt::Pane *); + + /* 0x18 */ nw4r::lyt::Pane *mpRootPane; + /* 0x1C */ dCsCheckLyt_BoundingData *mpBoundingData; + /* 0x20 */ u16 mNumBoundings; + /* 0x22 */ bool mHasCalculatedBoundingData; + /* 0x23 */ u8 field_0x23; + /* 0x24 */ nw4r::lyt::Pane *mpHitPane; +}; + +/** The basic cursor position getter. */ +class dCursorInterface_c { + friend class dCsMgr_c; + +public: + dCursorInterface_c() : mCursorMask(0), mpHit(nullptr) {} + virtual ~dCursorInterface_c() {} + virtual mVec2_c &getCursorPos(); + + void setCursorMask(u16 val) { + mCursorMask = val; + } + + dCursorHitCheck_c *getHit() const { + return mpHit; + } + +private: + /* 0x04 */ TListNode mLink; + /* 0x0C */ u16 mCursorMask; + /* 0x10 */ dCursorHitCheck_c *mpHit; +}; + +/** A variant of the cursor position getter for dCsGame_c */ +class dCursorInterfaceGame_c : public dCursorInterface_c { +public: + dCursorInterfaceGame_c() {} + virtual ~dCursorInterfaceGame_c() {} + virtual mVec2_c &getCursorPos(); + +private: + /* 0x14 */ u8 _0x14[8]; +}; + +/** + * The cursor manager. Cursors and hit targets are registered here, + * and this manager will track the target of each pointer. + */ +class dCsMgr_c { +public: + dCsMgr_c(); + static dCsMgr_c *create(EGG::Heap *heap); + + void execute(); + + void registCursor(dCursorInterface_c *cursor); + void unregistCursor(dCursorInterface_c *cursor); + + void registCursorTarget(dCursorHitCheck_c *target); + void unregistCursorTarget(dCursorHitCheck_c *target); + + bool isRegist(dCursorHitCheck_c *target); + + static dCsMgr_c *GetInstance() { + return sInstance; + } + + typedef TList CursorList; + typedef TList HitCheckList; + +private: + static dCsMgr_c *sInstance; + /* 0x00 */ CursorList mList1; + /* 0x0C */ HitCheckList mList2; + /* 0x18 */ bool field_0x18; +}; + +#endif diff --git a/include/d/d_stage_mgr.h b/include/d/d_stage_mgr.h index 9160b33d..31ccd40b 100644 --- a/include/d/d_stage_mgr.h +++ b/include/d/d_stage_mgr.h @@ -10,6 +10,7 @@ #include "egg/gfx/eggScreen.h" #include "m/m_allocator.h" #include "m/m_dvd.h" +#include "nw4r/g3d/g3d_camera.h" #include "s/s_FPhase.h" #include "s/s_State.hpp" #include "sized_string.h" @@ -114,6 +115,8 @@ public: void addObjId(u16 id); void addActorId(u16 actorId); + nw4r::g3d::Camera getCamera(s32 idx); + dFader_c *getFader() { return &mFader; } diff --git a/include/d/lyt/d_lyt_common_arrow.h b/include/d/lyt/d_lyt_common_arrow.h index c6dd34ea..1cfe53b7 100644 --- a/include/d/lyt/d_lyt_common_arrow.h +++ b/include/d/lyt/d_lyt_common_arrow.h @@ -2,10 +2,12 @@ #define D_LYT_COMMON_ARROW_H #include "d/lyt/d2d.h" -#include "d/lyt/d_structd.h" +// clang-format off +// vtable order +#include "d/d_cursor_hit_check.h" +// clang-format on #include "nw4r/lyt/lyt_bounding.h" #include "s/s_State.hpp" -#include "s/s_StateMgr.hpp" class dLytCommonArrow_c { public: @@ -38,7 +40,7 @@ private: /* 0x40 */ d2d::LytBase_c mLytBase; d2d::ResAccIf_c mResAcc; d2d::AnmGroup_c mAnmGroups[0x9]; - d2d::dLytStructD mStructD; + dCursorHitCheckLyt_c mCsHitCheck; nw4r::lyt::Bounding *mBoundingL; nw4r::lyt::Bounding *mBoundingR; s32 mType; diff --git a/include/d/lyt/d_lyt_common_icon_item.h b/include/d/lyt/d_lyt_common_icon_item.h index 66be9d60..12b03864 100644 --- a/include/d/lyt/d_lyt_common_icon_item.h +++ b/include/d/lyt/d_lyt_common_icon_item.h @@ -2,8 +2,8 @@ #define D_LYT_COMMON_ICON_ITEM_H #include "common.h" +#include "d/d_cursor_hit_check.h" #include "d/lyt/d2d.h" -#include "d/lyt/d_structd.h" #include "d/lyt/d_textbox.h" #include "nw4r/lyt/lyt_bounding.h" #include "s/s_State.hpp" @@ -70,7 +70,7 @@ private: /* 0x098 */ d2d::AnmGroup_c mAnm[7]; /* 0x258 */ dTextBox_c *mpTextBoxes[2]; /* 0x260 */ nw4r::lyt::Bounding *mpBounding; - /* 0x264 */ d2d::dLytStructD mStructD; + /* 0x264 */ dCursorHitCheckLyt_c mCsHitCheck; /* 0x28C */ u8 mItem; /* 0x28D */ u8 mColor; /* 0x28E */ u8 _0x28E[0x294 - 0x28E]; @@ -148,7 +148,7 @@ private: /* 0x098 */ d2d::AnmGroup_c mAnm[10]; /* 0x318 */ dTextBox_c *mpTextBoxes[2]; /* 0x320 */ nw4r::lyt::Bounding *mpBounding; - /* 0x324 */ d2d::dLytStructD structD; + /* 0x324 */ dCursorHitCheckLyt_c structD; /* 0x34C */ u8 mItem; /* 0x34D */ u8 mColor; /* 0x350 */ u32 mNumber; @@ -200,7 +200,7 @@ private: /* 0x004 */ d2d::dLytSub mLyt; /* 0x098 */ d2d::AnmGroup_c mAnm[3]; /* 0x158 */ nw4r::lyt::Bounding *mpBounding; - /* 0x15C */ d2d::dLytStructD structD; + /* 0x15C */ dCursorHitCheckLyt_c structD; /* 0x184 */ u8 mItem; /* 0x185 */ bool mSize; /* 0x186 */ bool mBocoburinLocked; diff --git a/include/d/lyt/d_lyt_common_icon_material.h b/include/d/lyt/d_lyt_common_icon_material.h index 525004d8..a6922592 100644 --- a/include/d/lyt/d_lyt_common_icon_material.h +++ b/include/d/lyt/d_lyt_common_icon_material.h @@ -2,8 +2,8 @@ #define D_LYT_COMMON_ICON_MATERIAL_H #include "common.h" +#include "d/d_cursor_hit_check.h" #include "d/lyt/d2d.h" -#include "d/lyt/d_structd.h" #include "d/lyt/d_textbox.h" #include "nw4r/lyt/lyt_bounding.h" #include "s/s_State.hpp" @@ -68,7 +68,7 @@ private: /* 0x098 */ d2d::AnmGroup_c mAnm[6]; /* 0x218 */ dTextBox_c *mpTextBoxes[2]; /* 0x220 */ nw4r::lyt::Bounding *mpBounding; - /* 0x224 */ d2d::dLytStructD mCursor; + /* 0x224 */ dCursorHitCheckLyt_c mCursor; /* 0x24C */ u8 mItem; /* 0x24D */ u8 _0x24D[0x254 - 0x24D]; /* 0x254 */ wchar_t mNumberBuf[16]; @@ -129,7 +129,7 @@ private: /* 0x098 */ d2d::AnmGroup_c mAnm[6]; /* 0x218 */ dTextBox_c *mpTextBoxes[2]; /* 0x220 */ nw4r::lyt::Bounding *mpBounding; - /* 0x224 */ d2d::dLytStructD mCursor; + /* 0x224 */ dCursorHitCheckLyt_c mCursor; /* 0x24C */ u8 mItem; /* 0x24D */ u8 _0x24D[0x254 - 0x24D]; /* 0x254 */ wchar_t mNumberBuf[16]; @@ -183,7 +183,6 @@ public: bool isCursorOver() const; void setVisible(bool visible); - const nw4r::lyt::Bounding *getBounding() const; private: diff --git a/include/d/lyt/d_lyt_map.h b/include/d/lyt/d_lyt_map.h index fbe85483..ddf80e66 100644 --- a/include/d/lyt/d_lyt_map.h +++ b/include/d/lyt/d_lyt_map.h @@ -2,9 +2,9 @@ #define D_LYT_MAP_H #include "common.h" +#include "d/d_cursor_hit_check.h" #include "d/lyt/d2d.h" #include "d/lyt/d_lyt_map_capture.h" -#include "d/lyt/d_structd.h" #include "egg/core/eggColorFader.h" #include "m/m2d.h" #include "m/m_vec.h" @@ -32,8 +32,15 @@ public: friend class dLytMapPinIconAggregate_c; dLytMapPinIcon_c() - : mStateMgr(*this, sStateID::null), mpBounding(nullptr), field_0x1BC(0), field_0x1C0(0.0f, 0.0f, 0.0f), - field_0x1CC(0), field_0x1D0(nullptr), field_0x1D4(0), mIndex(0), field_0x1DC(0) {} + : mStateMgr(*this, sStateID::null), + mpBounding(nullptr), + field_0x1BC(0), + field_0x1C0(0.0f, 0.0f, 0.0f), + field_0x1CC(0), + field_0x1D0(nullptr), + field_0x1D4(0), + mIndex(0), + field_0x1DC(0) {} virtual ~dLytMapPinIcon_c(); bool build(d2d::ResAccIf_c *resAcc); @@ -62,7 +69,7 @@ private: /* 0x004 */ UI_STATE_MGR_DECLARE(dLytMapPinIcon_c); /* 0x040 */ d2d::LytBase_c mLyt; /* 0x0D0 */ d2d::AnmGroup_c mAnmGroups[3]; - /* 0x190 */ d2d::dLytStructD mStructD; + /* 0x190 */ dCursorHitCheckLyt_c mCsHitCheck; /* 0x1B8 */ nw4r::lyt::Bounding *mpBounding; /* 0x1BC */ UNKWORD field_0x1BC; /* 0x1C0 */ mVec3_c field_0x1C0; @@ -104,7 +111,12 @@ private: class dLytMapFloorBtn_c { public: dLytMapFloorBtn_c() - : mStateMgr(*this, sStateID::null), field_0x3C(0), field_0x40(0), field_0x44(0), field_0x48(0), field_0x4C(0), + : mStateMgr(*this, sStateID::null), + field_0x3C(0), + field_0x40(0), + field_0x44(0), + field_0x48(0), + field_0x4C(0), field_0x4D(0) {} ~dLytMapFloorBtn_c() {} @@ -164,7 +176,7 @@ private: /* 0x0DC */ d2d::AnmGroup_c mAnmGroups[1]; /* 0x11C */ LytMapFourAnimGroups mMoreGroups[4]; /* 0x51C */ void *field_0x51C; - /* 0x520 */ d2d::dLytStructD mStructDs[4]; + /* 0x520 */ dCursorHitCheckLyt_c mCsHitChecks[4]; /* 0x5C0 */ dLytMapFloorBtn_c mFloorBtns[4]; /* 0x700 */ UNKWORD field_0x700; /* 0x704 */ UNKWORD field_0x704; @@ -322,7 +334,7 @@ private: /* 0x0000 */ dLytMapSavePopup_c mSavePopup; /* 0x807C */ dLytMapPopupInfo_c mPopupInfo; /* 0x828C */ mVec3_c field_0x828C[12]; - /* 0x832C */ d2d::dLytStructD field_0x832C[33]; + /* 0x832C */ dCursorHitCheckLyt_c field_0x832C[33]; /* 0x8904 */ mVec3_c field_0x8904; /* 0x8910 */ mVec3_c field_0x8910; /* 0x891C */ mVec3_c field_0x891C; diff --git a/include/d/lyt/d_lyt_pause_disp_00.h b/include/d/lyt/d_lyt_pause_disp_00.h index a616ef92..aaacf9dc 100644 --- a/include/d/lyt/d_lyt_pause_disp_00.h +++ b/include/d/lyt/d_lyt_pause_disp_00.h @@ -1,8 +1,8 @@ #ifndef LYT_PAUSE_DISP_00_H #define LYT_PAUSE_DISP_00_H +#include "d/d_cursor_hit_check.h" #include "d/lyt/d2d.h" -#include "d/lyt/d_structd.h" #include "d/lyt/d_lyt_common_icon_item.h" #include "s/s_State.hpp" @@ -30,7 +30,7 @@ private: dLytCommonIconItem_c field_0x2050[0x18]; /* 0xE110 */ d2d::SubPaneList mSubpanes; d2d::SubPaneListNode field_0xE11C[0x18]; - d2d::dLytStructD field_0xE29C; + dCursorHitCheckLyt_c field_0xE29C; }; #endif diff --git a/include/d/lyt/d_lyt_pause_disp_01.h b/include/d/lyt/d_lyt_pause_disp_01.h index 101e4b5a..49b4cd97 100644 --- a/include/d/lyt/d_lyt_pause_disp_01.h +++ b/include/d/lyt/d_lyt_pause_disp_01.h @@ -1,8 +1,8 @@ #ifndef LYT_PAUSE_DISP_01_H #define LYT_PAUSE_DISP_01_H +#include "d/d_cursor_hit_check.h" #include "d/lyt/d2d.h" -#include "d/lyt/d_structd.h" #include "d/lyt/d_lyt_common_icon_material.h" #include "s/s_State.hpp" @@ -29,7 +29,7 @@ private: /* 0x0490 */ dLytCommonIconMaterial_c field_0x2050[28]; /* 0x96B0 */ d2d::SubPaneList mSubpanes; /* 0x96BC */ d2d::SubPaneListNode field_0xE11C[28]; - /* 0x987C */ d2d::dLytStructD field_0xE29C; + /* 0x987C */ dCursorHitCheckLyt_c field_0xE29C; }; #endif diff --git a/include/d/lyt/d_structd.h b/include/d/lyt/d_structd.h deleted file mode 100644 index 549c6883..00000000 --- a/include/d/lyt/d_structd.h +++ /dev/null @@ -1,119 +0,0 @@ -#ifndef D_LYT_STRUCTD_H -#define D_LYT_STRUCTD_H - -#include "common.h" -#include "egg/core/eggHeap.h" -#include "toBeSorted/tlist.h" - -namespace d2d { - -class dLytStructD; - -class dLytStructC { -public: - dLytStructC() : field_0x10(0), field_0x14(nullptr) {} - virtual ~dLytStructC() {} - virtual void *dLytStructC0x0C(); - - TListNode mLink; - u16 field_0x10; - dLytStructD *field_0x14; -}; - -class dLytStructCSub : public dLytStructC { -private: -public: - dLytStructCSub() {} - virtual ~dLytStructCSub() {} - virtual void *dLytStructC0x0C(); - - u8 field_0x18[8]; -}; - -struct dLytStructD_Base { - dLytStructD_Base() : field_0x0C(0), field_0x10(0), field_0x14(0), field_0x015(0), field_0x016(0) {} - virtual u32 getType() = 0; - virtual void doSomething() = 0; - TListNode mLink; - u32 field_0x0C; - u32 field_0x10; - u16 field_0x14; - u8 field_0x015; - u8 field_0x016; -}; - -struct dLytStructDInArray { - dLytStructDInArray() { - field_0x04 = 0; - field_0x08 = 0; - field_0x0A = 0; - field_0x0C = 0; - field_0x0E = 0; - } - virtual ~dLytStructDInArray() {} - u32 field_0x04; - u16 field_0x08; - u16 field_0x0A; - u16 field_0x0C; - u16 field_0x0E; -}; - -/** - * This whole file setup is from the days where I had no idea how this game's UI code works - * and I simply started naming the structs that appeared "StructA" and so on. - * - * The classes in this file are related to cursor pointing. UI code will generally - * contain one or more "dLytStructD", give it an nw4r::lyt::Pane, register it in the - * "dLytStructDList", and then ask the dCsBase_c which "dLytStructD" it's pointing at - * to compare it to the own "dLytStructD". - * - * There's a base class! dLytStructD will report its type as 'lyt ' but there also - * is a 'cc ' type used by the dStageMgr_c. d2d may not be a good namespace here! - */ -struct dLytStructD : dLytStructD_Base { - dLytStructD() - : field_0x18(0), field_0x1C(nullptr), field_0x20(0), field_0x22(0), field_0x23(0), field_0x24(nullptr) {} - - virtual u32 getType() override; - virtual void doSomething() override; - virtual ~dLytStructD(); - - void init(nw4r::lyt::Pane *, u16, u8, u8); - void fn_80065E70(nw4r::lyt::Pane *, s32, s32, s32); - void fn_80065F70(); - - u32 field_0x18; - dLytStructDInArray *field_0x1C; - u16 field_0x20; - u8 field_0x22; - u8 field_0x23; - void *field_0x24; -}; - -class dLytStructDList { -public: - dLytStructDList(); - static dLytStructDList *create(EGG::Heap *heap); - - void appendToList1(dLytStructC *other); - void removeFromList1(dLytStructC *other); - - void appendToList2(dLytStructD *other); - void removeFromList2(dLytStructD *other); - - bool fn_80065A30(dLytStructD *other); - - static dLytStructDList *GetInstance() { - return sInstance; - } - -private: - static dLytStructDList *sInstance; - TList mList1; - TList mList2; - bool field_0x18; -}; - -} // namespace d2d - -#endif diff --git a/include/nw4r/lyt/lyt_pane.h b/include/nw4r/lyt/lyt_pane.h index 87c760be..fd43858f 100644 --- a/include/nw4r/lyt/lyt_pane.h +++ b/include/nw4r/lyt/lyt_pane.h @@ -54,6 +54,8 @@ public: return mbUserAllocated; } + typedef ut::LinkList ChildList; + ut::LinkList *GetChildList() { return &mChildList; } @@ -94,6 +96,13 @@ public: return mGlbAlpha; } + u8 GetPositionH() const { + return detail::GetHorizontalPosition(mBasePosition); + } + u8 GetPositionV() const { + return detail::GetVerticalPosition(mBasePosition); + } + const Size &GetSize() const { return mSize; } diff --git a/include/toBeSorted/d_d3d.h b/include/toBeSorted/d_d3d.h index f088d007..36ca2040 100644 --- a/include/toBeSorted/d_d3d.h +++ b/include/toBeSorted/d_d3d.h @@ -20,6 +20,7 @@ namespace d3d { f32 fn_80016960(mVec3_c&, const mVec3_c& pos); bool fn_80016A90(const mVec3_c& pos); +void fn_80016B60(mVec3_c&, const mVec3_c& pos); class AnmMdlWrapper : protected m3d::mdlAnmChr { public: diff --git a/include/toBeSorted/lyt_related_floats.h b/include/toBeSorted/lyt_related_floats.h index 5b12e937..be17f713 100644 --- a/include/toBeSorted/lyt_related_floats.h +++ b/include/toBeSorted/lyt_related_floats.h @@ -18,4 +18,24 @@ inline s32 get_8057511C() { return lbl_8057511C; } +extern "C" f32 lbl_8057515C; +inline f32 get_8057515C() { + return lbl_8057515C; +} + +extern "C" f32 lbl_80575148; +inline f32 get_80575148() { + return lbl_80575148; +} + +extern "C" f32 lbl_8057519C; +inline f32 get_8057519C() { + return lbl_8057519C; +} + +extern "C" f32 lbl_80575190; +inline f32 get_80575190() { + return lbl_80575190; +} + #endif diff --git a/include/toBeSorted/tlist.h b/include/toBeSorted/tlist.h index 95d2eaaf..736d7320 100644 --- a/include/toBeSorted/tlist.h +++ b/include/toBeSorted/tlist.h @@ -103,7 +103,7 @@ public: static T *GetPtrFromNode(TNode *pN) { return (T *)((u8 *)pN - offset); } - void insert(T *value) { + void append(T *value) { TNode *node = GetNodeFromPtr(value); if (GetPtrFromNode(&mStartEnd) == mStartEnd.mpNext) { node->mpNext = GetPtrFromNode(&mStartEnd); @@ -120,6 +120,36 @@ public: } } + void prepend(T *value) { + TNode *node = GetNodeFromPtr(value); + if (GetPtrFromNode(&mStartEnd) == mStartEnd.mpNext) { + node->mpNext = GetPtrFromNode(&mStartEnd); + node->mpPrev = GetPtrFromNode(&mStartEnd); + mStartEnd.mpNext = value; + mStartEnd.mpPrev = value; + mCount++; + } else { + node->mpPrev = GetPtrFromNode(&mStartEnd); + node->mpNext = mStartEnd.mpNext; + GetNodeFromPtr(mStartEnd.mpNext)->mpPrev = value; + mStartEnd.mpNext = value; + mCount++; + } + } + + void insertBefore(T* existing, T *value) { + TNode *node = GetNodeFromPtr(value); + TNode *existingNode = GetNodeFromPtr(existing); + + T* itPrev = existingNode->mpPrev; + node->mpPrev = itPrev; + node->mpNext = existing; + GetNodeFromPtr(itPrev)->mpNext = value; + existingNode->mpPrev = value; + + mCount++; + } + void remove(T *value) { TNode *node = GetNodeFromPtr(value); T *next = reinterpret_cast(node->mpNext); diff --git a/src/d/col/bg/d_bg_s.cpp b/src/d/col/bg/d_bg_s.cpp index 43fd11dc..8409bc6a 100644 --- a/src/d/col/bg/d_bg_s.cpp +++ b/src/d/col/bg/d_bg_s.cpp @@ -1143,7 +1143,7 @@ void dBgS::InitMapParts() { } void dBgS::AppendMapSegment(MapLineSegment *pSeg) { - mList_0x388C.insert(pSeg); + mList_0x388C.append(pSeg); } void dBgS::RemoveMapSegment(MapLineSegment *pSeg) { diff --git a/src/d/col/cc/d_cc_s.cpp b/src/d/col/cc/d_cc_s.cpp index 120ee9f0..702042e4 100644 --- a/src/d/col/cc/d_cc_s.cpp +++ b/src/d/col/cc/d_cc_s.cpp @@ -106,7 +106,7 @@ bool dCcS::ChkCameraPoint( bool dCcS::ChkCo(const mVec3_c &, dAcObjBase_c *) {} -bool dCcS::fn_80357c90(const mVec3_c &, const mVec3_c &, u32, UNKTYPE **) {} +bool dCcS::fn_80357c90(const mVec3_c &, const mVec3_c &, u32, cCcD_ShapeAttr **, f32) {} void dCcS::Set(cCcD_Obj *) {} diff --git a/src/d/d_cs_base.cpp b/src/d/d_cs_base.cpp index 14aec0ee..fbd75427 100644 --- a/src/d/d_cs_base.cpp +++ b/src/d/d_cs_base.cpp @@ -43,8 +43,8 @@ int dCsBase_c::create() { mLyts[i].calc(); } setCurrentLyt(0); - mStructC.field_0x10 = 1; - d2d::dLytStructDList::GetInstance()->appendToList1(&mStructC); + mCursorIf.setCursorMask(1); + dCsMgr_c::GetInstance()->registCursor(&mCursorIf); fn_8016B2B0(); field_0x6F0 = 0.0f; field_0x6F4 = 0.0f; @@ -59,7 +59,7 @@ int dCsBase_c::create() { } int dCsBase_c::doDelete() { - d2d::dLytStructDList::GetInstance()->removeFromList1(&mStructC); + dCsMgr_c::GetInstance()->unregistCursor(&mCursorIf); fn_8016B2E0(); mResAcc.detach(); return SUCCEEDED; diff --git a/src/d/d_cs_game.cpp b/src/d/d_cs_game.cpp index bc153463..5ab406a5 100644 --- a/src/d/d_cs_game.cpp +++ b/src/d/d_cs_game.cpp @@ -1,8 +1,8 @@ #include "d/d_cs_game.h" #include "d/d_cs_base.h" +#include "d/d_cursor_hit_check.h" #include "d/lyt/d2d.h" -#include "d/lyt/d_structd.h" #include "f/f_base.h" #include "toBeSorted/arc_managers/layout_arc_manager.h" #include "toBeSorted/small_sound_mgr.h" @@ -148,8 +148,8 @@ int dCsGame_c::create() { mCursorType = 0; mCursor.setField0x9A0(0); - mStructC.field_0x10 = 2; - d2d::dLytStructDList::GetInstance()->appendToList1(&mStructC); + mCursorIf.setCursorMask(2); + dCsMgr_c::GetInstance()->registCursor(&mCursorIf); dCsBase_c::GetInstance()->setField703(false); return SUCCEEDED; } @@ -158,7 +158,7 @@ int dCsGame_c::doDelete() { mCursor.remove(); mLyt2.dCsGameLytBase_0x14(); mLyt1.dCsGameLytBase_0x14(); - d2d::dLytStructDList::GetInstance()->removeFromList1(&mStructC); + dCsMgr_c::GetInstance()->unregistCursor(&mCursorIf); mCursorResAcc.detach(); mMain2DResAcc.detach(); return SUCCEEDED; diff --git a/src/d/d_cursor_hit_check.cpp b/src/d/d_cursor_hit_check.cpp new file mode 100644 index 00000000..9446db18 --- /dev/null +++ b/src/d/d_cursor_hit_check.cpp @@ -0,0 +1,259 @@ +#include "d/d_cursor_hit_check.h" + +#include "common.h" +#include "d/col/bg/d_bg_s.h" +#include "d/col/bg/d_bg_s_lin_chk.h" +#include "d/col/cc/d_cc_s.h" +#include "d/d_stage_mgr.h" +#include "m/m_mtx.h" +#include "m/m_vec.h" +#include "nw4r/g3d/g3d_camera.h" +#include "nw4r/lyt/lyt_bounding.h" +#include "nw4r/lyt/lyt_pane.h" +#include "nw4r/ut/ut_RuntimeTypeInfo.h" +#include "rvl/MTX/mtx.h" +#include "toBeSorted/d_d3d.h" +#include "toBeSorted/lyt_related_floats.h" + +dCsMgr_c::dCsMgr_c() { + // NONMATCHING - TList ctor issues + field_0x18 = true; + sInstance = this; +} + +extern "C" bool lbl_80572D10; +void dCsMgr_c::execute() { + // NONMATCHING - TList + if (field_0x18 == 0 && lbl_80572D10 == 0) { + for (CursorList::Iterator it = mList1.GetBeginIter(); it != mList1.GetEndIter(); ++it) { + it->mpHit = nullptr; + } + return; + } + + for (CursorList::Iterator it = mList1.GetBeginIter(); it != mList1.GetEndIter(); ++it) { + mVec2_c &pos = it->getCursorPos(); + s16 x = pos.x; + s16 y = pos.y; + it->mpHit = 0; + u32 mask = it->mCursorMask; + + if (mask) { + for (HitCheckList::Iterator chkIt = mList2.GetBeginIter(); chkIt != mList2.GetEndIter(); ++it) { + if ((chkIt->mMask & mask) != 0) { + bool hit = chkIt->checkHit(x, y); + if (chkIt->checkOverrideCallback(hit)) { + it->mpHit = &*chkIt; + break; + } + } + } + } + } +} + +void dCsMgr_c::registCursor(dCursorInterface_c *cursor) { + mList1.append(cursor); +} + +void dCsMgr_c::unregistCursor(dCursorInterface_c *cursor) { + // NONMATCHING - TList + mList1.remove(cursor); +} + +void dCsMgr_c::registCursorTarget(dCursorHitCheck_c *target) { + // NONMATCHING - TList + HitCheckList::Iterator it = mList2.GetBeginIter(); + HitCheckList::Iterator end = mList2.GetEndIter(); + while (it != end) { + if (target->mPriority < it->mPriority) { + if (it == end) { + mList2.prepend(target); + return; + } + + mList2.insertBefore(&*it, target); + return; + } + ++it; + } + mList2.append(target); +} + +void dCsMgr_c::unregistCursorTarget(dCursorHitCheck_c *target) { + // NONMATCHING - TList + for (CursorList::Iterator it = mList1.GetBeginIter(); it != mList1.GetEndIter(); ++it) { + if (target == it->mpHit) { + it->mpHit = 0; + } + } + mList2.remove(target); +} + +bool dCsMgr_c::isRegist(dCursorHitCheck_c *target) { + return mList2.GetPosition(target) != mList2.GetEndIter(); +} + +dCsMgr_c *dCsMgr_c::create(EGG::Heap *heap) { + return new (heap) dCsMgr_c(); +} + +bool dCursorHitCheck_c::init(u8 prio, u8 a, u16 mask) { + if (dCsMgr_c::GetInstance()->isRegist(this)) { + return false; + } + mPriority = prio; + field_0x017 = a; + mMask = mask; + return true; +} + +bool dCursorHitCheck_c::checkOverrideCallback(bool b) { + if (mOverrideHitCallback == nullptr) { + return b; + } + return mOverrideHitCallback(b, this, mCallbackData); +} + +bool dCursorHitCheckCC_c::checkHit(s32 x, s32 y) { + // NONMATCHING - TODO + mVec3_c pos(x, y, 10000.0f); + pos.x = (pos.x - get_8057515C()) / get_80575148() * -2.0f - 1.0f; + pos.y = (pos.y - get_8057519C()) / get_80575190() * 2.0f - 1.0f; + mVec3_c v; + d3d::fn_80016B60(v, pos); + nw4r::g3d::Camera cam = dStageMgr_c::GetInstance()->getCamera(0); + mMtx_c mtx; + cam.GetCameraMtx(mtx); + PSMTXInverse(mtx, mtx); + mVec3_c a; + a.x = mtx.m[0][3]; + a.y = mtx.m[1][3]; + a.z = mtx.m[2][3]; + dBgS_LinChk ck; + ck.Set(&a, &v, nullptr); + dBgS::GetInstance()->LineCross(&ck); + cCcD_ShapeAttr *attr = nullptr; + if (dCcS::GetInstance()->fn_80357c90(a, v, 0, &attr, 15.0f)) { + // TODO - this branches into unsplit code in col/ + return true; + } else { + return false; + } +} + +bool dCursorHitCheckCC_c::init(u16 mask, u8 prio, u8 a) { + return dCursorHitCheck_c::init(prio, a, mask); +} + +dCursorHitCheckLyt_c::~dCursorHitCheckLyt_c() { + delete[] mpBoundingData; + mpBoundingData = nullptr; +} + +bool dCursorHitCheckLyt_c::checkHit(s32 x, s32 y) { + dCsCheckLyt_BoundingData *p = &mpBoundingData[0]; + for (u16 i = 0; i < mNumBoundings; i++) { + if (p->mMinX <= x && x <= p->mMaxX && p->mMaxY >= y && y >= p->mMinY) { + mpHitPane = p->mpPane; + if (mpHitPane->GetAlpha() != 0 && mpHitPane->IsVisible()) { + return true; + } + } + p++; + } + + mpHitPane = nullptr; + return false; +} + +bool dCursorHitCheckLyt_c::init(nw4r::lyt::Pane *pPane, u16 mask, u8 prio, u8 a) { + if (!dCursorHitCheck_c::init(prio, a, mask)) { + return false; + } + + mpRootPane = pPane; + mNumBoundings = 0; + + countBoundings(pPane); + + dCsCheckLyt_BoundingData *pData = new dCsCheckLyt_BoundingData[mNumBoundings](); + mpBoundingData = pData; + dCsCheckLyt_BoundingData *pEnd = pData + mNumBoundings; + gatherBoundings(&pEnd, mpRootPane); + + return true; +} + +void dCursorHitCheckLyt_c::execute() { + if (!mHasCalculatedBoundingData) { + dCsCheckLyt_BoundingData *dat = &mpBoundingData[0]; + for (u16 i = 0; i < mNumBoundings; i++) { + nw4r::lyt::Pane *pane = dat->mpPane; + f32 xx = pane->GetGlobalMtx()._00; + switch (pane->GetPositionH()) { + case 0: + dat->mMinX = (s16)pane->GetGlobalMtx()._03; + dat->mMaxX = (s16)pane->GetGlobalMtx()._03 + xx * pane->GetSize().width; + break; + case 1: + dat->mMinX = (s16)pane->GetGlobalMtx()._03 - xx * pane->GetSize().width * 0.5f; + dat->mMaxX = (s16)pane->GetGlobalMtx()._03 + xx * pane->GetSize().width * 0.5f; + break; + case 2: + dat->mMinX = (s16)pane->GetGlobalMtx()._03 - xx * pane->GetSize().width; + dat->mMaxX = (s16)pane->GetGlobalMtx()._03; + break; + } + + switch (pane->GetPositionV()) { + case 0: + dat->mMaxY = (s16)pane->GetGlobalMtx()._13; + dat->mMinY = (s16)pane->GetGlobalMtx()._13 - pane->GetSize().height; + break; + case 1: + dat->mMaxY = (s16)pane->GetGlobalMtx()._13 + (pane->GetSize().height * 0.5f); + dat->mMinY = (s16)pane->GetGlobalMtx()._13 - (pane->GetSize().height * 0.5f); + break; + case 2: + dat->mMaxY = (s16)pane->GetGlobalMtx()._13 + pane->GetSize().height; + dat->mMinY = (s16)pane->GetGlobalMtx()._13; + break; + } + + dat++; + } + + mHasCalculatedBoundingData = true; + } +} + +void dCursorHitCheckLyt_c::countBoundings(nw4r::lyt::Pane *pane) { + nw4r::lyt::Bounding *b = nw4r::ut::DynamicCast(pane); + if (b != nullptr) { + mNumBoundings++; + } + + for (nw4r::lyt::Pane::ChildList::RevIterator it = pane->GetChildList()->GetEndReverseIter(); + it != pane->GetChildList()->GetBeginIter(); ++it) { + countBoundings(&*it); + } +} + +void dCursorHitCheckLyt_c::gatherBoundings(dCsCheckLyt_BoundingData **pEnd, nw4r::lyt::Pane *pane) { + nw4r::lyt::Bounding *b = nw4r::ut::DynamicCast(pane); + if (b != nullptr) { + (*pEnd)--; + (*pEnd)->mpPane = pane; + } + + for (nw4r::lyt::Pane::ChildList::RevIterator it = pane->GetChildList()->GetEndReverseIter(); + it != pane->GetChildList()->GetBeginIter(); ++it) { + gatherBoundings(pEnd, &*it); + } +} + +mVec2_c &dCursorInterface_c::getCursorPos() { + // NONMATCHING - Controller stuff + return *(mVec2_c *)nullptr; +} diff --git a/src/d/lyt/d_lyt_common_arrow.cpp b/src/d/lyt/d_lyt_common_arrow.cpp index 586604b3..1aeb988b 100644 --- a/src/d/lyt/d_lyt_common_arrow.cpp +++ b/src/d/lyt/d_lyt_common_arrow.cpp @@ -1,7 +1,7 @@ #include "d/lyt/d_lyt_common_arrow.h" #include "d/d_cs_base.h" -#include "d/lyt/d_structd.h" +#include "d/d_cursor_hit_check.h" #include "rvl/MTX/mtx.h" #include "toBeSorted/arc_managers/layout_arc_manager.h" #include "toBeSorted/small_sound_mgr.h" @@ -47,8 +47,8 @@ bool dLytCommonArrow_c::build() { for (int i = 0; i < 9; i++) { mAnmGroups[i].init(brlanMap[i].mFile, &mResAcc, mLytBase.getLayout(), brlanMap[i].mName); } - mStructD.fn_80065E70(mLytBase.getLayout()->GetRootPane(), 1, 0, 0); - d2d::dLytStructDList::GetInstance()->appendToList2(&mStructD); + mCsHitCheck.init(mLytBase.getLayout()->GetRootPane(), 1, 0, 0); + dCsMgr_c::GetInstance()->registCursorTarget(&mCsHitCheck); mBoundingL = mLytBase.findBounding("B_arrowL_00"); mBoundingR = mLytBase.findBounding("B_arrowR_00"); mStateMgr.changeState(StateID_None); @@ -57,7 +57,7 @@ bool dLytCommonArrow_c::build() { } bool dLytCommonArrow_c::remove() { - d2d::dLytStructDList::GetInstance()->removeFromList2(&mStructD); + dCsMgr_c::GetInstance()->unregistCursorTarget(&mCsHitCheck); mLytBase.unbindAnims(); for (int i = 0; i < 9; i++) { mAnmGroups[i].remove(); @@ -71,8 +71,8 @@ bool dLytCommonArrow_c::execute() { mAnmGroups[ANIM_LOOP].play(); } mLytBase.calc(); - mStructD.field_0x22 = 0; - mStructD.fn_80065F70(); + mCsHitCheck.resetCachedHitboxes(); + mCsHitCheck.execute(); field_0x6BC = field_0x6B8; return true; } @@ -153,11 +153,11 @@ void dLytCommonArrow_c::fn_80168880() { return; } - d2d::dLytStructD *thing = dCsBase_c::GetInstance()->getUnk(); - if (thing != nullptr && thing->getType() == 'lyt ') { - if (thing->field_0x24 == mBoundingL) { + dCursorHitCheck_c *d = dCsBase_c::GetInstance()->getHitCheck(); + if (d != nullptr && d->getType() == 'lyt ') { + if (static_cast(d)->getHitPane() == mBoundingL) { i = 0; - } else if (thing->field_0x24 == mBoundingR) { + } else if (static_cast(d)->getHitPane() == mBoundingR) { i = 1; } } diff --git a/src/d/lyt/d_lyt_common_icon_item.cpp b/src/d/lyt/d_lyt_common_icon_item.cpp index e4d67762..840c7db3 100644 --- a/src/d/lyt/d_lyt_common_icon_item.cpp +++ b/src/d/lyt/d_lyt_common_icon_item.cpp @@ -2,8 +2,8 @@ #include "common.h" #include "d/d_cs_base.h" +#include "d/d_cursor_hit_check.h" #include "d/lyt/d_lyt_common_icon_item_maps.h" -#include "d/lyt/d_structd.h" #include @@ -223,8 +223,8 @@ bool dLytCommonIconItemPart1_c::isDoneDeciding() const { } bool dLytCommonIconItemPart1_c::isCursorOver() const { - d2d::dLytStructD *d = dCsBase_c::GetInstance()->getUnk(); - if (d != nullptr && d->getType() == 'lyt ' && d->field_0x24 == mpBounding) { + dCursorHitCheck_c *d = dCsBase_c::GetInstance()->getHitCheck(); + if (d != nullptr && d->getType() == 'lyt ' && static_cast(d)->getHitPane() == mpBounding) { return true; } return false; @@ -556,8 +556,8 @@ bool dLytCommonIconItemPart2_c::isDoneDeciding() const { } bool dLytCommonIconItemPart2_c::isCursorOver() const { - d2d::dLytStructD *d = dCsBase_c::GetInstance()->getUnk(); - if (d != nullptr && d->getType() == 'lyt ' && d->field_0x24 == mpBounding) { + dCursorHitCheck_c *d = dCsBase_c::GetInstance()->getHitCheck(); + if (d != nullptr && d->getType() == 'lyt ' && static_cast(d)->getHitPane() == mpBounding) { return true; } return false; @@ -688,8 +688,8 @@ void dLytCommonIconItemPart3_c::realizeItem(u8 item) { } bool dLytCommonIconItemPart3_c::isCursorOver() const { - d2d::dLytStructD *d = dCsBase_c::GetInstance()->getUnk(); - if (d != nullptr && d->getType() == 'lyt ' && d->field_0x24 == mpBounding) { + dCursorHitCheck_c *d = dCsBase_c::GetInstance()->getHitCheck(); + if (d != nullptr && d->getType() == 'lyt ' && static_cast(d)->getHitPane() == mpBounding) { return true; } return false; diff --git a/src/d/lyt/d_lyt_common_icon_material.cpp b/src/d/lyt/d_lyt_common_icon_material.cpp index 2759bfeb..a8f99733 100644 --- a/src/d/lyt/d_lyt_common_icon_material.cpp +++ b/src/d/lyt/d_lyt_common_icon_material.cpp @@ -194,8 +194,8 @@ void dLytCommonIconMaterialPart1_c::setOff() { } bool dLytCommonIconMaterialPart1_c::isCursorOver() const { - d2d::dLytStructD *d = dCsBase_c::GetInstance()->getUnk(); - if (d != nullptr && d->getType() == 'lyt ' && d->field_0x24 == mpBounding) { + dCursorHitCheck_c *d = dCsBase_c::GetInstance()->getHitCheck(); + if (d != nullptr && d->getType() == 'lyt ' && static_cast(d)->getHitPane() == mpBounding) { return true; } return false; @@ -393,8 +393,8 @@ void dLytCommonIconMaterialPart2_c::setOff() { } bool dLytCommonIconMaterialPart2_c::isCursorOver() const { - d2d::dLytStructD *d = dCsBase_c::GetInstance()->getUnk(); - if (d != nullptr && d->getType() == 'lyt ' && d->field_0x24 == mpBounding) { + dCursorHitCheck_c *d = dCsBase_c::GetInstance()->getHitCheck(); + if (d != nullptr && d->getType() == 'lyt ' && static_cast(d)->getHitPane() == mpBounding) { return true; } return false; diff --git a/src/d/lyt/d_lyt_map.cpp b/src/d/lyt/d_lyt_map.cpp index d01e6942..8d63e48e 100644 --- a/src/d/lyt/d_lyt_map.cpp +++ b/src/d/lyt/d_lyt_map.cpp @@ -2,7 +2,7 @@ #include "common.h" #include "d/lyt/d2d.h" -#include "d/lyt/d_structd.h" +#include "d/d_cursor_hit_check.h" #include "egg/core/eggColorFader.h" #include "m/m_video.h" #include "sized_string.h" @@ -236,8 +236,8 @@ void dLytMapPinIcon_c::executeState_Remove() { void dLytMapPinIcon_c::finalizeState_Remove() {} dLytMapPinIcon_c::~dLytMapPinIcon_c() { - if (d2d::dLytStructDList::GetInstance()->fn_80065A30(&mStructD)) { - d2d::dLytStructDList::GetInstance()->removeFromList2(&mStructD); + if (dCsMgr_c::GetInstance()->isRegist(&mCsHitCheck)) { + dCsMgr_c::GetInstance()->unregistCursorTarget(&mCsHitCheck); } } @@ -266,8 +266,8 @@ bool dLytMapPinIcon_c::build(d2d::ResAccIf_c *resAcc) { } mpBounding = mLyt.findBounding("B_mark_00"); - mStructD.fn_80065E70(mpBounding, 2, 1, 0); - d2d::dLytStructDList::GetInstance()->appendToList2(&mStructD); + mCsHitCheck.init(mpBounding, 2, 1, 0); + dCsMgr_c::GetInstance()->registCursorTarget(&mCsHitCheck); mAnmGroups[LYT_MAP_PIN_ICON_ANIM_SCALE].bind(false); mAnmGroups[LYT_MAP_PIN_ICON_ANIM_LOOP].bind(false); @@ -282,7 +282,7 @@ bool dLytMapPinIcon_c::build(d2d::ResAccIf_c *resAcc) { } bool dLytMapPinIcon_c::remove() { - d2d::dLytStructDList::GetInstance()->removeFromList2(&mStructD); + dCsMgr_c::GetInstance()->unregistCursorTarget(&mCsHitCheck); for (int i = 0; i < 3; i++) { mAnmGroups[i].remove(); } @@ -296,8 +296,8 @@ bool dLytMapPinIcon_c::execute() { mAnmGroups[2].setFrame(field_0x1DC); // TODO something MapCapture mLyt.calc(); - mStructD.field_0x22 = 0; - mStructD.fn_80065F70(); + mCsHitCheck.resetCachedHitboxes(); + mCsHitCheck.execute(); return true; } @@ -398,8 +398,8 @@ void dLytMapFloorBtnMgr_c::finalizeState_Wait() {} extern "C" void fn_801942F0(int, int); dLytMapFloorBtnMgr_c::~dLytMapFloorBtnMgr_c() { for (int i = 0; i < 4; i++) { - if (d2d::dLytStructDList::GetInstance()->fn_80065A30(&mStructDs[i])) { - d2d::dLytStructDList::GetInstance()->removeFromList2(&mStructDs[i]); + if (dCsMgr_c::GetInstance()->isRegist(&mCsHitChecks[i])) { + dCsMgr_c::GetInstance()->unregistCursorTarget(&mCsHitChecks[i]); } } fn_801942F0(0, 0); diff --git a/src/d/lyt/d_lyt_pause_disp_00.cpp b/src/d/lyt/d_lyt_pause_disp_00.cpp index 36367537..9f88dca6 100644 --- a/src/d/lyt/d_lyt_pause_disp_00.cpp +++ b/src/d/lyt/d_lyt_pause_disp_00.cpp @@ -39,7 +39,7 @@ void dLytPauseDisp00_c::init() { } field_0xE29C.init(mLytBase.getLayout()->GetRootPane(), 1, 0, 0); - d2d::dLytStructDList::GetInstance()->appendToList2(&field_0xE29C); + dCsMgr_c::GetInstance()->registCursorTarget(&field_0xE29C); for (int i = 0; i < 0x25; i++) { if (i != 0x1F && i != 0x20) { nw4r::lyt::Bounding *b = mLytBase.findBounding(B_LIST[i]); diff --git a/src/d/lyt/d_structd.cpp b/src/d/lyt/d_structd.cpp deleted file mode 100644 index 40ee0a88..00000000 --- a/src/d/lyt/d_structd.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "d/lyt/d_structd.h" - -namespace d2d { - -dLytStructDList::dLytStructDList() { - field_0x18 = true; - sInstance = this; -} - -dLytStructDList *dLytStructDList::create(EGG::Heap *heap) { - return new (heap) dLytStructDList(); -} - -void dLytStructDList::appendToList1(dLytStructC *other) { - mList1.insert(other); -} - -void dLytStructDList::removeFromList1(dLytStructC *other) { - mList1.remove(other); -} - -void dLytStructDList::appendToList2(dLytStructD *other) { - mList2.insert(other); -} - -void dLytStructDList::removeFromList2(dLytStructD *other) { - mList2.remove(other); -} - -dLytStructD::~dLytStructD() { - delete[] field_0x1C; - field_0x1C = nullptr; -} - -} // namespace d2d diff --git a/src/toBeSorted/d_d3d.cpp b/src/toBeSorted/d_d3d.cpp index 0b885de7..5ce74e32 100644 --- a/src/toBeSorted/d_d3d.cpp +++ b/src/toBeSorted/d_d3d.cpp @@ -217,7 +217,7 @@ extern "C" f32 lbl_80576A0C; void insertNode(SomeListNode *node, f32 a, f32 b) { node->field_0x04 = ((a * lbl_80575150) - 0.5f) + lbl_8057514C; node->field_0x06 = (lbl_80575150 - 0.5f) - b; - sSomeList.insert(node); + sSomeList.append(node); } void clearList() { @@ -340,7 +340,7 @@ bool UnkWithWater::init(nw4r::g3d::ResTexObj &obj, GXTexMapID mapId) { if (nd == nullptr) { return false; } - mList.insert(nd); + mList.append(nd); return true; } diff --git a/src/toBeSorted/dowsing_target.cpp b/src/toBeSorted/dowsing_target.cpp index 879447c3..bd375fca 100644 --- a/src/toBeSorted/dowsing_target.cpp +++ b/src/toBeSorted/dowsing_target.cpp @@ -211,7 +211,7 @@ static bool insertDowsingTarget(DowsingTarget *target) { if (DOWSING_LISTS[slot].GetPosition(target) != DOWSING_LISTS[slot].GetEndIter()) { return false; } - DOWSING_LISTS[slot].insert(target); + DOWSING_LISTS[slot].append(target); return true; } diff --git a/src/toBeSorted/nand_request_thread.cpp b/src/toBeSorted/nand_request_thread.cpp index fbed9616..591c627e 100644 --- a/src/toBeSorted/nand_request_thread.cpp +++ b/src/toBeSorted/nand_request_thread.cpp @@ -82,7 +82,7 @@ void NandRequestThread::sendMessage() { } void NandRequestThread::enqueueRequest(NandRequest *request) { - mRequestList.insert(request); + mRequestList.append(request); sendMessage(); } diff --git a/src/toBeSorted/sound_info.cpp b/src/toBeSorted/sound_info.cpp index 5e18b0bf..585f35ce 100644 --- a/src/toBeSorted/sound_info.cpp +++ b/src/toBeSorted/sound_info.cpp @@ -7,7 +7,7 @@ extern "C" bool fn_8002C250(SoundInfo *p1, int someNum, char *name, mVec3_c *pos if (!p1->sound_source) { return false; } - p1->actor->sound_list.insert(p1); + p1->actor->sound_list.append(p1); p1->obj_pos = position; return true; }