diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-06-16 13:36:04 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-06-16 13:36:04 +0000 |
commit | cf4a8c96a0a3b1910a2094cc1e967e720111abb8 (patch) | |
tree | 8d0aa3a56faebd5d19fa00ef00f838e7bbda0fea /src/gui | |
parent | 8d801b2c43f7dfd0b279bb263480d38f5694ac06 (diff) | |
download | mana-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')
-rw-r--r-- | src/gui/inventory.cpp | 3 | ||||
-rw-r--r-- | src/gui/itemcontainer.cpp | 20 | ||||
-rw-r--r-- | src/gui/itemcontainer.h | 6 |
3 files changed, 26 insertions, 3 deletions
diff --git a/src/gui/inventory.cpp b/src/gui/inventory.cpp index 59be88b8..36bea6cf 100644 --- a/src/gui/inventory.cpp +++ b/src/gui/inventory.cpp @@ -43,6 +43,7 @@ InventoryWindow::InventoryWindow(): items = new ItemContainer(); invenScroll = new ScrollArea(items); invenScroll->setPosition(8, 8); + invenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); useButton->setEventId("use"); dropButton->setEventId("drop"); @@ -227,8 +228,6 @@ void InventoryWindow::updateWidgets() // Resize widgets useButton->setPosition(8, height - 24); dropButton->setPosition(48 + 16, height - 24); - items->setSize(width - 24 - 12 - 1, - (INVENTORY_SIZE * 24) / columns - 1); invenScroll->setSize(width - 16, height - 90); itemNameLabel->setPosition(8, 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; diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h index 9ee6892a..fd38e818 100644 --- a/src/gui/itemcontainer.h +++ b/src/gui/itemcontainer.h @@ -74,6 +74,12 @@ class ItemContainer : public gcn::Widget, public gcn::MouseListener void draw(gcn::Graphics *graphics); /** + * Sets the width of the container. This is used to determine the new + * height of the container. + */ + void setWidth(int width); + + /** * Handles mouse click. */ void mousePress(int mx, int my, int button); |