forked from metin2/client
102 lines
1.7 KiB
C++
102 lines
1.7 KiB
C++
|
#include "StdAfx.h"
|
|||
|
#include "../eterBase/Utils.h"
|
|||
|
#include "GrpText.h"
|
|||
|
|
|||
|
CGraphicText::CGraphicText(const char* c_szFileName) : CResource(c_szFileName)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
CGraphicText::~CGraphicText()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
bool CGraphicText::CreateDeviceObjects()
|
|||
|
{
|
|||
|
return m_fontTexture.CreateDeviceObjects();
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicText::DestroyDeviceObjects()
|
|||
|
{
|
|||
|
m_fontTexture.DestroyDeviceObjects();
|
|||
|
}
|
|||
|
|
|||
|
CGraphicFontTexture* CGraphicText::GetFontTexturePointer()
|
|||
|
{
|
|||
|
return &m_fontTexture;
|
|||
|
}
|
|||
|
|
|||
|
CGraphicText::TType CGraphicText::Type()
|
|||
|
{
|
|||
|
static TType s_type = StringToType("CGraphicText");
|
|||
|
return s_type;
|
|||
|
}
|
|||
|
|
|||
|
bool CGraphicText::OnLoad(int /*iSize*/, const void* /*c_pvBuf*/)
|
|||
|
{
|
|||
|
static char strName[32];
|
|||
|
int size;
|
|||
|
bool bItalic = false;
|
|||
|
|
|||
|
// format
|
|||
|
// <20><><EFBFBD><EFBFBD>.fnt "<22><><EFBFBD><EFBFBD>" <20><>Ʈ <20>⺻ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 12 <20><> <20>ε<EFBFBD>
|
|||
|
// <20><><EFBFBD><EFBFBD>:18.fnt "<22><><EFBFBD><EFBFBD>" <20><>Ʈ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 18 <20><> <20>ε<EFBFBD>
|
|||
|
// <20><><EFBFBD><EFBFBD>:14i.fnt "<22><><EFBFBD><EFBFBD>" <20><>Ʈ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 14 & <20><><EFBFBD>Ÿ<EFBFBD><C5B8><EFBFBD><EFBFBD><EFBFBD> <20>ε<EFBFBD>
|
|||
|
const char * p = strrchr(GetFileName(), ':');
|
|||
|
|
|||
|
if (p)
|
|||
|
{
|
|||
|
strncpy(strName, GetFileName(), MIN(31, p - GetFileName()));
|
|||
|
++p;
|
|||
|
|
|||
|
static char num[8];
|
|||
|
|
|||
|
int i = 0;
|
|||
|
while (*p && isdigit(*p))
|
|||
|
{
|
|||
|
num[i++] = *(p++);
|
|||
|
}
|
|||
|
|
|||
|
num[i] = '\0';
|
|||
|
if(*p == 'i')
|
|||
|
bItalic = true;
|
|||
|
size = atoi(num);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
p = strrchr(GetFileName(), '.');
|
|||
|
|
|||
|
if (!p)
|
|||
|
{
|
|||
|
assert(!"CGraphicText::OnLoadFromFile there is no extension (ie: .fnt)");
|
|||
|
strName[0] = '\0';
|
|||
|
}
|
|||
|
else
|
|||
|
strncpy(strName, GetFileName(), MIN(31, p - GetFileName()));
|
|||
|
|
|||
|
size = 12;
|
|||
|
}
|
|||
|
|
|||
|
if (!m_fontTexture.Create(strName, size, bItalic))
|
|||
|
return false;
|
|||
|
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
void CGraphicText::OnClear()
|
|||
|
{
|
|||
|
m_fontTexture.Destroy();
|
|||
|
}
|
|||
|
|
|||
|
bool CGraphicText::OnIsEmpty() const
|
|||
|
{
|
|||
|
return m_fontTexture.IsEmpty();
|
|||
|
}
|
|||
|
|
|||
|
bool CGraphicText::OnIsType(TType type)
|
|||
|
{
|
|||
|
if (CGraphicText::Type() == type)
|
|||
|
return true;
|
|||
|
|
|||
|
return CResource::OnIsType(type);
|
|||
|
}
|