Skip to content

Commit

Permalink
Add HighDPI font sopport for CaptionMod
Browse files Browse the repository at this point in the history
  • Loading branch information
hzqst committed Oct 25, 2022
1 parent 2bb0d49 commit e0983a3
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Plugins/CaptionMod/BaseUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void CBaseUI::Initialize(CreateInterfaceFn *factories, int count)

KeyValuesSystem_InstallHook();
Surface_InstallHooks();
Scheme_InstallHook();
Scheme_InstallHooks();
GameUI_InstallHooks();
}

Expand Down
1 change: 0 additions & 1 deletion Plugins/CaptionMod/CaptionMod.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\;..\;..\..\;..\..\HLSDK\cl_dll;..\..\HLSDK\common;..\..\HLSDK\engine;..\..\HLSDK\pm_shared;..\..\HLSDK\public;..\..\Interface;.\SourceSDK;.\VGUI;.\vgui_controls;.\SourceSDK\tier0;.\SourceSDK\tier1;.\SourceSDK\vstdlib;..\..\SteamSDK\;..\..\capstone\include\capstone\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;STEAM_API_NODLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<ExceptionHandling>Async</ExceptionHandling>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
Expand Down
2 changes: 1 addition & 1 deletion Plugins/CaptionMod/Scheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ void CScheme::ReloadFontGlyphs(void)
if (fontdata->GetInt("additive"))
flags |= ISurface::FONTFLAG_ADDITIVE;

int tall = fontdata->GetInt("tall");
int tall = (int)(fontdata->GetInt("tall") * g_flDPIScaling);
int blur = fontdata->GetInt("blur");
int scanlines = fontdata->GetInt("scanlines");

Expand Down
2 changes: 1 addition & 1 deletion Plugins/CaptionMod/SourceSDK/SchemeHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ int CSchemeManagerProxy::GetProportionalNormalizedValue(int scaledValue)
static CSchemeManagerProxy g_SchemeProxy;
extern vgui::ISchemeManager *g_pScheme;

void Scheme_InstallHook(void)
void Scheme_InstallHooks(void)
{
DWORD *pVFTable = *(DWORD **)&g_SchemeProxy;

Expand Down
2 changes: 1 addition & 1 deletion Plugins/CaptionMod/SourceSDK/surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ void CSurface::GetAbsoluteWindowBounds( int &x, int &y, int &wide, int &tall )

void CSurface::GetProportionalBase( int &width, int &height )
{
return g_pSurface->GetProportionalBase( width, height );
g_pSurface->GetProportionalBase( width, height );
}

//-----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion Plugins/CaptionMod/exportfuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void VGUI1_InstallHook(void);
void VGUI1_Shutdown(void);
void Surface_InstallHooks(void);
void Surface_UninstallHooks(void);
void Scheme_InstallHook(void);
void Scheme_InstallHooks(void);
void KeyValuesSystem_InstallHook(void);

void *NewClientFactory(void);
Expand Down
4 changes: 4 additions & 0 deletions Plugins/CaptionMod/plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ PVOID g_dwClientBase = 0;
DWORD g_dwClientSize = 0;
int g_iVideoWidth = 0;
int g_iVideoHeight = 0;
float g_flDPIScaling = 1.0f;

PVOID g_dwEngineBase;
DWORD g_dwEngineSize;
Expand Down Expand Up @@ -116,6 +117,9 @@ void IPluginsV4::LoadClient(cl_exportfuncs_t *pExportFunc)
if (!strcmp(windowClass, "Valve001") || !strcmp(windowClass, "SDL_app"))
{
g_MainWnd = hwnd;

g_flDPIScaling = GetDpiForWindow(g_MainWnd) / 96.0f;

return FALSE;
}
}
Expand Down
2 changes: 2 additions & 0 deletions Plugins/CaptionMod/plugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ extern PVOID g_dwClientBase;
extern DWORD g_dwClientSize;
extern int g_iVideoWidth;
extern int g_iVideoHeight;
extern float g_flDPIScaling;

extern PVOID g_dwEngineBase;
extern DWORD g_dwEngineSize;
extern PVOID g_dwEngineTextBase;
Expand Down

0 comments on commit e0983a3

Please sign in to comment.