mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 06:28:19 +00:00
add new text renderer engine to support text buffering, cursors, text
marking and less character texture updates
This commit is contained in:
parent
75eddfec7a
commit
62c3074c88
File diff suppressed because it is too large
Load diff
|
@ -11,6 +11,18 @@ enum
|
||||||
TEXTFLAG_STOP_AT_END=4
|
TEXTFLAG_STOP_AT_END=4
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
TEXT_FONT_ICON_FONT = 0,
|
||||||
|
};
|
||||||
|
|
||||||
class CFont;
|
class CFont;
|
||||||
|
|
||||||
class CTextCursor
|
class CTextCursor
|
||||||
|
@ -30,6 +42,25 @@ public:
|
||||||
float m_FontSize;
|
float m_FontSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
class ITextRender : public IInterface
|
class ITextRender : public IInterface
|
||||||
{
|
{
|
||||||
MACRO_INTERFACE("textrender", 0)
|
MACRO_INTERFACE("textrender", 0)
|
||||||
|
@ -37,13 +68,29 @@ public:
|
||||||
virtual void SetCursor(CTextCursor *pCursor, float x, float y, float FontSize, int Flags) = 0;
|
virtual void SetCursor(CTextCursor *pCursor, float x, float y, float FontSize, int Flags) = 0;
|
||||||
|
|
||||||
virtual CFont *LoadFont(const char *pFilename) = 0;
|
virtual CFont *LoadFont(const char *pFilename) = 0;
|
||||||
|
virtual CFont *GetFont(int FontIndex) = 0;
|
||||||
|
virtual CFont *GetFont(const char *pFilename) = 0;
|
||||||
virtual void DestroyFont(CFont *pFont) = 0;
|
virtual void DestroyFont(CFont *pFont) = 0;
|
||||||
|
|
||||||
virtual void SetDefaultFont(CFont *pFont) = 0;
|
virtual void SetDefaultFont(CFont *pFont) = 0;
|
||||||
|
virtual void SetCurFont(CFont *pFont) = 0;
|
||||||
|
|
||||||
|
virtual void SetRenderFlags(unsigned int Flags) = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
virtual void TextEx(CTextCursor *pCursor, const char *pText, int Length) = 0;
|
virtual void TextEx(CTextCursor *pCursor, const char *pText, int Length) = 0;
|
||||||
virtual void UploadText(int TextureID, const char *pText, int Length, float x, float y, int Size, int MaxWidth, int MaxSize = -1, int MinSize = -1) = 0;
|
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;
|
||||||
|
|
||||||
// old foolish interface
|
// old foolish interface
|
||||||
virtual void TextColor(float r, float g, float b, float a) = 0;
|
virtual void TextColor(float r, float g, float b, float a) = 0;
|
||||||
|
|
|
@ -36,7 +36,7 @@ void CMapImages::OnInit()
|
||||||
|
|
||||||
float x = (i%16) * 64;
|
float x = (i%16) * 64;
|
||||||
float y = (int)(i/16)* 64;
|
float y = (int)(i/16)* 64;
|
||||||
TextRender()->UploadText(m_OverlayBottomTexture, buff, -1, x+1, y + 12 + 32, 20, 64-1);
|
TextRender()->UploadEntityLayerText(m_OverlayBottomTexture, buff, -1, x+1, y + 12 + 32, 20, 64-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(m_OverlayTopTexture == -1)
|
if(m_OverlayTopTexture == -1)
|
||||||
|
@ -53,7 +53,7 @@ void CMapImages::OnInit()
|
||||||
|
|
||||||
float x = (i%16) * 64;
|
float x = (i%16) * 64;
|
||||||
float y = (int)(i/16)* 64;
|
float y = (int)(i/16)* 64;
|
||||||
TextRender()->UploadText(m_OverlayTopTexture, buff, -1, x+1, y+1, 20, 64-1);
|
TextRender()->UploadEntityLayerText(m_OverlayTopTexture, buff, -1, x+1, y+1, 20, 64-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(m_OverlayCenterTexture == -1)
|
if(m_OverlayCenterTexture == -1)
|
||||||
|
@ -76,7 +76,7 @@ void CMapImages::OnInit()
|
||||||
int OffY = (len == 3 ? 10 : 5);
|
int OffY = (len == 3 ? 10 : 5);
|
||||||
int OffX = (len == 3 ? 5 : 1);
|
int OffX = (len == 3 ? 5 : 1);
|
||||||
|
|
||||||
TextRender()->UploadText(m_OverlayCenterTexture, buff, -1, x + OffX, y + OffY, -1, 64-(OffX*2), 64, MinSize);
|
TextRender()->UploadEntityLayerText(m_OverlayCenterTexture, buff, -1, x + OffX, y + OffY, -1, 64-(OffX*2), 64, MinSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue