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
|
#pragma once
|
||||||
|
|
||||||
#define LOGSYSTEM_LINES_TO_SHOW 3
|
enum class LogType_t : int
|
||||||
|
|
||||||
enum LogType_t
|
|
||||||
{
|
{
|
||||||
SCRIPT_SERVER,
|
SCRIPT_SERVER,
|
||||||
SCRIPT_CLIENT,
|
SCRIPT_CLIENT,
|
||||||
@ -13,6 +11,12 @@ enum LogType_t
|
|||||||
|
|
||||||
struct Log
|
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 = "";
|
std::string Message = "";
|
||||||
int Ticks = 1024;
|
int Ticks = 1024;
|
||||||
LogType_t Type = LogType_t::NATIVE;
|
LogType_t Type = LogType_t::NATIVE;
|
||||||
@ -20,7 +24,6 @@ struct Log
|
|||||||
|
|
||||||
class LogSystem
|
class LogSystem
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void AddLog(LogType_t type, std::string text);
|
void AddLog(LogType_t type, std::string text);
|
||||||
void Update();
|
void Update();
|
||||||
|
@ -127,6 +127,9 @@ namespace
|
|||||||
|
|
||||||
/*0x1405489C0*/
|
/*0x1405489C0*/
|
||||||
FUNC_AT_ADDRESS(addr_CMatSystemSurface_UnlockCursor, void(*)(void*), MemoryAddress(0x1405489C0).GetPtr()); // Maybe sigscan this via RTTI.
|
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
|
#pragma region Utility
|
||||||
/*0x140295600*/
|
/*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());
|
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);
|
int result = originalCEngineVGui_Paint(thisptr, mode);
|
||||||
|
|
||||||
static void* g_pMatSystemSurface = MemoryAddress(0x14D40B3B0).RCast<void* (*)()>();
|
static void* pCMatSystemSurface = MemoryAddress(0x14D40B3B0).RCast<void*(*)()>();
|
||||||
static auto RenderStart = MemoryAddress(0x14053EFC0).RCast<void(*)(void*)>();
|
static auto fnRenderStart = MemoryAddress(0x14053EFC0).RCast<void(*)(void*)>();
|
||||||
static auto RenderEnd = MemoryAddress(0x14053F1B0).RCast<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();
|
g_LogSystem.Update();
|
||||||
|
|
||||||
RenderEnd();
|
fnRenderEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
@ -6,62 +6,59 @@ LogSystem g_LogSystem;
|
|||||||
|
|
||||||
void LogSystem::Update()
|
void LogSystem::Update()
|
||||||
{
|
{
|
||||||
if (m_vLogs.empty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
static void* g_pMatSystemSurface = MemoryAddress(0x14D40B360).RCast<void* (*)()>();
|
|
||||||
|
|
||||||
int fontHeight = 16;
|
|
||||||
|
|
||||||
for (int i = 0; i < m_vLogs.size(); ++i) {
|
|
||||||
if (m_vLogs[i].Ticks >= 0)
|
|
||||||
{
|
|
||||||
if (GameGlobals::Cvar->FindVar("cl_drawconsoleoverlay")->m_iValue < 1)
|
if (GameGlobals::Cvar->FindVar("cl_drawconsoleoverlay")->m_iValue < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (m_vLogs.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
static void* pCMatSystemSurface = MemoryAddress(0x14D40B360).RCast<void*(*)()>();
|
||||||
|
if (!pCMatSystemSurface)
|
||||||
|
return;
|
||||||
|
|
||||||
|
static int fontHeight = 16;
|
||||||
|
|
||||||
|
for (int i = 0; i < m_vLogs.size(); ++i)
|
||||||
|
{
|
||||||
|
if (m_vLogs[i].Ticks >= 0)
|
||||||
|
{
|
||||||
if (i < GameGlobals::Cvar->FindVar("cl_consoleoverlay_lines")->m_iValue)
|
if (i < GameGlobals::Cvar->FindVar("cl_consoleoverlay_lines")->m_iValue)
|
||||||
{
|
{
|
||||||
|
float fadepct = fminf(static_cast<float>(m_vLogs[i].Ticks) / 64.f, 1.0);
|
||||||
if (i >= m_vLogs.size())
|
float ptc = static_cast<int>(ceilf( fadepct * 255.f));
|
||||||
{
|
int alpha = static_cast<int>(ptc);
|
||||||
break;
|
|
||||||
}
|
|
||||||
float fadepct = fminf(float(m_vLogs[i].Ticks) / 64.f, 1.0);
|
|
||||||
|
|
||||||
float ptc = (int)ceilf( fadepct * 255.f);
|
|
||||||
int alpha = (int)ptc;
|
|
||||||
|
|
||||||
int y = (10 + (fontHeight * i));
|
int y = (10 + (fontHeight * i));
|
||||||
|
|
||||||
std::array<int, 3> color = GetLogColorForType(m_vLogs[i].Type);
|
std::array<int, 3> color = GetLogColorForType(m_vLogs[i].Type);
|
||||||
|
addr_CMatSystemSurface_DrawColoredText(pCMatSystemSurface, 0x13, fontHeight, 10, y, color[0], color[1], color[2], alpha, m_vLogs[i].Message.c_str());
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
m_vLogs.erase(m_vLogs.begin());
|
m_vLogs.erase(m_vLogs.begin());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_vLogs[i].Ticks--;
|
m_vLogs[i].Ticks--;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
m_vLogs.erase(m_vLogs.begin() + i);
|
m_vLogs.erase(m_vLogs.begin() + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogSystem::AddLog(LogType_t type, std::string message)
|
void LogSystem::AddLog(LogType_t type, std::string message)
|
||||||
{
|
{
|
||||||
Log log;
|
if (message.length() > 0)
|
||||||
log.Message = message;
|
{
|
||||||
log.Type = type;
|
m_vLogs.push_back(Log{ message, 1024, type });
|
||||||
log.Ticks = 1024;
|
}
|
||||||
m_vLogs.push_back(log);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<int, 3> LogSystem::GetLogColorForType(LogType_t type) {
|
std::array<int, 3> LogSystem::GetLogColorForType(LogType_t type)
|
||||||
switch(type) {
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
case LogType_t::NATIVE:
|
case LogType_t::NATIVE:
|
||||||
return { 255, 255, 255 };
|
return { 255, 255, 255 };
|
||||||
case LogType_t::SCRIPT_SERVER:
|
case LogType_t::SCRIPT_SERVER:
|
||||||
@ -73,4 +70,6 @@ std::array<int, 3> LogSystem::GetLogColorForType(LogType_t type) {
|
|||||||
default:
|
default:
|
||||||
return { 255, 255, 255 };
|
return { 255, 255, 255 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return { 255, 255, 255 };
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user