From d2c7139b0131a7e0b5d99e8b9efd9c672d11ed49 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Fri, 24 May 2024 22:54:27 +0800 Subject: [PATCH] [saco] Implement `CDXUTDialog::SetFont(...)` --- saco/d3d9/common/DXUTgui.cpp | 23 +++++++++++++++++++++++ saco/d3d9/common/DXUTgui.h | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/saco/d3d9/common/DXUTgui.cpp b/saco/d3d9/common/DXUTgui.cpp index e669314..f83fdb9 100644 --- a/saco/d3d9/common/DXUTgui.cpp +++ b/saco/d3d9/common/DXUTgui.cpp @@ -255,6 +255,29 @@ int CDXUTDialogResourceManager::AddFont( LPCTSTR strFaceName, LONG height, LONG } +//-------------------------------------------------------------------------------------- +HRESULT CDXUTDialog::SetFont( UINT index, LPCTSTR strFaceName, LONG height, LONG weight ) +{ + // If this assert triggers, you need to call CDXUTDialog::Init() first. This change + // was made so that the DXUT's GUI could become seperate and optional from DXUT's core. The + // creation and interfacing with CDXUTDialogResourceManager is now the responsibility + // of the application if it wishes to use DXUT's GUI. + assert( m_pManager != NULL && "To fix call CDXUTDialog::Init() first. See comments for details." ); + + // Make sure the list is at least as large as the index being set + UINT i; + for( i=m_Fonts.GetSize(); i <= index; i++ ) + { + m_Fonts.Add( -1 ); + } + + int iFont = m_pManager->AddFont( strFaceName, height, weight ); + m_Fonts.SetAt( index, iFont ); + + return S_OK; +} + + //-------------------------------------------------------------------------------------- // CDXUTControl class //-------------------------------------------------------------------------------------- diff --git a/saco/d3d9/common/DXUTgui.h b/saco/d3d9/common/DXUTgui.h index e92e6f6..2f8f2ff 100644 --- a/saco/d3d9/common/DXUTgui.h +++ b/saco/d3d9/common/DXUTgui.h @@ -103,6 +103,10 @@ public: // Device state notification void Refresh(); + // Shared resource access. Indexed fonts and textures are shared among + // all the controls. + HRESULT SetFont( UINT index, LPCTSTR strFaceName, LONG height, LONG weight ); + bool m_bNonUserEvents; bool m_bKeyboardInput;