From 17252b95f49ee7b84b48d7c68afb6106a73c01eb Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Thu, 1 Feb 2024 15:56:27 -0500 Subject: [PATCH] Implement Infocenter::HandleNotification0 (#514) * Implement Infocenter::HandleNotification0 * Match * Match * Match * Match * Braces * Add enum constants --- LEGO1/lego/legoomni/include/infocenter.h | 13 ++- LEGO1/lego/legoomni/include/infocenterstate.h | 5 +- LEGO1/lego/legoomni/include/radio.h | 2 + .../legoomni/src/infocenter/infocenter.cpp | 84 ++++++++++++++++--- 4 files changed, 91 insertions(+), 13 deletions(-) diff --git a/LEGO1/lego/legoomni/include/infocenter.h b/LEGO1/lego/legoomni/include/infocenter.h index bd06f5bf..3c0d04d6 100644 --- a/LEGO1/lego/legoomni/include/infocenter.h +++ b/LEGO1/lego/legoomni/include/infocenter.h @@ -61,9 +61,17 @@ class Infocenter : public LegoWorld { c_nickSelected = 33, c_lauraSelected = 34, + c_unk40 = 40, + c_unk41 = 41, + c_unk42 = 42, + c_unk43 = 43, + c_unk44 = 44, + c_goToRegBook = 70, c_goToRegBookRed = 71, + c_unk499 = 499, + c_welcomeDialogue = 500, c_goodJobDialogue = 501, @@ -127,6 +135,7 @@ class Infocenter : public LegoWorld { c_gasCtlDescription = 555, c_medCtlDescription = 556, + c_unk557 = 557, c_boatCtlDescription = 558, c_copCtlDescription = 559, c_pizzaCtlDescription = 560, @@ -182,8 +191,8 @@ class Infocenter : public LegoWorld { MxU8 HandleMouseMove(MxS32 p_x, MxS32 p_y); MxU8 HandleButtonUp(MxS32 p_x, MxS32 p_y); MxU8 HandleClick(LegoControlManagerEvent& p_param); - MxLong HandleEndAction(MxParam& p_param); - MxLong HandleNotification0(MxParam&); + MxLong HandleEndAction(MxEndActionNotificationParam& p_param); + MxLong HandleNotification0(MxNotificationParam& p_param); void UpdateFrameHot(MxBool p_display); void FUN_10070e90(); diff --git a/LEGO1/lego/legoomni/include/infocenterstate.h b/LEGO1/lego/legoomni/include/infocenterstate.h index 49ca0988..7e651740 100644 --- a/LEGO1/lego/legoomni/include/infocenterstate.h +++ b/LEGO1/lego/legoomni/include/infocenterstate.h @@ -30,6 +30,8 @@ class InfocenterState : public LegoState { inline MxS16 GetInfocenterBufferSize() { return sizeof(m_buffer) / sizeof(m_buffer[0]); } inline MxStillPresenter* GetInfocenterBufferElement(MxS32 p_index) { return m_buffer[p_index]; } + inline StateStruct& GetUnknown0x08() { return m_unk0x08; } + inline StateStruct& GetUnknown0x14() { return m_unk0x14; } inline StateStruct& GetUnknown0x68() { return m_unk0x68; } inline MxU32 GetUnknown0x74() { return m_unk0x74; } @@ -39,7 +41,8 @@ class InfocenterState : public LegoState { // InfocenterState::`scalar deleting destructor' private: - undefined m_unk0x08[0x18]; // 0x08 + StateStruct m_unk0x08; // 0x08 + StateStruct m_unk0x14; // 0x14 StateStruct m_unk0x20[3]; // 0x20 StateStruct m_unk0x44[3]; // 0x44 StateStruct m_unk0x68; // 0x68 diff --git a/LEGO1/lego/legoomni/include/radio.h b/LEGO1/lego/legoomni/include/radio.h index fe06be9b..23ddb276 100644 --- a/LEGO1/lego/legoomni/include/radio.h +++ b/LEGO1/lego/legoomni/include/radio.h @@ -32,6 +32,8 @@ class Radio : public MxCore { void Play(); void Stop(); + inline RadioState* GetState() { return m_state; } + // SYNTHETIC: LEGO1 0x1002c970 // Radio::`scalar deleting destructor' diff --git a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp index 0e90c761..0a262819 100644 --- a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp +++ b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp @@ -106,10 +106,10 @@ MxLong Infocenter::Notify(MxParam& p_param) if (m_worldStarted) { switch (((MxNotificationParam&) p_param).GetNotification()) { case c_notificationType0: - result = HandleNotification0(p_param); + result = HandleNotification0((MxNotificationParam&) p_param); break; case c_notificationEndAction: - result = HandleEndAction(p_param); + result = HandleEndAction((MxEndActionNotificationParam&) p_param); break; case c_notificationKeyPress: result = HandleKeyPress(((LegoEventNotificationParam&) p_param).GetKey()); @@ -150,17 +150,17 @@ MxLong Infocenter::Notify(MxParam& p_param) } // FUNCTION: LEGO1 0x1006f080 -MxLong Infocenter::HandleEndAction(MxParam& p_param) +MxLong Infocenter::HandleEndAction(MxEndActionNotificationParam& p_param) { - MxDSAction* action = ((MxEndActionNotificationParam&) p_param).GetAction(); - if (action->GetAtomId() == *g_creditsScript && action->GetObjectId() == 499) { + MxDSAction* action = p_param.GetAction(); + if (action->GetAtomId() == *g_creditsScript && action->GetObjectId() == c_unk499) { Lego()->CloseMainWindow(); return 1; } if (action->GetAtomId() == m_atom && - (action->GetObjectId() == 40 || action->GetObjectId() == 41 || action->GetObjectId() == 42 || - action->GetObjectId() == 43 || action->GetObjectId() == 44)) { + (action->GetObjectId() == c_unk40 || action->GetObjectId() == c_unk41 || action->GetObjectId() == c_unk42 || + action->GetObjectId() == c_unk43 || action->GetObjectId() == c_unk44)) { if (m_unk0x1d4) { m_unk0x1d4--; } @@ -260,7 +260,7 @@ MxLong Infocenter::HandleEndAction(MxParam& p_param) BackgroundAudioManager()->RaiseVolume(); return 1; case 4: - if (action->GetObjectId() == 70 || action->GetObjectId() == 71) { + if (action->GetObjectId() == c_goToRegBook || action->GetObjectId() == c_goToRegBookRed) { TransitionManager()->StartTransition(MxTransitionManager::e_pixelation, 50, FALSE, FALSE); m_infocenterState->SetUnknown0x74(14); return 1; @@ -638,9 +638,73 @@ MxU8 Infocenter::HandleClick(LegoControlManagerEvent& p_param) return 1; } -// STUB: LEGO1 0x10070870 -MxLong Infocenter::HandleNotification0(MxParam&) +// FUNCTION: LEGO1 0x10070870 +MxLong Infocenter::HandleNotification0(MxNotificationParam& p_param) { + // MxLong result + MxCore* sender = p_param.GetSender(); + + if (sender == NULL) { + if (m_infocenterState->GetUnknown0x74() == 8) { + m_infoManDialogueTimer = 0; + StopCutscene(); + PlayAction(c_exitConfirmationDialogue); + } + } + else if (sender->IsA("MxEntity") && m_infocenterState->GetUnknown0x74() != 5 && m_infocenterState->GetUnknown0x74() != 12) { + switch (((MxEntity*) sender)->GetEntityId()) { + case 5: { + m_infoManDialogueTimer = 0; + + InfomainScript objectId; + if (GameState()->GetUnknown10()) { + objectId = (InfomainScript) m_infocenterState->GetUnknown0x14().FUN_10014d00(); + } + else { + objectId = (InfomainScript) m_infocenterState->GetUnknown0x08().FUN_10014d00(); + } + + PlayAction(objectId); + FUN_10015860(g_object2x4red, 0); + FUN_10015860(g_object2x4grn, 0); + return 1; + } + case 6: + if (m_infocenterState->GetUnknown0x74() == 8) { + StopCurrentAction(); + FUN_10015860(g_object2x4red, 0); + FUN_10015860(g_object2x4grn, 0); + m_infocenterState->SetUnknown0x74(2); + PlayAction(c_infomanSneeze); + return 1; + } + case 7: + if (m_infocenterState->GetUnknown0x74() == 8) { + if (m_infocenterState->GetInfocenterBufferElement(0)) { + GameState()->Save(0); + } + + m_infocenterState->SetUnknown0x74(12); + PlayAction(c_exitGameDialogue); + InputManager()->DisableInputProcessing(); + InputManager()->SetUnknown336(TRUE); + return 1; + } + } + } + else { + if (sender->IsA("Radio") && m_radio.GetState()->IsActive()) { + if (m_currentInfomainScript == c_unk40 || m_currentInfomainScript == c_unk41 || + m_currentInfomainScript == c_unk42 || m_currentInfomainScript == c_unk43 || + m_currentInfomainScript == c_unk44 || m_currentInfomainScript == c_unk557 || + m_currentInfomainScript == c_boatCtlDescription || m_currentInfomainScript == c_raceCtlDescription || + m_currentInfomainScript == c_pizzaCtlDescription || m_currentInfomainScript == c_gasCtlDescription || + m_currentInfomainScript == c_medCtlDescription || m_currentInfomainScript == c_copCtlDescription) { + StopCurrentAction(); + } + } + } + return 1; }