summaryrefslogtreecommitdiff
path: root/src/gui/itemcontainer.cpp
diff options
context:
space:
mode:
authorBlue <bluesansdouze@gmail.com>2009-05-13 20:35:44 +0200
committerBlue <bluesansdouze@gmail.com>2009-05-13 20:35:44 +0200
commit22685431a23b05d66af28abda488d0891b1c0a34 (patch)
treea207b9230833abbed3da751ca7e3c4ccdc8e9783 /src/gui/itemcontainer.cpp
parent9071a692116745f2cafd8556cbff28095910730e (diff)
parentb5ad7e490f0f429a5abac2acae48ecf25485256f (diff)
downloadmana-client-22685431a23b05d66af28abda488d0891b1c0a34.tar.gz
mana-client-22685431a23b05d66af28abda488d0891b1c0a34.tar.bz2
mana-client-22685431a23b05d66af28abda488d0891b1c0a34.tar.xz
mana-client-22685431a23b05d66af28abda488d0891b1c0a34.zip
Merge branch 'master' of git@gitorious.org:tmw/mainline
Diffstat (limited to 'src/gui/itemcontainer.cpp')
-rw-r--r--src/gui/itemcontainer.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index 6cbdabb2..54aa818b 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -57,6 +57,7 @@ ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity):
mGridRows(1),
mSelectedIndex(-1),
mHighlightedIndex(-1),
+ mLastUsedSlot(-1),
mSelectionStatus(SEL_NONE),
mForceQuantity(forceQuantity),
mSwapItems(false),
@@ -82,6 +83,19 @@ ItemContainer::~ItemContainer()
delete mItemPopup;
}
+void ItemContainer::logic()
+{
+ gcn::Widget::logic();
+
+ const int lastUsedSlot = mInventory->getLastUsedSlot();
+
+ if (lastUsedSlot != mLastUsedSlot)
+ {
+ mLastUsedSlot = lastUsedSlot;
+ adjustHeight();
+ }
+}
+
void ItemContainer::draw(gcn::Graphics *graphics)
{
Graphics *g = static_cast<Graphics*>(graphics);
@@ -178,7 +192,7 @@ void ItemContainer::distributeValueChangedEvent()
void ItemContainer::keyPressed(gcn::KeyEvent &event)
{
- switch (event.getKey().getValue())
+ /*switch (event.getKey().getValue())
{
case Key::LEFT:
moveHighlight(Left);
@@ -202,12 +216,12 @@ void ItemContainer::keyPressed(gcn::KeyEvent &event)
case Key::RIGHT_CONTROL:
mDescItems = true;
break;
- }
+ }*/
}
void ItemContainer::keyReleased(gcn::KeyEvent &event)
{
- switch (event.getKey().getValue())
+ /*switch (event.getKey().getValue())
{
case Key::LEFT_ALT:
case Key::RIGHT_ALT:
@@ -216,7 +230,7 @@ void ItemContainer::keyReleased(gcn::KeyEvent &event)
case Key::RIGHT_CONTROL:
mDescItems = false;
break;
- }
+ }*/
}
void ItemContainer::mousePressed(gcn::MouseEvent &event)
@@ -316,8 +330,13 @@ void ItemContainer::mouseExited(gcn::MouseEvent &event)
void ItemContainer::widgetResized(const gcn::Event &event)
{
mGridColumns = std::max(1, getWidth() / BOX_WIDTH);
- mGridRows = mInventory->getSize() / mGridColumns;
- if (mGridRows == 0 || mInventory->getSize() % mGridColumns > 0)
+ adjustHeight();
+}
+
+void ItemContainer::adjustHeight()
+{
+ mGridRows = (mLastUsedSlot + 1) / mGridColumns;
+ if (mGridRows == 0 || (mLastUsedSlot + 1) % mGridColumns > 0)
++mGridRows;
setHeight(mGridRows * BOX_HEIGHT);