mirror of https://github.com/AxioDL/metaforce.git
CTextExecuteBuffer imps
This commit is contained in:
parent
08ccc1be63
commit
7835769a98
|
@ -34,6 +34,9 @@ public:
|
|||
/** Indicates an asynchronous load transaction has been submitted and is not yet finished */
|
||||
bool IsLoading() const {return x3_loading;}
|
||||
|
||||
/** Indicates an asynchronous load transaction has finished and object is completely loaded */
|
||||
bool IsLoaded() const {return x10_object != nullptr;}
|
||||
|
||||
/** Decrements 2nd ref-count, performing unload or async-load-cancel if 0 reached */
|
||||
void Unlock()
|
||||
{
|
||||
|
@ -140,6 +143,12 @@ public:
|
|||
x4_lockHeld = true;
|
||||
}
|
||||
}
|
||||
bool IsLoaded() const
|
||||
{
|
||||
if (!x0_objRef)
|
||||
return false;
|
||||
return x0_objRef->IsLoaded();
|
||||
}
|
||||
void RemoveRef()
|
||||
{
|
||||
if (x0_objRef && x0_objRef->RemoveReference() == 0)
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
#include "CFontImageDef.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
CFontImageDef::CFontImageDef(std::vector<TToken<CTexture>>&& texs,
|
||||
float interval, const zeus::CVector2f& vec)
|
||||
: x0_interval(interval), x4_texs(std::move(texs)), x14_(vec)
|
||||
{
|
||||
for (TToken<CTexture>& tok : x4_texs)
|
||||
tok.Lock();
|
||||
}
|
||||
|
||||
CFontImageDef::CFontImageDef(TToken<CTexture>&& tex, const zeus::CVector2f& vec)
|
||||
: x0_interval(0.f), x4_texs({std::move(tex)}), x14_(vec)
|
||||
{
|
||||
x4_texs[0].Lock();
|
||||
}
|
||||
|
||||
bool CFontImageDef::IsLoaded() const
|
||||
{
|
||||
for (const TToken<CTexture>& tok : x4_texs)
|
||||
if (!tok.IsLoaded())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +1,24 @@
|
|||
#ifndef __URDE_CFONTIMAGEDEF_HPP__
|
||||
#define __URDE_CFONTIMAGEDEF_HPP__
|
||||
|
||||
#include <vector>
|
||||
#include "CToken.hpp"
|
||||
#include "zeus/CVector2f.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
class CTexture;
|
||||
|
||||
class CFontImageDef
|
||||
{
|
||||
float x0_interval;
|
||||
std::vector<TToken<CTexture>> x4_texs;
|
||||
zeus::CVector2f x14_;
|
||||
public:
|
||||
CFontImageDef(std::vector<TToken<CTexture>>&& texs, float interval,
|
||||
const zeus::CVector2f& vec);
|
||||
CFontImageDef(TToken<CTexture>&& tex, const zeus::CVector2f& vec);
|
||||
bool IsLoaded() const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -13,10 +13,13 @@ class CRasterFont;
|
|||
|
||||
enum class EJustification
|
||||
{
|
||||
Zero = 0
|
||||
};
|
||||
|
||||
enum class EVerticalJustification
|
||||
{
|
||||
Zero = 0,
|
||||
Three = 3
|
||||
};
|
||||
|
||||
enum class EColorType
|
||||
|
@ -30,6 +33,8 @@ enum class EColorType
|
|||
|
||||
enum class ETextDirection
|
||||
{
|
||||
Horizontal,
|
||||
Vertical
|
||||
};
|
||||
|
||||
using CTextColor = zeus::CColor;
|
||||
|
|
|
@ -43,13 +43,24 @@ size_t CFontInstruction::GetAssetCount() const
|
|||
return 1;
|
||||
}
|
||||
|
||||
void CExtraLineSpaceInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const
|
||||
void CLineExtraSpaceInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const
|
||||
{
|
||||
state.x44_extraLineSpace = x4_extraSpace;
|
||||
}
|
||||
|
||||
void CLineInstruction::TestLargestFont(int, int, int)
|
||||
void CLineInstruction::TestLargestFont(s32 w, s32 h, s32 b)
|
||||
{
|
||||
if (!x18_largestBaseline)
|
||||
x18_largestBaseline = b;
|
||||
|
||||
if (x14_largestMonoWidth < w)
|
||||
w = x14_largestMonoWidth;
|
||||
|
||||
if (x10_largestMonoHeight < h)
|
||||
{
|
||||
x10_largestMonoHeight = h;
|
||||
x18_largestBaseline = b;
|
||||
}
|
||||
}
|
||||
|
||||
void CLineInstruction::InvokeLTR(CFontRenderState& state) const
|
||||
|
@ -63,4 +74,12 @@ void CLineInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) c
|
|||
state.x74_currentLineInst = this;
|
||||
}
|
||||
|
||||
CTextInstruction::CTextInstruction(const wchar_t* str, int len)
|
||||
{
|
||||
}
|
||||
|
||||
void CTextInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -49,73 +49,92 @@ public:
|
|||
size_t GetAssetCount() const;
|
||||
};
|
||||
|
||||
class CExtraLineSpaceInstruction : public CInstruction
|
||||
class CLineExtraSpaceInstruction : public CInstruction
|
||||
{
|
||||
s32 x4_extraSpace;
|
||||
public:
|
||||
CExtraLineSpaceInstruction(s32 extraSpace) : x4_extraSpace(extraSpace) {}
|
||||
CLineExtraSpaceInstruction(s32 extraSpace) : x4_extraSpace(extraSpace) {}
|
||||
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
|
||||
};
|
||||
|
||||
class CLineInstruction : public CInstruction
|
||||
{
|
||||
u32 x4_ = 0;
|
||||
u32 x8_ = 0;
|
||||
u32 xc_ = 0;
|
||||
u32 x10_ = 0;
|
||||
u32 x14_ = 0;
|
||||
u32 x18_ = 0;
|
||||
u32 x1c_;
|
||||
u32 x20_;
|
||||
friend class CTextExecuteBuffer;
|
||||
s32 x4_ = 0;
|
||||
s32 x8_curX = 0;
|
||||
s32 xc_curY = 0;
|
||||
s32 x10_largestMonoHeight = 0;
|
||||
s32 x14_largestMonoWidth = 0;
|
||||
s32 x18_largestBaseline = 0;
|
||||
EJustification x1c_just;
|
||||
EVerticalJustification x20_vjust;
|
||||
public:
|
||||
CLineInstruction(u32 a, u32 b) : x1c_(a), x20_(b) {}
|
||||
void TestLargestFont(int, int, int);
|
||||
CLineInstruction(EJustification just, EVerticalJustification vjust)
|
||||
: x1c_just(just), x20_vjust(vjust) {}
|
||||
void TestLargestFont(s32 w, s32 h, s32 b);
|
||||
void InvokeLTR(CFontRenderState& state) const;
|
||||
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
|
||||
};
|
||||
|
||||
class CLineSpacingInstruction : public CInstruction
|
||||
{
|
||||
float x4_lineSpacing;
|
||||
public:
|
||||
CLineSpacingInstruction(float spacing) : x4_lineSpacing(spacing) {}
|
||||
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
|
||||
};
|
||||
|
||||
class CPopStateInstruction : public CInstruction
|
||||
{
|
||||
public:
|
||||
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
|
||||
};
|
||||
|
||||
class CPushStateInstruction : public CInstruction
|
||||
{
|
||||
public:
|
||||
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
|
||||
};
|
||||
|
||||
class CRemoveColorOverrideInstruction : public CInstruction
|
||||
{
|
||||
int x4_idx;
|
||||
public:
|
||||
CRemoveColorOverrideInstruction(int idx) : x4_idx(idx) {}
|
||||
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
|
||||
};
|
||||
|
||||
class CImageInstruction : public CInstruction
|
||||
{
|
||||
public:
|
||||
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
|
||||
};
|
||||
|
||||
class CTextInstruction : public CInstruction
|
||||
{
|
||||
public:
|
||||
CTextInstruction(const wchar_t* str, int len);
|
||||
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
|
||||
};
|
||||
|
||||
class CBlockInstruction : public CInstruction
|
||||
{
|
||||
friend class CTextExecuteBuffer;
|
||||
int x4_;
|
||||
int x8_;
|
||||
int xc_;
|
||||
int x10_;
|
||||
s32 x4_;
|
||||
s32 x8_;
|
||||
s32 xc_;
|
||||
s32 x10_;
|
||||
ETextDirection x14_direction;
|
||||
EJustification x18_justification;
|
||||
EVerticalJustification x1c_vertJustification;
|
||||
int x20_ = 0;
|
||||
int x24_ = 0;
|
||||
int x28_ = 0;
|
||||
int x2c_ = 0;
|
||||
int x30_ = 0;
|
||||
int x34_wordCount = 0;
|
||||
s32 x20_ = 0;
|
||||
s32 x24_ = 0;
|
||||
s32 x28_ = 0;
|
||||
s32 x2c_ = 0;
|
||||
s32 x30_lineY = 0;
|
||||
s32 x34_lineCount = 0;
|
||||
public:
|
||||
CBlockInstruction(int a, int b, int c, int d, ETextDirection dir,
|
||||
CBlockInstruction(s32 a, s32 b, s32 c, s32 d, ETextDirection dir,
|
||||
EJustification just, EVerticalJustification vjust)
|
||||
: x4_(a), x8_(b), xc_(c), x10_(d), x14_direction(dir),
|
||||
x18_justification(just), x1c_vertJustification(vjust) {}
|
||||
|
@ -124,6 +143,8 @@ public:
|
|||
|
||||
class CWordInstruction : public CInstruction
|
||||
{
|
||||
public:
|
||||
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -15,17 +15,17 @@ class CSaveableState
|
|||
friend class CTextExecuteBuffer;
|
||||
friend class CColorOverrideInstruction;
|
||||
friend class CFontInstruction;
|
||||
friend class CExtraLineSpaceInstruction;
|
||||
friend class CLineExtraSpaceInstruction;
|
||||
protected:
|
||||
CDrawStringOptions x0_drawStrOpts;
|
||||
TToken<CRasterFont> x14_token;
|
||||
std::vector<CTextColor> x20_;
|
||||
std::vector<bool> x30_;
|
||||
float x40_ = 1.f;
|
||||
float x40_lineSpacing = 1.f;
|
||||
s32 x44_extraLineSpace = 0;
|
||||
bool x48_ = false;
|
||||
u32 x4c_ = 0;
|
||||
u32 x50_ = 0;
|
||||
EJustification x4c_just = EJustification::Zero;
|
||||
EVerticalJustification x50_vjust = EVerticalJustification::Zero;
|
||||
|
||||
public:
|
||||
CSaveableState()
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include "CFontRenderState.hpp"
|
||||
#include "CFontImageDef.hpp"
|
||||
#include "CInstruction.hpp"
|
||||
#include "CRasterFont.hpp"
|
||||
#include "CWordBreakTables.hpp"
|
||||
#include "Graphics/CGraphicsPalette.hpp"
|
||||
|
||||
namespace urde
|
||||
|
@ -29,29 +31,296 @@ CTextRenderBuffer CTextExecuteBuffer::CreateTextRenderBuffer() const
|
|||
return ret;
|
||||
}
|
||||
|
||||
std::vector<CToken> CTextExecuteBuffer::GetAssets() const
|
||||
{
|
||||
size_t totalAssets = 0;
|
||||
for (const std::shared_ptr<CInstruction>& inst : x0_instList)
|
||||
totalAssets += inst->GetAssetCount();
|
||||
|
||||
std::vector<CToken> ret;
|
||||
ret.reserve(totalAssets);
|
||||
|
||||
for (const std::shared_ptr<CInstruction>& inst : x0_instList)
|
||||
inst->GetAssets(ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CTextExecuteBuffer::AddString(const wchar_t* str, int count)
|
||||
{
|
||||
if (!x70_curLine)
|
||||
StartNewLine();
|
||||
|
||||
const wchar_t* charCur = str;
|
||||
const wchar_t* wordCur = str;
|
||||
|
||||
for (int ac=0 ; *charCur && (ac < count || count == -1) ; ++charCur, ++ac)
|
||||
{
|
||||
if (*charCur == L'\n' || *charCur == L' ')
|
||||
{
|
||||
AddStringFragment(wordCur, charCur - wordCur);
|
||||
wordCur = charCur + 1;
|
||||
if (*charCur == L'\n')
|
||||
{
|
||||
StartNewLine();
|
||||
}
|
||||
else
|
||||
{
|
||||
StartNewWord();
|
||||
int w, h;
|
||||
wchar_t space = L' ';
|
||||
x18_textState.x14_token.GetObj()->GetSize(x18_textState.x0_drawStrOpts,
|
||||
w, h, &space, 1);
|
||||
if (x6c_curBlock->x14_direction == ETextDirection::Horizontal)
|
||||
{
|
||||
x70_curLine->x8_curX += w;
|
||||
x88_spaceDistance = w;
|
||||
}
|
||||
else
|
||||
{
|
||||
x70_curLine->xc_curY += h;
|
||||
x88_spaceDistance = h;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (charCur > wordCur)
|
||||
AddStringFragment(wordCur, charCur - wordCur);
|
||||
}
|
||||
|
||||
void CTextExecuteBuffer::AddStringFragment(const wchar_t* str, int len)
|
||||
{
|
||||
if (x6c_curBlock->x14_direction == ETextDirection::Horizontal)
|
||||
for (int i=0 ; i<len ;)
|
||||
i += WrapOneLTR(str + i, len - i);
|
||||
}
|
||||
|
||||
int CTextExecuteBuffer::WrapOneLTR(const wchar_t* str, int len)
|
||||
{
|
||||
if (!x18_textState.x14_token)
|
||||
return len;
|
||||
|
||||
CRasterFont* font = x18_textState.x14_token.GetObj();
|
||||
int rem = len;
|
||||
int w, h;
|
||||
x18_textState.x14_token.GetObj()->GetSize(x18_textState.x0_drawStrOpts,
|
||||
w, h, str, len);
|
||||
|
||||
if (x18_textState.x48_)
|
||||
{
|
||||
if (w + x70_curLine->x8_curX > x6c_curBlock->xc_ &&
|
||||
x70_curLine->x4_ > 1 &&
|
||||
x7c_curX + w < x6c_curBlock->xc_)
|
||||
{
|
||||
MoveWordLTR();
|
||||
}
|
||||
if (w + x70_curLine->x8_curX > x6c_curBlock->xc_ && len > 1)
|
||||
{
|
||||
const wchar_t* strEnd = str + len;
|
||||
int aRank = 5;
|
||||
|
||||
do
|
||||
{
|
||||
--rem;
|
||||
--strEnd;
|
||||
int endRank = 4;
|
||||
if (len > 2)
|
||||
endRank = CWordBreakTables::GetEndRank(*(strEnd - 1));
|
||||
|
||||
int beginRank = CWordBreakTables::GetBeginRank(*strEnd);
|
||||
|
||||
if (endRank < aRank && endRank <= beginRank)
|
||||
{
|
||||
aRank = endRank;
|
||||
}
|
||||
else
|
||||
{
|
||||
x18_textState.x14_token.GetObj()->GetSize(x18_textState.x0_drawStrOpts,
|
||||
w, h, str, rem);
|
||||
}
|
||||
|
||||
} while (w + x70_curLine->x8_curX > x6c_curBlock->xc_ && rem > 1);
|
||||
}
|
||||
}
|
||||
|
||||
x78_curY = std::max(x78_curY, font->GetMonoHeight());
|
||||
|
||||
x70_curLine->TestLargestFont(font->GetMonoWidth(),
|
||||
font->GetMonoHeight(),
|
||||
font->GetBaseline());
|
||||
|
||||
x70_curLine->x8_curX += w;
|
||||
x6c_curBlock->x2c_ = std::max(x6c_curBlock->x2c_, x70_curLine->x8_curX);
|
||||
x7c_curX += w;
|
||||
|
||||
x0_instList.emplace(x0_instList.cend(), new CTextInstruction(str, rem));
|
||||
|
||||
if (rem != len)
|
||||
StartNewLine();
|
||||
|
||||
return rem;
|
||||
}
|
||||
|
||||
void CTextExecuteBuffer::MoveWordLTR()
|
||||
{
|
||||
x70_curLine->xc_curY = std::min(x70_curLine->xc_curY, x84_);
|
||||
x88_spaceDistance = 0;
|
||||
--x70_curLine->x4_;
|
||||
TerminateLineLTR();
|
||||
|
||||
x70_curLine = static_cast<CLineInstruction*>(x0_instList.emplace(x74_curWordIt,
|
||||
new CLineInstruction(x18_textState.x4c_just, x18_textState.x50_vjust))->get());
|
||||
|
||||
x0_instList.emplace(x74_curWordIt, new CWordInstruction());
|
||||
|
||||
++x6c_curBlock->x34_lineCount;
|
||||
}
|
||||
|
||||
void CTextExecuteBuffer::StartNewLine()
|
||||
{
|
||||
if (x70_curLine)
|
||||
TerminateLine();
|
||||
|
||||
x74_curInst = x0_instList.emplace(x0_instList.cend(),
|
||||
new CLineInstruction(x18_.x4c_, x18_.x50_));
|
||||
x88_curFontSize = 0;
|
||||
x74_curWordIt = x0_instList.emplace(x0_instList.cend(),
|
||||
new CLineInstruction(x18_textState.x4c_just, x18_textState.x50_vjust));
|
||||
x88_spaceDistance = 0;
|
||||
|
||||
StartNewWord();
|
||||
++x6c_curBlock->x34_wordCount;
|
||||
++x6c_curBlock->x34_lineCount;
|
||||
}
|
||||
|
||||
void CTextExecuteBuffer::StartNewWord()
|
||||
{
|
||||
x74_curWordIt = x0_instList.emplace(x0_instList.cend(), new CWordInstruction());
|
||||
x7c_curX = 0;
|
||||
x78_curY = 0;
|
||||
x80_ = x70_curLine->x8_curX;
|
||||
x84_ = x70_curLine->xc_curY;
|
||||
++x70_curLine->x4_;
|
||||
}
|
||||
|
||||
void CTextExecuteBuffer::TerminateLine()
|
||||
{
|
||||
if (x6c_curBlock->x14_direction == ETextDirection::Horizontal)
|
||||
TerminateLineLTR();
|
||||
}
|
||||
|
||||
void CTextExecuteBuffer::TerminateLineLTR()
|
||||
{
|
||||
if (!x70_curLine->xc_curY && x18_textState.x14_token)
|
||||
{
|
||||
x70_curLine->xc_curY = x70_curLine->x10_largestMonoHeight;
|
||||
}
|
||||
|
||||
if (x6c_curBlock->x1c_vertJustification == EVerticalJustification::Three)
|
||||
{
|
||||
x6c_curBlock->x30_lineY += x70_curLine->xc_curY;
|
||||
}
|
||||
else
|
||||
{
|
||||
x6c_curBlock->x30_lineY += x18_textState.x44_extraLineSpace +
|
||||
x70_curLine->xc_curY * x18_textState.x40_lineSpacing;
|
||||
}
|
||||
}
|
||||
|
||||
void CTextExecuteBuffer::AddPopState()
|
||||
{
|
||||
x0_instList.emplace(x0_instList.cend(), new CPopStateInstruction());
|
||||
|
||||
x18_textState = x8c_stateStack.back();
|
||||
x8c_stateStack.pop_back();
|
||||
|
||||
if (!x70_curLine->x8_curX)
|
||||
{
|
||||
x70_curLine->x1c_just = x18_textState.x4c_just;
|
||||
x70_curLine->x20_vjust = x18_textState.x50_vjust;
|
||||
}
|
||||
}
|
||||
|
||||
void CTextExecuteBuffer::AddPushState()
|
||||
{
|
||||
x0_instList.emplace(x0_instList.cend(), new CPushStateInstruction());
|
||||
x8c_stateStack.push_back(x18_textState);
|
||||
}
|
||||
|
||||
void CTextExecuteBuffer::AddVerticalJustification(EVerticalJustification vjust)
|
||||
{
|
||||
x18_textState.x50_vjust = vjust;
|
||||
if (!x70_curLine)
|
||||
return;
|
||||
if (x70_curLine->x8_curX)
|
||||
return;
|
||||
x70_curLine->x20_vjust = vjust;
|
||||
}
|
||||
|
||||
void CTextExecuteBuffer::AddJustification(EJustification just)
|
||||
{
|
||||
x18_textState.x4c_just = just;
|
||||
if (!x70_curLine)
|
||||
return;
|
||||
if (x70_curLine->x8_curX)
|
||||
return;
|
||||
x70_curLine->x1c_just = just;
|
||||
}
|
||||
|
||||
void CTextExecuteBuffer::AddLineExtraSpace(s32 space)
|
||||
{
|
||||
x0_instList.emplace(x0_instList.cend(), new CLineExtraSpaceInstruction(space));
|
||||
x18_textState.x44_extraLineSpace = space;
|
||||
}
|
||||
|
||||
void CTextExecuteBuffer::AddLineSpacing(float spacing)
|
||||
{
|
||||
x0_instList.emplace(x0_instList.cend(), new CLineSpacingInstruction(spacing));
|
||||
x18_textState.x40_lineSpacing = spacing;
|
||||
}
|
||||
|
||||
void CTextExecuteBuffer::AddRemoveColorOverride(int idx)
|
||||
{
|
||||
x0_instList.emplace(x0_instList.cend(), new CRemoveColorOverrideInstruction(idx));
|
||||
}
|
||||
|
||||
void CTextExecuteBuffer::AddColorOverride(int idx, const CTextColor& color)
|
||||
{
|
||||
x0_instList.emplace(x0_instList.cend(), new CColorOverrideInstruction(idx, color));
|
||||
}
|
||||
|
||||
void CTextExecuteBuffer::AddColor(EColorType tp, const CTextColor& color)
|
||||
{
|
||||
x0_instList.emplace(x0_instList.cend(), new CColorInstruction(tp, color));
|
||||
}
|
||||
|
||||
void CTextExecuteBuffer::AddImage(const CFontImageDef& image)
|
||||
{
|
||||
if (!x70_curLine)
|
||||
StartNewLine();
|
||||
|
||||
if (x6c_curBlock)
|
||||
{
|
||||
/* TODO: Finish */
|
||||
}
|
||||
}
|
||||
|
||||
void CTextExecuteBuffer::EndBlock()
|
||||
{
|
||||
}
|
||||
|
||||
void CTextExecuteBuffer::BeginBlock(int,int,int,int,
|
||||
ETextDirection,EJustification,EVerticalJustification)
|
||||
{
|
||||
}
|
||||
|
||||
void CTextExecuteBuffer::Clear()
|
||||
{
|
||||
x0_instList.clear();
|
||||
x18_ = CSaveableState();
|
||||
x18_textState = CSaveableState();
|
||||
x6c_curBlock = nullptr;
|
||||
x70_curLine = nullptr;
|
||||
x74_curInst = x0_instList.begin();
|
||||
x74_curWordIt = x0_instList.begin();
|
||||
x80_ = 0;
|
||||
x84_ = 0;
|
||||
x88_curFontSize = 0;
|
||||
x88_spaceDistance = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,41 +17,38 @@ class CTextExecuteBuffer
|
|||
{
|
||||
std::list<std::shared_ptr<CInstruction>> x0_instList;
|
||||
u32 x14_ = 0;
|
||||
CSaveableState x18_;
|
||||
CSaveableState x18_textState;
|
||||
CBlockInstruction* x6c_curBlock = nullptr;
|
||||
CLineInstruction* x70_curLine = nullptr;
|
||||
std::list<std::shared_ptr<CInstruction>>::iterator x74_curInst;
|
||||
u32 x80_ = 0;
|
||||
u32 x84_ = 0;
|
||||
u32 x88_curFontSize = 0;
|
||||
u32 x90_ = 0;
|
||||
u32 x94_ = 0;
|
||||
u32 x98_ = 0;
|
||||
std::list<std::shared_ptr<CInstruction>>::iterator x74_curWordIt;
|
||||
s32 x78_curY;
|
||||
s32 x7c_curX;
|
||||
s32 x80_ = 0;
|
||||
s32 x84_ = 0;
|
||||
s32 x88_spaceDistance = 0;
|
||||
std::vector<CSaveableState> x8c_stateStack;
|
||||
|
||||
public:
|
||||
CTextExecuteBuffer()
|
||||
{
|
||||
x74_curInst = x0_instList.begin();
|
||||
x74_curWordIt = x0_instList.begin();
|
||||
}
|
||||
|
||||
CTextRenderBuffer CreateTextRenderBuffer() const;
|
||||
std::vector<TResId> GetAssets() const;
|
||||
std::vector<CToken> GetAssets() const;
|
||||
void AddString(const wchar_t* str, int);
|
||||
void AddStringFragment(const wchar_t* str, int);
|
||||
void WrapOneTTB(const wchar_t* str, int);
|
||||
void WrapOneLTR(const wchar_t* str, int);
|
||||
void MoveWordTTB();
|
||||
int WrapOneLTR(const wchar_t* str, int);
|
||||
void MoveWordLTR();
|
||||
void StartNewLine();
|
||||
void StartNewWord();
|
||||
void TerminateLine();
|
||||
void TerminateLineTTB();
|
||||
void TerminateLineLTR();
|
||||
void AddPopState();
|
||||
void AddPushState();
|
||||
void AddVerticalJustification(EVerticalJustification);
|
||||
void AddJustification(EJustification);
|
||||
void AddLineExtraSpace(int);
|
||||
void AddLineExtraSpace(s32 space);
|
||||
void AddLineSpacing(float);
|
||||
void AddRemoveColorOverride(int);
|
||||
void AddColorOverride(int, const CTextColor& color);
|
||||
|
|
|
@ -27,11 +27,6 @@ void CTextRenderBuffer::GetOutStream()
|
|||
{
|
||||
}
|
||||
|
||||
void CTextRenderBuffer::SetMode(EMode mode)
|
||||
{
|
||||
x0_mode = mode;
|
||||
}
|
||||
|
||||
void CTextRenderBuffer::VerifyBuffer()
|
||||
{
|
||||
if (x34_blob.empty())
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
void SetPrimitive(const Primitive&, int);
|
||||
Primitive GetPrimitive(int) const;
|
||||
void GetOutStream();
|
||||
void SetMode(EMode mode);
|
||||
void SetMode(EMode mode) {x0_mode = mode;}
|
||||
void VerifyBuffer();
|
||||
void Render(const zeus::CColor& col, float) const;
|
||||
void AddImage(const zeus::CVector2i& vec, const CFontImageDef&);
|
||||
|
|
|
@ -0,0 +1,190 @@
|
|||
#include "CWordBreakTables.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
struct CCharacterIdentifier
|
||||
{
|
||||
wchar_t chr;
|
||||
u32 rank;
|
||||
};
|
||||
|
||||
static const CCharacterIdentifier gCantBeginChars[]=
|
||||
{
|
||||
{0x21, 1},
|
||||
{0x29, 1},
|
||||
{0x2C, 1},
|
||||
{0x2D, 1},
|
||||
{0x2E, 1},
|
||||
{0x3A, 1},
|
||||
{0x3B, 1},
|
||||
{0x3F, 1},
|
||||
{0x5D, 1},
|
||||
{0x7D, 1},
|
||||
{0x92, 1},
|
||||
{0x94, 1},
|
||||
{0xBB, 1},
|
||||
{0x3001, 1},
|
||||
{0x3002, 1},
|
||||
{0x3005, 1},
|
||||
{0x300D, 1},
|
||||
{0x300F, 1},
|
||||
{0x3011, 1},
|
||||
{0x3015, 1},
|
||||
{0x3017, 1},
|
||||
{0x3019, 1},
|
||||
{0x301B, 1},
|
||||
{0x301C, 3},
|
||||
{0x301E, 1},
|
||||
{0x302B, 3},
|
||||
{0x3041, 2},
|
||||
{0x3043, 2},
|
||||
{0x3045, 2},
|
||||
{0x3047, 2},
|
||||
{0x3049, 2},
|
||||
{0x3063, 2},
|
||||
{0x3083, 2},
|
||||
{0x3085, 2},
|
||||
{0x3087, 2},
|
||||
{0x308E, 2},
|
||||
{0x309D, 3},
|
||||
{0x309E, 3},
|
||||
{0x30A1, 2},
|
||||
{0x30A3, 2},
|
||||
{0x30A5, 2},
|
||||
{0x30A7, 2},
|
||||
{0x30A9, 2},
|
||||
{0x30C3, 2},
|
||||
{0x30E3, 2},
|
||||
{0x30E5, 2},
|
||||
{0x30E7, 2},
|
||||
{0x30EE, 2},
|
||||
{0x30F5, 2},
|
||||
{0x30F6, 2},
|
||||
{0x30FC, 2},
|
||||
{0x30FD, 3},
|
||||
{0x30FE, 3},
|
||||
{0xFF01, 1},
|
||||
{0xFF05, 3},
|
||||
{0xFF09, 1},
|
||||
{0xFF0D, 1},
|
||||
{0xFF3D, 1},
|
||||
{0xFF5D, 1},
|
||||
{0xFF61, 1},
|
||||
{0xFF63, 1},
|
||||
{0xFF64, 1},
|
||||
{0xFF1F, 1}
|
||||
};
|
||||
|
||||
static const CCharacterIdentifier gCantEndChars[] =
|
||||
{
|
||||
{0x23, 2},
|
||||
{0x24, 2},
|
||||
{0x28, 1},
|
||||
{0x40, 2},
|
||||
{0x42, 4},
|
||||
{0x43, 4},
|
||||
{0x44, 4},
|
||||
{0x46, 4},
|
||||
{0x47, 4},
|
||||
{0x48, 4},
|
||||
{0x4A, 4},
|
||||
{0x4B, 4},
|
||||
{0x4C, 4},
|
||||
{0x4D, 4},
|
||||
{0x4E, 4},
|
||||
{0x50, 4},
|
||||
{0x51, 4},
|
||||
{0x52, 4},
|
||||
{0x53, 4},
|
||||
{0x54, 4},
|
||||
{0x56, 4},
|
||||
{0x57, 4},
|
||||
{0x58, 4},
|
||||
{0x59, 4},
|
||||
{0x5A, 4},
|
||||
{0x62, 4},
|
||||
{0x63, 4},
|
||||
{0x64, 4},
|
||||
{0x66, 4},
|
||||
{0x67, 4},
|
||||
{0x68, 4},
|
||||
{0x6A, 4},
|
||||
{0x6B, 4},
|
||||
{0x6C, 4},
|
||||
{0x6D, 4},
|
||||
{0x6E, 4},
|
||||
{0x70, 4},
|
||||
{0x71, 4},
|
||||
{0x72, 4},
|
||||
{0x73, 4},
|
||||
{0x74, 4},
|
||||
{0x76, 4},
|
||||
{0x77, 4},
|
||||
{0x78, 4},
|
||||
{0x79, 4},
|
||||
{0x7A, 4},
|
||||
{0xD1, 4},
|
||||
{0xF1, 4},
|
||||
{0x5B, 1},
|
||||
{0x7B, 1},
|
||||
{0x91, 1},
|
||||
{0x93, 1},
|
||||
{0x91, 1},
|
||||
{0x93, 1},
|
||||
{0xA2, 2},
|
||||
{0xA3, 2},
|
||||
{0xA5, 2},
|
||||
{0xA7, 2},
|
||||
{0xA9, 2},
|
||||
{0xAB, 1},
|
||||
{0x20A0, 2},
|
||||
{0x20A1, 2},
|
||||
{0x20A2, 2},
|
||||
{0x20A3, 2},
|
||||
{0x20A4, 2},
|
||||
{0x20A5, 2},
|
||||
{0x20A6, 2},
|
||||
{0x20A7, 2},
|
||||
{0x20A8, 2},
|
||||
{0x20A9, 2},
|
||||
{0x20AA, 2},
|
||||
{0x20AB, 2},
|
||||
{0x20AC, 2},
|
||||
{0x300C, 1},
|
||||
{0x300E, 1},
|
||||
{0x3010, 1},
|
||||
{0x3012, 2},
|
||||
{0x3014, 1},
|
||||
{0x3016, 1},
|
||||
{0x3018, 1},
|
||||
{0x301A, 1},
|
||||
{0xFF03, 2},
|
||||
{0xFF04, 2},
|
||||
{0xFF20, 2},
|
||||
{0xFF3C, 1},
|
||||
{0xFF5C, 1},
|
||||
{0xFFE0, 2},
|
||||
{0xFFE1, 2},
|
||||
{0xFFEF, 2},
|
||||
};
|
||||
|
||||
int CWordBreakTables::GetBeginRank(wchar_t ch)
|
||||
{
|
||||
auto search = std::lower_bound(std::cbegin(gCantBeginChars), std::cend(gCantBeginChars), ch,
|
||||
[](const CCharacterIdentifier& item, const wchar_t& test) -> bool {return item.chr < test;});
|
||||
if (search == std::cend(gCantBeginChars))
|
||||
return 5;
|
||||
return search->rank;
|
||||
}
|
||||
|
||||
int CWordBreakTables::GetEndRank(wchar_t ch)
|
||||
{
|
||||
auto search = std::lower_bound(std::cbegin(gCantEndChars), std::cend(gCantEndChars), ch,
|
||||
[](const CCharacterIdentifier& item, const wchar_t& test) -> bool {return item.chr < test;});
|
||||
if (search == std::cend(gCantEndChars))
|
||||
return 5;
|
||||
return search->rank;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +1,16 @@
|
|||
#ifndef __URDE_CWORDBREAKTABLES_HPP__
|
||||
#define __URDE_CWORDBREAKTABLES_HPP__
|
||||
|
||||
#include "RetroTypes.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
class CWordBreakTables
|
||||
{
|
||||
public:
|
||||
static int GetBeginRank(wchar_t ch);
|
||||
static int GetEndRank(wchar_t ch);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue