Esempio n. 1
0
// -----------------------------------------------------------------------------
// Loads all editor images (thing icons, etc) from the program resource archive
// -----------------------------------------------------------------------------
void MapTextureManager::importEditorImages(MapTexHashMap& map, ArchiveTreeNode* dir, std::string_view path) const
{
	SImage image;

	// Go through entries
	for (unsigned a = 0; a < dir->numEntries(); a++)
	{
		auto entry = dir->entryAt(a);

		// Load entry to image
		if (image.open(entry->data()))
		{
			// Create texture in hashmap
			auto name = fmt::format("{}{}", path, entry->nameNoExt());
			Log::info(4, "Loading editor texture {}", name);
			auto& mtex = map[name];
			mtex.gl_id = OpenGL::Texture::createFromImage(image, nullptr, OpenGL::TexFilter::Mipmap);
		}
	}

	// Go through subdirs
	for (unsigned a = 0; a < dir->nChildren(); a++)
	{
		auto subdir = dynamic_cast<ArchiveTreeNode*>(dir->child(a));
		importEditorImages(map, subdir, fmt::format("{}{}/", path, subdir->name()));
	}
}
Esempio n. 2
0
std::string dropExtension( const std::string& filename)
{
    std::string nameNoExt( filename);
    std::string::size_type findExt= nameNoExt.rfind( '.');
    if ( findExt != std::string::npos)
        if( *(nameNoExt.begin()+ findExt+ 1) != '\\')
            nameNoExt.erase( nameNoExt.begin()+ findExt, nameNoExt.end());	// delete '.' too.
    return nameNoExt;
}