bool LoadViewerSettings (const char *filename) { LONG lResult; // Registry function result code DWORD dwDisposition; // Type of key opening event HKEY hModelKey; lResult = RegViewerSettingsKey( filename, &hModelKey, &dwDisposition); if (lResult != ERROR_SUCCESS) // Failure return false; // First time, just set to Valve default if (dwDisposition == REG_CREATED_NEW_KEY) { return false; } RegReadQAngle( hModelKey, "Rot", g_viewerSettings.rot ); RegReadVector( hModelKey, "Trans", g_viewerSettings.trans ); RegReadColor( hModelKey, "bgColor", g_viewerSettings.bgColor ); RegReadColor( hModelKey, "gColor", g_viewerSettings.gColor ); RegReadColor( hModelKey, "lColor", g_viewerSettings.lColor ); RegReadColor( hModelKey, "aColor", g_viewerSettings.aColor ); RegReadQAngle( hModelKey, "lightrot", g_viewerSettings.lightrot ); RegReadInt( hModelKey, "sequence", &g_viewerSettings.sequence ); RegReadInt( hModelKey, "overlaySequence0", &g_viewerSettings.overlaySequence[0] ); RegReadFloat( hModelKey, "overlayWeight0", &g_viewerSettings.overlayWeight[0] ); RegReadInt( hModelKey, "overlaySequence1", &g_viewerSettings.overlaySequence[1] ); RegReadFloat( hModelKey, "overlayWeight1", &g_viewerSettings.overlayWeight[1] ); RegReadInt( hModelKey, "overlaySequence2", &g_viewerSettings.overlaySequence[2] ); RegReadFloat( hModelKey, "overlayWeight2", &g_viewerSettings.overlayWeight[2] ); RegReadInt( hModelKey, "overlaySequence3", &g_viewerSettings.overlaySequence[3] ); RegReadFloat( hModelKey, "overlayWeight3", &g_viewerSettings.overlayWeight[3] ); RegReadInt( hModelKey, "renderwidth", &g_viewerSettings.width ); RegReadInt( hModelKey, "renderheight", &g_viewerSettings.height ); RegReadFloat( hModelKey, "speedscale", &g_viewerSettings.speedScale ); if (g_viewerSettings.speedScale > 1.0) g_viewerSettings.speedScale = 1.0; g_viewerSettings.width = max( 200, g_viewerSettings.width ); g_viewerSettings.height = max( 150, g_viewerSettings.height ); RegReadInt( hModelKey, "viewermode", &g_viewerSettings.application_mode ); RegReadInt( hModelKey, "thumbnailsize", &g_viewerSettings.thumbnailsize ); if ( g_viewerSettings.thumbnailsize == 0 ) { g_viewerSettings.thumbnailsize = 128; } RegReadInt( hModelKey, "speechapiindex", &g_viewerSettings.speechapiindex ); return true; }
bool SaveViewerSettings (const char *filename, StudioModel *pModel ) { LONG lResult; // Registry function result code DWORD dwDisposition; // Type of key opening event if (filename == NULL || pModel == NULL) return false; HKEY hModelKey; lResult = RegViewerSettingsKey( filename, &hModelKey, &dwDisposition); if (lResult != ERROR_SUCCESS) // Failure return false; MDLCACHE_CRITICAL_SECTION_( g_pMDLCache ); CStudioHdr *hdr = pModel->GetStudioHdr(); RegWriteQAngle( hModelKey, "Rot", pModel->m_angles ); RegWriteVector( hModelKey, "Trans", pModel->m_origin ); RegWriteColor( hModelKey, "bgColor", g_viewerSettings.bgColor ); RegWriteColor( hModelKey, "gColor", g_viewerSettings.gColor ); RegWriteColor( hModelKey, "lColor", g_viewerSettings.lColor ); RegWriteColor( hModelKey, "aColor", g_viewerSettings.aColor ); RegWriteQAngle( hModelKey, "lightrot", g_viewerSettings.lightrot ); RegWriteString( hModelKey, "sequence", hdr->pSeqdesc( pModel->GetSequence() ).pszLabel() ); RegWriteString( hModelKey, "overlaySequence0", hdr->pSeqdesc( pModel->GetOverlaySequence( 0 ) ).pszLabel() ); RegWriteFloat( hModelKey, "overlayWeight0", pModel->GetOverlaySequenceWeight( 0 ) ); RegWriteString( hModelKey, "overlaySequence1", hdr->pSeqdesc( pModel->GetOverlaySequence( 1 ) ).pszLabel() ); RegWriteFloat( hModelKey, "overlayWeight1", pModel->GetOverlaySequenceWeight( 1 ) ); RegWriteString( hModelKey, "overlaySequence2", hdr->pSeqdesc( pModel->GetOverlaySequence( 2 ) ).pszLabel() ); RegWriteFloat( hModelKey, "overlayWeight2", pModel->GetOverlaySequenceWeight( 2 ) ); RegWriteString( hModelKey, "overlaySequence3", hdr->pSeqdesc( pModel->GetOverlaySequence( 3 ) ).pszLabel() ); RegWriteFloat( hModelKey, "overlayWeight3", pModel->GetOverlaySequenceWeight( 3 ) ); RegWriteInt( hModelKey, "renderwidth", g_viewerSettings.width ); RegWriteInt( hModelKey, "renderheight", g_viewerSettings.height ); RegWriteFloat( hModelKey, "speedscale", g_viewerSettings.speedScale ); RegWriteInt( hModelKey, "viewermode", g_viewerSettings.application_mode ); RegWriteInt( hModelKey, "thumbnailsize", g_viewerSettings.thumbnailsize ); RegWriteInt( hModelKey, "thumbnailsizeanim", g_viewerSettings.thumbnailsizeanim ); RegWriteInt( hModelKey, "speechapiindex", g_viewerSettings.speechapiindex ); RegWriteInt( hModelKey, "cclanguageid", g_viewerSettings.cclanguageid ); RegWriteInt( hModelKey, "showground", g_viewerSettings.showGround ); RegWriteInt( hModelKey, "showbackground", g_viewerSettings.showBackground ); RegWriteInt( hModelKey, "showshadow", g_viewerSettings.showShadow ); RegWriteInt( hModelKey, "showillumpos", g_viewerSettings.showIllumPosition ); RegWriteInt( hModelKey, "enablenormalmapping", g_viewerSettings.enableNormalMapping ); RegWriteString( hModelKey, "merge0", g_viewerSettings.mergeModelFile[0] ); RegWriteString( hModelKey, "merge1", g_viewerSettings.mergeModelFile[1] ); RegWriteString( hModelKey, "merge2", g_viewerSettings.mergeModelFile[2] ); RegWriteString( hModelKey, "merge3", g_viewerSettings.mergeModelFile[3] ); return true; }
bool SaveViewerSettingsInt ( const char *keyname, int value ) { LONG lResult; // Registry function result code DWORD dwDisposition; // Type of key opening event HKEY hModelKey; lResult = RegViewerSettingsKey( "hlfaceposer", &hModelKey, &dwDisposition); if (lResult != ERROR_SUCCESS) // Failure return false; RegWriteInt( hModelKey, keyname, value ); return true; }
bool SaveViewerSettings (const char *filename) { LONG lResult; // Registry function result code DWORD dwDisposition; // Type of key opening event HKEY hModelKey; lResult = RegViewerSettingsKey( filename, &hModelKey, &dwDisposition); if (lResult != ERROR_SUCCESS) // Failure return false; RegWriteQAngle( hModelKey, "Rot", g_viewerSettings.rot ); RegWriteVector( hModelKey, "Trans", g_viewerSettings.trans ); RegWriteColor( hModelKey, "bgColor", g_viewerSettings.bgColor ); RegWriteColor( hModelKey, "gColor", g_viewerSettings.gColor ); RegWriteColor( hModelKey, "lColor", g_viewerSettings.lColor ); RegWriteColor( hModelKey, "aColor", g_viewerSettings.aColor ); RegWriteQAngle( hModelKey, "lightrot", g_viewerSettings.lightrot ); RegWriteInt( hModelKey, "sequence", g_viewerSettings.sequence ); RegWriteInt( hModelKey, "overlaySequence0", g_viewerSettings.overlaySequence[0] ); RegWriteFloat( hModelKey, "overlayWeight0", g_viewerSettings.overlayWeight[0] ); RegWriteInt( hModelKey, "overlaySequence1", g_viewerSettings.overlaySequence[1] ); RegWriteFloat( hModelKey, "overlayWeight1", g_viewerSettings.overlayWeight[1] ); RegWriteInt( hModelKey, "overlaySequence2", g_viewerSettings.overlaySequence[2] ); RegWriteFloat( hModelKey, "overlayWeight2", g_viewerSettings.overlayWeight[2] ); RegWriteInt( hModelKey, "overlaySequence3", g_viewerSettings.overlaySequence[3] ); RegWriteFloat( hModelKey, "overlayWeight3", g_viewerSettings.overlayWeight[3] ); RegWriteInt( hModelKey, "renderwidth", g_viewerSettings.width ); RegWriteInt( hModelKey, "renderheight", g_viewerSettings.height ); RegWriteFloat( hModelKey, "speedscale", g_viewerSettings.speedScale ); RegWriteInt( hModelKey, "viewermode", g_viewerSettings.application_mode ); RegWriteInt( hModelKey, "thumbnailsize", g_viewerSettings.thumbnailsize ); RegWriteInt( hModelKey, "speechapiindex", g_viewerSettings.speechapiindex ); return true; }
bool LoadViewerSettingsInt( char const *keyname, int *value ) { LONG lResult; // Registry function result code DWORD dwDisposition; // Type of key opening event HKEY hModelKey; lResult = RegViewerSettingsKey( "hlfaceposer", &hModelKey, &dwDisposition); if (lResult != ERROR_SUCCESS) // Failure return false; // First time, just set to Valve default if (dwDisposition == REG_CREATED_NEW_KEY) { return false; } *value = 0; RegReadInt( hModelKey, keyname, value ); return true; }
bool LoadViewerSettings (const char *filename, StudioModel *pModel ) { LONG lResult; // Registry function result code DWORD dwDisposition; // Type of key opening event HKEY hModelKey; if (filename == NULL || pModel == NULL) return false; lResult = RegViewerSettingsKey( filename, &hModelKey, &dwDisposition); if (lResult != ERROR_SUCCESS) // Failure return false; // First time, just set to Valve default if (dwDisposition == REG_CREATED_NEW_KEY) { return false; } RegReadQAngle( hModelKey, "Rot", pModel->m_angles ); RegReadVector( hModelKey, "Trans", pModel->m_origin ); RegReadColor( hModelKey, "bgColor", g_viewerSettings.bgColor ); RegReadColor( hModelKey, "gColor", g_viewerSettings.gColor ); RegReadColor( hModelKey, "lColor", g_viewerSettings.lColor ); RegReadColor( hModelKey, "aColor", g_viewerSettings.aColor ); RegReadQAngle( hModelKey, "lightrot", g_viewerSettings.lightrot ); int iTemp; float flTemp; char szTemp[256]; RegReadString( hModelKey, "sequence", szTemp, sizeof( szTemp ) ); iTemp = pModel->LookupSequence( szTemp ); pModel->SetSequence( iTemp ); RegReadString( hModelKey, "overlaySequence0", szTemp, sizeof( szTemp ) ); iTemp = pModel->LookupSequence( szTemp ); RegReadFloat( hModelKey, "overlayWeight0", &flTemp ); pModel->SetOverlaySequence( 0, iTemp, flTemp ); RegReadString( hModelKey, "overlaySequence1", szTemp, sizeof( szTemp ) ); iTemp = pModel->LookupSequence( szTemp ); RegReadFloat( hModelKey, "overlayWeight1", &flTemp ); pModel->SetOverlaySequence( 1, iTemp, flTemp ); RegReadString( hModelKey, "overlaySequence2", szTemp, sizeof( szTemp ) ); iTemp = pModel->LookupSequence( szTemp ); RegReadFloat( hModelKey, "overlayWeight2", &flTemp ); pModel->SetOverlaySequence( 2, iTemp, flTemp ); RegReadString( hModelKey, "overlaySequence3", szTemp, sizeof( szTemp ) ); iTemp = pModel->LookupSequence( szTemp ); RegReadFloat( hModelKey, "overlayWeight3",&flTemp ); pModel->SetOverlaySequence( 3, iTemp, flTemp ); RegReadInt( hModelKey, "renderwidth", &g_viewerSettings.width ); RegReadInt( hModelKey, "renderheight", &g_viewerSettings.height ); RegReadFloat( hModelKey, "speedscale", &g_viewerSettings.speedScale ); if (g_viewerSettings.speedScale > 1.0) g_viewerSettings.speedScale = 1.0; g_viewerSettings.width = MAX( 200, g_viewerSettings.width ); g_viewerSettings.height = MAX( 150, g_viewerSettings.height ); RegReadInt( hModelKey, "viewermode", &g_viewerSettings.application_mode ); RegReadInt( hModelKey, "thumbnailsize", &g_viewerSettings.thumbnailsize ); RegReadInt( hModelKey, "thumbnailsizeanim", &g_viewerSettings.thumbnailsizeanim ); if ( g_viewerSettings.thumbnailsize == 0 ) { g_viewerSettings.thumbnailsize = 128; } if ( g_viewerSettings.thumbnailsizeanim == 0 ) { g_viewerSettings.thumbnailsizeanim = 128; } RegReadInt( hModelKey, "speechapiindex", &g_viewerSettings.speechapiindex ); RegReadInt( hModelKey, "cclanguageid", &g_viewerSettings.cclanguageid ); RegReadBool( hModelKey, "showground", &g_viewerSettings.showGround ); RegReadBool( hModelKey, "showbackground", &g_viewerSettings.showBackground ); RegReadBool( hModelKey, "showshadow", &g_viewerSettings.showShadow ); RegReadBool( hModelKey, "showillumpos", &g_viewerSettings.showIllumPosition ); RegReadBool( hModelKey, "enablenormalmapping", &g_viewerSettings.enableNormalMapping ); RegReadString( hModelKey, "merge0", g_viewerSettings.mergeModelFile[0], sizeof( g_viewerSettings.mergeModelFile[0] ) ); RegReadString( hModelKey, "merge1", g_viewerSettings.mergeModelFile[1], sizeof( g_viewerSettings.mergeModelFile[1] ) ); RegReadString( hModelKey, "merge2", g_viewerSettings.mergeModelFile[2], sizeof( g_viewerSettings.mergeModelFile[2] ) ); RegReadString( hModelKey, "merge3", g_viewerSettings.mergeModelFile[3], sizeof( g_viewerSettings.mergeModelFile[3] ) ); return true; }