2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 23:47:42 +00:00

Work on CWorldTransManager

This commit is contained in:
Jack Andersen
2016-08-15 10:58:07 -10:00
parent eb7ce0b84b
commit 0dacc2233c
19 changed files with 264 additions and 108 deletions

View File

@@ -14,26 +14,26 @@ namespace urde
CGuiTextSupport::CGuiTextSupport(ResId fontId, const CGuiTextProperties& props,
const zeus::CColor& fontCol, const zeus::CColor& outlineCol,
const zeus::CColor& geomCol, s32 padX, s32 padY, CSimplePool* store)
: x10_props(props), x1c_fontColor(fontCol), x20_outlineColor(outlineCol),
x24_geometryColor(geomCol), x28_extentX(padX), x2c_extentY(padY)
: x14_props(props), x24_fontColor(fontCol), x28_outlineColor(outlineCol),
x2c_geometryColor(geomCol), x34_extentX(padX), x38_extentY(padY)
{
x2c0_font = store->GetObj({SBIG('FONT'), fontId});
x2cc_font = store->GetObj({SBIG('FONT'), fontId});
}
float CGuiTextSupport::GetCurrentAnimationOverAge() const
{
if (!x2ac_active || !x44_typeEnable)
if (!x2ac_active || !x50_typeEnable)
return 0.f;
if (x34_primStartTimes.size())
if (x44_primStartTimes.size())
{
float val = (x54_renderBuf->GetPrimitiveCount() - x34_primStartTimes.back().second) /
x4c_chRate + x34_primStartTimes.back().first;
float val = (x60_renderBuf->GetPrimitiveCount() - x44_primStartTimes.back().second) /
x58_chRate + x44_primStartTimes.back().first;
return std::max(0.f, val);
}
else
{
float val = x54_renderBuf->GetPrimitiveCount() / x4c_chRate;
float val = x60_renderBuf->GetPrimitiveCount() / x58_chRate;
return std::max(0.f, val);
}
}
@@ -41,23 +41,23 @@ float CGuiTextSupport::GetCurrentAnimationOverAge() const
float CGuiTextSupport::GetNumCharsPrinted() const
{
if (x2ac_active)
return std::min(x30_curTime * x4c_chRate, float(x54_renderBuf->GetPrimitiveCount()));
return std::min(x3c_curTime * x58_chRate, float(x60_renderBuf->GetPrimitiveCount()));
return 0.f;
}
float CGuiTextSupport::GetTotalAnimationTime() const
{
if (!x2ac_active || !x44_typeEnable)
if (!x2ac_active || !x50_typeEnable)
return 0.f;
return x54_renderBuf->GetPrimitiveCount() / x4c_chRate;
return x60_renderBuf->GetPrimitiveCount() / x58_chRate;
}
void CGuiTextSupport::SetTypeWriteEffectOptions(bool enable, float chFadeTime, float chRate)
{
x44_typeEnable = enable;
x48_chFadeTime = std::max(chFadeTime, 0.0001f);
x4c_chRate = std::max(chRate, 1.f);
x50_typeEnable = enable;
x54_chFadeTime = std::max(chFadeTime, 0.0001f);
x58_chRate = std::max(chRate, 1.f);
}
void CGuiTextSupport::Update(float dt)
@@ -65,12 +65,12 @@ void CGuiTextSupport::Update(float dt)
if (!x2ac_active)
return;
if (x44_typeEnable)
if (x50_typeEnable)
{
for (int i=0 ; i<x54_renderBuf->GetPrimitiveCount() ; ++i)
for (int i=0 ; i<x60_renderBuf->GetPrimitiveCount() ; ++i)
{
float chStartTime = 0.f;
for (const std::pair<float, int>& p : x34_primStartTimes)
for (const std::pair<float, int>& p : x44_primStartTimes)
{
if (p.second < i)
continue;
@@ -85,18 +85,18 @@ void CGuiTextSupport::Update(float dt)
prim.x0_color1.a = std::min(std::max(0.f, (x30_curTime - chStartTime) / x48_chFadeTime), 1.f);
x54_renderBuf->SetPrimitive(prim, i);
#else
x54_renderBuf->SetPrimitiveOpacity(i,
std::min(std::max(0.f, (x30_curTime - chStartTime) / x48_chFadeTime), 1.f));
x60_renderBuf->SetPrimitiveOpacity(i,
std::min(std::max(0.f, (x3c_curTime - chStartTime) / x54_chFadeTime), 1.f));
#endif
}
}
x30_curTime += dt;
x3c_curTime += dt;
}
void CGuiTextSupport::ClearBuffer()
{
x54_renderBuf = std::experimental::nullopt;
x60_renderBuf = std::experimental::nullopt;
}
void CGuiTextSupport::CheckAndRebuildTextRenderBuffer()
@@ -105,15 +105,15 @@ void CGuiTextSupport::CheckAndRebuildTextRenderBuffer()
return;
g_TextExecuteBuf->Clear();
g_TextExecuteBuf->x18_textState.x48_enableWordWrap = x10_props.x0_wordWrap;
g_TextExecuteBuf->BeginBlock(0, 0, x28_extentX, x2c_extentY, ETextDirection(x10_props.x1_vertical),
x10_props.x4_justification, x10_props.x8_vertJustification);
g_TextExecuteBuf->AddColor(EColorType::Main, x1c_fontColor);
g_TextExecuteBuf->AddColor(EColorType::Outline, x20_outlineColor);
g_TextExecuteBuf->x18_textState.x48_enableWordWrap = x14_props.x0_wordWrap;
g_TextExecuteBuf->BeginBlock(0, 0, x34_extentX, x38_extentY, ETextDirection(x14_props.x1_vertical),
x14_props.x4_justification, x14_props.x8_vertJustification);
g_TextExecuteBuf->AddColor(EColorType::Main, x24_fontColor);
g_TextExecuteBuf->AddColor(EColorType::Outline, x28_outlineColor);
std::wstring initStr;
if ((x50_fontId & 0xffff) != 0xffff)
initStr = hecl::WideFormat(L"&font=%08X;", u32(x50_fontId));
if ((x5c_fontId & 0xffff) != 0xffff)
initStr = hecl::WideFormat(L"&font=%08X;", u32(x5c_fontId));
initStr += x0_string;
g_TextParser->ParseText(*g_TextExecuteBuf, initStr.c_str(), initStr.size());
@@ -123,7 +123,7 @@ void CGuiTextSupport::CheckAndRebuildTextRenderBuffer()
if (GetIsTextSupportFinishedLoading())
{
x54_renderBuf = g_TextExecuteBuf->CreateTextRenderBuffer();
x60_renderBuf = g_TextExecuteBuf->CreateTextRenderBuffer();
g_TextExecuteBuf->Clear();
}
@@ -136,31 +136,31 @@ void CGuiTextSupport::Render() const
{
zeus::CTransform oldModel = CGraphics::g_GXModelMatrix;
CGraphics::SetModelMatrix(oldModel * zeus::CTransform::Scale(1.f, 1.f, -1.f));
x54_renderBuf->Render(x24_geometryColor, x30_curTime);
x60_renderBuf->Render(x2c_geometryColor, x3c_curTime);
CGraphics::SetModelMatrix(oldModel);
}
}
void CGuiTextSupport::SetGeometryColor(const zeus::CColor& col)
{
x24_geometryColor = col;
x2c_geometryColor = col;
}
void CGuiTextSupport::SetOutlineColor(const zeus::CColor& col)
{
if (col != x20_outlineColor)
if (col != x28_outlineColor)
{
ClearBuffer();
x20_outlineColor = col;
x28_outlineColor = col;
}
}
void CGuiTextSupport::SetFontColor(const zeus::CColor& col)
{
if (col != x1c_fontColor)
if (col != x24_fontColor)
{
ClearBuffer();
x1c_fontColor = col;
x24_fontColor = col;
}
}
@@ -169,8 +169,8 @@ void CGuiTextSupport::AddText(const std::wstring& str)
if (x2ac_active)
{
float t = GetCurrentAnimationOverAge();
x34_primStartTimes.push_back(std::make_pair(std::max(t, x30_curTime),
x54_renderBuf->GetPrimitiveCount()));
x44_primStartTimes.push_back(std::make_pair(std::max(t, x3c_curTime),
x60_renderBuf->GetPrimitiveCount()));
}
x0_string += str;
ClearBuffer();
@@ -180,8 +180,8 @@ void CGuiTextSupport::SetText(const std::wstring& str)
{
if (x0_string.compare(str))
{
x34_primStartTimes.clear();
x30_curTime = 0.f;
x44_primStartTimes.clear();
x3c_curTime = 0.f;
x0_string = str;
ClearBuffer();
}
@@ -200,7 +200,7 @@ bool CGuiTextSupport::GetIsTextSupportFinishedLoading() const
if (!tok.IsLoaded())
return false;
}
return x2c0_font.IsLoaded();
return x2cc_font.IsLoaded();
}
}