2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-03-19 00:07:31 +00:00
|
|
|
|
|
|
|
#include "CToken.hpp"
|
|
|
|
#include "CGuiTextSupport.hpp"
|
2016-03-20 06:37:08 +00:00
|
|
|
#include "CFontImageDef.hpp"
|
2016-03-19 00:07:31 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2016-03-19 00:07:31 +00:00
|
|
|
class CFontRenderState;
|
|
|
|
class CTextRenderBuffer;
|
2016-03-20 06:37:08 +00:00
|
|
|
class CFontImageDef;
|
2016-03-19 00:07:31 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CInstruction {
|
2016-03-19 00:07:31 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
virtual ~CInstruction() = default;
|
|
|
|
virtual void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const = 0;
|
|
|
|
virtual void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
|
|
|
|
virtual void GetAssets(std::vector<CToken>& assetsOut) const;
|
|
|
|
virtual size_t GetAssetCount() const;
|
2016-03-19 00:07:31 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CColorInstruction : public CInstruction {
|
|
|
|
EColorType x4_cType;
|
|
|
|
CTextColor x8_color;
|
|
|
|
|
2016-03-19 00:07:31 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CColorInstruction(EColorType tp, const CTextColor& color) : x4_cType(tp), x8_color(color) {}
|
2019-08-09 12:45:18 +00:00
|
|
|
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
|
|
|
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
2016-03-19 00:07:31 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CColorOverrideInstruction : public CInstruction {
|
|
|
|
int x4_overrideIdx;
|
|
|
|
CTextColor x8_color;
|
|
|
|
|
2016-03-19 00:07:31 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CColorOverrideInstruction(int idx, const CTextColor& color) : x4_overrideIdx(idx), x8_color(color) {}
|
2019-08-09 12:45:18 +00:00
|
|
|
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
|
|
|
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
2016-03-19 00:07:31 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CFontInstruction : public CInstruction {
|
|
|
|
TLockedToken<CRasterFont> x4_font;
|
|
|
|
|
2016-03-19 03:58:01 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CFontInstruction(const TToken<CRasterFont>& font) : x4_font(font) {}
|
2019-08-09 12:45:18 +00:00
|
|
|
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
|
|
|
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
|
|
|
void GetAssets(std::vector<CToken>& assetsOut) const override;
|
|
|
|
size_t GetAssetCount() const override;
|
2016-03-19 00:07:31 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CLineExtraSpaceInstruction : public CInstruction {
|
|
|
|
s32 x4_extraSpace;
|
|
|
|
|
2016-03-19 03:58:01 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CLineExtraSpaceInstruction(s32 extraSpace) : x4_extraSpace(extraSpace) {}
|
2019-08-09 12:45:18 +00:00
|
|
|
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
|
|
|
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
2016-03-19 00:07:31 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CLineInstruction : public CInstruction {
|
|
|
|
friend class CTextExecuteBuffer;
|
|
|
|
friend class CTextInstruction;
|
|
|
|
friend class CImageInstruction;
|
|
|
|
friend class CWordInstruction;
|
|
|
|
|
|
|
|
s32 x4_wordCount = 0;
|
|
|
|
s32 x8_curX = 0;
|
|
|
|
s32 xc_curY = 0;
|
|
|
|
s32 x10_largestMonoHeight = 0;
|
|
|
|
s32 x14_largestMonoWidth = 0;
|
|
|
|
s32 x18_largestMonoBaseline = 0;
|
|
|
|
s32 x1c_largestImageHeight = 0;
|
|
|
|
s32 x20_largestImageWidth = 0;
|
|
|
|
s32 x24_largestImageBaseline = 0;
|
|
|
|
EJustification x28_just;
|
|
|
|
EVerticalJustification x2c_vjust;
|
|
|
|
bool x30_imageBaseline;
|
|
|
|
|
2016-03-19 03:58:01 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CLineInstruction(EJustification just, EVerticalJustification vjust, bool imageBaseline)
|
|
|
|
: 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;
|
2019-08-09 12:45:18 +00:00
|
|
|
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
|
|
|
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
s32 GetHeight() const {
|
|
|
|
if (x10_largestMonoHeight && !x30_imageBaseline)
|
|
|
|
return x10_largestMonoHeight;
|
|
|
|
else
|
|
|
|
return x1c_largestImageHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 GetBaseline() const {
|
|
|
|
if (x10_largestMonoHeight && !x30_imageBaseline)
|
|
|
|
return x18_largestMonoBaseline;
|
|
|
|
else
|
|
|
|
return x24_largestImageBaseline;
|
|
|
|
}
|
2016-03-19 00:07:31 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CLineSpacingInstruction : public CInstruction {
|
|
|
|
float x4_lineSpacing;
|
|
|
|
|
2016-03-20 00:32:30 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CLineSpacingInstruction(float spacing) : x4_lineSpacing(spacing) {}
|
2019-08-09 12:45:18 +00:00
|
|
|
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
|
|
|
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
2016-03-19 00:07:31 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CPopStateInstruction : public CInstruction {
|
2016-03-20 00:32:30 +00:00
|
|
|
public:
|
2019-08-09 12:45:18 +00:00
|
|
|
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
|
|
|
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
2016-03-19 00:07:31 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CPushStateInstruction : public CInstruction {
|
2016-03-20 00:32:30 +00:00
|
|
|
public:
|
2019-08-09 12:45:18 +00:00
|
|
|
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
|
|
|
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
2016-03-19 00:07:31 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CRemoveColorOverrideInstruction : public CInstruction {
|
|
|
|
int x4_idx;
|
|
|
|
|
2016-03-20 00:32:30 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CRemoveColorOverrideInstruction(int idx) : x4_idx(idx) {}
|
2019-08-09 12:45:18 +00:00
|
|
|
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
|
|
|
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
2016-03-19 00:07:31 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CImageInstruction : public CInstruction {
|
|
|
|
CFontImageDef x4_image;
|
|
|
|
|
2016-03-20 00:32:30 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CImageInstruction(const CFontImageDef& image) : x4_image(image) {}
|
2019-08-09 12:45:18 +00:00
|
|
|
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
|
|
|
void GetAssets(std::vector<CToken>& assetsOut) const override;
|
|
|
|
size_t GetAssetCount() const override;
|
2016-03-19 00:07:31 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CTextInstruction : public CInstruction {
|
|
|
|
std::u16string x4_str; /* used to be a placement-new sized allocation */
|
2016-03-20 00:32:30 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CTextInstruction(const char16_t* str, int len) : x4_str(str, len) {}
|
2019-08-09 12:45:18 +00:00
|
|
|
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
2016-03-19 00:07:31 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CBlockInstruction : public CInstruction {
|
|
|
|
friend class CTextExecuteBuffer;
|
|
|
|
friend class CLineInstruction;
|
|
|
|
friend class CImageInstruction;
|
|
|
|
friend class CTextInstruction;
|
|
|
|
friend class CWordInstruction;
|
|
|
|
|
|
|
|
s32 x4_offsetX;
|
|
|
|
s32 x8_offsetY;
|
|
|
|
s32 xc_blockExtentX;
|
|
|
|
s32 x10_blockExtentY;
|
|
|
|
ETextDirection x14_dir;
|
|
|
|
EJustification x18_justification;
|
|
|
|
EVerticalJustification x1c_vertJustification;
|
|
|
|
s32 x20_largestMonoW = 0;
|
|
|
|
s32 x24_largestMonoH = 0;
|
|
|
|
s32 x28_largestBaseline = 0;
|
|
|
|
s32 x2c_lineX = 0;
|
|
|
|
s32 x30_lineY = 0;
|
|
|
|
s32 x34_lineCount = 0;
|
|
|
|
|
2016-03-19 03:58:01 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CBlockInstruction(s32 offX, s32 offY, s32 extX, s32 extY, ETextDirection dir, EJustification just,
|
|
|
|
EVerticalJustification vjust)
|
|
|
|
: x4_offsetX(offX)
|
|
|
|
, x8_offsetY(offY)
|
|
|
|
, xc_blockExtentX(extX)
|
|
|
|
, x10_blockExtentY(extY)
|
|
|
|
, x14_dir(dir)
|
|
|
|
, x18_justification(just)
|
|
|
|
, x1c_vertJustification(vjust) {}
|
|
|
|
void TestLargestFont(s32 monoW, s32 monoH, s32 baseline);
|
|
|
|
void SetupPositionLTR(CFontRenderState& state) const;
|
2019-08-09 12:45:18 +00:00
|
|
|
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
|
|
|
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
2016-03-19 00:07:31 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CWordInstruction : public CInstruction {
|
2016-03-20 00:32:30 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
void InvokeLTR(CFontRenderState& state) const;
|
2019-08-09 12:45:18 +00:00
|
|
|
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
|
|
|
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const override;
|
2016-03-19 00:07:31 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|