From fd193321df49fe33697a77f6721b4e1fc13fe05b Mon Sep 17 00:00:00 2001 From: Aaron Marks Date: Wed, 27 Apr 2005 11:25:42 +0000 Subject: Updated item container (fixed rendering position errors). Moved widgets in inventory so everything is aligned. --- src/gui/itemcontainer.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/gui/itemcontainer.cpp') diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index bb10c5a9..5bb3eb35 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -59,20 +59,25 @@ void ItemContainer::draw(gcn::Graphics* graphics) w = getWidth(); h = getHeight(); + int itemWidth = getWidth() / 24; + if (items[selectedItem].quantity <= 0) { selectedItem = -1; } if (selectedItem >= 0) { - int itemX = (((selectedItem - 2) * 24) % (getWidth() - 24)); - int itemY = (((selectedItem - 2) * 24) / (getWidth() - 24)) * 24; + int itemX = ((selectedItem - 2) % itemWidth) * 24; + int itemY = ((selectedItem - 2) / itemWidth) * 24; + itemX -= itemX % 24; selImg->draw(screen, x + itemX, y+itemY); } for (int i = 0; i < INVENTORY_SIZE; i++) { - int itemX = (((i - 2) * 24) % (getWidth() - 24)); - int itemY = (((i - 2) * 24) / (getWidth() - 24)) * 24; + int itemX = ((i - 2) % itemWidth) * 24; + int itemY = ((i - 2) / itemWidth) * 24; + + itemX -= itemX % 24; if (items[i].quantity > 0) { if (itemDb.getItemInfo(items[i].id)->getImage() > 0) { -- cgit v1.2.3-70-g09d2