mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Log system adjustments.
This commit is contained in:
parent
7f86722116
commit
ab12789faf
@ -1,8 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#define LOGSYSTEM_LINES_TO_SHOW 3
|
||||
|
||||
enum LogType_t
|
||||
enum class LogType_t : int
|
||||
{
|
||||
SCRIPT_SERVER,
|
||||
SCRIPT_CLIENT,
|
||||
@ -13,6 +11,12 @@ enum LogType_t
|
||||
|
||||
struct Log
|
||||
{
|
||||
Log(const std::string Message, const int Ticks, const LogType_t Type)
|
||||
{
|
||||
this->Message = Message;
|
||||
this->Ticks = Ticks;
|
||||
this->Type = Type;
|
||||
}
|
||||
std::string Message = "";
|
||||
int Ticks = 1024;
|
||||
LogType_t Type = LogType_t::NATIVE;
|
||||
@ -20,7 +24,6 @@ struct Log
|
||||
|
||||
class LogSystem
|
||||
{
|
||||
|
||||
public:
|
||||
void AddLog(LogType_t type, std::string text);
|
||||
void Update();
|
||||
|
@ -127,6 +127,9 @@ namespace
|
||||
|
||||
/*0x1405489C0*/
|
||||
FUNC_AT_ADDRESS(addr_CMatSystemSurface_UnlockCursor, void(*)(void*), MemoryAddress(0x1405489C0).GetPtr()); // Maybe sigscan this via RTTI.
|
||||
|
||||
/*0x140547900*/
|
||||
FUNC_AT_ADDRESS(addr_CMatSystemSurface_DrawColoredText, void(*)(void*, int, int, int, int, int, int, int, int, const char*, ...), MemoryAddress(0x140547900).GetPtr());
|
||||
#pragma region Utility
|
||||
/*0x140295600*/
|
||||
FUNC_AT_ADDRESS(addr_MSG_EngineError, int(*)(char*, va_list), r5_patterns.StringSearch("Engine Error").FindPatternSelf("48 89 ? ? ? 48 89", MemoryAddress::Direction::UP, 500).GetPtr());
|
||||
|
@ -11,19 +11,18 @@ int Hooks::CEngineVGui_Paint(void* thisptr, int mode)
|
||||
{
|
||||
int result = originalCEngineVGui_Paint(thisptr, mode);
|
||||
|
||||
static void* g_pMatSystemSurface = MemoryAddress(0x14D40B3B0).RCast<void* (*)()>();
|
||||
static auto RenderStart = MemoryAddress(0x14053EFC0).RCast<void(*)(void*)>();
|
||||
static auto RenderEnd = MemoryAddress(0x14053F1B0).RCast<void*(*)()>();
|
||||
static void* pCMatSystemSurface = MemoryAddress(0x14D40B3B0).RCast<void*(*)()>();
|
||||
static auto fnRenderStart = MemoryAddress(0x14053EFC0).RCast<void(*)(void*)>();
|
||||
static auto fnRenderEnd = MemoryAddress(0x14053F1B0).RCast<void*(*)()>();
|
||||
|
||||
if (mode == 1 || mode == 2)
|
||||
if (mode == 1 || mode == 2) // Render in main menu and ingame.
|
||||
{
|
||||
RenderStart(g_pMatSystemSurface);
|
||||
fnRenderStart(pCMatSystemSurface);
|
||||
|
||||
g_LogSystem.Update();
|
||||
|
||||
RenderEnd();
|
||||
fnRenderEnd();
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
@ -413,7 +413,7 @@ namespace GameGlobals
|
||||
void* BanConCommand = CreateCustomConCommand("ban", "Bans a client from the Server via name. | Usage: ban (name)", 0, CustomCommandVariations::Ban_Callback, nullptr);
|
||||
void* BanIDConCommand = CreateCustomConCommand("banid", "Bans a client from the Server via originID, userID or IP | Usage: banid (originID/ipAddress/userID)", 0, CustomCommandVariations::BanID_Callback, nullptr);
|
||||
|
||||
ConVar* DrawConsoleOverlayConVar = CreateCustomConVar("cl_drawconsoleoverlay", "0", 0, "Draw the console overlay at the top of the screen", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
ConVar* DrawConsoleOverlayConVar = CreateCustomConVar("cl_drawconsoleoverlay", "0", 0, "Draw the console overlay at the top of the screen", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
ConVar* ConsoleOverlayLinesConVar = CreateCustomConVar("cl_consoleoverlay_lines", "3", 0, "Number of lines of console output to draw", false, 1.f, false, 50.f, nullptr, nullptr);
|
||||
}
|
||||
|
||||
|
@ -6,62 +6,59 @@ LogSystem g_LogSystem;
|
||||
|
||||
void LogSystem::Update()
|
||||
{
|
||||
if (GameGlobals::Cvar->FindVar("cl_drawconsoleoverlay")->m_iValue < 1)
|
||||
return;
|
||||
|
||||
if (m_vLogs.empty())
|
||||
return;
|
||||
|
||||
static void* g_pMatSystemSurface = MemoryAddress(0x14D40B360).RCast<void* (*)()>();
|
||||
static void* pCMatSystemSurface = MemoryAddress(0x14D40B360).RCast<void*(*)()>();
|
||||
if (!pCMatSystemSurface)
|
||||
return;
|
||||
|
||||
int fontHeight = 16;
|
||||
static int fontHeight = 16;
|
||||
|
||||
for (int i = 0; i < m_vLogs.size(); ++i) {
|
||||
for (int i = 0; i < m_vLogs.size(); ++i)
|
||||
{
|
||||
if (m_vLogs[i].Ticks >= 0)
|
||||
{
|
||||
if (GameGlobals::Cvar->FindVar("cl_drawconsoleoverlay")->m_iValue < 1)
|
||||
return;
|
||||
|
||||
if (i < GameGlobals::Cvar->FindVar("cl_consoleoverlay_lines")->m_iValue)
|
||||
{
|
||||
|
||||
if (i >= m_vLogs.size())
|
||||
{
|
||||
break;
|
||||
}
|
||||
float fadepct = fminf(float(m_vLogs[i].Ticks) / 64.f, 1.0);
|
||||
|
||||
float ptc = (int)ceilf( fadepct * 255.f);
|
||||
int alpha = (int)ptc;
|
||||
|
||||
float fadepct = fminf(static_cast<float>(m_vLogs[i].Ticks) / 64.f, 1.0);
|
||||
float ptc = static_cast<int>(ceilf( fadepct * 255.f));
|
||||
int alpha = static_cast<int>(ptc);
|
||||
int y = (10 + (fontHeight * i));
|
||||
|
||||
std::array<int, 3> color = GetLogColorForType(m_vLogs[i].Type);
|
||||
|
||||
MemoryAddress(0x140547900).RCast<void(*)(void*, QWORD, __int64, QWORD, int, int, DWORD, DWORD, DWORD, const char*, ...)>()(g_pMatSystemSurface, 0x13, fontHeight, 10, y, color[0], color[1], color[2], alpha, m_vLogs[i].Message.c_str());
|
||||
addr_CMatSystemSurface_DrawColoredText(pCMatSystemSurface, 0x13, fontHeight, 10, y, color[0], color[1], color[2], alpha, m_vLogs[i].Message.c_str());
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
m_vLogs.erase(m_vLogs.begin());
|
||||
continue;
|
||||
}
|
||||
|
||||
m_vLogs[i].Ticks--;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
m_vLogs.erase(m_vLogs.begin() + i);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LogSystem::AddLog(LogType_t type, std::string message)
|
||||
{
|
||||
Log log;
|
||||
log.Message = message;
|
||||
log.Type = type;
|
||||
log.Ticks = 1024;
|
||||
m_vLogs.push_back(log);
|
||||
if (message.length() > 0)
|
||||
{
|
||||
m_vLogs.push_back(Log{ message, 1024, type });
|
||||
}
|
||||
}
|
||||
|
||||
std::array<int, 3> LogSystem::GetLogColorForType(LogType_t type) {
|
||||
switch(type) {
|
||||
std::array<int, 3> LogSystem::GetLogColorForType(LogType_t type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case LogType_t::NATIVE:
|
||||
return { 255, 255, 255 };
|
||||
case LogType_t::SCRIPT_SERVER:
|
||||
@ -73,4 +70,6 @@ std::array<int, 3> LogSystem::GetLogColorForType(LogType_t type) {
|
||||
default:
|
||||
return { 255, 255, 255 };
|
||||
}
|
||||
|
||||
return { 255, 255, 255 };
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user