From bd79e805b56fa46514f2f0d846b49152ff83e622 Mon Sep 17 00:00:00 2001 From: rexx <67599507+r-ex@users.noreply.github.com> Date: Fri, 1 Jul 2022 22:33:48 +0100 Subject: [PATCH] material debug info overlay (#70) * material debug info overlay * add x/y offset convars * change flags to signature flags is static? * Update vgui_debugpanel.cpp Co-authored-by: PixieCore <41352111+IcePixelx@users.noreply.github.com> --- r5dev/tier1/IConVar.cpp | 4 ++++ r5dev/tier1/cvar.cpp | 4 ++++ r5dev/tier1/cvar.h | 4 ++++ r5dev/vgui/vgui_debugpanel.cpp | 23 +++++++++++++++++++++++ r5dev/vgui/vgui_debugpanel.h | 1 + 5 files changed, 36 insertions(+) diff --git a/r5dev/tier1/IConVar.cpp b/r5dev/tier1/IConVar.cpp index db2a71a4..b0dfd4f1 100644 --- a/r5dev/tier1/IConVar.cpp +++ b/r5dev/tier1/IConVar.cpp @@ -119,6 +119,10 @@ void ConVar::Init(void) const cl_gpustats_offset_x = new ConVar("cl_gpustats_offset_x" , "650", FCVAR_DEVELOPMENTONLY, "X offset for texture streaming debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr); cl_gpustats_offset_y = new ConVar("cl_gpustats_offset_y" , "105", FCVAR_DEVELOPMENTONLY, "Y offset for texture streaming debug overlay.", false, 0.f, false, 0.f, nullptr, nullptr); + cl_showmaterialinfo = new ConVar("cl_showmaterialinfo", "0", FCVAR_DEVELOPMENTONLY, "Draw info for the material under the crosshair on screen", false, 0.f, false, 0.f, nullptr, nullptr); + cl_materialinfo_offset_x = new ConVar("cl_materialinfo_offset_x", "0", FCVAR_DEVELOPMENTONLY, "X offset for material debug info overlay.", false, 0.f, false, 0.f, nullptr, nullptr); + cl_materialinfo_offset_y = new ConVar("cl_materialinfo_offset_y", "420", FCVAR_DEVELOPMENTONLY, "Y offset for material debug info overlay.", false, 0.f, false, 0.f, nullptr, nullptr); + con_max_size_logvector = new ConVar("con_max_size_logvector" , "1000", FCVAR_DEVELOPMENTONLY, "Maximum number of logs in the console until cleanup starts.", false, 0.f, false, 0.f, nullptr, nullptr); con_suggestion_limit = new ConVar("con_suggestion_limit" , "120" , FCVAR_DEVELOPMENTONLY, "Maximum number of suggestions the autocomplete window will show for the console.", false, 0.f, false, 0.f, nullptr, nullptr); con_suggestion_showhelptext = new ConVar("con_suggestion_showhelptext" , "1" , FCVAR_DEVELOPMENTONLY, "Show CommandBase help text in autocomplete window.", false, 0.f, false, 0.f, nullptr, nullptr); diff --git a/r5dev/tier1/cvar.cpp b/r5dev/tier1/cvar.cpp index e9ec1ffb..dfd60bc5 100644 --- a/r5dev/tier1/cvar.cpp +++ b/r5dev/tier1/cvar.cpp @@ -97,6 +97,10 @@ ConVar* cl_gpustats_invert_rect_y = nullptr; ConVar* cl_gpustats_offset_x = nullptr; ConVar* cl_gpustats_offset_y = nullptr; +ConVar* cl_showmaterialinfo = nullptr; +ConVar* cl_materialinfo_offset_x = nullptr; +ConVar* cl_materialinfo_offset_y = nullptr; + ConVar* con_max_size_logvector = nullptr; ConVar* con_suggestion_limit = nullptr; ConVar* con_suggestion_showhelptext = nullptr; diff --git a/r5dev/tier1/cvar.h b/r5dev/tier1/cvar.h index cfa57e97..37a92aae 100644 --- a/r5dev/tier1/cvar.h +++ b/r5dev/tier1/cvar.h @@ -94,6 +94,10 @@ extern ConVar* cl_gpustats_invert_rect_y; extern ConVar* cl_gpustats_offset_x; extern ConVar* cl_gpustats_offset_y; +extern ConVar* cl_showmaterialinfo; +extern ConVar* cl_materialinfo_offset_x; +extern ConVar* cl_materialinfo_offset_y; + extern ConVar* con_max_size_logvector; extern ConVar* con_suggestion_limit; extern ConVar* con_suggestion_showhelptext; diff --git a/r5dev/vgui/vgui_debugpanel.cpp b/r5dev/vgui/vgui_debugpanel.cpp index 4032924b..062bd7ed 100644 --- a/r5dev/vgui/vgui_debugpanel.cpp +++ b/r5dev/vgui/vgui_debugpanel.cpp @@ -16,6 +16,7 @@ #include #include #include +#include //----------------------------------------------------------------------------- // Purpose: @@ -42,6 +43,10 @@ void CLogSystem::Update(void) { DrawHostStats(); } + if (cl_showmaterialinfo->GetBool()) + { + DrawCrosshairMaterial(); + } } //----------------------------------------------------------------------------- @@ -174,6 +179,24 @@ void CLogSystem::DrawGPUStats(void) const CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, 0x13, m_nFontHeight, nWidth, nHeight, c.r(), c.g(), c.b(), c.a(), (char*)szLogbuf); } +void CLogSystem::DrawCrosshairMaterial(void) const +{ + CMaterialGlue* material = GetMaterialAtCrossHair(); + if (material) + return; + + static Color c = { 255, 255, 255, 255 }; + static const char* szLogbuf[4096]{}; + snprintf((char*)szLogbuf, 4096, "name: %s\nguid: %llx\ndimensions: %d x %d\nsurface: %s/%s\nsig: %i", + material->m_pszName, + material->m_GUID, + material->m_iWidth, material->m_iHeight, + material->m_pszSurfaceName1, material->m_pszSurfaceName2, + material->m_UnknownSignature); + + CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, 0x13, m_nFontHeight, cl_materialinfo_offset_x->GetInt(), cl_materialinfo_offset_y->GetInt(), c.r(), c.g(), c.b(), c.a(), (char*)szLogbuf); +} + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- diff --git a/r5dev/vgui/vgui_debugpanel.h b/r5dev/vgui/vgui_debugpanel.h index 69f1c75c..c07bf0e5 100644 --- a/r5dev/vgui/vgui_debugpanel.h +++ b/r5dev/vgui/vgui_debugpanel.h @@ -42,6 +42,7 @@ public: void DrawHostStats(void) const; void DrawSimStats(void) const; void DrawGPUStats(void) const; + void DrawCrosshairMaterial(void) const; private: Color GetLogColorForType(LogType_t type) const;