Finish CInventoryScreen

This commit is contained in:
Jack Andersen 2017-05-09 09:44:05 -10:00
parent aee73fc11a
commit e3dc0762ec
5 changed files with 249 additions and 24 deletions

View File

@ -92,7 +92,7 @@ public:
Ice,
Plasma,
Wave,
Phazon
Phazon = 27
};
enum class EChargeState : u32

View File

@ -1,6 +1,7 @@
#include "CInventoryScreen.hpp"
#include "GuiSys/CGuiTableGroup.hpp"
#include "GuiSys/CGuiTextPane.hpp"
#include "GuiSys/CGuiModel.hpp"
#include "Input/ControlMapper.hpp"
#include "GameGlobalObjects.hpp"
@ -269,6 +270,8 @@ void CInventoryScreen::VActivate() const
x180_basewidget_yicon->SetVisibility(true, ETraversalMode::Children);
}
void CInventoryScreen::RightTableSelectionChanged(int selBegin, int selEnd) {}
void CInventoryScreen::UpdateTextBody()
{
const SInventoryItem& sel = InventoryRegistry[x70_tablegroup_leftlog->GetUserSelection()].second[x1c_rightSel];
@ -357,9 +360,65 @@ bool CInventoryScreen::HasRightInventoryItem(int idx) const
}
}
void CInventoryScreen::SetRightTableScroll(int, int)
bool CInventoryScreen::IsRightInventoryItemEquipped(int idx) const
{
CPlayerState& playerState = *x4_mgr.GetPlayerState();
switch (idx)
{
case 0: // Power Beam
return playerState.GetCurrentBeam() == CPlayerState::EBeamId::Power;
case 1: // Ice Beam
return playerState.GetCurrentBeam() == CPlayerState::EBeamId::Ice;
case 2: // Wave Beam
return playerState.GetCurrentBeam() == CPlayerState::EBeamId::Wave;
case 3: // Plasma Beam
return playerState.GetCurrentBeam() == CPlayerState::EBeamId::Plasma;
case 4: // Phazon Beam
return playerState.GetCurrentBeam() == CPlayerState::EBeamId::Phazon;
case 5: // Morph Ball
return playerState.HasPowerUp(CPlayerState::EItemType::MorphBall);
case 6: // Boost Ball
return playerState.HasPowerUp(CPlayerState::EItemType::BoostBall);
case 7: // Spider Ball
return playerState.HasPowerUp(CPlayerState::EItemType::SpiderBall);
case 8: // Morph Ball Bomb
return playerState.HasPowerUp(CPlayerState::EItemType::MorphBallBombs);
case 9: // Power Bomb
return playerState.HasPowerUp(CPlayerState::EItemType::PowerBombs);
case 10: // Power Suit
return playerState.GetCurrentSuit() == CPlayerState::EPlayerSuit::Power;
case 11: // Varia Suit
return playerState.GetCurrentSuit() == CPlayerState::EPlayerSuit::Varia;
case 12: // Gravity Suit
return playerState.GetCurrentSuit() == CPlayerState::EPlayerSuit::Gravity;
case 13: // Phazon Suit
return playerState.GetCurrentSuit() == CPlayerState::EPlayerSuit::Phazon;
case 14: // Energy Tank
return playerState.HasPowerUp(CPlayerState::EItemType::EnergyTanks);
case 15: // Combat Visor
return playerState.GetCurrentVisor() == CPlayerState::EPlayerVisor::Combat;
case 16: // Scan Visor
return playerState.GetCurrentVisor() == CPlayerState::EPlayerVisor::Scan;
case 17: // X-Ray Visor
return playerState.GetCurrentVisor() == CPlayerState::EPlayerVisor::XRay;
case 18: // Thermal Visor
return playerState.GetCurrentVisor() == CPlayerState::EPlayerVisor::Thermal;
case 19: // Space Jump Boots
return playerState.HasPowerUp(CPlayerState::EItemType::SpaceJumpBoots);
case 20: // Grapple Beam
return playerState.HasPowerUp(CPlayerState::EItemType::GrappleBeam);
case 21: // Missile Launcher
return playerState.HasPowerUp(CPlayerState::EItemType::Missiles);
case 22: // Charge Beam
return playerState.HasPowerUp(CPlayerState::EItemType::ChargeBeam);
case 23: // Beam Combo
return playerState.HasPowerUp(CPlayerState::EItemType::SuperMissile) ||
playerState.HasPowerUp(CPlayerState::EItemType::IceSpreader) ||
playerState.HasPowerUp(CPlayerState::EItemType::Wavebuster) ||
playerState.HasPowerUp(CPlayerState::EItemType::Flamethrower);
default:
return false;
}
}
void CInventoryScreen::UpdateRightTable()
@ -396,7 +455,7 @@ void CInventoryScreen::UpdateRightTable()
if (minSel != INT_MAX)
{
x1c_rightSel = minSel;
SetRightTableScroll(x1c_rightSel, x1c_rightSel);
SetRightTableSelection(x1c_rightSel, x1c_rightSel);
}
x84_tablegroup_rightlog->GetWorkerWidget(0)->SetIsSelectable(false);
@ -406,6 +465,16 @@ void CInventoryScreen::UpdateRightTable()
UpdateRightLogColors(false, g_tweakGuiColors->GetPauseItemAmberColor(), inactiveColor);
}
bool CInventoryScreen::ShouldLeftTableAdvance() const
{
return x19c_samusDoll->IsLoaded();
}
bool CInventoryScreen::ShouldRightTableAdvance() const
{
return std::fabs(x19c_samusDoll->GetViewInterpolation()) == 0.f;
}
u32 CInventoryScreen::GetRightTableCount() const
{
return InventoryRegistry[x70_tablegroup_leftlog->GetUserSelection()].first;
@ -419,14 +488,42 @@ bool CInventoryScreen::IsRightLogDynamic() const
void CInventoryScreen::UpdateRightLogColors(bool active, const zeus::CColor& activeColor,
const zeus::CColor& inactiveColor)
{
x80_basewidget_rightlog->SetColor(active ? zeus::CColor::skWhite : zeus::CColor(1.f, 0.71f));
const std::pair<u32, const SInventoryItem*>& cat =
InventoryRegistry[x70_tablegroup_leftlog->GetUserSelection()];
for (u32 i=0 ; i<5 ; ++i)
{
if (i < cat.first && IsRightInventoryItemEquipped(cat.second[i].idx))
{
x15c_model_righttitledecos[i]->SetColor(g_tweakGuiColors->GetPauseItemBlueColor());
xd8_textpane_titles[i]->TextSupport()->SetFontColor(g_tweakGuiColors->GetPauseItemBlueColor());
}
else
{
x15c_model_righttitledecos[i]->SetColor(activeColor);
xd8_textpane_titles[i]->TextSupport()->SetFontColor(activeColor);
}
}
}
void CInventoryScreen::UpdateRightLogHighlight(bool active, int idx,
const zeus::CColor& activeColor,
const zeus::CColor& inactiveColor)
{
zeus::CColor actColor = g_tweakGuiColors->GetPauseItemAmberColor() * activeColor;
zeus::CColor inactColor = g_tweakGuiColors->GetPauseItemAmberColor() * inactiveColor;
const std::pair<u32, const SInventoryItem*>& cat =
InventoryRegistry[x70_tablegroup_leftlog->GetUserSelection()];
for (u32 i=0 ; i<5 ; ++i)
{
bool act = i == idx && active;
if (i < cat.first && IsRightInventoryItemEquipped(cat.second[i].idx) && act)
x8c_model_righthighlight->SetColor(g_tweakGuiColors->GetPauseItemBlueColor());
else if (act)
x8c_model_righthighlight->SetColor(actColor);
x144_model_titles[i]->SetColor(act ? actColor : inactColor);
}
}
void CInventoryScreen::UpdateSamusDollPulses()

View File

@ -20,6 +20,12 @@ class CInventoryScreen : public CPauseScreenBase
u32 x1a8_ = 0;
bool x1ac_ = false;
bool x1ad_textBodyVisible;
void UpdateSamusDollPulses();
bool HasLeftInventoryItem(int idx) const;
bool HasRightInventoryItem(int idx) const;
bool IsRightInventoryItemEquipped(int idx) const;
void UpdateTextBody();
public:
CInventoryScreen(const CStateManager& mgr, CGuiFrame& frame, const CStringTable& pauseStrg,
const CDependencyGroup& suitDgrp, const CDependencyGroup& ballDgrp);
@ -33,17 +39,15 @@ public:
float GetCameraYBias() const;
bool VReady() const;
void VActivate() const;
void RightTableSelectionChanged(int selBegin, int selEnd);
void ChangedMode();
void UpdateRightTable();
bool ShouldLeftTableAdvance() const;
bool ShouldRightTableAdvance() const;
u32 GetRightTableCount() const;
bool IsRightLogDynamic() const;
void UpdateRightLogColors(bool active, const zeus::CColor& activeColor, const zeus::CColor& inactiveColor);
void UpdateRightLogHighlight(bool active, int idx, const zeus::CColor& activeColor, const zeus::CColor& inactiveColor);
void UpdateSamusDollPulses();
bool HasLeftInventoryItem(int idx) const;
bool HasRightInventoryItem(int idx) const;
void UpdateTextBody();
void SetRightTableScroll(int, int);
};
}

