mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-17 10:52:46 +00:00
Remove hsFiles in favor of plFilesystem stuff
This commit is contained in:
@ -1063,7 +1063,7 @@ uint8_t *plFont::IGetFreeCharData( uint32_t &newOffset )
|
||||
//// LoadFromP2FFile //////////////////////////////////////////////////////////
|
||||
// Handy quick wrapper
|
||||
|
||||
bool plFont::LoadFromP2FFile( const char *path )
|
||||
bool plFont::LoadFromP2FFile( const plFileName &path )
|
||||
{
|
||||
hsUNIXStream stream;
|
||||
if( stream.Open( path, "rb" ) )
|
||||
|
@ -289,7 +289,7 @@ class plFont : public hsKeyedObject
|
||||
bool LoadFromBDF( const char *path, plBDFConvertCallback *callback );
|
||||
bool LoadFromBDFStream( hsStream *stream, plBDFConvertCallback *callback );
|
||||
|
||||
bool LoadFromP2FFile( const char *path );
|
||||
bool LoadFromP2FFile( const plFileName &path );
|
||||
|
||||
bool ReadRaw( hsStream *stream );
|
||||
bool WriteRaw( hsStream *stream );
|
||||
|
@ -57,7 +57,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#include "plFont.h"
|
||||
#include "plStatusLog/plStatusLog.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "pnMessage/plRefMsg.h"
|
||||
|
||||
#include "hsResMgr.h"
|
||||
@ -71,7 +70,6 @@ plFontCache *plFontCache::fInstance = nil;
|
||||
|
||||
plFontCache::plFontCache()
|
||||
{
|
||||
fCustFontDir = nil;
|
||||
RegisterAs( kFontCache_KEY );
|
||||
fInstance = this;
|
||||
}
|
||||
@ -79,7 +77,6 @@ plFontCache::plFontCache()
|
||||
plFontCache::~plFontCache()
|
||||
{
|
||||
Clear();
|
||||
delete [] fCustFontDir;
|
||||
fInstance = nil;
|
||||
}
|
||||
|
||||
@ -151,46 +148,38 @@ plFont *plFontCache::GetFont( const char *face, uint8_t size, uint32_t fontFlag
|
||||
return nil;
|
||||
}
|
||||
|
||||
void plFontCache::LoadCustomFonts( const char *dir )
|
||||
void plFontCache::LoadCustomFonts( const plFileName &dir )
|
||||
{
|
||||
delete [] fCustFontDir;
|
||||
fCustFontDir = ( dir != nil ) ? hsStrcpy( dir ) : nil;
|
||||
|
||||
fCustFontDir = dir;
|
||||
ILoadCustomFonts();
|
||||
}
|
||||
|
||||
void plFontCache::ILoadCustomFonts( void )
|
||||
void plFontCache::ILoadCustomFonts( void )
|
||||
{
|
||||
if( fCustFontDir == nil )
|
||||
if (!fCustFontDir.IsValid())
|
||||
return;
|
||||
|
||||
// Iterate through all the custom fonts in our dir
|
||||
hsFolderIterator iter( fCustFontDir );
|
||||
char fileName[ kFolderIterator_MaxPath ];
|
||||
|
||||
|
||||
hsFolderIterator iter2( fCustFontDir );
|
||||
while( iter2.NextFileSuffix( ".p2f" ) )
|
||||
std::vector<plFileName> fonts = plFileSystem::ListDir(fCustFontDir, "*.p2f");
|
||||
for (auto iter = fonts.begin(); iter != fonts.end(); ++iter)
|
||||
{
|
||||
iter2.GetPathAndName( fileName );
|
||||
|
||||
plFont *font = new plFont;
|
||||
if( !font->LoadFromP2FFile( fileName ) )
|
||||
if (!font->LoadFromP2FFile(*iter))
|
||||
delete font;
|
||||
else
|
||||
{
|
||||
plString keyName;
|
||||
if( font->GetKey() == nil )
|
||||
if (font->GetKey() == nil)
|
||||
{
|
||||
keyName = plString::Format( "%s-%d", font->GetFace(), font->GetSize() );
|
||||
hsgResMgr::ResMgr()->NewKey( keyName, font, plLocation::kGlobalFixedLoc );
|
||||
}
|
||||
|
||||
hsgResMgr::ResMgr()->AddViaNotify( font->GetKey(),
|
||||
new plGenRefMsg( GetKey(), plRefMsg::kOnCreate, 0, -1 ),
|
||||
plRefFlags::kActiveRef );
|
||||
hsgResMgr::ResMgr()->AddViaNotify( font->GetKey(),
|
||||
new plGenRefMsg( GetKey(), plRefMsg::kOnCreate, 0, -1 ),
|
||||
plRefFlags::kActiveRef );
|
||||
|
||||
//plStatusLog::AddLineS( "pipeline.log", "FontCache: Added custom font %s", keyName );
|
||||
//plStatusLog::AddLineS( "pipeline.log", "FontCache: Added custom font %s", keyName.c_str() );
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "HeadSpin.h"
|
||||
#include "hsTemplates.h"
|
||||
#include "pnKeyedObject/hsKeyedObject.h"
|
||||
#include "plFileSystem.h"
|
||||
|
||||
|
||||
//// Class Definition /////////////////////////////////////////////////////////
|
||||
@ -69,9 +70,9 @@ class plFontCache : public hsKeyedObject
|
||||
protected:
|
||||
|
||||
hsTArray<plFont *> fCache;
|
||||
char *fCustFontDir;
|
||||
plFileName fCustFontDir;
|
||||
|
||||
static plFontCache *fInstance;
|
||||
static plFontCache *fInstance;
|
||||
|
||||
void ILoadCustomFonts( void );
|
||||
|
||||
@ -96,7 +97,7 @@ class plFontCache : public hsKeyedObject
|
||||
// void FreeFont( HFONT font );
|
||||
void Clear( void );
|
||||
|
||||
void LoadCustomFonts( const char *dir );
|
||||
void LoadCustomFonts( const plFileName &dir );
|
||||
|
||||
// Our custom font extension
|
||||
static const char* kCustFontExtension;
|
||||
|
@ -63,7 +63,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plWinFontCache.h"
|
||||
|
||||
#include "plStatusLog/plStatusLog.h"
|
||||
#include "plFile/hsFiles.h"
|
||||
#include "plGImage/plDynSurfaceWriter.h"
|
||||
|
||||
#if HS_BUILD_FOR_WIN32
|
||||
@ -234,11 +233,11 @@ void plWinFontCache::Clear( void )
|
||||
for( i = 0; i < fCustFonts.GetCount(); i++ )
|
||||
{
|
||||
#if (_WIN32_WINNT >= 0x0500)
|
||||
if( plDynSurfaceWriter::CanHandleLotsOfThem() )
|
||||
RemoveFontResourceEx( fCustFonts[ i ]->fFilename, FR_PRIVATE, 0 );
|
||||
if (plDynSurfaceWriter::CanHandleLotsOfThem())
|
||||
RemoveFontResourceExW(fCustFonts[i]->fFilename.AsString().ToWchar(), FR_PRIVATE, 0);
|
||||
else
|
||||
#endif
|
||||
if( RemoveFontResource( fCustFonts[ i ]->fFilename ) == 0 )
|
||||
if (RemoveFontResourceW(fCustFonts[i]->fFilename.AsString().ToWchar()) == 0)
|
||||
{
|
||||
int q= 0;
|
||||
DWORD e = GetLastError();
|
||||
@ -267,31 +266,27 @@ void plWinFontCache::ILoadCustomFonts( void )
|
||||
return;
|
||||
|
||||
// Iterate through all the custom fonts in our dir
|
||||
hsFolderIterator iter( fCustFontDir );
|
||||
char fileName[ kFolderIterator_MaxPath ];
|
||||
int numAdded;
|
||||
int numAdded;
|
||||
|
||||
|
||||
while( iter.NextFileSuffix( kCustFontExtension ) )
|
||||
std::vector<plFileName> fonts = plFileSystem::ListDir(fCustFontDir, kCustFontExtension);
|
||||
for (auto iter = fonts.begin(); iter != fonts.end(); ++iter)
|
||||
{
|
||||
iter.GetPathAndName( fileName );
|
||||
|
||||
// Note that this call can be translated as "does my OS suck?"
|
||||
#if (_WIN32_WINNT >= 0x0500)
|
||||
if( plDynSurfaceWriter::CanHandleLotsOfThem() )
|
||||
numAdded = AddFontResourceEx( fileName, FR_PRIVATE, 0 );
|
||||
numAdded = AddFontResourceExW(iter->AsString().ToWchar(), FR_PRIVATE, 0);
|
||||
else
|
||||
#endif
|
||||
numAdded = AddFontResource( fileName );
|
||||
numAdded = AddFontResourceW(iter->AsString().ToWchar());
|
||||
|
||||
if( numAdded > 0 )
|
||||
{
|
||||
plStatusLog::AddLineS( "pipeline.log", "WinFontCache: Added custom font %s, %d fonts", fileName, numAdded );
|
||||
fCustFonts.Append( new plCustFont( fileName ) );
|
||||
plStatusLog::AddLineS( "pipeline.log", "WinFontCache: Added custom font %s, %d fonts", iter->GetFileName().c_str(), numAdded );
|
||||
fCustFonts.Append(new plCustFont(*iter));
|
||||
}
|
||||
else
|
||||
{
|
||||
plStatusLog::AddLineS( "pipeline.log", "WinFontCache: Unable to load custom font %s", fileName );
|
||||
plStatusLog::AddLineS( "pipeline.log", "WinFontCache: Unable to load custom font %s", iter->GetFileName().c_str() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,10 +90,9 @@ class plWinFontCache
|
||||
class plCustFont
|
||||
{
|
||||
public:
|
||||
char *fFilename;
|
||||
plFileName fFilename;
|
||||
|
||||
plCustFont( const char *c ) { fFilename = hsStrcpy( c ); }
|
||||
~plCustFont() { delete [] fFilename; }
|
||||
plCustFont(const plFileName &c) { fFilename = c; }
|
||||
};
|
||||
|
||||
bool fInShutdown;
|
||||
|
Reference in New Issue
Block a user