Isle
Loading...
Searching...
No Matches
legocontrolmanager.cpp
Go to the documentation of this file.
2
4#include "legovideomanager.h"
5#include "misc.h"
7#include "mxdsaction.h"
8#include "mxmisc.h"
9#include "mxpresenter.h"
10#include "mxticklemanager.h"
11
15
16// FUNCTION: LEGO1 0x10028520
18{
19 m_presenterList = NULL;
20 m_unk0x08 = 0;
21 m_unk0x0c = 0;
22 m_unk0x10 = FALSE;
23 m_unk0x14 = NULL;
24 TickleManager()->RegisterClient(this, 10);
25}
26
27// FUNCTION: LEGO1 0x10028d60
29{
31}
32
33// FUNCTION: LEGO1 0x10028df0
35{
36 m_presenterList = p_presenterList;
37 g_unk0x100f31b0 = -1;
39}
40
41// FUNCTION: LEGO1 0x10028e10
42// FUNCTION: BETA10 0x1007c232
44{
45 m_notifyList.Append(p_listener);
46}
47
48// FUNCTION: LEGO1 0x10028ea0
49// FUNCTION: BETA10 0x1007c330
51{
52 LegoNotifyListCursor cursor(&m_notifyList);
53 if (cursor.Find(p_listener)) {
54 cursor.Detach();
55 }
56}
57
58// FUNCTION: LEGO1 0x10029210
60{
61 if (m_presenterList != NULL && m_presenterList->GetNumElements() != 0) {
62 m_unk0x14 = p_presenter;
63
64 if (p_param.GetNotification() == c_notificationButtonUp ||
66 m_event.SetNotification(p_param.GetNotification());
67 m_event.SetSender(p_param.GetSender());
68 m_event.SetModifier(p_param.GetModifier());
69 m_event.SetX(p_param.GetX());
70 m_event.SetY(p_param.GetY());
71 m_event.SetKey(p_param.GetKey());
72
73 if (p_param.GetNotification() == c_notificationButtonUp) {
74 if (m_unk0x10 == TRUE) {
75 m_unk0x10 = FALSE;
76 return TRUE;
77 }
78
79 if (g_unk0x100f31b0 != -1 && g_unk0x100f31b4 != NULL) {
80 if (m_unk0x08 == 2) {
81 return FUN_10029750();
82 }
83 else {
84 m_unk0x0c = 1;
85 return TRUE;
86 }
87 }
88 }
89 else if (p_param.GetNotification() == c_notificationButtonDown) {
90 if (m_unk0x0c == 1) {
91 m_unk0x10 = TRUE;
92 return TRUE;
93 }
94 else {
95 return FUN_10029630();
96 }
97 }
98 }
99
100 return FALSE;
101 }
102 else {
103 g_unk0x100f31b0 = -1;
105
106 return FALSE;
107 }
108}
109
110// FUNCTION: LEGO1 0x100292e0
112{
113 LegoNotifyListCursor cursor(&m_notifyList);
114 MxCore* target;
115
116 cursor.Head();
117 while (cursor.Current(target)) {
118 cursor.Next();
119 target->Notify(m_event);
120 }
121}
122
123// FUNCTION: LEGO1 0x100293c0
124void LegoControlManager::FUN_100293c0(MxU32 p_objectId, const char* p_atom, MxS16 p_unk0x4e)
125{
126 if (m_presenterList) {
127 MxPresenterListCursor cursor(m_presenterList);
128 MxPresenter* control;
129
130 while (cursor.Next(control)) {
131 MxDSAction* action = control->GetAction();
132
133 if (action->GetObjectId() == p_objectId && action->GetAtomId().GetInternal() == p_atom) {
134 ((MxControlPresenter*) control)->VTable0x6c(p_unk0x4e);
135
136 if (((MxControlPresenter*) control)->GetUnknown0x4e() == 0) {
137 g_unk0x100f31b0 = -1;
139 break;
140 }
141 }
142 }
143 }
144}
145
146// FUNCTION: LEGO1 0x100294e0
147// FUNCTION: BETA10 0x1007c92f
149{
150 if (m_presenterList) {
151 MxPresenterListCursor cursor(m_presenterList);
152 MxPresenter* control;
153 MxPresenter* presenter = VideoManager()->GetPresenterAt(p_x, p_y);
154
155 if (presenter) {
156 while (cursor.Next(control)) {
157 if (((MxControlPresenter*) control)->FUN_10044270(p_x, p_y, presenter)) {
158 return (MxControlPresenter*) control;
159 }
160 }
161 }
162 }
163
164 return NULL;
165}
166
167// FUNCTION: LEGO1 0x10029600
169{
170 if (m_unk0x08 == 2 && m_unk0x0c == 1) {
172 FUN_10029750();
173 return 0;
174 }
175 else if (m_unk0x08 == 1) {
176 m_unk0x08 = 2;
177 }
178 return 0;
179}
180
181// FUNCTION: LEGO1 0x10029630
183{
184 MxPresenterListCursor cursor(m_presenterList);
185 MxPresenter* presenter;
186
187 while (cursor.Next(presenter)) {
188 if (((MxControlPresenter*) presenter)->FUN_10044480(&m_event, m_unk0x14)) {
191 FUN_100292e0();
192 m_unk0x08 = 1;
193 return TRUE;
194 }
195 }
196
197 return FALSE;
198}
199
200// FUNCTION: LEGO1 0x10029750
202{
203 MxPresenterListCursor cursor(m_presenterList);
204 MxPresenter* presenter;
205
206 while (cursor.Next(presenter)) {
207 if (presenter->GetAction() && presenter->GetAction()->GetObjectId() == g_unk0x100f31b0 &&
208 presenter->GetAction()->GetAtomId().GetInternal() == g_unk0x100f31b4) {
209 if (((MxControlPresenter*) presenter)->FUN_10044480(&m_event, m_unk0x14)) {
210 FUN_100292e0();
211 }
212
213 g_unk0x100f31b0 = -1;
215
216 m_unk0x08 = 0;
217 m_unk0x0c = 0;
218
219 return TRUE;
220 }
221 }
222
223 g_unk0x100f31b0 = -1;
225 return FALSE;
226}
[AI] Notification parameter for the LegoControlManager, used to propagate information about control e...
MxS32 m_clickedObjectId
[AI] Object ID of the clicked control/presenter (or -1 if not set). [AI]
const char * GetClickedAtom() const
[AI] Returns the atom string associated with the control event.
[AI] Manages control presenters and dispatches notifications for control/input events within the LEGO...
MxBool FUN_10029750()
[AI] Handles "button up" click resolution logic for the UI system.
MxBool FUN_10029630()
[AI] Handles "button down" logic for the input system over presenters.
void FUN_10028df0(MxPresenterList *p_presenterList)
[AI] Assigns the active presenter list to this control manager.
void FUN_100292e0()
[AI] Notifies all registered listeners with the current control event.
void Register(MxCore *p_listener)
[AI] Adds a listener to be notified of control events.
MxResult Tickle() override
[AI] Performs periodic processing on the control manager, advancing internal event state and dispatch...
MxControlPresenter * FUN_100294e0(MxS32 p_x, MxS32 p_y)
[AI] Finds the topmost control presenter at the given screen coordinates.
~LegoControlManager() override
[AI] Destructor; unregisters this manager from tickle management.
MxBool FUN_10029210(LegoEventNotificationParam &p_param, MxPresenter *p_presenter)
[AI] Handles event notification logic, taking an event and possibly updating the manager/presenter st...
void Unregister(MxCore *p_listener)
[AI] Removes a listener so it no longer receives control events.
void FUN_100293c0(MxU32 p_objectId, const char *p_atom, MxS16 p_unk0x4e)
[AI] Dispatches a presenter event for the given object and atom parameters.
Notification parameter class for LEGO event notifications such as mouse events and modifier keys.
MxS32 GetY() const
Returns Y (vertical) coordinate for the event, usually screen-relative in pixels.
void SetX(MxS32 p_x)
Sets the X (horizontal) coordinate for the event.
MxU8 GetModifier()
Returns modifier bitmask for this event (mouse/keyboard state).
void SetKey(MxU8 p_key)
Sets the keycode for the event.
void SetY(MxS32 p_y)
Sets the Y (vertical) coordinate for the event.
MxU8 GetKey() const
Returns the keycode for this event, or 0 if not used.
MxS32 GetX() const
Returns X (horizontal) coordinate for the event, usually screen-relative in pixels.
void SetModifier(MxU8 p_modifier)
Sets the modifier state bitmask for the event.
[AI] Cursor (iterator) for traversing a LegoNotifyList. Used to find or detach notification targets....
virtual MxPresenter * GetPresenterAt(MxS32 p_x, MxS32 p_y)
[AI] Finds a presenter at the specific screen coordinates (for hit testing).
const char * GetInternal() const
[AI] Returns a pointer to the internal string, or nullptr if not set.
Definition: mxatom.h:194
[AI] Presenter for UI controls, supporting toggles, grids, and "map" style controls with multiple int...
[AI] Base virtual class for all Mindscape engine (Mx) objects.
Definition: mxcore.h:15
virtual MxLong Notify(MxParam &p_param)
[AI] Virtual callback notification mechanism.
Definition: mxcore.cpp:25
[AI] Represents an action deserialized from SI chunks, holding key animation or script parameters suc...
Definition: mxdsaction.h:17
const MxAtomId & GetAtomId()
[AI] Returns a const-reference to the object's atom identifier.
Definition: mxdsobject.h:133
MxU32 GetObjectId()
[AI] Returns the object id numeric value.
Definition: mxdsobject.h:130
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 Append(T p_obj)
[AI]
Definition: mxlist.h:100
MxU32 GetNumElements()
[AI]
Definition: mxlist.h:118
NotificationId GetNotification() const
[AI] Retrieves the current notification type of this parameter.
MxCore * GetSender() const
[AI] Retrieves the sender pointer associated with this notification.
void SetSender(MxCore *p_sender)
[AI] Sets the sender pointer for this notification parameter.
void SetNotification(NotificationId p_type)
[AI] Sets the notification type for this parameter object.
[AI] Cursor/iterator for traversing an MxPresenterList.
[AI] List to hold pointers to MxPresenter objects with optional ownership semantics.
[AI] Abstract base class for all presenter types in the LEGO Island engine, responsible for managing ...
Definition: mxpresenter.h:20
MxDSAction * GetAction() const
[AI] Returns the current action being presented.
Definition: mxpresenter.h:175
virtual void UnregisterClient(MxCore *p_client)
[AI] Unregisters (marks for destruction) a previously registered client.
virtual void RegisterClient(MxCore *p_client, MxTime p_interval)
[AI] Registers an MxCore object to receive periodic tickles.
#define TRUE
Definition: d3drmdef.h:28
#define FALSE
Definition: d3drmdef.h:27
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
MxS32 g_unk0x100f31b0
[AI] Global variable used for tracking drag state, -1 if inactive. [AI]
const char * g_unk0x100f31b4
[AI] Global pointer for additional drag state/context (purpose unclear). [AI]
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
LegoVideoManager * VideoManager()
[AI] Accessor for the game's LegoVideoManager subsystem. Used for managing 3D/video hardware....
Definition: misc.cpp:29
MxTickleManager * TickleManager()
[AI] Provides access to the global tickle manager.
Definition: mxmisc.cpp:25
@ c_notificationButtonUp
[AI] Mouse/gamepad button release [AI]
@ c_notificationButtonDown
[AI] Mouse/gamepad button press [AI]
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
signed short MxS16
[AI]
Definition: mxtypes.h:26
signed int MxS32
[AI]
Definition: mxtypes.h:38
unsigned int MxU32
[AI]
Definition: mxtypes.h:32