mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Add case insensitive search for developer console input field
This has been requested by a user. This change will allow for searching convars from partial input regardless of the case.
This commit is contained in:
parent
cf1adef1a2
commit
11fa1c5119
@ -495,7 +495,7 @@ void CConsole::FindFromPartial(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (suggest.m_svName.find(m_szInputBuf) == string::npos)
|
||||
if (!HasPartial(suggest.m_svName, m_szInputBuf))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -245,6 +245,19 @@ char* StripQuotes(const char* pInBuffer, char* pOutBuffer, int nOutBufferSize)
|
||||
return out;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// For finding a partial string within input (case insensitive).
|
||||
bool HasPartial(const string& svInput, const string& svPartial)
|
||||
{
|
||||
auto it = std::search( svInput.begin(), svInput.end(),
|
||||
svPartial.begin(), svPartial.end(), [](char ci, char cp)
|
||||
{
|
||||
return std::toupper(ci) == std::toupper(cp);
|
||||
}
|
||||
);
|
||||
return (it != svInput.end());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// For checking if file name has a specific extension.
|
||||
bool HasExtension(const string& svInput, const string& svExtension)
|
||||
|
@ -20,6 +20,7 @@ char* StripQuotes(const char* pInBuffer, char* pOutBuffer, int nOutBufferSize);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// String
|
||||
bool HasPartial(const string& svInput, const string& svPartial);
|
||||
bool HasExtension(const string& svInput, const string& svExtension);
|
||||
string GetExtension(const string& svInput, bool bReturnOriginal = false, bool bKeepDelimiter = false);
|
||||
string RemoveExtension(const string& svInput);
|
||||
|
Loading…
x
Reference in New Issue
Block a user