Fix drawing creatures in UICreature

I will leave this ugly hack for the time being, but I do encourage to change it later on. The whole "resize" boolean makes no sense since the outfit is resized by the destination rectangle anyway. I believe we should give it a try with a real size of the object defined in dat by the user for creatures bigger than 32x32.

Please keep in mind that we did cut bigger creatures to 48x48 (2*Otc::TILE_PIXELS*0.75f) before as well, so nothing really changed besides ability to properly draw bigger creatures than 64x64 on battlelist.
master
Konrad Kuśnierz 9 years ago
parent 6bd0e37670
commit c3c2ac80e7

@ -200,29 +200,24 @@ void Creature::drawOutfit(const Rect& destRect, bool resize)
else
exactSize = g_things.rawGetThingType(m_outfit.getAuxId(), m_outfit.getCategory())->getExactSize();
int frameSize;
if(!resize)
frameSize = std::max<int>(exactSize * 0.75f, 2 * Otc::TILE_PIXELS * 0.75f);
else if(!(frameSize = exactSize))
return;
if(g_graphics.canUseFBO()) {
const FrameBufferPtr& outfitBuffer = g_framebuffers.getTemporaryFrameBuffer();
outfitBuffer->resize(Size(exactSize, exactSize));
outfitBuffer->resize(Size(frameSize, frameSize));
outfitBuffer->bind();
g_painter->setAlphaWriting(true);
g_painter->clear(Color::alpha);
internalDrawOutfit(Point(exactSize - Otc::TILE_PIXELS, exactSize - Otc::TILE_PIXELS) + getDisplacement(), 1, false, true, Otc::South);
internalDrawOutfit(Point(frameSize - Otc::TILE_PIXELS, frameSize - Otc::TILE_PIXELS) + getDisplacement(), 1, false, true, Otc::South);
outfitBuffer->release();
Rect srcRect;
if(resize)
srcRect.resize(exactSize, exactSize);
else
srcRect.resize(exactSize*0.75f, exactSize*0.75f);
srcRect.moveBottomRight(Point(exactSize - 1, exactSize - 1));
outfitBuffer->draw(destRect, srcRect);
outfitBuffer->draw(destRect, Rect(0,0,frameSize,frameSize));
} else {
float scaleFactor;
if(resize)
scaleFactor = destRect.width() / (float)exactSize;
else
scaleFactor = destRect.width() / (float)(exactSize*0.75f);
Point dest = destRect.bottomRight() - (Point(exactSize - Otc::TILE_PIXELS, exactSize - Otc::TILE_PIXELS) - getDisplacement()) * scaleFactor;
float scaleFactor = destRect.width() / (float)frameSize;
Point dest = destRect.bottomRight() - (Point(Otc::TILE_PIXELS,Otc::TILE_PIXELS) - getDisplacement()) * scaleFactor;
internalDrawOutfit(dest, scaleFactor, false, true, Otc::South);
}
}

Loading…
Cancel
Save