Isle
Loading...
Searching...
No Matches
mxcompositepresenter.cpp
Go to the documentation of this file.
2
3#include "decomp.h"
5#include "mxautolock.h"
6#include "mxdsmultiaction.h"
7#include "mxmisc.h"
9#include "mxobjectfactory.h"
10
11#include <assert.h>
12
14
15// FUNCTION: LEGO1 0x100b60b0
17{
19}
20
21// FUNCTION: LEGO1 0x100b6390
23{
25}
26
27// FUNCTION: LEGO1 0x100b6410
28// FUNCTION: BETA10 0x100e9d37
30{
32
33 MxResult result = FAILURE;
34 MxDSActionList* actions = ((MxDSMultiAction*) p_action)->GetActionList();
35 MxObjectFactory* factory = ObjectFactory();
36 MxDSActionListCursor cursor(actions);
37 MxDSAction* action;
38
39 if (MxPresenter::StartAction(p_controller, p_action) == SUCCESS) {
40 cursor.Head();
41
42 while (cursor.Current(action)) {
43 MxBool success = FALSE;
44 const char* presenterName;
45 MxPresenter* presenter = NULL;
46
47 cursor.Next();
48
50 action->SetFlags(action->GetFlags() | MxDSAction::c_looping);
51 }
52 else if (m_action->GetFlags() & MxDSAction::c_bit3) {
53 action->SetFlags(action->GetFlags() | MxDSAction::c_bit3);
54 }
55
56 presenterName = PresenterNameDispatch(*action);
57 presenter = (MxPresenter*) factory->Create(presenterName);
58
59 if (presenter && presenter->AddToManager() == SUCCESS) {
60 presenter->SetCompositePresenter(this);
61 if (presenter->StartAction(p_controller, action) == SUCCESS) {
62 success = TRUE;
63 }
64 }
65
66 if (success) {
67 action->SetOrigin(this);
68 m_list.push_back(presenter);
69 }
70 else if (presenter) {
71 delete presenter;
72 }
73 }
74
75 result = SUCCESS;
76 }
77
78 return result;
79}
80
81// FUNCTION: LEGO1 0x100b65e0
82// FUNCTION: BETA10 0x101375bc
84{
86
87 if (!m_action) {
88 return;
89 }
90
91 ((MxDSMultiAction*) m_action)->GetActionList()->Empty();
92
93 while (!m_list.empty()) {
94 MxPresenter* presenter = m_list.front();
95 m_list.pop_front();
96 presenter->SetCompositePresenter(NULL);
97 presenter->EndAction();
98 }
99
100 MxDSAction* action = m_action;
102
103 if (action && action->GetOrigin()) {
105 action->GetOrigin(),
107 );
108 }
109}
110
111// FUNCTION: LEGO1 0x100b6760
112// FUNCTION: BETA10 0x1013771e
114{
116 MxNotificationParam& param = (MxNotificationParam&) p_param;
117
118 switch (param.GetNotification()) {
121 break;
124 break;
125 default:
126 assert(0);
127 break;
128 }
129
130 return 0;
131}
132
133// FUNCTION: LEGO1 0x100b67f0
135{
136 MxPresenter* presenter = (MxPresenter*) p_param.GetSender();
137 MxDSAction* action = p_param.GetAction();
138 MxCompositePresenterList::iterator it;
139
140 if (!m_list.empty()) {
141 for (it = m_list.begin(); it != m_list.end(); it++) {
142 if (*it == presenter) {
143 m_list.erase(it++);
144 break;
145 }
146 }
147 }
148
149 if (m_action) {
150 MxDSActionList* actions = ((MxDSMultiAction*) m_action)->GetActionList();
151 MxDSActionListCursor cursor(actions);
152
153 if (cursor.Find(action)) {
154 cursor.Detach();
155 }
156 }
157
158 if (presenter) {
159 delete presenter;
160 }
161
162 if (action) {
163 delete action;
164 }
165
166 if (m_list.empty()) {
167 EndAction();
168 }
169 else {
170 if (m_action->IsA("MxDSSerialAction") && it != m_list.end()) {
171 MxPresenter* presenter = *it;
172 if (presenter->GetCurrentTickleState() == e_idle) {
173 presenter->SetTickleState(e_ready);
174 }
175 }
176 }
177}
178
179// FUNCTION: LEGO1 0x100b69b0
181{
182 if (!m_list.empty()) {
183 MxPresenter* presenter = (MxPresenter*) p_param.GetSender();
184
185 for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
186 if (*it == presenter) {
187 m_list.erase(it++);
188
189 if (presenter->GetCurrentTickleState() == e_idle) {
190 presenter->SetTickleState(e_ready);
191 }
192
193 MxDSActionList* actions = ((MxDSMultiAction*) m_action)->GetActionList();
194 MxDSActionListCursor cursor(actions);
195
196 if (cursor.Find(presenter->GetAction())) {
197 cursor.Detach();
198 }
199
200 if (m_list.empty()) {
201 EndAction();
202 }
203 else {
204 if (m_action->IsA("MxDSSerialAction")) {
205 MxPresenter* presenter = *it;
206 if (presenter->GetCurrentTickleState() == e_idle) {
207 presenter->SetTickleState(e_ready);
208 }
209 }
210 }
211
212 return;
213 }
214 }
215
216 NotificationManager()->Send(this, p_param);
217 }
218}
219
220// FUNCTION: LEGO1 0x100b6b40
222{
223 for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
224 if (*it == p_presenter) {
225 if (++it == m_list.end()) {
228 }
229 }
230 else if (m_action->IsA("MxDSSerialAction")) {
231 MxPresenter* presenter = *it;
232 if (presenter->GetCurrentTickleState() == e_idle) {
233 presenter->SetTickleState(e_ready);
234 }
235 }
236 return;
237 }
238 }
239}
240
241// FUNCTION: LEGO1 0x100b6bc0
243{
244 ProgressTickleState(p_tickleState);
245
246 for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
247 MxPresenter* presenter = *it;
248 presenter->SetTickleState(p_tickleState);
249
250 if (m_action->IsA("MxDSSerialAction") && p_tickleState == e_ready) {
251 return;
252 }
253 }
254}
255
256// FUNCTION: LEGO1 0x100b6c30
258{
259 MxPresenter::Enable(p_enable);
260
261 for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
262 MxPresenter* presenter = *it;
263 presenter->Enable(p_enable);
264 }
265}
266
267// FUNCTION: LEGO1 0x100b6c80
269{
270 for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
271 MxPresenter* presenter = *it;
272 if (!presenter->HasTickleStatePassed(p_tickleState)) {
273 return FALSE;
274 }
275 }
276
277 return TRUE;
278}
MxDSAction * GetAction()
[AI] Direct access to the underlying action.
[AI] Composite presenter that manages a collection of child presenters, orchestrating their actions a...
void EndAction() override
[AI] Ends the composite action, terminating all child presenters and clearing action lists....
~MxCompositePresenter() override
[AI] Destructor, unregisters the presenter from the notification manager and properly cleans up conta...
MxCompositePresenterList m_list
[AI] List of owned child presenters that are managed by this MxCompositePresenter....
virtual void VTable0x60(MxPresenter *p_presenter)
[AI] Advance sequencing for serial multi-actions: promotes the next presenter in sequence to e_ready ...
MxCompositePresenter()
[AI] Default constructor; registers the composite presenter with the notification manager.
MxLong Notify(MxParam &p_param) override
[AI] Notifies the composite presenter of a particular event (such as end of sub-action or notificatio...
virtual void VTable0x58(MxEndActionNotificationParam &p_param)
[AI] Handler for "end action" notification, invoked when one of the child presenters finishes its ass...
void Enable(MxBool p_enable) override
[AI] Enables or disables this presenter and all child presenters.
virtual void VTable0x5c(MxNotificationParam &p_param)
[AI] Handler for generic presenter notification, such as state change.
void SetTickleState(TickleState p_tickleState) override
[AI] Change the tickle state of this composite presenter and propagate to each child.
MxResult StartAction(MxStreamController *p_controller, MxDSAction *p_action) override
[AI] Starts a composite action by creating child presenters for each action in a MxDSMultiAction list...
MxBool HasTickleStatePassed(TickleState p_tickleState) override
[AI] Checks if all child presenters have advanced past the given tickle state.
[AI] Convenience cursor class for iterating over an MxDSActionList.
[AI] A list (collection) of pointers to MxDSAction objects, supporting comparison,...
[AI] Represents an action deserialized from SI chunks, holding key animation or script parameters suc...
Definition: mxdsaction.h:17
MxU32 GetFlags()
[AI] Returns the flag field for this action (bitmask).
Definition: mxdsaction.h:177
MxBool IsA(const char *p_name) const override
[AI] Run-time type check, compares provided name with this or any ancestor type.
Definition: mxdsaction.h:80
void SetOrigin(MxCore *p_origin)
[AI] Sets the origin core pointer for this action, if spatially transforming/localizing this action.
Definition: mxdsaction.h:265
void SetFlags(MxU32 p_flags)
[AI] Sets the flag bitmask controlling action logic (enabled, looping, etc).
Definition: mxdsaction.h:183
MxCore * GetOrigin()
[AI] Returns a pointer to the "origin" core object, which may be used to localize the action.
Definition: mxdsaction.h:259
@ c_looping
[AI] Action or media should repeat in a loop [AI]
Definition: mxdsaction.h:21
@ c_bit3
[AI] Unknown - possibly reserved [AI]
Definition: mxdsaction.h:22
[AI] Represents a container for multiple MxDSAction objects, facilitating the grouping and management...
[AI] Notification parameter marking the end of an action, specialization of MxActionNotificationParam...
MxBool Next()
[AI]
MxBool Head()
[AI]
Definition: mxlist.h:252
void Detach()
[AI]
MxBool Current(T &p_obj)
[AI]
MxBool Find(T p_obj)
[AI]
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.
MxResult Send(MxCore *p_listener, const MxNotificationParam &p_param)
[AI] Queues a notification to be sent to a specific registered listener.
[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.
MxCore * GetSender() const
[AI] Retrieves the sender pointer associated with this notification.
[AI] Forward declaration for the factory responsible for constructing core objects from atom or type ...
virtual MxCore * Create(const char *p_name)
[AI] Creates a new instance of the class matching the provided string name.
[AI] MxParam serves as a polymorphic base class for parameter passing in event and notification syste...
Definition: mxparam.h:7
[AI] Abstract base class for all presenter types in the LEGO Island engine, responsible for managing ...
Definition: mxpresenter.h:20
virtual void SetTickleState(TickleState p_tickleState)
[AI] Forces the tickle state, advancing to the requested lifecycle stage.
Definition: mxpresenter.h:100
virtual void EndAction()
[AI] Terminates the current action, notifies listeners and resets state.
Definition: mxpresenter.cpp:59
void ProgressTickleState(TickleState p_tickleState)
[AI] Helper for advancing the presenter's tickle state and updating transition history.
Definition: mxpresenter.h:72
virtual void Enable(MxBool p_enable)
[AI] Enables or disables this presenter (controls action flags accordingly).
virtual MxResult StartAction(MxStreamController *, MxDSAction *)
[AI] Initiates presenter for a new action, setting up context and state.
Definition: mxpresenter.cpp:45
MxDSAction * m_action
[AI] The associated action currently being presented by this presenter.
Definition: mxpresenter.h:211
MxS32 GetCurrentTickleState() const
[AI] Returns the current tickle state.
Definition: mxpresenter.h:160
virtual MxBool HasTickleStatePassed(TickleState p_tickleState)
[AI] Checks if the specified tickle state has ever been passed since last reset.
Definition: mxpresenter.h:105
TickleState
[AI] Represents the state of the presenter's tickle (update) lifecycle.
Definition: mxpresenter.h:23
@ e_idle
[AI] Not processing an action.
Definition: mxpresenter.h:24
@ e_ready
[AI] Prepared to start processing an action.
Definition: mxpresenter.h:25
MxCriticalSection m_criticalSection
[AI] Thread synchronization for presenter state and data.
Definition: mxpresenter.h:214
MxCompositePresenter * m_compositePresenter
[AI] Owner composite presenter, if any.
Definition: mxpresenter.h:217
virtual MxResult AddToManager()
[AI] Optional registration with a manager (such as TickleManager); by default does nothing.
Definition: mxpresenter.h:84
void SetCompositePresenter(MxCompositePresenter *p_compositePresenter)
[AI] Sets the composite presenter to notify/join on completion.
Definition: mxpresenter.h:183
MxDSAction * GetAction() const
[AI] Returns the current action being presented.
Definition: mxpresenter.h:175
[AI] Controller for streaming and managing multimedia resources and actions during gameplay.
#define TRUE
Definition: d3drmdef.h:28
#define FALSE
Definition: d3drmdef.h:27
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
Definition: legotypes.h:34
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
Definition: legotypes.h:30
#define AUTOLOCK(CS)
[AI] Macro for automatic locking using the MxAutoLock class. This macro instantiates an MxAutoLock ob...
Definition: mxautolock.h:5
MxObjectFactory * ObjectFactory()
[AI] Returns the factory for creating core engine objects from atom/type ids.
Definition: mxmisc.cpp:9
MxNotificationManager * NotificationManager()
[AI] Returns the notification manager for system-wide state/update notifications.
Definition: mxmisc.cpp:17
@ c_notificationPresenter
[AI] Update or event from a Presenter [AI]
@ c_notificationEndAction
[AI] Indicates the end of an action [AI]
const char * PresenterNameDispatch(const MxDSAction &)
[AI] Provides a mapping from action object/type to the correct presenter handler class name based on ...
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
int MxLong
[AI]
Definition: mxtypes.h:83