reimplement stream overlay drawing

This commit is contained in:
rexx 2022-07-20 22:50:55 +01:00
parent 2998953600
commit cb4e422724
7 changed files with 41 additions and 1 deletions

View File

@ -5,7 +5,6 @@
#include "materialsystem/cshaderglue.h"
#endif // !DEDICATED
/******************************************************************************
-------------------------------------------------------------------------------
File : rtech.cpp
@ -655,10 +654,21 @@ RPakLoadedInfo_t* RTech::GetPakLoadedInfo(const char* szPakName)
return nullptr;
}
#if not defined DEDICATED && defined (GAMEDLL_S3)
void RTech_GetStreamOverlay(const char* mode, char* buf, size_t bufSize)
{
// call original first to populate the buffer
GetStreamOverlay(mode, buf, bufSize);
s_StreamOverlayBuf = std::string(buf);
}
#endif
void RTech_Utils_Attach()
{
#if not defined DEDICATED && defined (GAMEDLL_S3)
DetourAttach((LPVOID*)&RTech_CreateDXTexture, &RTech::CreateDXTexture);
DetourAttach((LPVOID*)&GetStreamOverlay, &RTech_GetStreamOverlay);
#endif
}
@ -666,6 +676,7 @@ void RTech_Utils_Detach()
{
#if not defined DEDICATED && defined (GAMEDLL_S3)
DetourDetach((LPVOID*)&RTech_CreateDXTexture, &RTech::CreateDXTexture);
DetourDetach((LPVOID*)&GetStreamOverlay, &RTech_GetStreamOverlay);
#endif
}

View File

@ -450,6 +450,11 @@ public:
#if not defined DEDICATED && defined (GAMEDLL_S3)
inline CMemory p_RTech_CreateDXTexture;
inline auto RTech_CreateDXTexture = p_RTech_CreateDXTexture.RCast<void(*)(RPakTextureHeader_t*, int64_t)>();
inline CMemory p_GetStreamOverlay;
inline auto GetStreamOverlay = p_GetStreamOverlay.RCast<void(*)(const char*, char*, size_t)>();
inline std::string s_StreamOverlayBuf;
#endif
inline RPakLoadedInfo_t* g_pLoadedPakInfo;
@ -494,6 +499,9 @@ class VPakFile : public IDetour
#if not defined DEDICATED && defined (GAMEDLL_S3)
p_RTech_CreateDXTexture = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\xE8\x00\x00\x00\x00\x4C\x8B\xC7\x48\x8B\xD5\x48\x8B\xCB\x48\x83\xC4\x60"), "x????xxxxxxxxxxxxx").FollowNearCallSelf();
RTech_CreateDXTexture = p_RTech_CreateDXTexture.RCast<void(*)(RPakTextureHeader_t*, int64_t)>(); /*E8 ? ? ? ? 4C 8B C7 48 8B D5 48 8B CB 48 83 C4 60*/
p_GetStreamOverlay = g_mGameDll.FindPatternSIMD(reinterpret_cast<rsig_t>("\xE8\x00\x00\x00\x00\x80\x7C\x24\x00\x00\x0F\x84\x00\x00\x00\x00\x48\x89\x9C\x24\x00\x00\x00\x00"), "x????xxx??xx????xxxx????").FollowNearCallSelf();
GetStreamOverlay = p_GetStreamOverlay.RCast<void(*)(const char*, char*, size_t)>();
#endif
}
virtual void GetVar(void) const

View File

@ -192,6 +192,8 @@ void ConVar::InitShipped(void) const
host_hasIrreversibleShutdown = g_pCVar->FindVar("host_hasIrreversibleShutdown");
net_usesocketsforloopback = g_pCVar->FindVar("net_usesocketsforloopback");
stream_overlay = g_pCVar->FindVar("stream_overlay");
mp_gamemode->SetCallback(&MP_GameMode_Changed_f);
}

View File

@ -38,6 +38,8 @@ ConVar* r_debug_overlay_zbuffer = nullptr;
ConVar* r_drawWorldMeshes = nullptr;
ConVar* r_drawWorldMeshesDepthOnly = nullptr;
ConVar* r_drawWorldMeshesDepthAtTheEnd = nullptr;
ConVar* stream_overlay = nullptr;
//-----------------------------------------------------------------------------
// SERVER |
ConVar* ai_ainDumpOnLoad = nullptr;

View File

@ -37,6 +37,8 @@ extern ConVar* r_debug_overlay_zbuffer;
extern ConVar* r_drawWorldMeshes;
extern ConVar* r_drawWorldMeshesDepthOnly;
extern ConVar* r_drawWorldMeshesDepthAtTheEnd;
extern ConVar* stream_overlay;
//-------------------------------------------------------------------------
// SERVER |
extern ConVar* ai_ainDumpOnLoad;

View File

@ -21,6 +21,7 @@
#ifndef CLIENT_DLL
#include <engine/server/server.h>
#endif
#include <rtech/rtech_utils.h>
//-----------------------------------------------------------------------------
// Purpose: proceed a log update
@ -51,6 +52,10 @@ void CLogSystem::Update(void)
{
DrawCrosshairMaterial();
}
if (stream_overlay->GetBool())
{
DrawStreamOverlay();
}
}
//-----------------------------------------------------------------------------
@ -211,6 +216,15 @@ void CLogSystem::DrawCrosshairMaterial(void) const
CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, v_Rui_GetFontFace(), m_nFontHeight, cl_materialinfo_offset_x->GetInt(), cl_materialinfo_offset_y->GetInt(), c.r(), c.g(), c.b(), c.a(), (char*)szLogbuf);
}
void CLogSystem::DrawStreamOverlay(void) const
{
std::string buf = s_StreamOverlayBuf;
static Color c = { 255, 255, 255, 255 };
CMatSystemSurface_DrawColoredText(g_pMatSystemSurface, v_Rui_GetFontFace(), m_nFontHeight, 20, 300, c.r(), c.g(), c.b(), c.a(), (char*)buf.c_str());
}
//-----------------------------------------------------------------------------
// Purpose: get log color for passed type.
//-----------------------------------------------------------------------------

View File

@ -43,6 +43,7 @@ public:
void DrawSimStats(void) const;
void DrawGPUStats(void) const;
void DrawCrosshairMaterial(void) const;
void DrawStreamOverlay(void) const;
private:
Color GetLogColorForType(LogType_t type) const;