Isle
Loading...
Searching...
No Matches
mxcompositemediapresenter.cpp
Go to the documentation of this file.
2
3#include "legosoundmanager.h"
4#include "legovideomanager.h"
5#include "misc.h"
6#include "mxautolock.h"
7#include "mxdsmultiaction.h"
8#include "mxmediapresenter.h"
9#include "mxmisc.h"
10#include "mxobjectfactory.h"
11#include "mxtimer.h"
12
14
15// FUNCTION: LEGO1 0x10073ea0
17{
18 m_unk0x4c = 0;
19 m_unk0x4e = FALSE;
21}
22
23// FUNCTION: LEGO1 0x10074020
25{
27}
28
29// FUNCTION: LEGO1 0x10074090
31{
33
34 MxResult result = FAILURE;
35 MxDSActionList* actions = ((MxDSMultiAction*) p_action)->GetActionList();
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*) ObjectFactory()->Create(presenterName);
58
59 if (presenter && presenter->AddToManager() == SUCCESS) {
60 presenter->SetCompositePresenter(this);
61 if (presenter->StartAction(p_controller, action) == SUCCESS) {
62 presenter->SetTickleState(e_idle);
63
64 if (presenter->IsA("MxVideoPresenter")) {
65 VideoManager()->UnregisterPresenter(*presenter);
66 }
67 else if (presenter->IsA("MxAudioPresenter")) {
68 SoundManager()->UnregisterPresenter(*presenter);
69 }
70
71 success = TRUE;
72 }
73 }
74
75 if (success) {
76 action->SetOrigin(this);
77 m_list.push_back(presenter);
78 }
79 else if (presenter) {
80 delete presenter;
81 }
82 }
83
86 MxLong time = Timer()->GetTime();
88 }
89
90 result = SUCCESS;
91 }
92
93 return result;
94}
95
96// FUNCTION: LEGO1 0x100742e0
98{
100
101 if (!m_unk0x4e) {
102 for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
103 if ((*it)->GetCurrentTickleState() < e_streaming) {
104 (*it)->Tickle();
105
106 if ((*it)->GetCurrentTickleState() == e_streaming ||
107 ((*it)->GetAction() && (*it)->GetAction()->GetStartTime())) {
108 m_unk0x4c++;
109 }
110 }
111 }
112
113 if (m_list.size() == m_unk0x4c) {
114 m_unk0x4e = TRUE;
115 m_unk0x4c = 0;
116
117 for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
118 if (!(*it)->GetAction()->GetStartTime()) {
119 m_unk0x4c++;
120 }
121 }
122 }
123 }
124 else {
125 for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
126 if (!(*it)->GetAction()->GetStartTime() && ((MxMediaPresenter*) *it)->CurrentChunk() &&
127 !((*it)->GetAction()->GetFlags() & MxDSAction::c_bit9)) {
128 (*it)->Tickle();
129 (*it)->GetAction()->SetFlags((*it)->GetAction()->GetFlags() | MxDSAction::c_bit9);
130 m_unk0x4c--;
131 }
132 }
133
134 if (!m_unk0x4c) {
136 MxLong time = Timer()->GetTime();
137 m_action->SetUnknown90(time);
138 }
139 }
140}
141
142// FUNCTION: LEGO1 0x10074470
144{
146
147 switch (GetCurrentTickleState()) {
148 case e_ready:
150 case e_starting:
152 break;
153 case e_streaming:
154 case e_repeating:
155 case e_freezing:
156 case e_done: {
157 for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
158 (*it)->Tickle();
159 }
160 break;
161 }
162 default:
163 break;
164 }
165
166 return SUCCESS;
167}
168
169// FUNCTION: LEGO1 0x10074540
171{
173
175 for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
176 (*it)->PutData();
177 }
178 }
179
180 return SUCCESS;
181}
Composite presenter for handling multiple synchronized media actions.
void StartingTickle() override
Handles transition logic when entering the starting state, orchestrating sub-presenters and managing ...
MxResult Tickle() override
Orchestrates the tickle (update) across all managed sub-presenters, depending on current tickle state...
~MxCompositeMediaPresenter() override
Destructor; unregisters this presenter from the video manager.
MxResult PutData() override
Propagates PutData events to all sub-presenters during streaming or completion states.
MxResult StartAction(MxStreamController *, MxDSAction *p_action) override
Begins the playback of composite actions— instantiates and configures individual sub-presenters for e...
MxCompositePresenterList m_list
[AI] List of owned child presenters that are managed by this MxCompositePresenter....
void SetTickleState(TickleState p_tickleState) override
[AI] Change the tickle state of this composite presenter and propagate to each child.
[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
virtual void SetUnknown90(MxLong p_unk0x90)
[AI] Set unknown value at offset 0x90, used as baseline in GetElapsedTime.
Definition: mxdsaction.cpp:60
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
@ 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
@ c_bit9
[AI] Unknown - possibly reserved [AI]
Definition: mxdsaction.h:28
[AI] Represents a container for multiple MxDSAction objects, facilitating the grouping and management...
MxBool Next()
[AI]
MxBool Head()
[AI]
Definition: mxlist.h:252
MxBool Current(T &p_obj)
[AI]
virtual void RegisterPresenter(MxPresenter &p_presenter)
[AI] Register a new presenter for tickle management and playback coordination.
virtual void UnregisterPresenter(MxPresenter &p_presenter)
[AI] Remove a presenter from tickle and managed output lists.
[AI] Abstract base class for presenters that play back continuous media streams such as video or audi...
virtual MxCore * Create(const char *p_name)
[AI] Creates a new instance of the class matching the provided string name.
[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
void ProgressTickleState(TickleState p_tickleState)
[AI] Helper for advancing the presenter's tickle state and updating transition history.
Definition: mxpresenter.h:72
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
TickleState m_currentTickleState
[AI] Current state in the tickle lifecycle.
Definition: mxpresenter.h:199
@ e_repeating
[AI] Presentation is repeating (e.g., looping media).
Definition: mxpresenter.h:28
@ e_done
[AI] Completed processing the current action.
Definition: mxpresenter.h:30
@ e_idle
[AI] Not processing an action.
Definition: mxpresenter.h:24
@ e_ready
[AI] Prepared to start processing an action.
Definition: mxpresenter.h:25
@ e_freezing
[AI] Temporarily suspending updates or playback.
Definition: mxpresenter.h:29
@ e_starting
[AI] In the process of starting playback/presentation.
Definition: mxpresenter.h:26
@ e_streaming
[AI] Streaming or rendering actively.
Definition: mxpresenter.h:27
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
MxBool IsA(const char *p_name) const override
[AI] Determines if this object is of (or inherits) the specified named class.
Definition: mxpresenter.h:141
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
[AI] Controller for streaming and managing multimedia resources and actions during gameplay.
MxLong GetTime()
Returns the current timer value in ms, depending on running state.
Definition: mxtimer.h:50
#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
LegoVideoManager * VideoManager()
[AI] Accessor for the game's LegoVideoManager subsystem. Used for managing 3D/video hardware....
Definition: misc.cpp:29
LegoSoundManager * SoundManager()
[AI] Accessor for the game's LegoSoundManager subsystem from the global LegoOmni instance....
Definition: misc.cpp:22
#define AUTOLOCK(CS)
[AI] Macro for automatic locking using the MxAutoLock class. This macro instantiates an MxAutoLock ob...
Definition: mxautolock.h:5
MxTimer * Timer()
[AI] Returns the global simulation timer.
Definition: mxmisc.cpp:33
MxObjectFactory * ObjectFactory()
[AI] Returns the factory for creating core engine objects from atom/type ids.
Definition: mxmisc.cpp:9
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