mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-02-03 12:31:15 +00:00
* Implement/match LegoPathActor::ParseAction (#946) * Implement/match LegoPathActor::ParseAction * Fix naming * Space * Implement/match Isle::UpdateGlobe (#947) * Implement/match Isle::UpdateGlobe * Change function access * Implement/match Isle::CreateState and related (#948) * Implement/match actor Create functions (#949) * Implement/match Isle::Escape (#950) * Implement/match Isle::FUN_10033350 (#951) * Implement/match Isle::HandleType19Notification (#952) * Implement/match Isle::HandleType19Notification * Fix * Implement/match LegoAnimationManager::FUN_10063b90 (#953) * Implement/match LegoAnimationManager::FUN_100648f0 (#954) * Implement LegoROI::FUN_100a9410 (#955) * WIP * WIP * Remove space * Fix * Implement/match LegoExtraActor::VTable0x6c (#956) * Match LegoUnknown::FUN_1009a1e0 (#957) * Fix extra actor collisions (#958) * Implement/match IslePathActor::FUN_1001b660 (#960) * Refactor MxBitmap (again) (#961) * Remove this * Starting list of beta addrs * Static for height-specific abs, fix StrechBits * MxBitmap refactor * Implement/match LegoPathBoundary::FUN_100586e0 and FUN_10057fe0 (#962) * Implement/match LegoAnimPresenter::FUN_1006b140 (#963) * Implement LegoMeterPresenter::DrawMeter (#964) * Implement LegoMeterPresenter::DrawMeter * New MxRect16 header, offsets and size annotations * Missing mxtypes include * Implement/match LegoAnimationManager::FUN_10063270 (#965) * Implement/match LegoAnimMMPresenter::FUN_1004b840 (#966) * Implement/match LegoAnimationManager::FUN_10062e20 (#967) * Beta match MxPalette (#968) * Beta match MxPalette * Modern compiler fix * Implement/match LegoCameraController::FUN_10012290 and FUN_10012320 (#969) * Implement/match LegoControlManager::FUN_100293c0 (#970) * Implement/match Pizzeria::HandleClick (#971) * Implement/match Lego3DWavePresenter::StartingTickle (#972) * Implement/match Lego3DWavePresenter::StartingTickle * Fix annotation * Add StreamingTickle * Rename * Add static HandlerClassName function (#973) * Add static HandlerClassName function * Use method in PresenterNameDispatch --------- Co-authored-by: disinvite@users.noreply.github.com <disinvite@users.noreply.github.com>
163 lines
3.8 KiB
C++
163 lines
3.8 KiB
C++
#include "legometerpresenter.h"
|
|
|
|
#include "decomp.h"
|
|
#include "define.h"
|
|
#include "mxbitmap.h"
|
|
#include "mxdsaction.h"
|
|
#include "mxmisc.h"
|
|
#include "mxutilities.h"
|
|
#include "mxvariabletable.h"
|
|
|
|
#include <assert.h>
|
|
|
|
DECOMP_SIZE_ASSERT(LegoMeterPresenter, 0x94)
|
|
|
|
// FUNCTION: LEGO1 0x10043430
|
|
// FUNCTION: BETA10 0x10097570
|
|
LegoMeterPresenter::LegoMeterPresenter()
|
|
{
|
|
m_meterPixels = NULL;
|
|
m_fillColor = 1;
|
|
m_curPercent = 0;
|
|
m_layout = e_leftToRight;
|
|
m_flags.m_bit1 = FALSE;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x10043780
|
|
// FUNCTION: BETA10 0x1009764a
|
|
LegoMeterPresenter::~LegoMeterPresenter()
|
|
{
|
|
delete m_meterPixels;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x10043800
|
|
// FUNCTION: BETA10 0x100976ec
|
|
void LegoMeterPresenter::ParseExtra()
|
|
{
|
|
MxStillPresenter::ParseExtra();
|
|
|
|
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];
|
|
if (KeyValueStringParse(extraCopy, g_strTYPE, output)) {
|
|
if (!strcmpi(output, g_strLEFT_TO_RIGHT)) {
|
|
m_layout = e_leftToRight;
|
|
}
|
|
else if (!strcmpi(output, g_strRIGHT_TO_LEFT)) {
|
|
m_layout = e_rightToLeft;
|
|
}
|
|
else if (!strcmpi(output, g_strBOTTOM_TO_TOP)) {
|
|
m_layout = e_bottomToTop;
|
|
}
|
|
else if (!strcmpi(output, g_strTOP_TO_BOTTOM)) {
|
|
m_layout = e_topToBottom;
|
|
}
|
|
}
|
|
|
|
if (KeyValueStringParse(extraCopy, g_strFILLER_INDEX, output)) {
|
|
m_fillColor = atoi(output);
|
|
}
|
|
|
|
if (KeyValueStringParse(extraCopy, g_strVARIABLE, output)) {
|
|
m_variable = output;
|
|
}
|
|
else {
|
|
assert(0);
|
|
EndAction();
|
|
}
|
|
}
|
|
else {
|
|
EndAction();
|
|
}
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x10043990
|
|
// FUNCTION: BETA10 0x10097917
|
|
void LegoMeterPresenter::StreamingTickle()
|
|
{
|
|
MxStillPresenter::StreamingTickle();
|
|
m_meterPixels = new MxU8[m_frameBitmap->GetDataSize()];
|
|
if (m_meterPixels == NULL) {
|
|
assert(0);
|
|
EndAction();
|
|
}
|
|
|
|
memcpy(m_meterPixels, m_frameBitmap->GetImage(), m_frameBitmap->GetDataSize());
|
|
|
|
m_meterRect.SetLeft(0);
|
|
m_meterRect.SetTop(0);
|
|
m_meterRect.SetRight(m_frameBitmap->GetBmiWidth() - 1);
|
|
m_meterRect.SetBottom(m_frameBitmap->GetBmiHeightAbs() - 1);
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x10043a30
|
|
// FUNCTION: BETA10 0x10097a1a
|
|
void LegoMeterPresenter::RepeatingTickle()
|
|
{
|
|
DrawMeter();
|
|
MxStillPresenter::RepeatingTickle();
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x10043a50
|
|
// FUNCTION: BETA10 0x10097a40
|
|
void LegoMeterPresenter::DrawMeter()
|
|
{
|
|
const char* strval = VariableTable()->GetVariable(m_variable.GetData());
|
|
MxFloat percent = atof(strval);
|
|
MxS16 row, leftRightCol, bottomTopCol, leftRightEnd, bottomTopEnd;
|
|
|
|
if (strval != NULL && m_curPercent != percent) {
|
|
m_curPercent = percent;
|
|
|
|
// DECOMP: This clamp is retail only
|
|
if (percent > 0.99) {
|
|
m_curPercent = 0.99f;
|
|
}
|
|
else if (percent < 0.0) {
|
|
m_curPercent = 0.0f;
|
|
}
|
|
|
|
// Copy the previously drawn meter back into the bitmap
|
|
memcpy(m_frameBitmap->GetImage(), m_meterPixels, m_frameBitmap->GetDataSize());
|
|
|
|
switch (m_layout) {
|
|
case e_leftToRight:
|
|
leftRightEnd = m_meterRect.GetWidth() * m_curPercent;
|
|
|
|
for (row = m_meterRect.GetTop(); row < m_meterRect.GetBottom(); row++) {
|
|
MxU8* line = m_frameBitmap->GetStart(m_meterRect.GetLeft(), row);
|
|
|
|
for (leftRightCol = 0; leftRightCol < leftRightEnd; leftRightCol++, line++) {
|
|
if (*line) {
|
|
*line = m_fillColor;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case e_bottomToTop:
|
|
bottomTopEnd = m_meterRect.GetBottom() - (MxS16) (m_meterRect.GetHeight() * m_curPercent);
|
|
|
|
for (row = m_meterRect.GetBottom(); row < bottomTopEnd; row--) {
|
|
MxU8* line = m_frameBitmap->GetStart(m_meterRect.GetLeft(), row);
|
|
|
|
for (bottomTopCol = 0; bottomTopCol < m_meterRect.GetWidth(); bottomTopCol++, line++) {
|
|
if (*line) {
|
|
*line = m_fillColor;
|
|
}
|
|
}
|
|
}
|
|
// break;
|
|
default:
|
|
// The other two fill options are not implemented.
|
|
break;
|
|
}
|
|
}
|
|
}
|