r5sdk/r5dev/vgui/vgui_debugpanel.h
Kawe Mazidjatari 8965d6f101 Error/Warning/Con_NPrintf log hook refactor
* Warning now only logs if error level < 5.
* Warning buffer size has been increased to '10000' (internal buffer size).
* Error is now hooked as well.
* Error buffer size has been increased to '4096' (internal buffer size).
* Con_NPrintf has been refactored; 'cl_showhoststats' has been removed.
* Con_NPrintf buffer size has been increased to '4096' (MAXPRINTMSG).
* CTextOverlay::Con_NPrintf now checks the first byte in the character buffer before rendering anything, and sets the first byte to a terminating null character after rendering. This fixes the bug causing the host_speeds overlay to be still drawn while the cvar 'host_speeds' was disabled.
2023-02-19 09:51:46 +01:00

54 lines
1.4 KiB
C++

#pragma once
#include "core/stdafx.h"
#include "mathlib/color.h"
struct CTextNotify
{
CTextNotify(const EGlobalContext_t type, const float nTime, const string& svMessage)
{
this->m_svMessage = svMessage;
this->m_flLifeRemaining = nTime;
this->m_type = type;
}
EGlobalContext_t m_type = EGlobalContext_t::NONE;
float m_flLifeRemaining = 0.0f;
string m_svMessage = "";
};
class CTextOverlay
{
public:
CTextOverlay()
{
m_nFontHeight = 16;
m_nCon_NPrintf_Idx = 0;
memset(m_szCon_NPrintf_Buf, '\0', sizeof(m_szCon_NPrintf_Buf));
}
void Update(void);
void AddLog(const EGlobalContext_t context, const string& svText);
void DrawNotify(void);
void DrawFormat(const int x, const int y, const Color c, const char* pszFormat, ...) const;
void ShouldDraw(const float flFrameTime);
void DrawSimStats(void) const;
void DrawGPUStats(void) const;
void DrawCrosshairMaterial(void) const;
void DrawStreamOverlay(void) const;
void Con_NPrintf(void);
private:
Color GetLogColorForType(const EGlobalContext_t type) const;
vector<CTextNotify> m_vNotifyText;
int m_nFontHeight; // Hardcoded to 16 in this engine.
mutable std::mutex m_Mutex;
public:
int m_nCon_NPrintf_Idx;
char m_szCon_NPrintf_Buf[4096];
};
///////////////////////////////////////////////////////////////////////////////
extern CTextOverlay* g_pOverlay;