mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-20 11:05:24 +00:00
Initial CTextRenderBuffer rewrite
This commit is contained in:
@@ -68,48 +68,44 @@ const CTextRenderBuffer* CGuiTextSupport::GetCurrentPageRenderBuffer() const {
|
||||
|
||||
float CGuiTextSupport::GetCurrentAnimationOverAge() const {
|
||||
float ret = 0.f;
|
||||
// TODO
|
||||
// if (const CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) {
|
||||
// if (x50_typeEnable) {
|
||||
// if (x40_primStartTimes.size()) {
|
||||
// const auto& lastTime = x40_primStartTimes.back();
|
||||
// ret = std::max(ret, (buf->GetPrimitiveCount() - lastTime.second) / x58_chRate + lastTime.first);
|
||||
// } else {
|
||||
// ret = std::max(ret, buf->GetPrimitiveCount() / x58_chRate);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if (const CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) {
|
||||
if (x50_typeEnable) {
|
||||
if (!x40_primStartTimes.empty()) {
|
||||
const auto& lastTime = x40_primStartTimes.back();
|
||||
ret = std::max(ret, (buf->GetPrimitiveCount() - lastTime.second) / x58_chRate + lastTime.first);
|
||||
} else {
|
||||
ret = std::max(ret, buf->GetPrimitiveCount() / x58_chRate);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
float CGuiTextSupport::GetNumCharsTotal() const {
|
||||
// TODO
|
||||
// if (const CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) {
|
||||
// if (x50_typeEnable) {
|
||||
// return buf->GetPrimitiveCount();
|
||||
// }
|
||||
// }
|
||||
if (const CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) {
|
||||
if (x50_typeEnable) {
|
||||
return buf->GetPrimitiveCount();
|
||||
}
|
||||
}
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
float CGuiTextSupport::GetNumCharsPrinted() const {
|
||||
// TODO
|
||||
// if (const CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) {
|
||||
// if (x50_typeEnable) {
|
||||
// const float charsPrinted = x3c_curTime * x58_chRate;
|
||||
// return std::min(charsPrinted, float(buf->GetPrimitiveCount()));
|
||||
// }
|
||||
// }
|
||||
if (const CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) {
|
||||
if (x50_typeEnable) {
|
||||
const float charsPrinted = x3c_curTime * x58_chRate;
|
||||
return std::min(charsPrinted, float(buf->GetPrimitiveCount()));
|
||||
}
|
||||
}
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
float CGuiTextSupport::GetTotalAnimationTime() const {
|
||||
// TODO
|
||||
// if (const CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) {
|
||||
// if (x50_typeEnable) {
|
||||
// return buf->GetPrimitiveCount() / x58_chRate;
|
||||
// }
|
||||
// }
|
||||
if (const CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) {
|
||||
if (x50_typeEnable) {
|
||||
return buf->GetPrimitiveCount() / x58_chRate;
|
||||
}
|
||||
}
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
@@ -121,21 +117,20 @@ void CGuiTextSupport::SetTypeWriteEffectOptions(bool enable, float chFadeTime, f
|
||||
x58_chRate = std::max(chRate, 1.f);
|
||||
if (enable) {
|
||||
if (CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) {
|
||||
// TODO
|
||||
// float chStartTime = 0.f;
|
||||
// for (u32 i = 0; i < buf->GetPrimitiveCount(); ++i) {
|
||||
// for (const std::pair<float, int>& p : x40_primStartTimes) {
|
||||
// if (p.second < i)
|
||||
// continue;
|
||||
// if (p.second != i)
|
||||
// break;
|
||||
// chStartTime = p.first;
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// buf->SetPrimitiveOpacity(i, std::min(std::max(0.f, (x3c_curTime - chStartTime) / x54_chFadeTime), 1.f));
|
||||
// chStartTime += 1.f / x58_chRate;
|
||||
// }
|
||||
float chStartTime = 0.f;
|
||||
for (u32 i = 0; i < buf->GetPrimitiveCount(); ++i) {
|
||||
for (const std::pair<float, int>& p : x40_primStartTimes) {
|
||||
if (p.second < i)
|
||||
continue;
|
||||
if (p.second != i)
|
||||
break;
|
||||
chStartTime = p.first;
|
||||
break;
|
||||
}
|
||||
|
||||
//buf->SetPrimitiveOpacity(i, std::min(std::max(0.f, (x3c_curTime - chStartTime) / x54_chFadeTime), 1.f));
|
||||
chStartTime += 1.f / x58_chRate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,21 +138,20 @@ void CGuiTextSupport::SetTypeWriteEffectOptions(bool enable, float chFadeTime, f
|
||||
void CGuiTextSupport::Update(float dt) {
|
||||
if (x50_typeEnable) {
|
||||
if (CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) {
|
||||
// TODO
|
||||
// float chStartTime = 0.f;
|
||||
// for (u32 i = 0; i < buf->GetPrimitiveCount(); ++i) {
|
||||
// for (const std::pair<float, int>& p : x40_primStartTimes) {
|
||||
// if (p.second < i)
|
||||
// continue;
|
||||
// if (p.second != i)
|
||||
// break;
|
||||
// chStartTime = p.first;
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// buf->SetPrimitiveOpacity(i, std::min(std::max(0.f, (x3c_curTime - chStartTime) / x54_chFadeTime), 1.f));
|
||||
// chStartTime += 1.f / x58_chRate;
|
||||
// }
|
||||
float chStartTime = 0.f;
|
||||
for (u32 i = 0; i < buf->GetPrimitiveCount(); ++i) {
|
||||
for (const std::pair<float, int>& p : x40_primStartTimes) {
|
||||
if (p.second < i)
|
||||
continue;
|
||||
if (p.second != i)
|
||||
break;
|
||||
chStartTime = p.first;
|
||||
break;
|
||||
}
|
||||
|
||||
//buf->SetPrimitiveOpacity(i, std::min(std::max(0.f, (x3c_curTime - chStartTime) / x54_chFadeTime), 1.f));
|
||||
chStartTime += 1.f / x58_chRate;
|
||||
}
|
||||
}
|
||||
x3c_curTime += dt;
|
||||
}
|
||||
@@ -190,9 +184,11 @@ void CGuiTextSupport::CheckAndRebuildTextBuffer() {
|
||||
}
|
||||
|
||||
bool CGuiTextSupport::CheckAndRebuildRenderBuffer() {
|
||||
if (x308_multipageFlag || x60_renderBuf)
|
||||
if (!x308_multipageFlag || x2ec_renderBufferPages.size())
|
||||
if (x308_multipageFlag || x60_renderBuf) {
|
||||
if (!x308_multipageFlag || x2ec_renderBufferPages.size()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
CheckAndRebuildTextBuffer();
|
||||
x2bc_assets = g_TextExecuteBuf->GetAssets();
|
||||
@@ -259,8 +255,7 @@ void CGuiTextSupport::SetFontColor(const zeus::CColor& col) {
|
||||
void CGuiTextSupport::AddText(std::u16string_view str) {
|
||||
if (x60_renderBuf) {
|
||||
const float t = GetCurrentAnimationOverAge();
|
||||
// TODO
|
||||
// x40_primStartTimes.emplace_back(std::max(t, x3c_curTime), x60_renderBuf->GetPrimitiveCount());
|
||||
x40_primStartTimes.emplace_back(std::max(t, x3c_curTime), x60_renderBuf->GetPrimitiveCount());
|
||||
}
|
||||
x0_string += str;
|
||||
ClearRenderBuffer();
|
||||
|
||||
Reference in New Issue
Block a user