#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 // ±¼¸².fnt "±¼¸²" ÆùÆ® ±âº» »çÀÌÁî 12 ·Î ·Îµù // ±¼¸²:18.fnt "±¼¸²" ÆùÆ® »çÀÌÁî 18 ·Î ·Îµù // ±¼¸²:14i.fnt "±¼¸²" ÆùÆ® »çÀÌÁî 14 & ÀÌÅŸ¯À¸·Î ·Îµù 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); }