1151 lines
27 KiB
C++
1151 lines
27 KiB
C++
|
#include "StdAfx.h"
|
|||
|
#include "GrpTextInstance.h"
|
|||
|
#include "StateManager.h"
|
|||
|
#include "IME.h"
|
|||
|
#include "TextTag.h"
|
|||
|
#include "../EterLocale/StringCodec.h"
|
|||
|
#include "../EterBase/Utils.h"
|
|||
|
#include "../EterLocale/Arabic.h"
|
|||
|
|
|||
|
extern DWORD GetDefaultCodePage();
|
|||
|
|
|||
|
const float c_fFontFeather = 0.5f;
|
|||
|
|
|||
|
CDynamicPool<CGraphicTextInstance> CGraphicTextInstance::ms_kPool;
|
|||
|
|
|||
|
static int gs_mx = 0;
|
|||
|
static int gs_my = 0;
|
|||
|
|
|||
|
static std::wstring gs_hyperlinkText;
|
|||
|
|
|||
|
void CGraphicTextInstance::Hyperlink_UpdateMousePos(int x, int y)
|
|||
|
{
|
|||
|
gs_mx = x;
|
|||
|
gs_my = y;
|
|||
|
gs_hyperlinkText = L"";
|
|||
|
}
|
|||
|
|
|||
|
int CGraphicTextInstance::Hyperlink_GetText(char* buf, int len)
|
|||
|
{
|
|||
|
if (gs_hyperlinkText.empty())
|
|||
|
return 0;
|
|||
|
|
|||
|
int codePage = GetDefaultCodePage();
|
|||
|
|
|||
|
return Ymir_WideCharToMultiByte(codePage, 0, gs_hyperlinkText.c_str(), gs_hyperlinkText.length(), buf, len, NULL, NULL);
|
|||
|
}
|
|||
|
|
|||
|
int CGraphicTextInstance::__DrawCharacter(CGraphicFontTexture * pFontTexture, WORD codePage, wchar_t text, DWORD dwColor)
|
|||
|
{
|
|||
|
CGraphicFontTexture::TCharacterInfomation* pInsCharInfo = pFontTexture->GetCharacterInfomation(codePage, text);
|
|||
|
|
|||
|
if (pInsCharInfo)
|
|||
|
{
|
|||
|
m_dwColorInfoVector.push_back(dwColor);
|
|||
|
m_pCharInfoVector.push_back(pInsCharInfo);
|
|||
|
|
|||
|
m_textWidth += pInsCharInfo->advance;
|
|||
|
m_textHeight = max(pInsCharInfo->height, m_textHeight);
|
|||
|
return pInsCharInfo->advance;
|
|||
|
}
|
|||
|
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::__GetTextPos(DWORD index, float* x, float* y)
|
|||
|
{
|
|||
|
index = min(index, m_pCharInfoVector.size());
|
|||
|
|
|||
|
float sx = 0;
|
|||
|
float sy = 0;
|
|||
|
float fFontMaxHeight = 0;
|
|||
|
|
|||
|
for(DWORD i=0; i<index; ++i)
|
|||
|
{
|
|||
|
if (sx+float(m_pCharInfoVector[i]->width) > m_fLimitWidth)
|
|||
|
{
|
|||
|
sx = 0;
|
|||
|
sy += fFontMaxHeight;
|
|||
|
}
|
|||
|
|
|||
|
sx += float(m_pCharInfoVector[i]->advance);
|
|||
|
fFontMaxHeight = max(float(m_pCharInfoVector[i]->height), fFontMaxHeight);
|
|||
|
}
|
|||
|
|
|||
|
*x = sx;
|
|||
|
*y = sy;
|
|||
|
}
|
|||
|
|
|||
|
bool isNumberic(const char chr)
|
|||
|
{
|
|||
|
if (chr >= '0' && chr <= '9')
|
|||
|
return true;
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
bool IsValidToken(const char* iter)
|
|||
|
{
|
|||
|
return iter[0]=='@' &&
|
|||
|
isNumberic(iter[1]) &&
|
|||
|
isNumberic(iter[2]) &&
|
|||
|
isNumberic(iter[3]) &&
|
|||
|
isNumberic(iter[4]);
|
|||
|
}
|
|||
|
|
|||
|
const char* FindToken(const char* begin, const char* end)
|
|||
|
{
|
|||
|
while(begin < end)
|
|||
|
{
|
|||
|
begin = std::find(begin, end, '@');
|
|||
|
|
|||
|
if(end-begin>5 && IsValidToken(begin))
|
|||
|
{
|
|||
|
return begin;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
++begin;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
return end;
|
|||
|
}
|
|||
|
|
|||
|
int ReadToken(const char* token)
|
|||
|
{
|
|||
|
int nRet = (token[1]-'0')*1000 + (token[2]-'0')*100 + (token[3]-'0')*10 + (token[4]-'0');
|
|||
|
if (nRet == 9999)
|
|||
|
return CP_UTF8;
|
|||
|
return nRet;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::Update()
|
|||
|
{
|
|||
|
if (m_isUpdate) // <20><><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD> <20>ٲ<EFBFBD><D9B2><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20>Ѵ<EFBFBD>.
|
|||
|
return;
|
|||
|
|
|||
|
if (m_roText.IsNull())
|
|||
|
{
|
|||
|
Tracef("CGraphicTextInstance::Update - <20><>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʾҽ<CABE><D2BD>ϴ<EFBFBD>\n");
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (m_roText->IsEmpty())
|
|||
|
return;
|
|||
|
|
|||
|
CGraphicFontTexture* pFontTexture = m_roText->GetFontTexturePointer();
|
|||
|
if (!pFontTexture)
|
|||
|
return;
|
|||
|
|
|||
|
UINT defCodePage = GetDefaultCodePage();
|
|||
|
|
|||
|
UINT dataCodePage = defCodePage; // <20>ƶ<EFBFBD> <20><> <20><>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> UTF8 <20><> <20><><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
CGraphicFontTexture::TCharacterInfomation* pSpaceInfo = pFontTexture->GetCharacterInfomation(dataCodePage, ' ');
|
|||
|
|
|||
|
int spaceHeight = pSpaceInfo ? pSpaceInfo->height : 12;
|
|||
|
|
|||
|
m_pCharInfoVector.clear();
|
|||
|
m_dwColorInfoVector.clear();
|
|||
|
m_hyperlinkVector.clear();
|
|||
|
|
|||
|
m_textWidth = 0;
|
|||
|
m_textHeight = spaceHeight;
|
|||
|
|
|||
|
/* wstring begin */
|
|||
|
|
|||
|
const char* begin = m_stText.c_str();
|
|||
|
const char* end = begin + m_stText.length();
|
|||
|
|
|||
|
int wTextMax = (end - begin) * 2;
|
|||
|
wchar_t* wText = (wchar_t*)_alloca(sizeof(wchar_t)*wTextMax);
|
|||
|
|
|||
|
DWORD dwColor = m_dwTextColor;
|
|||
|
|
|||
|
/* wstring end */
|
|||
|
while (begin < end)
|
|||
|
{
|
|||
|
const char * token = FindToken(begin, end);
|
|||
|
|
|||
|
int wTextLen = Ymir_MultiByteToWideChar(dataCodePage, 0, begin, token - begin, wText, wTextMax);
|
|||
|
|
|||
|
if (m_isSecret)
|
|||
|
{
|
|||
|
for(int i=0; i<wTextLen; ++i)
|
|||
|
__DrawCharacter(pFontTexture, dataCodePage, '*', dwColor);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (defCodePage == CP_ARABIC) // ARABIC
|
|||
|
{
|
|||
|
|
|||
|
wchar_t* wArabicText = (wchar_t*)_alloca(sizeof(wchar_t) * wTextLen);
|
|||
|
int wArabicTextLen = Arabic_MakeShape(wText, wTextLen, wArabicText, wTextLen);
|
|||
|
|
|||
|
bool isEnglish = true;
|
|||
|
int nEnglishBase = wArabicTextLen - 1;
|
|||
|
|
|||
|
//<<<3C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ũ>>
|
|||
|
int x = 0;
|
|||
|
|
|||
|
int len;
|
|||
|
int hyperlinkStep = 0;
|
|||
|
SHyperlink kHyperlink;
|
|||
|
std::wstring hyperlinkBuffer;
|
|||
|
int no_hyperlink = 0;
|
|||
|
|
|||
|
// <20>ɺ<EFBFBD><C9BA><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ƶ<EFBFBD><C6B6><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE>Ѵ<EFBFBD>
|
|||
|
if (Arabic_IsInSymbol(wArabicText[wArabicTextLen - 1]))
|
|||
|
{
|
|||
|
isEnglish = false;
|
|||
|
}
|
|||
|
|
|||
|
int i = 0;
|
|||
|
for (i = wArabicTextLen - 1 ; i >= 0; --i)
|
|||
|
{
|
|||
|
wchar_t wArabicChar = wArabicText[i];
|
|||
|
|
|||
|
if (isEnglish)
|
|||
|
{
|
|||
|
|
|||
|
// <<<3C>ɺ<EFBFBD><C9BA><EFBFBD> <20><><EFBFBD><EFBFBD> (ex. <20><>ȣ, <20><><EFBFBD><EFBFBD>)>> -> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
// <<(<28>ɺ<EFBFBD><C9BA><EFBFBD> <20>ƴ<EFBFBD> <20>͵<EFBFBD> : <20><><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>, <20>ƶ<EFBFBD><C6B6><EFBFBD>)>>
|
|||
|
// (1) <20><> <20><><EFBFBD><EFBFBD> <20>ɺ<EFBFBD> or
|
|||
|
// (2)
|
|||
|
// 1) <20><> <20><><EFBFBD>ڰ<EFBFBD> <20>ƶ<EFBFBD><C6B6><EFBFBD> <20>ƴ<EFBFBD> &&
|
|||
|
// 2) <20><> <20><><EFBFBD>ڰ<EFBFBD> <20>ƶ<EFBFBD><C6B6><EFBFBD> <20>ƴ<EFBFBD> &&
|
|||
|
// 3) <20><> <20><><EFBFBD>ڰ<EFBFBD> <20>ɺ<EFBFBD>'|'<27><> <20>ƴ<EFBFBD> &&
|
|||
|
// or
|
|||
|
// (3) <20><><EFBFBD><EFBFBD> <20>ɺ<EFBFBD><C9BA><EFBFBD> '|'
|
|||
|
// <<<3C>ƶ<EFBFBD><C6B6><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ѿ<D1BE><EEB0A1> <20><><EFBFBD><EFBFBD> : <20>ɺ<EFBFBD><C9BA><EFBFBD><EFBFBD><EFBFBD>.>>
|
|||
|
// 1) <20>ձ<EFBFBD><D5B1><EFBFBD> <20>ƶ<EFBFBD><C6B6><EFBFBD>
|
|||
|
// 2) <20>ޱ<EFBFBD><DEB1><EFBFBD> <20>ƶ<EFBFBD><C6B6><EFBFBD>
|
|||
|
//
|
|||
|
//
|
|||
|
if (Arabic_IsInSymbol(wArabicChar) && (
|
|||
|
(i == 0) ||
|
|||
|
(i > 0 &&
|
|||
|
!(Arabic_HasPresentation(wArabicText, i - 1) || Arabic_IsInPresentation(wArabicText[i + 1])) && //<2F>ձ<EFBFBD><D5B1><EFBFBD>, <20>ޱ<EFBFBD><DEB1>ڰ<EFBFBD> <20>ƶ<EFBFBD><C6B6><EFBFBD> <20>ƴ<EFBFBD>.
|
|||
|
wArabicText[i+1] != '|'
|
|||
|
) ||
|
|||
|
wArabicText[i] == '|'
|
|||
|
))//if end.
|
|||
|
{
|
|||
|
// pass
|
|||
|
int temptest = 1;
|
|||
|
}
|
|||
|
// (1)<29>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD>̰ų<CCB0> (2)<29>ƶ<EFBFBD><C6B6><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ɺ<EFBFBD><C9BA>̶<EFBFBD><CCB6><EFBFBD> <20>ƶ<EFBFBD><C6B6><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ȯ
|
|||
|
else if (Arabic_IsInPresentation(wArabicChar) || Arabic_IsInSymbol(wArabicChar))
|
|||
|
{
|
|||
|
//<2F><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><EFBFBD><D7B8><EFBFBD>.
|
|||
|
for (int e = i + 1; e <= nEnglishBase;) {
|
|||
|
int ret = GetTextTag(&wArabicText[e], wArabicTextLen - e, len, hyperlinkBuffer);
|
|||
|
|
|||
|
if (ret == TEXT_TAG_PLAIN || ret == TEXT_TAG_TAG)
|
|||
|
{
|
|||
|
if (hyperlinkStep == 1)
|
|||
|
hyperlinkBuffer.append(1, wArabicText[e]);
|
|||
|
else
|
|||
|
{
|
|||
|
int charWidth = __DrawCharacter(pFontTexture, dataCodePage, wArabicText[e], dwColor);
|
|||
|
kHyperlink.ex += charWidth;
|
|||
|
//x += charWidth;
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD> <20>߰<EFBFBD><DFB0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>۸<EFBFBD>ũ<EFBFBD><C5A9> <20><>ǥ <20><><EFBFBD><EFBFBD>.
|
|||
|
for (int j = 1; j <= no_hyperlink; j++)
|
|||
|
{
|
|||
|
if(m_hyperlinkVector.size() < j)
|
|||
|
break;
|
|||
|
|
|||
|
SHyperlink & tempLink = m_hyperlinkVector[m_hyperlinkVector.size() - j];
|
|||
|
tempLink.ex += charWidth;
|
|||
|
tempLink.sx += charWidth;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (ret == TEXT_TAG_COLOR)
|
|||
|
dwColor = htoi(hyperlinkBuffer.c_str(), 8);
|
|||
|
else if (ret == TEXT_TAG_RESTORE_COLOR)
|
|||
|
dwColor = m_dwTextColor;
|
|||
|
else if (ret == TEXT_TAG_HYPERLINK_START)
|
|||
|
{
|
|||
|
hyperlinkStep = 1;
|
|||
|
hyperlinkBuffer = L"";
|
|||
|
}
|
|||
|
else if (ret == TEXT_TAG_HYPERLINK_END)
|
|||
|
{
|
|||
|
if (hyperlinkStep == 1)
|
|||
|
{
|
|||
|
++hyperlinkStep;
|
|||
|
kHyperlink.ex = kHyperlink.sx = 0; // <20><><EFBFBD><EFBFBD> <20>ؽ<EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD>۵Ǵ<DBB5> <20><>ġ
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
kHyperlink.text = hyperlinkBuffer;
|
|||
|
m_hyperlinkVector.push_back(kHyperlink);
|
|||
|
no_hyperlink++;
|
|||
|
|
|||
|
|
|||
|
hyperlinkStep = 0;
|
|||
|
hyperlinkBuffer = L"";
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
e += len;
|
|||
|
}
|
|||
|
|
|||
|
int charWidth = __DrawCharacter(pFontTexture, dataCodePage, Arabic_ConvSymbol(wArabicText[i]), dwColor);
|
|||
|
kHyperlink.ex += charWidth;
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD> <20>߰<EFBFBD><DFB0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>۸<EFBFBD>ũ<EFBFBD><C5A9> <20><>ǥ <20><><EFBFBD><EFBFBD>.
|
|||
|
for (int j = 1; j <= no_hyperlink; j++)
|
|||
|
{
|
|||
|
if(m_hyperlinkVector.size() < j)
|
|||
|
break;
|
|||
|
|
|||
|
SHyperlink & tempLink = m_hyperlinkVector[m_hyperlinkVector.size() - j];
|
|||
|
tempLink.ex += charWidth;
|
|||
|
tempLink.sx += charWidth;
|
|||
|
}
|
|||
|
|
|||
|
isEnglish = false;
|
|||
|
}
|
|||
|
}
|
|||
|
else //[[[<5B>ƶ<EFBFBD><C6B6><EFBFBD> <20><><EFBFBD><EFBFBD>]]]
|
|||
|
{
|
|||
|
// <20>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD>̰ų<CCB0> <20>ƶ<EFBFBD><C6B6><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ɺ<EFBFBD><C9BA>̶<EFBFBD><CCB6><EFBFBD>
|
|||
|
if (Arabic_IsInPresentation(wArabicChar) || Arabic_IsInSymbol(wArabicChar))
|
|||
|
{
|
|||
|
int charWidth = __DrawCharacter(pFontTexture, dataCodePage, Arabic_ConvSymbol(wArabicText[i]), dwColor);
|
|||
|
kHyperlink.ex += charWidth;
|
|||
|
x += charWidth;
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD> <20>߰<EFBFBD><DFB0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>۸<EFBFBD>ũ<EFBFBD><C5A9> <20><>ǥ <20><><EFBFBD><EFBFBD>.
|
|||
|
for (int j = 1; j <= no_hyperlink; j++)
|
|||
|
{
|
|||
|
if(m_hyperlinkVector.size() < j)
|
|||
|
break;
|
|||
|
|
|||
|
SHyperlink & tempLink = m_hyperlinkVector[m_hyperlinkVector.size() - j];
|
|||
|
tempLink.ex += charWidth;
|
|||
|
tempLink.sx += charWidth;
|
|||
|
}
|
|||
|
}
|
|||
|
else //<2F><><EFBFBD><EFBFBD><EFBFBD>̰ų<CCB0>, <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ɺ<EFBFBD><C9BA>̶<EFBFBD><CCB6><EFBFBD>,
|
|||
|
{
|
|||
|
nEnglishBase = i;
|
|||
|
isEnglish = true;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (isEnglish)
|
|||
|
{
|
|||
|
for (int e = i + 1; e <= nEnglishBase;) {
|
|||
|
int ret = GetTextTag(&wArabicText[e], wArabicTextLen - e, len, hyperlinkBuffer);
|
|||
|
|
|||
|
if (ret == TEXT_TAG_PLAIN || ret == TEXT_TAG_TAG)
|
|||
|
{
|
|||
|
if (hyperlinkStep == 1)
|
|||
|
hyperlinkBuffer.append(1, wArabicText[e]);
|
|||
|
else
|
|||
|
{
|
|||
|
int charWidth = __DrawCharacter(pFontTexture, dataCodePage, wArabicText[e], dwColor);
|
|||
|
kHyperlink.ex += charWidth;
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD> <20>߰<EFBFBD><DFB0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>۸<EFBFBD>ũ<EFBFBD><C5A9> <20><>ǥ <20><><EFBFBD><EFBFBD>.
|
|||
|
for (int j = 1; j <= no_hyperlink; j++)
|
|||
|
{
|
|||
|
if(m_hyperlinkVector.size() < j)
|
|||
|
break;
|
|||
|
|
|||
|
SHyperlink & tempLink = m_hyperlinkVector[m_hyperlinkVector.size() - j];
|
|||
|
tempLink.ex += charWidth;
|
|||
|
tempLink.sx += charWidth;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (ret == TEXT_TAG_COLOR)
|
|||
|
dwColor = htoi(hyperlinkBuffer.c_str(), 8);
|
|||
|
else if (ret == TEXT_TAG_RESTORE_COLOR)
|
|||
|
dwColor = m_dwTextColor;
|
|||
|
else if (ret == TEXT_TAG_HYPERLINK_START)
|
|||
|
{
|
|||
|
hyperlinkStep = 1;
|
|||
|
hyperlinkBuffer = L"";
|
|||
|
}
|
|||
|
else if (ret == TEXT_TAG_HYPERLINK_END)
|
|||
|
{
|
|||
|
if (hyperlinkStep == 1)
|
|||
|
{
|
|||
|
++hyperlinkStep;
|
|||
|
kHyperlink.ex = kHyperlink.sx = 0; // <20><><EFBFBD><EFBFBD> <20>ؽ<EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD>۵Ǵ<DBB5> <20><>ġ
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
kHyperlink.text = hyperlinkBuffer;
|
|||
|
m_hyperlinkVector.push_back(kHyperlink);
|
|||
|
no_hyperlink++;
|
|||
|
|
|||
|
hyperlinkStep = 0;
|
|||
|
hyperlinkBuffer = L"";
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
e += len;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
else // <20>ƶ<EFBFBD><C6B6><EFBFBD> <20>ٸ<EFBFBD> <20><><EFBFBD><EFBFBD>.
|
|||
|
{
|
|||
|
int x = 0;
|
|||
|
int len;
|
|||
|
int hyperlinkStep = 0;
|
|||
|
SHyperlink kHyperlink;
|
|||
|
std::wstring hyperlinkBuffer;
|
|||
|
|
|||
|
for (int i = 0; i < wTextLen; )
|
|||
|
{
|
|||
|
int ret = GetTextTag(&wText[i], wTextLen - i, len, hyperlinkBuffer);
|
|||
|
|
|||
|
if (ret == TEXT_TAG_PLAIN || ret == TEXT_TAG_TAG)
|
|||
|
{
|
|||
|
if (hyperlinkStep == 1)
|
|||
|
hyperlinkBuffer.append(1, wText[i]);
|
|||
|
else
|
|||
|
{
|
|||
|
int charWidth = __DrawCharacter(pFontTexture, dataCodePage, wText[i], dwColor);
|
|||
|
kHyperlink.ex += charWidth;
|
|||
|
x += charWidth;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (ret == TEXT_TAG_COLOR)
|
|||
|
dwColor = htoi(hyperlinkBuffer.c_str(), 8);
|
|||
|
else if (ret == TEXT_TAG_RESTORE_COLOR)
|
|||
|
dwColor = m_dwTextColor;
|
|||
|
else if (ret == TEXT_TAG_HYPERLINK_START)
|
|||
|
{
|
|||
|
hyperlinkStep = 1;
|
|||
|
hyperlinkBuffer = L"";
|
|||
|
}
|
|||
|
else if (ret == TEXT_TAG_HYPERLINK_END)
|
|||
|
{
|
|||
|
if (hyperlinkStep == 1)
|
|||
|
{
|
|||
|
++hyperlinkStep;
|
|||
|
kHyperlink.ex = kHyperlink.sx = x; // <20><><EFBFBD><EFBFBD> <20>ؽ<EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD>۵Ǵ<DBB5> <20><>ġ
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
kHyperlink.text = hyperlinkBuffer;
|
|||
|
m_hyperlinkVector.push_back(kHyperlink);
|
|||
|
|
|||
|
hyperlinkStep = 0;
|
|||
|
hyperlinkBuffer = L"";
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
i += len;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (token < end)
|
|||
|
{
|
|||
|
int newCodePage = ReadToken(token);
|
|||
|
dataCodePage = newCodePage; // <20>ƶ<EFBFBD> <20><> <20><>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> UTF8 <20><> <20><><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
begin = token + 5;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
begin = token;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
pFontTexture->UpdateTexture();
|
|||
|
|
|||
|
m_isUpdate = true;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::Render(RECT * pClipRect)
|
|||
|
{
|
|||
|
if (!m_isUpdate)
|
|||
|
return;
|
|||
|
|
|||
|
CGraphicText* pkText=m_roText.GetPointer();
|
|||
|
if (!pkText)
|
|||
|
return;
|
|||
|
|
|||
|
CGraphicFontTexture* pFontTexture = pkText->GetFontTexturePointer();
|
|||
|
if (!pFontTexture)
|
|||
|
return;
|
|||
|
|
|||
|
float fStanX = m_v3Position.x;
|
|||
|
float fStanY = m_v3Position.y + 1.0f;
|
|||
|
|
|||
|
UINT defCodePage = GetDefaultCodePage();
|
|||
|
|
|||
|
if (defCodePage == CP_ARABIC)
|
|||
|
{
|
|||
|
switch (m_hAlign)
|
|||
|
{
|
|||
|
case HORIZONTAL_ALIGN_LEFT:
|
|||
|
fStanX -= m_textWidth;
|
|||
|
break;
|
|||
|
|
|||
|
case HORIZONTAL_ALIGN_CENTER:
|
|||
|
fStanX -= float(m_textWidth / 2);
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
switch (m_hAlign)
|
|||
|
{
|
|||
|
case HORIZONTAL_ALIGN_RIGHT:
|
|||
|
fStanX -= m_textWidth;
|
|||
|
break;
|
|||
|
|
|||
|
case HORIZONTAL_ALIGN_CENTER:
|
|||
|
fStanX -= float(m_textWidth / 2);
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
switch (m_vAlign)
|
|||
|
{
|
|||
|
case VERTICAL_ALIGN_BOTTOM:
|
|||
|
fStanY -= m_textHeight;
|
|||
|
break;
|
|||
|
|
|||
|
case VERTICAL_ALIGN_CENTER:
|
|||
|
fStanY -= float(m_textHeight) / 2.0f;
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
//WORD FillRectIndices[6] = { 0, 2, 1, 2, 3, 1 };
|
|||
|
|
|||
|
STATEMANAGER.SaveRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
|||
|
STATEMANAGER.SaveRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
|||
|
DWORD dwFogEnable = STATEMANAGER.GetRenderState(D3DRS_FOGENABLE);
|
|||
|
DWORD dwLighting = STATEMANAGER.GetRenderState(D3DRS_LIGHTING);
|
|||
|
STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, FALSE);
|
|||
|
STATEMANAGER.SetRenderState(D3DRS_LIGHTING, FALSE);
|
|||
|
|
|||
|
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1);
|
|||
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
|||
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
|||
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
|||
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
|||
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
|
|||
|
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
|||
|
|
|||
|
{
|
|||
|
const float fFontHalfWeight=1.0f;
|
|||
|
|
|||
|
float fCurX;
|
|||
|
float fCurY;
|
|||
|
|
|||
|
float fFontSx;
|
|||
|
float fFontSy;
|
|||
|
float fFontEx;
|
|||
|
float fFontEy;
|
|||
|
float fFontWidth;
|
|||
|
float fFontHeight;
|
|||
|
float fFontMaxHeight;
|
|||
|
float fFontAdvance;
|
|||
|
|
|||
|
SVertex akVertex[4];
|
|||
|
akVertex[0].z=m_v3Position.z;
|
|||
|
akVertex[1].z=m_v3Position.z;
|
|||
|
akVertex[2].z=m_v3Position.z;
|
|||
|
akVertex[3].z=m_v3Position.z;
|
|||
|
|
|||
|
CGraphicFontTexture::TCharacterInfomation* pCurCharInfo;
|
|||
|
|
|||
|
// <20>θ<D7B5>
|
|||
|
if (m_isOutline)
|
|||
|
{
|
|||
|
fCurX=fStanX;
|
|||
|
fCurY=fStanY;
|
|||
|
fFontMaxHeight=0.0f;
|
|||
|
|
|||
|
CGraphicFontTexture::TPCharacterInfomationVector::iterator i;
|
|||
|
for (i=m_pCharInfoVector.begin(); i!=m_pCharInfoVector.end(); ++i)
|
|||
|
{
|
|||
|
pCurCharInfo = *i;
|
|||
|
|
|||
|
fFontWidth=float(pCurCharInfo->width);
|
|||
|
fFontHeight=float(pCurCharInfo->height);
|
|||
|
fFontAdvance=float(pCurCharInfo->advance);
|
|||
|
|
|||
|
// NOTE : <20><>Ʈ <20><><EFBFBD>¿<EFBFBD> Width <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ӵϴ<D3B4>. - [levites]
|
|||
|
if ((fCurX+fFontWidth)-m_v3Position.x > m_fLimitWidth)
|
|||
|
{
|
|||
|
if (m_isMultiLine)
|
|||
|
{
|
|||
|
fCurX=fStanX;
|
|||
|
fCurY+=fFontMaxHeight;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (pClipRect)
|
|||
|
{
|
|||
|
if (fCurY <= pClipRect->top)
|
|||
|
{
|
|||
|
fCurX += fFontAdvance;
|
|||
|
continue;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
fFontSx = fCurX - 0.5f;
|
|||
|
fFontSy = fCurY - 0.5f;
|
|||
|
fFontEx = fFontSx + fFontWidth;
|
|||
|
fFontEy = fFontSy + fFontHeight;
|
|||
|
|
|||
|
pFontTexture->SelectTexture(pCurCharInfo->index);
|
|||
|
STATEMANAGER.SetTexture(0, pFontTexture->GetD3DTexture());
|
|||
|
|
|||
|
akVertex[0].u=pCurCharInfo->left;
|
|||
|
akVertex[0].v=pCurCharInfo->top;
|
|||
|
akVertex[1].u=pCurCharInfo->left;
|
|||
|
akVertex[1].v=pCurCharInfo->bottom;
|
|||
|
akVertex[2].u=pCurCharInfo->right;
|
|||
|
akVertex[2].v=pCurCharInfo->top;
|
|||
|
akVertex[3].u=pCurCharInfo->right;
|
|||
|
akVertex[3].v=pCurCharInfo->bottom;
|
|||
|
|
|||
|
akVertex[3].color = akVertex[2].color = akVertex[1].color = akVertex[0].color = m_dwOutLineColor;
|
|||
|
|
|||
|
|
|||
|
float feather = 0.0f; // m_fFontFeather
|
|||
|
|
|||
|
akVertex[0].y=fFontSy-feather;
|
|||
|
akVertex[1].y=fFontEy+feather;
|
|||
|
akVertex[2].y=fFontSy-feather;
|
|||
|
akVertex[3].y=fFontEy+feather;
|
|||
|
|
|||
|
// <20><>
|
|||
|
akVertex[0].x=fFontSx-fFontHalfWeight-feather;
|
|||
|
akVertex[1].x=fFontSx-fFontHalfWeight-feather;
|
|||
|
akVertex[2].x=fFontEx-fFontHalfWeight+feather;
|
|||
|
akVertex[3].x=fFontEx-fFontHalfWeight+feather;
|
|||
|
|
|||
|
if (CGraphicBase::SetPDTStream((SPDTVertex*)akVertex, 4))
|
|||
|
STATEMANAGER.DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
|
|||
|
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD>
|
|||
|
akVertex[0].x=fFontSx+fFontHalfWeight-feather;
|
|||
|
akVertex[1].x=fFontSx+fFontHalfWeight-feather;
|
|||
|
akVertex[2].x=fFontEx+fFontHalfWeight+feather;
|
|||
|
akVertex[3].x=fFontEx+fFontHalfWeight+feather;
|
|||
|
|
|||
|
if (CGraphicBase::SetPDTStream((SPDTVertex*)akVertex, 4))
|
|||
|
STATEMANAGER.DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
|
|||
|
|
|||
|
akVertex[0].x=fFontSx-feather;
|
|||
|
akVertex[1].x=fFontSx-feather;
|
|||
|
akVertex[2].x=fFontEx+feather;
|
|||
|
akVertex[3].x=fFontEx+feather;
|
|||
|
|
|||
|
// <20><>
|
|||
|
akVertex[0].y=fFontSy-fFontHalfWeight-feather;
|
|||
|
akVertex[1].y=fFontEy-fFontHalfWeight+feather;
|
|||
|
akVertex[2].y=fFontSy-fFontHalfWeight-feather;
|
|||
|
akVertex[3].y=fFontEy-fFontHalfWeight+feather;
|
|||
|
|
|||
|
// 20041216.myevan.DrawPrimitiveUP
|
|||
|
if (CGraphicBase::SetPDTStream((SPDTVertex*)akVertex, 4))
|
|||
|
STATEMANAGER.DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
|
|||
|
|
|||
|
// <20>Ʒ<EFBFBD>
|
|||
|
akVertex[0].y=fFontSy+fFontHalfWeight-feather;
|
|||
|
akVertex[1].y=fFontEy+fFontHalfWeight+feather;
|
|||
|
akVertex[2].y=fFontSy+fFontHalfWeight-feather;
|
|||
|
akVertex[3].y=fFontEy+fFontHalfWeight+feather;
|
|||
|
|
|||
|
// 20041216.myevan.DrawPrimitiveUP
|
|||
|
if (CGraphicBase::SetPDTStream((SPDTVertex*)akVertex, 4))
|
|||
|
STATEMANAGER.DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
|
|||
|
|
|||
|
fCurX += fFontAdvance;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD> <20><>Ʈ
|
|||
|
fCurX=fStanX;
|
|||
|
fCurY=fStanY;
|
|||
|
fFontMaxHeight=0.0f;
|
|||
|
|
|||
|
for (int i = 0; i < m_pCharInfoVector.size(); ++i)
|
|||
|
{
|
|||
|
pCurCharInfo = m_pCharInfoVector[i];
|
|||
|
|
|||
|
fFontWidth=float(pCurCharInfo->width);
|
|||
|
fFontHeight=float(pCurCharInfo->height);
|
|||
|
fFontMaxHeight=max(fFontHeight, pCurCharInfo->height);
|
|||
|
fFontAdvance=float(pCurCharInfo->advance);
|
|||
|
|
|||
|
// NOTE : <20><>Ʈ <20><><EFBFBD>¿<EFBFBD> Width <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ӵϴ<D3B4>. - [levites]
|
|||
|
if ((fCurX+fFontWidth)-m_v3Position.x > m_fLimitWidth)
|
|||
|
{
|
|||
|
if (m_isMultiLine)
|
|||
|
{
|
|||
|
fCurX=fStanX;
|
|||
|
fCurY+=fFontMaxHeight;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (pClipRect)
|
|||
|
{
|
|||
|
if (fCurY <= pClipRect->top)
|
|||
|
{
|
|||
|
fCurX += fFontAdvance;
|
|||
|
continue;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
fFontSx = fCurX-0.5f;
|
|||
|
fFontSy = fCurY-0.5f;
|
|||
|
fFontEx = fFontSx + fFontWidth;
|
|||
|
fFontEy = fFontSy + fFontHeight;
|
|||
|
|
|||
|
pFontTexture->SelectTexture(pCurCharInfo->index);
|
|||
|
STATEMANAGER.SetTexture(0, pFontTexture->GetD3DTexture());
|
|||
|
|
|||
|
akVertex[0].x=fFontSx;
|
|||
|
akVertex[0].y=fFontSy;
|
|||
|
akVertex[0].u=pCurCharInfo->left;
|
|||
|
akVertex[0].v=pCurCharInfo->top;
|
|||
|
|
|||
|
akVertex[1].x=fFontSx;
|
|||
|
akVertex[1].y=fFontEy;
|
|||
|
akVertex[1].u=pCurCharInfo->left;
|
|||
|
akVertex[1].v=pCurCharInfo->bottom;
|
|||
|
|
|||
|
akVertex[2].x=fFontEx;
|
|||
|
akVertex[2].y=fFontSy;
|
|||
|
akVertex[2].u=pCurCharInfo->right;
|
|||
|
akVertex[2].v=pCurCharInfo->top;
|
|||
|
|
|||
|
akVertex[3].x=fFontEx;
|
|||
|
akVertex[3].y=fFontEy;
|
|||
|
akVertex[3].u=pCurCharInfo->right;
|
|||
|
akVertex[3].v=pCurCharInfo->bottom;
|
|||
|
|
|||
|
//m_dwColorInfoVector[i];
|
|||
|
//m_dwTextColor;
|
|||
|
akVertex[0].color = akVertex[1].color = akVertex[2].color = akVertex[3].color = m_dwColorInfoVector[i];
|
|||
|
|
|||
|
// 20041216.myevan.DrawPrimitiveUP
|
|||
|
if (CGraphicBase::SetPDTStream((SPDTVertex*)akVertex, 4))
|
|||
|
STATEMANAGER.DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
|
|||
|
//STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, akVertex, sizeof(SVertex));
|
|||
|
|
|||
|
fCurX += fFontAdvance;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (m_isCursor)
|
|||
|
{
|
|||
|
// Draw Cursor
|
|||
|
float sx, sy, ex, ey;
|
|||
|
TDiffuse diffuse;
|
|||
|
|
|||
|
int curpos = CIME::GetCurPos();
|
|||
|
int compend = curpos + CIME::GetCompLen();
|
|||
|
|
|||
|
__GetTextPos(curpos, &sx, &sy);
|
|||
|
|
|||
|
// If Composition
|
|||
|
if(curpos<compend)
|
|||
|
{
|
|||
|
diffuse = 0x7fffffff;
|
|||
|
__GetTextPos(compend, &ex, &sy);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
diffuse = 0xffffffff;
|
|||
|
ex = sx + 2;
|
|||
|
}
|
|||
|
|
|||
|
// FOR_ARABIC_ALIGN
|
|||
|
if (defCodePage == CP_ARABIC)
|
|||
|
{
|
|||
|
sx += m_v3Position.x - m_textWidth;
|
|||
|
ex += m_v3Position.x - m_textWidth;
|
|||
|
sy += m_v3Position.y;
|
|||
|
ey = sy + m_textHeight;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
sx += m_v3Position.x;
|
|||
|
sy += m_v3Position.y;
|
|||
|
ex += m_v3Position.x;
|
|||
|
ey = sy + m_textHeight;
|
|||
|
}
|
|||
|
|
|||
|
switch (m_vAlign)
|
|||
|
{
|
|||
|
case VERTICAL_ALIGN_BOTTOM:
|
|||
|
sy -= m_textHeight;
|
|||
|
break;
|
|||
|
|
|||
|
case VERTICAL_ALIGN_CENTER:
|
|||
|
sy -= float(m_textHeight) / 2.0f;
|
|||
|
break;
|
|||
|
}
|
|||
|
// <20><><EFBFBD><EFBFBD>ȭ <20><><EFBFBD><EFBFBD>
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ؽ<EFBFBD><D8BD>ĸ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵٸ<D1B4>... STRIP<49><50> <20><><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD>, <20>ؽ<EFBFBD><D8BD>İ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ǰų<C7B0> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DrawPrimitive<76><65> ȣ<><C8A3><EFBFBD><EFBFBD>
|
|||
|
// <20>ִ<EFBFBD><D6B4><EFBFBD> <20><><EFBFBD>ڸ<EFBFBD> <20><><EFBFBD>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!
|
|||
|
|
|||
|
TPDTVertex vertices[4];
|
|||
|
vertices[0].diffuse = diffuse;
|
|||
|
vertices[1].diffuse = diffuse;
|
|||
|
vertices[2].diffuse = diffuse;
|
|||
|
vertices[3].diffuse = diffuse;
|
|||
|
vertices[0].position = TPosition(sx, sy, 0.0f);
|
|||
|
vertices[1].position = TPosition(ex, sy, 0.0f);
|
|||
|
vertices[2].position = TPosition(sx, ey, 0.0f);
|
|||
|
vertices[3].position = TPosition(ex, ey, 0.0f);
|
|||
|
|
|||
|
STATEMANAGER.SetTexture(0, NULL);
|
|||
|
|
|||
|
|
|||
|
// 2004.11.18.myevan.DrawIndexPrimitiveUP -> DynamicVertexBuffer
|
|||
|
CGraphicBase::SetDefaultIndexBuffer(CGraphicBase::DEFAULT_IB_FILL_RECT);
|
|||
|
if (CGraphicBase::SetPDTStream(vertices, 4))
|
|||
|
STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 4, 0, 2);
|
|||
|
|
|||
|
int ulbegin = CIME::GetULBegin();
|
|||
|
int ulend = CIME::GetULEnd();
|
|||
|
|
|||
|
if(ulbegin < ulend)
|
|||
|
{
|
|||
|
__GetTextPos(curpos+ulbegin, &sx, &sy);
|
|||
|
__GetTextPos(curpos+ulend, &ex, &sy);
|
|||
|
|
|||
|
sx += m_v3Position.x;
|
|||
|
sy += m_v3Position.y + m_textHeight;
|
|||
|
ex += m_v3Position.x;
|
|||
|
ey = sy + 2;
|
|||
|
|
|||
|
vertices[0].diffuse = 0xFFFF0000;
|
|||
|
vertices[1].diffuse = 0xFFFF0000;
|
|||
|
vertices[2].diffuse = 0xFFFF0000;
|
|||
|
vertices[3].diffuse = 0xFFFF0000;
|
|||
|
vertices[0].position = TPosition(sx, sy, 0.0f);
|
|||
|
vertices[1].position = TPosition(ex, sy, 0.0f);
|
|||
|
vertices[2].position = TPosition(sx, ey, 0.0f);
|
|||
|
vertices[3].position = TPosition(ex, ey, 0.0f);
|
|||
|
|
|||
|
STATEMANAGER.DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, c_FillRectIndices, D3DFMT_INDEX16, vertices, sizeof(TPDTVertex));
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
STATEMANAGER.RestoreRenderState(D3DRS_SRCBLEND);
|
|||
|
STATEMANAGER.RestoreRenderState(D3DRS_DESTBLEND);
|
|||
|
|
|||
|
STATEMANAGER.SetRenderState(D3DRS_FOGENABLE, dwFogEnable);
|
|||
|
STATEMANAGER.SetRenderState(D3DRS_LIGHTING, dwLighting);
|
|||
|
|
|||
|
//<2F>ݰ<EFBFBD><DDB0><EFBFBD> <20><>ũ <20><><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD> <20>κ<EFBFBD>.
|
|||
|
if (m_hyperlinkVector.size() != 0)
|
|||
|
{
|
|||
|
int lx = gs_mx - m_v3Position.x;
|
|||
|
int ly = gs_my - m_v3Position.y;
|
|||
|
|
|||
|
//<2F>ƶ<EFBFBD><C6B6><EFBFBD> <20><>ǥ <20><>ȣ<EFBFBD><C8A3> <20>ٲ<EFBFBD><D9B2>ش<EFBFBD>.
|
|||
|
if (GetDefaultCodePage() == CP_ARABIC) {
|
|||
|
lx = -lx;
|
|||
|
ly = -ly + m_textHeight;
|
|||
|
}
|
|||
|
|
|||
|
if (lx >= 0 && ly >= 0 && lx < m_textWidth && ly < m_textHeight)
|
|||
|
{
|
|||
|
std::vector<SHyperlink>::iterator it = m_hyperlinkVector.begin();
|
|||
|
|
|||
|
while (it != m_hyperlinkVector.end())
|
|||
|
{
|
|||
|
SHyperlink & link = *it++;
|
|||
|
if (lx >= link.sx && lx < link.ex)
|
|||
|
{
|
|||
|
gs_hyperlinkText = link.text;
|
|||
|
/*
|
|||
|
OutputDebugStringW(link.text.c_str());
|
|||
|
OutputDebugStringW(L"\n");
|
|||
|
*/
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::CreateSystem(UINT uCapacity)
|
|||
|
{
|
|||
|
ms_kPool.Create(uCapacity);
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::DestroySystem()
|
|||
|
{
|
|||
|
ms_kPool.Destroy();
|
|||
|
}
|
|||
|
|
|||
|
CGraphicTextInstance* CGraphicTextInstance::New()
|
|||
|
{
|
|||
|
return ms_kPool.Alloc();
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::Delete(CGraphicTextInstance* pkInst)
|
|||
|
{
|
|||
|
pkInst->Destroy();
|
|||
|
ms_kPool.Free(pkInst);
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::ShowCursor()
|
|||
|
{
|
|||
|
m_isCursor = true;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::HideCursor()
|
|||
|
{
|
|||
|
m_isCursor = false;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::ShowOutLine()
|
|||
|
{
|
|||
|
m_isOutline = true;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::HideOutLine()
|
|||
|
{
|
|||
|
m_isOutline = false;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::SetColor(DWORD color)
|
|||
|
{
|
|||
|
if (m_dwTextColor != color)
|
|||
|
{
|
|||
|
for (int i = 0; i < m_pCharInfoVector.size(); ++i)
|
|||
|
if (m_dwColorInfoVector[i] == m_dwTextColor)
|
|||
|
m_dwColorInfoVector[i] = color;
|
|||
|
|
|||
|
m_dwTextColor = color;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::SetColor(float r, float g, float b, float a)
|
|||
|
{
|
|||
|
SetColor(D3DXCOLOR(r, g, b, a));
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::SetOutLineColor(DWORD color)
|
|||
|
{
|
|||
|
m_dwOutLineColor=color;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::SetOutLineColor(float r, float g, float b, float a)
|
|||
|
{
|
|||
|
m_dwOutLineColor=D3DXCOLOR(r, g, b, a);
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::SetSecret(bool Value)
|
|||
|
{
|
|||
|
m_isSecret = Value;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::SetOutline(bool Value)
|
|||
|
{
|
|||
|
m_isOutline = Value;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::SetFeather(bool Value)
|
|||
|
{
|
|||
|
if (Value)
|
|||
|
{
|
|||
|
m_fFontFeather = c_fFontFeather;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
m_fFontFeather = 0.0f;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::SetMultiLine(bool Value)
|
|||
|
{
|
|||
|
m_isMultiLine = Value;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::SetHorizonalAlign(int hAlign)
|
|||
|
{
|
|||
|
m_hAlign = hAlign;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::SetVerticalAlign(int vAlign)
|
|||
|
{
|
|||
|
m_vAlign = vAlign;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::SetMax(int iMax)
|
|||
|
{
|
|||
|
m_iMax = iMax;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::SetLimitWidth(float fWidth)
|
|||
|
{
|
|||
|
m_fLimitWidth = fWidth;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::SetValueString(const std::string& c_stValue)
|
|||
|
{
|
|||
|
if (0 == m_stText.compare(c_stValue))
|
|||
|
return;
|
|||
|
|
|||
|
m_stText = c_stValue;
|
|||
|
m_isUpdate = false;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::SetValue(const char* c_szText, size_t len)
|
|||
|
{
|
|||
|
if (0 == m_stText.compare(c_szText))
|
|||
|
return;
|
|||
|
|
|||
|
m_stText = c_szText;
|
|||
|
m_isUpdate = false;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::SetPosition(float fx, float fy, float fz)
|
|||
|
{
|
|||
|
m_v3Position.x = fx;
|
|||
|
m_v3Position.y = fy;
|
|||
|
m_v3Position.z = fz;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::SetTextPointer(CGraphicText* pText)
|
|||
|
{
|
|||
|
m_roText = pText;
|
|||
|
}
|
|||
|
|
|||
|
const std::string & CGraphicTextInstance::GetValueStringReference()
|
|||
|
{
|
|||
|
return m_stText;
|
|||
|
}
|
|||
|
|
|||
|
WORD CGraphicTextInstance::GetTextLineCount()
|
|||
|
{
|
|||
|
CGraphicFontTexture::TCharacterInfomation* pCurCharInfo;
|
|||
|
CGraphicFontTexture::TPCharacterInfomationVector::iterator itor;
|
|||
|
|
|||
|
float fx = 0.0f;
|
|||
|
WORD wLineCount = 1;
|
|||
|
for (itor=m_pCharInfoVector.begin(); itor!=m_pCharInfoVector.end(); ++itor)
|
|||
|
{
|
|||
|
pCurCharInfo = *itor;
|
|||
|
|
|||
|
float fFontWidth=float(pCurCharInfo->width);
|
|||
|
float fFontAdvance=float(pCurCharInfo->advance);
|
|||
|
//float fFontHeight=float(pCurCharInfo->height);
|
|||
|
|
|||
|
// NOTE : <20><>Ʈ <20><><EFBFBD>¿<EFBFBD> Width <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ӵϴ<D3B4>. - [levites]
|
|||
|
if (fx+fFontWidth > m_fLimitWidth)
|
|||
|
{
|
|||
|
fx = 0.0f;
|
|||
|
++wLineCount;
|
|||
|
}
|
|||
|
|
|||
|
fx += fFontAdvance;
|
|||
|
}
|
|||
|
|
|||
|
return wLineCount;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::GetTextSize(int* pRetWidth, int* pRetHeight)
|
|||
|
{
|
|||
|
*pRetWidth = m_textWidth;
|
|||
|
*pRetHeight = m_textHeight;
|
|||
|
}
|
|||
|
|
|||
|
int CGraphicTextInstance::PixelPositionToCharacterPosition(int iPixelPosition)
|
|||
|
{
|
|||
|
int icurPosition = 0;
|
|||
|
for (int i = 0; i < (int)m_pCharInfoVector.size(); ++i)
|
|||
|
{
|
|||
|
CGraphicFontTexture::TCharacterInfomation* pCurCharInfo = m_pCharInfoVector[i];
|
|||
|
icurPosition += pCurCharInfo->width;
|
|||
|
|
|||
|
if (iPixelPosition < icurPosition)
|
|||
|
return i;
|
|||
|
}
|
|||
|
|
|||
|
return -1;
|
|||
|
}
|
|||
|
|
|||
|
int CGraphicTextInstance::GetHorizontalAlign()
|
|||
|
{
|
|||
|
return m_hAlign;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::__Initialize()
|
|||
|
{
|
|||
|
m_roText = NULL;
|
|||
|
|
|||
|
m_hAlign = HORIZONTAL_ALIGN_LEFT;
|
|||
|
m_vAlign = VERTICAL_ALIGN_TOP;
|
|||
|
|
|||
|
m_iMax = 0;
|
|||
|
m_fLimitWidth = 1600.0f; // NOTE : <20>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD><EFBFBD> <20>ִ<EFBFBD>ġ. <20>̺<EFBFBD><CCBA><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? - [levites]
|
|||
|
|
|||
|
m_isCursor = false;
|
|||
|
m_isSecret = false;
|
|||
|
m_isMultiLine = false;
|
|||
|
|
|||
|
m_isOutline = false;
|
|||
|
m_fFontFeather = c_fFontFeather;
|
|||
|
|
|||
|
m_isUpdate = false;
|
|||
|
|
|||
|
m_textWidth = 0;
|
|||
|
m_textHeight = 0;
|
|||
|
|
|||
|
m_v3Position.x = m_v3Position.y = m_v3Position.z = 0.0f;
|
|||
|
|
|||
|
m_dwOutLineColor=0xff000000;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicTextInstance::Destroy()
|
|||
|
{
|
|||
|
m_stText="";
|
|||
|
m_pCharInfoVector.clear();
|
|||
|
m_dwColorInfoVector.clear();
|
|||
|
m_hyperlinkVector.clear();
|
|||
|
|
|||
|
__Initialize();
|
|||
|
}
|
|||
|
|
|||
|
CGraphicTextInstance::CGraphicTextInstance()
|
|||
|
{
|
|||
|
__Initialize();
|
|||
|
}
|
|||
|
|
|||
|
CGraphicTextInstance::~CGraphicTextInstance()
|
|||
|
{
|
|||
|
Destroy();
|
|||
|
}
|