Color logging improvements

Check local variable for overriding colors instead of relying on the global one set from 'sqstd_aux_printerror()'. This should make it render properly in the in-game console.
This commit is contained in:
Kawe Mazidjatari 2022-05-20 02:14:54 +02:00
parent cb5f7cd1b0
commit 9f8ff78a8d

View File

@ -82,6 +82,7 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
if (sq_showvmoutput->GetInt() > 1) if (sq_showvmoutput->GetInt() > 1)
{ {
bool bError = false; bool bError = false;
bool bColorOverride = false;
if (!g_bSpdLog_UseAnsiClr) if (!g_bSpdLog_UseAnsiClr)
{ {
wconsole->debug(vmStr); wconsole->debug(vmStr);
@ -94,13 +95,13 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
std::string vmStrAnsi; std::string vmStrAnsi;
if (g_bSQAuxError) if (g_bSQAuxError)
{ {
bColorOverride = true;
if (strstr(buf, "SCRIPT ERROR:") || strstr(buf, " -> ")) if (strstr(buf, "SCRIPT ERROR:") || strstr(buf, " -> "))
{ {
bError = true; bError = true;
vmStrAnsi = SQVM_ERROR_ANSI_LOG_T[static_cast<SQInteger>(context)].c_str(); vmStrAnsi = SQVM_ERROR_ANSI_LOG_T[static_cast<SQInteger>(context)].c_str();
} }
else else {
{
vmStrAnsi = SQVM_WARNING_ANSI_LOG_T[static_cast<SQInteger>(context)].c_str(); vmStrAnsi = SQVM_WARNING_ANSI_LOG_T[static_cast<SQInteger>(context)].c_str();
} }
} }
@ -109,16 +110,15 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
if (strstr(buf, "There was a problem processing game logic.")) if (strstr(buf, "There was a problem processing game logic."))
{ {
bError = true; bError = true;
bColorOverride = true;
g_bSQAuxBadLogic = false; g_bSQAuxBadLogic = false;
vmStrAnsi = SQVM_ERROR_ANSI_LOG_T[static_cast<SQInteger>(context)].c_str(); vmStrAnsi = SQVM_ERROR_ANSI_LOG_T[static_cast<SQInteger>(context)].c_str();
} }
else else {
{
vmStrAnsi = SQVM_ANSI_LOG_T[static_cast<SQInteger>(context)].c_str(); vmStrAnsi = SQVM_ANSI_LOG_T[static_cast<SQInteger>(context)].c_str();
} }
} }
else else {
{
vmStrAnsi = SQVM_ANSI_LOG_T[static_cast<SQInteger>(context)].c_str(); vmStrAnsi = SQVM_ANSI_LOG_T[static_cast<SQInteger>(context)].c_str();
} }
vmStrAnsi.append(buf); vmStrAnsi.append(buf);
@ -135,7 +135,7 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
if (sq_showvmoutput->GetInt() > 2) if (sq_showvmoutput->GetInt() > 2)
{ {
ImVec4 color; ImVec4 color;
if (g_bSQAuxError) if (bColorOverride)
{ {
if (bError) { if (bError) {
color = ImVec4(1.00f, 0.00f, 0.00f, 0.80f); color = ImVec4(1.00f, 0.00f, 0.00f, 0.80f);