Skip to content

Commit

Permalink
Console|Resources|Client: Applied rich formatting to "listtextures" o…
Browse files Browse the repository at this point in the history
…utput; cleanup
  • Loading branch information
danij-deng committed Nov 17, 2013
1 parent 310a45d commit 67b00b7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 43 deletions.
3 changes: 2 additions & 1 deletion doomsday/client/src/resource/fonts.cpp
@@ -1,4 +1,4 @@
/** @file fonts.cpp Font resource collection.
/** @file fonts.cpp Font resource collection.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2005-2013 Daniel Swanson <danij@dengine.net>
Expand All @@ -23,6 +23,7 @@

#include "de_console.h"
#include "dd_main.h" // App_Fonts(), verbose
#include <de/Log>
#include <de/memory.h>
#include <QList>
#include <QtAlgorithms>
Expand Down
71 changes: 29 additions & 42 deletions doomsday/client/src/resource/textures.cpp
@@ -1,4 +1,4 @@
/** @file textures.cpp Texture Resource Collection.
/** @file textures.cpp Texture Resource Collection.
*
* @authors Copyright © 2010-2013 Daniel Swanson <danij@dengine.net>
*
Expand All @@ -17,19 +17,17 @@
* 02110-1301 USA</small>
*/

#include "de_base.h"
#include "de_console.h"
#include "de_platform.h"
#include "resource/textures.h"

#include "de_console.h"
#include "dd_main.h" // App_Textures(), verbose
#include <de/Log>
#include <de/math.h>
#include <de/mathutil.h> // for M_NumDigits
#include <QList>
#include <QtAlgorithms>

#include "resource/textures.h"

D_CMD(ListTextures);
D_CMD(InspectTexture);

#ifdef DENG_DEBUG
D_CMD(PrintTextureStats);
#endif
Expand All @@ -39,11 +37,11 @@ namespace de {
DENG2_PIMPL(Textures)
{
/// System subspace schemes containing the textures.
Textures::Schemes schemes;
Schemes schemes;
QList<TextureScheme *> schemeCreationOrder;

/// All texture instances in the system (from all schemes).
Textures::All textures;
All textures;

Instance(Public *i) : Base(i)
{}
Expand Down Expand Up @@ -87,12 +85,12 @@ Textures::Scheme &Textures::scheme(String name) const
if(found != d->schemes.end()) return **found;
}
/// @throw UnknownSchemeError An unknown scheme was referenced.
throw Textures::UnknownSchemeError("Textures::scheme", "No scheme found matching '" + name + "'");
throw UnknownSchemeError("Textures::scheme", "No scheme found matching '" + name + "'");
}

TextureScheme &Textures::createScheme(String name)
{
DENG_ASSERT(name.length() >= Scheme::min_name_length);
DENG2_ASSERT(name.length() >= Scheme::min_name_length);

// Ensure this is a unique name.
if(knownScheme(name)) return scheme(name);
Expand All @@ -112,8 +110,7 @@ bool Textures::knownScheme(String name) const
{
if(!name.isEmpty())
{
Schemes::iterator found = d->schemes.find(name.toLower());
if(found != d->schemes.end()) return true;
return d->schemes.contains(name.toLower());
}
return false;
}
Expand Down Expand Up @@ -314,31 +311,21 @@ static int printIndex2(TextureScheme *scheme, Path const &like,
if(!printSchemeName && scheme)
heading += " in scheme '" + scheme->name() + "'";
if(!like.isEmpty())
heading += " like \"" + like.toStringRef() + "\"";
heading += ":";
Con_FPrintf(CPF_YELLOW, "%s\n", heading.toUtf8().constData());
heading += " like \"" _E(b) + like.toStringRef() + _E(.) "\"";
LOG_MSG(_E(D) "%s:" _E(.)) << heading;

// Print the result index key.
int numFoundDigits = de::max(3/*idx*/, M_NumDigits(found.count()));

#ifdef __CLIENT__
Con_Printf(" %*s: %-*s origin n# uri\n", numFoundDigits, "idx",
printSchemeName? 22 : 14, printSchemeName? "scheme:path" : "path");
#else
Con_Printf(" %*s: %-*s origin uri\n", numFoundDigits, "idx",
printSchemeName? 22 : 14, printSchemeName? "scheme:path" : "path");
#endif
Con_PrintRuler();

// Sort and print the index.
qSort(found.begin(), found.end(), compareManifestPathsAssending);
int numFoundDigits = de::max(3/*idx*/, M_NumDigits(found.count()));
int idx = 0;
foreach(TextureManifest *manifest, found)
{
String info = String(" %1: ").arg(idx, numFoundDigits)
+ manifest->description(composeUriFlags);
String info = String("%1: %2%3")
.arg(idx, numFoundDigits)
.arg(manifest->hasTexture()? _E(1) : _E(2))
.arg(manifest->description(composeUriFlags));

Con_FPrintf(!manifest->hasTexture()? CPF_LIGHT : CPF_WHITE, "%s\n", info.toUtf8().constData());
LOG_MSG(" " _E(>)) << info;
idx++;
}

Expand All @@ -356,13 +343,13 @@ static void printIndex(de::Uri const &search,
if(search.scheme().isEmpty() && !search.path().isEmpty())
{
printTotal = printIndex2(0/*any scheme*/, search.path(), flags & ~de::Uri::OmitScheme);
Con_PrintRuler();
LOG_MSG(_E(R));
}
// Print results within only the one scheme?
else if(textures.knownScheme(search.scheme()))
{
printTotal = printIndex2(&textures.scheme(search.scheme()), search.path(), flags | de::Uri::OmitScheme);
Con_PrintRuler();
LOG_MSG(_E(R));
}
else
{
Expand All @@ -372,12 +359,12 @@ static void printIndex(de::Uri const &search,
int numPrinted = printIndex2(scheme, search.path(), flags | de::Uri::OmitScheme);
if(numPrinted)
{
Con_PrintRuler();
LOG_MSG(_E(R));
printTotal += numPrinted;
}
}
}
Con_Message("Found %i %s.", printTotal, printTotal == 1? "Texture" : "Textures");
LOG_MSG("Found " _E(b) "%i" _E(.) " %s.") << printTotal << (printTotal == 1? "texture" : "textures in total");
}

} // namespace de
Expand Down Expand Up @@ -457,12 +444,12 @@ D_CMD(InspectTexture)
" " _E(l) "Coords: " _E(.) _E(i) "%s" _E(.)
_E(R)
"\n" _E(1) "Specification:" _E(.) "%s")
<< variantIdx
<< variant->sourceDescription()
<< (variant->isMasked()? "yes":"no")
<< variant->glName()
<< coords.asText()
<< textualVariantSpec;
<< variantIdx
<< variant->sourceDescription()
<< (variant->isMasked()? "yes":"no")
<< variant->glName()
<< coords.asText()
<< textualVariantSpec;

++variantIdx;
}
Expand Down

0 comments on commit 67b00b7

Please sign in to comment.