Skip to content

Commit

Permalink
Refactor: Removed Con_PrintPathList()
Browse files Browse the repository at this point in the history
This routine is now obsolete as there more flexible ways of preparing
and printing a concatenated list of paths.
  • Loading branch information
danij-deng committed Jan 4, 2014
1 parent 20509d3 commit a278c95
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 77 deletions.
25 changes: 0 additions & 25 deletions doomsday/client/include/con_main.h
Expand Up @@ -326,31 +326,6 @@ void Con_Printf(char const *format, ...) PRINTF_F(1,2);
/// Print a ruler into the console.
void Con_PrintRuler();

/**
* @defgroup printPathFlags Print Path Flags
* @ingroup flags
*/
/*{@*/
#define PPF_MULTILINE 0x1 // Use multiple lines.
#define PPF_TRANSFORM_PATH_MAKEPRETTY 0x2 // Make paths 'prettier'.
#define PPF_TRANSFORM_PATH_PRINTINDEX 0x4 // Print an index for each path.
/*}@*/

#define DEFAULT_PRINTPATHFLAGS (PPF_MULTILINE|PPF_TRANSFORM_PATH_MAKEPRETTY|PPF_TRANSFORM_PATH_PRINTINDEX)

/**
* Prints the passed path list to the console.
*
* @todo treat paths as URIs (i.e., resolve symbols).
*
* @param pathList A series of file/resource names/paths separated by @a delimiter.
* @param delimiter Path delimiter character.
* @param separator Text printed between list entries.
* @param flags @ref printPathFlags.
*/
void Con_PrintPathList(char const *pathList, char delimiter = ';',
char const *separator = " ", int flags = DEFAULT_PRINTPATHFLAGS);

void Con_PrintCVar(cvar_t *cvar, char const *prefix);

de::String Con_VarAsStyledText(cvar_t *var, char const *prefix);
Expand Down
51 changes: 5 additions & 46 deletions doomsday/client/src/con_main.cpp
Expand Up @@ -2017,70 +2017,29 @@ static void conPrintf(int flags, const char* format, va_list args)

void Con_Printf(const char* format, ...)
{
va_list args;
if(!ConsoleInited || ConsoleSilent)
return;
if(!format || !format[0])
return;

va_list args;
va_start(args, format);
conPrintf(CPF_WHITE, format, args);
va_end(args);
}

void Con_FPrintf(int flags, const char* format, ...)
void Con_FPrintf(int flags, char const *format, ...)
{
if(!ConsoleInited || ConsoleSilent)
return;

if(!format || !format[0])
return;

{va_list args;
va_list args;
va_start(args, format);
conPrintf(flags, format, args);
va_end(args);}
}

static void printListPath(const ddstring_t* path, int flags, int index)
{
assert(path);
if(flags & PPF_TRANSFORM_PATH_PRINTINDEX)
Con_Printf("%i: ", index);
Con_Printf("%s", (flags & PPF_TRANSFORM_PATH_MAKEPRETTY)? F_PrettyPath(Str_Text(path)) : Str_Text(path));
}

void Con_PrintPathList(char const *pathList, char delimiter, char const *separator, int flags)
{
DENG_ASSERT(pathList != 0&& pathList[0]);

ddstring_t path;
Str_Init(&path);

char const *p = pathList;
int n = 0;
while((p = Str_CopyDelim2(&path, p, delimiter, CDF_OMIT_DELIMITER)))
{
printListPath(&path, flags, n++);
if(separator && !(flags & PPF_MULTILINE) && p && p[0])
{
Con_Printf("%s", separator);
}
if(flags & PPF_MULTILINE)
{
Con_Printf("\n");
}
}

if(Str_Length(&path) != 0)
{
printListPath(&path, flags, n++);
if(flags & PPF_MULTILINE)
{
Con_Printf("\n");
}
}

Str_Free(&path);
va_end(args);
}

#undef Con_Message
Expand Down
18 changes: 12 additions & 6 deletions doomsday/client/src/filesys/manifest.cpp
Expand Up @@ -351,20 +351,26 @@ QStringList const &ResourceManifest::names() const

void ResourceManifest::consolePrint(ResourceManifest &manifest, bool showStatus)
{
QByteArray names = manifest.names().join(";").toUtf8();
bool const resourceFound = (manifest.fileFlags() & FF_FOUND) != 0;

String text;

if(showStatus)
{
Con_Printf("%s", !resourceFound? " ! ":" ");
text += (resourceFound? " " : ":");
}

Con_PrintPathList(names.constData(), ';', " or ", PPF_TRANSFORM_PATH_MAKEPRETTY);
// Format the resource name list.
text += manifest.names().join(" or ");

if(showStatus)
{
QByteArray foundPath = resourceFound? manifest.resolvedPath(false/*don't try to locate*/).toUtf8() : QByteArray("");
Con_Printf(" %s%s", !resourceFound? "- missing" : "- found ", F_PrettyPath(foundPath.constData()));
text += String(" - ") + (resourceFound? "found" : "missing");
if(resourceFound)
{
text += String(" ") + NativePath(manifest.resolvedPath(false/*don't try to locate*/)).expand().pretty();
}
}
Con_Printf("\n");

LOG_MSG("") << text;
}

0 comments on commit a278c95

Please sign in to comment.