コード例 #1
0
void plAgeDescInterface::IGetAgeFiles(std::vector<plAgeFile*>& ageFiles)
{
    IClearAgeFiles(ageFiles);

    char agePath[MAX_PATH];

    // Make list of "local" ages. This might contain copies of those in AssetMan, so we make the
    // list first and take out the ones that are in AssetMan
    char localPath[MAX_PATH];
    if (IGetLocalAgePath(localPath))
    {
        hsFolderIterator ageFolder(localPath);
        while (ageFolder.NextFileSuffix(".age"))
        {
            ageFolder.GetPathAndName(agePath);

            plAgeFile* age = new plAgeFile(plAgeFile::kLocalFile, agePath);
            ageFiles.push_back(age);
        }
    }

#ifdef MAXASS_AVAILABLE
    // Add AssetMan ages, if available (since we're static, go thru the main MaxAss interface)
    // Hoikas (many years later) does not believe the above comment...
    MaxAssInterface *assetMan = GetMaxAssInterface();
    if( assetMan!= nil )
    {
        hsTArray<jvUniqueId> doneAssets;

        jvArray<jvUniqueId>* assets = assetMan->GetAssetsByType(MaxAssInterface::kTypeAge);
        for (int i = 0; i < assets->Size(); i++)
        {
            if( doneAssets.Find( (*assets)[ i ] ) == doneAssets.kMissingIndex )
            {
                if (assetMan->GetLatestVersionFile((*assets)[i], agePath, sizeof(agePath)))
                {
                    plAgeFile* age = new plAgeFile(plAgeFile::kAssetFile, agePath, (*assets)[i]);

                    int existing = IFindAge(age->fAgeName.c_str(), ageFiles);
                    // Remove it from our "local" list if there, since it's a duplicate
                    if (existing != -1)
                    {
                        delete ageFiles[existing];
                        ageFiles[existing] = age;
                    }
                    else
                        ageFiles.push_back(age);

                    doneAssets.Append( (*assets)[ i ] );
                }
            }
        }
        assets->DeleteSelf();
    }
#endif
}
コード例 #2
0
bool    plPlasmaMAXLayer::GetBitmapFileName( char *destFilename, int maxLength, int index /* = 0 */ )
{
#ifdef MAXASS_AVAILABLE
    jvUniqueId targetAssetId;
    GetBitmapAssetId(targetAssetId, index);

    MaxAssInterface* maxAssInterface = GetMaxAssInterface();
    if (maxAssInterface != nil && !targetAssetId.IsEmpty()) 
    {
        // Download the latest version and retrieve the filename
        if (maxAssInterface->GetLatestVersionFile(targetAssetId, destFilename, maxLength))
            return true;
    }
#endif

    // Normal return
    if( GetPBBitmap( index ) == nil )
        return false;

    strncpy( destFilename, GetPBBitmap( index )->bi.Name(), maxLength );
    return true;
}
コード例 #3
0
void plPlasmaMAXLayer::SetBitmap(BitmapInfo *bi, int index)
{
#ifdef MAXASS_AVAILABLE
    jvUniqueId targetAssetId;
    GetBitmapAssetId(targetAssetId, index);
#endif

    Bitmap *BM = GetMaxBitmap(index);
    if (BM)
    {
        BM->DeleteThis();
        BM = NULL;
    }
    
    if (bi)
    {
#ifdef MAXASS_AVAILABLE
        if (!targetAssetId.IsEmpty())
        {
            // If this texture has an assetId, we will check the
            // asset database and make sure we have the latest version
            // of the texture file before loading it
            MaxAssInterface* assInterface = GetMaxAssInterface();
            if (assInterface) 
            {
                char buf[20];
                assInterface->UniqueIdToString(targetAssetId, buf);
                bi->SetDevice(buf);
            
                const char* filename = bi->Name();
                // Download the latest version and retrieve the filename
                char newfilename[MAX_PATH];
                if (assInterface->GetLatestVersionFile(targetAssetId, newfilename, sizeof(newfilename)))
                {
                    // If the filename has changed, we have to reset the bitmap in the ParamBlock
                    if(stricmp(filename, newfilename) != 0)
                        bi->SetName(newfilename);
                }
            }
        }
#endif

        BMMRES result;
        BM = TheManager->Load(bi, &result);
        if (result == BMMRES_SUCCESS)
            ISetMaxBitmap(BM, index);
        else
            ISetMaxBitmap(NULL, index);

        // The load may have failed, but we still want to set the paramblock. We
        // don't want to modify the layer if we're just missing the file.
        PBBitmap pbBitmap(*bi);
        ISetPBBitmap(&pbBitmap, index);
    }
    else
    {
        ISetMaxBitmap(NULL, index);
        ISetPBBitmap(NULL, index);
    }

/*
    Bitmap *BM = GetMaxBitmap(index);

    if (BM)
    {
        BM->DeleteThis();
        BM = NULL;
    }
    
    if (filename)
    {
        BitmapInfo bi;
        bi.SetName(filename);

        // If this texture has an assetId, get the latest version from AssetMan before loading it
        if (assetId && !assetId->IsEmpty())
        {
            MaxAssInterface* maxAssInterface = GetMaxAssInterface();
            if (maxAssInterface) 
            {
                // Download the latest version and retrieve the filename
                char newfilename[MAX_PATH];
                if (maxAssInterface->GetLatestVersionFile(*assetId, newfilename, sizeof(newfilename)))
                {
                    // If the filename has changed, we have to reset the bitmap in the ParamBlock
                    if (stricmp(filename, newfilename) != 0)
                    {
                        bi.SetName(newfilename);
                    }
                }
            }
        }

        ISetMaxBitmap(TheManager->Load(&bi));

        PBBitmap pbBitmap(bi);
//      TheManager->LoadInto(&pbBitmap.bi, &pbBitmap.bm, TRUE);
        ISetPBBitmap(&pbBitmap, index);

        if (assetId)
            SetBitmapAssetId(*assetId, index);
    }
    else
    {
        ISetMaxBitmap(NULL, index);
        ISetPBBitmap(NULL, index);
    }

    NotifyDependents(FOREVER, PART_ALL, REFMSG_CHANGE);
*/
}