mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Display '%' symbol properly in console
This commit is contained in:
parent
9ceffb2491
commit
452c8afcf3
@ -188,7 +188,7 @@ void DevMsg(eDLL_T idx, const char* fmt, ...)
|
||||
break;
|
||||
}
|
||||
|
||||
g_pIConsole->m_ivConLog.push_back(CConLog(g_spd_sys_w_oss.str().c_str(), color));
|
||||
g_pIConsole->m_ivConLog.push_back(CConLog(PrintPercentageEscape(g_spd_sys_w_oss.str()), color));
|
||||
g_pLogSystem.AddLog(tLog, g_spd_sys_w_oss.str());
|
||||
|
||||
g_spd_sys_w_oss.str("");
|
||||
@ -265,8 +265,8 @@ void Warning(eDLL_T idx, const char* fmt, ...)
|
||||
#ifndef DEDICATED
|
||||
iconsole->info(svOut);
|
||||
|
||||
g_pIConsole->m_ivConLog.push_back(CConLog(PrintPercentageEscape(g_spd_sys_w_oss.str()), ImVec4(1.00f, 1.00f, 0.00f, 0.80f)));
|
||||
g_pLogSystem.AddLog(LogType_t::WARNING_C, g_spd_sys_w_oss.str());
|
||||
g_pIConsole->m_ivConLog.push_back(CConLog(g_spd_sys_w_oss.str(), ImVec4(1.00f, 1.00f, 0.00f, 0.80f)));
|
||||
|
||||
g_spd_sys_w_oss.str("");
|
||||
g_spd_sys_w_oss.clear();
|
||||
@ -342,8 +342,8 @@ void Error(eDLL_T idx, const char* fmt, ...)
|
||||
#ifndef DEDICATED
|
||||
iconsole->info(svOut);
|
||||
|
||||
g_pIConsole->m_ivConLog.push_back(CConLog(PrintPercentageEscape(g_spd_sys_w_oss.str()), ImVec4(1.00f, 0.00f, 0.00f, 1.00f)));
|
||||
g_pLogSystem.AddLog(LogType_t::ERROR_C, g_spd_sys_w_oss.str());
|
||||
g_pIConsole->m_ivConLog.push_back(CConLog(g_spd_sys_w_oss.str(), ImVec4(1.00f, 0.00f, 0.00f, 1.00f)));
|
||||
|
||||
g_spd_sys_w_oss.str("");
|
||||
g_spd_sys_w_oss.clear();
|
||||
|
@ -520,7 +520,7 @@ void CConsole::FindFromPartial(void)
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConsole::ProcessCommand(const char* pszCommand)
|
||||
{
|
||||
AddLog(ImVec4(1.00f, 0.80f, 0.60f, 1.00f), "# %s\n", pszCommand);
|
||||
AddLog(ImVec4(1.00f, 0.80f, 0.60f, 1.00f), "# %s\n", PrintPercentageEscape(pszCommand).c_str());
|
||||
|
||||
std::thread t(CEngineClient_CommandExecute, this, pszCommand);
|
||||
t.detach(); // Detach from render thread.
|
||||
|
@ -27,8 +27,11 @@ bool CompareStringLexicographically(const string& svA, const string& svB);
|
||||
bool StringReplace(string& svInput, const string& svFrom, const string& svTo);
|
||||
string StringEscape(const string& svInput);
|
||||
string StringUnescape(const string& svInput);
|
||||
|
||||
vector<int> StringToBytes(const string& svInput, bool bNullTerminator);
|
||||
vector<int> PatternToBytes(const string& svInput);
|
||||
vector<int> IntToDigits(int value);
|
||||
|
||||
string PrintPercentageEscape(const string& svInput);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -144,7 +144,7 @@ void PrintLastError(void)
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// For dumping data from a buffer to a file on the disk
|
||||
// For dumping data from a buffer to a file on the disk.
|
||||
void HexDump(const char* szHeader, const char* szLogger, const void* pData, int nSize)
|
||||
{
|
||||
static unsigned char szAscii[17] = {};
|
||||
@ -345,7 +345,7 @@ string Base64Decode(const string& svInput)
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// For comparing input strings alphabetically
|
||||
// For comparing input strings alphabetically.
|
||||
bool CompareStringAlphabetically(const string& svA, const string& svB)
|
||||
{
|
||||
int i = 0;
|
||||
@ -358,7 +358,7 @@ bool CompareStringAlphabetically(const string& svA, const string& svB)
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// For comparing input strings lexicographically
|
||||
// For comparing input strings lexicographically.
|
||||
bool CompareStringLexicographically(const string& svA, const string& svB)
|
||||
{
|
||||
return svA < svB;
|
||||
@ -384,6 +384,7 @@ string StringEscape(const string& svInput)
|
||||
{
|
||||
string results;
|
||||
results.reserve(svInput.size());
|
||||
|
||||
for (const char c : svInput)
|
||||
{
|
||||
switch (c)
|
||||
@ -408,6 +409,7 @@ string StringUnescape(const string& svInput)
|
||||
{
|
||||
string results;
|
||||
results.reserve(svInput.size());
|
||||
|
||||
for (const char c : svInput)
|
||||
{
|
||||
switch (c)
|
||||
@ -475,7 +477,7 @@ vector<int> PatternToBytes(const string& svInput)
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// For converting a integer into digits
|
||||
// For converting a integer into digits.
|
||||
vector<int> IntToDigits(int value)
|
||||
{
|
||||
vector<int> vDigits;
|
||||
@ -486,3 +488,21 @@ vector<int> IntToDigits(int value)
|
||||
std::reverse(vDigits.begin(), vDigits.end());
|
||||
return vDigits;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// For escaping the '%' character for *rintf.
|
||||
string PrintPercentageEscape(const string& svInput)
|
||||
{
|
||||
string results;
|
||||
results.reserve(svInput.size());
|
||||
|
||||
for (const char c : svInput)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case '%': results += "%%"; break;
|
||||
default: results += c; break;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
@ -147,7 +147,7 @@ SQRESULT HSQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
|
||||
}
|
||||
}
|
||||
|
||||
g_pIConsole->m_ivConLog.push_back(CConLog(g_spd_sys_w_oss.str(), color));
|
||||
g_pIConsole->m_ivConLog.push_back(CConLog(PrintPercentageEscape(g_spd_sys_w_oss.str()), color));
|
||||
g_pLogSystem.AddLog(static_cast<LogType_t>(context), g_spd_sys_w_oss.str());
|
||||
|
||||
g_spd_sys_w_oss.str("");
|
||||
@ -216,7 +216,7 @@ SQRESULT HSQVM_WarningFunc(HSQUIRRELVM v, SQInteger a2, SQInteger a3, SQInteger*
|
||||
#ifndef DEDICATED
|
||||
iconsole->debug(vmStr); // Emit to in-game console.
|
||||
|
||||
g_pIConsole->m_ivConLog.push_back(CConLog(g_spd_sys_w_oss.str(), ImVec4(1.00f, 1.00f, 0.00f, 0.80f)));
|
||||
g_pIConsole->m_ivConLog.push_back(CConLog(PrintPercentageEscape(g_spd_sys_w_oss.str()), ImVec4(1.00f, 1.00f, 0.00f, 0.80f)));
|
||||
g_pLogSystem.AddLog(LogType_t::WARNING_C, g_spd_sys_w_oss.str());
|
||||
|
||||
g_spd_sys_w_oss.str("");
|
||||
|
Loading…
x
Reference in New Issue
Block a user