예제 #1
0
	const std::pair<Charset, Charset>* getcharsets(DamageNumber::Type type)
	{
		static std::map<DamageNumber::Type, std::pair<Charset, Charset>> charsets;
		if (!charsets.count(type))
		{
			switch (type)
			{
			case DamageNumber::NORMAL:
				charsets[type].first = Charset(nl::nx::effect["BasicEff.img"]["NoRed1"], Charset::LEFT);
				charsets[type].second = Charset(nl::nx::effect["BasicEff.img"]["NoRed0"], Charset::LEFT);
				break;
			case DamageNumber::CRITICAL:
				charsets[type].first = Charset(nl::nx::effect["BasicEff.img"]["NoCri1"], Charset::LEFT);
				charsets[type].second = Charset(nl::nx::effect["BasicEff.img"]["NoCri0"], Charset::LEFT);
				break;
			case DamageNumber::TOPLAYER:
				charsets[type].first = Charset(nl::nx::effect["BasicEff.img"]["NoViolet1"], Charset::LEFT);
				charsets[type].second = Charset(nl::nx::effect["BasicEff.img"]["NoViolet0"], Charset::LEFT);
				break;
			default:
				return nullptr;
			}
		}
		return &charsets[type];
	}
예제 #2
0
void XMLFontRenderer::LoadFont(const char* pFilename)
{
	TiXmlDocument doc(pFilename);
	bool loadOkay = doc.LoadFile();
	if (!loadOkay)
		return;
	else {
		m_charset = Charset();
		m_charset.Chars.resize(256 * 3);

		m_currentFontLoadedName = std::string(pFilename);
		TiXmlElement* docElement = doc.RootElement();

		TiXmlElement* commonTag = docElement->FirstChild( "common" )->ToElement();
		m_charset.LineHeight = (unsigned short)atoi(commonTag->Attribute( "lineHeight"));
		m_charset.Base = (unsigned short)atoi(commonTag->Attribute( "base"));
		m_charset.Width = (unsigned short)atoi(commonTag->Attribute( "scaleW"));
		m_charset.Height = (unsigned short)atoi(commonTag->Attribute( "scaleH"));

		TiXmlElement* pageTag = docElement->FirstChild( "pages" )->FirstChild("page")->ToElement();
		TiXmlElement* charTag = docElement->FirstChild("chars")->FirstChild("char")->ToElement();

		m_fontImage = pageTag->Attribute( "file");
		for( charTag; charTag; charTag = charTag->NextSiblingElement() )
		{
			FontElement currentChar;
			currentChar.id = atoi(charTag->Attribute( "id"));
			currentChar.x = atoi(charTag->Attribute( "x"));
			currentChar.y = atoi(charTag->Attribute( "y"));
			currentChar.width = atoi(charTag->Attribute( "width"));
			currentChar.height = atoi(charTag->Attribute( "height"));
			currentChar.xoffset = atoi(charTag->Attribute( "xoffset"));
			currentChar.yoffset = atoi(charTag->Attribute( "yoffset"));
			currentChar.xadvance = atoi(charTag->Attribute( "xadvance"));
			m_charset.Chars[currentChar.id] = currentChar;
		}

	}
}