diff --git a/LEGO1/lego/legoomni/include/actions/regbook_actions.h b/LEGO1/lego/legoomni/include/actions/regbook_actions.h index 74182f46..42470c15 100644 --- a/LEGO1/lego/legoomni/include/actions/regbook_actions.h +++ b/LEGO1/lego/legoomni/include/actions/regbook_actions.h @@ -76,35 +76,35 @@ enum Script { c_Back_Down_Bitmap = 66, c_Info_Down_Bitmap = 67, c_Check0_Ctl = 68, - c_Check0_Bitmap = 69, - c_Check0_Bitmap = 70, + c_Check0_Bitmap_69 = 69, + c_Check0_Bitmap_70 = 70, c_Check1_Ctl = 71, - c_Check1_Bitmap = 72, - c_Check1_Bitmap = 73, + c_Check1_Bitmap_72 = 72, + c_Check1_Bitmap_73 = 73, c_Check2_Ctl = 74, - c_Check2_Bitmap = 75, - c_Check2_Bitmap = 76, + c_Check2_Bitmap_75 = 75, + c_Check2_Bitmap_76 = 76, c_Check3_Ctl = 77, - c_Check3_Bitmap = 78, - c_Check3_Bitmap = 79, + c_Check3_Bitmap_78 = 78, + c_Check3_Bitmap_79 = 79, c_Check4_Ctl = 80, - c_Check4_Bitmap = 81, - c_Check4_Bitmap = 82, + c_Check4_Bitmap_81 = 81, + c_Check4_Bitmap_82 = 82, c_Check5_Ctl = 83, - c_Check5_Bitmap = 84, - c_Check5_Bitmap = 85, + c_Check5_Bitmap_84 = 84, + c_Check5_Bitmap_85 = 85, c_Check6_Ctl = 86, - c_Check6_Bitmap = 87, - c_Check6_Bitmap = 88, + c_Check6_Bitmap_87 = 87, + c_Check6_Bitmap_88 = 88, c_Check7_Ctl = 89, - c_Check7_Bitmap = 90, - c_Check7_Bitmap = 91, + c_Check7_Bitmap_90 = 90, + c_Check7_Bitmap_91 = 91, c_Check8_Ctl = 92, - c_Check8_Bitmap = 93, - c_Check8_Bitmap = 94, + c_Check8_Bitmap_93 = 93, + c_Check8_Bitmap_94 = 94, c_Check9_Ctl = 95, - c_Check9_Bitmap = 96, - c_Check9_Bitmap = 97, + c_Check9_Bitmap_96 = 96, + c_Check9_Bitmap_97 = 97, c_ConfigAnimation = 98, c_Chptr_Model = 99, c_DuneBugy_Model = 100, diff --git a/LEGO1/lego/legoomni/include/legogamestate.h b/LEGO1/lego/legoomni/include/legogamestate.h index 3252b2c9..4d9085fe 100644 --- a/LEGO1/lego/legoomni/include/legogamestate.h +++ b/LEGO1/lego/legoomni/include/legogamestate.h @@ -162,11 +162,13 @@ class LegoGameState { inline void SetActorId(MxU8 p_actorId) { m_actorId = p_actorId; } inline void SetUnknown0x41c(undefined4 p_unk0x41c) { m_unk0x41c = p_unk0x41c; } inline void SetUnknown0x42c(Area p_unk0x42c) { m_unk0x42c = p_unk0x42c; } + inline Username* GetPlayersIndex(MxS32 p_index) { return &m_players[p_index]; } + inline MxS16 GetPlayerCount() { return m_playerCount; } void SetCurrentAct(Act p_currentAct); void FindLoadedAct(); -private: +public: void RegisterState(LegoState* p_state); MxResult WriteVariable(LegoStorage* p_storage, MxVariableTable* p_from, const char* p_variableName); MxResult WriteEndOfVariables(LegoStorage* p_storage); diff --git a/LEGO1/lego/legoomni/include/registrationbook.h b/LEGO1/lego/legoomni/include/registrationbook.h index c9628786..e281b822 100644 --- a/LEGO1/lego/legoomni/include/registrationbook.h +++ b/LEGO1/lego/legoomni/include/registrationbook.h @@ -1,7 +1,10 @@ #ifndef REGISTRATIONBOOK_H #define REGISTRATIONBOOK_H +#include "jukebox.h" #include "legoworld.h" +#include "mxcontrolpresenter.h" +#include "mxstillpresenter.h" class InfocenterState; class MxEndActionNotificationParam; @@ -39,25 +42,25 @@ class RegistrationBook : public LegoWorld { // RegistrationBook::`scalar deleting destructor' private: - undefined4 m_unk0xf8; // 0xf8 - undefined m_unk0xfc; // 0xfc - undefined m_unk0xfd[3]; // 0xfd - undefined m_unk0x100[0x68]; // 0x100 - undefined m_unk0x168[0x118]; // 0x168 + undefined4 m_unk0xf8; // 0xf8 + undefined m_unk0xfc; // 0xfc + undefined m_unk0xfd[3]; // 0xfd + MxStillPresenter* m_alphabet[26]; // 0x100 + MxStillPresenter* m_name[10][7]; // 0x168 struct { - undefined4 m_unk0x00[3]; // 0x00 - undefined2 m_unk0x0c; // 0x0c - undefined2 m_unk0x0e; // 0x0e - } m_unk0x280; // 0x280 - undefined m_unk0x290[0x28]; // 0x290 - undefined2 m_unk0x2b8; // 0x2b8 - InfocenterState* m_infocenterState; // 0x2bc - undefined m_unk0x2c0; // 0x2c0 - undefined m_unk0x2c1; // 0x2c1 - undefined m_unk0x2c2[0x02]; // 0x2c2 - undefined4 m_unk0x2c4; // 0x2c4 - undefined4 m_unk0x2c8; // 0x2c8 - undefined4 m_unk0x2cc; // 0x2cc + undefined4 m_unk0x00[3]; // 0x00 + undefined2 m_unk0x0c; // 0x0c + undefined2 m_unk0x0e; // 0x0e + } m_unk0x280; // 0x280 + MxControlPresenter* m_checkmark[10]; // 0x290 + undefined2 m_unk0x2b8; // 0x2b8 + InfocenterState* m_infocenterState; // 0x2bc + undefined m_unk0x2c0; // 0x2c0 + undefined m_unk0x2c1; // 0x2c1 + undefined m_unk0x2c2[0x02]; // 0x2c2 + undefined4 m_unk0x2c4; // 0x2c4 + undefined4 m_unk0x2c8; // 0x2c8 + undefined4 m_unk0x2cc; // 0x2cc MxLong HandleEndAction(MxEndActionNotificationParam& p_param); MxLong HandleKeyPress(MxS8 p_key); diff --git a/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp b/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp index 35bfb3dc..c5b704f0 100644 --- a/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp +++ b/LEGO1/lego/legoomni/src/worlds/registrationbook.cpp @@ -4,24 +4,27 @@ #include "legocontrolmanager.h" #include "legogamestate.h" #include "legoinputmanager.h" +#include "legoomni.h" #include "misc.h" #include "mxactionnotificationparam.h" +#include "mxbackgroundaudiomanager.h" #include "mxmisc.h" #include "mxnotificationmanager.h" #include "mxtimer.h" +#include "regbook_actions.h" DECOMP_SIZE_ASSERT(RegistrationBook, 0x2d0) // FUNCTION: LEGO1 0x10076d20 RegistrationBook::RegistrationBook() : m_unk0xf8(0x80000000), m_unk0xfc(1) { - memset(m_unk0x100, 0, sizeof(m_unk0x100)); - memset(m_unk0x168, 0, sizeof(m_unk0x168)); + memset(m_alphabet, 0, sizeof(m_alphabet)); + memset(m_name, 0, sizeof(m_name)); - // Maybe not be part of the struct, but then it would need packing + // May not be part of the struct, but then it would need packing m_unk0x280.m_unk0x0e = 0; - memset(m_unk0x290, 0, sizeof(m_unk0x290)); + memset(m_checkmark, 0, sizeof(m_checkmark)); memset(&m_unk0x280, -1, sizeof(m_unk0x280) - 2); m_unk0x2b8 = 0; @@ -110,10 +113,80 @@ MxLong RegistrationBook::HandleClick(LegoControlManagerEvent& p_param) return 0; } -// STUB: LEGO1 0x10077cc0 +// FUNCTION: LEGO1 0x10077cc0 void RegistrationBook::ReadyWorld() { - // TODO + LegoGameState* gameState = GameState(); + gameState->GetHistory()->WriteScoreHistory(); + + PlayMusic(JukeboxScript::c_InformationCenter_Music); + + char letterBuffer[12] = "A_Bitmap"; + for (MxS16 i = 0; i < 26; i++) { + m_alphabet[i] = (MxStillPresenter*) Find("MxStillPresenter", letterBuffer); + + // We need to loop through the entire alphabet, + // so increment the first char of the bitmap name + letterBuffer[0]++; + } + + // Now we have to do the checkmarks + char checkmarkBuffer[] = "Check0_Ctl"; + for (i = 0; i < 10; i++) { + m_checkmark[i] = (MxControlPresenter*) Find("MxControlPresenter", checkmarkBuffer); + + // Just like in the prior letter loop, + // we need to increment the fifth char + // to get the next checkmark bitmap + checkmarkBuffer[5]++; + } + + MxS16 playerCount = GameState()->GetPlayerCount(); + + // Optimization: Just skip the whole loop if there's no player data + if (playerCount > 0) { + for (i = 1; i <= playerCount; i++) { + for (MxS16 j = 0; j < 7; j++) { + if (GameState()->m_players[i].m_letters[j] != -1) { + if (!j) { + m_checkmark[i]->Enable(TRUE); + } + + // Start building the player name using a two-dimensional array + m_name[i][j] = m_alphabet[gameState->m_players[i].m_letters[j]]->Clone(); + + // Enable the presenter to actually show the letter + m_name[i][j]->Enable(TRUE); + + m_name[i][j]->SetTickleState(MxPresenter::e_repeating); + m_name[i][j]->SetPosition((23 * j + 343), 27 * i + 121); + } + } + } + } + + if (m_infocenterState->GetNameLetter(0) == NULL) { + MxDSAction action; + action.SetAtomId(*g_regbookScript); + action.SetObjectId(RegbookScript::c_iic006in_RunAnim); + + BackgroundAudioManager()->LowerVolume(); + Start(&action); + } + else { + LegoROI* infoman = FindROI("infoman"); + + MxDSAction action; + action.SetAtomId(*g_regbookScript); + action.SetObjectId(RegbookScript::c_iic008in_PlayWav); + + BackgroundAudioManager()->LowerVolume(); + Start(&action); + + if (infoman != NULL) { + infoman->SetUnknown0x0c(0); + } + } } // STUB: LEGO1 0x10077fd0