From 737d19e61eba3e9c4796bb8ec0afb0765c38b55c Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sun, 10 Dec 2023 09:31:09 -0500 Subject: [PATCH] Implement/match rest of MxCompositePresenter --- LEGO1/mxcompositepresenter.cpp | 119 ++++++++++++++++++++++++++++----- LEGO1/mxcompositepresenter.h | 5 +- 2 files changed, 107 insertions(+), 17 deletions(-) diff --git a/LEGO1/mxcompositepresenter.cpp b/LEGO1/mxcompositepresenter.cpp index 6cf14956..da79c38e 100644 --- a/LEGO1/mxcompositepresenter.cpp +++ b/LEGO1/mxcompositepresenter.cpp @@ -1,7 +1,6 @@ #include "mxcompositepresenter.h" #include "decomp.h" -#include "mxactionnotificationparam.h" #include "mxautolocker.h" #include "mxdsmultiaction.h" #include "mxnotificationmanager.h" @@ -133,25 +132,96 @@ MxLong MxCompositePresenter::Notify(MxParam& p) switch (((MxNotificationParam&) p).GetNotification()) { case c_notificationEndAction: - VTable0x58(p); + VTable0x58((MxEndActionNotificationParam&) p); break; case MXPRESENTER_NOTIFICATION: - VTable0x5c(p); + VTable0x5c((MxNotificationParam&) p); } return 0; } -// STUB: LEGO1 0x100b67f0 -void MxCompositePresenter::VTable0x58(MxParam& p) +// FUNCTION: LEGO1 0x100b67f0 +void MxCompositePresenter::VTable0x58(MxEndActionNotificationParam& p) { - // TODO + MxPresenter* presenter = (MxPresenter*) p.GetSender(); + MxDSAction* action = p.GetAction(); + MxCompositePresenterList::iterator it; + + if (!m_list.empty()) { + for (it = m_list.begin(); it != m_list.end(); it++) { + if (*it == presenter) { + m_list.erase(it++); + break; + } + } + } + + if (m_action) { + MxDSActionList* actions = ((MxDSMultiAction*) m_action)->GetActionList(); + MxDSActionListCursor cursor(actions); + + if (cursor.Find(action)) + cursor.Detach(); + } + + if (presenter) + delete presenter; + + if (action) + delete action; + + if (m_list.empty()) { + EndAction(); + } + else { + if (m_action->IsA("MxDSSerialAction") && it != m_list.end()) { + MxPresenter* presenter = *it; + if (presenter->GetCurrentTickleState() == TickleState_Idle) + presenter->SetTickleState(TickleState_Ready); + } + } } -// STUB: LEGO1 0x100b69b0 -void MxCompositePresenter::VTable0x5c(MxParam& p) +// TEMPLATE: LEGO1 0x100b6cd0 +// MxList::_DeleteEntry + +// FUNCTION: LEGO1 0x100b69b0 +void MxCompositePresenter::VTable0x5c(MxNotificationParam& p) { - // TODO + if (!m_list.empty()) { + MxPresenter* presenter = (MxPresenter*) p.GetSender(); + + for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) { + if (*it == presenter) { + m_list.erase(it++); + + if (presenter->GetCurrentTickleState() == TickleState_Idle) + presenter->SetTickleState(TickleState_Ready); + + MxDSActionList* actions = ((MxDSMultiAction*) m_action)->GetActionList(); + MxDSActionListCursor cursor(actions); + + if (cursor.Find(presenter->GetAction())) + cursor.Detach(); + + if (m_list.empty()) { + EndAction(); + } + else { + if (m_action->IsA("MxDSSerialAction")) { + MxPresenter* presenter = *it; + if (presenter->GetCurrentTickleState() == TickleState_Idle) + presenter->SetTickleState(TickleState_Ready); + } + } + + return; + } + } + + NotificationManager()->Send(this, &p); + } } // FUNCTION: LEGO1 0x100b6b40 @@ -173,21 +243,40 @@ void MxCompositePresenter::VTable0x60(MxPresenter* p_presenter) } } -// STUB: LEGO1 0x100b6bc0 +// FUNCTION: LEGO1 0x100b6bc0 void MxCompositePresenter::SetTickleState(TickleState p_tickleState) { - // TODO + m_previousTickleStates |= 1 << (unsigned char) m_currentTickleState; + m_currentTickleState = p_tickleState; + + for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) { + MxPresenter* presenter = *it; + presenter->SetTickleState(p_tickleState); + + if (m_action->IsA("MxDSSerialAction") && p_tickleState == TickleState_Ready) + return; + } } -// STUB: LEGO1 0x100b6c30 +// FUNCTION: LEGO1 0x100b6c30 void MxCompositePresenter::Enable(MxBool p_enable) { - // TODO + MxPresenter::Enable(p_enable); + + for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) { + MxPresenter* presenter = *it; + presenter->Enable(p_enable); + } } -// STUB: LEGO1 0x100b6c80 +// FUNCTION: LEGO1 0x100b6c80 MxBool MxCompositePresenter::HasTickleStatePassed(TickleState p_tickleState) { - // TODO + for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) { + MxPresenter* presenter = *it; + if (!presenter->HasTickleStatePassed(p_tickleState)) + return FALSE; + } + return TRUE; } diff --git a/LEGO1/mxcompositepresenter.h b/LEGO1/mxcompositepresenter.h index 76028765..8b164299 100644 --- a/LEGO1/mxcompositepresenter.h +++ b/LEGO1/mxcompositepresenter.h @@ -2,6 +2,7 @@ #define MXCOMPOSITEPRESENTER_H #include "compat.h" // STL +#include "mxactionnotificationparam.h" #include "mxpresenter.h" class MxCompositePresenterList : public list {}; @@ -31,8 +32,8 @@ class MxCompositePresenter : public MxPresenter { virtual void SetTickleState(TickleState p_tickleState) override; // vtable+0x44 virtual MxBool HasTickleStatePassed(TickleState p_tickleState) override; // vtable+0x48 virtual void Enable(MxBool p_enable) override; // vtable+0x54 - virtual void VTable0x58(MxParam& p); // vtable+0x58 - virtual void VTable0x5c(MxParam& p); // vtable+0x5c + virtual void VTable0x58(MxEndActionNotificationParam& p); // vtable+0x58 + virtual void VTable0x5c(MxNotificationParam& p); // vtable+0x5c virtual void VTable0x60(MxPresenter* p_presenter); // vtable+0x60 virtual MxBool VTable0x64(undefined4 p_unknown); // vtable+0x64