Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
hzqst committed Jan 30, 2024
1 parent 283717f commit ceabe2d
Show file tree
Hide file tree
Showing 19 changed files with 98 additions and 215 deletions.
7 changes: 1 addition & 6 deletions Plugins/CaptionMod/BaseUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
#include <IKeyValuesSystem.h>
#include <IGameUIFuncs.h>
#include <IVGUI2Extension.h>
#include "vgui_internal.h"
#include "exportfuncs.h"
#include "privatefuncs.h"
#include "plugins.h"

IGameUIFuncs* gameuifuncs = NULL;

Expand All @@ -26,7 +24,6 @@ namespace vgui
bool VGui_InitInterfacesList(const char *moduleName, CreateInterfaceFn *factoryList, int numFactories);
}


class CVGUI2Extension_BaseUICallbacks : public IVGUI2Extension_BaseUICallbacks
{
public:
Expand Down Expand Up @@ -69,9 +66,7 @@ class CVGUI2Extension_BaseUICallbacks : public IVGUI2Extension_BaseUICallbacks

void Shutdown(void)
{
ClientVGUI_UninstallHooks();

GameUI_UninstallHooks();
}

void Key_Event(int& down, int& keynum, const char*& pszCurrentBinding, VGUI2Extension_CallbackContext* CallbackContext) override
Expand Down
4 changes: 2 additions & 2 deletions Plugins/CaptionMod/CaptionMod.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>.\;$(SolutionDir)include;$(SolutionDir)include\Interface;$(SolutionDir)include\Interface\VGUI;$(SolutionDir)include\HLSDK\cl_dll;$(SolutionDir)include\HLSDK\common;$(SolutionDir)include\HLSDK\engine;$(SolutionDir)include\HLSDK\pm_shared;$(SolutionDir)include\HLSDK\public;$(SolutionDir)include\SteamSDK;$(SolutionDir)include\VGUI;$(SolutionDir)include\vgui_controls;$(SolutionDir)include\SourceSDK;$(SolutionDir)include\SourceSDK\tier0;$(SolutionDir)include\SourceSDK\tier1;$(SolutionDir)include\SourceSDK\vstdlib;$(CapstoneIncludeDirectory);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>.\;$(SolutionDir)include;$(SolutionDir)include\Interface;$(SolutionDir)include\Interface\VGUI;$(SolutionDir)include\HLSDK\cl_dll;$(SolutionDir)include\HLSDK\common;$(SolutionDir)include\HLSDK\engine;$(SolutionDir)include\HLSDK\pm_shared;$(SolutionDir)include\HLSDK\public;$(SolutionDir)include\VGUI;$(SolutionDir)include\vgui_controls;$(SolutionDir)include\SourceSDK;$(SolutionDir)include\SourceSDK\tier0;$(SolutionDir)include\SourceSDK\tier1;$(SolutionDir)include\SourceSDK\vstdlib;$(CapstoneIncludeDirectory);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;STEAM_API_NODLL;VGUI_USE_SURFACE2;VGUI_USE_SCHEME2;NO_MALLOC_OVERRIDE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader />
Expand All @@ -102,7 +102,7 @@ $(GLEWCheckRequirements)</Command>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
<AdditionalIncludeDirectories>.\;$(SolutionDir)include;$(SolutionDir)include\Interface;$(SolutionDir)include\Interface\VGUI;$(SolutionDir)include\HLSDK\cl_dll;$(SolutionDir)include\HLSDK\common;$(SolutionDir)include\HLSDK\engine;$(SolutionDir)include\HLSDK\pm_shared;$(SolutionDir)include\HLSDK\public;$(SolutionDir)include\SteamSDK;$(SolutionDir)include\VGUI;$(SolutionDir)include\vgui_controls;$(SolutionDir)include\SourceSDK;$(SolutionDir)include\SourceSDK\tier0;$(SolutionDir)include\SourceSDK\tier1;$(SolutionDir)include\SourceSDK\vstdlib;$(CapstoneIncludeDirectory);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>.\;$(SolutionDir)include;$(SolutionDir)include\Interface;$(SolutionDir)include\Interface\VGUI;$(SolutionDir)include\HLSDK\cl_dll;$(SolutionDir)include\HLSDK\common;$(SolutionDir)include\HLSDK\engine;$(SolutionDir)include\HLSDK\pm_shared;$(SolutionDir)include\HLSDK\public;$(SolutionDir)include\VGUI;$(SolutionDir)include\vgui_controls;$(SolutionDir)include\SourceSDK;$(SolutionDir)include\SourceSDK\tier0;$(SolutionDir)include\SourceSDK\tier1;$(SolutionDir)include\SourceSDK\vstdlib;$(CapstoneIncludeDirectory);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;STEAM_API_NODLL;VGUI_USE_SURFACE2;VGUI_USE_SCHEME2;NO_MALLOC_OVERRIDE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>Async</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
Expand Down
6 changes: 5 additions & 1 deletion Plugins/CaptionMod/ClientVGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ class CVGUI2Extension_ClientVGUICallbacks : public IVGUI2Extension_ClientVGUICal

void Initialize(CreateInterfaceFn* factories, int count) override
{
vgui::VGui_InitInterfacesList("CaptionMod", factories, count);
if (!vgui::VGui_InitInterfacesList("CaptionMod", factories, count))
{
Sys_Error("Failed to VGui_InitInterfacesList");
return;
}

vgui::scheme()->LoadSchemeFromFile("captionmod/CaptionScheme.res", "CaptionScheme");

Expand Down
176 changes: 6 additions & 170 deletions Plugins/CaptionMod/GameUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,172 +17,9 @@

#include <IVGUI2Extension.h>

#include "Viewport.h"
#include "plugins.h"
#include "privatefuncs.h"
#include <capstone.h>
#include <set>
#include <sstream>

class COptionsSubVideoAdvancedDlg : public vgui::PropertyPage
{
DECLARE_CLASS_SIMPLE(COptionsSubVideoAdvancedDlg, vgui::PropertyPage);

public:
COptionsSubVideoAdvancedDlg(vgui::Panel *parent) : BaseClass(parent, "OptionsSubVideoAdvancedDlg")
{
m_pAnisotropicFiltering = new vgui::ComboBox(this, "AnisotropicFiltering", 5, false);
m_pAnisotropicFiltering->AddItem("1X", NULL);
m_pAnisotropicFiltering->AddItem("2X", NULL);
m_pAnisotropicFiltering->AddItem("4X", NULL);
m_pAnisotropicFiltering->AddItem("8X", NULL);
m_pAnisotropicFiltering->AddItem("16X", NULL);

m_pDetailTexture = new CCvarToggleCheckButton(this, "DetailTexture", "#GameUI_DetailTextures", "r_detailtextures");
m_pWaterShader = new CCvarToggleCheckButton(this, "WaterShader", "#GameUI_WaterShader", "r_water");
m_pDynamicShadow = new CCvarToggleCheckButton(this, "DynamicShadow", "#GameUI_DynamicShadow", "r_shadow");
m_pAmbientOcclusion = new CCvarToggleCheckButton(this, "AmbientOcclusion", "#GameUI_AmbientOcclusion", "r_ssao");
m_pDynamicLights = new CCvarToggleCheckButton(this, "DynamicLights", "#GameUI_DynamicLights", "r_light_dynamic");
m_pScreenSpaceReflection = new CCvarToggleCheckButton(this, "ScreenSpaceReflection", "#GameUI_ScreenSpaceReflection", "r_ssr");
m_pCelShade = new CCvarToggleCheckButton(this, "CelShade", "#GameUI_CelShade", "r_studio_celshade");
m_pAntiAliasing = new CCvarToggleCheckButton(this, "AntiAliasing", "#GameUI_AntiAliasing", "r_fxaa");
m_pSkyOcclusion = new CCvarToggleCheckButton(this, "SkyOcclusion", "#GameUI_SkyOcclusion", "r_wsurf_sky_occlusion");
m_pZPrepass = new CCvarToggleCheckButton(this, "ZPrepass", "#GameUI_ZPrepass", "r_wsurf_zprepass");
m_pHDR = new CCvarToggleCheckButton(this, "HDR", "#GameUI_HDR", "r_hdr");

m_pHDRExposure = new CCvarSlider(this, "HDRExposure", "#GameUI_HDRExposure", 0.1f, 2.0f, "r_hdr_exposure", false);
m_pHDRDarkness = new CCvarSlider(this, "HDRDarkness", "#GameUI_HDRDarkness", 0.1f, 2.0f, "r_hdr_darkness", false);
m_pBloomIntensity = new CCvarSlider(this, "BloomIntensity", "#GameUI_BloomIntensity", 0.0f, 1.0f, "r_hdr_blurwidth", false);
m_pShadowIntensity = new CCvarSlider(this, "ShadowIntensity", "#GameUI_ShadowIntensity", 0.0f, 1.0f, "r_shadow_intensity", false);

m_pTexGamma = new CCvarSlider(this, "TexGamma", "#GameUI_TexGamma", 1.8f, 3.0f, "texgamma", false);
m_pLightGamma = new CCvarSlider(this, "LightGamma", "#GameUI_LightGamma", 1.8f, 3.0f, "lightgamma", false);

LoadControlSettings("captionmod/OptionsSubVideoAdvancedDlg.res");
}

void ApplyChangesToConVar(const char *pConVarName, int value)
{
char szCmd[256] = {0};
Q_snprintf(szCmd, sizeof(szCmd) - 1, "%s %d\n", pConVarName, value);
gEngfuncs.pfnClientCmd(szCmd);
}

void ApplyChanges(void)
{
int activateItem = m_pAnisotropicFiltering->GetActiveItem();

switch (activateItem)
{
case 0: ApplyChangesToConVar("gl_ansio", 1); break;
case 1: ApplyChangesToConVar("gl_ansio", 2); break;
case 2: ApplyChangesToConVar("gl_ansio", 4); break;
case 3: ApplyChangesToConVar("gl_ansio", 8); break;
case 4: ApplyChangesToConVar("gl_ansio", 16); break;
}

ApplyChangesToConVar(m_pDetailTexture->GetCvarName(), m_pDetailTexture->IsSelected());
ApplyChangesToConVar(m_pWaterShader->GetCvarName(), m_pWaterShader->IsSelected());
ApplyChangesToConVar(m_pDynamicShadow->GetCvarName(), m_pDynamicShadow->IsSelected());
ApplyChangesToConVar(m_pAmbientOcclusion->GetCvarName(), m_pAmbientOcclusion->IsSelected());
ApplyChangesToConVar(m_pScreenSpaceReflection->GetCvarName(), m_pScreenSpaceReflection->IsSelected());
ApplyChangesToConVar(m_pCelShade->GetCvarName(), m_pCelShade->IsSelected());
ApplyChangesToConVar(m_pAntiAliasing->GetCvarName(), m_pAntiAliasing->IsSelected());
ApplyChangesToConVar(m_pSkyOcclusion->GetCvarName(), m_pSkyOcclusion->IsSelected());
ApplyChangesToConVar(m_pZPrepass->GetCvarName(), m_pZPrepass->IsSelected());
ApplyChangesToConVar(m_pHDR->GetCvarName(), m_pHDR->IsSelected());

m_pHDRExposure->ApplyChanges();
m_pHDRDarkness->ApplyChanges();
m_pBloomIntensity->ApplyChanges();
m_pShadowIntensity->ApplyChanges();
m_pTexGamma->ApplyChanges();
m_pLightGamma->ApplyChanges();
}

void OnResetData(void) override
{
m_pDetailTexture->Reset();
m_pWaterShader->Reset();
m_pDynamicShadow->Reset();
m_pDynamicLights->Reset();
m_pAmbientOcclusion->Reset();
m_pScreenSpaceReflection->Reset();
m_pCelShade->Reset();
m_pAntiAliasing->Reset();
m_pSkyOcclusion->Reset();
m_pZPrepass->Reset();
m_pHDR->Reset();

m_pHDRExposure->Reset();
m_pHDRDarkness->Reset();
m_pBloomIntensity->Reset();
m_pShadowIntensity->Reset();
m_pTexGamma->Reset();
m_pLightGamma->Reset();

auto gl_ansio = gEngfuncs.pfnGetCvarPointer("gl_ansio");

if (gl_ansio)
{
int ansio = gl_ansio->value;

if (ansio >= 16)
m_pAnisotropicFiltering->ActivateItem(4);
else if (ansio >= 8)
m_pAnisotropicFiltering->ActivateItem(3);
else if (ansio >= 4)
m_pAnisotropicFiltering->ActivateItem(2);
else if (ansio >= 2)
m_pAnisotropicFiltering->ActivateItem(1);
else
m_pAnisotropicFiltering->ActivateItem(0);
}
else
{
m_pAnisotropicFiltering->SetEnabled(false);
}
}

void OnCommand(const char *command) override
{
if (!stricmp(command, "OK"))
{
ApplyChanges();
}
else if (!stricmp(command, "Apply"))
{
ApplyChanges();
}
else
{
BaseClass::OnCommand(command);
}
}

MESSAGE_FUNC(OnDataChanged, "ControlModified");

private:
vgui::ComboBox *m_pAnisotropicFiltering;
CCvarToggleCheckButton *m_pDetailTexture;
CCvarToggleCheckButton *m_pWaterShader;
CCvarToggleCheckButton *m_pDynamicShadow;
CCvarToggleCheckButton *m_pAmbientOcclusion;
CCvarToggleCheckButton *m_pDynamicLights;
CCvarToggleCheckButton *m_pScreenSpaceReflection;
CCvarToggleCheckButton *m_pCelShade;
CCvarToggleCheckButton *m_pAntiAliasing;
CCvarToggleCheckButton *m_pSkyOcclusion;
CCvarToggleCheckButton *m_pZPrepass;
CCvarToggleCheckButton *m_pHDR;

CCvarSlider *m_pHDRExposure;
CCvarSlider *m_pHDRDarkness;
CCvarSlider *m_pBloomIntensity;
CCvarSlider *m_pShadowIntensity;
CCvarSlider *m_pTexGamma;
CCvarSlider *m_pLightGamma;
};
#include "Viewport.h"

class COptionsSubAudioAdvancedDlg : public vgui::PropertyPage
{
Expand Down Expand Up @@ -273,11 +110,6 @@ class COptionsSubAudioAdvancedDlg : public vgui::PropertyPage
CCvarTextEntry *m_pStartTimeScaleEntry;
};

void COptionsSubVideoAdvancedDlg::OnDataChanged()
{
GetParentWithModuleName("GameUI")->PostActionSignal(new KeyValues("ApplyButtonEnable"));
}

void COptionsSubAudioAdvancedDlg::OnDataChanged()
{
GetParentWithModuleName("GameUI")->PostActionSignal(new KeyValues("ApplyButtonEnable"));
Expand All @@ -304,7 +136,11 @@ class CVGUI2Extension_GameUICallbacks : public IVGUI2Extension_GameUICallbacks

void Initialize(CreateInterfaceFn* factories, int count) override
{
vgui::VGui_InitInterfacesList("CaptionMod", factories, count);
if (!vgui::VGui_InitInterfacesList("CaptionMod", factories, count))
{
Sys_Error("Failed to VGui_InitInterfacesList");
return;
}
}

void Start(struct cl_enginefuncs_s* engineFuncs, int interfaceVersion, void* system) override
Expand Down
11 changes: 10 additions & 1 deletion Plugins/CaptionMod/VGUI2ExtensionImport.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@
#include <IDpiManager.h>

void VGUI2Extension_Init();
void VGUI2Extension_Shutdown();
void VGUI2Extension_Shutdown();

void BaseUI_InstallHooks(void);
void BaseUI_UninstallHooks(void);

void GameUI_InstallHooks(void);
void GameUI_UninstallHooks(void);

void ClientVGUI_InstallHooks(void);
void ClientVGUI_UninstallHooks(void);
3 changes: 0 additions & 3 deletions Plugins/CaptionMod/exportfuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
#include "exportfuncs.h"
#include "privatefuncs.h"

//Steam API
#include "steam_api.h"

//Viewport
#include <IVGUI2Extension.h>
#include <VGUI/VGUI.h>
Expand Down
7 changes: 0 additions & 7 deletions Plugins/CaptionMod/privatefuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,6 @@ void Client_UninstallHooks(void);
void Engine_FillAddress(void);
void Engine_InstallHooks(void);
void Engine_UninstallHooks(void);
void BaseUI_InstallHooks(void);
void BaseUI_UninstallHooks(void);
void GameUI_FillAddress(HMODULE hModule);
void GameUI_InstallHooks(void);
void GameUI_UninstallHooks(void);
void ClientVGUI_InstallHooks(void);
void ClientVGUI_UninstallHooks(void);
void FMOD_InstallHooks(HMODULE fmodex);
void FMOD_UninstallHooks(HMODULE fmodex);

Expand Down
6 changes: 6 additions & 0 deletions Plugins/Renderer/BaseUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ static CVGUI2Extension_BaseUICallbacks s_BaseUICallbacks;

void BaseUI_InstallHooks(void)
{
if (!VGUI2Extension())
return;

CreateInterfaceFn fnCreateInterface = g_pMetaHookAPI->GetEngineFactory();

if (!fnCreateInterface)
Expand All @@ -130,5 +133,8 @@ void BaseUI_InstallHooks(void)

void BaseUI_UninstallHooks(void)
{
if (!VGUI2Extension())
return;

VGUI2Extension()->UnregisterBaseUICallbacks(&s_BaseUICallbacks);
}
6 changes: 6 additions & 0 deletions Plugins/Renderer/GameUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,19 @@ GameUI init & shutdown

void GameUI_InstallHooks(void)
{
if (!VGUI2Extension())
return;

VGUI2Extension()->RegisterGameUICallbacks(&s_GameUICallbacks);
VGUI2Extension()->RegisterGameUIOptionDialogCallbacks(&s_GameUIOptionDialogCallbacks);
VGUI2Extension()->RegisterGameUIKeyValuesCallbacks(&s_GameUIKeyValuesCallbacks);
}

void GameUI_UninstallHooks(void)
{
if (!VGUI2Extension())
return;

VGUI2Extension()->UnregisterGameUICallbacks(&s_GameUICallbacks);
VGUI2Extension()->UnregisterGameUIOptionDialogCallbacks(&s_GameUIOptionDialogCallbacks);
VGUI2Extension()->UnregisterGameUIKeyValuesCallbacks(&s_GameUIKeyValuesCallbacks);
Expand Down
1 change: 1 addition & 0 deletions Plugins/Renderer/Renderer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ $(FreeImageCheckRequirements)</Command>
<ClCompile Include="..\..\include\vgui_controls\vgui_controls.cpp" />
<ClCompile Include="..\..\include\vgui_controls\WizardPanel.cpp" />
<ClCompile Include="..\..\include\vgui_controls\WizardSubPanel.cpp" />
<ClCompile Include="BaseUI.cpp" />
<ClCompile Include="exportfuncs.cpp" />
<ClCompile Include="GameUI.cpp" />
<ClCompile Include="gl_cvar.cpp" />
Expand Down
21 changes: 12 additions & 9 deletions Plugins/Renderer/Renderer.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,6 @@
<ClCompile Include="..\..\include\HLSDK\common\interface.cpp">
<Filter>HLSDK</Filter>
</ClCompile>
<ClCompile Include="GameUI.cpp">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="VGUI2ExtensionImport.cpp">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="..\..\include\vgui_controls\AnalogBar.cpp">
<Filter>vgui_controls</Filter>
</ClCompile>
Expand Down Expand Up @@ -431,6 +425,15 @@
<ClCompile Include="..\..\include\SourceSDK\mathlib\sse.cpp">
<Filter>SourceSDK\mathlib</Filter>
</ClCompile>
<ClCompile Include="GameUI.cpp">
<Filter>VGUI2</Filter>
</ClCompile>
<ClCompile Include="VGUI2ExtensionImport.cpp">
<Filter>VGUI2</Filter>
</ClCompile>
<ClCompile Include="BaseUI.cpp">
<Filter>VGUI2</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="bspfile.h">
Expand Down Expand Up @@ -511,9 +514,6 @@
<ClInclude Include="gl_common.h">
<Filter>Header</Filter>
</ClInclude>
<ClInclude Include="VGUI2ExtensionImport.h">
<Filter>Header</Filter>
</ClInclude>
<ClInclude Include="..\..\include\vgui_controls\AnalogBar.h">
<Filter>vgui_controls</Filter>
</ClInclude>
Expand Down Expand Up @@ -928,5 +928,8 @@
<ClInclude Include="..\..\include\SourceSDK\filesystem_helpers.h">
<Filter>SourceSDK</Filter>
</ClInclude>
<ClInclude Include="VGUI2ExtensionImport.h">
<Filter>VGUI2</Filter>
</ClInclude>
</ItemGroup>
</Project>
Loading

0 comments on commit ceabe2d

Please sign in to comment.