2023-06-29 04:10:08 -04:00
|
|
|
#include "mxloopingflcpresenter.h"
|
|
|
|
|
2023-07-02 03:00:28 -04:00
|
|
|
#include "decomp.h"
|
|
|
|
|
|
|
|
DECOMP_SIZE_ASSERT(MxLoopingFlcPresenter, 0x6c);
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b4310
|
2023-06-29 04:10:08 -04:00
|
|
|
MxLoopingFlcPresenter::MxLoopingFlcPresenter()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
Init();
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b43b0
|
2023-06-29 04:10:08 -04:00
|
|
|
MxLoopingFlcPresenter::~MxLoopingFlcPresenter()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
Destroy(TRUE);
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b4410
|
2023-06-29 04:10:08 -04:00
|
|
|
void MxLoopingFlcPresenter::Init()
|
|
|
|
{
|
2024-01-19 10:33:04 -05:00
|
|
|
this->m_elapsedDuration = 0;
|
2024-01-29 11:29:12 -05:00
|
|
|
SetBit1(FALSE);
|
|
|
|
SetBit2(FALSE);
|
2023-10-03 17:38:03 -04:00
|
|
|
}
|
|
|
|
|
2023-12-28 13:55:03 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b4430
|
2023-10-13 12:43:45 -04:00
|
|
|
void MxLoopingFlcPresenter::Destroy(MxBool p_fromDestructor)
|
2023-10-03 17:38:03 -04:00
|
|
|
{
|
2023-12-28 13:55:03 -05:00
|
|
|
m_criticalSection.Enter();
|
|
|
|
Init();
|
|
|
|
m_criticalSection.Leave();
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (!p_fromDestructor) {
|
2023-12-28 13:55:03 -05:00
|
|
|
MxFlcPresenter::Destroy(FALSE);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
2023-11-29 07:35:32 -05:00
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b4470
|
2023-11-29 07:35:32 -05:00
|
|
|
void MxLoopingFlcPresenter::NextFrame()
|
|
|
|
{
|
|
|
|
MxStreamChunk* chunk = NextChunk();
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (chunk->GetFlags() & MxDSChunk::c_end) {
|
2024-01-17 11:53:53 -05:00
|
|
|
ProgressTickleState(e_repeating);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-11-29 07:35:32 -05:00
|
|
|
else {
|
|
|
|
LoadFrame(chunk);
|
2024-01-08 13:07:13 -05:00
|
|
|
LoopChunk(chunk);
|
2024-01-19 10:33:04 -05:00
|
|
|
m_elapsedDuration += m_flcHeader->speed;
|
2023-11-29 07:35:32 -05:00
|
|
|
}
|
|
|
|
|
2024-01-08 13:07:13 -05:00
|
|
|
m_subscriber->DestroyChunk(chunk);
|
2023-11-29 07:35:32 -05:00
|
|
|
}
|
2024-01-19 10:33:04 -05:00
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100b44c0
|
|
|
|
void MxLoopingFlcPresenter::VTable0x88()
|
|
|
|
{
|
2024-02-01 15:42:10 -05:00
|
|
|
if (m_action->GetDuration() < m_elapsedDuration) {
|
2024-01-19 10:33:04 -05:00
|
|
|
ProgressTickleState(e_unk5);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-19 10:33:04 -05:00
|
|
|
else {
|
|
|
|
MxStreamChunk* chunk;
|
|
|
|
m_loopingChunkCursor->Current(chunk);
|
|
|
|
LoadFrame(chunk);
|
|
|
|
m_elapsedDuration += m_flcHeader->speed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100b4520
|
|
|
|
void MxLoopingFlcPresenter::RepeatingTickle()
|
|
|
|
{
|
|
|
|
for (MxS16 i = 0; i < m_unk0x5c; i++) {
|
|
|
|
if (!m_loopingChunkCursor->HasMatch()) {
|
|
|
|
MxStreamChunk* chunk;
|
|
|
|
MxStreamChunkListCursor cursor(m_loopingChunks);
|
|
|
|
|
|
|
|
cursor.Last(chunk);
|
|
|
|
MxLong time = chunk->GetTime();
|
|
|
|
|
|
|
|
cursor.First(chunk);
|
|
|
|
|
|
|
|
time -= chunk->GetTime();
|
|
|
|
time += m_flcHeader->speed;
|
|
|
|
|
|
|
|
cursor.Reset();
|
2024-02-01 15:42:10 -05:00
|
|
|
while (cursor.Next(chunk)) {
|
2024-01-19 10:33:04 -05:00
|
|
|
chunk->SetTime(chunk->GetTime() + time);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-19 10:33:04 -05:00
|
|
|
|
|
|
|
m_loopingChunkCursor->Next();
|
|
|
|
}
|
|
|
|
|
|
|
|
MxStreamChunk* chunk;
|
|
|
|
m_loopingChunkCursor->Current(chunk);
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (m_action->GetElapsedTime() < chunk->GetTime()) {
|
2024-01-19 10:33:04 -05:00
|
|
|
break;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-19 10:33:04 -05:00
|
|
|
|
|
|
|
VTable0x88();
|
|
|
|
|
|
|
|
m_loopingChunkCursor->Next(chunk);
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (m_currentTickleState != e_repeating) {
|
2024-01-19 10:33:04 -05:00
|
|
|
break;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-19 10:33:04 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100b4860
|
|
|
|
MxResult MxLoopingFlcPresenter::AddToManager()
|
|
|
|
{
|
|
|
|
MxResult result = FAILURE;
|
|
|
|
MxBool locked = FALSE;
|
|
|
|
|
|
|
|
if (MxFlcPresenter::AddToManager() == SUCCESS) {
|
|
|
|
m_criticalSection.Enter();
|
|
|
|
locked = TRUE;
|
|
|
|
result = SUCCESS;
|
|
|
|
}
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (locked) {
|
2024-01-19 10:33:04 -05:00
|
|
|
m_criticalSection.Leave();
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-19 10:33:04 -05:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100b48a0
|
|
|
|
void MxLoopingFlcPresenter::Destroy()
|
|
|
|
{
|
|
|
|
Destroy(FALSE);
|
|
|
|
}
|