From 526318a05771fe7067ca59846222d4b3ae010fc6 Mon Sep 17 00:00:00 2001 From: Misha <106913236+MishaProductions@users.noreply.github.com> Date: Tue, 16 Jan 2024 19:33:43 -0500 Subject: [PATCH] implement Infocenter::HandleKeyPress --- LEGO1/lego/legoomni/include/infocenter.h | 4 +- .../legoomni/src/infocenter/infocenter.cpp | 47 +++++++++++++++++-- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/LEGO1/lego/legoomni/include/infocenter.h b/LEGO1/lego/legoomni/include/infocenter.h index 50ed0a51..ad512549 100644 --- a/LEGO1/lego/legoomni/include/infocenter.h +++ b/LEGO1/lego/legoomni/include/infocenter.h @@ -48,7 +48,7 @@ class Infocenter : public LegoWorld { // notifications MxLong HandleMouseMove(MxS32 p_x, MxS32 p_y); - MxU8 HandleKeyPress(char p_key); + MxU32 HandleKeyPress(char p_key); MxU8 HandleButtonUp(MxS32 p_x, MxS32 p_y); MxU8 HandleNotification17(MxParam&); MxLong HandleEndAction(MxParam&); @@ -61,7 +61,7 @@ class Infocenter : public LegoWorld { void PlayCutScene(MxU32 p_entityId, MxBool p_scale); void StopCutScene(); void StartCredits(); - static void DeleteCredits(); + static void StopCredits(); void PlayDialogue(MxS32 p_objectId); void StopCurrentDialogue(); static void PlayBookAnimation(); diff --git a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp index 26c02b61..7b7a4262 100644 --- a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp +++ b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp @@ -84,7 +84,7 @@ MxLong Infocenter::Notify(MxParam& p_param) case c_notificationEndAction: return HandleEndAction(p_param); case c_notificationKeyPress: - return HandleKeyPress(((LegoEventNotificationParam&) p_param).GetKey()); + return (MxU8)HandleKeyPress(((LegoEventNotificationParam&) p_param).GetKey()); case c_notificationButtonUp: return HandleButtonUp( ((LegoEventNotificationParam&) p_param).GetX(), @@ -344,10 +344,47 @@ MxLong Infocenter::HandleMouseMove(MxS32 p_x, MxS32 p_y) return 1; } -// STUB: LEGO1 0x1006fda0 -MxU8 Infocenter::HandleKeyPress(char p_key) +// FUNCTION: LEGO1 0x1006fda0 +MxU32 Infocenter::HandleKeyPress(char p_key) { - return 1; + MxU32 result = 0; + if (p_key == ' ' && m_worldStarted) { + switch (m_infocenterState->GetUnknown0x74()) { + case 0: + StopCutScene(); + m_infocenterState->SetUnknown0x74(1); + if (m_infocenterState->GetInfocenterBufferElement(0) == 0) { + m_unk0x1d2 = 1; + return 1; + } + break; + case 1: + case 4: + break; + default: + result = m_unk0xf8; + StopCurrentDialogue(); + switch (m_infocenterState->GetUnknown0x74()) { + case 5: + case 12: + m_unk0xf8 = result; + return 1; + default: + m_infocenterState->SetUnknown0x74(2); + return 1; + case 8: + case 11: + break; + } + case 13: + StopCredits(); + break; + } + + result = 1; + } + + return result; } // STUB: LEGO1 0x1006feb0 @@ -452,7 +489,7 @@ void Infocenter::StartCredits() } // FUNCTION: LEGO1 0x10071250 -void DeleteCredits() +void Infocenter::StopCredits() { MxDSAction action; action.SetObjectId(499);