mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-03-13 22:42:07 +00:00
- add new ccmd cvarsearch
allows searching cvar by name, languageid, or description
This commit is contained in:
parent
6ff667a490
commit
93772c4e0c
2 changed files with 59 additions and 7 deletions
|
@ -44,6 +44,7 @@
|
|||
#include "printf.h"
|
||||
#include "palutil.h"
|
||||
#include "i_interface.h"
|
||||
#include "gstrings.h"
|
||||
|
||||
#include "dobject.h"
|
||||
#include "dobjtype.h"
|
||||
|
@ -1695,16 +1696,37 @@ CCMD (toggle)
|
|||
}
|
||||
}
|
||||
|
||||
void FBaseCVar::ListVars (const char *filter, bool plain)
|
||||
void FBaseCVar::ListVars (const char *filter, int listtype)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
bool plain = listtype == LCT_Plain;
|
||||
bool includedesc = listtype == LCT_FullSearch;
|
||||
|
||||
decltype(cvarMap)::Iterator it(cvarMap);
|
||||
decltype(cvarMap)::Pair *pair;
|
||||
while (it.NextPair(pair))
|
||||
{
|
||||
auto var = pair->Value;
|
||||
if (CheckWildcards (filter, var->GetName()))
|
||||
|
||||
bool ismatch;
|
||||
|
||||
if (includedesc)
|
||||
{
|
||||
// search always allow partial matches
|
||||
// also allow matching to cvar name, localised description, and description language-id
|
||||
|
||||
FString SearchString = FString("*") + filter + "*";
|
||||
ismatch = CheckWildcards (SearchString.GetChars(), var->GetName()) ||
|
||||
CheckWildcards (SearchString.GetChars(), var->GetDescription().GetChars()) ||
|
||||
CheckWildcards (SearchString.GetChars(), GStrings.localize(var->GetDescription().GetChars()));
|
||||
}
|
||||
else
|
||||
{
|
||||
ismatch = CheckWildcards (filter, var->GetName());
|
||||
}
|
||||
|
||||
if (ismatch)
|
||||
{
|
||||
uint32_t flags = var->GetFlags();
|
||||
if (plain)
|
||||
|
@ -1718,7 +1740,8 @@ void FBaseCVar::ListVars (const char *filter, bool plain)
|
|||
else
|
||||
{
|
||||
++count;
|
||||
Printf ("%c%c%c%c%c %s = %s\n",
|
||||
|
||||
Printf ("%c%c%c%c%c %s = %s",
|
||||
flags & CVAR_ARCHIVE ? 'A' : ' ',
|
||||
flags & CVAR_USERINFO ? 'U' :
|
||||
flags & CVAR_SERVERINFO ? 'S' :
|
||||
|
@ -1730,6 +1753,16 @@ void FBaseCVar::ListVars (const char *filter, bool plain)
|
|||
flags & CVAR_IGNORE ? 'X' : ' ',
|
||||
var->GetName(),
|
||||
var->GetHumanString());
|
||||
|
||||
if (includedesc)
|
||||
if (var->GetDescription().Len())
|
||||
Printf(" // \"%s\"\n", GStrings.localize(var->GetDescription().GetChars()));
|
||||
else
|
||||
Printf("\n");
|
||||
else
|
||||
Printf("\n");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1740,17 +1773,29 @@ CCMD (cvarlist)
|
|||
{
|
||||
if (argv.argc() == 1)
|
||||
{
|
||||
FBaseCVar::ListVars (NULL, false);
|
||||
FBaseCVar::ListVars (NULL, LCT_Default);
|
||||
}
|
||||
else
|
||||
{
|
||||
FBaseCVar::ListVars (argv[1], false);
|
||||
FBaseCVar::ListVars (argv[1], LCT_Default);
|
||||
}
|
||||
}
|
||||
|
||||
CCMD (cvarlistplain)
|
||||
{
|
||||
FBaseCVar::ListVars (NULL, true);
|
||||
FBaseCVar::ListVars (NULL, LCT_Plain);
|
||||
}
|
||||
|
||||
CCMD (cvarsearch)
|
||||
{
|
||||
if (argv.argc() == 1)
|
||||
{
|
||||
FBaseCVar::ListVars (NULL, LCT_FullSearch);
|
||||
}
|
||||
else
|
||||
{
|
||||
FBaseCVar::ListVars (argv[1], LCT_FullSearch);
|
||||
}
|
||||
}
|
||||
|
||||
CCMD (archivecvar)
|
||||
|
|
|
@ -89,6 +89,13 @@ enum ECVarType
|
|||
CVAR_Dummy, // Unknown
|
||||
};
|
||||
|
||||
enum ListCCMDType
|
||||
{
|
||||
LCT_Default,
|
||||
LCT_Plain,
|
||||
LCT_FullSearch,
|
||||
};
|
||||
|
||||
|
||||
class FIntCVarRef;
|
||||
union UCVarValue
|
||||
|
@ -201,7 +208,7 @@ public:
|
|||
static void MarkZSCallbacks ();
|
||||
static void ResetColors (); // recalc color cvars' indices after screen change
|
||||
|
||||
static void ListVars (const char *filter, bool plain);
|
||||
static void ListVars (const char *filter, int listtype);
|
||||
|
||||
const FString &GetDescription() const { return Description; };
|
||||
const FString& GetToggleMessage(int which) { return ToggleMessages[which]; }
|
||||
|
|
Loading…
Reference in a new issue