metaforce/Runtime/GuiSys/CHudBossEnergyInterface.cpp

58 lines
2.1 KiB
C++
Raw Permalink Normal View History

#include "Runtime/GuiSys/CHudBossEnergyInterface.hpp"
#include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/GuiSys/CAuiEnergyBarT01.hpp"
#include "Runtime/GuiSys/CGuiFrame.hpp"
#include "Runtime/GuiSys/CGuiTextPane.hpp"
2017-04-03 01:39:23 +00:00
2021-04-10 08:42:06 +00:00
namespace metaforce {
2018-12-08 05:30:43 +00:00
CHudBossEnergyInterface::CHudBossEnergyInterface(CGuiFrame& selHud) {
x14_basewidget_bossenergystuff = selHud.FindWidget("basewidget_bossenergystuff");
x18_energybart01_bossbar = static_cast<CAuiEnergyBarT01*>(selHud.FindWidget("energybart01_bossbar"));
x1c_textpane_boss = static_cast<CGuiTextPane*>(selHud.FindWidget("textpane_boss"));
x18_energybart01_bossbar->SetCoordFunc(BossEnergyCoordFunc);
x18_energybart01_bossbar->SetTesselation(0.2f);
const auto& [filled, empty, shadow] = g_tweakGuiColors->GetVisorEnergyBarColors(0);
x18_energybart01_bossbar->SetFilledColor(filled);
x18_energybart01_bossbar->SetShadowColor(shadow);
x18_energybart01_bossbar->SetEmptyColor(empty);
2017-04-04 05:48:13 +00:00
}
2018-12-08 05:30:43 +00:00
void CHudBossEnergyInterface::Update(float dt) {
if (x10_24_visible)
x4_fader = std::min(x4_fader + dt, 1.f);
else
x4_fader = std::max(0.f, x4_fader - dt);
if (x4_fader > 0.f) {
zeus::CColor color = zeus::skWhite;
2018-12-08 05:30:43 +00:00
color.a() = x0_alpha * x4_fader;
x14_basewidget_bossenergystuff->SetColor(color);
x14_basewidget_bossenergystuff->SetVisibility(true, ETraversalMode::Children);
} else {
x14_basewidget_bossenergystuff->SetVisibility(false, ETraversalMode::Children);
}
2017-04-04 05:48:13 +00:00
}
2018-12-08 05:30:43 +00:00
void CHudBossEnergyInterface::SetBossParams(bool visible, std::u16string_view name, float curEnergy, float maxEnergy) {
x10_24_visible = visible;
if (visible) {
x18_energybart01_bossbar->SetFilledDrainSpeed(maxEnergy);
x18_energybart01_bossbar->SetCurrEnergy(curEnergy, CAuiEnergyBarT01::ESetMode::Normal);
x18_energybart01_bossbar->SetMaxEnergy(maxEnergy);
x1c_textpane_boss->TextSupport().SetText(name);
}
x8_curEnergy = curEnergy;
xc_maxEnergy = maxEnergy;
2017-04-04 05:48:13 +00:00
}
2017-04-03 01:39:23 +00:00
2018-12-08 05:30:43 +00:00
std::pair<zeus::CVector3f, zeus::CVector3f> CHudBossEnergyInterface::BossEnergyCoordFunc(float t) {
float x = 9.25f * t - 4.625f;
return {zeus::CVector3f(x, 0.f, 0.f), zeus::CVector3f(x, 0.f, 0.4f)};
2017-04-03 01:39:23 +00:00
}
2021-04-10 08:42:06 +00:00
} // namespace metaforce