Exemple #1
0
/* TextureXListView::getItemText
 * Returns the string for [item] at [column]
 *******************************************************************/
string TextureXListView::getItemText(long item, long column, long index) const
{
	// Check texture list exists
	if (!texturex)
		return "INVALID INDEX";

	// Check index is ok
	if (index < 0 || (unsigned)index > texturex->nTextures())
		return "INVALID INDEX";

	// Get associated texture
	CTexture* tex = texturex->getTexture(index);

	if (column == 0)						// Name column
		return tex->getName();
	else if (column == 1)					// Size column
		return S_FMT("%dx%d", tex->getWidth(), tex->getHeight());
	else if (column == 2)					// Type column
		return tex->getType();
	else
		return "INVALID COLUMN";
}
/* MapTextureManager::buildTexInfoList
 * (Re)builds lists with information about all currently available
 * resource textures and flats
 *******************************************************************/
void MapTextureManager::buildTexInfoList()
{
	// Clear
	tex_info.clear();
	flat_info.clear();

	// --- Textures ---

	// Composite textures
	vector<TextureResource::tex_res_t> textures;
	theResourceManager->getAllTextures(textures, NULL);
	for (unsigned a = 0; a < textures.size(); a++)
	{
		CTexture * tex = textures[a].tex;
		Archive* parent = textures[a].parent;
		if (tex->isExtended())
		{
			if (S_CMPNOCASE(tex->getType(), "texture") || S_CMPNOCASE(tex->getType(), "walltexture"))
				tex_info.push_back(map_texinfo_t(tex->getName(), TC_TEXTURES, parent));
			else if (S_CMPNOCASE(tex->getType(), "define"))
				tex_info.push_back(map_texinfo_t(tex->getName(), TC_HIRES, parent));
			else if (S_CMPNOCASE(tex->getType(), "flat"))
				flat_info.push_back(map_texinfo_t(tex->getName(), TC_TEXTURES, parent));
			// Ignore graphics, patches and sprites
		}
		else
			tex_info.push_back(map_texinfo_t(tex->getName(), TC_TEXTUREX, parent, "", tex->getIndex() + 1));
	}

	// Texture namespace patches (TX_)
	if (theGameConfiguration->txTextures())
	{
		vector<ArchiveEntry*> patches;
		theResourceManager->getAllPatchEntries(patches, NULL);
		for (unsigned a = 0; a < patches.size(); a++)
		{
			if (patches[a]->isInNamespace("textures") || patches[a]->isInNamespace("hires"))
			{
				// Determine texture path if it's in a pk3
				string path = patches[a]->getPath();
				if (path.StartsWith("/textures/"))
					path.Remove(0, 9);
				else if (path.StartsWith("/hires/"))
					path.Remove(0, 6);
				else
					path = "";

				tex_info.push_back(map_texinfo_t(patches[a]->getName(true), TC_TX, patches[a]->getParent(), path));
			}
		}
	}

	// Flats
	vector<ArchiveEntry*> flats;
	theResourceManager->getAllFlatEntries(flats, NULL);
	for (unsigned a = 0; a < flats.size(); a++)
	{
		ArchiveEntry* entry = flats[a];

		// Determine flat path if it's in a pk3
		string path = entry->getPath();
		if (path.StartsWith("/flats/") || path.StartsWith("/hires/"))
			path.Remove(0, 6);
		else
			path = "";

		flat_info.push_back(map_texinfo_t(entry->getName(true), TC_NONE, flats[a]->getParent(), path));
	}
}