2023-06-29 04:10:08 -04:00
|
|
|
#include "mxcompositepresenter.h"
|
|
|
|
|
2023-07-02 03:00:28 -04:00
|
|
|
#include "decomp.h"
|
2023-12-11 16:35:50 -05:00
|
|
|
#include "mxautolocker.h"
|
|
|
|
#include "mxdsmultiaction.h"
|
2024-03-09 15:07:52 -05:00
|
|
|
#include "mxmisc.h"
|
2023-10-08 11:25:38 -04:00
|
|
|
#include "mxnotificationmanager.h"
|
2023-12-11 16:35:50 -05:00
|
|
|
#include "mxobjectfactory.h"
|
2023-07-02 03:00:28 -04:00
|
|
|
|
|
|
|
DECOMP_SIZE_ASSERT(MxCompositePresenter, 0x4c);
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b60b0
|
2023-06-29 04:10:08 -04:00
|
|
|
MxCompositePresenter::MxCompositePresenter()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
NotificationManager()->Register(this);
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b6390
|
2023-06-29 04:10:08 -04:00
|
|
|
MxCompositePresenter::~MxCompositePresenter()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
NotificationManager()->Unregister(this);
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
2023-11-02 06:54:08 -04:00
|
|
|
|
2023-12-11 16:35:50 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b6410
|
|
|
|
MxResult MxCompositePresenter::StartAction(MxStreamController* p_controller, MxDSAction* p_action)
|
2023-12-07 07:06:44 -05:00
|
|
|
{
|
2023-12-11 16:35:50 -05:00
|
|
|
MxAutoLocker lock(&m_criticalSection);
|
|
|
|
|
|
|
|
MxResult result = FAILURE;
|
|
|
|
MxDSActionList* actions = ((MxDSMultiAction*) p_action)->GetActionList();
|
|
|
|
MxObjectFactory* factory = ObjectFactory();
|
|
|
|
MxDSActionListCursor cursor(actions);
|
|
|
|
MxDSAction* action;
|
|
|
|
|
|
|
|
if (MxPresenter::StartAction(p_controller, p_action) == SUCCESS) {
|
|
|
|
cursor.Head();
|
|
|
|
|
2024-03-01 13:07:07 -05:00
|
|
|
while (cursor.Current(action)) {
|
2023-12-11 16:35:50 -05:00
|
|
|
MxBool success = FALSE;
|
2024-03-01 13:07:07 -05:00
|
|
|
const char* presenterName;
|
|
|
|
MxPresenter* presenter = NULL;
|
|
|
|
|
|
|
|
cursor.Next();
|
2023-12-11 16:35:50 -05:00
|
|
|
|
2024-03-01 13:07:07 -05:00
|
|
|
if (m_action->GetFlags() & MxDSAction::c_looping) {
|
|
|
|
action->SetFlags(action->GetFlags() | MxDSAction::c_looping);
|
|
|
|
}
|
|
|
|
else if (m_action->GetFlags() & MxDSAction::c_bit3) {
|
|
|
|
action->SetFlags(action->GetFlags() | MxDSAction::c_bit3);
|
|
|
|
}
|
2023-12-11 16:35:50 -05:00
|
|
|
|
2024-03-01 13:07:07 -05:00
|
|
|
presenterName = PresenterNameDispatch(*action);
|
|
|
|
presenter = (MxPresenter*) factory->Create(presenterName);
|
2023-12-11 16:35:50 -05:00
|
|
|
|
|
|
|
if (presenter && presenter->AddToManager() == SUCCESS) {
|
|
|
|
presenter->SetCompositePresenter(this);
|
2024-02-01 15:42:10 -05:00
|
|
|
if (presenter->StartAction(p_controller, action) == SUCCESS) {
|
2023-12-11 16:35:50 -05:00
|
|
|
success = TRUE;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-11 16:35:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
action->SetOrigin(this);
|
|
|
|
m_list.push_back(presenter);
|
|
|
|
}
|
2024-02-01 15:42:10 -05:00
|
|
|
else if (presenter) {
|
2023-12-11 16:35:50 -05:00
|
|
|
delete presenter;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-11 16:35:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
result = SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2023-12-07 07:06:44 -05:00
|
|
|
}
|
|
|
|
|
2023-12-11 16:35:50 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b65e0
|
2023-12-07 07:06:44 -05:00
|
|
|
void MxCompositePresenter::EndAction()
|
|
|
|
{
|
2023-12-11 16:35:50 -05:00
|
|
|
MxAutoLocker lock(&m_criticalSection);
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (!m_action) {
|
2023-12-11 16:35:50 -05:00
|
|
|
return;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-11 16:35:50 -05:00
|
|
|
|
|
|
|
((MxDSMultiAction*) m_action)->GetActionList()->DeleteAll(FALSE);
|
|
|
|
|
|
|
|
while (!m_list.empty()) {
|
|
|
|
MxPresenter* presenter = m_list.front();
|
|
|
|
m_list.pop_front();
|
|
|
|
presenter->SetCompositePresenter(NULL);
|
|
|
|
presenter->EndAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
MxDSAction* action = m_action;
|
|
|
|
MxPresenter::EndAction();
|
|
|
|
|
|
|
|
if (action && action->GetOrigin()) {
|
2024-01-07 12:30:45 -05:00
|
|
|
#ifdef COMPAT_MODE
|
|
|
|
{
|
|
|
|
MxEndActionNotificationParam param(c_notificationEndAction, this, action, FALSE);
|
|
|
|
NotificationManager()->Send(action->GetOrigin(), ¶m);
|
|
|
|
}
|
|
|
|
#else
|
2023-12-11 16:35:50 -05:00
|
|
|
NotificationManager()->Send(
|
|
|
|
action->GetOrigin(),
|
|
|
|
&MxEndActionNotificationParam(c_notificationEndAction, this, action, FALSE)
|
|
|
|
);
|
2024-01-07 12:30:45 -05:00
|
|
|
#endif
|
2023-12-11 16:35:50 -05:00
|
|
|
}
|
2023-12-07 07:06:44 -05:00
|
|
|
}
|
|
|
|
|
2023-12-11 16:35:50 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b6760
|
2023-12-13 05:48:14 -05:00
|
|
|
MxLong MxCompositePresenter::Notify(MxParam& p_param)
|
2023-12-07 07:06:44 -05:00
|
|
|
{
|
2023-12-11 16:35:50 -05:00
|
|
|
MxAutoLocker lock(&m_criticalSection);
|
|
|
|
|
2023-12-13 05:48:14 -05:00
|
|
|
switch (((MxNotificationParam&) p_param).GetNotification()) {
|
2023-12-11 16:35:50 -05:00
|
|
|
case c_notificationEndAction:
|
2023-12-13 06:59:22 -05:00
|
|
|
VTable0x58((MxEndActionNotificationParam&) p_param);
|
2023-12-11 16:35:50 -05:00
|
|
|
break;
|
2024-01-17 11:53:53 -05:00
|
|
|
case c_notificationPresenter:
|
2023-12-13 06:59:22 -05:00
|
|
|
VTable0x5c((MxNotificationParam&) p_param);
|
2023-12-11 16:35:50 -05:00
|
|
|
}
|
|
|
|
|
2023-12-07 07:06:44 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-12-13 06:59:22 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b67f0
|
|
|
|
void MxCompositePresenter::VTable0x58(MxEndActionNotificationParam& p_param)
|
2023-11-02 06:54:08 -04:00
|
|
|
{
|
2023-12-13 06:59:22 -05:00
|
|
|
MxPresenter* presenter = (MxPresenter*) p_param.GetSender();
|
|
|
|
MxDSAction* action = p_param.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);
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (cursor.Find(action)) {
|
2023-12-13 06:59:22 -05:00
|
|
|
cursor.Detach();
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-13 06:59:22 -05:00
|
|
|
}
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (presenter) {
|
2023-12-13 06:59:22 -05:00
|
|
|
delete presenter;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-13 06:59:22 -05:00
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (action) {
|
2023-12-13 06:59:22 -05:00
|
|
|
delete action;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-13 06:59:22 -05:00
|
|
|
|
|
|
|
if (m_list.empty()) {
|
|
|
|
EndAction();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (m_action->IsA("MxDSSerialAction") && it != m_list.end()) {
|
|
|
|
MxPresenter* presenter = *it;
|
2024-02-01 15:42:10 -05:00
|
|
|
if (presenter->GetCurrentTickleState() == e_idle) {
|
2024-01-17 11:53:53 -05:00
|
|
|
presenter->SetTickleState(e_ready);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-13 06:59:22 -05:00
|
|
|
}
|
|
|
|
}
|
2023-11-02 06:54:08 -04:00
|
|
|
}
|
|
|
|
|
2023-12-13 06:59:22 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b69b0
|
|
|
|
void MxCompositePresenter::VTable0x5c(MxNotificationParam& p_param)
|
2023-11-02 06:54:08 -04:00
|
|
|
{
|
2023-12-13 06:59:22 -05:00
|
|
|
if (!m_list.empty()) {
|
|
|
|
MxPresenter* presenter = (MxPresenter*) p_param.GetSender();
|
|
|
|
|
|
|
|
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
|
|
|
if (*it == presenter) {
|
|
|
|
m_list.erase(it++);
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (presenter->GetCurrentTickleState() == e_idle) {
|
2024-01-17 11:53:53 -05:00
|
|
|
presenter->SetTickleState(e_ready);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-13 06:59:22 -05:00
|
|
|
|
|
|
|
MxDSActionList* actions = ((MxDSMultiAction*) m_action)->GetActionList();
|
|
|
|
MxDSActionListCursor cursor(actions);
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (cursor.Find(presenter->GetAction())) {
|
2023-12-13 06:59:22 -05:00
|
|
|
cursor.Detach();
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-13 06:59:22 -05:00
|
|
|
|
|
|
|
if (m_list.empty()) {
|
|
|
|
EndAction();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (m_action->IsA("MxDSSerialAction")) {
|
|
|
|
MxPresenter* presenter = *it;
|
2024-02-01 15:42:10 -05:00
|
|
|
if (presenter->GetCurrentTickleState() == e_idle) {
|
2024-01-17 11:53:53 -05:00
|
|
|
presenter->SetTickleState(e_ready);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-13 06:59:22 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NotificationManager()->Send(this, &p_param);
|
|
|
|
}
|
2023-11-02 06:54:08 -04:00
|
|
|
}
|
|
|
|
|
2023-12-07 07:06:44 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b6b40
|
|
|
|
void MxCompositePresenter::VTable0x60(MxPresenter* p_presenter)
|
|
|
|
{
|
|
|
|
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
|
|
|
if (*it == p_presenter) {
|
|
|
|
if (++it == m_list.end()) {
|
2024-02-01 15:42:10 -05:00
|
|
|
if (m_compositePresenter) {
|
2023-12-07 07:06:44 -05:00
|
|
|
m_compositePresenter->VTable0x60(this);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-07 07:06:44 -05:00
|
|
|
}
|
|
|
|
else if (m_action->IsA("MxDSSerialAction")) {
|
|
|
|
MxPresenter* presenter = *it;
|
2024-02-01 15:42:10 -05:00
|
|
|
if (presenter->GetCurrentTickleState() == e_idle) {
|
2024-01-17 11:53:53 -05:00
|
|
|
presenter->SetTickleState(e_ready);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-07 07:06:44 -05:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-13 06:59:22 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b6bc0
|
2023-12-07 07:06:44 -05:00
|
|
|
void MxCompositePresenter::SetTickleState(TickleState p_tickleState)
|
2023-11-02 06:54:08 -04:00
|
|
|
{
|
2024-01-11 10:02:55 -05:00
|
|
|
ProgressTickleState(p_tickleState);
|
2023-12-13 06:59:22 -05:00
|
|
|
|
|
|
|
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
|
|
|
MxPresenter* presenter = *it;
|
|
|
|
presenter->SetTickleState(p_tickleState);
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (m_action->IsA("MxDSSerialAction") && p_tickleState == e_ready) {
|
2023-12-13 06:59:22 -05:00
|
|
|
return;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-13 06:59:22 -05:00
|
|
|
}
|
2023-11-02 06:54:08 -04:00
|
|
|
}
|
2023-12-07 07:06:44 -05:00
|
|
|
|
2023-12-13 06:59:22 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b6c30
|
2023-12-07 07:06:44 -05:00
|
|
|
void MxCompositePresenter::Enable(MxBool p_enable)
|
|
|
|
{
|
2023-12-13 06:59:22 -05:00
|
|
|
MxPresenter::Enable(p_enable);
|
|
|
|
|
|
|
|
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
|
|
|
MxPresenter* presenter = *it;
|
|
|
|
presenter->Enable(p_enable);
|
|
|
|
}
|
2023-12-07 07:06:44 -05:00
|
|
|
}
|
|
|
|
|
2023-12-13 06:59:22 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b6c80
|
2023-12-07 07:06:44 -05:00
|
|
|
MxBool MxCompositePresenter::HasTickleStatePassed(TickleState p_tickleState)
|
|
|
|
{
|
2023-12-13 06:59:22 -05:00
|
|
|
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
|
|
|
MxPresenter* presenter = *it;
|
2024-02-01 15:42:10 -05:00
|
|
|
if (!presenter->HasTickleStatePassed(p_tickleState)) {
|
2023-12-13 06:59:22 -05:00
|
|
|
return FALSE;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-13 06:59:22 -05:00
|
|
|
}
|
|
|
|
|
2023-12-07 07:06:44 -05:00
|
|
|
return TRUE;
|
|
|
|
}
|