From df17fa201a9ff8fcc46c3de9fc5fccfef3975f97 Mon Sep 17 00:00:00 2001 From: robojumper Date: Fri, 16 May 2025 01:21:45 +0200 Subject: [PATCH] dLytDoButton_c OK --- config/SOUE01/splits.txt | 1 + config/SOUE01/symbols.txt | 4 +- configure.py | 2 +- include/d/a/d_a_player.h | 2 + include/d/lyt/d2d.h | 4 + include/d/lyt/d_lyt_do_button.h | 69 +++- include/d/lyt/d_lyt_unknowns.h | 1 + include/m/m2d.h | 4 + src/d/lyt/d_lyt_do_button.cpp | 428 ++++++++++++++++++-- src/d/lyt/meter/d_lyt_meter.cpp | 16 +- src/d/lyt/meter/d_lyt_meter_item_select.cpp | 11 +- 11 files changed, 497 insertions(+), 45 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 92b31f9d..960e6c5c 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -693,6 +693,7 @@ d/lyt/d_lyt_do_button.cpp: .data start:0x8051A5A8 end:0x8051AC00 .sdata start:0x80572520 end:0x80572530 .sbss start:0x80575468 end:0x80575470 + .sdata2 start:0x80579D70 end:0x80579D98 .bss start:0x805ACE10 end:0x805ACF78 d/lyt/d_lyt_do_button_related.cpp: diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 130810cc..4caef926 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -2656,7 +2656,7 @@ fn_8005E090 = .text:0x8005E090; // type:function size:0x64 ActorLink__initSwordModels = .text:0x8005E100; // type:function size:0x1F0 ActorLink__updateSword = .text:0x8005E2F0; // type:function size:0xA8 getCurrentShieldPouchSlot = .text:0x8005E3A0; // type:function size:0x50 -checkBambooCuttingMinigameState = .text:0x8005E3F0; // type:function size:0x8 +isInBambooCuttingMinigame__7dAcPy_cFv = .text:0x8005E3F0; // type:function size:0x8 getCurrentlyEquippedShieldId = .text:0x8005E400; // type:function size:0x4C getShieldSubtype = .text:0x8005E450; // type:function size:0x3C ActorLink__initShieldModels = .text:0x8005E490; // type:function size:0x2C0 @@ -6531,7 +6531,7 @@ remove__14dLytDobutton_cFv = .text:0x8010D670; // type:function size:0x50 execute__14dLytDobutton_cFv = .text:0x8010D6C0; // type:function size:0x80C draw__14dLytDobutton_cFv = .text:0x8010DED0; // type:function size:0x28 realize__14dLytDobutton_cFv = .text:0x8010DF00; // type:function size:0x4CC -fn_8010E3D0 = .text:0x8010E3D0; // type:function size:0x1F0 +fn_8010E3D0__14dLytDobutton_cFb = .text:0x8010E3D0; // type:function size:0x1F0 setActionTextStuffInternal__14dLytDobutton_cFllb = .text:0x8010E5C0; // type:function size:0x10 getActionInternal__14dLytDobutton_cCFv = .text:0x8010E5D0; // type:function size:0x8 fn_8010E5E0__14dLytDobutton_cCFv = .text:0x8010E5E0; // type:function size:0x1C diff --git a/configure.py b/configure.py index a52f71aa..0fe1b801 100644 --- a/configure.py +++ b/configure.py @@ -490,7 +490,7 @@ config.libs = [ Object(Matching, "d/lyt/meter/d_lyt_meter_timer.cpp"), Object(Matching, "d/lyt/meter/d_lyt_meter_heart.cpp"), Object(Matching, "d/lyt/meter/d_lyt_meter_shield_gauge.cpp"), - Object(NonMatching, "d/lyt/d_lyt_do_button.cpp"), + Object(Matching, "d/lyt/d_lyt_do_button.cpp"), Object(NonMatching, "d/lyt/d_lyt_do_button_related.cpp"), Object(Matching, "d/lyt/d_lyt_common_a_btn.cpp"), Object(Matching, "d/lyt/d_lyt_common_icon_material.cpp"), diff --git a/include/d/a/d_a_player.h b/include/d/a/d_a_player.h index ed043bff..522b09fd 100644 --- a/include/d/a/d_a_player.h +++ b/include/d/a/d_a_player.h @@ -340,6 +340,8 @@ public: static s32 getCurrentBugNetType(); static s32 getCurrentlyEquippedShieldType(); + static bool isInBambooCuttingMinigame(); + static bool isItemRestrictedByBokoBase(ITEM_ID item); static u32 getCurrentHealthCapacity(); diff --git a/include/d/lyt/d2d.h b/include/d/lyt/d2d.h index c4e3e533..fc19bfb9 100644 --- a/include/d/lyt/d2d.h +++ b/include/d/lyt/d2d.h @@ -230,6 +230,10 @@ struct AnmGroupBase_c { mpFrameCtrl->setRate(rate); } + inline f32 getRate() const { + return mpFrameCtrl->getRate(); + } + inline bool isEnabled() const { return (mFlags & ANMGROUP_FLAG_ENABLE) != 0; } diff --git a/include/d/lyt/d_lyt_do_button.h b/include/d/lyt/d_lyt_do_button.h index efe6d25e..5893f817 100644 --- a/include/d/lyt/d_lyt_do_button.h +++ b/include/d/lyt/d_lyt_do_button.h @@ -9,6 +9,58 @@ class dLytDobutton_c { public: + // TODO: figure out that these mean. The two pane arrays in d_lyt_do_button.cpp might help + enum Icon_e { + ICON_0 = 0, + ICON_1 = 1, + ICON_2 = 2, + ICON_3 = 3, + ICON_4 = 4, + ICON_5 = 5, + ICON_6 = 6, + ICON_7 = 7, + ICON_8 = 8, + ICON_9 = 9, + ICON_10 = 10, + ICON_11 = 11, + ICON_12 = 12, + ICON_13 = 13, + ICON_14 = 14, + ICON_15 = 15, + ICON_16 = 16, + ICON_17 = 17, + ICON_18 = 18, + ICON_19 = 19, + ICON_20 = 20, + ICON_21 = 21, + ICON_22 = 22, + ICON_23 = 23, + ICON_24 = 24, + ICON_25 = 25, + ICON_26 = 26, + ICON_27 = 27, + ICON_28 = 28, + ICON_29 = 29, + ICON_30 = 30, + ICON_31 = 31, + ICON_32 = 32, + ICON_33 = 33, + ICON_34 = 34, + ICON_35 = 35, + ICON_36 = 36, + ICON_37 = 37, + ICON_38 = 38, + ICON_39 = 39, + ICON_40 = 40, + + ICON_NONE = 41, + }; + + // 001-Action.msbt - Enum for ACT_DO + // This is actually just the first part of ACT_INFO, but + // LytDoButtonRelated has a full conversion table + // from Act_IE_e -> Act_Do_e + enum Act_Do_e { ACT_DO_CLIMB_UP = 0, ACT_DO_JUMP = 1, @@ -104,6 +156,7 @@ public: ACT_DO_LEAN = 91, ACT_DO_PRESS = 92, + // why two of them? ACT_DO_NONE = 93, ACT_DO_INVALID = 94, }; @@ -136,7 +189,7 @@ public: if (sInstance != nullptr) { return sInstance->field_0x480; } else { - return 0x29; + return ICON_NONE; } } @@ -144,7 +197,8 @@ public: if (sInstance != nullptr) { return sInstance->mNextDoActionToShow; } else { - return 0x29; + // @bug (?) should this be ACT_DO_INVALID? + return ICON_NONE; } } @@ -152,7 +206,7 @@ public: if (sInstance != nullptr) { return sInstance->fn_8010E5E0(); } else { - return 0x29; + return ICON_NONE; } } @@ -177,6 +231,11 @@ private: void fn_8010E3D0(bool); void realize(); + void set_0x47C_0x480(s32 v1, s32 v2) { + field_0x47C = v1; + field_0x480 = v2; + } + static dLytDobutton_c *sInstance; STATE_FUNC_DECLARE(dLytDobutton_c, InvisibleWait); @@ -187,7 +246,7 @@ private: STATE_MGR_DEFINE_UTIL_CHANGESTATE(dLytDobutton_c); - UI_STATE_MGR_DECLARE(dLytDobutton_c); + /* 0x000 */ UI_STATE_MGR_DECLARE(dLytDobutton_c); /* 0x040 */ d2d::dLytSub mLyt; /* 0x0D4 */ d2d::AnmGroup_c mAnmGroups[12]; /* 0x3D4 */ nw4r::lyt::Pane *mpPanes[37]; @@ -202,7 +261,7 @@ private: /* 0x48C */ s32 field_0x48C; /* 0x490 */ u8 field_0x490; /* 0x491 */ u8 field_0x491; - /* 0x492 */ u8 field_0x492; + /* 0x492 */ bool mSavedIsInEvent; }; #endif diff --git a/include/d/lyt/d_lyt_unknowns.h b/include/d/lyt/d_lyt_unknowns.h index 36022564..0d885967 100644 --- a/include/d/lyt/d_lyt_unknowns.h +++ b/include/d/lyt/d_lyt_unknowns.h @@ -17,6 +17,7 @@ public: return sInstance; } + // 001-Action.msbt - Unified enum for ACT_INFO and ACT_ETC enum Act_IE_e { ACT_IE_INFO_CLIMB_UP = 0, ACT_IE_INFO_JUMP = 1, diff --git a/include/m/m2d.h b/include/m/m2d.h index c39ceec4..aad5f08d 100644 --- a/include/m/m2d.h +++ b/include/m/m2d.h @@ -61,6 +61,10 @@ public: return mCurrFrame; } + inline f32 getRate() const { + return mRate; + } + inline void setCurrFrame(f32 arg) { mCurrFrame = arg; } diff --git a/src/d/lyt/d_lyt_do_button.cpp b/src/d/lyt/d_lyt_do_button.cpp index c71d47d6..26122bb4 100644 --- a/src/d/lyt/d_lyt_do_button.cpp +++ b/src/d/lyt/d_lyt_do_button.cpp @@ -1,7 +1,13 @@ #include "d/lyt/d_lyt_do_button.h" #include "common.h" +#include "d/a/d_a_player.h" +#include "d/lyt/meter/d_lyt_meter.h" +#include "nw4r/lyt/lyt_pane.h" +#include "nw4r/lyt/lyt_types.h" +#include "nw4r/math/math_types.h" #include "sized_string.h" +#include "toBeSorted/event_manager.h" #include "toBeSorted/small_sound_mgr.h" struct DoButtonClass { @@ -36,6 +42,8 @@ DoButtonClass::DoButtonClass() { } DoButtonClass::~DoButtonClass() {} +dLytDobutton_c *dLytDobutton_c::sInstance; + STATE_DEFINE(dLytDobutton_c, InvisibleWait); STATE_DEFINE(dLytDobutton_c, InvisibleTimeCnt); STATE_DEFINE(dLytDobutton_c, In); @@ -43,7 +51,7 @@ STATE_DEFINE(dLytDobutton_c, Wait); STATE_DEFINE(dLytDobutton_c, Out); #define DO_BUTTON_ANIM_IN 0 -#define DO_BUTTON_ANIM 1 +#define DO_BUTTON_ANIM_BASIC_INFO 1 #define DO_BUTTON_ANIM_LOOP_BTN 2 #define DO_BUTTON_ANIM_LOOP_BTN_Z 3 #define DO_BUTTON_ANIM_LOOP_NUN 4 @@ -55,7 +63,7 @@ STATE_DEFINE(dLytDobutton_c, Out); #define DO_BUTTON_ANIM_MOVE_OUT 10 #define DO_BUTTON_ANIM_LOOP_BG 11 -#define DO_BUTTON_NUM_ANIM 12 +#define DO_BUTTON_NUM_ANIMS 12 static const d2d::LytBrlanMapping brlanMap[] = { { "basicInfo_00_in.brlan", "G_inOut_00"}, @@ -81,6 +89,45 @@ static const char *sPaneNames[] = { "N_upSwing_01", "N_aBtnDown_02", }; +#define DO_BUTTON_PANE_INFOALL_00 0 +#define DO_BUTTON_PANE_INFOALL_01 1 +#define DO_BUTTON_PANE_BG_00 2 +#define DO_BUTTON_PANE_W_BGP_00 3 +#define DO_BUTTON_PANE_W_BGP_01 4 +#define DO_BUTTON_PANE_INFOTEXT_00 5 +#define DO_BUTTON_PANE_A_BTN_00 6 +#define DO_BUTTON_PANE_A_BTN_01 7 +#define DO_BUTTON_PANE_B_BTN_00 8 +#define DO_BUTTON_PANE_C_BTN_00 9 +#define DO_BUTTON_PANE_C_BTN_01 10 +#define DO_BUTTON_PANE_NUNCHAKU_01 11 +#define DO_BUTTON_PANE_NUNCHAKU_02 12 +#define DO_BUTTON_PANE_NUNCHAKU_03 13 +#define DO_BUTTON_PANE_UP_SWING_00 14 +#define DO_BUTTON_PANE_DOWN_SWING_00 15 +#define DO_BUTTON_PANE_SWING_00 16 +#define DO_BUTTON_PANE_ROTATE_00 17 +#define DO_BUTTON_PANE_NUN_RIMO_00 18 +#define DO_BUTTON_PANE_NUN_DRAG_00 19 +#define DO_BUTTON_PANE_A_BTN_DOWN_00 20 +#define DO_BUTTON_PANE_A_BTN_DOWN_01 21 +#define DO_BUTTON_PANE_DRAW_00 22 +#define DO_BUTTON_PANE_PLAY_00 23 +#define DO_BUTTON_PANE_SWING_01 24 +#define DO_BUTTON_PANE_SWING_03 25 +#define DO_BUTTON_PANE_UPSET_00 26 +#define DO_BUTTON_PANE_STAB_00 27 +#define DO_BUTTON_PANE_PULL_OUT_01 28 +#define DO_BUTTON_PANE_B_BTN_01 29 +#define DO_BUTTON_PANE_TWIST_00 30 +#define DO_BUTTON_PANE_ZBTN_00 31 +#define DO_BUTTON_PANE_ZBTN_01 32 +#define DO_BUTTON_PANE_CROSS_BTN_00 33 +#define DO_BUTTON_PANE_PLUS_ALL_00 34 +#define DO_BUTTON_PANE_UP_SWING_01 35 +#define DO_BUTTON_PANE_A_BTN_DOWN_02 36 + +#define DO_BUTTON_PANE_NONE 37 #define DO_BUTTON_NUM_PANES 37 static const char *sTextBoxNames[] = { @@ -99,11 +146,11 @@ void dLytDobutton_c::executeState_InvisibleWait() { field_0x478 = field_0x474; field_0x474 = field_0x488; mDoActionToShow = mNextDoActionToShow; - if (field_0x488 == 0x29) { + if (field_0x488 == ICON_NONE) { return; } - if (mNextDoActionToShow == 0x5E) { + if (mNextDoActionToShow == ACT_DO_INVALID) { return; } mStateMgr.changeState(StateID_InvisibleTimeCnt); @@ -114,14 +161,12 @@ void dLytDobutton_c::initializeState_InvisibleTimeCnt() { field_0x48C = 0; } -extern "C" void fn_8010DF00(dLytDobutton_c *); - void dLytDobutton_c::executeState_InvisibleTimeCnt() { if (field_0x488 != field_0x474 || mNextDoActionToShow != mDoActionToShow) { field_0x478 = field_0x474; field_0x474 = field_0x488; mDoActionToShow = mNextDoActionToShow; - if (field_0x488 == 0x29 || mNextDoActionToShow == 0x5E) { + if (field_0x488 == ICON_NONE || mNextDoActionToShow == ACT_DO_INVALID) { mStateMgr.changeState(StateID_InvisibleWait); } else { field_0x48C = 0; @@ -130,7 +175,7 @@ void dLytDobutton_c::executeState_InvisibleTimeCnt() { if (field_0x48C < sDoButtonClass.field_0x15) { field_0x48C++; } else { - fn_8010DF00(this); + realize(); mStateMgr.changeState(StateID_In); } } @@ -147,7 +192,7 @@ void dLytDobutton_c::initializeState_In() { mAnmGroups[DO_BUTTON_ANIM_IN].setFrame(0.0f); } void dLytDobutton_c::executeState_In() { - if (field_0x488 == 0x29 || mNextDoActionToShow == 0x5E) { + if (field_0x488 == ICON_NONE || mNextDoActionToShow == ACT_DO_INVALID) { mAnmGroups[DO_BUTTON_ANIM_IN].setFrame(0.0f); mAnmGroups[DO_BUTTON_ANIM_MOVE_OUT].setAnimEnable(true); mAnmGroups[DO_BUTTON_ANIM_MOVE_OUT].setToEnd(); @@ -168,11 +213,11 @@ void dLytDobutton_c::executeState_Wait() { field_0x478 = field_0x474; field_0x474 = field_0x488; mDoActionToShow = mNextDoActionToShow; - if (field_0x488 == 0x29 || mNextDoActionToShow == 0x5E) { + if (field_0x488 == ICON_NONE || mNextDoActionToShow == ACT_DO_INVALID) { mStateMgr.changeState(StateID_Out); field_0x48C = 0; } else { - fn_8010DF00(this); + realize(); } } } @@ -191,7 +236,7 @@ void dLytDobutton_c::executeState_Out() { if (mAnmGroups[DO_BUTTON_ANIM_MOVE_OUT].isEndReached()) { mLyt.calc(); mAnmGroups[DO_BUTTON_ANIM_MOVE_OUT].setAnimEnable(false); - mStateMgr.changeState(StateID_InvisibleTimeCnt); + mStateMgr.changeState(StateID_InvisibleWait); } } void dLytDobutton_c::finalizeState_Out() {} @@ -201,7 +246,7 @@ bool dLytDobutton_c::build(m2d::ResAccIf_c *resAcc) { mLyt.build("basicInfo_00.brlyt", nullptr); mLyt.setPriority(0x8A); - for (int i = 0; i < DO_BUTTON_NUM_ANIM; i++) { + for (int i = 0; i < DO_BUTTON_NUM_ANIMS; i++) { mAnmGroups[i].init(brlanMap[i].mFile, resAcc, mLyt.getLayout(), brlanMap[i].mName); mAnmGroups[i].bind(false); mAnmGroups[i].setAnimEnable(false); @@ -215,16 +260,16 @@ bool dLytDobutton_c::build(m2d::ResAccIf_c *resAcc) { mpTextBoxes[i] = mLyt.getTextBox(sTextBoxNames[i]); } - mDoActionToShow = 0x5E; - field_0x474 = 0x29; - field_0x478 = 0x29; - mNextDoActionToShow = 0x5E; - field_0x488 = 0x29; + mDoActionToShow = ACT_DO_INVALID; + field_0x474 = ICON_NONE; + field_0x478 = ICON_NONE; + mNextDoActionToShow = ACT_DO_INVALID; + field_0x488 = ICON_NONE; field_0x490 = 0; - field_0x47C = 0x5E; - field_0x480 = 0x29; + field_0x47C = ACT_DO_INVALID; + field_0x480 = ICON_NONE; field_0x491 = 0; - field_0x492 = 0; + mSavedIsInEvent = false; mAnmGroups[DO_BUTTON_ANIM_LOOP_NUN].setAnimEnable(true); mAnmGroups[DO_BUTTON_ANIM_LOOP_BG].setAnimEnable(true); @@ -240,12 +285,189 @@ bool dLytDobutton_c::build(m2d::ResAccIf_c *resAcc) { } bool dLytDobutton_c::remove() { - for (int i = 0; i < DO_BUTTON_NUM_ANIM; i++) { + for (int i = 0; i < DO_BUTTON_NUM_ANIMS; i++) { mAnmGroups[i].remove(); } return true; } +bool dLytDobutton_c::execute() { + bool isInEvent = EventManager::isInEvent(); + bool b1 = true; + if (dAcPy_c::isInBambooCuttingMinigame()) { + setActionTextStuff(ICON_12, ACT_DO_70, false); + } + if (field_0x490 == 0) { + if (isInEvent != mSavedIsInEvent) { + if (isInEvent && field_0x488 == field_0x480 && mNextDoActionToShow == field_0x47C) { + setActionTextStuff(ICON_NONE, ACT_DO_INVALID, false); + b1 = false; + } + mSavedIsInEvent = isInEvent; + } else if (isInEvent && field_0x490 == 0 && field_0x488 == field_0x480 && mNextDoActionToShow == field_0x47C) { + setActionTextStuff(ICON_NONE, ACT_DO_INVALID, false); + b1 = false; + } + } + + if (b1) { + set_0x47C_0x480(mNextDoActionToShow, field_0x488); + } + + if ((isInEvent && !field_0x490) || dLytMeter_c::getItemSelect0x75A2() != 0 || + dLytMeter_c::getMinusBtnFn800F7600()) { + setActionTextStuffInternal(41, ACT_DO_INVALID, false); + } + + for (int i = 0; i < DO_BUTTON_NUM_ANIMS; i++) { + if (i != DO_BUTTON_ANIM_BASIC_INFO && i != DO_BUTTON_ANIM_LOOP_MOVE_INFO && i != DO_BUTTON_ANIM_MOVE_ALPHA) { + if (mAnmGroups[i].isEnabled()) { + mAnmGroups[i].play(); + } + } + } + + if (mAnmGroups[DO_BUTTON_ANIM_LOOP_MOVE_INFO].isEnabled() || mAnmGroups[DO_BUTTON_ANIM_MOVE_ALPHA].isEnabled()) { + bool b2 = false; + if (mAnmGroups[DO_BUTTON_ANIM_LOOP_MOVE_INFO].isStop2()) { + if (((field_0x478 == 26 && field_0x474 == 11) || (field_0x478 == 27 && field_0x474 == 11) || + (field_0x478 == 28 && field_0x474 == 11) || (field_0x478 == 29 && field_0x474 == 11) || + (field_0x478 == 30 && field_0x474 == 8) || (field_0x478 == 31 && field_0x474 == 11) || + (field_0x478 == 32 && field_0x474 == 36) || (field_0x478 == 33 && field_0x474 == 11) || + (field_0x478 == 34 && field_0x474 == 11) || (field_0x478 == 35 && field_0x474 == 11)) && + mAnmGroups[DO_BUTTON_ANIM_LOOP_MOVE_INFO].getFrame() == 0.0f) { + mAnmGroups[DO_BUTTON_ANIM_BASIC_INFO].setAnimEnable(true); + mAnmGroups[DO_BUTTON_ANIM_BASIC_INFO].setFrame(field_0x474); + } + mAnmGroups[DO_BUTTON_ANIM_LOOP_MOVE_INFO].setAnimEnable(false); + } else { + mAnmGroups[DO_BUTTON_ANIM_LOOP_MOVE_INFO].play(); + b2 = true; + } + if (mAnmGroups[DO_BUTTON_ANIM_MOVE_ALPHA].isStop2()) { + mAnmGroups[DO_BUTTON_ANIM_MOVE_ALPHA].setAnimEnable(false); + } else { + mAnmGroups[DO_BUTTON_ANIM_MOVE_ALPHA].play(); + b2 = true; + } + + if (b2) { + mLyt.calc(); + } + fn_8010E3D0(mDoActionToShow != ACT_DO_NONE); + } + + mStateMgr.executeState(); + + if (((field_0x474 == 1 && mDoActionToShow == ACT_DO_27) || + (field_0x474 == 1 && mDoActionToShow == ACT_DO_BREAK_FREE)) && + field_0x491) { + if (!mAnmGroups[DO_BUTTON_ANIM_LOOP_RECOVER].isEnabled()) { + mAnmGroups[DO_BUTTON_ANIM_LOOP_RECOVER].setFrame(0.0f); + mAnmGroups[DO_BUTTON_ANIM_LOOP_RECOVER].setRate(3.0f); + mAnmGroups[DO_BUTTON_ANIM_LOOP_RECOVER].setAnimEnable(true); + } + if (mAnmGroups[DO_BUTTON_ANIM_LOOP_REMO_CON].isEnabled()) { + mAnmGroups[DO_BUTTON_ANIM_LOOP_REMO_CON].setRate(1.0f); + mAnmGroups[DO_BUTTON_ANIM_LOOP_REMO_CON].setAnimEnable(false); + } + if (mAnmGroups[DO_BUTTON_ANIM_LOOP_ROTATE].isEnabled()) { + mAnmGroups[DO_BUTTON_ANIM_LOOP_ROTATE].setRate(1.0f); + mAnmGroups[DO_BUTTON_ANIM_LOOP_ROTATE].setAnimEnable(false); + } + } else if ((field_0x474 == 6 && field_0x491) || (field_0x478 == 6 && *mStateMgr.getStateID() == StateID_Out)) { + // Same code as above, copypasted + if (!mAnmGroups[DO_BUTTON_ANIM_LOOP_RECOVER].isEnabled()) { + mAnmGroups[DO_BUTTON_ANIM_LOOP_RECOVER].setFrame(0.0f); + mAnmGroups[DO_BUTTON_ANIM_LOOP_RECOVER].setRate(3.0f); + mAnmGroups[DO_BUTTON_ANIM_LOOP_RECOVER].setAnimEnable(true); + } + if (mAnmGroups[DO_BUTTON_ANIM_LOOP_REMO_CON].isEnabled()) { + mAnmGroups[DO_BUTTON_ANIM_LOOP_REMO_CON].setRate(1.0f); + mAnmGroups[DO_BUTTON_ANIM_LOOP_REMO_CON].setAnimEnable(false); + } + if (mAnmGroups[DO_BUTTON_ANIM_LOOP_ROTATE].isEnabled()) { + mAnmGroups[DO_BUTTON_ANIM_LOOP_ROTATE].setRate(1.0f); + mAnmGroups[DO_BUTTON_ANIM_LOOP_ROTATE].setAnimEnable(false); + } + } else { + if (mAnmGroups[DO_BUTTON_ANIM_LOOP_RECOVER].isEnabled()) { + mAnmGroups[DO_BUTTON_ANIM_LOOP_RECOVER].setRate(1.0f); + mAnmGroups[DO_BUTTON_ANIM_LOOP_RECOVER].setAnimEnable(false); + } + + if (field_0x474 == 4 || field_0x474 == 28 || field_0x474 == 29) { + if (mAnmGroups[DO_BUTTON_ANIM_LOOP_REMO_CON].isEnabled()) { + mAnmGroups[DO_BUTTON_ANIM_LOOP_REMO_CON].setRate(1.0f); + mAnmGroups[DO_BUTTON_ANIM_LOOP_REMO_CON].setAnimEnable(false); + } + if (!mAnmGroups[DO_BUTTON_ANIM_LOOP_ROTATE].isEnabled()) { + mAnmGroups[DO_BUTTON_ANIM_LOOP_ROTATE].setFrame(0.0f); + mAnmGroups[DO_BUTTON_ANIM_LOOP_ROTATE].setRate(1.0f); + mAnmGroups[DO_BUTTON_ANIM_LOOP_ROTATE].setAnimEnable(true); + } + } else if (field_0x474 == 12 && mDoActionToShow == ACT_DO_70) { + if (!mAnmGroups[DO_BUTTON_ANIM_LOOP_REMO_CON].isEnabled()) { + mAnmGroups[DO_BUTTON_ANIM_LOOP_REMO_CON].setFrame(0.0f); + mAnmGroups[DO_BUTTON_ANIM_LOOP_REMO_CON].setAnimEnable(true); + } + + if (mAnmGroups[DO_BUTTON_ANIM_LOOP_REMO_CON].getRate() != 2.0f) { + mAnmGroups[DO_BUTTON_ANIM_LOOP_REMO_CON].setRate(2.0f); + } + + if (mAnmGroups[DO_BUTTON_ANIM_LOOP_ROTATE].isEnabled()) { + mAnmGroups[DO_BUTTON_ANIM_LOOP_ROTATE].setRate(1.0f); + mAnmGroups[DO_BUTTON_ANIM_LOOP_ROTATE].setAnimEnable(false); + } + } else { + if (!mAnmGroups[DO_BUTTON_ANIM_LOOP_REMO_CON].isEnabled()) { + mAnmGroups[DO_BUTTON_ANIM_LOOP_REMO_CON].setFrame(0.0f); + mAnmGroups[DO_BUTTON_ANIM_LOOP_REMO_CON].setAnimEnable(true); + } + if (mAnmGroups[DO_BUTTON_ANIM_LOOP_REMO_CON].getRate() != 1.0f) { + mAnmGroups[DO_BUTTON_ANIM_LOOP_REMO_CON].setRate(1.0f); + } + if (mAnmGroups[DO_BUTTON_ANIM_LOOP_ROTATE].isEnabled()) { + mAnmGroups[DO_BUTTON_ANIM_LOOP_ROTATE].setRate(1.0f); + mAnmGroups[DO_BUTTON_ANIM_LOOP_ROTATE].setAnimEnable(false); + } + } + } + + mLyt.calc(); + + if (field_0x474 >= 26 && field_0x474 < 36) { + if (!mAnmGroups[DO_BUTTON_ANIM_LOOP_MOVE_INFO].isEnabled()) { + if (mAnmGroups[DO_BUTTON_ANIM_LOOP_BTN].isEnabled()) { + if (mAnmGroups[DO_BUTTON_ANIM_LOOP_BTN].getFrame() == 0.0f) { + mAnmGroups[DO_BUTTON_ANIM_LOOP_BTN].setAnimEnable(false); + } + } + if (mAnmGroups[DO_BUTTON_ANIM_LOOP_BTN_Z].isEnabled()) { + if (mAnmGroups[DO_BUTTON_ANIM_LOOP_BTN_Z].getFrame() == 0.0f) { + mAnmGroups[DO_BUTTON_ANIM_LOOP_BTN_Z].setAnimEnable(false); + } + } + } + } else { + if (!mAnmGroups[DO_BUTTON_ANIM_LOOP_BTN].isEnabled()) { + mAnmGroups[DO_BUTTON_ANIM_LOOP_BTN].setAnimEnable(true); + } + + if (!mAnmGroups[DO_BUTTON_ANIM_LOOP_BTN_Z].isEnabled()) { + mAnmGroups[DO_BUTTON_ANIM_LOOP_BTN_Z].setAnimEnable(true); + } + } + + if (mAnmGroups[DO_BUTTON_ANIM_BASIC_INFO].isEnabled()) { + mAnmGroups[DO_BUTTON_ANIM_BASIC_INFO].setAnimEnable(false); + } + + setActionTextStuffInternal(41, ACT_DO_INVALID, false); + return true; +} + bool dLytDobutton_c::draw() { mLyt.addToDrawList(); return true; @@ -345,6 +567,7 @@ static const s32 sActDoIds[] = { 91, // ACT_DO_CHARGE 92, // ACT_DO_LEAN 93, // ACT_DO_PRESS + -1, }; void dLytDobutton_c::realize() { @@ -399,8 +622,8 @@ void dLytDobutton_c::realize() { mAnmGroups[DO_BUTTON_ANIM_MOVE_ALPHA].setToEnd2(); } - mAnmGroups[DO_BUTTON_ANIM].setAnimEnable(true); - mAnmGroups[DO_BUTTON_ANIM].setFrame(i2); + mAnmGroups[DO_BUTTON_ANIM_BASIC_INFO].setAnimEnable(true); + mAnmGroups[DO_BUTTON_ANIM_BASIC_INFO].setFrame(i2); if (mDoActionToShow != ACT_DO_NONE) { SizedString<16> buf; buf.sprintf("ACT_DO_%03d", sActDoIds[mDoActionToShow]); @@ -420,6 +643,163 @@ void dLytDobutton_c::realize() { } } +static const s32 sPaneIdxes1[] = { + DO_BUTTON_PANE_A_BTN_00, // ICON_0 + DO_BUTTON_PANE_SWING_00, // ICON_1 + DO_BUTTON_PANE_UP_SWING_00, // ICON_2 + DO_BUTTON_PANE_DOWN_SWING_00, // ICON_3 + DO_BUTTON_PANE_ROTATE_00, // ICON_4 + DO_BUTTON_PANE_NONE, // ICON_5 + DO_BUTTON_PANE_NUN_RIMO_00, // ICON_6 + DO_BUTTON_PANE_A_BTN_00, // ICON_7 + DO_BUTTON_PANE_C_BTN_00, // ICON_8 + DO_BUTTON_PANE_NUN_DRAG_00, // ICON_9 + DO_BUTTON_PANE_C_BTN_01, // ICON_10 + DO_BUTTON_PANE_A_BTN_DOWN_00, // ICON_11 + DO_BUTTON_PANE_SWING_01, // ICON_12 + DO_BUTTON_PANE_DRAW_00, // ICON_13 + DO_BUTTON_PANE_PLAY_00, // ICON_14 + DO_BUTTON_PANE_NONE, // ICON_15 + DO_BUTTON_PANE_NUNCHAKU_01, // ICON_16 + DO_BUTTON_PANE_UPSET_00, // ICON_17 + DO_BUTTON_PANE_STAB_00, // ICON_18 + DO_BUTTON_PANE_NONE, // ICON_19 + DO_BUTTON_PANE_PULL_OUT_01, // ICON_20 + DO_BUTTON_PANE_A_BTN_01, // ICON_21 + DO_BUTTON_PANE_SWING_03, // ICON_22 + DO_BUTTON_PANE_B_BTN_00, // ICON_23 + DO_BUTTON_PANE_B_BTN_01, // ICON_24 + DO_BUTTON_PANE_TWIST_00, // ICON_25 + DO_BUTTON_PANE_A_BTN_DOWN_00, // ICON_26 + DO_BUTTON_PANE_A_BTN_DOWN_00, // ICON_27 + DO_BUTTON_PANE_A_BTN_DOWN_01, // ICON_28 + DO_BUTTON_PANE_A_BTN_DOWN_01, // ICON_29 + DO_BUTTON_PANE_C_BTN_00, // ICON_30 + DO_BUTTON_PANE_ZBTN_00, // ICON_31 + DO_BUTTON_PANE_ZBTN_01, // ICON_32 + DO_BUTTON_PANE_A_BTN_DOWN_01, // ICON_33 + DO_BUTTON_PANE_A_BTN_DOWN_00, // ICON_34 + DO_BUTTON_PANE_A_BTN_DOWN_00, // ICON_35 + DO_BUTTON_PANE_ZBTN_00, // ICON_36 + DO_BUTTON_PANE_CROSS_BTN_00, // ICON_37 + DO_BUTTON_PANE_UP_SWING_01, // ICON_38 + DO_BUTTON_PANE_A_BTN_DOWN_02, // ICON_39 + DO_BUTTON_PANE_A_BTN_DOWN_02, // ICON_40 + +}; + +static const s32 sPaneIdxes2[] = { + DO_BUTTON_PANE_NONE, // ICON_0 + DO_BUTTON_PANE_NONE, // ICON_1 + DO_BUTTON_PANE_NONE, // ICON_2 + DO_BUTTON_PANE_NONE, // ICON_3 + DO_BUTTON_PANE_NONE, // ICON_4 + DO_BUTTON_PANE_NONE, // ICON_5 + DO_BUTTON_PANE_NONE, // ICON_6 + DO_BUTTON_PANE_NONE, // ICON_7 + DO_BUTTON_PANE_NONE, // ICON_8 + DO_BUTTON_PANE_NONE, // ICON_9 + DO_BUTTON_PANE_NONE, // ICON_10 + DO_BUTTON_PANE_NONE, // ICON_11 + DO_BUTTON_PANE_NONE, // ICON_12 + DO_BUTTON_PANE_NONE, // ICON_13 + DO_BUTTON_PANE_NONE, // ICON_14 + DO_BUTTON_PANE_NONE, // ICON_15 + DO_BUTTON_PANE_NONE, // ICON_16 + DO_BUTTON_PANE_NONE, // ICON_17 + DO_BUTTON_PANE_NONE, // ICON_18 + DO_BUTTON_PANE_NONE, // ICON_19 + DO_BUTTON_PANE_NONE, // ICON_20 + DO_BUTTON_PANE_NONE, // ICON_21 + DO_BUTTON_PANE_NONE, // ICON_22 + DO_BUTTON_PANE_NONE, // ICON_23 + DO_BUTTON_PANE_NONE, // ICON_24 + DO_BUTTON_PANE_NONE, // ICON_25 + DO_BUTTON_PANE_NUNCHAKU_02, // ICON_26 + DO_BUTTON_PANE_NUNCHAKU_03, // ICON_27 + DO_BUTTON_PANE_ROTATE_00, // ICON_28 + DO_BUTTON_PANE_ROTATE_00, // ICON_29 + DO_BUTTON_PANE_NUN_DRAG_00, // ICON_30 + DO_BUTTON_PANE_A_BTN_00, // ICON_31 + DO_BUTTON_PANE_UP_SWING_00, // ICON_32 + DO_BUTTON_PANE_PLAY_00, // ICON_33 + DO_BUTTON_PANE_PULL_OUT_01, // ICON_34 + DO_BUTTON_PANE_STAB_00, // ICON_35 + DO_BUTTON_PANE_NONE, // ICON_36 + DO_BUTTON_PANE_NONE, // ICON_37 + DO_BUTTON_PANE_NONE, // ICON_38 + DO_BUTTON_PANE_STAB_00, // ICON_39 + DO_BUTTON_PANE_PULL_OUT_01, // ICON_40 + +}; + +void dLytDobutton_c::fn_8010E3D0(bool b) { + s32 i1 = field_0x474; + if (mAnmGroups[DO_BUTTON_ANIM_LOOP_MOVE_INFO].isEnabled()) { + if (mAnmGroups[DO_BUTTON_ANIM_LOOP_MOVE_INFO].isPlayingForwardsOnce()) { + if (mAnmGroups[DO_BUTTON_ANIM_LOOP_MOVE_INFO].getFrame() < + mAnmGroups[DO_BUTTON_ANIM_LOOP_MOVE_INFO].getAnimDuration() * 0.5f) { + i1 = field_0x478; + } + } else { + if (mAnmGroups[DO_BUTTON_ANIM_LOOP_MOVE_INFO].getFrame() > + mAnmGroups[DO_BUTTON_ANIM_LOOP_MOVE_INFO].getAnimDuration() * 0.5f) { + i1 = field_0x478; + } + } + } + + s32 idx1 = sPaneIdxes1[i1]; + f32 w1 = mpPanes[idx1]->GetSize().width; + f32 x1 = mpPanes[idx1]->GetTranslate().x; + f32 left = x1 - w1 / 2.0f; + f32 right = x1 + w1 / 2.0f; + f32 xBase = mpPanes[5]->GetTranslate().x; + + s32 idx2 = sPaneIdxes2[i1]; + if (idx2 != 37) { + f32 x2 = mpPanes[idx2]->GetTranslate().x; + f32 w2 = mpPanes[idx2]->GetSize().width; + f32 left2 = x2 - w2 / 2.0f; + f32 right2 = x2 + w2 / 2.0f; + if (left > left2) { + left = left2; + } + if (right < right2) { + right = right2; + } + w1 = right - left; + } + + nw4r::lyt::Size sz3 = mpPanes[3]->GetSize(); + nw4r::lyt::Size sz4 = mpPanes[4]->GetSize(); + if (b) { + f32 tmp = (xBase - left); + w1 = mpTextBoxes[0]->GetLineWidth(nullptr) + tmp; + } + f32 w = w1 + sDoButtonClass.field_0x10; + sz3.width = w; + sz4.width = w; + mpPanes[3]->SetSize(sz3); + mpPanes[4]->SetSize(sz4); + nw4r::math::VEC3 v = mpPanes[1]->GetTranslate(); + v.x = -left - w1 / 2.0f; + mpPanes[1]->SetTranslate(v); +} + +void dLytDobutton_c::setActionTextStuffInternal(s32 a1, s32 a2, bool b) { + field_0x488 = a1; + mNextDoActionToShow = a2; + field_0x490 = b; +} + s32 dLytDobutton_c::getActionInternal() const { return mDoActionToShow; } + +s32 dLytDobutton_c::fn_8010E5E0() const { + if (mDoActionToShow != ACT_DO_INVALID) { + return field_0x474; + } + return ICON_NONE; +} diff --git a/src/d/lyt/meter/d_lyt_meter.cpp b/src/d/lyt/meter/d_lyt_meter.cpp index 0f466304..f6580305 100644 --- a/src/d/lyt/meter/d_lyt_meter.cpp +++ b/src/d/lyt/meter/d_lyt_meter.cpp @@ -1130,10 +1130,10 @@ void dLytMeterMain_c::checkPaneVisibility() { const char *name = EventManager::getCurrentEventName(); if (strequals(name, "SwordDraw") || strequals(name, "SwordDrawDoorNew")) { field_0x1377E = true; - if (dLytDobutton_c::getNextActionToShow() != 0x12) { - dLytDobutton_c::setActionTextStuff(0x29, 0x5E, true); + if (dLytDobutton_c::getNextActionToShow() != dLytDobutton_c::ACT_DO_DRAW) { + dLytDobutton_c::setActionTextStuff(dLytDobutton_c::ICON_NONE, dLytDobutton_c::ACT_DO_INVALID, true); } - if (LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_A) != 0x12) { + if (LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_A) != LytDoButtonRelated::ACT_IE_INFO_DRAW) { LytDoButtonRelated::set(LytDoButtonRelated::DO_BUTTON_A, LytDoButtonRelated::ACT_IE_NONE); } LytDoButtonRelated::set(LytDoButtonRelated::DO_BUTTON_C, LytDoButtonRelated::ACT_IE_NONE); @@ -1164,9 +1164,9 @@ void dLytMeterMain_c::checkPaneVisibility() { LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_B) == LytDoButtonRelated::ACT_IE_NONE && !MinigameManager::isInMinigameState(MinigameManager::HOUSE_CLEANING) && !mItemSelect.fn_800F02F0()) - || - (isSilentRealm() && LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_B) == LytDoButtonRelated::ACT_IE_NONE && - !mItemSelect.fn_800F02F0()) + || (isSilentRealm() && + LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_B) == LytDoButtonRelated::ACT_IE_NONE && + !mItemSelect.fn_800F02F0()) || ((dAcPy_c::GetLink()->checkActionFlagsCont(0x400000) || fn_800D5420() || dAcPy_c::GetLink()->checkActionFlags(dAcPy_c::FLG0_CRAWLING) || fn_800D5380(0) || @@ -1379,8 +1379,8 @@ void dLytMeterMain_c::checkPaneVisibility() { if (dAcPy_c::GetLink()->getRidingActorType() != dAcPy_c::RIDING_LOFTWING || !field_0x13780 || - (dLytDobutton_c::getAction() != dLytDobutton_c::ACT_DO_INVALID || fn_800D56B0() || dLytMeter_c::getField_0x13B66() || - fn_800D5420() || fn_800D5650() || fn_800D5680())) { + (dLytDobutton_c::getAction() != dLytDobutton_c::ACT_DO_INVALID || fn_800D56B0() || + dLytMeter_c::getField_0x13B66() || fn_800D5420() || fn_800D5650() || fn_800D5680())) { mBirdGaugeVisible = false; } diff --git a/src/d/lyt/meter/d_lyt_meter_item_select.cpp b/src/d/lyt/meter/d_lyt_meter_item_select.cpp index 38abda5b..4b97558e 100644 --- a/src/d/lyt/meter/d_lyt_meter_item_select.cpp +++ b/src/d/lyt/meter/d_lyt_meter_item_select.cpp @@ -1410,7 +1410,9 @@ void dLytMeterItemSelect_c::executeState_DemoMove() { nw4r::math::MTX34 mtx = mpPanes[i + ITEM_SELECT_PANE_ICON_OFFSET]->GetGlobalMtx(); mVec3_c pos(mtx._03, mtx._13, 0.0f); - dJEffManager_c::spawnUIEffect(PARTICLE_RESOURCE_ID_MAPPING_740_, pos, nullptr, nullptr, nullptr, nullptr); + dJEffManager_c::spawnUIEffect( + PARTICLE_RESOURCE_ID_MAPPING_740_, pos, nullptr, nullptr, nullptr, nullptr + ); if (mIsBocoburinLocked[i]) { mIsBocoburinLocked[i] = false; @@ -1983,7 +1985,7 @@ bool dLytMeterItemSelect_c::execute() { } } - if (dLytDobutton_c::getField0x47C() == 0x28) { + if (dLytDobutton_c::getField0x47C() == dLytDobutton_c::ACT_DO_SAILCLOTH) { if (field_0x5774 == 0) { SmallSoundManager::GetInstance()->playSound(SE_S_PARACHUTE_CALL); } @@ -2069,7 +2071,7 @@ bool dLytMeterItemSelect_c::execute() { mStateMgr.executeState(); fn_800EF8C0(false); - if (dLytDobutton_c::getField0x47C() == 0x28) { + if (dLytDobutton_c::getField0x47C() == dLytDobutton_c::ACT_DO_SAILCLOTH) { if (field_0x57C3 != 0) { field_0x57BB = 1; } @@ -2481,8 +2483,7 @@ bool dLytMeterItemSelect_c::fn_800F0030() const { if (!StoryflagManager::sInstance->getCounterOrFlag(58) && !(EventManager::isInEvent() && EventManager::isCurrentEvent("ItemGetGorgeous")) || (mpOwnerPane == nullptr || !mpOwnerPane->IsVisible() || dLytMeter_c::GetMain()->fn_800D5650() || - dLytMeter_c::GetMain()->fn_800D5680() || - !dLytMeter_c::GetMain()->getItemSelectNotHiddenByAreaCaption())) { + dLytMeter_c::GetMain()->fn_800D5680() || !dLytMeter_c::GetMain()->getItemSelectNotHiddenByAreaCaption())) { // If we don't have a B-Wheel and we're not currently in the ItemGetGorgeous event, // or (random other conditions), return false return false;