From a2f2321da0354c219fb5b51bd2a40210b69d1809 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sat, 26 Oct 2024 14:12:40 +0200 Subject: [PATCH] d_lyt_sky_gauge OK (#82) --- config/SOUE01/splits.txt | 4 + config/SOUE01/symbols.txt | 138 +++++++++++----------- configure.py | 2 +- include/d/lyt/d2d.h | 4 + include/d/lyt/d_lyt_sky_gauge.h | 61 ++++++++-- src/d/lyt/d_lyt_sky_gauge.cpp | 200 +++++++++++++++++++++++++++++++- 6 files changed, 324 insertions(+), 85 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 66dc9b2d..4970d2cb 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -432,7 +432,11 @@ d/lyt/d_lyt_bird_gauge.cpp: d/lyt/d_lyt_sky_gauge.cpp: .text start:0x801548E0 end:0x80155CC8 .ctors start:0x804DB788 end:0x804DB78C + .rodata start:0x804E8138 end:0x804E8150 .data start:0x80524510 end:0x80524928 + .sbss start:0x805754E8 end:0x805754F0 + .sdata2 start:0x8057A040 end:0x8057A058 + .bss start:0x805B1230 end:0x805B1430 d/lyt/d_lyt_deposit_stock.cpp: .text start:0x80155CD0 end:0x801578A8 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 4eceea2f..be65cf08 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -4757,7 +4757,7 @@ fn_800D7B40 = .text:0x800D7B40; // type:function size:0xC draw__11dLytMeter_cFv = .text:0x800D7B50; // type:function size:0x128 fn_800D7C80 = .text:0x800D7C80; // type:function size:0x8 fn_800D7C90 = .text:0x800D7C90; // type:function size:0x8 -fn_800D7CA0 = .text:0x800D7CA0; // type:function size:0x8 +getLyt__14dLytSkyGauge_cFv = .text:0x800D7CA0; // type:function size:0x8 fn_800D7CB0 = .text:0x800D7CB0; // type:function size:0x8 __ct__20dLytMeterContainer_cFv = .text:0x800D7CC0; // type:function size:0x84 __dt__11dLytMeter_cFv = .text:0x800D7D50; // type:function size:0xB94 @@ -4775,7 +4775,7 @@ fn_800D91D0 = .text:0x800D91D0; // type:function size:0xE4 fn_800D92C0 = .text:0x800D92C0; // type:function size:0x48 fn_800D9310 = .text:0x800D9310; // type:function size:0xD8 fn_800D93F0 = .text:0x800D93F0; // type:function size:0x1F0 -fn_800D95E0 = .text:0x800D95E0; // type:function size:0x90 +draw__20dLytMeterContainer_cFv = .text:0x800D95E0; // type:function size:0x90 fn_800D9670 = .text:0x800D9670; // type:function size:0x8 fn_800D9680 = .text:0x800D9680; // type:function size:0x64 fn_800D96F0 = .text:0x800D96F0; // type:function size:0x20 @@ -8591,59 +8591,59 @@ __dt__34sFStateID_c<19dLytBirdGaugeMain_c>Fv = .text:0x80154700; // type:functio __dt__30sFStateID_c<15dLytBirdGauge_c>Fv = .text:0x80154760; // type:function size:0x58 isSameName__30sFStateID_c<15dLytBirdGauge_c>CFPCc = .text:0x801547C0; // type:function size:0x88 isSameName__34sFStateID_c<19dLytBirdGaugeMain_c>CFPCc = .text:0x80154850; // type:function size:0x88 -fn_801548E0 = .text:0x801548E0; // type:function size:0x4 -fn_801548F0 = .text:0x801548F0; // type:function size:0xC -fn_80154900 = .text:0x80154900; // type:function size:0x4 -fn_80154910 = .text:0x80154910; // type:function size:0x4 -fn_80154920 = .text:0x80154920; // type:function size:0x70 -fn_80154990 = .text:0x80154990; // type:function size:0x4 -fn_801549A0 = .text:0x801549A0; // type:function size:0x4 -fn_801549B0 = .text:0x801549B0; // type:function size:0xC -fn_801549C0 = .text:0x801549C0; // type:function size:0x4 -fn_801549D0 = .text:0x801549D0; // type:function size:0x4 -fn_801549E0 = .text:0x801549E0; // type:function size:0x70 -fn_80154A50 = .text:0x80154A50; // type:function size:0x4 +initializeState_ModeNone__18dLytSkyGaugeMain_cFv = .text:0x801548E0; // type:function size:0x4 +executeState_ModeNone__18dLytSkyGaugeMain_cFv = .text:0x801548F0; // type:function size:0xC +finalizeState_ModeNone__18dLytSkyGaugeMain_cFv = .text:0x80154900; // type:function size:0x4 +initializeState_ModeIn__18dLytSkyGaugeMain_cFv = .text:0x80154910; // type:function size:0x4 +executeState_ModeIn__18dLytSkyGaugeMain_cFv = .text:0x80154920; // type:function size:0x70 +finalizeState_ModeIn__18dLytSkyGaugeMain_cFv = .text:0x80154990; // type:function size:0x4 +initializeState_ModeMove__18dLytSkyGaugeMain_cFv = .text:0x801549A0; // type:function size:0x4 +executeState_ModeMove__18dLytSkyGaugeMain_cFv = .text:0x801549B0; // type:function size:0xC +finalizeState_ModeMove__18dLytSkyGaugeMain_cFv = .text:0x801549C0; // type:function size:0x4 +initializeState_ModeOut__18dLytSkyGaugeMain_cFv = .text:0x801549D0; // type:function size:0x4 +executeState_ModeOut__18dLytSkyGaugeMain_cFv = .text:0x801549E0; // type:function size:0x70 +finalizeState_ModeOut__18dLytSkyGaugeMain_cFv = .text:0x80154A50; // type:function size:0x4 __ct__18dLytSkyGaugeMain_cFv = .text:0x80154A60; // type:function size:0xD8 -fn_80154B40 = .text:0x80154B40; // type:function size:0x10C -fn_80154C50 = .text:0x80154C50; // type:function size:0xC4 -fn_80154D20 = .text:0x80154D20; // type:function size:0x10 -fn_80154D30 = .text:0x80154D30; // type:function size:0x5C -fn_80154D90 = .text:0x80154D90; // type:function size:0x4C -fn_80154DE0 = .text:0x80154DE0; // type:function size:0x10 -fn_80154DF0 = .text:0x80154DF0; // type:function size:0x80 -fn_80154E70 = .text:0x80154E70; // type:function size:0x4C -fn_80154EC0 = .text:0x80154EC0; // type:function size:0x80 -fn_80154F40 = .text:0x80154F40; // type:function size:0x84 -fn_80154FD0 = .text:0x80154FD0; // type:function size:0x4 -fn_80154FE0 = .text:0x80154FE0; // type:function size:0x60 -fn_80155040 = .text:0x80155040; // type:function size:0x4 -fn_80155050 = .text:0x80155050; // type:function size:0x4 -fn_80155060 = .text:0x80155060; // type:function size:0x58 -fn_801550C0 = .text:0x801550C0; // type:function size:0x4 -fn_801550D0 = .text:0x801550D0; // type:function size:0x4 -fn_801550E0 = .text:0x801550E0; // type:function size:0x60 -fn_80155140 = .text:0x80155140; // type:function size:0x4 -fn_80155150 = .text:0x80155150; // type:function size:0x4 -fn_80155160 = .text:0x80155160; // type:function size:0x58 -fn_801551C0 = .text:0x801551C0; // type:function size:0x4 -fn_801551D0 = .text:0x801551D0; // type:function size:0x60 -fn_80155230 = .text:0x80155230; // type:function size:0x48 -fn_80155280 = .text:0x80155280; // type:function size:0x28 -fn_801552B0 = .text:0x801552B0; // type:function size:0x8 -fn_801552C0 = .text:0x801552C0; // type:function size:0x8 -fn_801552D0 = .text:0x801552D0; // type:function size:0x8 -fn_801552E0 = .text:0x801552E0; // type:function size:0x60 -fn_80155340 = .text:0x80155340; // type:function size:0xC -fn_80155350 = .text:0x80155350; // type:function size:0x1C -fn_80155370 = .text:0x80155370; // type:function size:0x1C -fn_80155390 = .text:0x80155390; // type:function size:0x1C -fn_801553B0 = .text:0x801553B0; // type:function size:0x10 -fn_801553C0 = .text:0x801553C0; // type:function size:0x10 -fn_801553D0 = .text:0x801553D0; // type:function size:0x10 -fn_801553E0 = .text:0x801553E0; // type:function size:0x10 -fn_801553F0 = .text:0x801553F0; // type:function size:0x10 -fn_80155400 = .text:0x80155400; // type:function size:0x10 -fn_80155410 = .text:0x80155410; // type:function size:0x10 +build__18dLytSkyGaugeMain_cFPQ23d2d10ResAccIf_c = .text:0x80154B40; // type:function size:0x10C +execute__18dLytSkyGaugeMain_cFv = .text:0x80154C50; // type:function size:0xC4 +executeState__87sStateMgr_c<18dLytSkyGaugeMain_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x80154D20; // type:function size:0x10 +remove__18dLytSkyGaugeMain_cFv = .text:0x80154D30; // type:function size:0x5C +changeToNone__18dLytSkyGaugeMain_cFv = .text:0x80154D90; // type:function size:0x4C +changeState__87sStateMgr_c<18dLytSkyGaugeMain_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x80154DE0; // type:function size:0x10 +changeToIn__18dLytSkyGaugeMain_cFv = .text:0x80154DF0; // type:function size:0x80 +changeToMove__18dLytSkyGaugeMain_cFv = .text:0x80154E70; // type:function size:0x4C +changeToOut__18dLytSkyGaugeMain_cFv = .text:0x80154EC0; // type:function size:0x80 +setHeight__18dLytSkyGaugeMain_cFf = .text:0x80154F40; // type:function size:0x84 +initializeState_None__14dLytSkyGauge_cFv = .text:0x80154FD0; // type:function size:0x4 +executeState_None__14dLytSkyGauge_cFv = .text:0x80154FE0; // type:function size:0x60 +finalizeState_None__14dLytSkyGauge_cFv = .text:0x80155040; // type:function size:0x4 +initializeState_In__14dLytSkyGauge_cFv = .text:0x80155050; // type:function size:0x4 +executeState_In__14dLytSkyGauge_cFv = .text:0x80155060; // type:function size:0x58 +finalizeState_In__14dLytSkyGauge_cFv = .text:0x801550C0; // type:function size:0x4 +initializeState_Move__14dLytSkyGauge_cFv = .text:0x801550D0; // type:function size:0x4 +executeState_Move__14dLytSkyGauge_cFv = .text:0x801550E0; // type:function size:0x60 +finalizeState_Move__14dLytSkyGauge_cFv = .text:0x80155140; // type:function size:0x4 +initializeState_Out__14dLytSkyGauge_cFv = .text:0x80155150; // type:function size:0x4 +executeState_Out__14dLytSkyGauge_cFv = .text:0x80155160; // type:function size:0x58 +finalizeState_Out__14dLytSkyGauge_cFv = .text:0x801551C0; // type:function size:0x4 +build__14dLytSkyGauge_cFPQ23d2d10ResAccIf_c = .text:0x801551D0; // type:function size:0x60 +LytMeter0x14__14dLytSkyGauge_cFv = .text:0x80155230; // type:function size:0x48 +remove__14dLytSkyGauge_cFv = .text:0x80155280; // type:function size:0x28 +setHeight__14dLytSkyGauge_cFf = .text:0x801552B0; // type:function size:0x8 +getName__14dLytSkyGauge_cCFv = .text:0x801552C0; // type:function size:0x8 +getPane__14dLytSkyGauge_cFv = .text:0x801552D0; // type:function size:0x8 +build__34sFStateFct_c<18dLytSkyGaugeMain_c>FRC12sStateIDIf_c = .text:0x801552E0; // type:function size:0x60 +dispose__34sFStateFct_c<18dLytSkyGaugeMain_c>FRP10sStateIf_c = .text:0x80155340; // type:function size:0xC +initialize__31sFState_c<18dLytSkyGaugeMain_c>Fv = .text:0x80155350; // type:function size:0x1C +execute__31sFState_c<18dLytSkyGaugeMain_c>Fv = .text:0x80155370; // type:function size:0x1C +finalize__31sFState_c<18dLytSkyGaugeMain_c>Fv = .text:0x80155390; // type:function size:0x1C +initializeState__87sStateMgr_c<18dLytSkyGaugeMain_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x801553B0; // type:function size:0x10 +finalizeState__87sStateMgr_c<18dLytSkyGaugeMain_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x801553C0; // type:function size:0x10 +refreshState__87sStateMgr_c<18dLytSkyGaugeMain_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x801553D0; // type:function size:0x10 +getState__87sStateMgr_c<18dLytSkyGaugeMain_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x801553E0; // type:function size:0x10 +getNewStateID__87sStateMgr_c<18dLytSkyGaugeMain_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x801553F0; // type:function size:0x10 +getStateID__87sStateMgr_c<18dLytSkyGaugeMain_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x80155400; // type:function size:0x10 +getOldStateID__87sStateMgr_c<18dLytSkyGaugeMain_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x80155410; // type:function size:0x10 finalizeState__33sFStateID_c<18dLytSkyGaugeMain_c>CFR18dLytSkyGaugeMain_c = .text:0x80155420; // type:function size:0x30 executeState__33sFStateID_c<18dLytSkyGaugeMain_c>CFR18dLytSkyGaugeMain_c = .text:0x80155450; // type:function size:0x30 initializeState__33sFStateID_c<18dLytSkyGaugeMain_c>CFR18dLytSkyGaugeMain_c = .text:0x80155480; // type:function size:0x30 @@ -32905,11 +32905,11 @@ lbl_8052454C = .data:0x8052454C; // type:object size:0x18 lbl_80524564 = .data:0x80524564; // type:object size:0xC lbl_80524570 = .data:0x80524570; // type:object size:0x14 __vt__14dLytSkyGauge_c = .data:0x80524584; // type:object size:0x34 -lbl_805245B8 = .data:0x805245B8; // type:object size:0x10 -lbl_805245C8 = .data:0x805245C8; // type:object size:0x30 -lbl_805245F8 = .data:0x805245F8; // type:object size:0x30 -lbl_80524628 = .data:0x80524628; // type:object size:0x18 -lbl_80524640 = .data:0x80524640; // type:object size:0x27C +__vt__18dLytSkyGaugeMain_c = .data:0x805245B8; // type:object size:0xC +__vt__57sFStateMgr_c<18dLytSkyGaugeMain_c,20sStateMethodUsr_FI_c> = .data:0x805245C8; // type:object size:0x30 +__vt__87sStateMgr_c<18dLytSkyGaugeMain_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c> = .data:0x805245F8; // type:object size:0x30 +__vt__34sFStateFct_c<18dLytSkyGaugeMain_c> = .data:0x80524628; // type:object size:0x14 +__vt__31sFState_c<18dLytSkyGaugeMain_c> = .data:0x80524640; // type:object size:0x18 __vt__29sFStateID_c<14dLytSkyGauge_c> = .data:0x805248BC; // type:object size:0x34 __vt__33sFStateID_c<18dLytSkyGaugeMain_c> = .data:0x805248F0; // type:object size:0x34 lbl_80524928 = .data:0x80524928; // type:object size:0x1C data:string @@ -39981,7 +39981,7 @@ LytWipe = .sbss:0x805754C8; // type:object size:0x8 data:4byte LYT_HELP_PTR = .sbss:0x805754D0; // type:object size:0x8 data:4byte lbl_805754D8 = .sbss:0x805754D8; // type:object size:0x8 data:4byte lbl_805754E0 = .sbss:0x805754E0; // type:object size:0x8 data:4byte -lbl_805754E8 = .sbss:0x805754E8; // type:object size:0x8 data:4byte +sInstance__14dLytSkyGauge_c = .sbss:0x805754E8; // type:object size:0x4 data:4byte lbl_805754F0 = .sbss:0x805754F0; // type:object size:0x8 data:4byte sInstance__17dLytCursorStick_c = .sbss:0x805754F8; // type:object size:0x8 data:4byte GLOBAL_FI_CONTEXT = .sbss:0x80575500; // type:object size:0x4 data:4byte @@ -48712,15 +48712,15 @@ lbl_805B1080 = .bss:0x805B1080; // type:object size:0x40 data:4byte LytBirdGaugeMain__STATE_MODE_OUT = .bss:0x805B10C0; // type:object size:0x80 data:4byte LytBirdGauge__STATE_NONE = .bss:0x805B1140; // type:object size:0xC0 data:4byte LytBirdGauge__STATE_OUT = .bss:0x805B1200; // type:object size:0x30 data:4byte -lbl_805B1230 = .bss:0x805B1230; // type:object size:0x10 -LytSkyGaugeMain__STATE_MODE_NONE = .bss:0x805B1240; // type:object size:0x40 data:4byte -LytSkyGaugeMain__STATE_MODE_IN = .bss:0x805B1280; // type:object size:0x40 data:4byte -LytSkyGaugeMain__STATE_MODE_MOVE = .bss:0x805B12C0; // type:object size:0x40 data:4byte -LytSkyGaugeMain__STATE_MODE_OUT = .bss:0x805B1300; // type:object size:0x40 data:4byte -LytSkyGauge__STATE_NONE = .bss:0x805B1340; // type:object size:0x40 data:4byte -LytSkyGauge__STATE_IN = .bss:0x805B1380; // type:object size:0x40 data:4byte -LytSkyGauge__STATE_MOVE = .bss:0x805B13C0; // type:object size:0x40 data:4byte -LytSkyGauge__STATE_OUT = .bss:0x805B1400; // type:object size:0x30 data:4byte +lbl_805B1230 = .bss:0x805B1230; // type:object size:0xC scope:local +StateID_ModeNone__18dLytSkyGaugeMain_c = .bss:0x805B1240; // type:object size:0x30 data:4byte +StateID_ModeIn__18dLytSkyGaugeMain_c = .bss:0x805B1280; // type:object size:0x30 data:4byte +StateID_ModeMove__18dLytSkyGaugeMain_c = .bss:0x805B12C0; // type:object size:0x30 data:4byte +StateID_ModeOut__18dLytSkyGaugeMain_c = .bss:0x805B1300; // type:object size:0x30 data:4byte +StateID_None__14dLytSkyGauge_c = .bss:0x805B1340; // type:object size:0x30 data:4byte +StateID_In__14dLytSkyGauge_c = .bss:0x805B1380; // type:object size:0x30 data:4byte +StateID_Move__14dLytSkyGauge_c = .bss:0x805B13C0; // type:object size:0x30 data:4byte +StateID_Out__14dLytSkyGauge_c = .bss:0x805B1400; // type:object size:0x30 data:4byte lbl_805B1430 = .bss:0x805B1430; // type:object size:0x10 LytDepositStock__STATE_NONE = .bss:0x805B1440; // type:object size:0x30 data:4byte lbl_805B1470 = .bss:0x805B1470; // type:object size:0x10 diff --git a/configure.py b/configure.py index 549c3460..474e5cd1 100644 --- a/configure.py +++ b/configure.py @@ -408,7 +408,7 @@ config.libs = [ Object(NonMatching, "d/lyt/d_lyt_wipe.cpp"), Object(NonMatching, "d/lyt/d_lyt_help.cpp"), Object(NonMatching, "d/lyt/d_lyt_bird_gauge.cpp"), - Object(NonMatching, "d/lyt/d_lyt_sky_gauge.cpp"), + Object(Matching, "d/lyt/d_lyt_sky_gauge.cpp"), Object(NonMatching, "d/lyt/d_lyt_boss_gauge.cpp"), Object(NonMatching, "d/lyt/d_lyt_pause_disp_00.cpp"), Object(Matching, "d/lyt/d_lyt_fader.cpp"), diff --git a/include/d/lyt/d2d.h b/include/d/lyt/d2d.h index 0e037a61..9747f09c 100644 --- a/include/d/lyt/d2d.h +++ b/include/d/lyt/d2d.h @@ -228,6 +228,10 @@ struct AnmGroupBase_c { return (mFlags & 2) != 0; } + inline bool isStop() const { + return mpFrameCtrl->isStop(); + } + inline bool isStop2() const { return mpFrameCtrl->isStop2(); } diff --git a/include/d/lyt/d_lyt_sky_gauge.h b/include/d/lyt/d_lyt_sky_gauge.h index 2f2292d1..0e3b550d 100644 --- a/include/d/lyt/d_lyt_sky_gauge.h +++ b/include/d/lyt/d_lyt_sky_gauge.h @@ -2,23 +2,50 @@ #define D_LYT_SKY_GAUGE_H #include "d/lyt/d2d.h" -#include "m/m_color.h" #include "s/s_State.hpp" #include "s/s_StateMgr.hpp" +class dLytSkyGauge_c; + class dLytSkyGaugeMain_c { public: dLytSkyGaugeMain_c(); virtual ~dLytSkyGaugeMain_c() {} + + bool build(d2d::ResAccIf_c *resAcc); + bool execute(); + bool remove(); + + void changeToIn(); + void changeToMove(); + void changeToNone(); + void changeToOut(); + + void setHeight(f32 height); + + bool wantsMove() { + return mWantsModeChange; + } + + const d2d::dLytSub &getLyt() const { + return mLyt; + } + + d2d::dLytSub &getLyt() { + return mLyt; + } + private: STATE_FUNC_DECLARE(dLytSkyGaugeMain_c, ModeNone); STATE_FUNC_DECLARE(dLytSkyGaugeMain_c, ModeIn); STATE_FUNC_DECLARE(dLytSkyGaugeMain_c, ModeMove); STATE_FUNC_DECLARE(dLytSkyGaugeMain_c, ModeOut); - /* 0x04 */ UI_STATE_MGR_DECLARE(dLytSkyGaugeMain_c); - /* 0x40 */ d2d::dLytSub mLyt; - /* 0xD4 */ d2d::AnmGroup_c mAnmGroups[3]; + /* 0x004 */ UI_STATE_MGR_DECLARE(dLytSkyGaugeMain_c); + /* 0x040 */ d2d::dLytSub mLyt; + /* 0x0D4 */ d2d::AnmGroup_c mAnmGroups[3]; + /* 0x194 */ bool mWantsModeChange; + /* 0x195 */ bool field_0x195; // unused }; class dLytSkyGauge_c : public d2d::dSubPane { @@ -27,21 +54,33 @@ public: virtual bool build(d2d::ResAccIf_c *resAcc) override; virtual bool remove() override; virtual bool LytMeter0x14() 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 mMain.getLyt().getLayout()->GetRootPane(); + } + virtual d2d::LytBase_c *getLyt() override { + return &mMain.getLyt(); + } + virtual const char *getName() const override { + return mMain.getLyt().getName(); + } virtual ~dLytSkyGauge_c() {} + void setHeight(f32 height); + + static dLytSkyGauge_c *sInstance; + private: - STATE_FUNC_DECLARE(dLytSkyGauge_c, ModeNone); - STATE_FUNC_DECLARE(dLytSkyGauge_c, ModeIn); - STATE_FUNC_DECLARE(dLytSkyGauge_c, ModeMove); - STATE_FUNC_DECLARE(dLytSkyGauge_c, ModeOut); + STATE_FUNC_DECLARE(dLytSkyGauge_c, None); + STATE_FUNC_DECLARE(dLytSkyGauge_c, In); + STATE_FUNC_DECLARE(dLytSkyGauge_c, Move); + STATE_FUNC_DECLARE(dLytSkyGauge_c, Out); /* 0x008 */ UI_STATE_MGR_DECLARE(dLytSkyGauge_c); /* 0x008 */ d2d::ResAccIf_c mResAcc; /* 0x3B4 */ dLytSkyGaugeMain_c mMain; + /* 0x54C */ bool mWantsIn; + /* 0x54D */ bool mWantsOut; }; #endif diff --git a/src/d/lyt/d_lyt_sky_gauge.cpp b/src/d/lyt/d_lyt_sky_gauge.cpp index e1d09e5c..0ce4a0b6 100644 --- a/src/d/lyt/d_lyt_sky_gauge.cpp +++ b/src/d/lyt/d_lyt_sky_gauge.cpp @@ -1,11 +1,203 @@ #include "d/lyt/d_lyt_sky_gauge.h" +#include "common.h" +#include "s/s_StateID.hpp" + STATE_DEFINE(dLytSkyGaugeMain_c, ModeNone); STATE_DEFINE(dLytSkyGaugeMain_c, ModeIn); STATE_DEFINE(dLytSkyGaugeMain_c, ModeMove); STATE_DEFINE(dLytSkyGaugeMain_c, ModeOut); -STATE_DEFINE(dLytSkyGauge_c, ModeNone); -STATE_DEFINE(dLytSkyGauge_c, ModeIn); -STATE_DEFINE(dLytSkyGauge_c, ModeMove); -STATE_DEFINE(dLytSkyGauge_c, ModeOut); +STATE_DEFINE(dLytSkyGauge_c, None); +STATE_DEFINE(dLytSkyGauge_c, In); +STATE_DEFINE(dLytSkyGauge_c, Move); +STATE_DEFINE(dLytSkyGauge_c, Out); + +static const d2d::LytBrlanMapping brlanMap[] = { + { "skyGauge_00_in.brlan", "G_inOut_00"}, + { "skyGauge_00_out.brlan", "G_inOut_00"}, + {"skyGauge_00_move.brlan", "G_move_00"}, +}; + +#define LYT_SKY_GAUGE_MAIN_ANIM_IN 0 +#define LYT_SKY_GAUGE_MAIN_ANIM_OUT 1 +#define LYT_SKY_GAUGE_MAIN_ANIM_LOOP 2 + +dLytSkyGauge_c *dLytSkyGauge_c::sInstance; + +void dLytSkyGaugeMain_c::initializeState_ModeNone() {} +void dLytSkyGaugeMain_c::executeState_ModeNone() { + mWantsModeChange = true; +} +void dLytSkyGaugeMain_c::finalizeState_ModeNone() {} + +void dLytSkyGaugeMain_c::initializeState_ModeIn() {} +void dLytSkyGaugeMain_c::executeState_ModeIn() { + if (!mWantsModeChange) { + if (mAnmGroups[LYT_SKY_GAUGE_MAIN_ANIM_IN].isEndReached()) { + mAnmGroups[LYT_SKY_GAUGE_MAIN_ANIM_IN].setAnimEnable(false); + mWantsModeChange = true; + } + } +} +void dLytSkyGaugeMain_c::finalizeState_ModeIn() {} + +void dLytSkyGaugeMain_c::initializeState_ModeMove() {} +void dLytSkyGaugeMain_c::executeState_ModeMove() { + mWantsModeChange = true; +} +void dLytSkyGaugeMain_c::finalizeState_ModeMove() {} + +void dLytSkyGaugeMain_c::initializeState_ModeOut() {} +void dLytSkyGaugeMain_c::executeState_ModeOut() { + if (!mWantsModeChange) { + if (mAnmGroups[LYT_SKY_GAUGE_MAIN_ANIM_OUT].isEndReached()) { + mAnmGroups[LYT_SKY_GAUGE_MAIN_ANIM_OUT].setAnimEnable(false); + mWantsModeChange = true; + } + } +} +void dLytSkyGaugeMain_c::finalizeState_ModeOut() {} + +dLytSkyGaugeMain_c::dLytSkyGaugeMain_c() : mStateMgr(*this, sStateID::null) {} + +bool dLytSkyGaugeMain_c::build(d2d::ResAccIf_c *resAcc) { + mLyt.setResAcc(resAcc); + mLyt.build("skyGauge_00.brlyt", nullptr); + mLyt.setPriority(0x8A); + + for (int i = 0; i < 3; i++) { + mAnmGroups[i].init(brlanMap[i].mFile, resAcc, mLyt.getLayout(), brlanMap[i].mName); + mAnmGroups[i].setDirection(false); + mAnmGroups[i].setAnimEnable(false); + } + + mAnmGroups[LYT_SKY_GAUGE_MAIN_ANIM_IN].setAnimEnable(true); + mAnmGroups[LYT_SKY_GAUGE_MAIN_ANIM_IN].setFrame(0.0f); + mLyt.calc(); + mAnmGroups[LYT_SKY_GAUGE_MAIN_ANIM_IN].setAnimEnable(false); + mAnmGroups[LYT_SKY_GAUGE_MAIN_ANIM_LOOP].setAnimEnable(false); + field_0x195 = false; + return true; +} + +bool dLytSkyGaugeMain_c::execute() { + mStateMgr.executeState(); + + for (int i = 0; i < 2; i++) { + if (mAnmGroups[i].isFlag2()) { + if (mAnmGroups[i].isStop()) { + mAnmGroups[i].setAnimEnable(false); + if (i == 0) { + field_0x195 = true; + } + } + mAnmGroups[i].play(); + } + } + + mLyt.calc(); + + return true; +} + +bool dLytSkyGaugeMain_c::remove() { + mLyt.unbindAnims(); + for (int i = 0; i < 3; i++) { + mAnmGroups[i].afterUnbind(); + } + + return true; +} + +void dLytSkyGaugeMain_c::changeToNone() { + mStateMgr.changeState(StateID_ModeNone); + mWantsModeChange = false; +} + +void dLytSkyGaugeMain_c::changeToIn() { + mAnmGroups[LYT_SKY_GAUGE_MAIN_ANIM_IN].setAnimEnable(true); + mAnmGroups[LYT_SKY_GAUGE_MAIN_ANIM_IN].setFrame(0.0f); + mLyt.calc(); + mStateMgr.changeState(StateID_ModeIn); + mWantsModeChange = false; +} + +void dLytSkyGaugeMain_c::changeToMove() { + mStateMgr.changeState(StateID_ModeMove); + mWantsModeChange = false; +} + +void dLytSkyGaugeMain_c::changeToOut() { + mAnmGroups[LYT_SKY_GAUGE_MAIN_ANIM_OUT].setAnimEnable(true); + mAnmGroups[LYT_SKY_GAUGE_MAIN_ANIM_OUT].setFrame(0.0f); + mLyt.calc(); + mStateMgr.changeState(StateID_ModeOut); + mWantsModeChange = false; +} + +void dLytSkyGaugeMain_c::setHeight(f32 height) { + int frame = height * 60.0f + 0.5f; + mAnmGroups[LYT_SKY_GAUGE_MAIN_ANIM_LOOP].setAnimEnable(true); + mAnmGroups[LYT_SKY_GAUGE_MAIN_ANIM_LOOP].setFrame(frame); +} + +void dLytSkyGauge_c::initializeState_None() {} +void dLytSkyGauge_c::executeState_None() { + if (mWantsIn) { + mMain.changeToIn(); + mStateMgr.changeState(StateID_In); + mWantsIn = false; + } +} +void dLytSkyGauge_c::finalizeState_None() {} + +void dLytSkyGauge_c::initializeState_In() {} +void dLytSkyGauge_c::executeState_In() { + if (mMain.wantsMove()) { + mMain.changeToMove(); + mStateMgr.changeState(StateID_Move); + } +} +void dLytSkyGauge_c::finalizeState_In() {} + +void dLytSkyGauge_c::initializeState_Move() {} +void dLytSkyGauge_c::executeState_Move() { + if (mWantsOut) { + mMain.changeToOut(); + mStateMgr.changeState(StateID_Out); + mWantsOut = false; + } +} +void dLytSkyGauge_c::finalizeState_Move() {} + +void dLytSkyGauge_c::initializeState_Out() {} +void dLytSkyGauge_c::executeState_Out() { + if (mMain.wantsMove()) { + mMain.changeToNone(); + mStateMgr.changeState(StateID_None); + } +} +void dLytSkyGauge_c::finalizeState_Out() {} + +bool dLytSkyGauge_c::build(d2d::ResAccIf_c *resAcc) { + sInstance = this; + mMain.build(resAcc); + mWantsIn = false; + mWantsOut = false; + mStateMgr.changeState(StateID_None); + return true; +} +bool dLytSkyGauge_c::LytMeter0x14() { + mMain.execute(); + mStateMgr.executeState(); + return true; +} +bool dLytSkyGauge_c::remove() { + mMain.remove(); + return true; +} + +void dLytSkyGauge_c::setHeight(f32 height) { + mMain.setHeight(height); +}