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 }
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; }
BOOL plPlasmaMAXLayer::HandleBitmapSelection(int index /* = 0 */) { static ICustButton* bmSelectBtn; PBBitmap *pbbm = GetPBBitmap( index ); #ifdef MAXASS_AVAILABLE MaxAssInterface* maxAssInterface = GetMaxAssInterface(); #endif // If the control key is held, we want to get rid of this texture if ((GetKeyState(VK_CONTROL) & 0x8000) && pbbm != nil) { char msg[512]; sprintf(msg, "Are you sure you want to change this bitmap from %s to (none)?", pbbm->bi.Name()); if (hsMessageBox(msg, "Remove texture?", hsMessageBoxYesNo) == hsMBoxYes) { SetBitmap(nil, index); return TRUE; } return FALSE; } // if we have the assetman plug-in, then try to use it, unless shift is held down #ifdef MAXASS_AVAILABLE else if(maxAssInterface && !(GetKeyState(VK_SHIFT) & 0x8000)) { jvUniqueId assetId; GetBitmapAssetId(assetId, index); char filename[MAX_PATH]; if (maxAssInterface->OpenBitmapDlg(assetId, filename, sizeof(filename))) { SetBitmapAssetId(assetId, index); BitmapInfo bi; bi.SetName(filename); SetBitmap(&bi, index); return TRUE; } } #endif else { BitmapInfo bi; if( pbbm != NULL ) bi.SetName( pbbm->bi.Name() ); BOOL selectedNewBitmap = TheManager->SelectFileInput(&bi, GetCOREInterface()->GetMAXHWnd(), _T("Select Bitmap Image File")); if (selectedNewBitmap) { #ifdef MAXASS_AVAILABLE // Set the assetId to empty so our new, unmanaged texture will take jvUniqueId emptyId; SetBitmapAssetId(emptyId, index); #endif SetBitmap(&bi, index); return TRUE; } } return FALSE; }
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); */ }