metaforce/Runtime/GuiSys/CInstruction.hpp

184 lines
5.9 KiB
C++
Raw Normal View History

2016-03-19 00:07:31 +00:00
#ifndef __URDE_CINSTRUCTION_HPP__
#define __URDE_CINSTRUCTION_HPP__
#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>
namespace urde
{
class CFontRenderState;
class CTextRenderBuffer;
2016-03-20 06:37:08 +00:00
class CFontImageDef;
2016-03-19 00:07:31 +00:00
class CInstruction
{
public:
virtual ~CInstruction() = default;
virtual void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const=0;
2016-12-31 00:51:51 +00:00
virtual void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-03-19 00:07:31 +00:00
virtual void GetAssets(std::vector<CToken>& assetsOut) const;
virtual size_t GetAssetCount() const;
};
class CColorInstruction : public CInstruction
{
EColorType x4_cType;
CTextColor x8_color;
public:
2016-03-19 03:58:01 +00:00
CColorInstruction(EColorType tp, const CTextColor& color)
: x4_cType(tp), x8_color(color) {}
2016-03-19 00:07:31 +00:00
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-12-31 00:51:51 +00:00
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-03-19 00:07:31 +00:00
};
class CColorOverrideInstruction : public CInstruction
{
int x4_overrideIdx;
CTextColor x8_color;
public:
2016-03-19 03:58:01 +00:00
CColorOverrideInstruction(int idx, const CTextColor& color)
: x4_overrideIdx(idx), x8_color(color) {}
2016-03-19 00:07:31 +00:00
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-12-31 00:51:51 +00:00
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-03-19 00:07:31 +00:00
};
class CFontInstruction : public CInstruction
{
2016-03-19 03:58:01 +00:00
TLockedToken<CRasterFont> x4_font;
public:
CFontInstruction(const TToken<CRasterFont>& font) : x4_font(font) {}
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-12-31 00:51:51 +00:00
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-03-19 03:58:01 +00:00
void GetAssets(std::vector<CToken>& assetsOut) const;
size_t GetAssetCount() const;
2016-03-19 00:07:31 +00:00
};
2016-03-20 00:32:30 +00:00
class CLineExtraSpaceInstruction : public CInstruction
2016-03-19 00:07:31 +00:00
{
2016-03-19 03:58:01 +00:00
s32 x4_extraSpace;
public:
2016-03-20 00:32:30 +00:00
CLineExtraSpaceInstruction(s32 extraSpace) : x4_extraSpace(extraSpace) {}
2016-03-19 03:58:01 +00:00
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-12-31 00:51:51 +00:00
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-03-19 00:07:31 +00:00
};
class CLineInstruction : public CInstruction
{
2016-03-20 00:32:30 +00:00
friend class CTextExecuteBuffer;
2016-03-20 06:37:08 +00:00
friend class CTextInstruction;
2016-03-21 00:25:53 +00:00
friend class CImageInstruction;
friend class CWordInstruction;
s32 x4_wordCount = 0;
2016-03-20 00:32:30 +00:00
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;
2016-03-19 03:58:01 +00:00
public:
2016-03-20 00:32:30 +00:00
CLineInstruction(EJustification just, EVerticalJustification vjust)
: x1c_just(just), x20_vjust(vjust) {}
2016-03-20 06:37:08 +00:00
void TestLargestFont(s32 monoW, s32 monoH, s32 baseline);
2016-03-19 03:58:01 +00:00
void InvokeLTR(CFontRenderState& state) const;
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-12-31 00:51:51 +00:00
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-03-19 00:07:31 +00:00
};
class CLineSpacingInstruction : public CInstruction
{
2016-03-20 00:32:30 +00:00
float x4_lineSpacing;
public:
CLineSpacingInstruction(float spacing) : x4_lineSpacing(spacing) {}
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-12-31 00:51:51 +00:00
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-03-19 00:07:31 +00:00
};
class CPopStateInstruction : public CInstruction
{
2016-03-20 00:32:30 +00:00
public:
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-12-31 00:51:51 +00:00
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-03-19 00:07:31 +00:00
};
class CPushStateInstruction : public CInstruction
{
2016-03-20 00:32:30 +00:00
public:
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-12-31 00:51:51 +00:00
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-03-19 00:07:31 +00:00
};
class CRemoveColorOverrideInstruction : public CInstruction
{
2016-03-20 00:32:30 +00:00
int x4_idx;
public:
CRemoveColorOverrideInstruction(int idx) : x4_idx(idx) {}
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-12-31 00:51:51 +00:00
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-03-19 00:07:31 +00:00
};
class CImageInstruction : public CInstruction
{
2016-03-21 00:25:53 +00:00
CFontImageDef x4_image;
2016-03-20 00:32:30 +00:00
public:
2016-03-21 00:25:53 +00:00
CImageInstruction(const CFontImageDef& image) : x4_image(image) {}
2016-03-20 00:32:30 +00:00
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-12-31 00:51:51 +00:00
void GetAssets(std::vector<CToken>& assetsOut) const;
size_t GetAssetCount() const;
2016-03-19 00:07:31 +00:00
};
class CTextInstruction : public CInstruction
{
2016-03-20 06:37:08 +00:00
std::wstring x4_str; /* used to be a placement-new sized allocation */
2016-03-20 00:32:30 +00:00
public:
2016-03-20 06:37:08 +00:00
CTextInstruction(const wchar_t* str, int len) : x4_str(str, len) {}
2016-03-20 00:32:30 +00:00
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-03-19 00:07:31 +00:00
};
class CBlockInstruction : public CInstruction
{
2016-03-19 03:58:01 +00:00
friend class CTextExecuteBuffer;
2016-03-20 06:37:08 +00:00
friend class CLineInstruction;
2016-03-21 00:25:53 +00:00
friend class CImageInstruction;
friend class CWordInstruction;
2016-03-20 06:37:08 +00:00
s32 x4_offsetX;
s32 x8_offsetY;
2016-03-22 02:27:46 +00:00
s32 xc_blockExtentX;
s32 x10_blockExtentY;
2016-03-19 03:58:01 +00:00
ETextDirection x14_direction;
EJustification x18_justification;
EVerticalJustification x1c_vertJustification;
2016-03-20 06:37:08 +00:00
s32 x20_largestMonoW = 0;
s32 x24_largestMonoH = 0;
s32 x28_largestBaseline = 0;
s32 x2c_lineX = 0;
2016-03-20 00:32:30 +00:00
s32 x30_lineY = 0;
s32 x34_lineCount = 0;
2016-03-19 03:58:01 +00:00
public:
2016-03-22 02:27:46 +00:00
CBlockInstruction(s32 offX, s32 offY, s32 extX, s32 extY, ETextDirection dir,
2016-03-19 03:58:01 +00:00
EJustification just, EVerticalJustification vjust)
2016-03-20 06:37:08 +00:00
: x4_offsetX(offX), x8_offsetY(offY),
2016-03-22 02:27:46 +00:00
xc_blockExtentX(extX), x10_blockExtentY(extY), x14_direction(dir),
2016-03-19 03:58:01 +00:00
x18_justification(just), x1c_vertJustification(vjust) {}
2016-03-20 06:37:08 +00:00
void TestLargestFont(s32 monoW, s32 monoH, s32 baseline);
void SetupPositionLTR(CFontRenderState& state) const;
2016-03-19 03:58:01 +00:00
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-12-31 00:51:51 +00:00
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-03-19 00:07:31 +00:00
};
class CWordInstruction : public CInstruction
{
2016-03-20 00:32:30 +00:00
public:
2016-03-21 00:25:53 +00:00
void InvokeLTR(CFontRenderState& state) const;
2016-03-20 00:32:30 +00:00
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-12-31 00:51:51 +00:00
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
2016-03-19 00:07:31 +00:00
};
}
#endif // __URDE_CINSTRUCTION_HPP__