metaforce/Runtime/GuiSys/CHudBallInterface.cpp

116 lines
4.0 KiB
C++
Raw Normal View History

2017-04-03 01:39:23 +00:00
#include "CHudBallInterface.hpp"
2017-04-07 05:35:09 +00:00
#include "CGuiFrame.hpp"
#include "CGuiGroup.hpp"
#include "CGuiCamera.hpp"
#include "CGuiTextPane.hpp"
#include "CGuiModel.hpp"
#include "GameGlobalObjects.hpp"
2017-04-03 01:39:23 +00:00
namespace urde
{
2017-04-08 20:40:36 +00:00
CHudBallInterface::CHudBallInterface(CGuiFrame& selHud, int pbAmount, int pbCapacity,
2017-04-07 05:35:09 +00:00
int availableBombs, bool hasBombs, bool hasPb)
2017-04-08 20:40:36 +00:00
: x40_pbAmount(pbAmount), x44_pbCapacity(pbCapacity),
2017-04-07 05:35:09 +00:00
x48_availableBombs(availableBombs), x4c_hasPb(hasPb)
{
x0_camera = selHud.GetFrameCamera();
x4_basewidget_bombstuff = selHud.FindWidget("basewidget_bombstuff");
x8_basewidget_bombdeco = selHud.FindWidget("basewidget_bombdeco");
xc_model_bombicon = static_cast<CGuiModel*>(selHud.FindWidget("model_bombicon"));
x10_textpane_bombdigits = static_cast<CGuiTextPane*>(selHud.FindWidget("textpane_bombdigits"));
for (int i=0 ; i<3 ; ++i)
{
CGuiGroup* grp = static_cast<CGuiGroup*>(selHud.FindWidget(hecl::Format("group_bombcount%d", i).c_str()));
CGuiWidget* filled = grp->GetWorkerWidget(1);
CGuiWidget* empty = grp->GetWorkerWidget(0);
x14_group_bombfilled.push_back(filled);
x24_group_bombempty.push_back(empty);
if (filled)
filled->SetColor(g_tweakGuiColors->GetBallBombFilledColor());
if (empty)
empty->SetColor(g_tweakGuiColors->GetBallBombEmptyColor());
}
x8_basewidget_bombdeco->SetColor(g_tweakGuiColors->GetBallBombDecoColor());
x34_camPos = x0_camera->GetLocalPosition();
if (CGuiWidget* w = selHud.FindWidget("basewidget_energydeco"))
w->SetColor(g_tweakGuiColors->GetBallBombEnergyColor());
2017-04-08 20:40:36 +00:00
SetBombParams(pbAmount, pbCapacity, availableBombs, hasBombs, hasPb, true);
2017-04-07 05:35:09 +00:00
}
void CHudBallInterface::UpdatePowerBombReadoutColors()
{
zeus::CColor fontColor;
zeus::CColor outlineColor;
2017-04-08 20:40:36 +00:00
if (x40_pbAmount > 0)
2017-04-07 05:35:09 +00:00
{
fontColor = g_tweakGuiColors->GetPowerBombDigitAvailableFont();
outlineColor = g_tweakGuiColors->GetPowerBombDigitAvailableOutline();
}
2017-04-08 20:40:36 +00:00
else if (x44_pbCapacity > 0)
2017-04-07 05:35:09 +00:00
{
fontColor = g_tweakGuiColors->GetPowerBombDigitDelpetedFont();
outlineColor = g_tweakGuiColors->GetPowerBombDigitDelpetedOutline();
}
else
{
fontColor = zeus::CColor::skClear;
outlineColor = zeus::CColor::skClear;
}
2017-05-31 21:26:50 +00:00
x10_textpane_bombdigits->TextSupport().SetFontColor(fontColor);
x10_textpane_bombdigits->TextSupport().SetOutlineColor(outlineColor);
2017-04-07 05:35:09 +00:00
zeus::CColor iconColor;
2017-04-08 20:40:36 +00:00
if (x40_pbAmount > 0 && x4c_hasPb)
2017-04-07 05:35:09 +00:00
iconColor = g_tweakGuiColors->GetPowerBombIconAvailableColor();
2017-04-08 20:40:36 +00:00
else if (x44_pbCapacity > 0)
2017-04-07 05:35:09 +00:00
iconColor = g_tweakGuiColors->GetPowerBombIconDepletedColor();
else
iconColor = zeus::CColor::skClear;
xc_model_bombicon->SetColor(iconColor);
}
2017-04-08 20:40:36 +00:00
void CHudBallInterface::SetBombParams(int pbAmount, int pbCapacity, int availableBombs,
2017-04-07 05:35:09 +00:00
bool hasBombs, bool hasPb, bool init)
2017-04-03 01:39:23 +00:00
{
2017-04-08 20:40:36 +00:00
if (pbAmount != x40_pbAmount || init)
2017-04-07 05:35:09 +00:00
{
2017-05-31 21:26:50 +00:00
x10_textpane_bombdigits->TextSupport().SetText(hecl::Format("%02d", pbAmount));
2017-04-08 20:40:36 +00:00
x40_pbAmount = pbAmount;
2017-04-07 05:35:09 +00:00
UpdatePowerBombReadoutColors();
}
2017-04-03 01:39:23 +00:00
2017-04-08 20:40:36 +00:00
if (x44_pbCapacity != pbCapacity || init)
2017-04-07 05:35:09 +00:00
{
2017-04-08 20:40:36 +00:00
x44_pbCapacity = pbCapacity;
2017-04-07 05:35:09 +00:00
UpdatePowerBombReadoutColors();
}
if (x4c_hasPb != hasPb)
{
x4c_hasPb = hasPb;
UpdatePowerBombReadoutColors();
}
for (int i=0 ; i<3 ; ++i)
{
bool lit = i < availableBombs;
x14_group_bombfilled[i]->SetVisibility(lit && hasBombs, ETraversalMode::Children);
x24_group_bombempty[i]->SetVisibility(!lit && hasBombs, ETraversalMode::Children);
}
x48_availableBombs = availableBombs;
2017-04-08 20:40:36 +00:00
x8_basewidget_bombdeco->SetVisibility(hasBombs && x44_pbCapacity > 0, ETraversalMode::Children);
2017-04-07 05:35:09 +00:00
}
void CHudBallInterface::SetBallModeFactor(float t)
{
float tmp = 0.5f * 448.f * g_tweakGui->GetBallViewportYReduction();
x0_camera->SetLocalTransform(
zeus::CTransform::Translate(x34_camPos + zeus::CVector3f(0.f, 0.f, (t * tmp - tmp) * 0.01f)));
2017-04-03 01:39:23 +00:00
}
}