More text fixes

This commit is contained in:
Phillip Stephens 2022-05-31 14:13:06 -07:00
parent eff44ad56a
commit db38e5b288
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
4 changed files with 31 additions and 28 deletions

View File

@ -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;

View File

@ -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<CTextRenderBuffer> CTextExecuteBuffer::BuildRenderBufferPages(const ze
std::list<CTextRenderBuffer> 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<CLineInstruction*>(
x0_instList
.emplace(xa8_curWordIt, std::make_shared<CLineInstruction>(x18_textState.x80_just, x18_textState.x84_vjust,
xc0_imageBaseline))
.emplace(xa8_curWordIt,
std::make_shared<CLineInstruction>(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<CLineInstruction>(x18_textState.x80_just, x18_textState.x84_vjust, xc0_imageBaseline));
std::make_shared<CLineInstruction>(0, 0, 0, x18_textState.x80_just, x18_textState.x84_vjust, xc0_imageBaseline));
xa4_curLine = static_cast<CLineInstruction*>(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<CRasterFont>& font) {
void CTextExecuteBuffer::EndBlock() {
if (xa4_curLine)
TerminateLine();
TerminateLine(false);
xa4_curLine = nullptr;
xa0_curBlock = nullptr;
}

View File

@ -22,7 +22,6 @@ class CTextExecuteBuffer {
using InstList = std::list<std::shared_ptr<CInstruction>>;
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<CSaveableState> 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);

View File

@ -103,7 +103,7 @@ static std::optional<std::string> 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(':');