Skip to content

Commit

Permalink
Display big items in UI more conviniently (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonekk authored Nov 6, 2024
1 parent 357cd91 commit d20e8e1
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/client/thingtype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,16 +563,19 @@ DrawQueueItem* ThingType::draw(const Rect& dest, int layer, int xPattern, int yP
if (!size.isValid())
return nullptr;

// size correction for some too big items
if ((m_size.width() > 1 || m_size.height() > 1) &&
textureRect.width() <= g_sprites.spriteSize() && textureRect.height() <= g_sprites.spriteSize()) {
size = Size(g_sprites.spriteSize(), g_sprites.spriteSize());
textureOffset = Point((g_sprites.spriteSize() - textureRect.width()) / m_size.width(),
(g_sprites.spriteSize() - textureRect.height()) / m_size.height());
float scaleX = (float)dest.width() / size.width();
float scaleY = (float)dest.height() / size.height();
Size finalDrawSize = textureRect.size();
if (scaleX < 1) {
textureOffset.x = 0;
finalDrawSize.setWidth(dest.width());
}
if (scaleY < 1) {
textureOffset.y = 0;
finalDrawSize.setHeight(dest.height());
}

float scale = std::min<float>((float)dest.width() / size.width(), (float)dest.height() / size.height());
return g_drawQueue->addTexturedRect(Rect(dest.topLeft() + (textureOffset * scale), textureRect.size() * scale), texture, textureRect, color);
return g_drawQueue->addTexturedRect(Rect(dest.topLeft() + textureOffset, finalDrawSize), texture, textureRect, color);
}

std::shared_ptr<DrawOutfitParams> ThingType::drawOutfit(const Point& dest, int maskLayer, int xPattern, int yPattern, int zPattern, int animationPhase, Color color, LightView* lightView)
Expand Down

0 comments on commit d20e8e1

Please sign in to comment.