From 85a8c8fd31037277224403476722b951f8b595bc Mon Sep 17 00:00:00 2001 From: Misha <106913236+MishaProductions@users.noreply.github.com> Date: Tue, 16 Jan 2024 18:27:34 -0500 Subject: [PATCH] Implement Infocenter::HandleEndAction --- LEGO1/lego/legoomni/include/infocenter.h | 4 +- .../legoomni/include/legocontrolmanager.h | 1 + LEGO1/lego/legoomni/include/legogamestate.h | 1 + LEGO1/lego/legoomni/include/legoomni.h | 1 + .../legoomni/src/common/legogamestate.cpp | 6 + .../src/control/legocontrolmanager.cpp | 5 + .../legoomni/src/infocenter/infocenter.cpp | 193 +++++++++++++++++- .../src/infocenter/infocenterstate.cpp | 1 + LEGO1/lego/legoomni/src/main/legoomni.cpp | 6 + 9 files changed, 208 insertions(+), 10 deletions(-) diff --git a/LEGO1/lego/legoomni/include/infocenter.h b/LEGO1/lego/legoomni/include/infocenter.h index ae247217..50ed0a51 100644 --- a/LEGO1/lego/legoomni/include/infocenter.h +++ b/LEGO1/lego/legoomni/include/infocenter.h @@ -44,7 +44,6 @@ class Infocenter : public LegoWorld { virtual void VTable0x68(MxBool p_add) override; // vtable+0x68 private: - void PlayCutScene(MxU32 p_entityId, MxBool p_scale); void InitializeBitmaps(); // notifications @@ -55,9 +54,12 @@ class Infocenter : public LegoWorld { MxLong HandleEndAction(MxParam&); MxLong HandleNotification0(MxParam&); + void FUN_10070dc0(MxBool); void FUN_10070e90(); // utility functions + void PlayCutScene(MxU32 p_entityId, MxBool p_scale); + void StopCutScene(); void StartCredits(); static void DeleteCredits(); void PlayDialogue(MxS32 p_objectId); diff --git a/LEGO1/lego/legoomni/include/legocontrolmanager.h b/LEGO1/lego/legoomni/include/legocontrolmanager.h index 36bf6d48..f81ab6d2 100644 --- a/LEGO1/lego/legoomni/include/legocontrolmanager.h +++ b/LEGO1/lego/legoomni/include/legocontrolmanager.h @@ -28,6 +28,7 @@ class LegoControlManager : public MxCore { void FUN_10028df0(MxPresenterList* p_presenterList); void Register(MxCore* p_listener); void Unregister(MxCore* p_listener); + void FUN_100293c0(undefined4, const MxAtomId&, undefined2); }; #endif // LEGOCONTROLMANAGER_H diff --git a/LEGO1/lego/legoomni/include/legogamestate.h b/LEGO1/lego/legoomni/include/legogamestate.h index 00781094..ae39654c 100644 --- a/LEGO1/lego/legoomni/include/legogamestate.h +++ b/LEGO1/lego/legoomni/include/legogamestate.h @@ -43,6 +43,7 @@ class LegoGameState { void SetSomeEnumState(undefined4 p_state); void FUN_1003ceb0(); + void FUN_10039780(MxU8); struct ScoreStruct { void WriteScoreHistory(); diff --git a/LEGO1/lego/legoomni/include/legoomni.h b/LEGO1/lego/legoomni/include/legoomni.h index ec5b170b..aad0b43f 100644 --- a/LEGO1/lego/legoomni/include/legoomni.h +++ b/LEGO1/lego/legoomni/include/legoomni.h @@ -163,6 +163,7 @@ LegoWorld* GetCurrentWorld(); LegoUnkSaveDataWriter* GetUnkSaveDataWriter(); GifManager* GetGifManager(); void FUN_10015820(MxU32, MxU32); +void FUN_10015860(const char*, MxU8); LegoEntity* FindEntityByAtomIdOrEntityId(const MxAtomId& p_atom, MxS32 p_entityid); MxDSAction& GetCurrentAction(); diff --git a/LEGO1/lego/legoomni/src/common/legogamestate.cpp b/LEGO1/lego/legoomni/src/common/legogamestate.cpp index 2291b72c..a3459107 100644 --- a/LEGO1/lego/legoomni/src/common/legogamestate.cpp +++ b/LEGO1/lego/legoomni/src/common/legogamestate.cpp @@ -89,6 +89,12 @@ LegoGameState::~LegoGameState() delete[] m_savePath; } +// STUB: LEGO1 0x10039780 +void LegoGameState::FUN_10039780(MxU8) +{ + // TODO +} + // FUNCTION: LEGO1 0x10039980 MxResult LegoGameState::Save(MxULong p_slot) { diff --git a/LEGO1/lego/legoomni/src/control/legocontrolmanager.cpp b/LEGO1/lego/legoomni/src/control/legocontrolmanager.cpp index 24e3cb1b..64c19cd5 100644 --- a/LEGO1/lego/legoomni/src/control/legocontrolmanager.cpp +++ b/LEGO1/lego/legoomni/src/control/legocontrolmanager.cpp @@ -30,6 +30,11 @@ void LegoControlManager::Unregister(MxCore* p_listener) // TODO } +// STUB: LEGO1 0x100293c0 +void LegoControlManager::FUN_100293c0(undefined4, const MxAtomId&, undefined2) +{ +} + // STUB: LEGO1 0x10029600 MxResult LegoControlManager::Tickle() { diff --git a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp index af415781..ce6b770b 100644 --- a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp +++ b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp @@ -11,6 +11,13 @@ #include "mxbackgroundaudiomanager.h" #include "mxnotificationmanager.h" #include "mxstillpresenter.h" +#include "mxtransitionmanager.h" + +// GLOBAL: LEGO1 0x100f7698 +const char* g_2x4red = "2x4red"; + +// GLOBAL: LEGO1 0x100f76a4 +const char* g_2x4grn = "2x4grn"; DECOMP_SIZE_ASSERT(Infocenter, 0x1d8) @@ -111,16 +118,156 @@ MxLong Infocenter::Notify(MxParam& p_param) return 0; } -// STUB: LEGO1 0x1006f080 +// FUNCTION: LEGO1 0x1006f080 MxLong Infocenter::HandleEndAction(MxParam& p_param) { MxDSAction* endedAction = ((MxEndActionNotificationParam&) p_param).GetAction(); if (endedAction->GetAtomId() == *g_creditsScript && endedAction->GetObjectId() == 499) { Lego()->CloseMainWindow(); + return 1; } - // TODO - return 1; + switch (endedAction->GetObjectId()) { + case 40: + case 41: + case 42: + case 43: + case 44: + if (m_unk0x1d4) { + m_unk0x1d4--; + } + + if (m_unk0x1d4) + break; + + PlayMusic(11); + GameState()->FUN_10039780(m_unk0xfc); + + // Play dialogue when player selects character + switch (m_unk0xfc) { + case 1: + PlayDialogue(541); // pepper + break; + case 2: + PlayDialogue(542); // mama brickolinea + break; + case 3: + PlayDialogue(543); // papa brickolinea + break; + case 4: + PlayDialogue(544); // officer nick brick + break; + case 5: + PlayDialogue(545); // lora brick + break; + default: + break; + } + FUN_10070dc0(TRUE); + } + + MxLong result = m_radio.Notify(p_param); + if (result == 0) { + if (endedAction->GetAtomId() == m_atom || endedAction->GetAtomId() == *g_introScript) { + // 514: if you want to get back ... + if (endedAction->GetObjectId() == 514) { + ControlManager()->FUN_100293c0(0x10, endedAction->GetAtomId(), 0); + m_unk0x1d6 = 0; + } + + switch (m_infocenterState->GetUnknown0x74()) { + case 0: + switch (m_currentCutScene) { + case 0: + PlayCutScene(1, FALSE); // Mindscape animation + return 1; + case 1: + PlayCutScene(2, TRUE); // Lego Island animation + return 1; + case 4: + StopCutScene(); + // play bad ending dialogue after bad ending cutscene + PlayDialogue(540); + m_currentCutScene = -1; + return 1; + case 5: + StopCutScene(); + + // play good ending dialogue after good ending cutscene + PlayDialogue(539); + m_currentCutScene = -1; + return 1; + } + + // default / 2nd case probably? + StopCutScene(); + m_infocenterState->SetUnknown0x74(11); + PlayDialogue(500); // play welcome dialogue + m_currentCutScene = -1; + if (m_infocenterState->GetInfocenterBufferElement(0) == 0) { + m_unk0x1d2 = 1; + return 1; + } + break; + case 1: + m_infocenterState->SetUnknown0x74(11); + MxU32 val; + switch (m_currentCutScene) { + case 4: + val = 540; // bad ending dialogue + break; + case 5: + val = 539; // good ending dialogue + break; + default: + val = 500; // welcome dialogue + break; + } + + PlayDialogue(val); + m_currentCutScene = -1; + return 1; + case 2: + FUN_10015860(g_2x4red, 0); + FUN_10015860(g_2x4grn, 0); + BackgroundAudioManager()->RaiseVolume(); + return 1; + case 4: + if (endedAction->GetObjectId() == 70 || endedAction->GetObjectId() == 71) { + TransitionManager()->StartTransition(MxTransitionManager::PIXELATION, 50, FALSE, FALSE); + m_infocenterState->SetUnknown0x74(14); + return 1; + } + break; + case 5: + if (m_unk0xf8 == endedAction->GetObjectId()) { + if (GameState()->GetUnknown10() != 2 && m_unk0xfc != 0) { + GameState()->FUN_10039780(m_unk0xfc); + } + TransitionManager()->StartTransition(MxTransitionManager::PIXELATION, 50, FALSE, FALSE); + m_infocenterState->SetUnknown0x74(14); + return 1; + } + break; + case 11: + if (m_infocenterState->GetInfocenterBufferElement(0) == 0 && m_unk0xf8 != 28 && m_unk0xf8 != 29 && + m_unk0xf8 != 42 && m_unk0xf8 != 43 && m_unk0xf8 != 44) { + m_unk0x1d0 = 1; + PlayMusic(11); + } + m_infocenterState->SetUnknown0x74(2); + FUN_10015860("infoman", 1); + return 1; + case 12: + if (m_unk0xf8 == endedAction->GetObjectId()) { + TransitionManager()->StartTransition(MxTransitionManager::PIXELATION, 50, FALSE, FALSE); + } + } + + result = 1; + } + } + return result; } // FUNCTION: LEGO1 0x1006f4e0 @@ -191,12 +338,6 @@ void Infocenter::InitializeBitmaps() // TODO: Infocenter class size is wrong } -// STUB: LEGO1 0x10070aa0 -void Infocenter::VTable0x68(MxBool p_add) -{ - // TODO -} - // STUB: LEGO1 0x1006fd00 MxLong Infocenter::HandleMouseMove(MxS32 p_x, MxS32 p_y) { @@ -227,6 +368,22 @@ MxLong Infocenter::HandleNotification0(MxParam&) return 1; } +// FUNCTION: LEGO1 0x10070aa0 +void Infocenter::VTable0x68(MxBool p_add) +{ + LegoWorld::VTable0x68(p_add); + + if (p_add) { + InputManager()->SetWorld(this); + SetIsWorldActive(FALSE); + } + else { + if (InputManager()->GetWorld() == this) { + InputManager()->ClearWorld(); + } + } +} + // STUB: LEGO1 0x10070af0 MxResult Infocenter::Tickle() { @@ -253,12 +410,29 @@ void Infocenter::PlayCutScene(MxU32 p_entityId, MxBool p_scale) } } +// FUNCTION: LEGO1 0x10070cb0 +void Infocenter::StopCutScene() +{ + if (m_currentCutScene != -1) { + InvokeAction(ExtraActionType_close, *g_introScript, m_currentCutScene, NULL); + } + + VideoManager()->EnableFullScreenMovie(FALSE); + InputManager()->SetUnknown335(FALSE); + FUN_10015820(0, 7); +} + // FUNCTION: LEGO1 0x10070d00 MxBool Infocenter::VTable0x5c() { return TRUE; } +// STUB: LEGO1 0x10070dc0 +void Infocenter::FUN_10070dc0(MxBool) +{ +} + // STUB: LEGO1 0x10070e90 void Infocenter::FUN_10070e90() { @@ -273,6 +447,7 @@ MxBool Infocenter::VTable0x64() // STUB: LEGO1 0x10071030 void Infocenter::StartCredits() { + // TODO } // FUNCTION: LEGO1 0x10071250 diff --git a/LEGO1/lego/legoomni/src/infocenter/infocenterstate.cpp b/LEGO1/lego/legoomni/src/infocenter/infocenterstate.cpp index 47a31fbb..96e47c55 100644 --- a/LEGO1/lego/legoomni/src/infocenter/infocenterstate.cpp +++ b/LEGO1/lego/legoomni/src/infocenter/infocenterstate.cpp @@ -6,6 +6,7 @@ DECOMP_SIZE_ASSERT(InfocenterState, 0x94); InfocenterState::InfocenterState() { // TODO + memset(m_buffer, 0, sizeof(m_buffer)); } // STUB: LEGO1 0x10071920 diff --git a/LEGO1/lego/legoomni/src/main/legoomni.cpp b/LEGO1/lego/legoomni/src/main/legoomni.cpp index 2b83f6c2..619f68ff 100644 --- a/LEGO1/lego/legoomni/src/main/legoomni.cpp +++ b/LEGO1/lego/legoomni/src/main/legoomni.cpp @@ -211,6 +211,12 @@ void FUN_10015820(MxU32, MxU32) // TODO } +// STUB: LEGO1 0x10015860 +void FUN_10015860(const char*, MxU8) +{ + // TODO +} + // FUNCTION: LEGO1 0x100158c0 LegoEntity* FindEntityByAtomIdOrEntityId(const MxAtomId& p_atom, MxS32 p_entityid) {