2023-06-29 04:10:08 -04:00
|
|
|
#include "mxcontrolpresenter.h"
|
|
|
|
|
2024-01-21 12:45:40 -05:00
|
|
|
#include "define.h"
|
2024-01-28 16:09:33 -05:00
|
|
|
#include "legocontrolmanager.h"
|
2024-01-29 17:46:22 -05:00
|
|
|
#include "mxdsmultiaction.h"
|
2024-03-09 15:07:52 -05:00
|
|
|
#include "mxmisc.h"
|
2023-11-10 13:27:10 -05:00
|
|
|
#include "mxticklemanager.h"
|
2024-01-29 17:46:22 -05:00
|
|
|
#include "mxtimer.h"
|
2024-03-09 15:07:52 -05:00
|
|
|
#include "mxutilities.h"
|
2024-01-29 17:46:22 -05:00
|
|
|
#include "mxvideopresenter.h"
|
2023-11-10 13:27:10 -05:00
|
|
|
|
2023-10-01 08:49:55 -04:00
|
|
|
DECOMP_SIZE_ASSERT(MxControlPresenter, 0x5c)
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x10043f50
|
2023-06-29 04:10:08 -04:00
|
|
|
MxControlPresenter::MxControlPresenter()
|
|
|
|
{
|
2023-12-13 05:48:14 -05:00
|
|
|
this->m_unk0x4c = 0;
|
|
|
|
this->m_unk0x4e = -1;
|
2023-12-15 11:41:07 -05:00
|
|
|
this->m_unk0x50 = FALSE;
|
2023-12-13 05:48:14 -05:00
|
|
|
this->m_unk0x52 = 0;
|
|
|
|
this->m_unk0x58 = 0;
|
|
|
|
this->m_unk0x54 = 0;
|
2023-10-25 14:51:59 -04:00
|
|
|
}
|
2023-11-10 13:27:10 -05:00
|
|
|
|
2023-12-15 11:41:07 -05:00
|
|
|
// FUNCTION: LEGO1 0x10043fd0
|
|
|
|
void MxControlPresenter::RepeatingTickle()
|
|
|
|
{
|
|
|
|
// empty
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10043fe0
|
|
|
|
MxBool MxControlPresenter::VTable0x64(undefined4 p_undefined)
|
|
|
|
{
|
|
|
|
return m_unk0x50;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10043ff0
|
2024-01-15 14:08:28 -05:00
|
|
|
void MxControlPresenter::VTable0x68(MxBool p_unk0x50)
|
2023-12-15 11:41:07 -05:00
|
|
|
{
|
2024-01-15 14:08:28 -05:00
|
|
|
m_unk0x50 = p_unk0x50;
|
2023-12-15 11:41:07 -05:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x10044110
|
2023-11-10 13:27:10 -05:00
|
|
|
MxControlPresenter::~MxControlPresenter()
|
|
|
|
{
|
2024-02-01 15:42:10 -05:00
|
|
|
if (m_unk0x58) {
|
2023-12-15 11:41:07 -05:00
|
|
|
delete m_unk0x58;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-12-15 11:41:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10044180
|
|
|
|
MxResult MxControlPresenter::AddToManager()
|
|
|
|
{
|
|
|
|
m_unk0x4e = 0;
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2024-01-15 14:08:28 -05:00
|
|
|
// FUNCTION: LEGO1 0x10044190
|
|
|
|
MxResult MxControlPresenter::StartAction(MxStreamController* p_controller, MxDSAction* p_action)
|
2023-12-15 11:41:07 -05:00
|
|
|
{
|
2024-01-15 14:08:28 -05:00
|
|
|
MxResult result = MxCompositePresenter::StartAction(p_controller, p_action);
|
|
|
|
|
2024-01-17 11:53:53 -05:00
|
|
|
FUN_100b7220(m_action, MxDSAction::c_world | MxDSAction::c_looping, TRUE);
|
2024-01-15 14:08:28 -05:00
|
|
|
ParseExtra();
|
|
|
|
|
|
|
|
MxS16 i = 0;
|
|
|
|
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
|
|
|
(*it)->Enable((m_unk0x4c != 3 || m_unk0x4e) && IsEnabled() ? m_unk0x4e == i : FALSE);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_unk0x4c == 3) {
|
|
|
|
MxDSAction* action = (*m_list.begin())->GetAction();
|
2024-01-17 11:53:53 -05:00
|
|
|
action->SetFlags(action->GetFlags() | MxDSAction::c_bit11);
|
2024-01-15 14:08:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
TickleManager()->RegisterClient(this, 200);
|
|
|
|
|
|
|
|
return result;
|
2023-12-15 11:41:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10044260
|
|
|
|
void MxControlPresenter::EndAction()
|
|
|
|
{
|
|
|
|
if (m_action) {
|
|
|
|
m_unk0x50 = TRUE;
|
|
|
|
MxCompositePresenter::EndAction();
|
2023-11-10 13:27:10 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-29 17:46:22 -05:00
|
|
|
// FUNCTION: LEGO1 0x10044270
|
|
|
|
MxBool MxControlPresenter::FUN_10044270(MxS32 p_x, MxS32 p_y, MxVideoPresenter* p_presenter)
|
2023-12-15 11:41:07 -05:00
|
|
|
{
|
2024-01-29 17:46:22 -05:00
|
|
|
if (m_unk0x4c == 3) {
|
|
|
|
MxVideoPresenter* frontPresenter = (MxVideoPresenter*) m_list.front();
|
|
|
|
|
2024-01-31 09:47:15 -05:00
|
|
|
if (p_presenter == frontPresenter || frontPresenter->GetDisplayZ() < p_presenter->GetDisplayZ()) {
|
2024-01-29 17:46:22 -05:00
|
|
|
if (p_presenter->VTable0x7c()) {
|
|
|
|
MxS32 height = frontPresenter->GetHeight();
|
|
|
|
MxS32 width = frontPresenter->GetWidth();
|
|
|
|
|
|
|
|
if (frontPresenter->GetLocation().GetX() <= p_x &&
|
2024-01-31 09:47:15 -05:00
|
|
|
p_x < width - 1 + frontPresenter->GetLocation().GetX() &&
|
2024-01-29 17:46:22 -05:00
|
|
|
frontPresenter->GetLocation().GetY() <= p_y &&
|
|
|
|
p_y < height - 1 + frontPresenter->GetLocation().GetY()) {
|
|
|
|
MxU8* start;
|
|
|
|
|
|
|
|
if (frontPresenter->GetAlphaMask() == NULL) {
|
|
|
|
start = frontPresenter->GetBitmap()->GetStart(
|
|
|
|
p_x - frontPresenter->GetLocation().GetX(),
|
|
|
|
p_y - frontPresenter->GetLocation().GetY()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
start = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_unk0x56 = 0;
|
|
|
|
if (m_unk0x58 == NULL) {
|
|
|
|
if (*start != 0) {
|
|
|
|
m_unk0x56 = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (MxS16 i = 1; i <= *m_unk0x58; i++) {
|
|
|
|
if (m_unk0x58[i] == *start) {
|
|
|
|
m_unk0x56 = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_unk0x56) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (ContainsPresenter(m_list, p_presenter)) {
|
|
|
|
if (m_unk0x4c == 2) {
|
|
|
|
MxS32 width = p_presenter->GetWidth();
|
|
|
|
MxS32 height = p_presenter->GetHeight();
|
|
|
|
|
|
|
|
if (m_unk0x52 == 2 && m_unk0x54 == 2) {
|
|
|
|
MxS16 val;
|
|
|
|
if (p_x < p_presenter->GetLocation().GetX() + width / 2) {
|
|
|
|
val = 3;
|
|
|
|
if (p_y < p_presenter->GetLocation().GetY() + height / 2) {
|
|
|
|
val = 1;
|
|
|
|
}
|
|
|
|
m_unk0x56 = val;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
val = 4;
|
|
|
|
if (p_y < p_presenter->GetLocation().GetY() + height / 2) {
|
|
|
|
val = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_unk0x56 = val;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_unk0x56 = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2023-12-15 11:41:07 -05:00
|
|
|
}
|
|
|
|
|
2024-01-28 16:09:33 -05:00
|
|
|
// FUNCTION: LEGO1 0x10044480
|
|
|
|
MxBool MxControlPresenter::FUN_10044480(LegoControlManagerEvent* p_event, MxPresenter* p_presenter)
|
2023-12-15 11:41:07 -05:00
|
|
|
{
|
2024-01-28 16:09:33 -05:00
|
|
|
if (IsEnabled()) {
|
|
|
|
switch (p_event->GetType()) {
|
|
|
|
case c_notificationButtonUp:
|
|
|
|
if (m_unk0x4c == 0 || m_unk0x4c == 2 || m_unk0x4c == 3) {
|
|
|
|
p_event->SetClickedObjectId(m_action->GetObjectId());
|
|
|
|
p_event->SetClickedAtom(m_action->GetAtomId().GetInternal());
|
|
|
|
VTable0x6c(0);
|
2024-05-30 09:54:24 -04:00
|
|
|
p_event->SetType(c_notificationControl);
|
2024-01-28 16:09:33 -05:00
|
|
|
p_event->SetUnknown0x28(m_unk0x4e);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case c_notificationButtonDown:
|
2024-01-29 17:46:22 -05:00
|
|
|
if (FUN_10044270(p_event->GetX(), p_event->GetY(), (MxVideoPresenter*) p_presenter)) {
|
2024-01-28 16:09:33 -05:00
|
|
|
p_event->SetClickedObjectId(m_action->GetObjectId());
|
|
|
|
p_event->SetClickedAtom(m_action->GetAtomId().GetInternal());
|
|
|
|
VTable0x6c(m_unk0x56);
|
2024-05-30 09:54:24 -04:00
|
|
|
p_event->SetType(c_notificationControl);
|
2024-01-28 16:09:33 -05:00
|
|
|
p_event->SetUnknown0x28(m_unk0x4e);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2023-12-15 11:41:07 -05:00
|
|
|
}
|
|
|
|
|
2024-01-29 17:46:22 -05:00
|
|
|
// FUNCTION: LEGO1 0x10044540
|
2024-05-30 09:15:16 -04:00
|
|
|
void MxControlPresenter::VTable0x6c(MxS16 p_unk0x4e)
|
2023-12-15 11:41:07 -05:00
|
|
|
{
|
2024-05-30 09:15:16 -04:00
|
|
|
if (p_unk0x4e == -1) {
|
2024-01-29 17:46:22 -05:00
|
|
|
if ((MxS16) ((MxDSMultiAction*) m_action)->GetActionList()->GetCount() - m_unk0x4e == 1) {
|
|
|
|
m_unk0x4e = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_unk0x4e++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2024-05-30 09:15:16 -04:00
|
|
|
m_unk0x4e = p_unk0x4e;
|
2024-01-29 17:46:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
m_action->SetUnknown90(Timer()->GetTime());
|
|
|
|
|
|
|
|
MxS16 i = 0;
|
|
|
|
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
2024-02-01 15:42:10 -05:00
|
|
|
(*it)->Enable(((m_unk0x4c == 3 && m_unk0x4e == 0) || !IsEnabled()) ? FALSE : m_unk0x4e == i);
|
2024-01-29 17:46:22 -05:00
|
|
|
i++;
|
|
|
|
}
|
2023-12-15 11:41:07 -05:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x10044610
|
2023-11-10 13:27:10 -05:00
|
|
|
void MxControlPresenter::ReadyTickle()
|
|
|
|
{
|
|
|
|
MxPresenter::ParseExtra();
|
|
|
|
TickleManager()->UnregisterClient(this);
|
2024-01-17 11:53:53 -05:00
|
|
|
ProgressTickleState(e_repeating);
|
2023-11-10 13:27:10 -05:00
|
|
|
}
|
2023-12-15 11:41:07 -05:00
|
|
|
|
2024-01-21 12:45:40 -05:00
|
|
|
// FUNCTION: LEGO1 0x10044640
|
2023-12-15 11:41:07 -05:00
|
|
|
void MxControlPresenter::ParseExtra()
|
|
|
|
{
|
2024-02-29 13:15:20 -05:00
|
|
|
MxU16 extraLength;
|
|
|
|
char* extraData;
|
|
|
|
m_action->GetExtra(extraLength, extraData);
|
|
|
|
|
|
|
|
if (extraLength & MAXWORD) {
|
|
|
|
char extraCopy[256];
|
|
|
|
memcpy(extraCopy, extraData, extraLength & MAXWORD);
|
|
|
|
extraCopy[extraLength & MAXWORD] = '\0';
|
|
|
|
|
|
|
|
char output[256];
|
2024-05-14 10:43:06 -04:00
|
|
|
if (KeyValueStringParse(output, g_strSTYLE, extraCopy)) {
|
2024-02-29 13:15:20 -05:00
|
|
|
char* str = strtok(output, g_parseExtraTokens);
|
|
|
|
|
2024-05-14 10:43:06 -04:00
|
|
|
if (!strcmpi(str, g_strTOGGLE)) {
|
2024-01-21 12:45:40 -05:00
|
|
|
m_unk0x4c = 1;
|
|
|
|
}
|
2024-05-14 10:43:06 -04:00
|
|
|
else if (!strcmpi(str, g_strGRID)) {
|
2024-01-21 12:45:40 -05:00
|
|
|
m_unk0x4c = 2;
|
|
|
|
m_unk0x52 = atoi(strtok(NULL, g_parseExtraTokens));
|
|
|
|
m_unk0x54 = atoi(strtok(NULL, g_parseExtraTokens));
|
|
|
|
}
|
2024-05-14 10:43:06 -04:00
|
|
|
else if (!strcmpi(str, g_strMAP)) {
|
2024-01-21 12:45:40 -05:00
|
|
|
m_unk0x4c = 3;
|
|
|
|
str = strtok(NULL, g_parseExtraTokens);
|
2024-02-29 13:15:20 -05:00
|
|
|
|
2024-01-21 12:45:40 -05:00
|
|
|
if (str) {
|
|
|
|
MxS16 count = atoi(str);
|
|
|
|
m_unk0x58 = new MxS16[count + 1];
|
|
|
|
*m_unk0x58 = count;
|
2024-02-29 13:15:20 -05:00
|
|
|
|
2024-01-21 12:45:40 -05:00
|
|
|
for (MxS16 i = 1; i <= count; i++) {
|
|
|
|
m_unk0x58[i] = atoi(strtok(NULL, g_parseExtraTokens));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_unk0x4c = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-29 13:15:20 -05:00
|
|
|
if (KeyValueStringParse(output, g_strVISIBILITY, extraCopy)) {
|
|
|
|
if (!strcmpi(output, "FALSE")) {
|
2024-01-21 12:45:40 -05:00
|
|
|
Enable(FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-12-15 11:41:07 -05:00
|
|
|
}
|
|
|
|
|
2024-01-15 14:08:28 -05:00
|
|
|
// FUNCTION: LEGO1 0x10044820
|
2023-12-15 11:41:07 -05:00
|
|
|
void MxControlPresenter::Enable(MxBool p_enable)
|
|
|
|
{
|
2024-01-15 14:08:28 -05:00
|
|
|
if (MxPresenter::IsEnabled() != p_enable) {
|
|
|
|
MxPresenter::Enable(p_enable);
|
|
|
|
|
|
|
|
MxS16 i = 0;
|
|
|
|
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
|
|
|
|
if (i == m_unk0x4e) {
|
|
|
|
(*it)->Enable((m_unk0x4c != 3 || i != 0) ? p_enable : 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!p_enable) {
|
|
|
|
m_unk0x4e = 0;
|
|
|
|
}
|
|
|
|
}
|
2023-12-15 11:41:07 -05:00
|
|
|
}
|
|
|
|
|
2024-01-15 14:08:28 -05:00
|
|
|
// FUNCTION: LEGO1 0x100448a0
|
2023-12-15 11:41:07 -05:00
|
|
|
MxBool MxControlPresenter::HasTickleStatePassed(TickleState p_tickleState)
|
|
|
|
{
|
2024-01-15 14:08:28 -05:00
|
|
|
MxCompositePresenterList::iterator it = m_list.begin();
|
2024-02-01 15:42:10 -05:00
|
|
|
for (MxS16 i = m_unk0x4e; i > 0; i--, it++) {
|
|
|
|
}
|
2024-01-15 14:08:28 -05:00
|
|
|
|
|
|
|
return (*it)->HasTickleStatePassed(p_tickleState);
|
2023-12-15 11:41:07 -05:00
|
|
|
}
|