bool ProjectViewModel::GetAttr( const wxDataViewItem& item, unsigned int column, wxDataViewItemAttr& attr ) const { if ( !item.IsOk() ) { return false; } Asset *node = static_cast< Asset* >( item.GetID() ); HELIUM_ASSERT( node ); // bold the entry if the node is active attr.SetBold( node->IsPackage() ); if ( node->GetAllFlagsSet( Asset::FLAG_EDITOR_FORCIBLY_LOADED ) ) { attr.SetColour( *wxBLACK ); } else { attr.SetColour( *wxLIGHT_GREY ); } // italicize the entry if it is modified attr.SetItalic( node->GetAllFlagsSet( Asset::FLAG_CHANGED_SINCE_LOADED ) ); if ( node->GetAllFlagsSet( Asset::FLAG_CHANGED_SINCE_LOADED ) ) { attr.SetColour( *wxRED ); } return true; }
/// Begin asynchronous loading of an object. /// /// @param[in] path Asset path. /// /// @return ID for the load request if started successfully, invalid index if not. /// /// @see TryFinishLoad(), FinishLoad() size_t AssetLoader::BeginLoadObject( AssetPath path ) { HELIUM_TRACE( TraceLevels::Info, TXT(" AssetLoader::BeginLoadObject - Loading path %s\n"), *path.ToString() ); // Search for an existing load request with the given path. ConcurrentHashMap< AssetPath, LoadRequest* >::ConstAccessor requestConstAccessor; if( m_loadRequestMap.Find( requestConstAccessor, path ) ) { LoadRequest* pRequest = requestConstAccessor->Second(); HELIUM_ASSERT( pRequest ); AtomicIncrementRelease( pRequest->requestCount ); // We can release now, as the request shouldn't get released now that we've incremented its reference count. requestConstAccessor.Release(); return m_loadRequestPool.GetIndex( pRequest ); } Asset *pAsset = Asset::Find<Asset>( path ); if ( pAsset && !pAsset->GetAllFlagsSet( Asset::FLAG_LOADED ) ) { pAsset = NULL; } PackageLoader *pPackageLoader = 0; if ( pAsset ) { HELIUM_TRACE( TraceLevels::Info, TXT( "AssetLoader::BeginLoadObject(): Object \"%s\" already loaded.\n" ), *path.ToString() ); } else { // Get the package loader to use for the given object. pPackageLoader = GetPackageLoader( path ); if( !pPackageLoader ) { HELIUM_TRACE( TraceLevels::Error, TXT( "AssetLoader::BeginLoadObject(): Failed to locate package loader for \"%s\".\n" ), *path.ToString() ); return Invalid< size_t >(); } } // Add the load request. LoadRequest* pRequest = m_loadRequestPool.Allocate(); pRequest->path = path; pRequest->pPackageLoader = pPackageLoader; SetInvalid( pRequest->packageLoadRequestId ); pRequest->stateFlags = pAsset ? (pAsset->GetFlags() & Asset::FLAG_BROKEN ? LOAD_FLAG_FULLY_LOADED | LOAD_FLAG_ERROR : LOAD_FLAG_FULLY_LOADED ) : 0; pRequest->requestCount = 1; HELIUM_ASSERT( !pRequest->spObject ); pRequest->spObject = pAsset; ConcurrentHashMap< AssetPath, LoadRequest* >::Accessor requestAccessor; if( m_loadRequestMap.Insert( requestAccessor, KeyValue< AssetPath, LoadRequest* >( path, pRequest ) ) ) { // New load request was created, so tick it once to get the load process running. requestAccessor.Release(); TickLoadRequest( pRequest ); } else { // A matching request was added while we were building our request, so reuse it. m_loadRequestPool.Release( pRequest ); pRequest = requestAccessor->Second(); HELIUM_ASSERT( pRequest ); AtomicIncrementRelease( pRequest->requestCount ); // We can release now, as the request shouldn't get released now that we've incremented its reference count. requestAccessor.Release(); } return m_loadRequestPool.GetIndex( pRequest ); }