void ConfigAdapter::ResolveSubEntities(MutableMapInterface **maps, XMLNode *datamap)
{
  int entitymapnbr = datamap->GetChildrenCount("entitymap");
  for (int i = 0; i < entitymapnbr; i++)
  {
    XMLNode *entitymap = datamap->GetChild("entitymap", i);
    int subentitynbr = entitymap->GetChildrenCount("subentity");
    for (int j = 0; j < subentitynbr; j++)
    {
      CreateSubEntity(maps, i, entitymap->GetChild("subentity", j));
    }
  }
}
Exemple #2
0
FontRenderer* FontRenderer::LoadFromFile(const char *path, SpriteBatch *spriteBatch)
{
	assert(spriteBatch != NULL);

	FontLetter texLetters[256];

	XMLNode *xmlDoc = XMLLoader::LoadFromFile(path);
	if (xmlDoc == NULL)
		return NULL;
	
	std::string bmpFilename = xmlDoc->GetAttribAsString("bitmap");
	if (bmpFilename.empty())
		return NULL;
	
	Path _path(path);
	Texture *tex = LoadFontBitmap(_path.GetPath() + bmpFilename);
	if (tex == NULL)
		return NULL;

	if (xmlDoc->GetName() != "alphabet")
	{
		delete xmlDoc;
		return NULL;
	}

	for (uint32_t i = 0; i < xmlDoc->GetChildrenCount(); i++)
	{
		std::string letter = xmlDoc[i].GetAttribAsString("letter");
		std::string bounds = xmlDoc[i].GetAttribAsString("bounds");

		sm::Rect<int> boundsValues;
		if (!ParseBounds(bounds, boundsValues))
			return NULL;

		texLetters[letter[0]].Size = sm::Point<int>(boundsValues.Width, boundsValues.Height);
		texLetters[letter[0]].Coords = TexPart(tex, boundsValues);
	}
	
	FontRenderer *fontRenderer = new FontRenderer();
	fontRenderer->m_spriteBatch = spriteBatch;
	if (fontRenderer != NULL)
	{
		memcpy(fontRenderer ->texLetters, texLetters, sizeof(FontLetter) * 256);
	}
	return fontRenderer;
}