diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-03-06 10:38:07 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-03-06 10:38:07 +0100 |
commit | 7cbdab589491e007adacd7597c769cdb9308a32c (patch) | |
tree | 0269c37cccbed49a1cb15db9de816f39ef549189 /src/gui/itemcontainer.cpp | |
parent | 616afb27c23def5661b3466d6fc86fd1c65c0082 (diff) | |
parent | aa4229cbb9f2b264ca96c3beedc66b1c79ccc1f5 (diff) | |
download | mana-7cbdab589491e007adacd7597c769cdb9308a32c.tar.gz mana-7cbdab589491e007adacd7597c769cdb9308a32c.tar.bz2 mana-7cbdab589491e007adacd7597c769cdb9308a32c.tar.xz mana-7cbdab589491e007adacd7597c769cdb9308a32c.zip |
Merge branch 'aethyra/master'
Conflicts:
src/being.cpp
src/being.h
src/floor_item.cpp
src/floor_item.h
src/flooritemmanager.cpp
src/gui/inventorywindow.cpp
src/gui/inventorywindow.h
src/gui/itemcontainer.cpp
src/gui/popupmenu.cpp
src/net/beinghandler.cpp
src/npc.cpp
Diffstat (limited to 'src/gui/itemcontainer.cpp')
-rw-r--r-- | src/gui/itemcontainer.cpp | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index eed31f7a..8285a491 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -19,14 +19,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "itemcontainer.h" - -#include "itempopup.h" - #include <guichan/mouseinput.hpp> #include <guichan/selectionlistener.hpp> -#include <SDL_mouse.h> +#include "itemcontainer.h" +#include "itempopup.h" +#include "viewport.h" #include "../graphics.h" #include "../inventory.h" @@ -72,6 +70,9 @@ ItemContainer::~ItemContainer() void ItemContainer::logic() { + if (!isVisible()) + return; + gcn::Widget::logic(); int i = mInventory->getLastUsedSlot() - 1; // Count from 0, usage from 2 @@ -85,18 +86,19 @@ void ItemContainer::logic() void ItemContainer::draw(gcn::Graphics *graphics) { + if (!isVisible()) + return; + int columns = getWidth() / gridWidth; // Have at least 1 column if (columns < 1) - { columns = 1; - } /* - * mOffset is used to compensate for some weirdness that eAthena inherited from - * Ragnarok Online. Inventory slots and cart slots are +2 from their actual index, - * while storage slots are +1. + * mOffset is used to compensate for some weirdness that eAthena inherited + * from Ragnarok Online. Inventory slots and cart slots are +2 from their + * actual index, while storage slots are +1. */ for (int i = mOffset; i < mInventory->getSize(); i++) { @@ -105,31 +107,25 @@ void ItemContainer::draw(gcn::Graphics *graphics) if (!item || item->getQuantity() <= 0) continue; - int itemX = ((i - 2) % columns) * gridWidth; - int itemY = ((i - 2) / columns) * gridHeight; + int itemX = ((i - mOffset) % columns) * gridWidth; + int itemY = ((i - mOffset) / columns) * gridHeight; // Draw selection image below selected item if (mSelectedItemIndex == i) - { - static_cast<Graphics*>(graphics)->drawImage( - mSelImg, itemX, itemY); - } + static_cast<Graphics*>(graphics)->drawImage(mSelImg, itemX, itemY); // Draw item icon Image* image = item->getImage(); + if (image) - { - static_cast<Graphics*>(graphics)->drawImage( - image, itemX, itemY); - } + static_cast<Graphics*>(graphics)->drawImage(image, itemX, itemY); // Draw item caption graphics->setFont(getFont()); graphics->setColor(gcn::Color(0, 0, 0)); graphics->drawText( (item->isEquipped() ? "Eq." : toString(item->getQuantity())), - itemX + gridWidth / 2, - itemY + gridHeight - 11, + itemX + gridWidth / 2, itemY + gridHeight - 11, gcn::Graphics::CENTER); } } @@ -258,12 +254,9 @@ void ItemContainer::mouseMoved(gcn::MouseEvent &event) if (item) { - int mouseX, mouseY; - SDL_GetMouseState(&mouseX, &mouseY); - mItemPopup->setItem(item->getInfo()); mItemPopup->setOpaque(false); - mItemPopup->view(mouseX, mouseY); + mItemPopup->view(viewport->getMouseX(), viewport->getMouseY()); } else { |