[saco] Implement CDXUTDialogResourceManager::AddFont(...)

This commit is contained in:
RD42 2024-05-24 22:53:50 +08:00
parent fd4965bf98
commit efc90f78e3
2 changed files with 38 additions and 0 deletions

View File

@ -219,6 +219,42 @@ VOID CDXUTDialog::SendEvent( UINT nEvent, bool bTriggeredByUser, CDXUTControl* p
}
//--------------------------------------------------------------------------------------
int CDXUTDialogResourceManager::AddFont( LPCTSTR strFaceName, LONG height, LONG weight )
{
// See if this font already exists
for( int i=0; i < m_FontCache.GetSize(); i++ )
{
DXUTFontNode* pFontNode = m_FontCache.GetAt(i);
if( 0 == _strnicmp( pFontNode->strFace, strFaceName, MAX_PATH-1 ) &&
pFontNode->nHeight == height &&
pFontNode->nWeight == weight )
{
return i;
}
}
// Add a new font and try to create it
DXUTFontNode* pNewFontNode = new DXUTFontNode();
if( pNewFontNode == NULL )
return -1;
ZeroMemory( pNewFontNode, sizeof(DXUTFontNode) );
StringCchCopy( pNewFontNode->strFace, MAX_PATH, strFaceName );
pNewFontNode->nHeight = height;
pNewFontNode->nWeight = weight;
m_FontCache.Add( pNewFontNode );
int iFont = m_FontCache.GetSize()-1;
// If a device is available, try to create immediately
if( m_pd3dDevice )
CreateFont( iFont );
return iFont;
}
//--------------------------------------------------------------------------------------
// CDXUTControl class
//--------------------------------------------------------------------------------------

View File

@ -181,6 +181,8 @@ public:
HRESULT OnResetDevice();
void OnLostDevice();
void OnDestroyDevice();
int AddFont( LPCTSTR strFaceName, LONG height, LONG weight );
// Shared between all dialogs
IDirect3DStateBlock9* m_pStateBlock;