View File

@ -51,6 +51,12 @@ void CPauseScreenBase::InitializeFrameGlue()
x190_tablegroup_double = static_cast<CGuiTableGroup*>(x8_frame.FindWidget("tablegroup_double"));
x194_tablegroup_triple = static_cast<CGuiTableGroup*>(x8_frame.FindWidget("tablegroup_triple"));
x2c_rightTableStart = x84_tablegroup_rightlog->GetWorkerWidget(0)->GetIdlePosition();
x38_hightlightPitch = x84_tablegroup_rightlog->GetWorkerWidget(1)->GetIdlePosition().z - x2c_rightTableStart.z;
x3c_sliderStart = x18c_slidergroup_slider->GetIdlePosition();
x48_tableDoubleStart = x190_tablegroup_double->GetIdlePosition();
x54_tableTripleStart = x194_tablegroup_triple->GetIdlePosition();
for (int i=0 ; i<5 ; ++i)
{
xd8_textpane_titles.push_back(static_cast<CGuiTextPane*>(x8_frame.FindWidget(hecl::Format("textpane_title%d", i + 1))));
@ -69,6 +75,59 @@ void CPauseScreenBase::InitializeFrameGlue()
x74_basewidget_leftguages->SetVisibility(false, ETraversalMode::Children);
x88_basewidget_rightguages->SetVisibility(false, ETraversalMode::Children);
x6c_basewidget_leftlog->SetColor(g_tweakGuiColors->GetPauseItemAmberColor());
if (IsRightLogDynamic())
{
zeus::CColor color = g_tweakGuiColors->GetPauseItemAmberColor();
color.a = 0.5f;
UpdateRightLogColors(false, g_tweakGuiColors->GetPauseItemAmberColor(), color);
}
else
{
x80_basewidget_rightlog->SetColor(g_tweakGuiColors->GetPauseItemAmberColor());
}
for (CGuiObject* obj = x64_basewidget_bgframe->GetChildObject() ; obj ; obj = obj->GetNextSibling())
static_cast<CGuiWidget*>(obj)->SetColor(g_tweakGuiColors->GetPauseItemAmberColor());
zeus::CColor dimColor = g_tweakGuiColors->GetPauseItemAmberColor();
dimColor.a = 0.2f;
x98_model_scrollleftup->SetColor(dimColor);
x9c_model_scrollleftdown->SetColor(dimColor);
xa0_model_scrollrightup->SetColor(dimColor);
xa4_model_scrollrightdown->SetColor(dimColor);
x90_model_textarrowtop->SetColor(dimColor);
x94_model_textarrowbottom->SetColor(dimColor);
x18c_slidergroup_slider->SetColor(g_tweakGuiColors->GetPauseItemAmberColor());
x190_tablegroup_double->SetColor(g_tweakGuiColors->GetPauseItemAmberColor());
x194_tablegroup_triple->SetColor(g_tweakGuiColors->GetPauseItemAmberColor());
UpdateSideTable(x190_tablegroup_double);
UpdateSideTable(x194_tablegroup_triple);
UpdateSideTable(x70_tablegroup_leftlog);
UpdateSideTable(x84_tablegroup_rightlog);
x18c_slidergroup_slider->SetVisibility(false, ETraversalMode::Children);
x190_tablegroup_double->SetIsVisible(false);
x194_tablegroup_triple->SetIsVisible(false);
x190_tablegroup_double->SetVertical(false);
x194_tablegroup_triple->SetVertical(false);
x70_tablegroup_leftlog->SetMenuAdvanceCallback(
std::bind(&CPauseScreenBase::OnLeftTableAdvance, this, std::placeholders::_1));
x70_tablegroup_leftlog->SetMenuSelectionChangeCallback(
std::bind(&CPauseScreenBase::OnTableSelectionChange, this, std::placeholders::_1, std::placeholders::_2));
x84_tablegroup_rightlog->SetMenuAdvanceCallback(
std::bind(&CPauseScreenBase::OnRightTableAdvance, this, std::placeholders::_1));
x84_tablegroup_rightlog->SetMenuSelectionChangeCallback(
std::bind(&CPauseScreenBase::OnTableSelectionChange, this, std::placeholders::_1, std::placeholders::_2));
x84_tablegroup_rightlog->SetMenuCancelCallback(
std::bind(&CPauseScreenBase::OnRightTableCancel, this, std::placeholders::_1));
x18c_slidergroup_slider->SetSelectionChangedCallback({});
x190_tablegroup_double->SetMenuSelectionChangeCallback({});
x194_tablegroup_triple->SetMenuSelectionChangeCallback({});
}
bool CPauseScreenBase::IsReady()
@ -127,7 +186,7 @@ void CPauseScreenBase::ChangeMode(EMode mode)
x6c_basewidget_leftlog->SetColor(color);
x70_tablegroup_leftlog->SetIsActive(true);
UpdateSideTable(x70_tablegroup_leftlog);
x18_ = 0;
x18_firstViewRightSel = 0;
x1c_rightSel = 0;
x84_tablegroup_rightlog->SetUserSelection(1);
UpdateSideTable(x84_tablegroup_rightlog);
@ -171,9 +230,9 @@ void CPauseScreenBase::UpdateSideTable(CGuiTableGroup* table)
if (table == x84_tablegroup_rightlog)
{
int sel = x1c_rightSel - x18_;
int sel = x1c_rightSel - x18_firstViewRightSel;
x8c_model_righthighlight->SetLocalTransform(
x8c_model_righthighlight->GetTransform() * zeus::CTransform::Translate(0.f, 0.f, x38_ * sel));
x8c_model_righthighlight->GetTransform() * zeus::CTransform::Translate(0.f, 0.f, x38_hightlightPitch * sel));
x8c_model_righthighlight->SetVisibility(x10_mode == EMode::RightTable, ETraversalMode::Children);
int selInView = x1c_rightSel % 5;
if (IsRightLogDynamic())
@ -190,7 +249,7 @@ void CPauseScreenBase::UpdateSideTable(CGuiTableGroup* table)
{
int sel = x70_tablegroup_leftlog->GetUserSelection();
x78_model_lefthighlight->SetLocalTransform(
x78_model_lefthighlight->GetTransform() * zeus::CTransform::Translate(0.f, 0.f, x38_ * sel));
x78_model_lefthighlight->GetTransform() * zeus::CTransform::Translate(0.f, 0.f, x38_hightlightPitch * sel));
for (int i=0 ; i<xc0_model_categories.size() ; ++i)
xc0_model_categories[i]->SetColor(i == sel ? selColor : deselColor);
}
@ -203,8 +262,8 @@ void CPauseScreenBase::Update(float dt, CRandom16& rand, CArchitectureQueue& arc
x14_alpha = std::min(2.f * dt + x14_alpha, 1.f);
u32 rightCount = GetRightTableCount();
bool pulseRightUp = x10_mode == EMode::RightTable && x18_ > 0;
bool pulseRightDown = x10_mode == EMode::RightTable && x18_ + 5 < rightCount;
bool pulseRightUp = x10_mode == EMode::RightTable && x18_firstViewRightSel > 0;
bool pulseRightDown = x10_mode == EMode::RightTable && x18_firstViewRightSel + 5 < rightCount;
float rightUpT = pulseRightUp ? CGraphics::GetSecondsMod900() : 0.f;
float rightDownT = pulseRightDown ? CGraphics::GetSecondsMod900() : 0.f;
@ -248,12 +307,67 @@ void CPauseScreenBase::Draw(float mainAlpha, float frameAlpha, float yOff)
void CPauseScreenBase::UpdateRightTable()
{
x18_ = 0;
x18_firstViewRightSel = 0;
x1c_rightSel = 0;
x84_tablegroup_rightlog->SetUserSelection(1);
UpdateSideTable(x84_tablegroup_rightlog);
}
void CPauseScreenBase::SetRightTableSelection(int begin, int end)
{
int oldRightSel = x1c_rightSel;
x1c_rightSel = zeus::clamp(end, x1c_rightSel + (end - begin), int(GetRightTableCount()) - 1);
if (oldRightSel != x1c_rightSel)
CSfxManager::SfxStart(1436, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
if (x1c_rightSel < x18_firstViewRightSel)
x18_firstViewRightSel = x1c_rightSel;
else if (x1c_rightSel >= x18_firstViewRightSel + 5)
x18_firstViewRightSel = x1c_rightSel - 4;
x84_tablegroup_rightlog->SetUserSelection(x1c_rightSel + 1 - x18_firstViewRightSel);
UpdateSideTable(x84_tablegroup_rightlog);
RightTableSelectionChanged(begin, end);
}
void CPauseScreenBase::OnLeftTableAdvance(CGuiTableGroup* caller)
{
if (ShouldLeftTableAdvance())
{
ChangeMode(EMode::RightTable);
x198_25_handledInput = true;
CSfxManager::SfxStart(1432, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
}
}
void CPauseScreenBase::OnRightTableAdvance(CGuiTableGroup* caller)
{
if (ShouldRightTableAdvance() && !x198_25_handledInput)
{
ChangeMode(EMode::TextScroll);
CSfxManager::SfxStart(1432, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
}
}
void CPauseScreenBase::OnTableSelectionChange(CGuiTableGroup* caller, int sel)
{
UpdateSideTable(caller);
if (x70_tablegroup_leftlog == caller)
{
CSfxManager::SfxStart(1436, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
UpdateRightTable();
}
else
{
SetRightTableSelection(sel, x84_tablegroup_rightlog->GetUserSelection());
}
}
void CPauseScreenBase::OnRightTableCancel(CGuiTableGroup* caller)
{
ChangeMode(EMode::LeftTable);
}
static const char* PaneSuffixes[] =
{
"0",

View File

@ -37,14 +37,14 @@ protected:
const CStringTable& xc_pauseStrg;
EMode x10_mode = EMode::Invalid;
float x14_alpha = 0.f;
u32 x18_ = 0;
u32 x1c_rightSel = 0;
int x18_firstViewRightSel = 0;
int x1c_rightSel = 0;
zeus::CVector3f x20_;
zeus::CVector3f x2c_;
float x38_ = 0.f;
zeus::CVector3f x3c_;
zeus::CVector3f x48_;
zeus::CVector3f x54_;
zeus::CVector3f x2c_rightTableStart;
float x38_hightlightPitch = 0.f;
zeus::CVector3f x3c_sliderStart;
zeus::CVector3f x48_tableDoubleStart;
zeus::CVector3f x54_tableTripleStart;
CGuiWidget* x60_basewidget_pivot;
CGuiWidget* x64_basewidget_bgframe;
CGuiWidget* x68_basewidget_leftside = nullptr;
@ -95,6 +95,13 @@ protected:
static std::string GetImagePaneName(u32 i);
void ChangeMode(EMode mode);
void UpdateSideTable(CGuiTableGroup* table);
void SetRightTableSelection(int selBegin, int selEnd);
void OnLeftTableAdvance(CGuiTableGroup* caller);
void OnRightTableAdvance(CGuiTableGroup* caller);
void OnTableSelectionChange(CGuiTableGroup* caller, int sel);
void OnRightTableCancel(CGuiTableGroup* caller);
public:
CPauseScreenBase(const CStateManager& mgr, CGuiFrame& frame, const CStringTable& pauseStrg);
@ -114,8 +121,11 @@ public:
virtual float GetCameraYBias() const { return 0.f; }
virtual bool VReady() const=0;
virtual void VActivate() const=0;
virtual void RightTableSelectionChanged(int selBegin, int selEnd) {}
virtual void ChangedMode() {}
virtual void UpdateRightTable();
virtual bool ShouldLeftTableAdvance() const { return true; }
virtual bool ShouldRightTableAdvance() const { return true; }
virtual u32 GetRightTableCount() const=0;
virtual bool IsRightLogDynamic() const { return false; }
virtual void UpdateRightLogColors(bool active, const zeus::CColor& activeColor, zeus::CColor& inactiveColor) {}