From e3617099bc605fa76db586a4dc44866aec40700f Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Sat, 27 Jul 2024 17:41:17 +0800 Subject: [PATCH] [saco] Implement/match `CDeathWindow::CreateFonts()` * Implement/match `CDeathWindow::GetSymbolSize()` --- saco/deathwindow.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++ saco/deathwindow.h | 20 ++++++++++---- 2 files changed, 78 insertions(+), 5 deletions(-) diff --git a/saco/deathwindow.cpp b/saco/deathwindow.cpp index 25552c4..e2d2c8d 100644 --- a/saco/deathwindow.cpp +++ b/saco/deathwindow.cpp @@ -1,6 +1,10 @@ #include "main.h" +int GetDeathWindowFontSize(); +char* GetFontFace(); +int GetFontWeight(); + //---------------------------------------------------- CDeathWindow::CDeathWindow(IDirect3DDevice9 *pD3DDevice) @@ -21,6 +25,44 @@ void CDeathWindow::CreateAuxFonts() field_14B = TRUE; } +//---------------------------------------------------- + +void CDeathWindow::CreateFonts() +{ + if(!m_pD3DDevice) return; + + RECT rectLongestNick = {0,0,0,0}; + int iFontSize; + + SAFE_RELEASE(m_pD3DFont); + SAFE_RELEASE(m_pWeaponFont); + SAFE_RELEASE(m_pWeaponFont2); + SAFE_RELEASE(m_pSprite); + + iFontSize = GetDeathWindowFontSize(); + + // Create a sprite to use when drawing text + D3DXCreateSprite(m_pD3DDevice,&m_pSprite); + + D3DXCreateFont(m_pD3DDevice, iFontSize, 0, GetFontWeight(), 1, FALSE, + DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, GetFontFace(), &m_pD3DFont); + + // Store the rect for right aligned name (DT_RIGHT fucks the text) + if(m_pD3DFont) m_pD3DFont->DrawText(0,"LONGESTNICKNICK_NICKNICK",-1,&rectLongestNick,DT_CALCRECT|DT_LEFT,0xFF000000); + + m_iLongestNickLength = rectLongestNick.right - rectLongestNick.left; + + D3DXCreateFont(m_pD3DDevice, iFontSize + 8, 0, FW_NORMAL, 1, FALSE, + SYMBOL_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "GTAWEAPON3", &m_pWeaponFont); + D3DXCreateFont(m_pD3DDevice, iFontSize + 12, 0, FW_NORMAL, 1, FALSE, + SYMBOL_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "GTAWEAPON3", &m_pWeaponFont2); + + field_12F = GetSymbolSize().cx; + field_133 = GetSymbolSize().cy; +} + +//---------------------------------------------------- + void CDeathWindow::AddMessage( CHAR *szKiller, CHAR *szKillee, DWORD dwKillerColor, @@ -64,6 +106,27 @@ void CDeathWindow::PushBack() //---------------------------------------------------- +SIZE CDeathWindow::GetSymbolSize() +{ + SIZE ret; + RECT rectSize; + + rectSize.top = 0; + rectSize.bottom = 100; + rectSize.left = 0; + rectSize.right = 100; + + if(m_pWeaponFont2) { + m_pWeaponFont2->DrawText(0,"G",-1,&rectSize,DT_CALCRECT|DT_NOCLIP|DT_VCENTER,0xFF000000); + } + + ret.cx = rectSize.right - rectSize.left; + ret.cy = rectSize.bottom - rectSize.top; + return ret; +} + +//---------------------------------------------------- + PCHAR CDeathWindow::SpriteIDForWeapon(BYTE byteWeaponID) { switch (byteWeaponID) { diff --git a/saco/deathwindow.h b/saco/deathwindow.h index a7867f9..dd9ded5 100644 --- a/saco/deathwindow.h +++ b/saco/deathwindow.h @@ -18,17 +18,18 @@ typedef struct _DEATH_WINDOW_ENTRY //---------------------------------------------------- +#pragma pack(1) class CDeathWindow { private: char _gap0[4]; DEATH_WINDOW_ENTRY m_DeathWindowEntries[MAX_DISP_DEATH_MESSAGES]; - char _gap012B[24]; - BOOL field_14B; - ID3DXFont *field_14F; - ID3DXFont *field_153; - + int m_iLongestNickLength; // In screen units, longest nick length; + LONG field_12F; + LONG field_133; + void PushBack(); + SIZE GetSymbolSize(); void AddToDeathWindowBuffer(CHAR *szKiller,CHAR *szKillee,DWORD dwKillerColor,DWORD dwKilleeColor,BYTE byteWeaponID); public: @@ -38,8 +39,17 @@ public: CDeathWindow(IDirect3DDevice9 *pD3DDevice); + void CreateFonts(); void CreateAuxFonts(); + ID3DXFont *m_pD3DFont; + ID3DXFont *m_pWeaponFont; + ID3DXFont *m_pWeaponFont2; + ID3DXSprite *m_pSprite; + IDirect3DDevice9 *m_pD3DDevice; + BOOL field_14B; + ID3DXFont *field_14F; + ID3DXFont *field_153; }; //----------------------------------------------------