示例#1
0
const AssetInfo getIntensityAssetInfo(const AssetId& id, AssetManager* manager)
{
    return AssetInfo(
        manager->getLocalAssetHash(id),
        id
    );
}
const AssetInfo ListFileProvider::getAssetInfo( int index )
{
	if ( index < 0 || getNumItems() <= index )
		return AssetInfo();

	SimpleMutexHolder smh( mutex_ );
	ListItemPtr item;
	if ( isFiltering() )
		item = searchResults_[ index ];
	else
		item = items_[ index ];

	return AssetInfo(
		type_,
		item->title,
		item->fileName );
}
const AssetInfo SmartListCtrl::getAssetInfo( int index )
{
	XmlItem* item = getCustomItem( index );
	if ( item )
		return item->assetInfo();

	if ( !provider_ || index >= provider_->getNumItems() )
		return AssetInfo();

	return provider_->getAssetInfo( index );
}
void SmartListCtrl::thumbManagerUpdate( const std::string& longText )
{
	if ( !GetSafeHwnd() || longText.empty() )
		return;

	std::string longTextTmp = longText;
	std::replace( longTextTmp.begin(), longTextTmp.end(), '/', '\\' );
	std::string textTmp = longTextTmp.c_str() + longTextTmp.find_last_of( '\\' ) + 1;

	updateItem(
		AssetInfo( "", textTmp, longTextTmp ),
		false /* dont try to remove from cache, it's not there */ );
}
示例#5
0
文件: Asset.cpp 项目: zenkovich/o2
	AssetInfo Asset::GetAssetInfo() const
	{
		return AssetInfo(mPath, GetAssetId(), &GetType());
	}
VFolderItemDataPtr VFolderFileProvider::getNextChild( ThumbnailManager& thumbnailManager, CImage& img )
{
	if ( finderStack_.empty() )
		return 0;

	FileFinderPtr finder = topFinderStack();

	if ( !finder )
		return 0;

	bool found = false;
	int group;
	std::string name;
	VFolderFileItemData::ItemDataType type;
	while( !finder->eof )
	{
		finder->eof = finder->files.FindNextFile()?false:true;

		if ( !finder->files.IsDirectory() )
		{
			// check filters
			filterHolder_->enableSearchText( false );
			if ( ( !filterHolder_ ||
				filterHolder_->filter( (LPCTSTR)finder->files.GetFileName(), (LPCTSTR)finder->files.GetFilePath() ) ) &&
				( includeFolders_.empty() ||
					StringUtils::matchSpec( (LPCTSTR)finder->files.GetRoot(), includeFolders_ ) ) )
			{
				// file
				if ( ( flags_ & FILETREE_SHOWFILES )
					&& StringUtils::matchExtension( (LPCTSTR)finder->files.GetFileName(), extensions_ )
					&& finder->files.GetFileName().Find( thumbnailPostfix_.c_str() ) == -1 
					&& finder->files.GetFileName().Find( ".thumbnail.bmp" ) == -1 )
				{
					std::string filePath = (LPCTSTR)finder->files.GetFilePath();
					// if it's not a DDS, or if its a DDS and a corresponding
					// source image file doesn't exists, return the file.
					if ( BWResource::getExtension( filePath ) != "dds" ||
						(!PathFileExists( BWResource::changeExtension( filePath, ".bmp" ).c_str() ) &&
						!PathFileExists( BWResource::changeExtension( filePath, ".png" ).c_str() ) &&
						!PathFileExists( BWResource::changeExtension( filePath, ".tga" ).c_str() ) ) )
					{
						name = (LPCTSTR)finder->files.GetFileName();
						group = FILEGROUP_FILE;
						type = VFolderFileItemData::ITEMDATA_FILE;
						thumbnailManager.create( filePath, img, 16, 16, folderTree_ );
						found = true;
					}
				}
			}
			filterHolder_->enableSearchText( true );
			if ( found )
				break;
		}
		else if ( !finder->files.IsDots() )
		{
			// dir
			if ( excludeFolders_.empty() ||
					!StringUtils::matchSpec( (LPCTSTR)finder->files.GetFilePath(), excludeFolders_ ) )
			{
				if ( flags_ & FILETREE_SHOWSUBFOLDERS )
				{
					// return the folder's name
					name = finder->files.GetFileName();
					group = FILEGROUP_FOLDER;
					type = VFolderFileItemData::ITEMDATA_FOLDER;
					found = true;
					break;
				}
				else if ( ( flags_ & FILETREE_SHOWFILES )
						&& !( flags_ & FILETREE_DONTRECURSE ) )
				{
					// push the folder in the finder stack to find all files in it
					std::vector<std::string> subPaths;
					std::string path = (LPCTSTR)finder->files.GetFilePath();
					subPaths.push_back( path );
					path += "\\*.*";
					FileFinderPtr newFinder = new FileFinder();
					if ( newFinder->files.FindFile( path.c_str() ) )
					{
						newFinder->paths = subPaths;
						newFinder->path = newFinder->paths.begin();
						newFinder->pathEnd = newFinder->paths.end();
						newFinder->eof = false;

						finderStack_.push( newFinder );
						finder = newFinder;
					}
				}
			}
		}

		if ( finder->eof )
		{
			finder = topFinderStack();

			if ( !finder )
				return 0;
		}
	}

	if ( found )
	{
		VFolderFileItemData* newItem =
			new VFolderFileItemData( this,
				type,
				AssetInfo(
					type==VFolderFileItemData::ITEMDATA_FOLDER?"FOLDER":"FILE",
					name.c_str(),
					(LPCTSTR)finder->files.GetFilePath() ),
				group, (group == FILEGROUP_FILE)?false:true );
		return newItem;
	}
	else
	{
		return 0;
	}
}