Implement LegoMeterPresenter (#439)

* push changes

* Update legometerpresenter.h

* fix wrong offset

* fix deconstructor

* fix + improve accuracy

* Update legometerpresenter.cpp

* Match functions

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
Misha 2024-01-15 10:26:52 -05:00 committed by GitHub
parent e9d8fde8bc
commit 7f72a36462
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 138 additions and 2 deletions

View file

@ -7,7 +7,30 @@
// SIZE 0x94 (from 0x1000a163)
class LegoMeterPresenter : public MxStillPresenter {
public:
LegoMeterPresenter();
virtual ~LegoMeterPresenter() override;
// MxStillPresenter's `::ClassName` and `::IsA` are used.
virtual void StreamingTickle() override; // vtable+0x20
virtual void RepeatingTickle() override; // vtable+0x24
virtual void ParseExtra() override; // vtable+0x30
private:
void FUN_10043a50();
MxU8* m_unk0x6c; // 0x6c
MxU16 m_type; // 0x70
MxString m_variable; // 0x74
MxFloat m_unk0x84; // 0x84
MxU16 m_unk0x88; // 0x88
MxU16 m_unk0x8a; // 0x8a
MxU16 m_unk0x8c; // 0x8c
MxU16 m_unk0x8e; // 0x8e
MxU16 m_layout; // 0x90
};
// SYNTHETIC: LEGO1 0x10043760
// LegoMeterPresenter::`scalar deleting destructor'
#endif // LEGOMETERPRESENTER_H

View file

@ -1,6 +1,119 @@
#include "legometerpresenter.h"
#include "decomp.h"
#include "mxbitmap.h"
#include "mxutil.h"
// Uncomment when member class variables are fleshed out.
// DECOMP_SIZE_ASSERT(LegoMeterPresenter, 0x94); // 0x1000a163
DECOMP_SIZE_ASSERT(LegoMeterPresenter, 0x94)
// GLOBAL: LEGO1 0x1010207c
const char* g_filterIndex = "FILTER_INDEX";
// GLOBAL: LEGO1 0x10102094
const char* g_type = "TYPE";
// GLOBAL: LEGO1 0x10102088
const char* g_leftToRight = "LEFT_TO_RIGHT";
// GLOBAL: LEGO1 0x101020ac
const char* g_rightToLeft = "RIGHT_TO_LEFT";
// GLOBAL: LEGO1 0x1010205c
const char* g_bottomToTop = "BOTTOM_TO_TOP";
// GLOBAL: LEGO1 0x101020c0
const char* g_topToBottom = "TOP_TO_BOTTOM";
// GLOBAL: LEGO1 0x101020c8
const char* g_variable = "VARIABLE";
// FUNCTION: LEGO1 0x10043430
LegoMeterPresenter::LegoMeterPresenter()
{
m_layout = 0;
m_unk0x6c = 0;
m_unk0x84 = 0;
m_type = 1;
m_flags &= ~Flag_Bit2;
}
// FUNCTION: LEGO1 0x10043780
LegoMeterPresenter::~LegoMeterPresenter()
{
delete m_unk0x6c;
}
// FUNCTION: LEGO1 0x10043800
void LegoMeterPresenter::ParseExtra()
{
char buffer[256];
MxStillPresenter::ParseExtra();
*((MxU16*) &buffer[0]) = m_action->GetExtraLength();
char* extraData = m_action->GetExtraData();
if (*((MxU16*) &buffer[0])) {
MxU16 len = *((MxU16*) &buffer[0]);
memcpy(buffer, extraData, len);
buffer[len] = '\0';
char result[256];
if (KeyValueStringParse(buffer, g_type, result)) {
if (!strcmpi(result, g_leftToRight)) {
m_layout = 0;
}
else if (!strcmpi(result, g_rightToLeft)) {
m_layout = 1;
}
else if (!strcmpi(result, g_bottomToTop)) {
m_layout = 2;
}
else if (!strcmpi(result, g_topToBottom)) {
m_layout = 3;
}
}
if (KeyValueStringParse(buffer, g_filterIndex, result)) {
m_type = atoi(result);
}
if (KeyValueStringParse(buffer, g_variable, result)) {
m_variable = result;
}
else {
EndAction();
}
}
else {
EndAction();
}
}
// FUNCTION: LEGO1 0x10043990
void LegoMeterPresenter::StreamingTickle()
{
MxStillPresenter::StreamingTickle();
m_unk0x6c = new MxU8[m_bitmap->GetBmiStride() * m_bitmap->GetBmiHeightAbs()];
if (m_unk0x6c == NULL) {
EndAction();
}
memcpy(m_unk0x6c, m_bitmap->GetBitmapData(), m_bitmap->GetBmiStride() * m_bitmap->GetBmiHeightAbs());
m_unk0x88 = 0;
m_unk0x8a = 0;
m_unk0x8c = m_bitmap->GetBmiWidth() - 1;
m_unk0x8e = m_bitmap->GetBmiHeightAbs() - 1;
}
// FUNCTION: LEGO1 0x10043a30
void LegoMeterPresenter::RepeatingTickle()
{
FUN_10043a50();
MxStillPresenter::RepeatingTickle();
}
// STUB: LEGO1 0x10043a50
void LegoMeterPresenter::FUN_10043a50()
{
}