summaryrefslogtreecommitdiff
path: root/src/gui/inventorywindow.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-06-12 09:06:01 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-06-12 09:06:01 +0000
commit2f8ee95fbacb71e7cbca85fcc11e6f9f7e36c258 (patch)
tree8d256ac1a38932aaf0db7b55ed178e4212616555 /src/gui/inventorywindow.cpp
parenteb019ab915998a3ec247b33dad4b23f763d7a29a (diff)
downloadmana-client-2f8ee95fbacb71e7cbca85fcc11e6f9f7e36c258.tar.gz
mana-client-2f8ee95fbacb71e7cbca85fcc11e6f9f7e36c258.tar.bz2
mana-client-2f8ee95fbacb71e7cbca85fcc11e6f9f7e36c258.tar.xz
mana-client-2f8ee95fbacb71e7cbca85fcc11e6f9f7e36c258.zip
Merged revisions 3738 via svnmerge from
https://themanaworld.svn.sourceforge.net/svnroot/themanaworld/tmw/trunk ........ r3738 | b_lindeijer | 2007-11-16 00:44:01 +0100 (Fri, 16 Nov 2007) | 3 lines Moved item icon from ItemInfo class to the Item class, so that it can be loaded on demand. Results in faster startup time and reduced memory usage. ........
Diffstat (limited to 'src/gui/inventorywindow.cpp')
-rw-r--r--src/gui/inventorywindow.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 4172a532..fcc602f9 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -57,7 +57,7 @@ InventoryWindow::InventoryWindow():
mUseButton = new Button("Use", "use", this);
mDropButton = new Button("Drop", "drop", this);
- mItems = new ItemContainer(player_node->mInventory);
+ mItems = new ItemContainer(player_node->getInventory());
mItems->addSelectionListener(this);
mInvenScroll = new ScrollArea(mItems);
@@ -100,11 +100,10 @@ void InventoryWindow::logic()
void InventoryWindow::action(const gcn::ActionEvent &event)
{
- Item *item = mItems->getItem();
+ Item *item = mItems->getSelectedItem();
- if (!item) {
+ if (!item)
return;
- }
if (event.getId() == "use") {
if (item->isEquipment()) {
@@ -133,7 +132,7 @@ void InventoryWindow::action(const gcn::ActionEvent &event)
void InventoryWindow::valueChanged(const gcn::SelectionEvent &event)
{
- Item *item = mItems->getItem();
+ const Item *item = mItems->getSelectedItem();
// Update name, effect and description
if (!item)
@@ -161,7 +160,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
if (event.getButton() == gcn::MouseEvent::RIGHT)
{
- Item *item = mItems->getItem();
+ Item *item = mItems->getSelectedItem();
if (!item) return;
@@ -208,11 +207,11 @@ void InventoryWindow::widgetResized(const gcn::Event &event)
void InventoryWindow::updateButtons()
{
- Item *item;
+ const Item *selectedItem = mItems->getSelectedItem();
- if ((item = mItems->getItem()) && item->isEquipment())
+ if (selectedItem && selectedItem->isEquipment())
{
- if (item->isEquipped()) {
+ if (selectedItem->isEquipped()) {
mUseButton->setCaption("Unequip");
}
else {
@@ -220,14 +219,14 @@ void InventoryWindow::updateButtons()
}
}
else {
- mUseButton ->setCaption("Use");
+ mUseButton->setCaption("Use");
}
- mUseButton->setEnabled(!!item);
- mDropButton->setEnabled(!!item);
+ mUseButton->setEnabled(selectedItem != 0);
+ mDropButton->setEnabled(selectedItem != 0);
}
-Item* InventoryWindow::getItem()
+Item* InventoryWindow::getSelectedItem() const
{
- return mItems->getItem();
+ return mItems->getSelectedItem();
}