2023-06-29 04:10:08 -04:00
|
|
|
#include "historybook.h"
|
|
|
|
|
2024-02-19 09:24:30 -05:00
|
|
|
#include "jukebox.h"
|
2024-03-17 13:01:47 -04:00
|
|
|
#include "jukebox_actions.h"
|
2024-02-17 14:04:48 -05:00
|
|
|
#include "legocontrolmanager.h"
|
|
|
|
#include "legoinputmanager.h"
|
2024-03-09 15:07:52 -05:00
|
|
|
#include "misc.h"
|
|
|
|
#include "mxmisc.h"
|
2024-02-17 14:04:48 -05:00
|
|
|
#include "mxnotificationmanager.h"
|
2024-05-03 12:19:12 -04:00
|
|
|
#include "mxstillpresenter.h"
|
2024-02-17 14:04:48 -05:00
|
|
|
#include "mxtransitionmanager.h"
|
|
|
|
|
|
|
|
DECOMP_SIZE_ASSERT(HistoryBook, 0x3e4)
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100822f0
|
2023-06-29 04:10:08 -04:00
|
|
|
HistoryBook::HistoryBook()
|
|
|
|
{
|
2024-06-25 11:56:30 -04:00
|
|
|
memset(m_alphabet, 0, sizeof(m_alphabet));
|
|
|
|
memset(m_names, 0, sizeof(m_names));
|
|
|
|
memset(m_scores, 0, sizeof(m_scores));
|
2024-02-17 14:04:48 -05:00
|
|
|
NotificationManager()->Register(this);
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2024-11-10 11:07:48 -05:00
|
|
|
// FUNCTION: LEGO1 0x100824d0
|
|
|
|
// FUNCTION: BETA10 0x1002b63e
|
2023-06-29 04:10:08 -04:00
|
|
|
HistoryBook::~HistoryBook()
|
|
|
|
{
|
2024-11-10 11:07:48 -05:00
|
|
|
for (MxS16 scoreIndex = 0; scoreIndex < GameState()->m_history.GetCount(); scoreIndex++) {
|
|
|
|
if (m_scores[scoreIndex]) {
|
|
|
|
delete m_scores[scoreIndex]->GetAction();
|
|
|
|
delete m_scores[scoreIndex];
|
|
|
|
m_scores[scoreIndex] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (MxS16 letterIndex = 0; letterIndex < (MxS16) sizeOfArray(m_names[0]); letterIndex++) {
|
|
|
|
if (m_names[scoreIndex][letterIndex]) {
|
|
|
|
delete m_names[scoreIndex][letterIndex]->GetAction();
|
|
|
|
delete m_names[scoreIndex][letterIndex];
|
|
|
|
m_names[scoreIndex][letterIndex] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
InputManager()->UnRegister(this);
|
|
|
|
if (InputManager()->GetWorld() == this) {
|
|
|
|
InputManager()->ClearWorld();
|
|
|
|
}
|
|
|
|
|
|
|
|
ControlManager()->Unregister(this);
|
|
|
|
NotificationManager()->Unregister(this);
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
|
|
|
|
2024-02-17 14:04:48 -05:00
|
|
|
// FUNCTION: LEGO1 0x10082610
|
2024-01-20 18:04:46 -05:00
|
|
|
MxResult HistoryBook::Create(MxDSAction& p_dsAction)
|
|
|
|
{
|
2024-02-17 14:04:48 -05:00
|
|
|
MxResult result = LegoWorld::Create(p_dsAction);
|
|
|
|
if (result == SUCCESS) {
|
|
|
|
InputManager()->SetWorld(this);
|
|
|
|
ControlManager()->Register(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
InputManager()->SetCamera(NULL);
|
|
|
|
InputManager()->Register(this);
|
|
|
|
|
2024-11-01 12:21:15 -04:00
|
|
|
GameState()->m_currentArea = LegoGameState::Area::e_histbook;
|
2024-02-17 14:04:48 -05:00
|
|
|
GameState()->StopArea(LegoGameState::Area::e_previousArea);
|
|
|
|
return result;
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-02-17 14:04:48 -05:00
|
|
|
// FUNCTION: LEGO1 0x10082680
|
2024-12-03 17:51:03 -05:00
|
|
|
// FUNCTION: BETA10 0x1002b907
|
2023-12-13 05:48:14 -05:00
|
|
|
MxLong HistoryBook::Notify(MxParam& p_param)
|
2023-06-29 04:10:08 -04:00
|
|
|
{
|
2024-12-03 17:51:03 -05:00
|
|
|
MxNotificationParam& param = (MxNotificationParam&) p_param;
|
2024-02-17 14:04:48 -05:00
|
|
|
LegoWorld::Notify(p_param);
|
2024-02-17 14:26:29 -05:00
|
|
|
|
2024-02-17 14:04:48 -05:00
|
|
|
if (m_worldStarted) {
|
2024-12-03 17:51:03 -05:00
|
|
|
switch (param.GetNotification()) {
|
2024-02-17 14:04:48 -05:00
|
|
|
case c_notificationButtonUp:
|
2024-03-13 13:17:20 -04:00
|
|
|
m_destLocation = LegoGameState::Area::e_infoscor;
|
2024-07-04 17:28:23 -04:00
|
|
|
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE);
|
2024-02-17 14:04:48 -05:00
|
|
|
break;
|
|
|
|
case c_notificationTransitioned:
|
2024-03-13 13:17:20 -04:00
|
|
|
GameState()->SwitchArea(m_destLocation);
|
2024-02-17 14:04:48 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-06-29 04:10:08 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
return 0;
|
2023-06-29 04:10:08 -04:00
|
|
|
}
|
2024-01-20 18:04:46 -05:00
|
|
|
|
2024-02-19 09:35:20 -05:00
|
|
|
inline void SetColor(MxStillPresenter* p_presenter, MxU8 p_color, MxU8* p_colors, MxS32 p_x, MxS32 p_y)
|
2024-02-19 09:24:30 -05:00
|
|
|
{
|
|
|
|
if (p_color) {
|
|
|
|
for (MxS32 lax = 0; lax < 4; lax++) {
|
|
|
|
if (p_presenter->GetAlphaMask() != NULL) {
|
|
|
|
memset(NULL, p_colors[p_color - 1], 4);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
memset(p_presenter->GetBitmap()->GetStart(p_x, p_y + lax), p_colors[p_color - 1], 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100826f0
|
2024-01-27 15:18:35 -05:00
|
|
|
void HistoryBook::ReadyWorld()
|
2024-01-20 18:04:46 -05:00
|
|
|
{
|
2024-02-19 09:24:30 -05:00
|
|
|
LegoWorld::ReadyWorld();
|
2024-02-26 11:19:16 -05:00
|
|
|
GameState()->GetHistory()->WriteScoreHistory();
|
2024-02-19 09:24:30 -05:00
|
|
|
|
|
|
|
char bitmap[] = "A_Bitmap";
|
|
|
|
for (MxS16 i = 0; i < 26; i++) {
|
|
|
|
m_alphabet[i] = (MxStillPresenter*) Find("MxStillPresenter", bitmap);
|
|
|
|
bitmap[0]++;
|
|
|
|
}
|
|
|
|
|
|
|
|
MxStillPresenter* scoreboxMaster = (MxStillPresenter*) Find("MxStillPresenter", "ScoreBox");
|
|
|
|
MxU8 scoreColors[3] =
|
|
|
|
{0x76, 0x4c, 0x38}; // yellow - #FFB900, blue - #00548C, red - #CB1220, background - #CECECE, border - #74818B
|
|
|
|
MxS32 scoreY = 0x79;
|
|
|
|
|
2024-02-26 11:19:16 -05:00
|
|
|
for (MxS16 scoreIndex = 0; scoreIndex < GameState()->GetHistory()->m_count; scoreIndex++) {
|
|
|
|
LegoGameState::ScoreItem* score = GameState()->GetHistory()->GetScore(scoreIndex);
|
2024-02-19 09:24:30 -05:00
|
|
|
|
|
|
|
MxStillPresenter** scorebox = &m_scores[scoreIndex];
|
|
|
|
*scorebox = scoreboxMaster->Clone();
|
|
|
|
|
|
|
|
MxS32 scoreX = 0x90;
|
|
|
|
if (scoreIndex >= 10) {
|
|
|
|
if (scoreIndex == 10) {
|
|
|
|
scoreY = 0x79;
|
|
|
|
}
|
|
|
|
|
|
|
|
scoreX = 0x158;
|
|
|
|
}
|
|
|
|
|
|
|
|
MxS32 scoreboxX = 1;
|
|
|
|
MxS32 scoreboxRow = 5;
|
2024-02-26 11:19:16 -05:00
|
|
|
MxS32 scoreState = 0;
|
2024-02-19 09:24:30 -05:00
|
|
|
|
|
|
|
for (; scoreboxRow > 0; scoreboxRow--) {
|
|
|
|
for (MxS32 scoreBoxColumn = 0, scoreboxY = 1; scoreBoxColumn < 5; scoreBoxColumn++, scoreboxY += 5) {
|
2024-11-27 17:42:05 -05:00
|
|
|
SetColor(*scorebox, score->m_scores[scoreState][scoreBoxColumn], scoreColors, scoreboxX, scoreboxY);
|
2024-02-19 09:24:30 -05:00
|
|
|
}
|
|
|
|
|
2024-02-26 11:19:16 -05:00
|
|
|
scoreState++;
|
2024-02-19 09:24:30 -05:00
|
|
|
scoreboxX += 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
(*scorebox)->Enable(TRUE);
|
|
|
|
(*scorebox)->SetTickleState(MxPresenter::e_repeating);
|
|
|
|
(*scorebox)->SetPosition(scoreX + 0xa1, scoreY);
|
|
|
|
|
2024-05-14 10:35:22 -04:00
|
|
|
for (MxS16 letterIndex = 0; letterIndex < (MxS16) sizeOfArray(m_names[0]);) {
|
2024-02-19 09:24:30 -05:00
|
|
|
MxS16 letter = score->m_name.m_letters[letterIndex];
|
|
|
|
|
|
|
|
if (letter == -1) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
MxS16 nameIndex = letterIndex++;
|
|
|
|
m_names[scoreIndex][nameIndex] = m_alphabet[letter]->Clone();
|
|
|
|
m_names[scoreIndex][nameIndex]->Enable(TRUE);
|
|
|
|
m_names[scoreIndex][nameIndex]->SetTickleState(MxPresenter::e_repeating);
|
|
|
|
m_names[scoreIndex][nameIndex]->SetPosition(scoreX, scoreY);
|
|
|
|
scoreX += 0x17;
|
|
|
|
}
|
|
|
|
|
|
|
|
scoreY += 0x1b;
|
|
|
|
}
|
|
|
|
|
2024-03-10 12:08:21 -04:00
|
|
|
PlayMusic(JukeboxScript::c_InformationCenter_Music);
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|
|
|
|
|
2024-02-17 14:04:48 -05:00
|
|
|
// FUNCTION: LEGO1 0x10082a10
|
2024-05-24 20:41:57 -04:00
|
|
|
MxBool HistoryBook::Escape()
|
2024-01-20 18:04:46 -05:00
|
|
|
{
|
2024-03-13 13:17:20 -04:00
|
|
|
m_destLocation = LegoGameState::Area::e_infomain;
|
2024-02-17 14:04:48 -05:00
|
|
|
return TRUE;
|
2024-01-20 18:04:46 -05:00
|
|
|
}
|