forked from Mirrors/openclonk
Rename CMarkup to C4Markup
parent
6700bff4de
commit
efed250aa7
|
@ -408,8 +408,8 @@ set(OC_CLONK_SOURCES
|
|||
src/lib/StdColors.h
|
||||
src/lib/StdCompiler.cpp
|
||||
src/lib/StdCompiler.h
|
||||
src/lib/StdMarkup.cpp
|
||||
src/lib/StdMarkup.h
|
||||
src/lib/C4Markup.cpp
|
||||
src/lib/C4Markup.h
|
||||
src/lib/StdMesh.cpp
|
||||
src/lib/StdMesh.h
|
||||
src/lib/StdMeshLoader.h
|
||||
|
@ -886,7 +886,7 @@ add_executable(c4group
|
|||
src/c4group/C4Update.cpp
|
||||
src/lib/Standard.cpp
|
||||
src/c4group/CStdFile.cpp
|
||||
src/lib/StdMarkup.cpp
|
||||
src/lib/C4Markup.cpp
|
||||
src/lib/StdBuf.cpp
|
||||
src/lib/StdCompiler.cpp
|
||||
src/platform/StdFile.cpp
|
||||
|
@ -920,8 +920,8 @@ add_executable(c4script
|
|||
src/lib/StdBuf.h
|
||||
src/lib/StdCompiler.cpp
|
||||
src/lib/StdCompiler.h
|
||||
src/lib/StdMarkup.cpp
|
||||
src/lib/StdMarkup.h
|
||||
src/lib/C4Markup.cpp
|
||||
src/lib/C4Markup.h
|
||||
src/lib/StdResStr2.cpp
|
||||
src/lib/StdResStr2.h
|
||||
src/platform/GetTime.cpp
|
||||
|
|
|
@ -126,8 +126,8 @@ src/lib/StdBuf.cpp \
|
|||
src/lib/StdBuf.h \
|
||||
src/lib/StdCompiler.cpp \
|
||||
src/lib/StdCompiler.h \
|
||||
src/lib/StdMarkup.cpp \
|
||||
src/lib/StdMarkup.h \
|
||||
src/lib/C4Markup.cpp \
|
||||
src/lib/C4Markup.h \
|
||||
src/lib/StdResStr2.cpp \
|
||||
src/lib/StdResStr2.h \
|
||||
src/network/C4NetIO.cpp \
|
||||
|
|
|
@ -124,7 +124,7 @@ class C4ValueNumbers;
|
|||
class C4Viewport;
|
||||
class C4ViewportList;
|
||||
class C4ViewportWindow;
|
||||
class CMarkup;
|
||||
class C4Markup;
|
||||
class CStdFont;
|
||||
class CStdStream;
|
||||
class CStdVectorFont;
|
||||
|
|
|
@ -95,7 +95,7 @@ bool C4PlayerInfoCore::Load(C4Group &hGroup)
|
|||
PrefColorDw &= 0xffffff;
|
||||
PrefColor2Dw &= 0xffffff;
|
||||
// Validate name
|
||||
CMarkup::StripMarkup(PrefName);
|
||||
C4Markup::StripMarkup(PrefName);
|
||||
// Success
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ void C4MenuItem::DoTextProgress(int32_t &riByVal)
|
|||
if (IsSelectable || !*Caption) { TextDisplayProgress=-1; return; }
|
||||
// normal text: move forward in unbroken message, ignoring markup
|
||||
StdStrBuf sText(Caption);
|
||||
CMarkup MarkupChecker(false);
|
||||
C4Markup MarkupChecker(false);
|
||||
const char *szPos = sText.getPtr(Min<int>(TextDisplayProgress, sText.getLength()));
|
||||
while (riByVal && *szPos)
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "C4Include.h"
|
||||
#include <C4InputValidation.h>
|
||||
#include <C4Log.h>
|
||||
#include "StdMarkup.h"
|
||||
#include "C4Markup.h"
|
||||
|
||||
#include <cctype>
|
||||
|
||||
|
@ -94,7 +94,7 @@ namespace C4InVal
|
|||
case VAL_NameNoEmpty:
|
||||
case VAL_NameAllowEmpty:
|
||||
// no markup
|
||||
if (CMarkup::StripMarkup(&rsString)) { fValid = false; }
|
||||
if (C4Markup::StripMarkup(&rsString)) { fValid = false; }
|
||||
// trim spaces
|
||||
if (rsString.TrimSpaces()) fValid = false;
|
||||
// min length
|
||||
|
|
|
@ -113,7 +113,7 @@ bool LogSilent(const char *szMessage, bool fConsole)
|
|||
char *pDest = TimeMessage.getMData() + 11;
|
||||
|
||||
// copy rest of message, skip tags
|
||||
CMarkup Markup(false);
|
||||
C4Markup Markup(false);
|
||||
while (*pSrc)
|
||||
{
|
||||
Markup.SkipTags(&pSrc);
|
||||
|
|
|
@ -18,24 +18,24 @@
|
|||
// markup tags for fonts
|
||||
|
||||
#include "C4Include.h"
|
||||
#include <StdMarkup.h>
|
||||
#include <C4Markup.h>
|
||||
#include <StdDDraw2.h>
|
||||
|
||||
void CMarkupTagItalic::Apply(C4BltTransform &rBltTrf, bool fDoClr, DWORD &dwClr)
|
||||
void C4MarkupTagItalic::Apply(C4BltTransform &rBltTrf, bool fDoClr, DWORD &dwClr)
|
||||
{
|
||||
// do sheering
|
||||
rBltTrf.mat[1]-=0.3f;
|
||||
}
|
||||
|
||||
void CMarkupTagColor::Apply(C4BltTransform &rBltTrf, bool fDoClr, DWORD &dwClr)
|
||||
void C4MarkupTagColor::Apply(C4BltTransform &rBltTrf, bool fDoClr, DWORD &dwClr)
|
||||
{
|
||||
// set color
|
||||
if (fDoClr) dwClr = this->dwClr;
|
||||
}
|
||||
|
||||
bool CMarkup::Read(const char **ppText, bool fSkip)
|
||||
bool C4Markup::Read(const char **ppText, bool fSkip)
|
||||
{
|
||||
char Tag[50]; CMarkupTag *pNewTag=0; int iTagLen,iParLen;
|
||||
char Tag[50]; C4MarkupTag *pNewTag=0; int iTagLen,iParLen;
|
||||
// get tag
|
||||
if (!SCopyEnclosed(*ppText, '<', '>', Tag, 49)) return false;
|
||||
iTagLen=SLen(Tag);
|
||||
|
@ -66,7 +66,7 @@ bool CMarkup::Read(const char **ppText, bool fSkip)
|
|||
// no parameters
|
||||
if (szPars) return false;
|
||||
// create italic tag
|
||||
if (!fSkip) pNewTag=new CMarkupTagItalic();
|
||||
if (!fSkip) pNewTag=new C4MarkupTagItalic();
|
||||
}
|
||||
// colored
|
||||
else if (SEqual(Tag, "c"))
|
||||
|
@ -89,7 +89,7 @@ bool CMarkup::Read(const char **ppText, bool fSkip)
|
|||
// adjust alpha if not given
|
||||
if (iParLen<=6) dwClr|=0xff000000;
|
||||
// create color tag
|
||||
pNewTag=new CMarkupTagColor(dwClr);
|
||||
pNewTag=new C4MarkupTagColor(dwClr);
|
||||
}
|
||||
}
|
||||
// unknown tag
|
||||
|
@ -104,7 +104,7 @@ bool CMarkup::Read(const char **ppText, bool fSkip)
|
|||
|
||||
|
||||
|
||||
bool CMarkup::SkipTags(const char **ppText)
|
||||
bool C4Markup::SkipTags(const char **ppText)
|
||||
{
|
||||
// read tags as long as found
|
||||
while (**ppText=='<') if (!Read(ppText, true)) break;
|
||||
|
@ -112,10 +112,10 @@ bool CMarkup::SkipTags(const char **ppText)
|
|||
return !**ppText;
|
||||
}
|
||||
|
||||
bool CMarkup::StripMarkup(char *szText)
|
||||
bool C4Markup::StripMarkup(char *szText)
|
||||
{
|
||||
// skip any tags and inline-images
|
||||
CMarkup mkup(false);
|
||||
C4Markup mkup(false);
|
||||
const char *szRead = szText, *szPos2;
|
||||
do
|
||||
{
|
||||
|
@ -137,7 +137,7 @@ bool CMarkup::StripMarkup(char *szText)
|
|||
return szText != szRead;
|
||||
}
|
||||
|
||||
bool CMarkup::StripMarkup(StdStrBuf *sText)
|
||||
bool C4Markup::StripMarkup(StdStrBuf *sText)
|
||||
{
|
||||
// strip any markup codes from given text buffer
|
||||
char *buf = sText->GrabPointer();
|
|
@ -20,63 +20,61 @@
|
|||
#ifndef INC_STDMARKUP
|
||||
#define INC_STDMARKUP
|
||||
|
||||
struct FONT2DVERTEX;
|
||||
|
||||
// one markup tag
|
||||
class CMarkupTag
|
||||
class C4MarkupTag
|
||||
{
|
||||
public:
|
||||
CMarkupTag *pPrev, *pNext;
|
||||
C4MarkupTag *pPrev, *pNext;
|
||||
|
||||
CMarkupTag(): pPrev(0), pNext(0) { }; // ctor
|
||||
virtual ~CMarkupTag() { }; // dtor
|
||||
C4MarkupTag(): pPrev(0), pNext(0) { }; // ctor
|
||||
virtual ~C4MarkupTag() { }; // dtor
|
||||
|
||||
virtual void Apply(C4BltTransform &rBltTrf, bool fDoClr, DWORD &dwClr)=0; // assign markup
|
||||
virtual const char *TagName()=0; // get character string for this tag
|
||||
};
|
||||
|
||||
// markup tag for italic text
|
||||
class CMarkupTagItalic : public CMarkupTag
|
||||
class C4MarkupTagItalic : public C4MarkupTag
|
||||
{
|
||||
public:
|
||||
CMarkupTagItalic() : CMarkupTag() { } // ctor
|
||||
C4MarkupTagItalic() : C4MarkupTag() { } // ctor
|
||||
|
||||
virtual void Apply(C4BltTransform &rBltTrf, bool fDoClr, DWORD &dwClr); // assign markup
|
||||
virtual const char *TagName() { return "i"; }
|
||||
};
|
||||
|
||||
// markup tag for colored text
|
||||
class CMarkupTagColor : public CMarkupTag
|
||||
class C4MarkupTagColor : public C4MarkupTag
|
||||
{
|
||||
private:
|
||||
DWORD dwClr; // color
|
||||
public:
|
||||
CMarkupTagColor(DWORD dwClr) : CMarkupTag(), dwClr(dwClr) { } // ctor
|
||||
C4MarkupTagColor(DWORD dwClr) : C4MarkupTag(), dwClr(dwClr) { } // ctor
|
||||
|
||||
virtual void Apply(C4BltTransform &rBltTrf, bool fDoClr, DWORD &dwClr); // assign markup
|
||||
virtual const char *TagName() { return "c"; }
|
||||
};
|
||||
|
||||
// markup rendering functionality for text
|
||||
class CMarkup
|
||||
class C4Markup
|
||||
{
|
||||
private:
|
||||
CMarkupTag *pTags, *pLast; // tag list; single linked
|
||||
C4MarkupTag *pTags, *pLast; // tag list; single linked
|
||||
bool fDoClr; // set if color changes should be made (not in text shadow!)
|
||||
|
||||
void Push(CMarkupTag *pTag)
|
||||
void Push(C4MarkupTag *pTag)
|
||||
{ if ((pTag->pPrev=pLast)) pLast->pNext=pTag; else pTags=pTag; pLast=pTag; }
|
||||
CMarkupTag *Pop()
|
||||
{ CMarkupTag *pL=pLast; if (!pL) return 0; if ((pLast=pL->pPrev)) pLast->pNext=0; else pTags=0; return pL; }
|
||||
C4MarkupTag *Pop()
|
||||
{ C4MarkupTag *pL=pLast; if (!pL) return 0; if ((pLast=pL->pPrev)) pLast->pNext=0; else pTags=0; return pL; }
|
||||
public:
|
||||
CMarkup(bool fDoClr) { pTags=pLast=0; this->fDoClr=fDoClr; }; // ctor
|
||||
~CMarkup() // dtor
|
||||
{ CMarkupTag *pTag=pTags,*pNext; while (pTag) { pNext=pTag->pNext; delete pTag; pTag=pNext; } }
|
||||
C4Markup(bool fDoClr) { pTags=pLast=0; this->fDoClr=fDoClr; }; // ctor
|
||||
~C4Markup() // dtor
|
||||
{ C4MarkupTag *pTag=pTags,*pNext; while (pTag) { pNext=pTag->pNext; delete pTag; pTag=pNext; } }
|
||||
|
||||
bool Read(const char **ppText, bool fSkip=false); // get markup from text
|
||||
bool SkipTags(const char **ppText); // extract markup from text; return whether end is reached
|
||||
void Apply(C4BltTransform &rBltTrf, DWORD &dwClr) // assign markup to vertices
|
||||
{ for (CMarkupTag *pTag=pTags; pTag; pTag=pTag->pNext) pTag->Apply(rBltTrf, fDoClr, dwClr); }
|
||||
{ for (C4MarkupTag *pTag=pTags; pTag; pTag=pTag->pNext) pTag->Apply(rBltTrf, fDoClr, dwClr); }
|
||||
bool Clean() { return !pTags; } // empty?
|
||||
|
||||
static bool StripMarkup(char *szText); // strip any markup codes from given text buffer
|
|
@ -28,7 +28,7 @@
|
|||
#include <StdD3DShader.h>
|
||||
|
||||
#include <StdApp.h>
|
||||
#include <StdMarkup.h>
|
||||
#include <C4Markup.h>
|
||||
#include <StdWindow.h>
|
||||
#include <C4Config.h>
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <StdD3D.h>
|
||||
#include <StdGL.h>
|
||||
#include <StdNoGfx.h>
|
||||
#include <StdMarkup.h>
|
||||
#include <C4Markup.h>
|
||||
#include <StdFont.h>
|
||||
#include "C4Rect.h"
|
||||
#include <C4Config.h>
|
||||
|
@ -987,7 +987,7 @@ bool CStdDDraw::BlitSurfaceTile2(SURFACE sfcSurface, SURFACE sfcTarget, int iToX
|
|||
|
||||
bool CStdDDraw::TextOut(const char *szText, CStdFont &rFont, float fZoom, SURFACE sfcDest, float iTx, float iTy, DWORD dwFCol, BYTE byForm, bool fDoMarkup)
|
||||
{
|
||||
CMarkup Markup(true);
|
||||
C4Markup Markup(true);
|
||||
static char szLinebuf[2500+1];
|
||||
for (int cnt=0; SCopySegmentEx(szText,cnt,szLinebuf,fDoMarkup ? '|' : '\n','\n',2500); cnt++,iTy+=int(fZoom*rFont.iLineHgt))
|
||||
if (!StringOut(szLinebuf,sfcDest,iTx,iTy,dwFCol,byForm,fDoMarkup,Markup,&rFont,fZoom)) return false;
|
||||
|
@ -997,12 +997,12 @@ bool CStdDDraw::TextOut(const char *szText, CStdFont &rFont, float fZoom, SURFAC
|
|||
bool CStdDDraw::StringOut(const char *szText, CStdFont &rFont, float fZoom, SURFACE sfcDest, float iTx, float iTy, DWORD dwFCol, BYTE byForm, bool fDoMarkup)
|
||||
{
|
||||
// init markup
|
||||
CMarkup Markup(true);
|
||||
C4Markup Markup(true);
|
||||
// output string
|
||||
return StringOut(szText, sfcDest, iTx, iTy, dwFCol, byForm, fDoMarkup, Markup, &rFont, fZoom);
|
||||
}
|
||||
|
||||
bool CStdDDraw::StringOut(const char *szText, SURFACE sfcDest, float iTx, float iTy, DWORD dwFCol, BYTE byForm, bool fDoMarkup, CMarkup &Markup, CStdFont *pFont, float fZoom)
|
||||
bool CStdDDraw::StringOut(const char *szText, SURFACE sfcDest, float iTx, float iTy, DWORD dwFCol, BYTE byForm, bool fDoMarkup, C4Markup &Markup, CStdFont *pFont, float fZoom)
|
||||
{
|
||||
// clip
|
||||
if (ClipAll) return true;
|
||||
|
|
|
@ -327,7 +327,7 @@ public:
|
|||
int GetByteCnt() { return byByteCnt; } // return bytes per pixel
|
||||
|
||||
protected:
|
||||
bool StringOut(const char *szText, SURFACE sfcDest, float iTx, float iTy, DWORD dwFCol, BYTE byForm, bool fDoMarkup, CMarkup &Markup, CStdFont *pFont, float fZoom);
|
||||
bool StringOut(const char *szText, SURFACE sfcDest, float iTx, float iTy, DWORD dwFCol, BYTE byForm, bool fDoMarkup, C4Markup &Markup, CStdFont *pFont, float fZoom);
|
||||
virtual void PerformPix(SURFACE sfcDest, float tx, float ty, DWORD dwCol) = 0; // without ClrModMap
|
||||
virtual void PerformLine(SURFACE sfcTarget, float x1, float y1, float x2, float y2, DWORD dwClr) = 0;
|
||||
bool CreatePrimaryClipper(unsigned int iXRes, unsigned int iYRes);
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <StdBuf.h>
|
||||
#include <StdDDraw2.h>
|
||||
#include <StdSurface2.h>
|
||||
#include <StdMarkup.h>
|
||||
#include <C4Markup.h>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
|
@ -410,7 +410,7 @@ bool CStdFont::GetTextExtent(const char *szText, int32_t &rsx, int32_t &rsy, boo
|
|||
// keep track of each row's size
|
||||
int iRowWdt=0,iWdt=0,iHgt=iLineHgt;
|
||||
// ignore any markup
|
||||
CMarkup MarkupChecker(false);
|
||||
C4Markup MarkupChecker(false);
|
||||
// go through all text
|
||||
while (*szText)
|
||||
{
|
||||
|
@ -490,7 +490,7 @@ int CStdFont::BreakMessage(const char *szMsg, int iWdt, char *szOut, int iMaxOut
|
|||
iHgt=iLineHgt; // total height of output text
|
||||
bool fIsFirstLineChar = true;
|
||||
// ignore any markup
|
||||
CMarkup MarkupChecker(false);
|
||||
C4Markup MarkupChecker(false);
|
||||
// go through all text
|
||||
while (*(szLastPos = szPos))
|
||||
{
|
||||
|
@ -646,7 +646,7 @@ int CStdFont::BreakMessage(const char *szMsg, int iWdt, StdStrBuf *pOut, bool fC
|
|||
iHgt=iLineHgt; // total height of output text
|
||||
bool fIsFirstLineChar = true;
|
||||
// ignore any markup
|
||||
CMarkup MarkupChecker(false);
|
||||
C4Markup MarkupChecker(false);
|
||||
// go through all text
|
||||
while (*(szLastPos = szPos))
|
||||
{
|
||||
|
@ -819,7 +819,7 @@ int CStdFont::GetMessageBreak(const char *szMsg, const char **ppNewPos, int iBre
|
|||
/* Text drawing */
|
||||
|
||||
|
||||
void CStdFont::DrawText(SURFACE sfcDest, float iX, float iY, DWORD dwColor, const char *szText, DWORD dwFlags, CMarkup &Markup, float fZoom)
|
||||
void CStdFont::DrawText(SURFACE sfcDest, float iX, float iY, DWORD dwColor, const char *szText, DWORD dwFlags, C4Markup &Markup, float fZoom)
|
||||
{
|
||||
assert(IsValidUtf8(szText));
|
||||
C4BltTransform bt, *pbt=NULL;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#ifndef INC_STDFONT
|
||||
#define INC_STDFONT
|
||||
|
||||
#include <StdMarkup.h>
|
||||
#include <C4Markup.h>
|
||||
#include <C4Facet.h>
|
||||
#include <StdBuf.h>
|
||||
#include <stdio.h>
|
||||
|
@ -42,7 +42,7 @@
|
|||
#define FW_BOLD 700
|
||||
#endif
|
||||
|
||||
class CMarkup;
|
||||
class C4Markup;
|
||||
class CStdVectorFont;
|
||||
|
||||
class CStdFont
|
||||
|
@ -108,7 +108,7 @@ protected:
|
|||
public:
|
||||
int iLineHgt; // height of one line of font (in pixels)
|
||||
// draw ine line of text
|
||||
void DrawText(SURFACE sfcDest, float iX, float iY, DWORD dwColor, const char *szText, DWORD dwFlags, CMarkup &Markup, float fZoom);
|
||||
void DrawText(SURFACE sfcDest, float iX, float iY, DWORD dwColor, const char *szText, DWORD dwFlags, C4Markup &Markup, float fZoom);
|
||||
|
||||
// get text size
|
||||
bool GetTextExtent(const char *szText, int32_t &rsx, int32_t &rsy, bool fCheckMarkup = true);
|
||||
|
|
Loading…
Reference in New Issue