summaryrefslogtreecommitdiff
path: root/src/gui/itemcontainer.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-06-16 13:36:04 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-06-16 13:36:04 +0000
commitcf4a8c96a0a3b1910a2094cc1e967e720111abb8 (patch)
tree8d0aa3a56faebd5d19fa00ef00f838e7bbda0fea /src/gui/itemcontainer.cpp
parent8d801b2c43f7dfd0b279bb263480d38f5694ac06 (diff)
downloadmana-cf4a8c96a0a3b1910a2094cc1e967e720111abb8.tar.gz
mana-cf4a8c96a0a3b1910a2094cc1e967e720111abb8.tar.bz2
mana-cf4a8c96a0a3b1910a2094cc1e967e720111abb8.tar.xz
mana-cf4a8c96a0a3b1910a2094cc1e967e720111abb8.zip
Fixed cutting off bottom item row of inventory in some cases
Diffstat (limited to 'src/gui/itemcontainer.cpp')
-rw-r--r--src/gui/itemcontainer.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index cdf77436..1a95c857 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -39,7 +39,8 @@ ItemContainer::ItemContainer()
selectedItem = -1; // No item selected
- for (int i = 0; i < INVENTORY_SIZE; i++) {
+ for (int i = 0; i < INVENTORY_SIZE; i++)
+ {
items[i].id = -1;
items[i].quantity = 0;
items[i].equipment = false;
@@ -120,6 +121,23 @@ void ItemContainer::draw(gcn::Graphics* graphics)
}
}
+void ItemContainer::setWidth(int width)
+{
+ gcn::Widget::setWidth(width);
+
+ int gridWidth = itemset->spriteset[0]->getWidth() + 4;
+ int gridHeight = itemset->spriteset[0]->getHeight() + 10;
+ int columns = getWidth() / gridWidth;
+
+ if (columns < 1)
+ {
+ columns = 1;
+ }
+
+ setHeight(((INVENTORY_SIZE / columns) +
+ (INVENTORY_SIZE % columns > 0 ? 1 : 0)) * gridHeight);
+}
+
int ItemContainer::getIndex()
{
return selectedItem;