2023-06-29 04:10:08 -04:00
|
|
|
#include "legoanimmmpresenter.h"
|
|
|
|
|
2024-03-20 17:11:40 -04:00
|
|
|
#include "decomp.h"
|
2024-04-20 09:32:10 -04:00
|
|
|
#include "define.h"
|
|
|
|
#include "legoanimationmanager.h"
|
|
|
|
#include "legotraninfo.h"
|
2024-03-20 17:11:40 -04:00
|
|
|
#include "legovideomanager.h"
|
|
|
|
#include "legoworld.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "mxautolock.h"
|
|
|
|
#include "mxdsmultiaction.h"
|
|
|
|
#include "mxmisc.h"
|
|
|
|
#include "mxnotificationmanager.h"
|
|
|
|
#include "mxobjectfactory.h"
|
2024-04-20 10:07:58 -04:00
|
|
|
#include "mxtimer.h"
|
2024-04-20 09:32:10 -04:00
|
|
|
#include "mxutilities.h"
|
2024-03-20 17:11:40 -04:00
|
|
|
|
|
|
|
DECOMP_SIZE_ASSERT(LegoAnimMMPresenter, 0x74)
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x1004a8d0
|
2023-06-29 04:10:08 -04:00
|
|
|
LegoAnimMMPresenter::LegoAnimMMPresenter()
|
|
|
|
{
|
2024-03-20 17:11:40 -04:00
|
|
|
m_unk0x4c = NULL;
|
2024-04-20 09:32:10 -04:00
|
|
|
m_animmanId = 0;
|
|
|
|
m_unk0x59 = FALSE;
|
|
|
|
m_tranInfo = NULL;
|
2024-03-20 17:11:40 -04:00
|
|
|
m_unk0x54 = 0;
|
|
|
|
m_unk0x64 = NULL;
|
|
|
|
m_unk0x68 = 0;
|
|
|
|
m_unk0x6c = 0;
|
|
|
|
m_unk0x70 = 0;
|
|
|
|
m_unk0x58 = 0;
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
2024-01-20 18:04:46 -05:00
|
|
|
|
2024-03-20 17:11:40 -04:00
|
|
|
// FUNCTION: LEGO1 0x1004aaf0
|
2024-01-20 18:04:46 -05:00
|
|
|
MxResult LegoAnimMMPresenter::StartAction(MxStreamController* p_controller, MxDSAction* p_action)
|
|
|
|
{
|
2024-03-20 17:11:40 -04:00
|
|
|
AUTOLOCK(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();
|
|
|
|
|
|
|
|
while (cursor.Current(action)) {
|
|
|
|
MxBool success = FALSE;
|
|
|
|
const char* presenterName;
|
|
|
|
MxPresenter* presenter = NULL;
|
|
|
|
|
|
|
|
cursor.Next();
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
presenterName = PresenterNameDispatch(*action);
|
|
|
|
presenter = (MxPresenter*) factory->Create(presenterName);
|
|
|
|
|
|
|
|
if (presenter && presenter->AddToManager() == SUCCESS) {
|
|
|
|
presenter->SetCompositePresenter(this);
|
|
|
|
if (presenter->StartAction(p_controller, action) == SUCCESS) {
|
|
|
|
presenter->SetTickleState(MxPresenter::e_idle);
|
|
|
|
|
|
|
|
if (presenter->IsA("LegoAnimPresenter") || presenter->IsA("LegoLoopingAnimPresenter")) {
|
2024-04-20 09:52:10 -04:00
|
|
|
m_unk0x4c = (LegoAnimPresenter*) presenter;
|
2024-03-20 17:11:40 -04:00
|
|
|
}
|
|
|
|
success = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
action->SetOrigin(this);
|
|
|
|
m_list.push_back(presenter);
|
|
|
|
}
|
|
|
|
else if (presenter) {
|
|
|
|
delete presenter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_unk0x64 = CurrentWorld();
|
|
|
|
if (m_unk0x64) {
|
|
|
|
m_unk0x64->Add(this);
|
|
|
|
}
|
|
|
|
VideoManager()->RegisterPresenter(*this);
|
|
|
|
|
|
|
|
result = SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// STUB: LEGO1 0x1004aec0
|
|
|
|
void LegoAnimMMPresenter::EndAction()
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2024-04-20 09:52:10 -04:00
|
|
|
// FUNCTION: LEGO1 0x1004b140
|
|
|
|
// FUNCTION: BETA10 0x1004c197
|
2024-01-20 18:04:46 -05:00
|
|
|
void LegoAnimMMPresenter::ReadyTickle()
|
|
|
|
{
|
2024-04-20 09:52:10 -04:00
|
|
|
ParseExtra();
|
|
|
|
|
|
|
|
if (m_tranInfo != NULL && m_tranInfo->m_unk0x15 && m_tranInfo->m_unk0x1c != NULL &&
|
|
|
|
m_tranInfo->m_unk0x1c[0] != NULL) {
|
|
|
|
m_tranInfo->m_unk0x1c[0]->Enable(FALSE);
|
|
|
|
m_tranInfo->m_unk0x1c[0]->Enable(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_tranInfo != NULL && m_tranInfo->m_unk0x0c != NULL) {
|
|
|
|
m_unk0x4c->VTable0xa0(m_tranInfo->m_unk0x0c);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_unk0x4c != NULL) {
|
|
|
|
m_unk0x4c->SetTickleState(e_ready);
|
|
|
|
}
|
|
|
|
|
|
|
|
ProgressTickleState(e_starting);
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-04-20 10:07:58 -04:00
|
|
|
// FUNCTION: LEGO1 0x1004b1c0
|
|
|
|
// FUNCTION: BETA10 0x1004c2cc
|
2024-01-20 18:04:46 -05:00
|
|
|
void LegoAnimMMPresenter::StartingTickle()
|
|
|
|
{
|
2024-04-20 10:07:58 -04:00
|
|
|
if (m_unk0x4c == NULL || m_unk0x4c->GetCurrentTickleState() == e_idle) {
|
|
|
|
if (m_tranInfo != NULL && m_tranInfo->m_unk0x08 != NULL) {
|
|
|
|
m_unk0x4c->FUN_1006b140(m_tranInfo->m_unk0x08);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_unk0x50 = Timer()->GetTime();
|
|
|
|
ProgressTickleState(e_streaming);
|
|
|
|
}
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// STUB: LEGO1 0x1004b220
|
|
|
|
void LegoAnimMMPresenter::StreamingTickle()
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
// STUB: LEGO1 0x1004b250
|
|
|
|
void LegoAnimMMPresenter::RepeatingTickle()
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2024-03-20 17:11:40 -04:00
|
|
|
// FUNCTION: LEGO1 0x1004b2c0
|
2024-01-20 18:04:46 -05:00
|
|
|
void LegoAnimMMPresenter::DoneTickle()
|
|
|
|
{
|
2024-03-20 17:11:40 -04:00
|
|
|
// Empty
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// STUB: LEGO1 0x1004b2d0
|
|
|
|
MxLong LegoAnimMMPresenter::Notify(MxParam& p_param)
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2024-03-20 17:11:40 -04:00
|
|
|
// FUNCTION: LEGO1 0x1004b360
|
2024-01-20 18:04:46 -05:00
|
|
|
void LegoAnimMMPresenter::VTable0x60(MxPresenter* p_presenter)
|
|
|
|
{
|
2024-03-20 17:11:40 -04:00
|
|
|
if (m_unk0x4c == p_presenter && ((MxU8) p_presenter->GetCurrentTickleState() == MxPresenter::e_streaming ||
|
|
|
|
(MxU8) p_presenter->GetCurrentTickleState() == MxPresenter::e_done)) {
|
|
|
|
p_presenter->SetTickleState(MxPresenter::e_idle);
|
|
|
|
}
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-04-20 09:32:10 -04:00
|
|
|
// FUNCTION: LEGO1 0x1004b390
|
|
|
|
// FUNCTION: BETA10 0x1004c5be
|
2024-01-20 18:04:46 -05:00
|
|
|
void LegoAnimMMPresenter::ParseExtra()
|
|
|
|
{
|
2024-04-20 09:32:10 -04:00
|
|
|
MxU16 extraLength;
|
|
|
|
char* extraData;
|
|
|
|
m_action->GetExtra(extraLength, extraData);
|
|
|
|
|
|
|
|
if (extraLength & MAXWORD) {
|
|
|
|
char extraCopy[1024];
|
|
|
|
memcpy(extraCopy, extraData, extraLength & MAXWORD);
|
|
|
|
extraCopy[extraLength & MAXWORD] = '\0';
|
|
|
|
|
|
|
|
char output[1024];
|
|
|
|
if (KeyValueStringParse(output, g_strANIMMAN_ID, extraCopy)) {
|
|
|
|
char* token = strtok(output, g_parseExtraTokens);
|
|
|
|
m_animmanId = atoi(token);
|
|
|
|
m_tranInfo = AnimationManager()->GetTranInfo(m_animmanId);
|
|
|
|
|
|
|
|
if (m_tranInfo != NULL) {
|
|
|
|
m_unk0x59 = m_tranInfo->m_unk0x10;
|
|
|
|
m_tranInfo->m_presenter = this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
2024-02-27 11:49:31 -05:00
|
|
|
|
2024-04-20 09:32:10 -04:00
|
|
|
// FUNCTION: LEGO1 0x1004b8b0
|
|
|
|
// FUNCTION: BETA10 0x1004d104
|
2024-02-27 11:49:31 -05:00
|
|
|
MxBool LegoAnimMMPresenter::FUN_1004b8b0()
|
|
|
|
{
|
2024-04-20 09:32:10 -04:00
|
|
|
return m_tranInfo != NULL ? m_tranInfo->m_unk0x28 : TRUE;
|
2024-02-27 11:49:31 -05:00
|
|
|
}
|