Finish CScanDisplay

This commit is contained in:
Jack Andersen 2017-05-16 19:04:38 -10:00
parent 5835e5173e
commit 08a8b1819a
12 changed files with 547 additions and 126 deletions

View File

@ -93,7 +93,10 @@ struct ITweakGui : ITweak
virtual float GetHudDamageColorGain() const=0;
virtual float GetHudDecoShakeTranslateGain() const=0;
virtual float GetHudLagOffsetScale() const=0;
virtual float GetScanAppearanceOffset() const=0;
virtual float GetScanAppearanceDuration() const=0;
virtual float GetScanPaneFadeAlpha() const=0;
virtual float GetScanPaneFadeInTime() const=0;
virtual float GetScanPaneFadeOutTime() const=0;
virtual float GetBallViewportYReduction() const=0;
virtual float GetScanSpeed(int idx) const=0;
virtual float GetXrayBlurScaleLinear() const=0;
@ -104,6 +107,12 @@ struct ITweakGui : ITweak
virtual float GetScanSidesDuration() const=0;
virtual float GetScanSidesStartTime() const=0;
virtual float GetScanSidesEndTime() const=0;
virtual float GetScanDataDotRadius() const=0;
virtual float GetScanDataDotPosRandMagnitude() const=0;
virtual float GetScanDataDotDuration1Min() const=0;
virtual float GetScanDataDotDuration1Max() const=0;
virtual float GetScanDataDotDuration2Min() const=0;
virtual float GetScanDataDotDuration2Max() const=0;
virtual float GetScanSidesPositionStart() const=0;
virtual bool GetLatchArticleText() const=0;
virtual float GetWorldTransManagerCharsPerSfx() const=0;

View File

@ -67,6 +67,7 @@ struct ITweakGuiColors : BigYAML
virtual const zeus::CColor& GetDamageAmbientPulseColor() const=0;
virtual const zeus::CColor& GetEnergyBarFlashColor() const=0;
virtual const zeus::CColor& GetXRayEnergyDecoColor() const=0;
virtual const zeus::CColor& GetScanDataDotColor() const=0;
virtual const zeus::CColor& GetPowerBombDigitAvailableFont() const=0;
virtual const zeus::CColor& GetPowerBombDigitAvailableOutline() const=0;
virtual const zeus::CColor& GetBallBombFilledColor() const=0;
@ -77,6 +78,7 @@ struct ITweakGuiColors : BigYAML
virtual const zeus::CColor& GetPowerBombDigitDelpetedFont() const=0;
virtual const zeus::CColor& GetPowerBombDigitDelpetedOutline() const=0;
virtual const zeus::CColor& GetPowerBombIconDepletedColor() const=0;
virtual const zeus::CColor& GetScanDisplayImagePaneColor() const=0;
virtual const zeus::CColor& GetThreatIconWarningColor() const=0;
virtual const zeus::CColor& GetHudCounterFill() const=0;
virtual const zeus::CColor& GetHudCounterOutline() const=0;

View File

@ -130,16 +130,16 @@ struct CTweakGui : ITweakGui
Value<float> x220_scanSidesDuration;
Value<float> x224_scanSidesStartTime;
float x228_scanSidesEndTime;
Value<float> x22c_;
Value<float> x230_;
Value<float> x234_;
Value<float> x238_;
Value<float> x23c_;
Value<float> x240_;
Value<float> x244_scanAppearanceOffset;
Value<float> x248_;
Value<float> x24c_;
Value<float> x250_;
Value<float> x22c_scanDataDotRadius;
Value<float> x230_scanDataDotPosRandMag;
Value<float> x234_scanDataDotDuration1Min;
Value<float> x238_scanDataDotDuration1Max;
Value<float> x23c_scanDataDotDuration2Min;
Value<float> x240_scanDataDotDuration2Max;
Value<float> x244_scanAppearanceDuration;
Value<float> x248_scanPaneFadeAlpha;
Value<float> x24c_scanPaneFadeInTime;
Value<float> x250_scanPaneFadeOutTime;
Value<float> x254_ballViewportYReduction;
Value<float> x258_;
Value<float> x25c_;
@ -255,7 +255,10 @@ struct CTweakGui : ITweakGui
float GetHudDamageColorGain() const { return x1d4_hudDamageColorGain; }
float GetHudDecoShakeTranslateGain() const { return x1d8_hudDecoShakeTranslateGain; }
float GetHudLagOffsetScale() const { return x1dc_hudLagOffsetScale; }
float GetScanAppearanceOffset() const { return x244_scanAppearanceOffset; }
float GetScanAppearanceDuration() const { return x244_scanAppearanceDuration; }
float GetScanPaneFadeAlpha() const { return x248_scanPaneFadeAlpha; }
float GetScanPaneFadeInTime() const { return x24c_scanPaneFadeInTime; }
float GetScanPaneFadeOutTime() const { return x250_scanPaneFadeOutTime; }
float GetBallViewportYReduction() const { return x254_ballViewportYReduction; }
float GetXrayBlurScaleLinear() const { return x204_xrayBlurScaleLinear; }
float GetXrayBlurScaleQuadratic() const { return x208_xrayBlurScaleQuadratic; }
@ -265,6 +268,12 @@ struct CTweakGui : ITweakGui
float GetScanSidesDuration() const { return x220_scanSidesDuration; }
float GetScanSidesStartTime() const { return x224_scanSidesStartTime; }
float GetScanSidesEndTime() const { return x228_scanSidesEndTime; }
float GetScanDataDotRadius() const { return x22c_scanDataDotRadius; }
float GetScanDataDotPosRandMagnitude() const { return x230_scanDataDotPosRandMag; }
float GetScanDataDotDuration1Min() const { return x234_scanDataDotDuration1Min; }
float GetScanDataDotDuration1Max() const { return x238_scanDataDotDuration1Max; }
float GetScanDataDotDuration2Min() const { return x23c_scanDataDotDuration2Min; }
float GetScanDataDotDuration2Max() const { return x240_scanDataDotDuration2Max; }
float GetScanSidesPositionStart() const { return x270_scanSidesPositionStart; }
bool GetLatchArticleText() const { return x275_latchArticleText; }
float GetWorldTransManagerCharsPerSfx() const { return x278_wtMgrCharsPerSfx; }

