2023-06-29 04:10:08 -04:00
|
|
|
#include "legopalettepresenter.h"
|
|
|
|
|
2023-12-27 15:44:51 -05:00
|
|
|
#include "legoomni.h"
|
|
|
|
#include "legostream.h"
|
|
|
|
#include "legovideomanager.h"
|
|
|
|
#include "mxstreamchunk.h"
|
|
|
|
|
2023-09-11 13:43:55 -04:00
|
|
|
DECOMP_SIZE_ASSERT(LegoPalettePresenter, 0x68)
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x10079e50
|
2023-06-29 04:10:08 -04:00
|
|
|
LegoPalettePresenter::LegoPalettePresenter()
|
|
|
|
{
|
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 0x1007a070
|
2023-06-29 04:10:08 -04:00
|
|
|
LegoPalettePresenter::~LegoPalettePresenter()
|
|
|
|
{
|
2023-11-17 15:01:27 -05:00
|
|
|
Destroy(TRUE);
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x1007a0d0
|
2023-06-29 04:10:08 -04:00
|
|
|
void LegoPalettePresenter::Init()
|
|
|
|
{
|
2023-11-17 15:01:27 -05:00
|
|
|
m_palette = NULL;
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x1007a0e0
|
2023-11-17 15:01:27 -05:00
|
|
|
void LegoPalettePresenter::Destroy(MxBool p_fromDestructor)
|
|
|
|
{
|
|
|
|
m_criticalSection.Enter();
|
|
|
|
if (m_palette) {
|
|
|
|
delete m_palette;
|
|
|
|
}
|
|
|
|
Init();
|
|
|
|
m_criticalSection.Leave();
|
|
|
|
if (!p_fromDestructor) {
|
|
|
|
MxVideoPresenter::Destroy(FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x1007a120
|
2023-11-17 15:01:27 -05:00
|
|
|
void LegoPalettePresenter::Destroy()
|
|
|
|
{
|
|
|
|
Destroy(FALSE);
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
2023-12-27 15:44:51 -05:00
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x1007a130
|
2024-01-08 13:07:13 -05:00
|
|
|
MxResult LegoPalettePresenter::ParsePalette(MxStreamChunk* p_chunk)
|
2023-12-27 15:44:51 -05:00
|
|
|
{
|
|
|
|
MxU8 buffer[40];
|
2024-01-16 14:33:03 -05:00
|
|
|
RGBQUAD palette[256];
|
2023-12-27 15:44:51 -05:00
|
|
|
MxResult result = FAILURE;
|
2024-01-16 14:33:03 -05:00
|
|
|
|
2023-12-27 15:44:51 -05:00
|
|
|
LegoMemoryStream stream((char*) p_chunk->GetData());
|
2024-01-16 14:33:03 -05:00
|
|
|
if (stream.Read(buffer, sizeof(buffer)) == SUCCESS) {
|
|
|
|
if (stream.Read(palette, sizeof(palette)) == SUCCESS) {
|
|
|
|
m_palette = new MxPalette(palette);
|
2023-12-27 15:44:51 -05:00
|
|
|
if (m_palette) {
|
|
|
|
result = SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result != SUCCESS && m_palette) {
|
|
|
|
delete m_palette;
|
|
|
|
m_palette = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x1007a230
|
|
|
|
void LegoPalettePresenter::ReadyTickle()
|
|
|
|
{
|
2024-01-08 13:07:13 -05:00
|
|
|
MxStreamChunk* chunk = m_subscriber->CurrentChunk();
|
2023-12-27 15:44:51 -05:00
|
|
|
if (chunk) {
|
|
|
|
if (chunk->GetTime() <= m_action->GetElapsedTime()) {
|
|
|
|
ParseExtra();
|
2024-01-17 11:53:53 -05:00
|
|
|
ProgressTickleState(e_starting);
|
2024-01-11 10:02:55 -05:00
|
|
|
|
2024-01-08 13:07:13 -05:00
|
|
|
chunk = m_subscriber->NextChunk();
|
|
|
|
MxResult result = ParsePalette(chunk);
|
|
|
|
m_subscriber->DestroyChunk(chunk);
|
2023-12-27 15:44:51 -05:00
|
|
|
|
|
|
|
if (result == SUCCESS) {
|
|
|
|
VideoManager()->RealizePalette(m_palette);
|
|
|
|
}
|
|
|
|
EndAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|