2023-06-29 04:10:08 -04:00
|
|
|
#include "legoactioncontrolpresenter.h"
|
2023-11-21 05:35:03 -05:00
|
|
|
|
|
|
|
#include "define.h"
|
|
|
|
#include "extra.h"
|
|
|
|
#include "legoomni.h"
|
|
|
|
#include "legoutil.h"
|
2024-01-07 17:03:04 -05:00
|
|
|
#include "mxcompositepresenter.h"
|
2023-11-21 05:35:03 -05:00
|
|
|
#include "mxmediapresenter.h"
|
|
|
|
#include "mxomni.h"
|
2024-01-07 17:03:04 -05:00
|
|
|
#include "mxstreamchunk.h"
|
2023-11-21 05:35:03 -05:00
|
|
|
#include "mxticklemanager.h"
|
|
|
|
|
|
|
|
DECOMP_SIZE_ASSERT(LegoActionControlPresenter, 0x68)
|
|
|
|
|
2024-01-07 17:03:04 -05:00
|
|
|
// FUNCTION: LEGO1 0x10043ce0
|
2023-11-21 05:35:03 -05:00
|
|
|
void LegoActionControlPresenter::ReadyTickle()
|
|
|
|
{
|
2024-01-07 17:03:04 -05:00
|
|
|
MxStreamChunk* chunk = NextChunk();
|
|
|
|
|
|
|
|
if (chunk) {
|
|
|
|
ParseExtra();
|
2024-01-17 11:53:53 -05:00
|
|
|
ProgressTickleState(e_starting);
|
2024-01-07 17:03:04 -05:00
|
|
|
|
2024-02-17 10:35:10 -05:00
|
|
|
m_subscriber->FreeDataChunk(chunk);
|
2024-01-07 17:03:04 -05:00
|
|
|
if (m_compositePresenter) {
|
|
|
|
if (m_action->GetDuration() == -1 || m_action->GetFlags() & 1) {
|
|
|
|
m_compositePresenter->VTable0x60(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-11-21 05:35:03 -05:00
|
|
|
}
|
|
|
|
|
2024-01-07 17:03:04 -05:00
|
|
|
// FUNCTION: LEGO1 0x10043d40
|
2023-11-21 05:35:03 -05:00
|
|
|
void LegoActionControlPresenter::RepeatingTickle()
|
|
|
|
{
|
2024-01-07 17:03:04 -05:00
|
|
|
if (IsEnabled()) {
|
|
|
|
if (m_unk0x50 == 0) {
|
|
|
|
ParseExtra();
|
|
|
|
}
|
|
|
|
|
2024-01-10 17:34:32 -05:00
|
|
|
#ifdef COMPAT_MODE
|
|
|
|
{
|
2024-01-17 11:53:53 -05:00
|
|
|
MxAtomId atom(m_unk0x54.GetData(), e_lowerCase2);
|
2024-01-10 17:34:32 -05:00
|
|
|
InvokeAction(m_unk0x50, atom, m_unk0x64, NULL);
|
|
|
|
}
|
|
|
|
#else
|
2024-01-17 11:53:53 -05:00
|
|
|
InvokeAction(m_unk0x50, MxAtomId(m_unk0x54.GetData(), e_lowerCase2), m_unk0x64, NULL);
|
2024-01-10 17:34:32 -05:00
|
|
|
#endif
|
2024-01-17 11:53:53 -05:00
|
|
|
ProgressTickleState(e_done);
|
2024-01-07 17:03:04 -05:00
|
|
|
}
|
2023-11-21 05:35:03 -05:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x10043df0
|
2023-11-21 05:35:03 -05:00
|
|
|
MxResult LegoActionControlPresenter::AddToManager()
|
|
|
|
{
|
|
|
|
MxResult result = FAILURE;
|
|
|
|
|
|
|
|
if (TickleManager()) {
|
|
|
|
result = SUCCESS;
|
|
|
|
TickleManager()->RegisterClient(this, 100);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x10043e20
|
2023-11-21 05:35:03 -05:00
|
|
|
void LegoActionControlPresenter::Destroy(MxBool p_fromDestructor)
|
|
|
|
{
|
|
|
|
if (TickleManager()) {
|
|
|
|
TickleManager()->UnregisterClient(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_fromDestructor) {
|
|
|
|
MxMediaPresenter::Destroy(FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x10043e50
|
2023-11-21 05:35:03 -05:00
|
|
|
void LegoActionControlPresenter::ParseExtra()
|
|
|
|
{
|
|
|
|
MxU32 len = m_action->GetExtraLength();
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (len == 0) {
|
2023-11-21 05:35:03 -05:00
|
|
|
return;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-11-21 05:35:03 -05:00
|
|
|
|
|
|
|
len &= MAXWORD;
|
|
|
|
|
|
|
|
char buf[1024];
|
|
|
|
memcpy(buf, m_action->GetExtraData(), len);
|
|
|
|
buf[len] = '\0';
|
|
|
|
|
|
|
|
char output[1024];
|
|
|
|
if (KeyValueStringParse(output, g_strACTION, buf)) {
|
|
|
|
m_unk0x50 = MatchActionString(strtok(output, g_parseExtraTokens));
|
2024-01-17 11:53:53 -05:00
|
|
|
if (m_unk0x50 != Extra::ActionType::e_exit) {
|
2023-11-21 05:35:03 -05:00
|
|
|
MakeSourceName(buf, strtok(NULL, g_parseExtraTokens));
|
|
|
|
m_unk0x54 = buf;
|
|
|
|
m_unk0x54.ToLowerCase();
|
2024-01-17 11:53:53 -05:00
|
|
|
if (m_unk0x50 != Extra::ActionType::e_run) {
|
2023-11-21 05:35:03 -05:00
|
|
|
m_unk0x64 = atoi(strtok(NULL, g_parseExtraTokens));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|