From 05bc94f0307401c2e46f5190c75049b50d110517 Mon Sep 17 00:00:00 2001 From: Misha <106913236+MishaProductions@users.noreply.github.com> Date: Sun, 21 Jan 2024 12:45:40 -0500 Subject: [PATCH] implement MxControlPresenter::ParseExtra (#477) * MxControlPresenter::ParseExtra * Update mxcontrolpresenter.h * fix loop --------- Co-authored-by: Christian Semmler --- .../legoomni/include/mxcontrolpresenter.h | 12 ++-- .../src/control/mxcontrolpresenter.cpp | 60 ++++++++++++++++++- 2 files changed, 64 insertions(+), 8 deletions(-) diff --git a/LEGO1/lego/legoomni/include/mxcontrolpresenter.h b/LEGO1/lego/legoomni/include/mxcontrolpresenter.h index 2db0a2e4..b4c8950e 100644 --- a/LEGO1/lego/legoomni/include/mxcontrolpresenter.h +++ b/LEGO1/lego/legoomni/include/mxcontrolpresenter.h @@ -41,12 +41,12 @@ private: MxBool FUN_10044480(undefined4, undefined4*); void FUN_10044540(undefined2); - undefined2 m_unk0x4c; // 0x4c - MxS16 m_unk0x4e; // 0x4e - MxBool m_unk0x50; // 0x50 - undefined2 m_unk0x52; // 0x52 - undefined2 m_unk0x54; // 0x54 - undefined4* m_unk0x58; // 0x58 + undefined2 m_unk0x4c; // 0x4c + MxS16 m_unk0x4e; // 0x4e + MxBool m_unk0x50; // 0x50 + undefined2 m_unk0x52; // 0x52 + undefined2 m_unk0x54; // 0x54 + MxS16* m_unk0x58; // 0x58 }; // SYNTHETIC: LEGO1 0x100440f0 diff --git a/LEGO1/lego/legoomni/src/control/mxcontrolpresenter.cpp b/LEGO1/lego/legoomni/src/control/mxcontrolpresenter.cpp index 7a204a78..b578f107 100644 --- a/LEGO1/lego/legoomni/src/control/mxcontrolpresenter.cpp +++ b/LEGO1/lego/legoomni/src/control/mxcontrolpresenter.cpp @@ -1,10 +1,27 @@ #include "mxcontrolpresenter.h" +#include "define.h" #include "mxticklemanager.h" #include "mxutil.h" DECOMP_SIZE_ASSERT(MxControlPresenter, 0x5c) +// GLOBAL: LEGO1 0x10102064 +// STRING: LEGO1 0x10101fec +const char* g_style = "STYLE"; + +// GLOBAL: LEGO1 0x10102068 +// STRING: LEGO1 0x10101fe4 +const char* g_grid = "GRID"; + +// GLOBAL: LEGO1 0x1010206c +// STRING: LEGO1 0x10101fe0 +const char* g_map = "MAP"; + +// GLOBAL: LEGO1 0x10102074 +// STRING: LEGO1 0x10101fd0 +const char* g_toggle = "TOGGLE"; + // FUNCTION: LEGO1 0x10043f50 MxControlPresenter::MxControlPresenter() { @@ -109,10 +126,49 @@ void MxControlPresenter::ReadyTickle() ProgressTickleState(e_repeating); } -// STUB: LEGO1 0x10044640 +// FUNCTION: LEGO1 0x10044640 void MxControlPresenter::ParseExtra() { - // TODO + char result[256]; + MxU16 len = m_action->GetExtraLength(); + if (len) { + char buffer[256]; + memcpy(buffer, m_action->GetExtraData(), m_action->GetExtraLength()); + buffer[len] = 0; + + if (KeyValueStringParse(result, g_style, buffer)) { + char* str = strtok(result, g_parseExtraTokens); + if (!strcmpi(str, g_toggle)) { + m_unk0x4c = 1; + } + else if (!strcmpi(str, g_grid)) { + m_unk0x4c = 2; + m_unk0x52 = atoi(strtok(NULL, g_parseExtraTokens)); + m_unk0x54 = atoi(strtok(NULL, g_parseExtraTokens)); + } + else if (!strcmpi(str, g_map)) { + m_unk0x4c = 3; + str = strtok(NULL, g_parseExtraTokens); + if (str) { + MxS16 count = atoi(str); + m_unk0x58 = new MxS16[count + 1]; + *m_unk0x58 = count; + for (MxS16 i = 1; i <= count; i++) { + m_unk0x58[i] = atoi(strtok(NULL, g_parseExtraTokens)); + } + } + } + else { + m_unk0x4c = 0; + } + } + + if (KeyValueStringParse(result, g_strVISIBILITY, buffer)) { + if (!strcmpi(result, "FALSE")) { + Enable(FALSE); + } + } + } } // FUNCTION: LEGO1 0x10044820