Rename CMarkup to C4Markup

Günther Brammer 2011-08-27 21:13:15 +02:00
parent 6700bff4de
commit efed250aa7
14 changed files with 55 additions and 57 deletions

View File

@ -408,8 +408,8 @@ set(OC_CLONK_SOURCES
src/lib/StdColors.h src/lib/StdColors.h
src/lib/StdCompiler.cpp src/lib/StdCompiler.cpp
src/lib/StdCompiler.h src/lib/StdCompiler.h
src/lib/StdMarkup.cpp src/lib/C4Markup.cpp
src/lib/StdMarkup.h src/lib/C4Markup.h
src/lib/StdMesh.cpp src/lib/StdMesh.cpp
src/lib/StdMesh.h src/lib/StdMesh.h
src/lib/StdMeshLoader.h src/lib/StdMeshLoader.h
@ -886,7 +886,7 @@ add_executable(c4group
src/c4group/C4Update.cpp src/c4group/C4Update.cpp
src/lib/Standard.cpp src/lib/Standard.cpp
src/c4group/CStdFile.cpp src/c4group/CStdFile.cpp
src/lib/StdMarkup.cpp src/lib/C4Markup.cpp
src/lib/StdBuf.cpp src/lib/StdBuf.cpp
src/lib/StdCompiler.cpp src/lib/StdCompiler.cpp
src/platform/StdFile.cpp src/platform/StdFile.cpp
@ -920,8 +920,8 @@ add_executable(c4script
src/lib/StdBuf.h src/lib/StdBuf.h
src/lib/StdCompiler.cpp src/lib/StdCompiler.cpp
src/lib/StdCompiler.h src/lib/StdCompiler.h
src/lib/StdMarkup.cpp src/lib/C4Markup.cpp
src/lib/StdMarkup.h src/lib/C4Markup.h
src/lib/StdResStr2.cpp src/lib/StdResStr2.cpp
src/lib/StdResStr2.h src/lib/StdResStr2.h
src/platform/GetTime.cpp src/platform/GetTime.cpp

View File

@ -126,8 +126,8 @@ src/lib/StdBuf.cpp \
src/lib/StdBuf.h \ src/lib/StdBuf.h \
src/lib/StdCompiler.cpp \ src/lib/StdCompiler.cpp \
src/lib/StdCompiler.h \ src/lib/StdCompiler.h \
src/lib/StdMarkup.cpp \ src/lib/C4Markup.cpp \
src/lib/StdMarkup.h \ src/lib/C4Markup.h \
src/lib/StdResStr2.cpp \ src/lib/StdResStr2.cpp \
src/lib/StdResStr2.h \ src/lib/StdResStr2.h \
src/network/C4NetIO.cpp \ src/network/C4NetIO.cpp \

View File

@ -124,7 +124,7 @@ class C4ValueNumbers;
class C4Viewport; class C4Viewport;
class C4ViewportList; class C4ViewportList;
class C4ViewportWindow; class C4ViewportWindow;
class CMarkup; class C4Markup;
class CStdFont; class CStdFont;
class CStdStream; class CStdStream;
class CStdVectorFont; class CStdVectorFont;

View File

@ -95,7 +95,7 @@ bool C4PlayerInfoCore::Load(C4Group &hGroup)
PrefColorDw &= 0xffffff; PrefColorDw &= 0xffffff;
PrefColor2Dw &= 0xffffff; PrefColor2Dw &= 0xffffff;
// Validate name // Validate name
CMarkup::StripMarkup(PrefName); C4Markup::StripMarkup(PrefName);
// Success // Success
return true; return true;
} }

View File

@ -88,7 +88,7 @@ void C4MenuItem::DoTextProgress(int32_t &riByVal)
if (IsSelectable || !*Caption) { TextDisplayProgress=-1; return; } if (IsSelectable || !*Caption) { TextDisplayProgress=-1; return; }
// normal text: move forward in unbroken message, ignoring markup // normal text: move forward in unbroken message, ignoring markup
StdStrBuf sText(Caption); StdStrBuf sText(Caption);
CMarkup MarkupChecker(false); C4Markup MarkupChecker(false);
const char *szPos = sText.getPtr(Min<int>(TextDisplayProgress, sText.getLength())); const char *szPos = sText.getPtr(Min<int>(TextDisplayProgress, sText.getLength()));
while (riByVal && *szPos) while (riByVal && *szPos)
{ {

View File

@ -22,7 +22,7 @@
#include "C4Include.h" #include "C4Include.h"
#include <C4InputValidation.h> #include <C4InputValidation.h>
#include <C4Log.h> #include <C4Log.h>
#include "StdMarkup.h" #include "C4Markup.h"
#include <cctype> #include <cctype>
@ -94,7 +94,7 @@ namespace C4InVal
case VAL_NameNoEmpty: case VAL_NameNoEmpty:
case VAL_NameAllowEmpty: case VAL_NameAllowEmpty:
// no markup // no markup
if (CMarkup::StripMarkup(&rsString)) { fValid = false; } if (C4Markup::StripMarkup(&rsString)) { fValid = false; }
// trim spaces // trim spaces
if (rsString.TrimSpaces()) fValid = false; if (rsString.TrimSpaces()) fValid = false;
// min length // min length

View File

@ -113,7 +113,7 @@ bool LogSilent(const char *szMessage, bool fConsole)
char *pDest = TimeMessage.getMData() + 11; char *pDest = TimeMessage.getMData() + 11;
// copy rest of message, skip tags // copy rest of message, skip tags
CMarkup Markup(false); C4Markup Markup(false);
while (*pSrc) while (*pSrc)
{ {
Markup.SkipTags(&pSrc); Markup.SkipTags(&pSrc);

View File

@ -18,24 +18,24 @@
// markup tags for fonts // markup tags for fonts
#include "C4Include.h" #include "C4Include.h"
#include <StdMarkup.h> #include <C4Markup.h>
#include <StdDDraw2.h> #include <StdDDraw2.h>
void CMarkupTagItalic::Apply(C4BltTransform &rBltTrf, bool fDoClr, DWORD &dwClr) void C4MarkupTagItalic::Apply(C4BltTransform &rBltTrf, bool fDoClr, DWORD &dwClr)
{ {
// do sheering // do sheering
rBltTrf.mat[1]-=0.3f; 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 // set color
if (fDoClr) dwClr = this->dwClr; 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 // get tag
if (!SCopyEnclosed(*ppText, '<', '>', Tag, 49)) return false; if (!SCopyEnclosed(*ppText, '<', '>', Tag, 49)) return false;
iTagLen=SLen(Tag); iTagLen=SLen(Tag);
@ -66,7 +66,7 @@ bool CMarkup::Read(const char **ppText, bool fSkip)
// no parameters // no parameters
if (szPars) return false; if (szPars) return false;
// create italic tag // create italic tag
if (!fSkip) pNewTag=new CMarkupTagItalic(); if (!fSkip) pNewTag=new C4MarkupTagItalic();
} }
// colored // colored
else if (SEqual(Tag, "c")) else if (SEqual(Tag, "c"))
@ -89,7 +89,7 @@ bool CMarkup::Read(const char **ppText, bool fSkip)
// adjust alpha if not given // adjust alpha if not given
if (iParLen<=6) dwClr|=0xff000000; if (iParLen<=6) dwClr|=0xff000000;
// create color tag // create color tag
pNewTag=new CMarkupTagColor(dwClr); pNewTag=new C4MarkupTagColor(dwClr);
} }
} }
// unknown tag // 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 // read tags as long as found
while (**ppText=='<') if (!Read(ppText, true)) break; while (**ppText=='<') if (!Read(ppText, true)) break;
@ -112,10 +112,10 @@ bool CMarkup::SkipTags(const char **ppText)
return !**ppText; return !**ppText;
} }
bool CMarkup::StripMarkup(char *szText) bool C4Markup::StripMarkup(char *szText)
{ {
// skip any tags and inline-images // skip any tags and inline-images
CMarkup mkup(false); C4Markup mkup(false);
const char *szRead = szText, *szPos2; const char *szRead = szText, *szPos2;
do do
{ {
@ -137,7 +137,7 @@ bool CMarkup::StripMarkup(char *szText)
return szText != szRead; return szText != szRead;
} }
bool CMarkup::StripMarkup(StdStrBuf *sText) bool C4Markup::StripMarkup(StdStrBuf *sText)
{ {
// strip any markup codes from given text buffer // strip any markup codes from given text buffer
char *buf = sText->GrabPointer(); char *buf = sText->GrabPointer();

View File

@ -20,63 +20,61 @@
#ifndef INC_STDMARKUP #ifndef INC_STDMARKUP
#define INC_STDMARKUP #define INC_STDMARKUP
struct FONT2DVERTEX;
// one markup tag // one markup tag
class CMarkupTag class C4MarkupTag
{ {
public: public:
CMarkupTag *pPrev, *pNext; C4MarkupTag *pPrev, *pNext;
CMarkupTag(): pPrev(0), pNext(0) { }; // ctor C4MarkupTag(): pPrev(0), pNext(0) { }; // ctor
virtual ~CMarkupTag() { }; // dtor virtual ~C4MarkupTag() { }; // dtor
virtual void Apply(C4BltTransform &rBltTrf, bool fDoClr, DWORD &dwClr)=0; // assign markup virtual void Apply(C4BltTransform &rBltTrf, bool fDoClr, DWORD &dwClr)=0; // assign markup
virtual const char *TagName()=0; // get character string for this tag virtual const char *TagName()=0; // get character string for this tag
}; };
// markup tag for italic text // markup tag for italic text
class CMarkupTagItalic : public CMarkupTag class C4MarkupTagItalic : public C4MarkupTag
{ {
public: public:
CMarkupTagItalic() : CMarkupTag() { } // ctor C4MarkupTagItalic() : C4MarkupTag() { } // ctor
virtual void Apply(C4BltTransform &rBltTrf, bool fDoClr, DWORD &dwClr); // assign markup virtual void Apply(C4BltTransform &rBltTrf, bool fDoClr, DWORD &dwClr); // assign markup
virtual const char *TagName() { return "i"; } virtual const char *TagName() { return "i"; }
}; };
// markup tag for colored text // markup tag for colored text
class CMarkupTagColor : public CMarkupTag class C4MarkupTagColor : public C4MarkupTag
{ {
private: private:
DWORD dwClr; // color DWORD dwClr; // color
public: 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 void Apply(C4BltTransform &rBltTrf, bool fDoClr, DWORD &dwClr); // assign markup
virtual const char *TagName() { return "c"; } virtual const char *TagName() { return "c"; }
}; };
// markup rendering functionality for text // markup rendering functionality for text
class CMarkup class C4Markup
{ {
private: 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!) 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; } { if ((pTag->pPrev=pLast)) pLast->pNext=pTag; else pTags=pTag; pLast=pTag; }
CMarkupTag *Pop() C4MarkupTag *Pop()
{ CMarkupTag *pL=pLast; if (!pL) return 0; if ((pLast=pL->pPrev)) pLast->pNext=0; else pTags=0; return pL; } { C4MarkupTag *pL=pLast; if (!pL) return 0; if ((pLast=pL->pPrev)) pLast->pNext=0; else pTags=0; return pL; }
public: public:
CMarkup(bool fDoClr) { pTags=pLast=0; this->fDoClr=fDoClr; }; // ctor C4Markup(bool fDoClr) { pTags=pLast=0; this->fDoClr=fDoClr; }; // ctor
~CMarkup() // dtor ~C4Markup() // dtor
{ CMarkupTag *pTag=pTags,*pNext; while (pTag) { pNext=pTag->pNext; delete pTag; pTag=pNext; } } { 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 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 bool SkipTags(const char **ppText); // extract markup from text; return whether end is reached
void Apply(C4BltTransform &rBltTrf, DWORD &dwClr) // assign markup to vertices 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? bool Clean() { return !pTags; } // empty?
static bool StripMarkup(char *szText); // strip any markup codes from given text buffer static bool StripMarkup(char *szText); // strip any markup codes from given text buffer

View File

@ -28,7 +28,7 @@
#include <StdD3DShader.h> #include <StdD3DShader.h>
#include <StdApp.h> #include <StdApp.h>
#include <StdMarkup.h> #include <C4Markup.h>
#include <StdWindow.h> #include <StdWindow.h>
#include <C4Config.h> #include <C4Config.h>

View File

@ -31,7 +31,7 @@
#include <StdD3D.h> #include <StdD3D.h>
#include <StdGL.h> #include <StdGL.h>
#include <StdNoGfx.h> #include <StdNoGfx.h>
#include <StdMarkup.h> #include <C4Markup.h>
#include <StdFont.h> #include <StdFont.h>
#include "C4Rect.h" #include "C4Rect.h"
#include <C4Config.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) 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]; static char szLinebuf[2500+1];
for (int cnt=0; SCopySegmentEx(szText,cnt,szLinebuf,fDoMarkup ? '|' : '\n','\n',2500); cnt++,iTy+=int(fZoom*rFont.iLineHgt)) 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; 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) bool CStdDDraw::StringOut(const char *szText, CStdFont &rFont, float fZoom, SURFACE sfcDest, float iTx, float iTy, DWORD dwFCol, BYTE byForm, bool fDoMarkup)
{ {
// init markup // init markup
CMarkup Markup(true); C4Markup Markup(true);
// output string // output string
return StringOut(szText, sfcDest, iTx, iTy, dwFCol, byForm, fDoMarkup, Markup, &rFont, fZoom); 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 // clip
if (ClipAll) return true; if (ClipAll) return true;

View File

@ -327,7 +327,7 @@ public:
int GetByteCnt() { return byByteCnt; } // return bytes per pixel int GetByteCnt() { return byByteCnt; } // return bytes per pixel
protected: 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 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; virtual void PerformLine(SURFACE sfcTarget, float x1, float y1, float x2, float y2, DWORD dwClr) = 0;
bool CreatePrimaryClipper(unsigned int iXRes, unsigned int iYRes); bool CreatePrimaryClipper(unsigned int iXRes, unsigned int iYRes);

View File

@ -30,7 +30,7 @@
#include <StdBuf.h> #include <StdBuf.h>
#include <StdDDraw2.h> #include <StdDDraw2.h>
#include <StdSurface2.h> #include <StdSurface2.h>
#include <StdMarkup.h> #include <C4Markup.h>
#include <stdexcept> #include <stdexcept>
#include <string> #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 // keep track of each row's size
int iRowWdt=0,iWdt=0,iHgt=iLineHgt; int iRowWdt=0,iWdt=0,iHgt=iLineHgt;
// ignore any markup // ignore any markup
CMarkup MarkupChecker(false); C4Markup MarkupChecker(false);
// go through all text // go through all text
while (*szText) 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 iHgt=iLineHgt; // total height of output text
bool fIsFirstLineChar = true; bool fIsFirstLineChar = true;
// ignore any markup // ignore any markup
CMarkup MarkupChecker(false); C4Markup MarkupChecker(false);
// go through all text // go through all text
while (*(szLastPos = szPos)) 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 iHgt=iLineHgt; // total height of output text
bool fIsFirstLineChar = true; bool fIsFirstLineChar = true;
// ignore any markup // ignore any markup
CMarkup MarkupChecker(false); C4Markup MarkupChecker(false);
// go through all text // go through all text
while (*(szLastPos = szPos)) while (*(szLastPos = szPos))
{ {
@ -819,7 +819,7 @@ int CStdFont::GetMessageBreak(const char *szMsg, const char **ppNewPos, int iBre
/* Text drawing */ /* 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)); assert(IsValidUtf8(szText));
C4BltTransform bt, *pbt=NULL; C4BltTransform bt, *pbt=NULL;

View File

@ -21,7 +21,7 @@
#ifndef INC_STDFONT #ifndef INC_STDFONT
#define INC_STDFONT #define INC_STDFONT
#include <StdMarkup.h> #include <C4Markup.h>
#include <C4Facet.h> #include <C4Facet.h>
#include <StdBuf.h> #include <StdBuf.h>
#include <stdio.h> #include <stdio.h>
@ -42,7 +42,7 @@
#define FW_BOLD 700 #define FW_BOLD 700
#endif #endif
class CMarkup; class C4Markup;
class CStdVectorFont; class CStdVectorFont;
class CStdFont class CStdFont
@ -108,7 +108,7 @@ protected:
public: public:
int iLineHgt; // height of one line of font (in pixels) int iLineHgt; // height of one line of font (in pixels)
// draw ine line of text // 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 // get text size
bool GetTextExtent(const char *szText, int32_t &rsx, int32_t &rsy, bool fCheckMarkup = true); bool GetTextExtent(const char *szText, int32_t &rsx, int32_t &rsy, bool fCheckMarkup = true);