better sprite warnings

This commit is contained in:
Konstantin Käfer
2014-05-22 15:19:51 +02:00
parent ba17d2cffc
commit 084e7af377
4 changed files with 21 additions and 8 deletions

View File

@@ -16,6 +16,7 @@ namespace debug {
extern const bool tileParseWarnings;
extern const bool styleParseWarnings;
extern const bool spriteWarnings;
extern const bool renderWarnings;
extern const bool renderTree;

View File

@@ -3,6 +3,7 @@
#include <llmr/platform/platform.hpp>
#include <llmr/util/math.hpp>
#include <llmr/util/std.hpp>
#include <llmr/util/constants.hpp>
#include <llmr/style/sprite.hpp>
@@ -124,7 +125,9 @@ Rect<SpriteAtlas::dimension> SpriteAtlas::getIcon(const int size, const std::str
Rect<dimension> rect = allocateImage(size, size);
if (rect.w == 0) {
fprintf(stderr, "sprite atlas bitmap overflow\n");
if (debug::spriteWarnings) {
fprintf(stderr, "[WARNING] sprite atlas bitmap overflow\n");
}
return rect;
}
@@ -165,7 +168,9 @@ Rect<SpriteAtlas::dimension> SpriteAtlas::getImage(const std::string &name, cons
Rect<dimension> rect = allocateImage(pos.width / pos.pixelRatio, pos.height / pos.pixelRatio);
if (rect.w == 0) {
fprintf(stderr, "sprite atlas bitmap overflow\n");
if (debug::spriteWarnings) {
fprintf(stderr, "[WARNING] sprite atlas bitmap overflow\n");
}
return rect;
}
@@ -215,6 +220,9 @@ void SpriteAtlas::update(const Sprite &sprite) {
Rect<dimension> dst = atlas.getImage(name, sprite);
const SpritePosition &src = sprite.getSpritePosition(name);
if (!src) {
if (debug::spriteWarnings) {
fprintf(stderr, "[WARNING] sprite doesn't have image with name '%s'\n", name.c_str());
}
return true;
}
@@ -222,7 +230,9 @@ void SpriteAtlas::update(const Sprite &sprite) {
atlas.copy(dst, src, sprite);
return true;
} else {
fprintf(stderr, "sprite icon dimension mismatch\n");
if (debug::spriteWarnings) {
fprintf(stderr, "[WARNING] sprite icon dimension mismatch\n");
}
return false;
}
});

View File

@@ -106,8 +106,9 @@ std::unique_ptr<Bucket> TileParser::createBucket(const BucketDescription& bucket
} else {
// The layer specified in the bucket does not exist. Do nothing.
if (debug::tileParseWarnings) {
fprintf(stderr, "[WARNING] layer '%s' does not exist in source '%s'\n",
bucket_desc.source_layer.c_str(), bucket_desc.source_name.c_str());
fprintf(stderr, "[WARNING] layer '%s' does not exist in tile %d/%d/%d of source '%s'\n",
bucket_desc.source_layer.c_str(), tile.id.z, tile.id.x, tile.id.y,
bucket_desc.source_name.c_str());
}
}

View File

@@ -2,7 +2,8 @@
const float llmr::util::tileSize = 512.0f;
const bool llmr::debug::tileParseWarnings = true;
const bool llmr::debug::styleParseWarnings = true;
const bool llmr::debug::renderWarnings = true;
const bool llmr::debug::tileParseWarnings = false;
const bool llmr::debug::styleParseWarnings = false;
const bool llmr::debug::spriteWarnings = false;
const bool llmr::debug::renderWarnings = false;
const bool llmr::debug::renderTree = false;