From e0ed438bf2cff4e08e0b649a96601d53fcd83bdc Mon Sep 17 00:00:00 2001 From: ricardoofnl Date: Sat, 1 Aug 2026 19:13:05 +0700 Subject: [PATCH] [saco] Implement/match `CChatWindow::CreateFonts` --- saco/chatwindow.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++- saco/chatwindow.h | 6 ++--- saco/cmdprocs.cpp | 2 +- 3 files changed, 65 insertions(+), 5 deletions(-) diff --git a/saco/chatwindow.cpp b/saco/chatwindow.cpp index 310e9fa..d7d29e0 100644 --- a/saco/chatwindow.cpp +++ b/saco/chatwindow.cpp @@ -1,6 +1,8 @@ #include "main.h" +extern CConfig *pConfig; + //---------------------------------------------------- CChatWindow::CChatWindow(IDirect3DDevice9 *pD3DDevice, CFontRender *pFontRender, CHAR *szChatLogFile) @@ -57,8 +59,66 @@ CChatWindow::CChatWindow(IDirect3DDevice9 *pD3DDevice, CFontRender *pFontRender, void CChatWindow::CreateFonts() { + D3DSURFACE_DESC desc; + HRESULT hr; - // TODO: CChatWindow::CreateFonts .text:100681D0 + field_63B2 = 1; + + if(field_63BE) { + field_63BE->Release(); + field_63BE = NULL; + } + + if(field_63BA) { + field_63BA->Release(); + field_63BA = NULL; + } + + if(field_63B6) { + field_63B6->Release(); + field_63B6 = NULL; + } + + m_pD3DDevice->GetDisplayMode(0,&field_63C2); + + if(pConfig->GetIntVariable("directmode")) { + AddDebugMessage("ChatWindow: Using direct drawing mode."); + FUNC_10067120(); + field_63B2 = 0; + return; + } + + // the render target has to cover the whole screen + if(field_63C2.Width <= 1024) { + hr = D3DXCreateTexture(m_pD3DDevice,1024,512,1,D3DUSAGE_RENDERTARGET, + D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,&field_63BA); + } else { + hr = D3DXCreateTexture(m_pD3DDevice,2048,1024,1,D3DUSAGE_RENDERTARGET, + D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,&field_63BA); + } + + if(hr < 0) { + AddDebugMessage("ChatWindow: Can't create a render surface texture. Will use direct mode."); + field_63B2 = 0; + return; + } + + field_63BA->GetSurfaceLevel(0,&field_63BE); + field_63BE->GetDesc(&desc); + + if(D3DXCreateRenderToSurface(m_pD3DDevice,desc.Width,desc.Height,desc.Format, + TRUE,D3DFMT_D16,&field_63B6) < 0) + { + AddDebugMessage("ChatWindow: Can't create a render to surface. Will use direct mode."); + FUNC_10067120(); + field_63B2 = 0; + return; + } + + FUNC_10067120(); + + field_63D6 = 0; + m_bRedraw = 1; } //---------------------------------------------------- diff --git a/saco/chatwindow.h b/saco/chatwindow.h index aaafaff..9b0fdb7 100644 --- a/saco/chatwindow.h +++ b/saco/chatwindow.h @@ -35,7 +35,7 @@ public: int field_63B2; ID3DXRenderToSurface *field_63B6; IDirect3DTexture9* field_63BA; - int field_63BE; + IDirect3DSurface9 *field_63BE; D3DDISPLAYMODE field_63C2; DWORD field_63D2; int field_63D6; @@ -45,9 +45,9 @@ public: char _gap63E6[4]; - void CreateFonts(); + void CreateFonts(); // .text:100681D0 - void FUNC_100681D0(); + int FUNC_10067120(); void FUNC_10067200(); diff --git a/saco/cmdprocs.cpp b/saco/cmdprocs.cpp index 06842a7..7d40c08 100644 --- a/saco/cmdprocs.cpp +++ b/saco/cmdprocs.cpp @@ -72,7 +72,7 @@ void cmdFontSize(PCHAR szCmd) if(pDefaultFont) pDefaultFont->CreateFonts(); if(pChatWindow) { - pChatWindow->FUNC_100681D0(); + pChatWindow->CreateFonts(); pChatWindow->FUNC_10067200(); } if(pDeathWindow) pDeathWindow->CreateFonts();