View File

@ -87,7 +87,7 @@ struct CTweakGuiColors : public ITweakGuiColors
DNAColor x12c_;
DNAColor x130_;
DNAColor x134_;
DNAColor x138_;
DNAColor x138_scanDataDotColor;
DNAColor x13c_powerBombDigitAvailableFont;
DNAColor x140_powerBombDigitAvailableOutline;
DNAColor x144_;
@ -102,7 +102,7 @@ struct CTweakGuiColors : public ITweakGuiColors
DNAColor x168_powerBombIconUnavailable;
DNAColor x16c_;
DNAColor x170_;
DNAColor x174_;
DNAColor x174_scanDisplayImagePaneColor;
DNAColor x178_;
DNAColor x17c_threatIconWarningColor;
DNAColor x180_hudCounterFill;
@ -185,6 +185,7 @@ struct CTweakGuiColors : public ITweakGuiColors
const zeus::CColor& GetDamageAmbientPulseColor() const { return xe4_damageAmbientPulseColor; }
const zeus::CColor& GetEnergyBarFlashColor() const { return xe8_energyBarFlashColor; }
const zeus::CColor& GetXRayEnergyDecoColor() const { return x100_xrayEnergyDecoColor; }
const zeus::CColor& GetScanDataDotColor() const { return x138_scanDataDotColor; }
const zeus::CColor& GetPowerBombDigitAvailableFont() const { return x13c_powerBombDigitAvailableFont; }
const zeus::CColor& GetPowerBombDigitAvailableOutline() const { return x140_powerBombDigitAvailableOutline; }
const zeus::CColor& GetBallBombFilledColor() const { return x148_ballBombFilled; }
@ -195,6 +196,7 @@ struct CTweakGuiColors : public ITweakGuiColors
const zeus::CColor& GetPowerBombDigitDelpetedFont() const { return x160_powerBombDigitDepletedFont; }
const zeus::CColor& GetPowerBombDigitDelpetedOutline() const { return x164_powerBombDigitDepletedOutline; }
const zeus::CColor& GetPowerBombIconDepletedColor() const { return x168_powerBombIconUnavailable; }
const zeus::CColor& GetScanDisplayImagePaneColor() const { return x174_scanDisplayImagePaneColor; }
const zeus::CColor& GetThreatIconWarningColor() const { return x17c_threatIconWarningColor; }
const zeus::CColor& GetHudCounterFill() const { return x180_hudCounterFill; }
const zeus::CColor& GetHudCounterOutline() const { return x184_hudCounterOutline; }

View File

@ -8,7 +8,7 @@ CScannableObjectInfo::CScannableObjectInfo(CInputStream& in, ResId resId) : x0_s
u32 version = in.readUint32Big();
Load(in, version);
float appearanceOffset = g_tweakGui->GetScanAppearanceOffset();
float appearanceOffset = g_tweakGui->GetScanAppearanceDuration();
for (u32 i = 0 ; i < x14_buckets.size(); ++i)
{
if (x14_buckets[i].x8_imagePos != -1)
@ -29,14 +29,6 @@ CScannableObjectInfo::CScannableObjectInfo(CInputStream& in, ResId resId) : x0_s
}
}
ResId CScannableObjectInfo::GetScannableObjectId() const { return x0_scannableObjectId; }
ResId CScannableObjectInfo::GetStringTableId() const { return x4_stringId; }
float CScannableObjectInfo::GetTotalDownloadTime() const { return x8_totalDownloadTime; }
const CScannableObjectInfo::SBucket& CScannableObjectInfo::GetBucket(s32 idx) const { return x14_buckets[idx]; }
void CScannableObjectInfo::Load(CInputStream& in, u32 version)
{
in.readUint32Big();

View File

@ -37,11 +37,12 @@ private:
public:
CScannableObjectInfo(CInputStream&, ResId);
ResId GetStringTableId() const;
ResId GetScannableObjectId() const;
float GetTotalDownloadTime() const;
const SBucket& GetBucket(s32) const;
bool IsImportant() const;
ResId GetScannableObjectId() const { return x0_scannableObjectId; }
ResId GetStringTableId() const { return x4_stringId; }
float GetTotalDownloadTime() const { return x8_totalDownloadTime; }
const SBucket& GetBucket(s32 idx) const { return x14_buckets[idx]; }
u32 GetCategory() const { return xc_category; }
bool IsImportant() const { return x10_important; }
};
CFactoryFnReturn FScannableObjectInfoFactory(const SObjectTag&, CInputStream&, const CVParamTransfer&,

View File

@ -22,8 +22,8 @@ class CAuiImagePane : public CGuiWidget
float x140_interval = 0.f;
float x144_ = 0.f;
float x148_duration = 0.f;
float x14c_invAlpha = 0.f;
float x150_interp = 0.f;
float x14c_deResFactor = 0.f;
float x150_alpha = 0.f;
public:
CAuiImagePane(const CGuiWidgetParms& parms, CSimplePool* sp, ResId, ResId,
rstl::reserved_vector<zeus::CVector3f, 4>&& coords,
@ -33,8 +33,8 @@ public:
void SetTextureID0(ResId tex, CSimplePool* sp);
void SetAnimationParms(const zeus::CVector2f& vec, float interval, float duration);
void SetInverseAlpha(float a) { x14c_invAlpha = a; }
void ResetInterp() { x150_interp = 0.f; }
void SetDeResFactor(float d) { x14c_deResFactor = d; }
void SetAlpha(float t) { x150_alpha = t; }
};
}

