Isle
Loading...
Searching...
No Matches
legoracemap.cpp
Go to the documentation of this file.
1#include "legoracemap.h"
2
3#include "define.h"
5#include "legovideomanager.h"
6#include "legoworld.h"
7#include "misc.h"
9#include "mxstillpresenter.h"
10#include "mxutilities.h"
11
13
14// FUNCTION: LEGO1 0x1005d0d0
15// FUNCTION: BETA10 0x100ca2c0
17{
18 m_unk0x08 = FALSE;
19 m_stillPresenter = NULL;
20 m_Map_Ctl = 0;
21 ControlManager()->Register(this);
22}
23
24// FUNCTION: LEGO1 0x1005d2b0
25// FUNCTION: BETA10 0x100ca48c
27{
29}
30
31// GLOBAL: LEGO1 0x1010208c
32// STRING: LEGO1 0x10101f88
33const char* g_mapLocator = "MAP_LOCATOR";
34
35// GLOBAL: LEGO1 0x10102090
36// STRING: LEGO1 0x10101f78
37const char* g_mapGeometry = "MAP_GEOMETRY";
38
39// FUNCTION: LEGO1 0x1005d310
40// FUNCTION: BETA10 0x100ca543
41void LegoRaceMap::ParseAction(char* p_extra)
42{
43 char value[256];
44
45 if (KeyValueStringParse(value, g_mapLocator, p_extra)) {
46 // variable name verified by BETA10 0x100ca5ac
48
49 assert(p);
50 p->Enable(FALSE);
51 m_stillPresenter = p;
52 }
53
54 if (KeyValueStringParse(value, g_mapGeometry, p_extra)) {
55 char* token = strtok(value, g_parseExtraTokens);
56 if (token != NULL) {
57 m_unk0x14 = atof(token);
58 }
59
60 token = strtok(NULL, g_parseExtraTokens);
61 if (token != NULL) {
62 m_unk0x18 = atof(token);
63 }
64
65 token = strtok(NULL, g_parseExtraTokens);
66 if (token != NULL) {
67 m_unk0x1c = atof(token);
68 }
69
70 token = strtok(NULL, g_parseExtraTokens);
71 if (token != NULL) {
72 m_unk0x20 = atof(token);
73 }
74
75 token = strtok(NULL, g_parseExtraTokens);
76 if (token != NULL) {
77 m_unk0x24 = atof(token);
78 }
79
80 token = strtok(NULL, g_parseExtraTokens);
81 if (token != NULL) {
82 m_unk0x28 = atof(token);
83 }
84
85 token = strtok(NULL, g_parseExtraTokens);
86 if (token != NULL) {
87 m_unk0x2c = atof(token);
88 }
89
90 token = strtok(NULL, g_parseExtraTokens);
91 if (token != NULL) {
92 m_unk0x30 = atof(token);
93 }
94 }
95
96 LegoWorld* currentWorld = CurrentWorld();
97
98 if (currentWorld) {
99 // STRING: LEGO1 0x100f67bc
100 const char* mapCtl = "Map_Ctl";
101
102 m_Map_Ctl = (MxControlPresenter*) currentWorld->Find("MxControlPresenter", mapCtl);
103 assert(m_Map_Ctl);
104 }
105}
106
107// FUNCTION: LEGO1 0x1005d4b0
108// FUNCTION: BETA10 0x100ca849
110{
111 if (m_unk0x08) {
112 short xPos = (GetWorldPosition()[0] - m_unk0x14) / m_unk0x18 * m_unk0x24;
113 short yPos = (GetWorldPosition()[2] - m_unk0x1c) / m_unk0x20 * m_unk0x28;
114
115 m_stillPresenter->SetPosition(xPos + m_unk0x2c, m_unk0x30 - yPos);
116 }
117}
118
119// FUNCTION: LEGO1 0x1005d550
120// FUNCTION: BETA10 0x100ca92d
122{
123 if (!m_stillPresenter) {
124 return 1;
125 }
126
127 MxNotificationParam& param = (MxNotificationParam&) p_param;
128
129 if (param.GetNotification() == c_notificationControl &&
130 m_Map_Ctl->GetAction()->GetObjectId() == ((LegoControlManagerNotificationParam&) p_param).m_clickedObjectId) {
131
132 if (((LegoControlManagerNotificationParam&) p_param).m_unk0x28 == 1) {
133 m_unk0x08 = TRUE;
134 FUN_1005d4b0();
135 m_stillPresenter->Enable(TRUE);
136 }
137 else {
138 m_unk0x08 = FALSE;
139 m_stillPresenter->Enable(FALSE);
140 }
141 }
142
143 return 1;
144}
[AI] Notification parameter for the LegoControlManager, used to propagate information about control e...
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.
Mx3DPointFloat GetWorldPosition()
[AI] Gets the world-space position vector, optionally updating from ROI. [AI]
Definition: legoentity.cpp:224
[AI] Represents the world-space to screen-space mapping and rendering handler for the interactive rac...
Definition: legoracemap.h:29
~LegoRaceMap() override
[AI] Destroys the LegoRaceMap and unregisters it from the ControlManager.
Definition: legoracemap.cpp:26
virtual void FUN_1005d4b0()
[AI] Updates the minimap overlay position and enables/disables the overlay image as needed.
MxLong Notify(MxParam &p_param) override
[AI] Handles notifications, especially for UI control interactions (e.g., clicking the map control to...
void ParseAction(char *p_extra) override
[AI] Parses action strings for map locator and geometry mapping and links control and map geometry to...
Definition: legoracemap.cpp:41
MxPresenter * GetPresenterByActionObjectName(const char *p_char)
[AI] Searches all active presenters for one associated with the given action object name.
Represents the active 3D world, holding all entity, animation, sound, path, and ROI objects.
Definition: legoworld.h:49
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
[AI] Presenter for UI controls, supporting toggles, grids, and "map" style controls with multiple int...
MxU32 GetObjectId()
[AI] Returns the object id numeric value.
Definition: mxdsobject.h:130
[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
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 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...
#define TRUE
Definition: d3drmdef.h:28
#define FALSE
Definition: d3drmdef.h:27
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
const char * g_parseExtraTokens
[AI] Delimiter tokens for parsing extra parameters in scripts or command strings.
Definition: define.cpp:141
const char * g_mapLocator
Definition: legoracemap.cpp:33
const char * g_mapGeometry
Definition: legoracemap.cpp:37
#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
LegoControlManager * ControlManager()
[AI] Accessor for the control manager through the input manager; manages higher-level user/game contr...
Definition: misc.cpp:53
LegoWorld * CurrentWorld()
[AI] Accessor for the currently active LegoWorld instance. [AI]
Definition: misc.cpp:93
@ c_notificationControl
[AI] UI control event [AI]
int MxLong
[AI]
Definition: mxtypes.h:83
MxBool KeyValueStringParse(char *, const char *, const char *)
Searches p_string for a key command and copies its associated value to p_output.
Definition: mxutilities.cpp:85