From db38e5b2880e26590203555599b462d88f6a0549 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Tue, 31 May 2022 14:13:06 -0700 Subject: [PATCH] More text fixes --- Runtime/GuiSys/CInstruction.hpp | 5 +-- Runtime/GuiSys/CTextExecuteBuffer.cpp | 46 +++++++++++++++------------ Runtime/GuiSys/CTextExecuteBuffer.hpp | 6 ++-- aurora/lib/input.cpp | 2 +- 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/Runtime/GuiSys/CInstruction.hpp b/Runtime/GuiSys/CInstruction.hpp index ba1594c13..fcbfeff55 100644 --- a/Runtime/GuiSys/CInstruction.hpp +++ b/Runtime/GuiSys/CInstruction.hpp @@ -62,6 +62,7 @@ public: class CCharacterExtraSpaceInstruction : public CInstruction { s32 x4_extraSpace; + public: explicit CCharacterExtraSpaceInstruction(s32 extraSpace) : x4_extraSpace(extraSpace) {} void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const override; @@ -87,8 +88,8 @@ class CLineInstruction : public CInstruction { bool x30_imageBaseline; public: - CLineInstruction(EJustification just, EVerticalJustification vjust, bool imageBaseline) - : x28_just(just), x2c_vjust(vjust), x30_imageBaseline(imageBaseline) {} + CLineInstruction(s32 wordCount, int x, int y, EJustification just, EVerticalJustification vjust, bool imageBaseline) + : x4_wordCount(wordCount), x8_curX(x), xc_curY(y), x28_just(just), x2c_vjust(vjust), x30_imageBaseline(imageBaseline) {} void TestLargestFont(s32 w, s32 h, s32 b); void TestLargestImage(s32 w, s32 h, s32 b); void InvokeLTR(CFontRenderState& state) const; diff --git a/Runtime/GuiSys/CTextExecuteBuffer.cpp b/Runtime/GuiSys/CTextExecuteBuffer.cpp index ca61097d7..8e9d297af 100644 --- a/Runtime/GuiSys/CTextExecuteBuffer.cpp +++ b/Runtime/GuiSys/CTextExecuteBuffer.cpp @@ -12,7 +12,7 @@ namespace metaforce { CTextRenderBuffer CTextExecuteBuffer::BuildRenderBuffer(CGuiWidget::EGuiModelDrawFlags df) const { - CTextRenderBuffer ret(CTextRenderBuffer::EMode::AllocTally);//, df); + CTextRenderBuffer ret(CTextRenderBuffer::EMode::AllocTally); //, df); { CFontRenderState rendState; @@ -35,7 +35,7 @@ CTextRenderBuffer CTextExecuteBuffer::BuildRenderBufferPage(InstList::const_iter InstList::const_iterator pgStart, InstList::const_iterator pgEnd, CGuiWidget::EGuiModelDrawFlags df) const { - CTextRenderBuffer ret(CTextRenderBuffer::EMode::AllocTally);//, df); + CTextRenderBuffer ret(CTextRenderBuffer::EMode::AllocTally); //, df); { CFontRenderState rendState; @@ -71,7 +71,7 @@ std::list CTextExecuteBuffer::BuildRenderBufferPages(const ze std::list ret; for (auto it = x0_instList.begin(); it != x0_instList.end();) { - CTextRenderBuffer rbuf(CTextRenderBuffer::EMode::AllocTally);//, df); + CTextRenderBuffer rbuf(CTextRenderBuffer::EMode::AllocTally); //, df); { CFontRenderState rstate; @@ -220,12 +220,13 @@ void CTextExecuteBuffer::MoveWordLTR() { xa4_curLine->xc_curY = std::min(xa4_curLine->xc_curY, xb8_curWordY); xbc_spaceDistance = 0; --xa4_curLine->x4_wordCount; - TerminateLineLTR(); + TerminateLineLTR(false); xa4_curLine = static_cast( x0_instList - .emplace(xa8_curWordIt, std::make_shared(x18_textState.x80_just, x18_textState.x84_vjust, - xc0_imageBaseline)) + .emplace(xa8_curWordIt, + std::make_shared(1, xb4_curWordX, xb8_curWordY, x18_textState.x80_just, + x18_textState.x84_vjust, xc0_imageBaseline)) ->get()); // Dunno what's up with this in the original; seems fine without @@ -235,12 +236,13 @@ void CTextExecuteBuffer::MoveWordLTR() { } void CTextExecuteBuffer::StartNewLine() { - if (xa4_curLine) - TerminateLine(); + if (xa4_curLine) { + TerminateLine(true); + } xa8_curWordIt = x0_instList.emplace( x0_instList.cend(), - std::make_shared(x18_textState.x80_just, x18_textState.x84_vjust, xc0_imageBaseline)); + std::make_shared(0, 0, 0, x18_textState.x80_just, x18_textState.x84_vjust, xc0_imageBaseline)); xa4_curLine = static_cast(xa8_curWordIt->get()); xbc_spaceDistance = 0; @@ -257,17 +259,21 @@ void CTextExecuteBuffer::StartNewWord() { ++xa4_curLine->x4_wordCount; } -void CTextExecuteBuffer::TerminateLine() { +void CTextExecuteBuffer::TerminateLine(bool b) { if (xa0_curBlock->x14_dir == ETextDirection::Horizontal) - TerminateLineLTR(); + TerminateLineLTR(b); } -void CTextExecuteBuffer::TerminateLineLTR() { - if (!xa4_curLine->xc_curY /*&& x18_textState.IsFinishedLoading()*/) { +void CTextExecuteBuffer::TerminateLineLTR(bool b) { + if (!xa4_curLine->xc_curY && x18_textState.IsFinishedLoading()) { xa4_curLine->xc_curY = std::max(xa4_curLine->GetHeight(), x18_textState.x48_font->GetCarriageAdvance()); } + bool b2 = true; + if (xa0_curBlock->x1c_vertJustification != EVerticalJustification::Full && !b) { + b2 = false; + } - if (xa0_curBlock->x1c_vertJustification == EVerticalJustification::Full) { + if (b2) { xa0_curBlock->x30_lineY += xa4_curLine->xc_curY; } else { xa0_curBlock->x30_lineY += x18_textState.x78_extraLineSpace + xa4_curLine->xc_curY * x18_textState.x74_lineSpacing; @@ -293,19 +299,17 @@ void CTextExecuteBuffer::AddPushState() { void CTextExecuteBuffer::AddVerticalJustification(EVerticalJustification vjust) { x18_textState.x84_vjust = vjust; - if (!xa4_curLine) - return; - if (xa4_curLine->x8_curX) + if (xa4_curLine == nullptr || xa4_curLine->x8_curX != 0) { return; + } xa4_curLine->x2c_vjust = vjust; } void CTextExecuteBuffer::AddJustification(EJustification just) { x18_textState.x80_just = just; - if (!xa4_curLine) - return; - if (xa4_curLine->x8_curX) + if (xa4_curLine == nullptr || xa4_curLine->x8_curX != 0) { return; + } xa4_curLine->x28_just = just; } @@ -372,7 +376,7 @@ void CTextExecuteBuffer::AddFont(const TToken& font) { void CTextExecuteBuffer::EndBlock() { if (xa4_curLine) - TerminateLine(); + TerminateLine(false); xa4_curLine = nullptr; xa0_curBlock = nullptr; } diff --git a/Runtime/GuiSys/CTextExecuteBuffer.hpp b/Runtime/GuiSys/CTextExecuteBuffer.hpp index 1ef9315c5..4e4b3c230 100644 --- a/Runtime/GuiSys/CTextExecuteBuffer.hpp +++ b/Runtime/GuiSys/CTextExecuteBuffer.hpp @@ -22,7 +22,6 @@ class CTextExecuteBuffer { using InstList = std::list>; InstList x0_instList; - u32 x14_ = 0; CSaveableState x18_textState; CBlockInstruction* xa0_curBlock = nullptr; CLineInstruction* xa4_curLine = nullptr; @@ -34,7 +33,6 @@ class CTextExecuteBuffer { s32 xbc_spaceDistance = 0; bool xc0_imageBaseline = false; std::list xc4_stateStack; - u32 xd8_ = 0; public: CTextExecuteBuffer() : xa8_curWordIt{x0_instList.begin()} {} @@ -51,8 +49,8 @@ public: void MoveWordLTR(); void StartNewLine(); void StartNewWord(); - void TerminateLine(); - void TerminateLineLTR(); + void TerminateLine(bool b); + void TerminateLineLTR(bool b); void AddPopState(); void AddPushState(); void AddVerticalJustification(EVerticalJustification vjust); diff --git a/aurora/lib/input.cpp b/aurora/lib/input.cpp index 96e72e97f..96e6de992 100644 --- a/aurora/lib/input.cpp +++ b/aurora/lib/input.cpp @@ -103,7 +103,7 @@ static std::optional remap_controller_layout(std::string_view mappi Log.report(logvisor::Error, FMT_STRING("Controller has unsupported layout: {}"), mapping); return {}; } - for (const auto [k, v] : entries) { + for (auto [k, v] : entries) { newMapping.push_back(','); newMapping.append(k); newMapping.push_back(':');