[saco] Implement/match CFontRender::MeasureText(...)

This commit is contained in:
RD42
2024-07-23 18:55:50 +08:00
parent 07904813b5
commit 05250c0aa2
2 changed files with 18 additions and 12 deletions

View File

@ -1,6 +1,6 @@
#include "main.h" #include "main.h"
#include "fontrender.h" #include "game/util.h"
int GetFontSize(); int GetFontSize();
int GetFontWeight(); int GetFontWeight();
@ -105,11 +105,18 @@ void CFontRender::RestoreDeviceObjects()
SIZE CFontRender::MeasureText(char * szString, DWORD dwFormat) SIZE CFontRender::MeasureText(char * szString, DWORD dwFormat)
{ {
SIZE size = {0,0}; RECT rect;
SIZE ret = {0, 0};
// TODO: CFontRender::MeasureText .text:1006B200 if(strlen(szString) > 100000) return ret;
return size; strcpy(field_1C,szString);
RemoveColorEmbedsFromString(field_1C);
field_0->DrawTextA(NULL,field_1C,-1,&rect,dwFormat|DT_CALCRECT,0xFF000000);
ret.cx = rect.right - rect.left;
ret.cy = rect.bottom - rect.top;
return ret;
} }
void CFontRender::RenderText(ID3DXSprite * pSprite, char * sz, RECT rect, DWORD dwColor, BOOL bShadowed) void CFontRender::RenderText(ID3DXSprite * pSprite, char * sz, RECT rect, DWORD dwColor, BOOL bShadowed)

View File

@ -1,9 +1,10 @@
#pragma once #pragma once
class CFontRender // size: 40 class CFontRender
{ {
private: public:
//char _gap0[40];
ID3DXFontHook *field_0; ID3DXFontHook *field_0;
ID3DXFontHook *field_4; ID3DXFontHook *field_4;
ID3DXFont *field_8; ID3DXFont *field_8;
@ -11,12 +12,10 @@ private:
ID3DXFont *field_10; ID3DXFont *field_10;
ID3DXSprite *field_14; ID3DXSprite *field_14;
IDirect3DDevice9 *m_pD3DDevice; IDirect3DDevice9 *m_pD3DDevice;
CHAR *field_1C; char *field_1C;
LONG field_20; LONG field_20;
LONG field_24; LONG field_24;
public:
CFontRender(IDirect3DDevice9* pD3DDevice); CFontRender(IDirect3DDevice9* pD3DDevice);
~CFontRender(); ~CFontRender();
@ -25,7 +24,7 @@ public:
void DeleteDeviceObjects(); void DeleteDeviceObjects();
void RestoreDeviceObjects(); void RestoreDeviceObjects();
SIZE MeasureText(char * szString, DWORD dwFormat = 0); SIZE MeasureText(char * szString, DWORD dwFormat = DT_LEFT);
void RenderText(ID3DXSprite * pSprite, char * sz, RECT rect, DWORD dwColor, BOOL bShadowed = TRUE); void RenderText(ID3DXSprite * pSprite, char * sz, RECT rect, DWORD dwColor, BOOL bShadowed = TRUE);
}; };