From 67b00b7c4e631573d138e781bd427e38a1b47dd2 Mon Sep 17 00:00:00 2001 From: danij Date: Sun, 17 Nov 2013 10:36:08 +0000 Subject: [PATCH] Console|Resources|Client: Applied rich formatting to "listtextures" output; cleanup --- doomsday/client/src/resource/fonts.cpp | 3 +- doomsday/client/src/resource/textures.cpp | 71 +++++++++-------------- 2 files changed, 31 insertions(+), 43 deletions(-) diff --git a/doomsday/client/src/resource/fonts.cpp b/doomsday/client/src/resource/fonts.cpp index 8d1f92f45a..e0200bbc27 100644 --- a/doomsday/client/src/resource/fonts.cpp +++ b/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 * @authors Copyright © 2005-2013 Daniel Swanson @@ -23,6 +23,7 @@ #include "de_console.h" #include "dd_main.h" // App_Fonts(), verbose +#include #include #include #include diff --git a/doomsday/client/src/resource/textures.cpp b/doomsday/client/src/resource/textures.cpp index 122e678a63..e00a2edb80 100644 --- a/doomsday/client/src/resource/textures.cpp +++ b/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 * @@ -17,19 +17,17 @@ * 02110-1301 USA */ -#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 -#include -#include // for M_NumDigits +#include #include -#include "resource/textures.h" - D_CMD(ListTextures); D_CMD(InspectTexture); - #ifdef DENG_DEBUG D_CMD(PrintTextureStats); #endif @@ -39,11 +37,11 @@ namespace de { DENG2_PIMPL(Textures) { /// System subspace schemes containing the textures. - Textures::Schemes schemes; + Schemes schemes; QList schemeCreationOrder; /// All texture instances in the system (from all schemes). - Textures::All textures; + All textures; Instance(Public *i) : Base(i) {} @@ -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); @@ -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; } @@ -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++; } @@ -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 { @@ -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 @@ -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; }