Optimize console autocomplete and show usage text

This commit is contained in:
Amos 2022-02-22 16:31:24 +01:00
parent 26c0fa89ab
commit c6cf40f539
3 changed files with 20 additions and 5 deletions

View File

@ -417,16 +417,21 @@ void CConsole::FindFromPartial(void)
if (pConVar != nullptr)
{
svValue = "= \""; // Assign default value to string if its a ConVar.
svValue.append(g_pCVar->FindVar(g_vsvAllConVars[i].c_str())->GetString());
svValue.append(pConVar->GetString());
svValue.append("\"");
if (con_suggestion_helptext->GetBool())
{
std::string svHelpText = g_pCVar->FindVar(g_vsvAllConVars[i].c_str())->GetHelpText();
std::string svHelpText = pConVar->GetHelpText();
if (!svHelpText.empty())
{
svValue.append(" [" + svHelpText + "]");
svValue.append(" | [" + svHelpText + "]");
}
std::string svUsageText = pConVar->GetUsageText();
if (!svUsageText.empty())
{
svValue.append(" | [" + svUsageText + "]");
}
}
}

View File

@ -101,7 +101,7 @@ void ConVar::Init(void) const
con_max_size_logvector = new ConVar("con_max_size_logvector", "1000", FCVAR_DEVELOPMENTONLY, "Maximum number of logs in the console until cleanup starts.", false, 0.f, false, 0.f, nullptr, nullptr);
con_suggestion_limit = new ConVar("con_suggestion_limit" , "120" , FCVAR_DEVELOPMENTONLY, "Maximum number of suggestions the autocomplete window will show for the console.", false, 0.f, false, 0.f, nullptr, nullptr);
con_suggestion_helptext = new ConVar("con_suggestion_helptext", "0" , FCVAR_DEVELOPMENTONLY, "Show ConVar help text in autocomplete window. Disabled by default to keep window less populated.", false, 0.f, false, 0.f, nullptr, nullptr);
con_suggestion_helptext = new ConVar("con_suggestion_helptext", "1" , FCVAR_DEVELOPMENTONLY, "Show ConVar help text in autocomplete window.", false, 0.f, false, 0.f, nullptr, nullptr);
#endif // !DEDICATED
//-------------------------------------------------------------------------
// FILESYSTEM |
@ -144,6 +144,15 @@ const char* ConVar::GetHelpText(void) const
return m_pParent->m_ConCommandBase.m_pszHelpString;
}
//-----------------------------------------------------------------------------
// Purpose: Returns the ConVar usage text.
// Output : const char*
//-----------------------------------------------------------------------------
const char* ConVar::GetUsageText(void) const
{
return m_pParent->m_ConCommandBase.m_pszUsageString;
}
//-----------------------------------------------------------------------------
// Purpose: Add's flags to ConVar.
// Input : nFlags -

View File

@ -94,6 +94,7 @@ public:
const char* GetBaseName(void) const;
const char* GetHelpText(void) const;
const char* GetUsageText(void) const;
void AddFlags(int nFlags);
void RemoveFlags(int nFlags);