Isle
Loading...
Searching...
No Matches
historybook.cpp
Go to the documentation of this file.
1#include "historybook.h"
2
3#include "jukebox.h"
4#include "jukebox_actions.h"
6#include "legoinputmanager.h"
7#include "misc.h"
8#include "mxmisc.h"
10#include "mxstillpresenter.h"
11#include "mxtransitionmanager.h"
12
14
15// FUNCTION: LEGO1 0x100822f0
17{
18 memset(m_alphabet, 0, sizeof(m_alphabet));
19 memset(m_name, 0, sizeof(m_name));
20 memset(m_scores, 0, sizeof(m_scores));
22}
23
24// FUNCTION: LEGO1 0x100824d0
25// FUNCTION: BETA10 0x1002b63e
27{
28 for (MxS16 scoreIndex = 0; scoreIndex < GameState()->m_history.GetCount(); scoreIndex++) {
29 if (m_scores[scoreIndex]) {
30 delete m_scores[scoreIndex]->GetAction();
31 delete m_scores[scoreIndex];
32 m_scores[scoreIndex] = NULL;
33 }
34
35 for (MxS16 letterIndex = 0; letterIndex < (MxS16) sizeOfArray(m_name[0]); letterIndex++) {
36 if (m_name[scoreIndex][letterIndex]) {
37 delete m_name[scoreIndex][letterIndex]->GetAction();
38 delete m_name[scoreIndex][letterIndex];
39 m_name[scoreIndex][letterIndex] = NULL;
40 }
41 }
42 }
43
44 InputManager()->UnRegister(this);
45 if (InputManager()->GetWorld() == this) {
47 }
48
51}
52
53// FUNCTION: LEGO1 0x10082610
55{
56 MxResult result = LegoWorld::Create(p_dsAction);
57 if (result == SUCCESS) {
58 InputManager()->SetWorld(this);
59 ControlManager()->Register(this);
60 }
61
63 InputManager()->Register(this);
64
67 return result;
68}
69
70// FUNCTION: LEGO1 0x10082680
71// FUNCTION: BETA10 0x1002b907
73{
74 MxNotificationParam& param = (MxNotificationParam&) p_param;
75 LegoWorld::Notify(p_param);
76
77 if (m_worldStarted) {
78 switch (param.GetNotification()) {
80 m_destLocation = LegoGameState::Area::e_infoscor;
82 break;
84 GameState()->SwitchArea(m_destLocation);
85 break;
86 }
87 }
88
89 return 0;
90}
91
92// FUNCTION: LEGO1 0x100826f0
93// FUNCTION: BETA10 0x1002b9b9
95{
96 undefined2 dummy1 = 0x90, dummy2 = 0x79, dummy3 = 0xc8, dummy4 = 0x17, dummy5 = 0x1b;
97#ifndef BETA10
99#endif
101
102 char bitmap[] = "A_Bitmap";
103 MxS16 i;
104
105 for (i = 0; i < 26; i++) {
106 // TODO: This might be an inline function.
107 // See also `RegistrationBook::ReadyWorld()`.
108 if (i < 26) {
109 m_alphabet[i] = (MxStillPresenter*) Find("MxStillPresenter", bitmap);
110 assert(m_alphabet[i]);
111 bitmap[0]++;
112 }
113 }
114
115 MxStillPresenter* scoreboxMaster = (MxStillPresenter*) Find("MxStillPresenter", "ScoreBox");
116 MxU8 scoreColors[3] =
117 {0x76, 0x4c, 0x38}; // yellow - #FFB900, blue - #00548C, red - #CB1220, background - #CECECE, border - #74818B
118
119 MxS32 scoreY;
120
121 for (i = 0, scoreY = 0x79; i < GameState()->m_history.GetCount(); i++, scoreY += 0x1b) {
123
124 m_scores[i] = scoreboxMaster->Clone();
125
126 MxS32 scoreX = 0x90;
127 if (i >= 10) {
128 if (i == 10) {
129 scoreY = 0x79;
130 }
131
132 scoreX = 0x158;
133 }
134
135 for (MxS32 scoreState = 0, scoreboxX = 1; scoreState < 5; scoreState++, scoreboxX += 5) {
136 for (MxS32 scoreBoxColumn = 0, scoreboxY = 1; scoreBoxColumn < 5; scoreBoxColumn++, scoreboxY += 5) {
137 MxU8 color = score->m_scores[scoreState][scoreBoxColumn];
138
139 if (color > 0) {
140 for (MxS32 lax = 0; lax < 4; lax++) {
141#ifdef BETA10
142 memset(m_scores[i]->GetBitmapStart(scoreboxX, scoreboxY + lax), scoreColors[color - 1], 4);
143#else
144 if (m_scores[i]->GetAlphaMask() != NULL) {
145 memset(NULL, scoreColors[color - 1], 4);
146 }
147 else {
148 memset(
149 m_scores[i]->GetBitmap()->GetStart(scoreboxX, lax + scoreboxY),
150 scoreColors[color - 1],
151 4
152 );
153 }
154#endif
155 }
156 }
157 }
158 }
159
160 m_scores[i]->Enable(TRUE);
162 m_scores[i]->SetPosition(scoreX + 0xa1, scoreY);
163
164#ifdef BETA10
165 for (MxS16 j = 0; score->m_name.m_letters[j] != -1; j++, scoreX += 0x17)
166#else
167 for (MxS16 j = 0; j < (MxS16) sizeOfArray(m_name[0]) && score->m_name.m_letters[j] != -1; j++, scoreX += 0x17)
168#endif
169 {
170 m_name[i][j] = m_alphabet[score->m_name.m_letters[j]]->Clone();
171
172 assert(m_name[i][j]);
173 m_name[i][j]->Enable(TRUE);
175 m_name[i][j]->SetPosition(scoreX, scoreY);
176 }
177 }
178
179#ifndef BETA10
181#endif
182}
183
184// FUNCTION: LEGO1 0x10082a10
186{
187 m_destLocation = LegoGameState::Area::e_infomain;
188 return TRUE;
189}
[AI] The HistoryBook class represents the "History Book" world/scene shown in LEGO Island,...
Definition: historybook.h:17
~HistoryBook() override
[AI] Destructor for HistoryBook.
Definition: historybook.cpp:26
void ReadyWorld() override
[AI] Prepares the HistoryBook for display, populates bitmap presenters with alphabet letters,...
Definition: historybook.cpp:94
MxResult Create(MxDSAction &p_dsAction) override
[AI] Sets up the world based on the provided action, registers for input/control, and enters the hist...
Definition: historybook.cpp:54
MxLong Notify(MxParam &p_param) override
[AI] Notification handler processing game events for this world, such as button presses and transitio...
Definition: historybook.cpp:72
MxBool Escape() override
[AI] Handles Escape key/input, setting the world to transition to the Info Main area.
void Register(MxCore *p_listener)
[AI] Adds a listener to be notified of control events.
void Unregister(MxCore *p_listener)
[AI] Removes a listener so it no longer receives control events.
void SwitchArea(Area p_area)
Switches the whole game state into a new area/world; manages transitions/scene loads.
History m_history
High score table/history for current game. [AI].
Area m_currentArea
Area/world the player is presently in. [AI].
void StopArea(Area p_area)
Calls cleanup logic for the specified area (removes actors, VMs, closes handles, etc....
@ e_infomain
Information Center, main screen. [AI].
Definition: legogamestate.h:96
@ e_previousArea
Alias: go to previous area. [AI].
Definition: legogamestate.h:94
@ e_histbook
History book (scoreboard). [AI].
@ e_infoscor
Info Center hi-score area. [AI].
void UnRegister(MxCore *)
[AI] Unregister a previously registered recipient so it will no longer receive input notifications.
void ClearWorld()
[AI] Remove any world assignment (used to clear targeting/scene changes). [AI]
void SetCamera(LegoCameraController *p_camera)
[AI] Assigns a new camera controller for mouse/look operations.
void SetWorld(LegoWorld *p_world)
[AI] Assigns the current world to receive mouse/click/pick notifications.
void Register(MxCore *)
[AI] Register a core object as a recipient for keyboard events; safe for concurrent multi-threading.
virtual void ReadyWorld()
Called when the world is ready to be used—typically for custom scene setup after startup.
Definition: legoworld.cpp:874
MxBool m_worldStarted
Indicates if the world has successfully started and is considered active.
Definition: legoworld.h:388
MxCore * Find(const char *p_class, const char *p_name)
Finds an object of a given class and name in the world.
Definition: legoworld.cpp:573
MxLong Notify(MxParam &p_param) override
Notification callback responding to registered events such as EndAction and NewPresenter.
Definition: legoworld.cpp:212
MxResult Create(MxDSAction &p_dsAction) override
Initializes the world using an action, creating entity and sound lists, and camera controller.
Definition: legoworld.cpp:58
[AI] Represents an action deserialized from SI chunks, holding key animation or script parameters suc...
Definition: mxdsaction.h:17
void Unregister(MxCore *p_listener)
[AI] Removes a previously registered listener and flushes any pending notifications for it.
void Register(MxCore *p_listener)
[AI] Registers a listener object to receive notifications.
[AI] Parameter object representing a single notification or event, carrying an identifier and sender ...
NotificationId GetNotification() const
[AI] Retrieves the current notification type of this parameter.
[AI] MxParam serves as a polymorphic base class for parameter passing in event and notification syste...
Definition: mxparam.h:7
virtual void SetTickleState(TickleState p_tickleState)
[AI] Forces the tickle state, advancing to the requested lifecycle stage.
Definition: mxpresenter.h:100
@ e_repeating
[AI] Presentation is repeating (e.g., looping media).
Definition: mxpresenter.h:28
MxDSAction * GetAction() const
[AI] Returns the current action being presented.
Definition: mxpresenter.h:175
[AI] Presenter for single still image/bitmap media sources in the game.
virtual MxStillPresenter * Clone()
[AI] Clones the presenter, attempting to fully duplicate internal state and associated memory resourc...
virtual void SetPosition(MxS32 p_x, MxS32 p_y)
[AI] Sets the pixel-based position of the presented image.
void Enable(MxBool p_enable) override
[AI] Sets the enabled/disabled state of the presenter, updating the video manager's rendering as need...
MxResult StartTransition(TransitionType p_animationType, MxS32 p_speed, MxBool p_doCopy, MxBool p_playMusicInAnim)
[AI] Begins a new transition animation of type p_animationType at the specified speed,...
@ e_mosaic
[AI] Complex mosaic block-out effect.
#define TRUE
Definition: d3drmdef.h:28
#define FALSE
Definition: d3drmdef.h:27
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
unsigned short undefined2
Definition: decomp.h:27
#define sizeOfArray(arr)
Definition: decomp.h:23
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
Definition: legotypes.h:30
LegoGameState * GameState()
[AI] Accessor for the game's central game state controller. [AI]
Definition: misc.cpp:61
MxTransitionManager * TransitionManager()
[AI] Accessor for the MxTransitionManager, handling level transitions, fades, and world changes....
Definition: misc.cpp:208
LegoControlManager * ControlManager()
[AI] Accessor for the control manager through the input manager; manages higher-level user/game contr...
Definition: misc.cpp:53
void PlayMusic(JukeboxScript::Script p_objectId)
[AI] Starts music playback by scripting the background audio manager to play the music piece referenc...
Definition: misc.cpp:216
LegoInputManager * InputManager()
[AI] Accessor for the input manager, which handles keyboard, mouse, and controller input....
Definition: misc.cpp:45
MxNotificationManager * NotificationManager()
[AI] Returns the notification manager for system-wide state/update notifications.
Definition: mxmisc.cpp:17
@ c_notificationButtonUp
[AI] Mouse/gamepad button release [AI]
@ c_notificationTransitioned
[AI] Object has transitioned states or locations [AI]
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
int MxLong
[AI]
Definition: mxtypes.h:83
signed short MxS16
[AI]
Definition: mxtypes.h:26
unsigned char MxU8
[AI]
Definition: mxtypes.h:8
signed int MxS32
[AI]
Definition: mxtypes.h:38
@ c_InformationCenter_Music
[AI] Background music for the information center.
void WriteScoreHistory()
Rebuilds the high score table from current state objects, sorts it descending. [AI].
ScoreItem * GetScore(MxS32 p_index)
Gets pointer to score entry at index, or NULL if out of range.
MxS16 GetCount()
Current number of score entries in the history. [AI].
Single score record for a player, including high score grids for all major games.
Username m_name
Username this score belongs to. [AI].
MxU8 m_scores[5][5]
Scores by (minigame,row,column): custom packed format for all 5 game types. [AI].
MxS16 m_letters[7]
Array of 7 wide characters: player name (filled by registration). [AI].