2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#ifndef ENGINE_TEXTRENDER_H
|
|
|
|
#define ENGINE_TEXTRENDER_H
|
|
|
|
#include "kernel.h"
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
TEXTFLAG_RENDER=1,
|
|
|
|
TEXTFLAG_ALLOW_NEWLINE=2,
|
|
|
|
TEXTFLAG_STOP_AT_END=4
|
|
|
|
};
|
|
|
|
|
2018-03-13 20:49:07 +00:00
|
|
|
enum ETextRenderFlags
|
|
|
|
{
|
|
|
|
TEXT_RENDER_FLAG_NO_X_BEARING = 1<<0,
|
|
|
|
TEXT_RENDER_FLAG_NO_Y_BEARING = 1<<1,
|
|
|
|
TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH = 1<<2,
|
2018-03-21 14:43:56 +00:00
|
|
|
TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT = 1<<3,
|
2019-01-06 05:42:57 +00:00
|
|
|
TEXT_RENDER_FLAG_KERNING = 1<<4,
|
|
|
|
TEXT_RENDER_FLAG_NO_OVERSIZE = 1<<5,
|
|
|
|
TEXT_RENDER_FLAG_NO_FIRST_CHARACTER_X_BEARING = 1<<6,
|
|
|
|
TEXT_RENDER_FLAG_NO_LAST_CHARACTER_ADVANCE = 1<<7,
|
2018-03-13 20:49:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
TEXT_FONT_ICON_FONT = 0,
|
|
|
|
};
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
class CFont;
|
|
|
|
|
|
|
|
class CTextCursor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int m_Flags;
|
|
|
|
int m_LineCount;
|
|
|
|
int m_CharCount;
|
2010-10-11 00:29:30 +00:00
|
|
|
int m_MaxLines;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
float m_StartX;
|
|
|
|
float m_StartY;
|
|
|
|
float m_LineWidth;
|
|
|
|
float m_X, m_Y;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-07-05 18:57:07 +00:00
|
|
|
CFont *m_pFont;
|
2010-05-29 07:25:38 +00:00
|
|
|
float m_FontSize;
|
2018-03-21 14:43:56 +00:00
|
|
|
float m_AlignedFontSize;
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
2018-03-13 20:49:07 +00:00
|
|
|
struct STextRenderColor
|
|
|
|
{
|
|
|
|
STextRenderColor() {}
|
|
|
|
STextRenderColor(float r, float g, float b, float a)
|
|
|
|
{
|
|
|
|
Set(r, g, b, a);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Set(float r, float g, float b, float a)
|
|
|
|
{
|
|
|
|
m_R = r;
|
|
|
|
m_G = g;
|
|
|
|
m_B = b;
|
|
|
|
m_A = a;
|
|
|
|
}
|
|
|
|
|
|
|
|
float m_R, m_G, m_B, m_A;
|
|
|
|
};
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
class ITextRender : public IInterface
|
|
|
|
{
|
|
|
|
MACRO_INTERFACE("textrender", 0)
|
|
|
|
public:
|
|
|
|
virtual void SetCursor(CTextCursor *pCursor, float x, float y, float FontSize, int Flags) = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual CFont *LoadFont(const char *pFilename) = 0;
|
2018-03-13 20:49:07 +00:00
|
|
|
virtual CFont *GetFont(int FontIndex) = 0;
|
|
|
|
virtual CFont *GetFont(const char *pFilename) = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void DestroyFont(CFont *pFont) = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-07-05 18:57:07 +00:00
|
|
|
virtual void SetDefaultFont(CFont *pFont) = 0;
|
2018-03-13 20:49:07 +00:00
|
|
|
virtual void SetCurFont(CFont *pFont) = 0;
|
|
|
|
|
|
|
|
virtual void SetRenderFlags(unsigned int Flags) = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
virtual void TextEx(CTextCursor *pCursor, const char *pText, int Length) = 0;
|
2018-03-13 20:49:07 +00:00
|
|
|
virtual int CreateTextContainer(CTextCursor *pCursor, const char *pText) = 0;
|
|
|
|
virtual void AppendTextContainer(CTextCursor *pCursor, int TextContainerIndex, const char *pText) = 0;
|
|
|
|
// just deletes and creates text container
|
|
|
|
virtual void RecreateTextContainer(CTextCursor *pCursor, int TextContainerIndex, const char *pText) = 0;
|
|
|
|
virtual void RecreateTextContainerSoft(CTextCursor *pCursor, int TextContainerIndex, const char *pText) = 0;
|
|
|
|
virtual void SetTextContainerSelection(int TextContainerIndex, const char *pText, int CursorPos, int SelectionStart, int SelectionEnd) = 0;
|
|
|
|
virtual void DeleteTextContainer(int TextContainerIndex) = 0;
|
|
|
|
|
|
|
|
virtual void RenderTextContainer(int TextContainerIndex, STextRenderColor *pTextColor, STextRenderColor *pTextOutlineColor) = 0;
|
|
|
|
virtual void RenderTextContainer(int TextContainerIndex, STextRenderColor *pTextColor, STextRenderColor *pTextOutlineColor, float X, float Y) = 0;
|
|
|
|
|
|
|
|
virtual void UploadEntityLayerText(int TextureID, const char *pText, int Length, float x, float y, int Size, int MaxWidth, int MaxSize = -1, int MinSize = -1) = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
// old foolish interface
|
|
|
|
virtual void TextColor(float r, float g, float b, float a) = 0;
|
2011-03-13 11:55:00 +00:00
|
|
|
virtual void TextOutlineColor(float r, float g, float b, float a) = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void Text(void *pFontSetV, float x, float y, float Size, const char *pText, int MaxWidth) = 0;
|
2018-03-21 14:43:56 +00:00
|
|
|
virtual float TextWidth(void *pFontSetV, float Size, const char *pText, int Length, float *pAlignedHeight = NULL) = 0;
|
2010-08-16 00:21:18 +00:00
|
|
|
virtual int TextLineCount(void *pFontSetV, float Size, const char *pText, float LineWidth) = 0;
|
2018-03-21 14:43:56 +00:00
|
|
|
|
|
|
|
virtual void OnWindowResize() = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class IEngineTextRender : public ITextRender
|
|
|
|
{
|
|
|
|
MACRO_INTERFACE("enginetextrender", 0)
|
|
|
|
public:
|
|
|
|
virtual void Init() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern IEngineTextRender *CreateEngineTextRender();
|
|
|
|
|
|
|
|
#endif
|