From 736c28581182616b79acec9a5fd4e28ed3c1f3c4 Mon Sep 17 00:00:00 2001 From: robojumper Date: Fri, 11 Apr 2025 16:17:28 +0200 Subject: [PATCH] d_lyt_meter_z_btn OK --- config/SOUE01/splits.txt | 3 + config/SOUE01/symbols.txt | 46 ++-- configure.py | 2 +- include/d/d_camera.h | 18 ++ include/d/d_sc_game.h | 4 + include/d/lyt/d_lyt_control_game.h | 16 ++ include/d/lyt/d_lyt_unknowns.h | 11 +- include/d/lyt/meter/d_lyt_meter_z_btn.h | 42 ++- include/toBeSorted/attention.h | 3 +- src/d/lyt/meter/d_lyt_meter_a_btn.cpp | 19 +- src/d/lyt/meter/d_lyt_meter_item_select.cpp | 75 +++--- src/d/lyt/meter/d_lyt_meter_z_btn.cpp | 284 ++++++++++++++++++++ 12 files changed, 441 insertions(+), 82 deletions(-) create mode 100644 include/d/d_camera.h diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 5a5c1a42..31370c97 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -325,7 +325,10 @@ d/lyt/meter/d_lyt_meter_a_btn.cpp: d/lyt/meter/d_lyt_meter_z_btn.cpp: .text start:0x800E1190 end:0x800E2238 .ctors start:0x804DB6E8 end:0x804DB6EC + .rodata start:0x804E5298 end:0x804E5510 .data start:0x80513F38 end:0x80514188 + .sdata start:0x80572398 end:0x805723B8 + .sdata2 start:0x80579B70 end:0x80579B80 .bss start:0x805AA350 end:0x805AA450 d/lyt/meter/d_lyt_meter_key.cpp: diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index d630fde6..5fbe4545 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -5473,26 +5473,26 @@ getPane__15dLytMeterABtn_cFv = .text:0x800E0B20; // type:function size:0x8 __sinit_\d_lyt_meter_a_btn_cpp = .text:0x800E0B30; // type:function size:0x56C scope:local __dt__30sFStateID_c<15dLytMeterABtn_c>Fv = .text:0x800E10A0; // type:function size:0x58 isSameName__30sFStateID_c<15dLytMeterABtn_c>CFPCc = .text:0x800E1100; // type:function size:0x88 -fn_800E1190 = .text:0x800E1190; // type:function size:0xC -fn_800E11A0 = .text:0x800E11A0; // type:function size:0x11C -fn_800E12C0 = .text:0x800E12C0; // type:function size:0x4 -fn_800E12D0 = .text:0x800E12D0; // type:function size:0x4 -fn_800E12E0 = .text:0x800E12E0; // type:function size:0x60 -fn_800E1340 = .text:0x800E1340; // type:function size:0x4 -fn_800E1350 = .text:0x800E1350; // type:function size:0x4 -fn_800E1360 = .text:0x800E1360; // type:function size:0x11C -fn_800E1480 = .text:0x800E1480; // type:function size:0x4 -fn_800E1490 = .text:0x800E1490; // type:function size:0x4 -fn_800E14A0 = .text:0x800E14A0; // type:function size:0x78 -fn_800E1520 = .text:0x800E1520; // type:function size:0x4 -fn_800E1530 = .text:0x800E1530; // type:function size:0x1F8 -fn_800E1730 = .text:0x800E1730; // type:function size:0x58 -fn_800E1790 = .text:0x800E1790; // type:function size:0x434 -fn_800E1BD0 = .text:0x800E1BD0; // type:function size:0x174 -fn_800E1D50 = .text:0x800E1D50; // type:function size:0x84 -fn_800E1DE0 = .text:0x800E1DE0; // type:function size:0x8 -fn_800E1DF0 = .text:0x800E1DF0; // type:function size:0x8 -fn_800E1E00 = .text:0x800E1E00; // type:function size:0x8 +initializeState_Wait__15dLytMeterZBtn_cFv = .text:0x800E1190; // type:function size:0xC +executeState_Wait__15dLytMeterZBtn_cFv = .text:0x800E11A0; // type:function size:0x11C +finalizeState_Wait__15dLytMeterZBtn_cFv = .text:0x800E12C0; // type:function size:0x4 +initializeState_On__15dLytMeterZBtn_cFv = .text:0x800E12D0; // type:function size:0x4 +executeState_On__15dLytMeterZBtn_cFv = .text:0x800E12E0; // type:function size:0x60 +finalizeState_On__15dLytMeterZBtn_cFv = .text:0x800E1340; // type:function size:0x4 +initializeState_Active__15dLytMeterZBtn_cFv = .text:0x800E1350; // type:function size:0x4 +executeState_Active__15dLytMeterZBtn_cFv = .text:0x800E1360; // type:function size:0x11C +finalizeState_Active__15dLytMeterZBtn_cFv = .text:0x800E1480; // type:function size:0x4 +initializeState_Off__15dLytMeterZBtn_cFv = .text:0x800E1490; // type:function size:0x4 +executeState_Off__15dLytMeterZBtn_cFv = .text:0x800E14A0; // type:function size:0x78 +finalizeState_Off__15dLytMeterZBtn_cFv = .text:0x800E1520; // type:function size:0x4 +build__15dLytMeterZBtn_cFPQ23d2d10ResAccIf_c = .text:0x800E1530; // type:function size:0x1F8 +remove__15dLytMeterZBtn_cFv = .text:0x800E1730; // type:function size:0x58 +execute__15dLytMeterZBtn_cFv = .text:0x800E1790; // type:function size:0x434 +setMessage__15dLytMeterZBtn_cFl = .text:0x800E1BD0; // type:function size:0x174 +isCalling__15dLytMeterZBtn_cCFv = .text:0x800E1D50; // type:function size:0x84 +getName__15dLytMeterZBtn_cCFv = .text:0x800E1DE0; // type:function size:0x8 +getLyt__15dLytMeterZBtn_cFv = .text:0x800E1DF0; // type:function size:0x8 +getPane__15dLytMeterZBtn_cFv = .text:0x800E1E00; // type:function size:0x8 __sinit_\d_lyt_meter_z_btn_cpp = .text:0x800E1E10; // type:function size:0x338 scope:local __dt__30sFStateID_c<15dLytMeterZBtn_c>Fv = .text:0x800E2150; // type:function size:0x58 isSameName__30sFStateID_c<15dLytMeterZBtn_c>CFPCc = .text:0x800E21B0; // type:function size:0x88 @@ -11194,7 +11194,7 @@ isStateLayerWithSeekerStoneHintMenu = .text:0x801BB490; // type:function size:0x copySpawnNextToCurrent__9dScGame_cFv = .text:0x801BB510; // type:function size:0xBC actuallyTriggerEntrance__9dScGame_cFPCcUcUcUciiUcUsSc = .text:0x801BB5D0; // type:function size:0x104 setCamera = .text:0x801BB6E0; // type:function size:0x10 -getCamera = .text:0x801BB6F0; // type:function size:0x10 +getCamera__9dScGame_cFl = .text:0x801BB6F0; // type:function size:0x10 fn_801BB700 = .text:0x801BB700; // type:function size:0x4C fn_801BB750 = .text:0x801BB750; // type:function size:0x4C fn_801BB7A0 = .text:0x801BB7A0; // type:function size:0xC4 @@ -31294,7 +31294,7 @@ lbl_80513FD0 = .data:0x80513FD0; // type:object size:0x10 lbl_80513FE0 = .data:0x80513FE0; // type:object size:0x10 data:string lbl_80513FF0 = .data:0x80513FF0; // type:object size:0x10 lbl_80514000 = .data:0x80514000; // type:object size:0x10 -__vt__15dLytMeterZBtn_c = .data:0x80514010; // type:object size:0x140 +__vt__15dLytMeterZBtn_c = .data:0x80514010; // type:object size:0x34 __vt__30sFStateID_c<15dLytMeterZBtn_c> = .data:0x80514150; // type:object size:0x34 lbl_80514188 = .data:0x80514188; // type:object size:0x18 lbl_805141A0 = .data:0x805141A0; // type:object size:0xC @@ -49462,7 +49462,7 @@ lbl_805B7D60 = .bss:0x805B7D60; // type:object size:0x10 data:4byte lbl_805B7D70 = .bss:0x805B7D70; // type:object size:0x60 data:4byte lbl_805B7DD0 = .bss:0x805B7DD0; // type:object size:0x10 lbl_805B7DE0 = .bss:0x805B7DE0; // type:object size:0x20 -LytControlGame__StateID_Normal = .bss:0x805B7E00; // type:object size:0x40 data:4byte +StateID_Normal__17dLytControlGame_c = .bss:0x805B7E00; // type:object size:0x40 data:4byte LytControlGame__StateID_Pause_SetRes = .bss:0x805B7E40; // type:object size:0x40 data:4byte LytControlGame__StateID_Pause_SyncRes = .bss:0x805B7E80; // type:object size:0x40 data:4byte LytControlGame__StateID_Pause = .bss:0x805B7EC0; // type:object size:0x40 data:4byte diff --git a/configure.py b/configure.py index 0a90d3b2..62d9499d 100644 --- a/configure.py +++ b/configure.py @@ -387,7 +387,7 @@ config.libs = [ Object(NonMatching, "d/lyt/meter/d_lyt_meter.cpp"), Object(NonMatching, "d/lyt/meter/d_lyt_meter_unk.cpp"), Object(Matching, "d/lyt/meter/d_lyt_meter_a_btn.cpp"), - Object(NonMatching, "d/lyt/meter/d_lyt_meter_z_btn.cpp"), + Object(Matching, "d/lyt/meter/d_lyt_meter_z_btn.cpp"), Object(NonMatching, "d/lyt/meter/d_lyt_meter_key.cpp"), Object(Matching, "d/lyt/meter/d_lyt_meter_drink.cpp"), Object(NonMatching, "d/lyt/meter/d_lyt_meter_remocon_bg.cpp"), diff --git a/include/d/d_camera.h b/include/d/d_camera.h new file mode 100644 index 00000000..3f8b8e97 --- /dev/null +++ b/include/d/d_camera.h @@ -0,0 +1,18 @@ +#ifndef D_CAMERA_H +#define D_CAMERA_H + +#include "d/d_base.h" + +extern "C" bool fn_80081FE0(void*, const char *); + +class dCamera_c : public dBase_c { +public: + /* 0x068 */ u8 _0x068[0xD98 - 0x068]; + /* 0xD98 */ void *field_0xD98; + + bool isCurrentTrend(const char *name) const { + return fn_80081FE0(field_0xD98, name); + } +}; + +#endif diff --git a/include/d/d_sc_game.h b/include/d/d_sc_game.h index 49f4cca3..d3efba4e 100644 --- a/include/d/d_sc_game.h +++ b/include/d/d_sc_game.h @@ -6,6 +6,7 @@ #include "d/d_dylink.h" #include "d/d_fader.h" #include "d/d_scene.h" +#include "d/d_camera.h" #include "egg/gfx/eggScreen.h" #include "f/f_profile_name.h" #include "m/m2d.h" @@ -190,6 +191,9 @@ public: sReloaderType = type; } + static dCamera_c *getCamera(s32 idx); + static void setCamera(s32 idx, dCamera_c *); + protected: static u32 sUpdateFrameCount; static u8 sCurrentLayer; diff --git a/include/d/lyt/d_lyt_control_game.h b/include/d/lyt/d_lyt_control_game.h index 5802522f..f8af08fc 100644 --- a/include/d/lyt/d_lyt_control_game.h +++ b/include/d/lyt/d_lyt_control_game.h @@ -2,6 +2,7 @@ #define D_LYT_CONTROL_GAME_H #include "d/d_base.h" +#include "s/s_State.hpp" class dLytControlGame_c : public dBase_c { public: @@ -17,7 +18,22 @@ public: return sInstance; } + STATE_FUNC_DECLARE(dLytControlGame_c, Normal); + STATE_FUNC_DECLARE(dLytControlGame_c, Pause_SetRes); + STATE_FUNC_DECLARE(dLytControlGame_c, Pause_SyncRes); + STATE_FUNC_DECLARE(dLytControlGame_c, Pause); + STATE_FUNC_DECLARE(dLytControlGame_c, Pause_DelRes); + STATE_FUNC_DECLARE(dLytControlGame_c, Map_SetRes); + STATE_FUNC_DECLARE(dLytControlGame_c, Map_SyncRes); + STATE_FUNC_DECLARE(dLytControlGame_c, Map); + STATE_FUNC_DECLARE(dLytControlGame_c, Map_DelRes); + + bool isStateNormal() const { + return *mStateMgr.getStateID() == StateID_Normal; + } + private: + /* 0x00068 */ UI_STATE_MGR_DECLARE(dLytControlGame_c); static dLytControlGame_c *sInstance; }; diff --git a/include/d/lyt/d_lyt_unknowns.h b/include/d/lyt/d_lyt_unknowns.h index 219ab3f3..50dc0ef3 100644 --- a/include/d/lyt/d_lyt_unknowns.h +++ b/include/d/lyt/d_lyt_unknowns.h @@ -30,11 +30,16 @@ public: enum DoButton_e { DO_BUTTON_A = 0, DO_BUTTON_B = 1, + + DO_BUTTON_Z = 3, }; - void set(DoButton_e button, Action_e value) { - field_0x04[button] = value; - field_0x34[button] = true; + static void set(DoButton_e button, Action_e value) { + LytDoButtonRelated *b = sInstance; + if (b != nullptr) { + b->field_0x04[button] = value; + b->field_0x34[button] = true; + } } static Action_e get(DoButton_e button) { diff --git a/include/d/lyt/meter/d_lyt_meter_z_btn.h b/include/d/lyt/meter/d_lyt_meter_z_btn.h index 81de20e1..a65a4415 100644 --- a/include/d/lyt/meter/d_lyt_meter_z_btn.h +++ b/include/d/lyt/meter/d_lyt_meter_z_btn.h @@ -1,9 +1,12 @@ #ifndef D_LYT_METER_Z_BTN_H #define D_LYT_METER_Z_BTN_H +#include "common.h" #include "d/lyt/d2d.h" +#include "d/lyt/d_textbox.h" +#include "d/lyt/d_window.h" +#include "nw4r/lyt/lyt_pane.h" #include "s/s_State.hpp" -#include "s/s_StateMgr.hpp" class dLytMeterZBtn_c : public d2d::dSubPane { public: @@ -11,21 +14,44 @@ public: virtual bool build(d2d::ResAccIf_c *resAcc) override; virtual bool remove() override; virtual bool execute() override; - virtual nw4r::lyt::Pane *getPane() override; - virtual d2d::LytBase_c *getLyt() override; - virtual const char *getName() const override; + virtual nw4r::lyt::Pane *getPane() override { + return mLyt.getLayout()->GetRootPane(); + } + virtual d2d::LytBase_c *getLyt() override { + return &mLyt; + } + virtual const char *getName() const override { + return mLyt.getName(); + } virtual ~dLytMeterZBtn_c() {} + + bool isCalling() const; + private: + void setMessage(s32 id); + STATE_FUNC_DECLARE(dLytMeterZBtn_c, Wait); STATE_FUNC_DECLARE(dLytMeterZBtn_c, On); STATE_FUNC_DECLARE(dLytMeterZBtn_c, Active); STATE_FUNC_DECLARE(dLytMeterZBtn_c, Off); - UI_STATE_MGR_DECLARE(dLytMeterZBtn_c); - d2d::dLytSub mLyt; - /* 0x0D8 */ d2d::AnmGroup_c mAnmGroups[3]; - /* 0x??? */ u8 padding[0x121C8 - 0x12198]; + /* 0x008 */ UI_STATE_MGR_DECLARE(dLytMeterZBtn_c); + /* 0x04C */ d2d::dLytSub mLyt; + /* 0x0D8 */ d2d::AnmGroup_c mAnm[3]; + /* 0x198 */ nw4r::lyt::Pane *mpPane; + /* 0x19C */ nw4r::lyt::Pane *mpOwnerPane; + /* 0x1A0 */ dTextBox_c *mpTextBoxes[2]; + /* 0x1A8 */ dWindow_c *mpWindow[1]; + /* 0x1AC */ dTextBox_c *mpSizeBox[1]; + /* 0x1B0 */ s32 field_0x1B0; + /* 0x1B4 */ s32 field_0x1B4; + /* 0x1B8 */ BOOL field_0x1B8; + /* 0x1BC */ s32 field_0x1BC; + /* 0x1C0 */ s32 mOnDelay; + /* 0x1C4 */ bool field_0x1C4; + /* 0x1C5 */ u8 field_0x1C5; + /* 0x1C6 */ u8 field_0x1C6; }; #endif diff --git a/include/toBeSorted/attention.h b/include/toBeSorted/attention.h index 00832210..69a9044b 100644 --- a/include/toBeSorted/attention.h +++ b/include/toBeSorted/attention.h @@ -213,12 +213,13 @@ public: void addReadTarget(dAcObjBase_c &actor, u32 flags, f32 field_0x14, f32 ignored, f32 field_0x20, f32 field_0x24); void addReadTarget2(dAcObjBase_c &actor, u32 flags, f32 field_0x14, f32 field_0x20, f32 field_0x24); + bool checkLink2() const; + private: bool isInNormalGameState() const; bool checkZButtonPressed() const; bool checkZButtonHeld() const; bool checkLink1() const; - bool checkLink2() const; bool switchTarget(s32 target); bool playTargetAnim(s32 target); diff --git a/src/d/lyt/meter/d_lyt_meter_a_btn.cpp b/src/d/lyt/meter/d_lyt_meter_a_btn.cpp index 15865fdf..10d8c174 100644 --- a/src/d/lyt/meter/d_lyt_meter_a_btn.cpp +++ b/src/d/lyt/meter/d_lyt_meter_a_btn.cpp @@ -209,16 +209,14 @@ bool dLytMeterABtn_c::execute() { if (*mStateMgr.getStateID() == StateID_Off) { mAnm[A_BTN_ANIM_INPUT].setToEnd2(); } - if (LytDoButtonRelated::GetInstance() != nullptr) { - LytDoButtonRelated::GetInstance()->set(LytDoButtonRelated::DO_BUTTON_A, LytDoButtonRelated::DO_NONE); - } + + LytDoButtonRelated::set(LytDoButtonRelated::DO_BUTTON_A, LytDoButtonRelated::DO_NONE); + return true; } if (dLytMeterContainer_c::GetInstance()->getMeterField_0x13750() == 0) { - if (LytDoButtonRelated::GetInstance() != nullptr) { - LytDoButtonRelated::GetInstance()->set(LytDoButtonRelated::DO_BUTTON_A, LytDoButtonRelated::DO_NONE); - } + LytDoButtonRelated::set(LytDoButtonRelated::DO_BUTTON_A, LytDoButtonRelated::DO_NONE); if (field_0x1BC != LytDoButtonRelated::DO_NONE) { field_0x1BC = LytDoButtonRelated::DO_NONE; @@ -233,9 +231,8 @@ bool dLytMeterABtn_c::execute() { dLytMeterContainer_c::GetMeter()->getField_0x1377E() == 0 && !checkIsInSkykeepPuzzle() && LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_A) == LytDoButtonRelated::DO_NONE) { field_0x1C9 = 0; - if (LytDoButtonRelated::GetInstance() != nullptr) { - LytDoButtonRelated::GetInstance()->set(LytDoButtonRelated::DO_BUTTON_A, LytDoButtonRelated::DO_NONE); - } + + LytDoButtonRelated::set(LytDoButtonRelated::DO_BUTTON_A, LytDoButtonRelated::DO_NONE); } else { field_0x1C9 = 1; } @@ -261,9 +258,7 @@ bool dLytMeterABtn_c::execute() { LytDoButtonRelated::Action_e action = LytDoButtonRelated::convertDoButton(dLytDobutton_c::getField0x47C()); if (action >= 0) { state = true; - if (LytDoButtonRelated::GetInstance() != nullptr) { - LytDoButtonRelated::GetInstance()->set(LytDoButtonRelated::DO_BUTTON_A, action); - } + LytDoButtonRelated::set(LytDoButtonRelated::DO_BUTTON_A, action); } field_0x1CA = 0; break; 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 c6a31879..aa740b1d 100644 --- a/src/d/lyt/meter/d_lyt_meter_item_select.cpp +++ b/src/d/lyt/meter/d_lyt_meter_item_select.cpp @@ -666,7 +666,8 @@ void dLytMeterItemSelect_c::initializeState_Wait() { } } void dLytMeterItemSelect_c::executeState_Wait() { - if (field_0x57B3 == 1 && (field_0x5794 == I_INVALID || LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_B) == LytDoButtonRelated::DO_STOP)) { + if (field_0x57B3 == 1 && (field_0x5794 == I_INVALID || LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_B) == + LytDoButtonRelated::DO_STOP)) { mStateMgr.changeState(StateID_SetNone); } else if (field_0x57B3 == 0 && field_0x5794 == I_INVALID && (field_0x579A == I_SAILCLOTH || field_0x579A == I_BOAT_CANNON || field_0x579A == I_HARP)) { @@ -681,14 +682,18 @@ void dLytMeterItemSelect_c::executeState_Wait() { } else if (isWheelBlockedByCurrentAction()) { field_0x5768 = 0; mStateMgr.changeState(StateID_FrameOffIn); - } else if ((field_0x5794 == I_SAILCLOTH || (field_0x5794 == I_BOAT_CANNON || field_0x5794 == I_HARP)) && field_0x579A == I_INVALID) { + } else if ((field_0x5794 == I_SAILCLOTH || (field_0x5794 == I_BOAT_CANNON || field_0x5794 == I_HARP)) && + field_0x579A == I_INVALID) { mStateMgr.changeState(StateID_SetSpecialItemIn); } else if (!dLytMeterContainer_c::GetInstance()->checkAllFlags(0x10)) { mStateMgr.changeState(StateID_ToUnuse); } else if (!dLytMeterContainer_c::GetMeter()->fn_800D5650() && !dLytMeterContainer_c::GetMeter()->fn_800D5680() && - LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_B) != LytDoButtonRelated::DO_ITEMS && LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_B) != LytDoButtonRelated::DO_RETURN && - LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_B) != LytDoButtonRelated::DO_DONE && LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_B) != LytDoButtonRelated::DO_STOP && - (field_0x5794 != I_BOAT_CANNON && field_0x5794 != I_HARP && field_0x5794 != I_INVALID && field_0x5794 != I_SAILCLOTH)) { + LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_B) != LytDoButtonRelated::DO_ITEMS && + LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_B) != LytDoButtonRelated::DO_RETURN && + LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_B) != LytDoButtonRelated::DO_DONE && + LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_B) != LytDoButtonRelated::DO_STOP && + (field_0x5794 != I_BOAT_CANNON && field_0x5794 != I_HARP && field_0x5794 != I_INVALID && + field_0x5794 != I_SAILCLOTH)) { mStateMgr.changeState(StateID_ResetIn); } } @@ -963,7 +968,8 @@ void dLytMeterItemSelect_c::executeState_Set() { mStateMgr.changeState(StateID_SetOut); } } else { - if ((field_0x5794 == I_SAILCLOTH || field_0x5794 == I_BOAT_CANNON || field_0x5794 == I_HARP) && field_0x579A != field_0x5794) { + if ((field_0x5794 == I_SAILCLOTH || field_0x5794 == I_BOAT_CANNON || field_0x5794 == I_HARP) && + field_0x579A != field_0x5794) { mStateMgr.changeState(StateID_SetSpecialItemIn); } else if (!dLytMeterContainer_c::GetInstance()->checkAllFlags(0x10) && field_0x5790 <= 0 && (field_0x5794 == I_BOAT_CANNON || field_0x5794 == I_HARP)) { @@ -1107,8 +1113,8 @@ void dLytMeterItemSelect_c::finalizeState_ResetIn() {} void dLytMeterItemSelect_c::initializeState_Reset() {} void dLytMeterItemSelect_c::executeState_Reset() { if (field_0x57A2 != 0 || field_0x5754 == 1 || - (field_0x57A0 != 0 && - (dLytMeterContainer_c::GetInstance()->checkAllFlags(0x10) || (field_0x5794 != I_HARP && field_0x5794 != I_BOAT_CANNON)))) { + (field_0x57A0 != 0 && (dLytMeterContainer_c::GetInstance()->checkAllFlags(0x10) || + (field_0x5794 != I_HARP && field_0x5794 != I_BOAT_CANNON)))) { mAnm[ITEM_SELECT_ANIM_RESET].setBackwardsOnce(); mAnm[ITEM_SELECT_ANIM_RESET].setToEnd2(); mAnm[ITEM_SELECT_ANIM_RESET].setAnimEnable(true); @@ -1117,9 +1123,12 @@ void dLytMeterItemSelect_c::executeState_Reset() { fn_800F0310(); } else if (field_0x5794 == I_SAILCLOTH || field_0x5794 == I_BOAT_CANNON || field_0x5794 == I_HARP) { mStateMgr.changeState(StateID_SetSpecialItemIn); - } else if (LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_B) == LytDoButtonRelated::DO_ITEMS || LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_B) == LytDoButtonRelated::DO_RETURN || - LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_B) == LytDoButtonRelated::DO_DONE || LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_B) == LytDoButtonRelated::DO_STOP || field_0x5794 == I_INVALID || - !dLytMeterContainer_c::GetInstance()->checkAllFlags(0x10) || field_0x5754 == 1) { + } else if (LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_B) == LytDoButtonRelated::DO_ITEMS || + LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_B) == LytDoButtonRelated::DO_RETURN || + LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_B) == LytDoButtonRelated::DO_DONE || + LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_B) == LytDoButtonRelated::DO_STOP || + field_0x5794 == I_INVALID || !dLytMeterContainer_c::GetInstance()->checkAllFlags(0x10) || + field_0x5754 == 1) { mStateMgr.changeState(StateID_ResetOut); } } @@ -1133,8 +1142,8 @@ void dLytMeterItemSelect_c::initializeState_ResetOut() { } void dLytMeterItemSelect_c::executeState_ResetOut() { if (field_0x57A2 != 0 || field_0x5754 == 1 || - (field_0x57A0 != 0 && - (dLytMeterContainer_c::GetInstance()->checkAllFlags(0x10) || (field_0x5794 != I_HARP && field_0x5794 != I_BOAT_CANNON)))) { + (field_0x57A0 != 0 && (dLytMeterContainer_c::GetInstance()->checkAllFlags(0x10) || + (field_0x5794 != I_HARP && field_0x5794 != I_BOAT_CANNON)))) { mAnm[ITEM_SELECT_ANIM_RESET].setToEnd2(); mBtn[2].setVisible(false, true); mLyt.calc(); @@ -1183,8 +1192,8 @@ void dLytMeterItemSelect_c::initializeState_ToUse() { } void dLytMeterItemSelect_c::executeState_ToUse() { if (field_0x57A2 != 0 || field_0x5754 == 1 || - (field_0x57A0 != 0 && - (dLytMeterContainer_c::GetInstance()->checkAllFlags(0x10) || (field_0x5794 != I_HARP && field_0x5794 != I_BOAT_CANNON)))) { + (field_0x57A0 != 0 && (dLytMeterContainer_c::GetInstance()->checkAllFlags(0x10) || + (field_0x5794 != I_HARP && field_0x5794 != I_BOAT_CANNON)))) { if (field_0x57C4 != 0 && mAnm[ITEM_SELECT_ANIM_OUT].isEnabled()) { mAnm[ITEM_SELECT_ANIM_OUT].setToEnd2(); mLyt.calc(); @@ -1253,7 +1262,8 @@ void dLytMeterItemSelect_c::initializeState_ToUnuse() { field_0x57A1 = field_0x57A0; } void dLytMeterItemSelect_c::executeState_ToUnuse() { - if (field_0x57B3 == 0 && field_0x5794 == I_INVALID && (field_0x579A == I_SAILCLOTH || field_0x579A == I_BOAT_CANNON || field_0x579A == I_HARP)) { + if (field_0x57B3 == 0 && field_0x5794 == I_INVALID && + (field_0x579A == I_SAILCLOTH || field_0x579A == I_BOAT_CANNON || field_0x579A == I_HARP)) { mStateMgr.changeState(StateID_SetNone); } else if (field_0x57A2 != 0 || field_0x5754 == 1 || (field_0x57A0 != 0 && (dLytMeterContainer_c::GetInstance()->checkAllFlags(0x10) || @@ -1817,7 +1827,8 @@ bool dLytMeterItemSelect_c::remove() { bool dLytMeterItemSelect_c::execute() { if (StoryflagManager::sInstance->getCounterOrFlag(569) != 0) { - if (field_0x57A2 != 0 || (field_0x57A0 != 0 && field_0x5794 != I_SAILCLOTH && field_0x5794 != I_BOAT_CANNON && field_0x5794 != I_HARP)) { + if (field_0x57A2 != 0 || (field_0x57A0 != 0 && field_0x5794 != I_SAILCLOTH && field_0x5794 != I_BOAT_CANNON && + field_0x5794 != I_HARP)) { field_0x57B9 = 0; StoryflagManager::sInstance->unsetFlag(569); } else { @@ -2010,7 +2021,8 @@ bool dLytMeterItemSelect_c::execute() { mStoredBowVariant = baseItemLytIndexToCurrentVariant(getBaseItemLytIndexforInternalId(I_BOW)); setBtnItem(field_0x5796); b = true; - } else if (mStoredSlingshotVariant != baseItemLytIndexToCurrentVariant(getBaseItemLytIndexforInternalId(I_SLINGSHOT))) { + } else if (mStoredSlingshotVariant != + baseItemLytIndexToCurrentVariant(getBaseItemLytIndexforInternalId(I_SLINGSHOT))) { mStoredSlingshotVariant = baseItemLytIndexToCurrentVariant(getBaseItemLytIndexforInternalId(I_SLINGSHOT)); setBtnItem(field_0x5796); b = true; @@ -2025,7 +2037,9 @@ bool dLytMeterItemSelect_c::execute() { } if (field_0x5797 != I_INVALID) { - realizeBtnNumberForLytIndex(baseItemLytIndexToCurrentVariant(getBaseItemLytIndexforInternalId(field_0x5797)), a); + realizeBtnNumberForLytIndex( + baseItemLytIndexToCurrentVariant(getBaseItemLytIndexforInternalId(field_0x5797)), a + ); } if (field_0x57B6) { @@ -2064,7 +2078,8 @@ bool dLytMeterItemSelect_c::execute() { } bool b2 = false; - if (field_0x57B9 != 0 && dLytMeterContainer_c::GetInstance()->checkAllFlags(0x10) && mLastDoButtonRelatedAction == 0x85) { + if (field_0x57B9 != 0 && dLytMeterContainer_c::GetInstance()->checkAllFlags(0x10) && + mLastDoButtonRelatedAction == 0x85) { if (field_0x57BA == 0) { mAnm[ITEM_SELECT_ANIM_CALL].setToEnd(); mAnm[ITEM_SELECT_ANIM_CALL].setRate(1.0f); @@ -2188,18 +2203,12 @@ bool dLytMeterItemSelect_c::execute() { } if (field_0x5794 == I_SAILCLOTH) { - if (LytDoButtonRelated::GetInstance() != nullptr) { - LytDoButtonRelated::GetInstance()->set(LytDoButtonRelated::DO_BUTTON_B, LytDoButtonRelated::DO_SAILCLOTH); - } + LytDoButtonRelated::set(LytDoButtonRelated::DO_BUTTON_B, LytDoButtonRelated::DO_SAILCLOTH); } else if (field_0x5794 == I_BOAT_CANNON) { if (field_0x57B3 != 0) { - if (LytDoButtonRelated::GetInstance() != nullptr) { - LytDoButtonRelated::GetInstance()->set(LytDoButtonRelated::DO_BUTTON_B, LytDoButtonRelated::DO_STOW_CANNON); - } + LytDoButtonRelated::set(LytDoButtonRelated::DO_BUTTON_B, LytDoButtonRelated::DO_STOW_CANNON); } else { - if (LytDoButtonRelated::GetInstance() != nullptr) { - LytDoButtonRelated::GetInstance()->set(LytDoButtonRelated::DO_BUTTON_B, LytDoButtonRelated::DO_READY_CANNON); - } + LytDoButtonRelated::set(LytDoButtonRelated::DO_BUTTON_B, LytDoButtonRelated::DO_READY_CANNON); } } @@ -2221,9 +2230,7 @@ bool dLytMeterItemSelect_c::execute() { } } - if (LytDoButtonRelated::GetInstance() != nullptr) { - LytDoButtonRelated::GetInstance()->set(LytDoButtonRelated::DO_BUTTON_B, LytDoButtonRelated::DO_NONE); - } + LytDoButtonRelated::set(LytDoButtonRelated::DO_BUTTON_B, LytDoButtonRelated::DO_NONE); } field_0x57C1 = isWheelBlockedByCurrentAction(); @@ -2499,9 +2506,9 @@ s32 dLytMeterItemSelect_c::fn_800F0170(s32 slot) const { return sUnkArray1[slot]; } - u8 dLytMeterItemSelect_c::getInternalBaseItemForSlot(s32 slot) const { - static s32 sSlotToInternalItem[] = {I_BOW, I_BOMB_BAG, I_BEETLE, I_BUG_NET, I_SLINGSHOT, I_CLAWSHOTS, I_WHIP, I_GUST_BELLOWS}; + static s32 sSlotToInternalItem[] = {I_BOW, I_BOMB_BAG, I_BEETLE, I_BUG_NET, + I_SLINGSHOT, I_CLAWSHOTS, I_WHIP, I_GUST_BELLOWS}; return sSlotToInternalItem[slot]; } diff --git a/src/d/lyt/meter/d_lyt_meter_z_btn.cpp b/src/d/lyt/meter/d_lyt_meter_z_btn.cpp index 9a48f924..e97583a8 100644 --- a/src/d/lyt/meter/d_lyt_meter_z_btn.cpp +++ b/src/d/lyt/meter/d_lyt_meter_z_btn.cpp @@ -1,6 +1,290 @@ #include "d/lyt/meter/d_lyt_meter_z_btn.h" +#include "common.h" +#include "d/d_pad.h" +#include "d/d_sc_game.h" +#include "d/flag/storyflag_manager.h" +#include "d/lyt/d_lyt_control_game.h" +#include "d/lyt/d_lyt_unknowns.h" +#include "d/lyt/meter/d_lyt_meter.h" +#include "toBeSorted/attention.h" +#include "toBeSorted/small_sound_mgr.h" + STATE_DEFINE(dLytMeterZBtn_c, Wait); STATE_DEFINE(dLytMeterZBtn_c, On); STATE_DEFINE(dLytMeterZBtn_c, Active); STATE_DEFINE(dLytMeterZBtn_c, Off); + +static const d2d::LytBrlanMapping brlanMap[] = { + {"nunBtn_01_input.brlan", "G_input_00"}, + { "nunBtn_01_call.brlan", "G_call_00"}, + { "nunBtn_01_loop.brlan", "G_loop_00"}, +}; + +#define Z_BTN_ANIM_INPUT 0 +#define Z_BTN_ANIM_CALL 1 +#define Z_BTN_ANIM_LOOP 2 + +#define Z_BTN_NUM_ANIMS 3 + +void dLytMeterZBtn_c::initializeState_Wait() { + mOnDelay = 15; +} +void dLytMeterZBtn_c::executeState_Wait() { + s32 timer = mOnDelay; + if (field_0x1C4) { + if (field_0x1B8) { + bool bDoUpdate = true; + if (field_0x1B4 != LytDoButtonRelated::DO_NONE) { + if (timer <= 0) { + mAnm[Z_BTN_ANIM_INPUT].setBackwardsOnce(); + mAnm[Z_BTN_ANIM_INPUT].setToStart(); + mAnm[Z_BTN_ANIM_INPUT].setAnimEnable(true); + mStateMgr.changeState(StateID_On); + setMessage(field_0x1B4); + } else { + mOnDelay = timer - 1; + bDoUpdate = false; + } + } + if (bDoUpdate) { + field_0x1B0 = field_0x1B4; + } + } else { + if (field_0x1B4 != LytDoButtonRelated::DO_NONE) { + setMessage(field_0x1B4); + } + field_0x1B0 = field_0x1B4; + } + } + + if (timer == mOnDelay) { + mOnDelay = 15; + } +} +void dLytMeterZBtn_c::finalizeState_Wait() {} + +void dLytMeterZBtn_c::initializeState_On() {} +void dLytMeterZBtn_c::executeState_On() { + if (mAnm[Z_BTN_ANIM_INPUT].isStop2()) { + mAnm[Z_BTN_ANIM_INPUT].setAnimEnable(false); + mStateMgr.changeState(StateID_Active); + } +} +void dLytMeterZBtn_c::finalizeState_On() {} + +void dLytMeterZBtn_c::initializeState_Active() {} +void dLytMeterZBtn_c::executeState_Active() { + if (field_0x1B4 != field_0x1B0 || !field_0x1B8) { + if (field_0x1B4 == LytDoButtonRelated::DO_NONE || !field_0x1B8) { + mAnm[Z_BTN_ANIM_INPUT].setForwardOnce(); + mAnm[Z_BTN_ANIM_INPUT].setFrame(0.0f); + mAnm[Z_BTN_ANIM_INPUT].setAnimEnable(true); + if (field_0x1B0 != field_0x1BC) { + field_0x1B4 = field_0x1BC; + } + mStateMgr.changeState(StateID_Off); + } else { + setMessage(field_0x1B4); + } + field_0x1B0 = field_0x1B4; + } else if (field_0x1B0 == LytDoButtonRelated::DO_NONE) { + mAnm[Z_BTN_ANIM_INPUT].setForwardOnce(); + mAnm[Z_BTN_ANIM_INPUT].setFrame(0.0f); + mAnm[Z_BTN_ANIM_INPUT].setAnimEnable(true); + mStateMgr.changeState(StateID_Off); + } +} +void dLytMeterZBtn_c::finalizeState_Active() {} + +void dLytMeterZBtn_c::initializeState_Off() {} +void dLytMeterZBtn_c::executeState_Off() { + if (mAnm[Z_BTN_ANIM_INPUT].isEndReached()) { + mAnm[Z_BTN_ANIM_INPUT].setAnimEnable(false); + mStateMgr.changeState(StateID_Wait); + } +} +void dLytMeterZBtn_c::finalizeState_Off() {} + +static const char *sPane = "N_collectAll_00"; + +static const char *sTextBoxes[] = { + "T_zBtn_00", + "T_zBtnS_00", +}; + +bool dLytMeterZBtn_c::build(d2d::ResAccIf_c *resAcc) { + mLyt.setResAcc(resAcc); + mLyt.build("nunBtn_01.brlyt", nullptr); + + for (int i = 0; i < Z_BTN_NUM_ANIMS; i++) { + mAnm[i].init(brlanMap[i].mFile, resAcc, mLyt.getLayout(), brlanMap[i].mName); + mAnm[i].bind(false); + mAnm[i].setAnimEnable(false); + } + + mpPane = mLyt.findPane(sPane); + + for (int i = 0; i < 2; i++) { + mpTextBoxes[i] = mLyt.getTextBox(sTextBoxes[i]); + } + + static const char *sWindows[] = {"W_bgP_00"}; + for (int i = 0; i < 1; i++) { + mpWindow[i] = mLyt.getWindow(sWindows[i]); + mpSizeBox[i] = mLyt.getSizeBoxInWindow(sWindows[i]); + } + + field_0x1BC = 0x5E; + field_0x1B0 = 0x5E; + field_0x1B4 = 0x5E; + field_0x1C4 = false; + field_0x1B8 = true; + mpOwnerPane = 0; + + setMessage(0x5E); + field_0x1C5 = 0; + field_0x1C6 = 0; + mOnDelay = 15; + + mAnm[Z_BTN_ANIM_INPUT].setToEnd(); + mAnm[Z_BTN_ANIM_INPUT].setAnimEnable(true); + mAnm[Z_BTN_ANIM_CALL].setToEnd(); + mAnm[Z_BTN_ANIM_CALL].setAnimEnable(true); + mAnm[Z_BTN_ANIM_LOOP].setAnimEnable(true); + mLyt.calc(); + mAnm[Z_BTN_ANIM_INPUT].setAnimEnable(false); + mAnm[Z_BTN_ANIM_CALL].setAnimEnable(false); + mStateMgr.changeState(StateID_Wait); + return true; +} + +bool dLytMeterZBtn_c::remove() { + for (int i = 0; i < Z_BTN_NUM_ANIMS; i++) { + mAnm[i].unbind(); + mAnm[i].remove(); + } + return true; +} + +bool dLytMeterZBtn_c::execute() { + if (mpOwnerPane == nullptr) { + return true; + } + + if (!mpOwnerPane->IsVisible()) { + if (*mStateMgr.getStateID() == StateID_Off) { + mAnm[Z_BTN_ANIM_INPUT].setToEnd2(); + } else if (*mStateMgr.getStateID() == StateID_Active) { + mAnm[Z_BTN_ANIM_INPUT].setForwardOnce(); + mAnm[Z_BTN_ANIM_INPUT].setToEnd2(); + mAnm[Z_BTN_ANIM_INPUT].setAnimEnable(true); + mStateMgr.changeState(StateID_Off); + } + LytDoButtonRelated::set(LytDoButtonRelated::DO_BUTTON_Z, LytDoButtonRelated::DO_NONE); + return true; + } + field_0x1C4 = true; + dCamera_c *cam = dScGame_c::getCamera(0); + if ((!cam->isCurrentTrend("mogu") || AttentionManager::GetInstance()->checkLink2()) && + LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_Z) == 0x67) { + field_0x1C4 = false; + LytDoButtonRelated::set(LytDoButtonRelated::DO_BUTTON_Z, LytDoButtonRelated::DO_NONE); + } + field_0x1B4 = LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_Z); + field_0x1B8 = LytDoButtonRelated::getHas(LytDoButtonRelated::DO_BUTTON_Z) && + dLytMeterContainer_c::GetInstance()->checkAllFlags(0x800); + mStateMgr.executeState(); + + for (int i = 0; i < Z_BTN_NUM_ANIMS; i++) { + if (i != 1 && mAnm[i].isEnabled()) { + mAnm[i].play(); + } + } + + if (dLytControlGame_c::getInstance()->isStateNormal()) { + if (StoryflagManager::sInstance->getCounterOrFlag(565)) { + if (dPad::checkButtonZPressed()) { + field_0x1C5 = 0; + StoryflagManager::sInstance->unsetFlag(565); + } else { + field_0x1C5 = 1; + } + } + } else { + field_0x1C5 = 0; + } + + if (field_0x1C5 != 0 && dLytMeterContainer_c::GetInstance()->checkAllFlags(0x800)) { + if (field_0x1C6 == 0) { + mAnm[Z_BTN_ANIM_CALL].setToEnd(); + mAnm[Z_BTN_ANIM_CALL].setAnimEnable(true); + field_0x1C6 = 1; + } + if (mAnm[Z_BTN_ANIM_CALL].isEnabled()) { + mAnm[Z_BTN_ANIM_CALL].play(); + if (dLytMeterContainer_c::GetInstance()->checkAllFlags(0x800) && mAnm[Z_BTN_ANIM_CALL].getFrame() == 1.0f) { + SmallSoundManager::GetInstance()->playSound(SE_S_Z_BUTTON_BLINK); + } + } + } else if (field_0x1C6 == 1) { + mAnm[Z_BTN_ANIM_CALL].setToEnd(); + } else if (mAnm[Z_BTN_ANIM_CALL].isEnabled()) { + mAnm[Z_BTN_ANIM_CALL].setAnimEnable(false); + } + + if (field_0x1C5 == 0) { + field_0x1C6 = field_0x1C5; + } + field_0x1C5 = 0; + + return true; +} + +// TODO +static const s32 sActIds[] = { + 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x10, 0x11, 0x12, 0x13, + 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, + 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, + 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, + 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, -1, 0x1, + 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x10, 0x11, 0x12, 0x13, 0x14, + 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x0, 0x0, 0x0, 0x0, 0x0 +}; + +void dLytMeterZBtn_c::setMessage(s32 id) { + char buf[11]; + for (int i = 0; i < 11; i++) { + buf[i] = 0; + } + + if (id < LytDoButtonRelated::DO_NONE) { + if (id < 0x5D) { + sprintf(buf, "ACT_INFO_%03d", sActIds[id]); + } else { + s32 id2 = id - 0x5E; + sprintf(buf, "ACT_ETC_%03d", sActIds[id2]); + } + + for (int i = 0; i < 2; i++) { + mpTextBoxes[i]->SetVisible(true); + mpTextBoxes[i]->setMessageWithGlobalTextProcessor2(buf, nullptr); + } + mpWindow[0]->SetVisible(true); + mpWindow[0]->UpdateSize(mpSizeBox[0], 32.0f); + field_0x1BC = id; + } else { + mpTextBoxes[0]->SetVisible(false); + mpTextBoxes[1]->SetVisible(false); + mpWindow[0]->SetVisible(false); + } +} + +bool dLytMeterZBtn_c::isCalling() const { + if (dLytControlGame_c::getInstance()->isStateNormal() && StoryflagManager::sInstance->getCounterOrFlag(565)) { + return true; + } + + return false; +}