mirror of
https://github.com/celisej567/source-sdk-2013.git
synced 2026-09-23 20:09:45 +03:00
Added map-specific closed captioning files
This commit is contained in:
@@ -2630,6 +2630,124 @@ void CHudCloseCaption::InitCaptionDictionary( const char *dbfile )
|
||||
g_AsyncCaptionResourceManager.SetDbInfo( m_AsyncCaptions );
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
void CHudCloseCaption::AddAdditionalCaptionDictionary( const char *dbfile, CUtlVector<CUtlSymbol> &outPathSymbols )
|
||||
{
|
||||
CGMsg( 1, CON_GROUP_MAPBASE_MISC, "Adding additional caption dictionary \"%s\"\n", dbfile );
|
||||
|
||||
g_AsyncCaptionResourceManager.Clear();
|
||||
|
||||
char searchPaths[4096];
|
||||
filesystem->GetSearchPath( "MOD", true, searchPaths, sizeof( searchPaths ) );
|
||||
|
||||
for ( char *path = strtok( searchPaths, ";" ); path; path = strtok( NULL, ";" ) )
|
||||
{
|
||||
if ( IsX360() && ( filesystem->GetDVDMode() == DVDMODE_STRICT ) && !V_stristr( path, ".zip" ) )
|
||||
{
|
||||
// only want zip paths
|
||||
continue;
|
||||
}
|
||||
|
||||
char fullpath[MAX_PATH];
|
||||
Q_snprintf( fullpath, sizeof( fullpath ), "%s%s", path, dbfile );
|
||||
Q_FixSlashes( fullpath );
|
||||
|
||||
if ( IsX360() )
|
||||
{
|
||||
char fullpath360[MAX_PATH];
|
||||
UpdateOrCreateCaptionFile( fullpath, fullpath360, sizeof( fullpath360 ) );
|
||||
Q_strncpy( fullpath, fullpath360, sizeof( fullpath ) );
|
||||
}
|
||||
|
||||
// Seach for this dictionary. If it already exists, remove it.
|
||||
for (int i = 0; i < m_AsyncCaptions.Count(); ++i)
|
||||
{
|
||||
if (FStrEq( m_AsyncCaptions[i].m_DataBaseFile.String(), fullpath ))
|
||||
{
|
||||
m_AsyncCaptions.Remove( i );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FileHandle_t fh = filesystem->Open( fullpath, "rb" );
|
||||
if ( FILESYSTEM_INVALID_HANDLE != fh )
|
||||
{
|
||||
MEM_ALLOC_CREDIT();
|
||||
|
||||
CUtlBuffer dirbuffer;
|
||||
|
||||
AsyncCaption_t& entry = m_AsyncCaptions[ m_AsyncCaptions.AddToTail() ];
|
||||
|
||||
// Read the header
|
||||
filesystem->Read( &entry.m_Header, sizeof( entry.m_Header ), fh );
|
||||
if ( entry.m_Header.magic != COMPILED_CAPTION_FILEID )
|
||||
Error( "Invalid file id for %s\n", fullpath );
|
||||
if ( entry.m_Header.version != COMPILED_CAPTION_VERSION )
|
||||
Error( "Invalid file version for %s\n", fullpath );
|
||||
if ( entry.m_Header.directorysize < 0 || entry.m_Header.directorysize > 64 * 1024 )
|
||||
Error( "Invalid directory size %d for %s\n", entry.m_Header.directorysize, fullpath );
|
||||
//if ( entry.m_Header.blocksize != MAX_BLOCK_SIZE )
|
||||
// Error( "Invalid block size %d, expecting %d for %s\n", entry.m_Header.blocksize, MAX_BLOCK_SIZE, fullpath );
|
||||
|
||||
int directoryBytes = entry.m_Header.directorysize * sizeof( CaptionLookup_t );
|
||||
entry.m_CaptionDirectory.EnsureCapacity( entry.m_Header.directorysize );
|
||||
dirbuffer.EnsureCapacity( directoryBytes );
|
||||
|
||||
filesystem->Read( dirbuffer.Base(), directoryBytes, fh );
|
||||
filesystem->Close( fh );
|
||||
|
||||
entry.m_CaptionDirectory.CopyArray( (const CaptionLookup_t *)dirbuffer.PeekGet(), entry.m_Header.directorysize );
|
||||
entry.m_CaptionDirectory.RedoSort( true );
|
||||
|
||||
entry.m_DataBaseFile = fullpath;
|
||||
outPathSymbols.AddToTail( entry.m_DataBaseFile );
|
||||
}
|
||||
}
|
||||
|
||||
g_AsyncCaptionResourceManager.SetDbInfo( m_AsyncCaptions );
|
||||
}
|
||||
|
||||
void CHudCloseCaption::AddCustomCaptionFile( char const *file, CUtlVector<CUtlSymbol> &outPathSymbols )
|
||||
{
|
||||
//
|
||||
// 'file' should be something like "maps/mapbase_demo01_closecaption_%language%"
|
||||
//
|
||||
|
||||
CGMsg( 1, CON_GROUP_MAPBASE_MISC, "Adding custom caption file \"%s\"\n", file );
|
||||
|
||||
if (!IsX360())
|
||||
{
|
||||
g_pVGuiLocalize->AddFile( file, "MOD", true );
|
||||
}
|
||||
|
||||
char uilanguage[64];
|
||||
engine->GetUILanguage( uilanguage, sizeof( uilanguage ) );
|
||||
|
||||
char dbfile[512];
|
||||
V_StrSubst( file, "%language%", uilanguage, dbfile, sizeof( dbfile ) );
|
||||
V_SetExtension( dbfile, ".dat", sizeof( dbfile ) );
|
||||
AddAdditionalCaptionDictionary( dbfile, outPathSymbols );
|
||||
}
|
||||
|
||||
void CHudCloseCaption::RemoveCaptionDictionary( const CUtlSymbol &dbFileSymbol )
|
||||
{
|
||||
//
|
||||
// 'file' should be something like "maps/mapbase_demo01_closecaption_%language%"
|
||||
//
|
||||
|
||||
CGMsg( 1, CON_GROUP_MAPBASE_MISC, "Removing custom caption file \"%s\"\n", dbFileSymbol.String() );
|
||||
|
||||
for (int i = 0; i < m_AsyncCaptions.Count(); ++i)
|
||||
{
|
||||
if ( m_AsyncCaptions[i].m_DataBaseFile == dbFileSymbol )
|
||||
{
|
||||
m_AsyncCaptions.Remove( i );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void CHudCloseCaption::OnFinishAsyncLoad( int nFileIndex, int nBlockNum, AsyncCaptionData_t *pData )
|
||||
{
|
||||
// Fill in data for all users of pData->m_nBlockNum
|
||||
|
||||
Reference in New Issue
Block a user