From d23a826feff2a09b081aee7d3f83d616d97d8e0e Mon Sep 17 00:00:00 2001 From: "wrenczes@gmail.com" Date: Sat, 9 Jul 2011 04:30:18 +0000 Subject: [PATCH] Fixed the back image card drawing offset. There's probably a better way to fix this, but it stems from the fact that cards (and the large back.jpg image handling) have their hotspots set to the center of the card coords, but for whatever reason, the code that draws the thumbnail version of the back image doesn't. Rather than try to fix the coords in all the places where we draw the back thumb image, I refined the quad sharing code so that there's one quad for temp cards, and another for actual back image drawing. --- projects/mtg/src/WCachedResource.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/projects/mtg/src/WCachedResource.cpp b/projects/mtg/src/WCachedResource.cpp index 6166aa3c8..2b1464c7e 100644 --- a/projects/mtg/src/WCachedResource.cpp +++ b/projects/mtg/src/WCachedResource.cpp @@ -9,6 +9,8 @@ #ifdef WITH_FMOD #endif +const std::string kPlaceholderID("placeholder"); + //WResource WResource::~WResource() { @@ -103,13 +105,12 @@ JQuadPtr WCachedTexture::GetQuad(float offX, float offY, float width, float heig // If we're fetching a card resource, but it's not available yet, we'll be attempting to get the Quad from the temporary back image. // If that's the case, don't stash a separate tracked quad entry for each card name in the the Back/BackThumbnail's resource string resource(resname); - if (mFilename == kGenericCard) + if (mFilename == kGenericCard || mFilename == kGenericThumbCard) { - resource = kGenericCardID; - } - else if (mFilename == kGenericThumbCard) - { - resource = kGenericCardThumbnailID; + // if we're the back or thumb_back file, but we've been asked for a card ID, then assign it + // a placeholder ID. Reason being, hotspots on quads are different (ie centered) for card images, so we'll store a separate quad for cards + if (resname != kGenericCardID && resname != kGenericCardThumbnailID) + resource = kPlaceholderID; } std::map::iterator iter = mTrackedQuads.find(resource);