summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrobojumper <robojumper@gmail.com>2025-09-19 11:38:37 +0200
committerrobojumper <robojumper@gmail.com>2025-09-19 11:38:37 +0200
commit5b043bdff9ff27a120a2e37f8736b97afc4f48ae (patch)
treee9bb150d76d53f586635cf52801899c7d171ac60 /src
parente9c2ac8f1a884db5724d326dbcedf9d3d2b35b53 (diff)
More cursor
Diffstat (limited to 'src')
-rw-r--r--src/d/d_cs_game.cpp681
-rw-r--r--src/d/d_cursor_hit_check.cpp2
2 files changed, 576 insertions, 107 deletions
diff --git a/src/d/d_cs_game.cpp b/src/d/d_cs_game.cpp
index f9f7518c..fdeff1cd 100644
--- a/src/d/d_cs_game.cpp
+++ b/src/d/d_cs_game.cpp
@@ -1,15 +1,23 @@
#include "d/d_cs_game.h"
+#include "common.h"
+#include "d/a/d_a_player.h"
#include "d/d_cs_base.h"
#include "d/d_cursor_hit_check.h"
+#include "d/d_gfx.h"
+#include "d/d_pad.h"
#include "d/lyt/d2d.h"
+#include "d/lyt/d_lyt_map.h"
#include "d/snd/d_snd_small_effect_mgr.h"
#include "f/f_base.h"
+#include "m/m_vec.h"
+#include "nw4r/lyt/lyt_pane.h"
#include "toBeSorted/arc_managers/layout_arc_manager.h"
+#include "toBeSorted/d_emitter.h"
SPECIAL_BASE_PROFILE(C_GAME, dCsGame_c, fProfile::C_GAME, 0x2BF, 0x06F9);
-dCsGame_HIO_c sConfig;
+static dCsGame_HIO_c sHio;
dCsGame_HIO_c::dCsGame_HIO_c() {
field_0x04 = 0.0f;
@@ -72,57 +80,7 @@ STATE_DEFINE(dCsGame_c::lytItemCursor_c::lytVacuumCsr_c, ToLock);
STATE_DEFINE(dCsGame_c::lytItemCursor_c::lytVacuumCsr_c, Lock);
STATE_DEFINE(dCsGame_c::lytItemCursor_c::lytVacuumCsr_c, ToNormal);
-#define MAIN_ANIM_CURSOR 0
-#define MAIN_ANIM_DOWSE_IN_OUT 1
-#define MAIN_ANIM_LOOP 2
-#define MAIN_ANIM_HOOK_FIX 3
-#define MAIN_ANIM_VACUUM_LOCK 4
-#define MAIN_ANIM_LOCK_LOOP 5
-#define MAIN_ANIM_DOWSE_LOOP_1 6
-#define MAIN_ANIM_DOWSE_LOOP_2 7
-#define MAIN_ANIM_DOWSE_LOOP_3 8
-#define MAIN_ANIM_DOWSE_ZOOM 9
-#define MAIN_ANIM_ARROW_ON 10
-#define MAIN_ANIM_ARROW_CURSOR 11
-#define MAIN_ANIM_ARROW_EFFECT 12
-#define MAIN_ANIM_ARROW_KEEP 13
-#define MAIN_ANIM_ARROW_PEAK 14
-#define MAIN_ANIM_SLING_ON 15
-#define MAIN_ANIM_SLING_KEEP 16
-#define MAIN_ANIM_SLING_PEAK 17
-#define MAIN_ANIM_SLING_PEAK_RING 18
-#define MAIN_ANIM_SLING_OUT 19
-#define MAIN_ANIM_ARROW_LOOP 20
-#define MAIN_ANIM_LOOP_END 21
-#define MAIN_ANIM_LOOP_END_2 22
-
-static const d2d::LytBrlanMapping lytItemCursorMap[] = {
- { "itemCursor_00_cursor.brlan", "G_cursor_00"},
- { "itemCursor_00_dowseInOut.brlan", "G_dowseAll_00"},
- { "itemCursor_00_loop.brlan", "G_loop_00"},
- { "itemCursor_00_hookFix.brlan", "G_hookFix_00"},
- { "itemCursor_00_vacuumLock.brlan", "G_vacuumLock_00"},
- { "itemCursor_00_lockLoop.brlan", "G_lockLoop_00"},
- { "itemCursor_00_dowseLoop1.brlan", "G_dowseLoop_00"},
- { "itemCursor_00_dowseLoop2.brlan", "G_dowseLoop_01"},
- { "itemCursor_00_dowseLoop3.brlan", "G_auraLoop_00"},
- { "itemCursor_00_dowseZoom.brlan", "G_dowseAll_00"},
- { "itemCursor_00_arrowOn.brlan", "G_arrowOn_00"},
- { "itemCursor_00_arrowCursor.brlan", "G_arrowCursor_00"},
- { "itemCursor_00_arrowEffect.brlan", "G_arrowEffect_00"},
- { "itemCursor_00_arrowKeep.brlan", "G_arrowCursor_00"},
- { "itemCursor_00_arrowPeak.brlan", "G_arrowCursor_00"},
- { "itemCursor_00_slingOn.brlan", "G_slingEffect_00"},
- { "itemCursor_00_slingKeep.brlan", "G_slingGauge_00"},
- { "itemCursor_00_slingPeak.brlan", "G_slingAll_00"},
- {"itemCursor_00_slingPeakRing.brlan", "G_slingRing_00"},
- { "itemCursor_00_slingOut.brlan", "G_slingEffect_00"},
- { "itemCursor_00_loop2.brlan", "G_arrowLoop"},
- { "itemCursor_00_loopEnd.brlan", "G_loopEnd_00"},
- { "itemCursor_00_loopEnd2.brlan", "G_loopEnd_01"},
-};
-
-dCsGame_c::dCsGame_c() : mCursorType(0) {
+dCsGame_c::dCsGame_c() : mCursorType(lytItemCursor_c::CS_NONE) {
sInstance = this;
}
@@ -137,14 +95,14 @@ int dCsGame_c::create() {
mMain2DResAcc.attach(mainData, "");
mLyt1.setResAcc(&mCursorResAcc);
- mLyt1.dCsGameLytBase_0x10();
+ mLyt1.init();
mLyt2.setResAcc(&mCursorResAcc);
- mLyt2.dCsGameLytBase_0x10();
+ mLyt2.init();
mCursor.setResAcc(&mMain2DResAcc);
mCursor.init();
- setNextCursorType(lytItemCursor_c::NONE);
- mCursorType = 0;
+ setNextCursorType(lytItemCursor_c::CS_NONE);
+ mCursorType = lytItemCursor_c::CS_NONE;
mCursor.setField0x9A0(0);
mCursorIf.setCursorMask(2);
@@ -155,22 +113,228 @@ int dCsGame_c::create() {
int dCsGame_c::doDelete() {
mCursor.remove();
- mLyt2.dCsGameLytBase_0x14();
- mLyt1.dCsGameLytBase_0x14();
+ mLyt2.remove();
+ mLyt1.remove();
dCsMgr_c::GetInstance()->unregistCursor(&mCursorIf);
mCursorResAcc.detach();
mMain2DResAcc.detach();
return SUCCEEDED;
}
+#pragma push
+#pragma pool_data off
+int dCsGame_c::execute() {
+ mCursorType = mCursor.mNextCursorType;
+ mCursor.mCursorActive = mCursor.mNextCursor;
+ if (mCursor.isCursorActive() && mCursorType == lytItemCursor_c::CS_DOWSING) {
+ mCursor.mDowsing.moveEffectsIn();
+ } else {
+ mCursor.mDowsing.moveEffectsOut();
+ }
+
+ bool active = mCursor.isCursorActive();
+ if (!active) {
+ if (!mCursor.field_0x9A2) {
+ mCursor.field_0x9A1 = active;
+ }
+ mCursor.field_0x9A2 = false;
+ return SUCCEEDED;
+ }
+
+ if (active != mCursor.field_0x9A1 || mCursorType != mCursor.mActiveCursorType) {
+ switch (mCursorType) {
+ case lytItemCursor_c::CS_BOW: mCursor.changeState(lytItemCursor_c::StateID_Bow); break;
+ case lytItemCursor_c::CS_DOWSING: mCursor.changeState(lytItemCursor_c::StateID_Dowsing); break;
+ case lytItemCursor_c::CS_VACUUM: mCursor.changeState(lytItemCursor_c::StateID_Vacuum); break;
+ case lytItemCursor_c::CS_PACHINKO: mCursor.changeState(lytItemCursor_c::StateID_Pachinko); break;
+ case lytItemCursor_c::CS_HOOKSHOT: mCursor.changeState(lytItemCursor_c::StateID_HookShot); break;
+ case lytItemCursor_c::CS_PLAYERCAM: mCursor.changeState(lytItemCursor_c::StateID_PlayerCam); break;
+ default: break;
+ }
+
+ if (!mCursor.field_0x9A2) {
+ mCursor.mActiveCursorType = mCursorType;
+ mCursor.field_0x9A1 = mCursor.mCursorActive;
+ }
+ }
+
+ const mVec2_c &cursorPosition = mCursorIf.getCursorPos();
+
+ switch (mCursorType) {
+ case lytItemCursor_c::CS_POINTER_CAT: {
+ mLyt2.setPosition(mVec2_c(cursorPosition.x, cursorPosition.y + 10.0f));
+ mLyt2.execute();
+ break;
+ }
+ case lytItemCursor_c::CS_POINTER_DEF: {
+ mLyt1.setPosition(cursorPosition);
+ mLyt1.execute();
+ break;
+ }
+ case lytItemCursor_c::CS_BOW:
+ case lytItemCursor_c::CS_DOWSING:
+ case lytItemCursor_c::CS_VACUUM:
+ case lytItemCursor_c::CS_PACHINKO:
+ case lytItemCursor_c::CS_PLAYERCAM:
+ case lytItemCursor_c::CS_HOOKSHOT: {
+ mCursor.setPosition(cursorPosition);
+ mCursor.execute();
+ } break;
+ default: break;
+ }
+
+ mCursor.mNextCursor = false;
+ mCursor.field_0x9A2 = false;
+
+ return SUCCEEDED;
+}
+#pragma pop
+
+int dCsGame_c::draw() {
+ if (!mCursor.isCursorActive() || isForcedHidden()) {
+ return SUCCEEDED;
+ }
+
+ switch (mCursorType) {
+ case lytItemCursor_c::CS_POINTER_CAT: mLyt2.draw(); break;
+ case lytItemCursor_c::CS_POINTER_DEF: mLyt1.draw(); break;
+ case lytItemCursor_c::CS_BOW:
+ case lytItemCursor_c::CS_DOWSING:
+ case lytItemCursor_c::CS_VACUUM:
+ case lytItemCursor_c::CS_PACHINKO:
+ case lytItemCursor_c::CS_PLAYERCAM:
+ case lytItemCursor_c::CS_HOOKSHOT: mCursor.draw(); break;
+ default: break;
+ }
+
+ return SUCCEEDED;
+}
+
bool dCsGame_c::fn_801BF5E0() const {
- return mCursor.isCursorActive() & !fn_801BF630();
+ return mCursor.isCursorActive() & !isForcedHidden();
}
void dCsGame_c::setNextCursorType(lytItemCursor_c::CursorType_e cs) {
mCursor.setNextCursorType(cs);
}
+void dCsGame_c::setCursorTypePlayerCam() {
+ setNextCursorType(lytItemCursor_c::CS_PLAYERCAM);
+}
+
+mVec2_c &dCursorInterfaceGame_c::getCursorPos() {
+ // TODO explain this math
+ mVec2_c pos = dPad::getDpdPosScreen();
+ f32 f0 = dGfx_c::getWidth4x3() / dGfx_c::getWidth16x9F() * 368.0f;
+ f32 f1 = sHio.field_0x04;
+ f32 f2 = sHio.field_0x08 + 6.0f;
+ f32 f3 = sHio.field_0x10 + 4.0f;
+ f32 f4 = sHio.field_0x0C + -15.0f;
+
+ if (dLytMap_c::GetInstance() != nullptr && dLytMap_c::GetInstance()->isOpenMaybe()) {
+ if (pos.x < -f0 + f4) {
+ pos.x = -f0 + f4;
+ }
+ if (pos.x > f0 + f3) {
+ pos.x = f0 + f3;
+ }
+ if (pos.y < f1 + -209.0f) {
+ pos.y = f1 + -209.0f;
+ }
+ if (pos.y < f2 + -209.0f) {
+ pos.y = f2 + -209.0f;
+ }
+ }
+
+ field_0x14 = pos;
+
+ return field_0x14;
+}
+
+bool dCsGameLytBase2_c::init() {
+ loadResAcc();
+ build();
+ return true;
+}
+
+bool dCsGameLytBase2_c::execute() {
+ nw4r::lyt::Pane *p = getLyt()->getLayout()->GetRootPane();
+ mVec3_c pos;
+ pos.x = mPosition.x;
+ pos.y = mPosition.y;
+ pos.z = 0.0f;
+ p->SetTranslate(pos);
+ getLyt()->calc();
+ return true;
+}
+
+bool dCsGameLytBase2_c::draw() {
+ getLyt()->addToDrawList();
+ return true;
+}
+
+void dCsGameLyt1_c::loadResAcc() {
+ mLyt.setResAcc(mpResAcc);
+}
+
+void dCsGameLyt1_c::build() {
+ mLyt.build("P1_Def.brlyt", nullptr);
+}
+
+bool dCsGameLyt1_c::init() {
+ dCsGameLytBase2_c::init();
+ mLyt.setPriority(0x88);
+ mLyt.calc();
+ return true;
+}
+
+bool dCsGameLyt1_c::remove() {
+ return true;
+}
+
+void dCsGameLyt2_c::loadResAcc() {
+ mLyt.setResAcc(mpResAcc);
+}
+
+void dCsGameLyt2_c::build() {
+ mLyt.build("P1_Cat.brlyt", nullptr);
+}
+
+bool dCsGameLyt2_c::init() {
+ dCsGameLytBase2_c::init();
+ mLyt.setPriority(0x88);
+ mLyt.calc();
+ return true;
+}
+
+bool dCsGameLyt2_c::remove() {
+ return true;
+}
+
+#define MAIN_ANIM_CURSOR 0
+#define MAIN_ANIM_DOWSE_IN_OUT 1
+#define MAIN_ANIM_LOOP 2
+#define MAIN_ANIM_HOOK_FIX 3
+#define MAIN_ANIM_VACUUM_LOCK 4
+#define MAIN_ANIM_LOCK_LOOP 5
+#define MAIN_ANIM_DOWSE_LOOP_1 6
+#define MAIN_ANIM_DOWSE_LOOP_2 7
+#define MAIN_ANIM_DOWSE_LOOP_3 8
+#define MAIN_ANIM_DOWSE_ZOOM 9
+#define MAIN_ANIM_ARROW_ON 10
+#define MAIN_ANIM_ARROW_CURSOR 11
+#define MAIN_ANIM_ARROW_EFFECT 12
+#define MAIN_ANIM_ARROW_KEEP 13
+#define MAIN_ANIM_ARROW_PEAK 14
+#define MAIN_ANIM_SLING_ON 15
+#define MAIN_ANIM_SLING_KEEP 16
+#define MAIN_ANIM_SLING_PEAK 17
+#define MAIN_ANIM_SLING_PEAK_RING 18
+#define MAIN_ANIM_SLING_OUT 19
+#define MAIN_ANIM_ARROW_LOOP 20
+#define MAIN_ANIM_LOOP_END 21
+#define MAIN_ANIM_LOOP_END_2 22
+
void dCsGame_c::lytItemCursor_c::initializeState_Invisible() {}
void dCsGame_c::lytItemCursor_c::executeState_Invisible() {}
void dCsGame_c::lytItemCursor_c::finalizeState_Invisible() {}
@@ -180,7 +344,7 @@ void dCsGame_c::lytItemCursor_c::initializeState_Bow() {
mBow.select();
}
void dCsGame_c::lytItemCursor_c::executeState_Bow() {
- mCursorTrail = 1;
+ mDrawCursorTrailThisFrame = true;
mBow.execute();
}
void dCsGame_c::lytItemCursor_c::finalizeState_Bow() {}
@@ -197,14 +361,14 @@ void dCsGame_c::lytItemCursor_c::initializeState_Vacuum() {
mVacuum.enter();
}
void dCsGame_c::lytItemCursor_c::executeState_Vacuum() {
- mCursorTrail = 1;
+ mDrawCursorTrailThisFrame = true;
mVacuum.execute();
}
void dCsGame_c::lytItemCursor_c::finalizeState_Vacuum() {}
void dCsGame_c::lytItemCursor_c::initializeState_Pachinko() {}
void dCsGame_c::lytItemCursor_c::executeState_Pachinko() {
- mCursorTrail = 1;
+ mDrawCursorTrailThisFrame = true;
mPachinko.execute();
}
void dCsGame_c::lytItemCursor_c::finalizeState_Pachinko() {}
@@ -213,7 +377,7 @@ void dCsGame_c::lytItemCursor_c::initializeState_HookShot() {
mCrawShot.enter();
}
void dCsGame_c::lytItemCursor_c::executeState_HookShot() {
- mCursorTrail = 1;
+ mDrawCursorTrailThisFrame = true;
mCrawShot.execute();
}
void dCsGame_c::lytItemCursor_c::finalizeState_HookShot() {}
@@ -229,24 +393,61 @@ void dCsGame_c::lytItemCursor_c::changeState(const sFStateID_c<lytItemCursor_c>
mStateMgr.changeState(newState);
}
-bool dCsGame_c::lytItemCursor_c::doInit() {
+void dCsGame_c::lytItemCursor_c::loadResAcc() {
+ mLyt.setResAcc(mpResAcc);
+}
+
+void dCsGame_c::lytItemCursor_c::build() {
+ mLyt.build("itemCursor_00.brlyt", nullptr);
+}
+
+static const d2d::LytBrlanMapping lytItemCursorMap[] = {
+ { "itemCursor_00_cursor.brlan", "G_cursor_00"},
+ { "itemCursor_00_dowseInOut.brlan", "G_dowseAll_00"},
+ { "itemCursor_00_loop.brlan", "G_loop_00"},
+ { "itemCursor_00_hookFix.brlan", "G_hookFix_00"},
+ { "itemCursor_00_vacuumLock.brlan", "G_vacuumLock_00"},
+ { "itemCursor_00_lockLoop.brlan", "G_lockLoop_00"},
+ { "itemCursor_00_dowseLoop1.brlan", "G_dowseLoop_00"},
+ { "itemCursor_00_dowseLoop2.brlan", "G_dowseLoop_01"},
+ { "itemCursor_00_dowseLoop3.brlan", "G_auraLoop_00"},
+ { "itemCursor_00_dowseZoom.brlan", "G_dowseAll_00"},
+ { "itemCursor_00_arrowOn.brlan", "G_arrowOn_00"},
+ { "itemCursor_00_arrowCursor.brlan", "G_arrowCursor_00"},
+ { "itemCursor_00_arrowEffect.brlan", "G_arrowEffect_00"},
+ { "itemCursor_00_arrowKeep.brlan", "G_arrowCursor_00"},
+ { "itemCursor_00_arrowPeak.brlan", "G_arrowCursor_00"},
+ { "itemCursor_00_slingOn.brlan", "G_slingEffect_00"},
+ { "itemCursor_00_slingKeep.brlan", "G_slingGauge_00"},
+ { "itemCursor_00_slingPeak.brlan", "G_slingAll_00"},
+ {"itemCursor_00_slingPeakRing.brlan", "G_slingRing_00"},
+ { "itemCursor_00_slingOut.brlan", "G_slingEffect_00"},
+ { "itemCursor_00_loop2.brlan", "G_arrowLoop"},
+ { "itemCursor_00_loopEnd.brlan", "G_loopEnd_00"},
+ { "itemCursor_00_loopEnd2.brlan", "G_loopEnd_01"},
+};
+
+bool dCsGame_c::lytItemCursor_c::init() {
mEffects.init(dCsGame_c::sInstance);
- preInit();
+ dCsGameLytBase2_c::init();
mLyt.setPriority(0x88);
mLyt.calc();
mAnm.init(mAnmGroups.tmp.mAnmGroups, lytItemCursorMap, 0x17, mpResAcc, mLyt.getLayout());
for (int i = 0; i < 0x17; i++) {
- mAnmGroups.tmp.mAnmGroups[i].bind(false);
- mAnmGroups.tmp.mAnmGroups[i].setAnimEnable(false);
+ d2d::AnmGroup_c &grp = mAnmGroups[i];
+ grp.bind(false);
+ grp.setAnimEnable(false);
}
mAnmGroups.tmp.mAnmGroups[MAIN_ANIM_CURSOR].setAnimEnable(true);
- mAnmGroups.tmp.mAnmGroups[MAIN_ANIM_LOOP].setFrame(0.0f);
- mAnmGroups.tmp.mAnmGroups[MAIN_ANIM_LOOP].setAnimEnable(true);
+ d2d::AnmGroup_c &mainLoop = mAnmGroups.tmp.mAnmGroups[MAIN_ANIM_LOOP];
+ mainLoop.setFrame(0.0f);
+ mainLoop.setAnimEnable(true);
mAnmGroups.tmp.mAnmGroups[MAIN_ANIM_ARROW_LOOP].setAnimEnable(true);
- mAnmGroups.tmp.mAnmGroups[MAIN_ANIM_ARROW_LOOP].setFrame(0.0f);
+ d2d::AnmGroup_c &arrowLoop = mAnmGroups.tmp.mAnmGroups[MAIN_ANIM_ARROW_LOOP];
+ arrowLoop.setFrame(0.0f);
mBow.init();
mDowsing.init();
@@ -256,18 +457,47 @@ bool dCsGame_c::lytItemCursor_c::doInit() {
mAnmGroups.tmp.mAnmGroups[MAIN_ANIM_VACUUM_LOCK].setAnimEnable(false);
mEffects.setEmitterCallback(&mTrailCb);
-
+
mLyt.setPriority(0x88);
mLyt.calc();
- mAnmGroups.tmp.mAnmGroups[0x14].setAnimEnable(false);
+ arrowLoop.setAnimEnable(false);
mStateMgr.changeState(StateID_Invisible);
return true;
}
+bool dCsGame_c::lytItemCursor_c::remove() {
+ mAnm.remove();
+ return true;
+}
+
+bool dCsGame_c::lytItemCursor_c::execute() {
+ mPositionThisFrame.x = mPosition.x;
+ mPositionThisFrame.y = mPosition.y;
+ mPositionThisFrame.z = 0.0f;
+
+ mDrawCursorTrailThisFrame = false;
+ mAnmGroups[MAIN_ANIM_LOOP].setAnimEnable(true);
+ mStateMgr.executeState();
+
+ if (dCsGame_c::GetInstance()->fn_801BF5E0() && mDrawCursorTrailThisFrame) {
+ f32 sqDist = mPositionThisFrame.squareDistance(mPositionLastFrame);
+ if (sqDist > sHio.field_0x34 * sHio.field_0x34 ||
+ (mEffects.hasEmitters() && sqDist > sHio.field_0x38 * sHio.field_0x38)) {
+ mEffects.createContinuousUIEffect(
+ PARTICLE_RESOURCE_ID_MAPPING_31_, mPositionThisFrame, nullptr, nullptr, nullptr, nullptr
+ );
+ }
+ }
+
+ dCsGameLytBase2_c::execute();
+ mPositionLastFrame = mPositionThisFrame;
+ return true;
+}
+
void dCsGame_c::lytItemCursor_c::lytDowsingCsr_c::initializeState_NotFind() {}
void dCsGame_c::lytItemCursor_c::lytDowsingCsr_c::executeState_NotFind() {
- if (field_0xC0 < 0.999f) {
+ if (field_0xC0 < 0.9999f) {
mAnm[MAIN_ANIM_DOWSE_IN_OUT].setAnimEnable(true);
mAnm[MAIN_ANIM_DOWSE_IN_OUT].setForward();
mStateMgr.changeState(StateID_Find);
@@ -280,8 +510,7 @@ void dCsGame_c::lytItemCursor_c::lytDowsingCsr_c::executeState_ToFind() {
if (mAnm[MAIN_ANIM_DOWSE_IN_OUT].isEndReached()) {
mAnm[MAIN_ANIM_DOWSE_IN_OUT].setAnimEnable(false);
mAnm[MAIN_ANIM_DOWSE_ZOOM].setAnimEnable(true);
- // TODO
- mAnm[MAIN_ANIM_DOWSE_ZOOM].setRatio(1.0f - field_0xC0);
+ mAnm[MAIN_ANIM_DOWSE_ZOOM].setFrame((1.0f - field_0xC0) * mAnm[MAIN_ANIM_DOWSE_ZOOM].getLastFrame());
mpLyt->calc();
mStateMgr.changeState(StateID_Find);
} else {
@@ -294,11 +523,11 @@ void dCsGame_c::lytItemCursor_c::lytDowsingCsr_c::initializeState_Find() {}
void dCsGame_c::lytItemCursor_c::lytDowsingCsr_c::executeState_Find() {
mAnm[MAIN_ANIM_DOWSE_LOOP_2].setAnimEnable(true);
mAnm[MAIN_ANIM_DOWSE_ZOOM].setAnimEnable(true);
- // TODO
- mAnm[MAIN_ANIM_DOWSE_ZOOM].setRatio(1.0f - field_0xC0);
+ f32 f = mAnm[MAIN_ANIM_DOWSE_ZOOM].getLastFrame();
+ mAnm[MAIN_ANIM_DOWSE_ZOOM].setFrame((1.0f - field_0xC0) * f);
if (field_0xC0 > 0.9999f) {
- mAnm[MAIN_ANIM_DOWSE_ZOOM].setToEnd();
+ mAnm[MAIN_ANIM_DOWSE_ZOOM].setFrame(f);
mpLyt->calc();
mAnm[MAIN_ANIM_DOWSE_IN_OUT].setAnimEnable(true);
mAnm[MAIN_ANIM_DOWSE_ZOOM].setAnimEnable(false);
@@ -335,6 +564,119 @@ void dCsGame_c::lytItemCursor_c::lytDowsingCsr_c::executeState_ToNotFind() {
}
void dCsGame_c::lytItemCursor_c::lytDowsingCsr_c::finalizeState_ToNotFind() {}
+void dCsGame_c::lytItemCursor_c::lytDowsingCsr_c::enter() {
+ mAnm[MAIN_ANIM_CURSOR].setFrame(3.0f);
+ mAnm[MAIN_ANIM_DOWSE_IN_OUT].setFrame(0.0f);
+ mAnm[MAIN_ANIM_DOWSE_IN_OUT].setAnimEnable(true);
+ mAnm[MAIN_ANIM_DOWSE_ZOOM].setAnimEnable(false);
+ mAnm[MAIN_ANIM_LOOP].setAnimEnable(false);
+ mAnm[MAIN_ANIM_DOWSE_LOOP_1].setAnimEnable(false);
+ mAnm[MAIN_ANIM_DOWSE_LOOP_2].setAnimEnable(false);
+ mAnm[MAIN_ANIM_DOWSE_LOOP_3].setAnimEnable(false);
+
+ mpLyt->calc();
+
+ mAnm[MAIN_ANIM_DOWSE_ZOOM].setAnimEnable(false);
+ mAnm[MAIN_ANIM_DOWSE_IN_OUT].setAnimEnable(false);
+ mAnm[MAIN_ANIM_DOWSE_LOOP_1].setAnimEnable(true);
+}
+
+void dCsGame_c::lytItemCursor_c::lytDowsingCsr_c::moveEffectsIn() {
+ if (mAlpha < sHio.field_0x40) {
+ mAlpha++;
+ }
+ updateEffects();
+}
+
+void dCsGame_c::lytItemCursor_c::lytDowsingCsr_c::moveEffectsOut() {
+ if (mAlpha > 0) {
+ mAlpha--;
+ updateEffects();
+ }
+}
+
+void dCsGame_c::lytItemCursor_c::lytDowsingCsr_c::updateEffects() {
+ u8 alpha = (f32)mAlpha / (f32)sHio.field_0x40 * 255.0f;
+ if (alpha != 0) {
+ mVec2_c csPos = dPad::getDpdPosScreen();
+ mVec3_c effectPos(csPos.x, csPos.y, 0.0f);
+ mVec3_c effectScale(sHio.field_0x3C, sHio.field_0x3C, 1.0f);
+ mEffects1.createContinuousUIEffect(
+ PARTICLE_RESOURCE_ID_MAPPING_725_, mVec3_c::Zero, nullptr, nullptr, nullptr, nullptr
+ );
+ mEffects2.createContinuousUIEffect(
+ PARTICLE_RESOURCE_ID_MAPPING_726_, effectPos, &mAng3_c::Zero, &effectScale, nullptr, nullptr
+ );
+ mEffects1.setGlobalAlpha(alpha);
+ mEffects2.setGlobalAlpha(alpha);
+ } else {
+ mEffects1.remove(true);
+ mEffects2.remove(true);
+ }
+}
+
+void dCsGame_c::lytItemCursor_c::lytDowsingCsr_c::init() {
+ mpDowsingPane = mpLyt->findPane("N_dowsing_00");
+ mpRingAllPane = mpLyt->findPane("N_ringAll_00");
+ mEffects1.init(dCsGame_c::GetInstance());
+ mEffects2.init(dCsGame_c::GetInstance());
+ field_0xC0 = 0.0f;
+ enter();
+ mStateMgr.changeState(StateID_NotFind);
+}
+
+void dCsGame_c::lytItemCursor_c::lytDowsingCsr_c::execute() {
+ mAnm[MAIN_ANIM_LOOP].setAnimEnable(false);
+ f32 f2 = (sHio.field_0x18 - sHio.field_0x1C) * 0.95f;
+ if (field_0xD0 > 0.0f) {
+ field_0xD0 -= f2 / sHio.field_0x14;
+ if (field_0xD0 < 0.0f) {
+ field_0xD0 = 0.0f;
+ }
+ } else {
+ field_0xD0 += f2 / sHio.field_0x14;
+ if (field_0xD0 > 0.0f) {
+ field_0xD0 = 0.0f;
+ }
+ }
+
+ f32 scale = sHio.field_0x1C + (sHio.field_0x18 - sHio.field_0x1C) * (field_0xCC + field_0xD0);
+ mpDowsingPane->SetScale(mVec2_c(scale, scale));
+
+ mVec3_c rot = mpRingAllPane->GetRotate();
+ rot.z = -mRotZ.degree2();
+ mpRingAllPane->SetRotate(rot);
+
+ mStateMgr.executeState();
+
+ if (mAnm[MAIN_ANIM_DOWSE_LOOP_1].isEnabled()) {
+ mAnm[MAIN_ANIM_DOWSE_LOOP_1].play();
+ }
+
+ if (mAnm[MAIN_ANIM_DOWSE_LOOP_2].isEnabled()) {
+ if (mAnm[MAIN_ANIM_DOWSE_LOOP_2].getFrame() >= 60.0f) {
+ mAnm[MAIN_ANIM_DOWSE_LOOP_2].setFrame(60.0f);
+ } else {
+ mAnm[MAIN_ANIM_DOWSE_LOOP_2].play();
+ }
+ }
+
+ if (mAnm[MAIN_ANIM_DOWSE_LOOP_3].isEnabled()) {
+ mAnm[MAIN_ANIM_DOWSE_LOOP_3].play();
+ if (mAnm[MAIN_ANIM_DOWSE_LOOP_3].isEndReached()) {
+ mAnm[MAIN_ANIM_DOWSE_LOOP_3].setAnimEnable(false);
+ }
+ }
+
+ const sStateIDIf_c *state = mStateMgr.getStateID();
+
+ if (*state == StateID_NotFind || *state == StateID_ToNotFind) {
+ mAnm[MAIN_ANIM_DOWSE_LOOP_2].setFrame(0.0f);
+ mpLyt->calc();
+ mAnm[MAIN_ANIM_DOWSE_LOOP_2].setAnimEnable(false);
+ }
+}
+
void dCsGame_c::lytItemCursor_c::lytBowCsr_c::initializeState_Invisible() {}
void dCsGame_c::lytItemCursor_c::lytBowCsr_c::executeState_Invisible() {}
void dCsGame_c::lytItemCursor_c::lytBowCsr_c::finalizeState_Invisible() {}
@@ -394,7 +736,8 @@ void dCsGame_c::lytItemCursor_c::lytBowCsr_c::executeState_Draw() {
} else if (t > 0.9999f) {
t = 1.0f;
}
- mAnm[MAIN_ANIM_ARROW_CURSOR].setBackwardsRatio(t);
+ f32 f = mAnm[MAIN_ANIM_ARROW_CURSOR].getLastFrame();
+ mAnm[MAIN_ANIM_ARROW_CURSOR].setFrame(f - (t * f));
if (t <= 0.0f) {
mAnm[MAIN_ANIM_ARROW_CURSOR].setAnimEnable(false);
mStateMgr.changeState(StateID_Charge);
@@ -434,26 +777,25 @@ void dCsGame_c::lytItemCursor_c::lytPachinkoCsr_c::finalizeState_Invisible() {}
void dCsGame_c::lytItemCursor_c::lytPachinkoCsr_c::initializeState_Select() {}
void dCsGame_c::lytItemCursor_c::lytPachinkoCsr_c::executeState_Select() {
- if (!field_0x50) {
- return;
+ if (mIsCharging) {
+ mStateMgr.changeState(StateID_ToDraw);
}
- mStateMgr.changeState(StateID_ToDraw);
}
void dCsGame_c::lytItemCursor_c::lytPachinkoCsr_c::finalizeState_Select() {}
void dCsGame_c::lytItemCursor_c::lytPachinkoCsr_c::initializeState_ToDraw() {
mAnm[MAIN_ANIM_SLING_ON].setAnimEnable(true);
mAnm[MAIN_ANIM_SLING_ON].setFrame(0.0f);
- field_0x58 = 0.0f;
+ mSavedOnProgress = 0.0f;
}
-extern "C" int getCurrentSlingshotType();
+
void dCsGame_c::lytItemCursor_c::lytPachinkoCsr_c::executeState_ToDraw() {
- if (field_0x50) {
+ if (mIsCharging) {
if (mAnm[MAIN_ANIM_SLING_ON].isEndReached()) {
mpLyt->calc();
mAnm[MAIN_ANIM_SLING_ON].setAnimEnable(false);
- if (getCurrentSlingshotType() == 2) {
- field_0x58 = field_0x54;
+ if (dAcPy_c::getCurrentSlingshotType() == 2) {
+ mSavedOnProgress = mDrawProgress;
mStateMgr.changeState(StateID_Charge);
} else {
mStateMgr.changeState(StateID_Draw);
@@ -470,10 +812,9 @@ void dCsGame_c::lytItemCursor_c::lytPachinkoCsr_c::finalizeState_ToDraw() {}
void dCsGame_c::lytItemCursor_c::lytPachinkoCsr_c::initializeState_Draw() {}
void dCsGame_c::lytItemCursor_c::lytPachinkoCsr_c::executeState_Draw() {
- if (field_0x50) {
- return;
+ if (!mIsCharging) {
+ mStateMgr.changeState(StateID_Out);
}
- mStateMgr.changeState(StateID_Out);
}
void dCsGame_c::lytItemCursor_c::lytPachinkoCsr_c::finalizeState_Draw() {}
@@ -498,15 +839,16 @@ void dCsGame_c::lytItemCursor_c::lytPachinkoCsr_c::initializeState_Charge() {
mpLyt->calc();
}
void dCsGame_c::lytItemCursor_c::lytPachinkoCsr_c::executeState_Charge() {
- if (field_0x50) {
- if (field_0x54 >= 1.0f) {
+ if (mIsCharging) {
+ if (mDrawProgress >= 1.0f) {
mAnm[MAIN_ANIM_SLING_KEEP].setToEnd();
mpLyt->calc();
mAnm[MAIN_ANIM_SLING_KEEP].setAnimEnable(false);
mStateMgr.changeState(StateID_ChargeFull);
} else {
- // TODO we need a second load of anm control here
- mAnm[MAIN_ANIM_SLING_KEEP].setRatio((field_0x54 - field_0x58) / (1.0f - field_0x58));
+ f32 frame = ((mDrawProgress - mSavedOnProgress) / (1.0f - mSavedOnProgress));
+ f32 len = mAnm[MAIN_ANIM_SLING_KEEP].getLastFrame();
+ mAnm[MAIN_ANIM_SLING_KEEP].setFrame(len * frame);
}
} else {
mAnm[MAIN_ANIM_SLING_KEEP].setAnimEnable(false);
@@ -522,7 +864,7 @@ void dCsGame_c::lytItemCursor_c::lytPachinkoCsr_c::initializeState_ChargeFull()
mAnm[MAIN_ANIM_SLING_PEAK_RING].setFrame(0.0f);
}
void dCsGame_c::lytItemCursor_c::lytPachinkoCsr_c::executeState_ChargeFull() {
- if (field_0x50) {
+ if (mIsCharging) {
if (mAnm[MAIN_ANIM_SLING_PEAK].isEndReached()) {
mpLyt->calc();
} else if (mAnm[MAIN_ANIM_SLING_PEAK].isEnabled()) {
@@ -536,24 +878,130 @@ void dCsGame_c::lytItemCursor_c::lytPachinkoCsr_c::executeState_ChargeFull() {
}
void dCsGame_c::lytItemCursor_c::lytPachinkoCsr_c::finalizeState_ChargeFull() {}
-void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::initializeState_Normal() {}
-void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::executeState_Normal() {}
+void dCsGame_c::lytItemCursor_c::lytPachinkoCsr_c::init() {
+ mAnm[MAIN_ANIM_SLING_ON].setFrame(0.0f);
+ mAnm[MAIN_ANIM_SLING_ON].setAnimEnable(true);
+ mAnm[MAIN_ANIM_SLING_KEEP].setFrame(0.0f);
+ mAnm[MAIN_ANIM_SLING_KEEP].setAnimEnable(true);
+ mAnm[MAIN_ANIM_SLING_PEAK].setFrame(0.0f);
+ mAnm[MAIN_ANIM_SLING_PEAK].setAnimEnable(true);
+ mAnm[MAIN_ANIM_SLING_OUT].setFrame(0.0f);
+ mAnm[MAIN_ANIM_SLING_OUT].setAnimEnable(true);
+ mpLyt->calc();
+
+ mAnm[MAIN_ANIM_SLING_KEEP].setAnimEnable(false);
+ mAnm[MAIN_ANIM_SLING_PEAK].setAnimEnable(false);
+ mAnm[MAIN_ANIM_SLING_OUT].setAnimEnable(false);
+
+ mIsCharging = false;
+ mDrawProgress = false;
+
+ mStateMgr.changeState(StateID_Select);
+}
+
+void dCsGame_c::lytItemCursor_c::lytPachinkoCsr_c::execute() {
+ mAnm[MAIN_ANIM_CURSOR].setFrame(5.0f);
+ mStateMgr.executeState();
+ if (mAnm[MAIN_ANIM_LOOP].isEnabled()) {
+ // ??? order
+ mpLyt->calc();
+ mAnm[MAIN_ANIM_LOOP].play();
+ }
+
+ if (mAnm[MAIN_ANIM_SLING_PEAK_RING].isEndReached()) {
+ mAnm[MAIN_ANIM_SLING_PEAK_RING].setAnimEnable(false);
+ mpLyt->calc();
+ } else {
+ mAnm[MAIN_ANIM_SLING_PEAK_RING].play();
+ }
+}
+
+void dCsGame_c::lytItemCursor_c::lytPachinkoCsr_c::setCharging(bool charging, f32 progress) {
+ mIsCharging = charging;
+ mDrawProgress = progress;
+}
+
+void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::initializeState_Normal() {
+ mAnm[MAIN_ANIM_LOOP].setAnimEnable(true);
+}
+void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::executeState_Normal() {
+ if (mLocked) {
+ mAnm[MAIN_ANIM_HOOK_FIX].setAnimEnable(true);
+ mAnm[MAIN_ANIM_HOOK_FIX].setForward();
+ mAnm[MAIN_ANIM_HOOK_FIX].setToStart();
+ mAnm[MAIN_ANIM_LOOP].setAnimEnable(false);
+ mStateMgr.changeState(StateID_ToLock);
+ } else {
+ mAnm[MAIN_ANIM_LOOP].play();
+ }
+}
void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::finalizeState_Normal() {}
-void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::initializeState_ToLock() {}
-void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::executeState_ToLock() {}
+void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::setRotate(f32 rot) {
+ mVec3_c v;
+ v.set(0.0f, 0.0f, rot);
+ mpPaneCraws[0]->SetRotate(v);
+ v.z -= 120.0f;
+ mpPaneCraws[1]->SetRotate(v);
+ v.z += 240.0f;
+ mpPaneCraws[2]->SetRotate(v);
+}
+
+void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::initializeState_ToLock() {
+ setRotate(0.0f);
+}
+void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::executeState_ToLock() {
+ if (mAnm[MAIN_ANIM_HOOK_FIX].isEndReached()) {
+ mAnm[MAIN_ANIM_HOOK_FIX].setAnimEnable(false);
+ mpLyt->calc();
+ mAnm[MAIN_ANIM_LOCK_LOOP].setAnimEnable(true);
+ mAnm[MAIN_ANIM_LOCK_LOOP].setFrame(0.0f);
+ mStateMgr.changeState(StateID_Lock);
+ } else {
+ mAnm[MAIN_ANIM_HOOK_FIX].play();
+ }
+}
void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::finalizeState_ToLock() {}
void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::initializeState_Lock() {}
-void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::executeState_Lock() {}
+void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::executeState_Lock() {
+ if (!mLocked) {
+ mAnm[MAIN_ANIM_HOOK_FIX].setAnimEnable(true);
+ mAnm[MAIN_ANIM_HOOK_FIX].setBackward();
+ mAnm[MAIN_ANIM_HOOK_FIX].setToStart();
+ mAnm[MAIN_ANIM_LOCK_LOOP].setAnimEnable(false);
+ field_0x68 = mpPaneCrawFix->GetRotate().z;
+ setRotate(field_0x68);
+ mStateMgr.changeState(StateID_ToNormal);
+ } else {
+ mAnm[MAIN_ANIM_LOCK_LOOP].play();
+ }
+}
void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::finalizeState_Lock() {}
void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::initializeState_ToNormal() {}
-void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::executeState_ToNormal() {}
+void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::executeState_ToNormal() {
+ if (mAnm[MAIN_ANIM_HOOK_FIX].isStop2()) {
+ setRotate(0.0f);
+ mpLyt->calc();
+ mAnm[MAIN_ANIM_HOOK_FIX].setAnimEnable(false);
+ mStateMgr.changeState(StateID_Normal);
+ } else {
+ mAnm[MAIN_ANIM_HOOK_FIX].play();
+ f32 frame = mAnm[MAIN_ANIM_HOOK_FIX].getFrame();
+ f32 len = mAnm[MAIN_ANIM_HOOK_FIX].getLastFrame();
+ f32 offset = (-120.0f - field_0x68);
+ offset /= len;
+ if (offset < -10.0f) {
+ offset = -10.0f;
+ }
+ setRotate(field_0x68 + offset * (len - frame));
+ }
+}
void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::finalizeState_ToNormal() {}
void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::enter() {
- mAnm[MAIN_ANIM_CURSOR].setFrame(4.0f);
+ mAnm[MAIN_ANIM_CURSOR].setFrame(6.0f);
mAnm[MAIN_ANIM_HOOK_FIX].setAnimEnable(true);
mAnm[MAIN_ANIM_HOOK_FIX].setFrame(0.0f);
mAnm[MAIN_ANIM_LOCK_LOOP].setAnimEnable(false);
@@ -563,7 +1011,16 @@ void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::enter() {
mStateMgr.changeState(StateID_Normal);
}
+void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::setLocked(bool locked) {
+ mLocked = locked;
+}
+
void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::init() {
+ mpPaneCrawFix = mpLyt->findPane("N_crawFix_00");
+ mpPaneCraws[0] = mpLyt->findPane("N_craw_03");
+ mpPaneCraws[1] = mpLyt->findPane("N_craw_04");
+ mpPaneCraws[2] = mpLyt->findPane("N_craw_05");
+ mLocked = false;
enter();
mStateMgr.changeState(StateID_Normal);
}
@@ -572,12 +1029,11 @@ void dCsGame_c::lytItemCursor_c::lytCrawShotCsr_c::execute() {
mStateMgr.executeState();
}
-
void dCsGame_c::lytItemCursor_c::lytVacuumCsr_c::initializeState_Normal() {
mAnm[MAIN_ANIM_LOOP].setAnimEnable(true);
}
void dCsGame_c::lytItemCursor_c::lytVacuumCsr_c::executeState_Normal() {
- if (field_0x5C) {
+ if (mLocked) {
mAnm[MAIN_ANIM_VACUUM_LOCK].setAnimEnable(true);
mAnm[MAIN_ANIM_VACUUM_LOCK].setForward();
mAnm[MAIN_ANIM_VACUUM_LOCK].setToStart();
@@ -605,7 +1061,7 @@ void dCsGame_c::lytItemCursor_c::lytVacuumCsr_c::finalizeState_ToLock() {}
void dCsGame_c::lytItemCursor_c::lytVacuumCsr_c::initializeState_Lock() {}
void dCsGame_c::lytItemCursor_c::lytVacuumCsr_c::executeState_Lock() {
- if (!field_0x5C) {
+ if (!mLocked) {
mAnm[MAIN_ANIM_VACUUM_LOCK].setAnimEnable(true);
mAnm[MAIN_ANIM_VACUUM_LOCK].setBackward();
mAnm[MAIN_ANIM_VACUUM_LOCK].setToStart();
@@ -629,6 +1085,19 @@ void dCsGame_c::lytItemCursor_c::lytVacuumCsr_c::executeState_ToNormal() {
}
void dCsGame_c::lytItemCursor_c::lytVacuumCsr_c::finalizeState_ToNormal() {}
+void dCsGame_c::lytItemCursor_c::lytVacuumCsr_c::setUnkFloat(f32 f) {
+ if (f < 0.0f) {
+ f = 0.0f;
+ } else if (f > 100.0f) {
+ f = 100.0f;
+ }
+ field_0x54 = f;
+}
+
+void dCsGame_c::lytItemCursor_c::lytVacuumCsr_c::setLocked(bool locked) {
+ mLocked = locked;
+}
+
void dCsGame_c::lytItemCursor_c::lytVacuumCsr_c::enter() {
mAnm[MAIN_ANIM_CURSOR].setFrame(4.0f);
mAnm[MAIN_ANIM_LOCK_LOOP].setAnimEnable(false);
@@ -641,7 +1110,7 @@ void dCsGame_c::lytItemCursor_c::lytVacuumCsr_c::enter() {
}
void dCsGame_c::lytItemCursor_c::lytVacuumCsr_c::init() {
- field_0x5C = 0;
+ mLocked = false;
enter();
mStateMgr.changeState(StateID_Normal);
}
diff --git a/src/d/d_cursor_hit_check.cpp b/src/d/d_cursor_hit_check.cpp
index 61fe1108..013d14cb 100644
--- a/src/d/d_cursor_hit_check.cpp
+++ b/src/d/d_cursor_hit_check.cpp
@@ -39,7 +39,7 @@ void dCsMgr_c::execute() {
u32 mask = it->mCursorMask;
if (mask) {
- for (HitCheckList::Iterator chkIt = mList2.GetBeginIter(); chkIt != mList2.GetEndIter(); ++it) {
+ for (HitCheckList::Iterator chkIt = mList2.GetBeginIter(); chkIt != mList2.GetEndIter(); ++chkIt) {
if ((chkIt->mMask & mask) != 0) {
bool hit = chkIt->checkHit(x, y);
if (chkIt->checkOverrideCallback(hit)) {