View File

@ -99,7 +99,7 @@ void CHudDecoInterfaceCombat::UpdateHudAlpha()
}
CHudDecoInterfaceScan::CHudDecoInterfaceScan(CGuiFrame& selHud)
: x14_selHud(selHud)
: x14_selHud(selHud), x18_scanDisplay(selHud)
{
x4_scanHudFlat = g_SimplePool->GetObj("FRME_ScanHudFlat");
x234_sidesPositioner = g_tweakGui->GetScanSidesPositionStart();
@ -287,10 +287,10 @@ void CHudDecoInterfaceScan::UpdateScanDisplay(const CStateManager& stateMgr, flo
}
const CScannableObjectInfo* scanInfo = GetCurrScanInfo(stateMgr);
if (x1d2_latestScanningObject != x18_scanDisplay.x10_ || !scanInfo)
if (x1d2_latestScanningObject != x18_scanDisplay.x10_objId || !scanInfo)
{
x18_scanDisplay.StopScan();
if (!x18_scanDisplay.xc_ && scanInfo)
if (x18_scanDisplay.xc_state == CScanDisplay::EScanState::Inactive && scanInfo)
{
x18_scanDisplay.StartScan(x1d2_latestScanningObject, *scanInfo, x264_flat_textpane_message,
x268_flat_textpane_scrollmessage, x260_flat_basewidget_textgroup,
@ -409,7 +409,7 @@ void CHudDecoInterfaceScan::UpdateHudAlpha()
float CHudDecoInterfaceScan::GetHudTextAlpha() const
{
return 1.f - std::max(std::min(x238_scanningTextAlpha, 1.f), x18_scanDisplay.x1a8_);
return 1.f - std::max(std::min(x238_scanningTextAlpha, 1.f), x18_scanDisplay.x1a8_bodyAlpha);
}
CHudDecoInterfaceXRay::CHudDecoInterfaceXRay(CGuiFrame& selHud)

View File

@ -1,116 +1,493 @@
#include "CScanDisplay.hpp"
#include "zeus/CTransform.hpp"
#include "Graphics/CGraphics.hpp"
#include "GameGlobalObjects.hpp"
#include "CSimplePool.hpp"
#include "GuiSys/CGuiWidget.hpp"
#include "GuiSys/CGuiTextPane.hpp"
#include "GuiSys/CGuiModel.hpp"
#include "GuiSys/CAuiImagePane.hpp"
#include "GuiSys/CGuiCamera.hpp"
#include "MP1/CPauseScreenBase.hpp"
#include "CStringTable.hpp"
#include "Audio/CSfxManager.hpp"
#include "Input/CFinalInput.hpp"
#include "Graphics/CBooRenderer.hpp"
namespace urde
{
void CScanDisplay::CDataDot::Update(float dt)
{
if (x20_ > 0.f)
if (x20_remTime > 0.f)
{
float diff = x20_ - dt;
if (diff < 0.f)
x20_ = 0.f;
else
x20_ = diff;
float d = x20_ / x1c_;
xc_ = (x14_ * (x4_ * d)) + (1.f - x1c_ > 0.f ? d : 0.f);
x20_remTime = std::max(0.f, x20_remTime - dt);
float d = x20_remTime / x1c_transDur;
xc_curPos = (x14_targetPos * (x4_startPos * d)) + (1.f - x1c_transDur > 0.f ? d : 0.f);
}
if (x24_ > x28_)
if (x24_alpha > x28_desiredAlpha)
{
float tmp = -((2.0f * x24_) - dt);
x24_ = (tmp >= x28_ ? x28_ : tmp);
float tmp = x24_alpha - 2.f * dt;
x24_alpha = std::max(tmp, x28_desiredAlpha);
}
else if (x24_ < x28_)
else if (x24_alpha < x28_desiredAlpha)
{
float tmp = (2.0 * x24_) + x28_;
x24_ = (tmp >= x28_ ? x28_ : tmp);
float tmp = 2.0 * dt + x24_alpha;
x24_alpha = std::min(tmp, x28_desiredAlpha);
}
}
void CScanDisplay::CDataDot::Draw(const zeus::CColor& col, float f1) const
void CScanDisplay::CDataDot::Draw(const zeus::CColor& col, float radius) const
{
if (x24_ == 0.f)
if (x24_alpha == 0.f)
return;
if (x0_ == EDotState::One)
if (x0_dotState != EDotState::Hidden)
{
zeus::CTransform xf = zeus::CTransform::Translate(xc_.x, 0.f, xc_.y);
#if 0
g_Renderer->SetModelMatrix(xf);
CGraphics::StreamBegin(ERglPrimitive::TriangleStrip);
zeus::Comp8 r, g, b, a;
col.toRGBA8(r, g, b, a);
CGraphics::StreamColor({col.r, col.g, col.b, x24_ * float(a)});
CGraphics::StreamTexCoord(0.f, 1.f);
CGraphics::StreamVertex(zeus::CVector3f{-f1, 0, f1});
CGraphics::StreamTexCoord(0.f, 0.f);
CGraphics::StreamVertex(zeus::CVector3f{-f1, 0, -f1});
CGraphics::StreamTexCoord(1.f, 1.f);
CGraphics::StreamVertex(zeus::CVector3f{f1, 0, f1});
CGraphics::StreamTexCoord(1.f, 0.f);
CGraphics::StreamVertex(zeus::CVector3f{f1, 0, -f1});
CGraphics::StreamEnd();
#endif
zeus::CTransform xf = zeus::CTransform::Translate(xc_curPos.x, 0.f, xc_curPos.y);
CGraphics::SetModelMatrix(xf);
zeus::CColor useColor = col;
useColor.a *= x24_alpha;
CTexturedQuadFilter::Vert verts[4] =
{
{{-radius, 0.f, radius}, {0.f, 1.f}},
{{-radius, 0.f, -radius}, {0.f, 0.f}},
{{radius, 0.f, radius}, {1.f, 1.f}},
{{radius, 0.f, -radius}, {1.f, 0.f}}
};
const_cast<CTexturedQuadFilter&>(m_quad).drawVerts(useColor, verts);
}
}
void CScanDisplay::CDataDot::StartTransitionTo(const zeus::CVector2f& vec, float f1)
void CScanDisplay::CDataDot::StartTransitionTo(const zeus::CVector2f& vec, float dur)
{
x20_ = f1;
x1c_ = f1;
x4_ = xc_;
x14_ = vec;
x20_remTime = dur;
x1c_transDur = dur;
x4_startPos = xc_curPos;
x14_targetPos = vec;
}
void CScanDisplay::CDataDot::SetDestPosition(const zeus::CVector2f& pos)
{
if (x20_ <= 0.f)
xc_ = pos;
if (x20_remTime <= 0.f)
xc_curPos = pos;
else
x14_ = pos;
x14_targetPos = pos;
}
CScanDisplay::CScanDisplay(const CGuiFrame& selHud)
: xa0_selHud(selHud)
{
x0_dataDot = g_SimplePool->GetObj("TXTR_DataDot");
}
void CScanDisplay::ProcessInput(const CFinalInput& input)
{
if (xc_state == EScanState::Inactive || xc_state == EScanState::Done)
return;
if (xc_state == EScanState::DownloadComplete && x1a4_xAlpha == 0.f)
{
if (input.PA())
{
if (xa8_message->TextSupport()->GetCurTime() < xa8_message->TextSupport()->GetTotalAnimationTime())
{
xa8_message->TextSupport()->SetCurTime(xa8_message->TextSupport()->GetTotalAnimationTime());
}
else
{
xc_state = EScanState::ViewingScan;
CSfxManager::SfxStart(1439, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
}
}
}
else if (xc_state == EScanState::ViewingScan)
{
int oldCounter = x1ac_pageCounter;
int totalPages = xac_scrollMessage->TextSupport()->GetTotalPageCount();
if (input.PA() && totalPages != -1)
{
CGuiTextSupport* supp = !x1ac_pageCounter ? xa8_message->TextSupport() : xac_scrollMessage->TextSupport();
if (supp->GetCurTime() < supp->GetTotalAnimationTime())
{
supp->SetCurTime(supp->GetTotalAnimationTime());
}
else
{
x1ac_pageCounter = std::min(totalPages, x1ac_pageCounter + 1);
}
}
if (x1ac_pageCounter != oldCounter)
{
CSfxManager::SfxStart(1439, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
if (x1ac_pageCounter == 0)
{
xa8_message->SetIsVisible(true);
xac_scrollMessage->SetIsVisible(false);
}
else
{
if (oldCounter == 0)
{
xa8_message->SetIsVisible(false);
xac_scrollMessage->SetIsVisible(true);
}
xac_scrollMessage->TextSupport()->SetPage(x1ac_pageCounter - 1);
SetScanMessageTypeEffect(xac_scrollMessage, !x1b4_scanComplete);
}
}
}
float xAlpha = 0.f;
float aAlpha = 0.f;
float dashAlpha = 0.f;
if (xc_state == EScanState::DownloadComplete)
{
xAlpha = std::min(2.f * x1a4_xAlpha, 1.f);
aAlpha = (1.f - xAlpha) * std::fabs(x1b0_aPulse);
}
else if (xc_state == EScanState::ViewingScan)
{
if (x1ac_pageCounter < xac_scrollMessage->TextSupport()->GetTotalPageCount())
aAlpha = std::fabs(x1b0_aPulse);
else
dashAlpha = 1.f;
}
xb0_xmark->SetVisibility(xAlpha > 0.f, ETraversalMode::Children);
xb4_abutton->SetVisibility(aAlpha > 0.f, ETraversalMode::Children);
xb8_dash->SetVisibility(dashAlpha > 0.f, ETraversalMode::Children);
xb0_xmark->SetColor(zeus::CColor(1.f, xAlpha));
xb4_abutton->SetColor(zeus::CColor(1.f, aAlpha));
xb8_dash->SetColor(zeus::CColor(0.53f, 0.84f, 1.f, dashAlpha));
}
float CScanDisplay::GetDownloadStartTime(int idx) const
{
if (!x14_scannableInfo)
return 0.f;
float nTime = x14_scannableInfo->GetBucket(idx).x4_appearanceRange;
float maxTime = 0.f;
for (int i=0 ; i<4 ; ++i)
{
float iTime = x14_scannableInfo->GetBucket(i).x4_appearanceRange;
if (iTime < nTime)
maxTime = std::max(iTime, maxTime);
}
return maxTime + g_tweakGui->GetScanAppearanceDuration();
}
float CScanDisplay::GetDownloadFraction(int idx, float scanningTime) const
{
if (!x14_scannableInfo)
return 0.f;
float appearTime = GetDownloadStartTime(idx);
float appearRange = x14_scannableInfo->GetBucket(idx).x4_appearanceRange;
if (appearTime == appearRange)
return 1.f;
return zeus::clamp(0.f, (scanningTime - appearTime) / (appearRange - appearTime), 1.f);
}
void CScanDisplay::StartScan(TUniqueId id, const CScannableObjectInfo& scanInfo, CGuiTextPane* message,
CGuiTextPane* scrollMessage, CGuiWidget* textGroup, CGuiModel* xmark,
CGuiModel* abutton, CGuiModel* dash, float scanTime)
{
x1b4_scanComplete = scanTime >= scanInfo.GetTotalDownloadTime();
x14_scannableInfo.emplace(scanInfo);
x10_objId = id;
xc_state = EScanState::Downloading;
x1ac_pageCounter = 0;
x1a4_xAlpha = 0.f;
xa8_message = message;
xac_scrollMessage = scrollMessage;
xa4_textGroup = textGroup;
xb0_xmark = xmark;
xb4_abutton = abutton;
xb8_dash = dash;
xa4_textGroup->SetVisibility(true, ETraversalMode::Children);
xa4_textGroup->SetColor(zeus::CColor(1.f, 0.f));
for (int i=0 ; i<20 ; ++i)
{
CAuiImagePane* pane = static_cast<CAuiImagePane*>(
xa0_selHud.FindWidget(MP1::CPauseScreenBase::GetImagePaneName(i)));
zeus::CColor color = g_tweakGuiColors->GetScanDisplayImagePaneColor();
color.a = 0.f;
pane->SetColor(color);
pane->SetTextureID0(-1, g_SimplePool);
pane->SetAnimationParms(zeus::CVector2f::skZero, 0.f, 0.f);
int pos = -1;
for (int j=0 ; j<4 ; ++j)
{
if (x14_scannableInfo->GetBucket(j).x8_imagePos == i)
{
pos = j;
break;
}
}
if (pos >= 0)
x170_paneStates[pos].second = pane;
}
for (int i=0 ; i<x170_paneStates.size() ; ++i)
{
std::pair<float, CAuiImagePane*>& state = x170_paneStates[i];
if (state.second)
{
const CScannableObjectInfo::SBucket& bucket = x14_scannableInfo->GetBucket(i);
if (bucket.x14_interval > 0.f)
{
state.second->SetAnimationParms(zeus::CVector2f(bucket.xc_size.x, bucket.xc_size.y),
bucket.x14_interval, bucket.x18_fadeDuration);
}
state.second->SetTextureID0(bucket.x0_texture, g_SimplePool);
state.second->SetAlpha(0.f);
if (scanTime >= GetDownloadStartTime(i))
x170_paneStates[i].first = 0.f;
else
x170_paneStates[i].first = -1.f;
}
}
ResId strId = x14_scannableInfo->GetStringTableId();
if (strId != -1)
x194_scanStr = g_SimplePool->GetObj({FOURCC('STRG'), strId});
for (int i=0 ; i<4 ; ++i)
{
int pos = x14_scannableInfo->GetBucket(i).x8_imagePos;
CDataDot& dot = xbc_dataDots[i];
if (pos != -1)
{
if (GetDownloadStartTime(i) - g_tweakGui->GetScanAppearanceDuration() < scanTime)
{
dot.SetAlpha(0.f);
dot.SetDotState(CDataDot::EDotState::Done);
}
else
{
dot.SetDesiredAlpha(1.f);
dot.SetDotState(CDataDot::EDotState::Seek);
dot.StartTransitionTo(zeus::CVector2f::skZero, FLT_EPSILON);
dot.Update(FLT_EPSILON);
}
}
else
{
dot.SetDotState(CDataDot::EDotState::Hidden);
}
}
}
void CScanDisplay::StopScan()
{
if (xc_state == EScanState::Done || xc_state == EScanState::Inactive)
return;
xc_state = EScanState::Done;
for (int i=0 ; i<4 ; ++i)
xbc_dataDots[i].SetDesiredAlpha(0.f);
}
void CScanDisplay::InitializeFrame(float)
void CScanDisplay::SetScanMessageTypeEffect(CGuiTextPane* pane, bool type)
{
if (type)
pane->TextSupport()->SetTypeWriteEffectOptions(true, 0.1f, 60.f);
else
pane->TextSupport()->SetTypeWriteEffectOptions(false, 0.f, 0.f);
}
void CScanDisplay::Update(float, float)
void CScanDisplay::Update(float dt, float scanningTime)
{
if (xc_state == EScanState::Inactive)
{
x0_dataDot.Unlock();
return;
}
void CScanDisplay::SetBackgroundBucketOccluded(s32, float)
{
x0_dataDot.Lock();
bool active = false;
if (xc_state == EScanState::Done)
{
x1a8_bodyAlpha = std::max(0.f, x1a8_bodyAlpha - 2.f * dt);
if (x1a8_bodyAlpha > 0.f)
active = true;
}
else
{
active = true;
x1a8_bodyAlpha = std::min(x1a8_bodyAlpha + 2.f * dt, 1.f);
if (xc_state == EScanState::DownloadComplete)
{
if (xac_scrollMessage->TextSupport()->GetIsTextSupportFinishedLoading())
x1a4_xAlpha = std::max(0.f, x1a4_xAlpha - dt);
if (x1a4_xAlpha < 0.5f)
{
x1b0_aPulse += 2.f * dt;
if (x1b0_aPulse > 1.f)
x1b0_aPulse -= 2.f;
}
}
else if (xc_state == EScanState::ViewingScan)
{
x1b0_aPulse += 2.f * dt;
if (x1b0_aPulse > 1.f)
x1b0_aPulse -= 2.f;
if (x1a4_xAlpha == 1.f)
{
xa8_message->TextSupport()->SetText(x194_scanStr->GetString(0));
SetScanMessageTypeEffect(xa8_message, !x1b4_scanComplete);
}
}
else if (xc_state == EScanState::Downloading && scanningTime >= x14_scannableInfo->GetTotalDownloadTime() &&
x194_scanStr.IsLoaded())
{
if (x1b4_scanComplete || x14_scannableInfo->GetCategory() == 0)
{
xc_state = EScanState::ViewingScan;
CSfxManager::SfxStart(1417, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
}
else
{
xa8_message->TextSupport()->SetText(std::u16string(g_MainStringTable->GetString(29)) +
g_MainStringTable->GetString(x14_scannableInfo->GetCategory() + 30) +
g_MainStringTable->GetString(30));
SetScanMessageTypeEffect(xa8_message, true);
CSfxManager::SfxStart(1425, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
}
bool CScanDisplay::PanelCoversBucketBackground(CScannableObjectInfo::EPanelType, s32)
if (x194_scanStr->GetStringCount() > 2)
{
return false;
xac_scrollMessage->TextSupport()->SetText(x194_scanStr->GetString(2), true);
SetScanMessageTypeEffect(xac_scrollMessage, !x1b4_scanComplete);
}
xac_scrollMessage->SetIsVisible(false);
}
}
for (int i=0 ; i<4 ; ++i)
{
if (x170_paneStates[i].second == 0)
continue;
if (x170_paneStates[i].first > 0.f)
{
x170_paneStates[i].first = std::max(0.f, x170_paneStates[i].first - dt);
float tmp;
if (x170_paneStates[i].first > g_tweakGui->GetScanPaneFadeOutTime())
tmp = 1.f - (x170_paneStates[i].first - g_tweakGui->GetScanPaneFadeOutTime()) / g_tweakGui->GetScanPaneFadeInTime();
else
tmp = x170_paneStates[i].first / g_tweakGui->GetScanPaneFadeOutTime();
x170_paneStates[i].second->SetAlpha(tmp * g_tweakGui->GetScanPaneFadeAlpha() * x1a8_bodyAlpha);
}
float alphaMul = ((xc_state == EScanState::Downloading) ? GetDownloadFraction(i, scanningTime) : 1.f) * x1a8_bodyAlpha;
zeus::CColor color = g_tweakGuiColors->GetScanDisplayImagePaneColor();
color.a *= alphaMul;
x170_paneStates[i].second->SetColor(color);
x170_paneStates[i].second->SetDeResFactor(1.f - alphaMul);
if (GetDownloadStartTime(i) - g_tweakGui->GetScanAppearanceDuration() < scanningTime)
{
CDataDot& dot = xbc_dataDots[i];
switch (dot.GetDotState())
{
case CDataDot::EDotState::Seek:
case CDataDot::EDotState::Hold:
dot.SetDotState(CDataDot::EDotState::RevealPane);
dot.StartTransitionTo(zeus::CVector2f::skZero, g_tweakGui->GetScanAppearanceDuration());
break;
case CDataDot::EDotState::RevealPane:
{
float tmp = dot.GetTransitionFactor();
if (tmp == 0.f)
{
dot.SetDotState(CDataDot::EDotState::Done);
CSfxManager::SfxStart(1414, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
x170_paneStates[i].first = g_tweakGui->GetScanPaneFadeOutTime() + g_tweakGui->GetScanPaneFadeInTime();
}
break;
}
default: break;
}
}
}
for (int i=0 ; i<4 ; ++i)
{
CDataDot& dot = xbc_dataDots[i];
switch (dot.GetDotState())
{
case CDataDot::EDotState::Hidden:
continue;
case CDataDot::EDotState::Seek:
case CDataDot::EDotState::Hold:
{
float tmp = dot.GetTransitionFactor();
if (tmp == 0.f)
{
float posRand = g_tweakGui->GetScanDataDotPosRandMagnitude();
float durMin = dot.GetDotState() == CDataDot::EDotState::Hold ? g_tweakGui->GetScanDataDotDuration2Min() : g_tweakGui->GetScanDataDotDuration1Min();
float durMax = dot.GetDotState() == CDataDot::EDotState::Hold ? g_tweakGui->GetScanDataDotDuration2Max() : g_tweakGui->GetScanDataDotDuration1Max();
zeus::CVector2f vec(dot.GetDotState() == CDataDot::EDotState::Hold ? dot.GetCurrPosition().x : (posRand * (rand() / float(RAND_MAX)) - 0.5f * posRand),
dot.GetDotState() == CDataDot::EDotState::Hold ? dot.GetCurrPosition().y : (posRand * (rand() / float(RAND_MAX)) - 0.5f * posRand));
dot.StartTransitionTo(vec, (durMax - durMin) * (rand() / float(RAND_MAX)) + durMin);
dot.SetDotState(dot.GetDotState() == CDataDot::EDotState::Hold ? CDataDot::EDotState::Seek : CDataDot::EDotState::Hold);
}
break;
}
case CDataDot::EDotState::RevealPane:
case CDataDot::EDotState::Done:
{
zeus::CVector3f screenPos = xa0_selHud.GetFrameCamera()->ConvertToScreenSpace(x170_paneStates[i].second->GetWorldPosition());
zeus::CVector2f viewportCoords(screenPos.x * g_Viewport.x8_width * 0.5f,
screenPos.y * g_Viewport.xc_height * 0.5f);
dot.SetDestPosition(viewportCoords);
break;
}
default: break;
}
dot.Update(dt);
}
if (!active)
{
xc_state = EScanState::Inactive;
x10_objId = kInvalidUniqueId;
x14_scannableInfo = std::experimental::nullopt;
xa8_message->TextSupport()->SetText(u"");
xac_scrollMessage->TextSupport()->SetText(u"");
xa4_textGroup->SetVisibility(false, ETraversalMode::Children);
xb0_xmark->SetVisibility(false, ETraversalMode::Children);
xb4_abutton->SetVisibility(false, ETraversalMode::Children);
xb8_dash->SetVisibility(false, ETraversalMode::Children);
xa8_message = nullptr;
xac_scrollMessage = nullptr;
xa4_textGroup = nullptr;
xb0_xmark = nullptr;
xb4_abutton = nullptr;
xb8_dash = nullptr;
x170_paneStates.clear();
x170_paneStates.resize(4);
x194_scanStr = TLockedToken<CStringTable>();
x1ac_pageCounter = 0;
x1b4_scanComplete = false;
}
else
{
xa4_textGroup->SetColor(zeus::CColor(1.f, x1a8_bodyAlpha));
}
}
void CScanDisplay::Draw() const
{
if (!x0_dataDot.IsLoaded())
return;
// No Z-test or write
g_Renderer->SetViewportOrtho(true, -4096.f, 4096.f);
// Additive alpha
for (const CDataDot& dot : xbc_dataDots)
dot.Draw(g_tweakGuiColors->GetScanDataDotColor(), g_tweakGui->GetScanDataDotRadius());
}
}

View File

@ -7,6 +7,7 @@
#include "zeus/CQuaternion.hpp"
#include "CScannableObjectInfo.hpp"
#include "Graphics/CTexture.hpp"
#include "Graphics/Shaders/CTexturedQuadFilter.hpp"
namespace urde
{
@ -14,6 +15,10 @@ class CGuiTextPane;
class CGuiWidget;
class CGuiModel;
class CFinalInput;
class CGuiFrame;
class CAuiImagePane;
class CStringTable;
class CScanDisplay
{
friend class CHudDecoInterfaceScan;
@ -23,60 +28,83 @@ public:
public:
enum class EDotState
{
Zero,
One
Hidden,
Seek,
Hold,
RevealPane,
Done
};
private:
EDotState x0_ = EDotState::Zero;
zeus::CVector2f x4_;
zeus::CVector2f xc_;
zeus::CVector2f x14_;
float x1c_ = 0.f;
float x20_ = 0.f;
float x24_ = 0.f;
float x28_ = 0.f;
EDotState x0_dotState = EDotState::Hidden;
zeus::CVector2f x4_startPos;
zeus::CVector2f xc_curPos;
zeus::CVector2f x14_targetPos;
float x1c_transDur = 0.f;
float x20_remTime = 0.f;
float x24_alpha = 0.f;
float x28_desiredAlpha = 0.f;
CTexturedQuadFilter m_quad;
public:
CDataDot() = default;
void Update(float);
void Draw(const zeus::CColor&, float) const;
float GetTransitionFactor() const;
CDataDot(const TLockedToken<CTexture>& dataDotTex)
: m_quad(CCameraFilterPass::EFilterType::Add, dataDotTex) {}
void Update(float dt);
void Draw(const zeus::CColor& color, float radius) const;
float GetTransitionFactor() const { return x1c_transDur > 0.f ? x20_remTime / x1c_transDur : 0.f; }
void StartTransitionTo(const zeus::CVector2f&, float);
void SetDestPosition(const zeus::CVector2f&);
void SetDesiredAlpha(float);
void SetDotState(EDotState);
void SetAlpha(float);
zeus::CVector2f GetCurrPosition() const;
EDotState GetDotState() const;
void SetDesiredAlpha(float a) { x28_desiredAlpha = a; }
void SetDotState(EDotState s) { x0_dotState = s; }
void SetAlpha(float a) { x24_alpha = a; }
const zeus::CVector2f& GetCurrPosition() const { return xc_curPos; }
EDotState GetDotState() const { return x0_dotState; }
};
struct SBucketBackground
enum class EScanState
{
Inactive,
Downloading,
DownloadComplete,
ViewingScan,
Done
};
private:
u32 xc_;
TUniqueId x10_;
float x1a8_;
TLockedToken<CTexture> x0_dataDot;
EScanState xc_state = EScanState::Inactive;
TUniqueId x10_objId = kInvalidUniqueId;
std::experimental::optional<CScannableObjectInfo> x14_scannableInfo;
const CGuiFrame& xa0_selHud;
CGuiWidget* xa4_textGroup = nullptr;
CGuiTextPane* xa8_message = nullptr;
CGuiTextPane* xac_scrollMessage = nullptr;
CGuiModel* xb0_xmark = nullptr;
CGuiModel* xb4_abutton = nullptr;
CGuiModel* xb8_dash = nullptr;
rstl::reserved_vector<CDataDot, 4> xbc_dataDots;
rstl::reserved_vector<std::pair<float, CAuiImagePane*>, 4> x170_paneStates;
TLockedToken<CStringTable> x194_scanStr; // Used to be optional
float x1a4_xAlpha = 0.f;
float x1a8_bodyAlpha = 0.f;
int x1ac_pageCounter = 0;
float x1b0_aPulse = 1.f;
bool x1b4_scanComplete = false;
float GetDownloadStartTime(int idx) const;
float GetDownloadFraction(int idx, float scanningTime) const;
static void SetScanMessageTypeEffect(CGuiTextPane* pane, bool type);
public:
CScanDisplay() = default;
CScanDisplay(const CGuiFrame& selHud);
void ProcessInput(const CFinalInput& input);
void StartScan(TUniqueId id, const CScannableObjectInfo& scanInfo, CGuiTextPane* message,
CGuiTextPane* scrollMessage, CGuiWidget* textGroup, CGuiModel* xmark,
CGuiModel* abutton, CGuiModel* dash, float scanTime);
void StopScan();
void InitializeFrame(float);
void Update(float, float);
void SetBackgroundBucketOccluded(s32, float);
bool PanelCoversBucketBackground(CScannableObjectInfo::EPanelType, s32);
void Update(float dt, float scanningTime);
void Draw() const;
void SetBaseOrientation(const zeus::CQuaternion&);
void SetDebugCameraOptions(float, float, float);
void SetPanelTranslationX(float);
void GetDownloadStartTime(s32) const;
void GetDownloadFraction(s32, float) const;
void GetScanState() const;
void ScanTarget() const;
EScanState GetScanState() const { return xc_state; }
TUniqueId ScanTarget() const { return x10_objId; }
};
}
#endif // __URDE_CSCANDISPLAY_HPP__

View File

@ -244,7 +244,7 @@ void CLogBookScreen::UpdateBodyImagesAndText()
bucket.x14_interval, bucket.x18_fadeDuration);
}
pane->SetTextureID0(bucket.x0_texture, g_SimplePool);
pane->ResetInterp();
pane->SetAlpha(0.f);
}
x260_26_exitTextScroll = false;
@ -327,7 +327,7 @@ void CLogBookScreen::Update(float dt, CRandom16& rand, CArchitectureQueue& archQ
x174_textpane_body->SetColor(invColor);
for (CAuiImagePane* pane : xf0_imagePanes)
pane->SetInverseAlpha(1.f - x254_viewInterp);
pane->SetDeResFactor(1.f - x254_viewInterp);
if (x254_viewInterp == 0.f && x25c_leavePauseState == ELeavePauseState::InPause)
ChangeMode(EMode::RightTable);

View File

@ -92,7 +92,6 @@ protected:
u32 _dummy = 0;
};
void InitializeFrameGlue();
static std::string GetImagePaneName(u32 i);
void ChangeMode(EMode mode);
void UpdateSideTable(CGuiTableGroup* table);
void SetRightTableSelection(int selBegin, int selEnd);
@ -103,6 +102,8 @@ protected:
void OnRightTableCancel(CGuiTableGroup* caller);
public:
static std::string GetImagePaneName(u32 i);
CPauseScreenBase(const CStateManager& mgr, CGuiFrame& frame, const CStringTable& pauseStrg);
bool ShouldExitPauseScreen() const { return x198_26_exitPauseScreen; }