CSamusHud: Dehardcode sizes where applicable

This commit is contained in:
Lioncash 2020-04-02 08:29:34 -04:00
parent 013b715c63
commit 66711ce023
1 changed files with 21 additions and 16 deletions

View File

@ -107,10 +107,11 @@ void CSamusHud::InitializeFrameGluePermanent(const CStateManager& mgr) {
child->SetDepthTest(false); child->SetDepthTest(false);
x59c_base_textpane_message = static_cast<CGuiTextPane*>(x274_loadedFrmeBaseHud->FindWidget("textpane_message")); x59c_base_textpane_message = static_cast<CGuiTextPane*>(x274_loadedFrmeBaseHud->FindWidget("textpane_message"));
x5a0_base_model_abutton = static_cast<CGuiModel*>(x274_loadedFrmeBaseHud->FindWidget("model_abutton")); x5a0_base_model_abutton = static_cast<CGuiModel*>(x274_loadedFrmeBaseHud->FindWidget("model_abutton"));
for (int i = 0; i < 4; ++i) for (size_t i = 0; i < x5d8_guiLights.size(); ++i) {
x5d8_guiLights[i] = x264_loadedFrmeHelmet->GetFrameLight(i); x5d8_guiLights[i] = x264_loadedFrmeHelmet->GetFrameLight(s32(i));
}
x5d8_guiLights[3]->SetColor(zeus::skBlack); x5d8_guiLights[3]->SetColor(zeus::skBlack);
for (int i = 0; i < 4; ++i) { for (size_t i = 0; i < x5a4_videoBands.size(); ++i) {
SVideoBand& band = x5a4_videoBands[i]; SVideoBand& band = x5a4_videoBands[i];
band.x0_videoband = band.x0_videoband =
static_cast<CGuiModel*>(x274_loadedFrmeBaseHud->FindWidget(fmt::format(fmt("model_videoband{}"), i))); static_cast<CGuiModel*>(x274_loadedFrmeBaseHud->FindWidget(fmt::format(fmt("model_videoband{}"), i)));
@ -497,9 +498,11 @@ void CSamusHud::UpdateMissile(float dt, const CStateManager& mgr, bool init) {
} }
void CSamusHud::UpdateVideoBands(float dt, const CStateManager& mgr) { void CSamusHud::UpdateVideoBands(float dt, const CStateManager& mgr) {
for (int i = 0; i < 4; ++i) for (auto& videoBand : x5a4_videoBands) {
if (x5a4_videoBands[i].x0_videoband) if (videoBand.x0_videoband) {
x5a4_videoBands[i].x0_videoband->SetIsVisible(false); videoBand.x0_videoband->SetIsVisible(false);
}
}
} }
void CSamusHud::UpdateBallMode(const CStateManager& mgr, bool init) { void CSamusHud::UpdateBallMode(const CStateManager& mgr, bool init) {
@ -710,9 +713,11 @@ bool CSamusHud::IsAreaLightInCachedLights(const CLight& light) const {
} }
int CSamusHud::FindEmptyHudLightSlot(const CLight& light) const { int CSamusHud::FindEmptyHudLightSlot(const CLight& light) const {
for (int i = 0; i < 3; ++i) for (size_t i = 0; i < x340_hudLights.size(); ++i) {
if (x340_hudLights[i].x1c_fader == 0.f) if (x340_hudLights[i].x1c_fader == 0.f) {
return i; return int(i);
}
}
return -1; return -1;
} }
@ -792,7 +797,7 @@ void CSamusHud::UpdateHudDynamicLights(float dt, const CStateManager& mgr) {
auto lightIt = x5d8_guiLights.begin(); auto lightIt = x5d8_guiLights.begin();
float maxIntensity = 0.f; float maxIntensity = 0.f;
int maxIntensityIdx = 0; int maxIntensityIdx = 0;
for (int i = 0; i < 3; ++i) { for (size_t i = 0; i < x340_hudLights.size(); ++i) {
SCachedHudLight& light = x340_hudLights[i]; SCachedHudLight& light = x340_hudLights[i];
CGuiLight* lightWidget = *lightIt++; CGuiLight* lightWidget = *lightIt++;
zeus::CVector3f lightToCam = fpCam->GetTranslation() - light.x0_pos; zeus::CVector3f lightToCam = fpCam->GetTranslation() - light.x0_pos;
@ -811,7 +816,7 @@ void CSamusHud::UpdateHudDynamicLights(float dt, const CStateManager& mgr) {
fadedFalloff * zeus::skForward.dot(-lightNormal) * lightAdd.rgbDot(zeus::CColor(0.3f, 0.6f, 0.1f)); fadedFalloff * zeus::skForward.dot(-lightNormal) * lightAdd.rgbDot(zeus::CColor(0.3f, 0.6f, 0.1f));
if (greyscale > maxIntensity) { if (greyscale > maxIntensity) {
maxIntensity = greyscale; maxIntensity = greyscale;
maxIntensityIdx = i; maxIntensityIdx = int(i);
} }
} }
@ -953,9 +958,9 @@ void CSamusHud::UpdateHudDamage(float dt, const CStateManager& mgr, DataSpec::IT
float rotAng = rotMul * (2.f * M_PIF / 10.f); float rotAng = rotMul * (2.f * M_PIF / 10.f);
x44c_hudLagShakeRot.rotateX(rand() / float(RAND_MAX) * rotAng); x44c_hudLagShakeRot.rotateX(rand() / float(RAND_MAX) * rotAng);
x44c_hudLagShakeRot.rotateZ(rand() / float(RAND_MAX) * rotAng); x44c_hudLagShakeRot.rotateZ(rand() / float(RAND_MAX) * rotAng);
zeus::CVector3f vecs[] = {zeus::skRight, zeus::skForward, zeus::skUp}; std::array<zeus::CVector3f, 3> vecs{zeus::skRight, zeus::skForward, zeus::skUp};
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
int sel = rand() % 9; const int sel = rand() % 9;
vecs[sel % 3][sel / 3] += (rand() / float(RAND_MAX) - dt) * rotMul; vecs[sel % 3][sel / 3] += (rand() / float(RAND_MAX) - dt) * rotMul;
} }
x428_decoShakeRotate = zeus::CMatrix3f(vecs[0], vecs[1], vecs[2]).transposed(); x428_decoShakeRotate = zeus::CMatrix3f(vecs[0], vecs[1], vecs[2]).transposed();
@ -1169,9 +1174,9 @@ void CSamusHud::Update(float dt, const CStateManager& mgr, CInGameGuiManager::EH
UpdateEnergyLow(dt, mgr); UpdateEnergyLow(dt, mgr);
for (int i = 0; i < 15; ++i) { for (auto& entry : x7ac_) {
x7ac_[i].x0_ = 0; entry.x0_ = 0;
x7ac_[i].x4_ = 0; entry.x4_ = 0;
} }
if (x2ac_radarIntf) if (x2ac_radarIntf)