Decompile fn_45488 (UIPlayerGage::Paint)

Batch #10456 by secret: 0 byte-identical, 1 confirmed by peer review.

- fn_45488 UIPlayerGage::Paint: logic confirmed by peer review

Peer-reviewed-by: ragnarok-clanker, Yommy, KWDev, seumadruga
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
This commit is contained in:
ragnarok-clanker 2026-11-04 09:15:07 +00:00
commit 90aef1f08d
2 changed files with 62 additions and 0 deletions

View file

@ -44,6 +44,7 @@ class UIPlayerGage : public UIGage {
public:
UIPlayerGage();
bool Slot03() override;
void Paint() override;
void SetFirstValues(std::function<std::int64_t()> current, std::function<std::int64_t()> maximum);
void SetSecondValues(std::function<std::int64_t()> current, std::function<std::int64_t()> maximum);
void SetThirdValues(std::function<std::int64_t()> current, std::function<std::int64_t()> maximum);

View file

@ -85,3 +85,64 @@ void UIPlayerGage::SetSecondValues(std::function<std::int64_t()> current, std::f
this->m_secondCurrent = current;
this->m_secondMaximum = maximum;
}
// OFFSET: 0x0088CB50
// FUNCTION: fn_45488
void UIPlayerGage::Paint() {
this->ClearSurface(this->colors[0]);
const auto drawBar = [this](int y, std::function<std::int64_t()>& current, std::function<std::int64_t()>& maximum,
std::uint32_t color, std::uint32_t alternateColor, bool thresholdColor,
bool wideDenominator) {
const std::int64_t maximumValue = (std::max)(std::int64_t(1), maximum());
const std::int64_t denominator = (std::max)(current(), maximumValue);
const std::int64_t numerator = current();
const double divisor =
wideDenominator ? static_cast<double>(denominator) : static_cast<double>(static_cast<int>(denominator));
const float ratio = static_cast<float>(static_cast<double>(numerator) / divisor);
this->FillRegion(1, y, this->geometry.width - 2, 3, this->colors[1]);
if (thresholdColor && ratio < 0.25f) {
color = alternateColor;
}
this->FillRegion(1, y, static_cast<int>(static_cast<float>(this->geometry.width - 2) * ratio), 3, color);
};
switch (this->unknown_009C) {
case 7:
if (this->m_thirdCurrent && this->m_thirdMaximum) {
drawBar(1, this->m_thirdCurrent, this->m_thirdMaximum, this->colors[5], this->colors[6], true, true);
}
break;
case 9:
case 10:
if (this->m_firstCurrent && this->m_firstMaximum && this->m_secondCurrent && this->m_secondMaximum) {
drawBar(1, this->m_firstCurrent, this->m_firstMaximum, this->colors[2], this->colors[4], true, true);
drawBar(5, this->m_secondCurrent, this->m_secondMaximum, this->colors[3], this->colors[3], false, false);
}
break;
case 13:
case 14:
if (this->m_firstCurrent && this->m_firstMaximum) {
drawBar(1, this->m_firstCurrent, this->m_firstMaximum, this->colors[2], this->colors[4], true, true);
}
break;
case 8:
if (this->m_firstCurrent && this->m_firstMaximum && this->m_secondCurrent && this->m_secondMaximum &&
this->m_thirdCurrent && this->m_thirdMaximum) {
drawBar(1, this->m_firstCurrent, this->m_firstMaximum, this->colors[2], this->colors[4], true, true);
drawBar(5, this->m_secondCurrent, this->m_secondMaximum, this->colors[3], this->colors[3], false, true);
drawBar(9, this->m_thirdCurrent, this->m_thirdMaximum, this->colors[5], this->colors[6], true, true);
}
break;
default:
if (this->m_firstCurrent && this->m_firstMaximum && this->m_secondCurrent && this->m_secondMaximum) {
drawBar(1, this->m_firstCurrent, this->m_firstMaximum, this->colors[2], this->colors[4], true, false);
drawBar(5, this->m_secondCurrent, this->m_secondMaximum, this->colors[3], this->colors[3], false, false);
if (this->m_fourthCurrent && this->m_fourthMaximum) {
drawBar(9, this->m_fourthCurrent, this->m_fourthMaximum, this->colors[7], this->colors[7], false, false);
}
}
break;
}
}