From ada99b0ff2395e4d0853016306564f471bfc1bc8 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sun, 10 Jan 2010 22:09:42 +0000 Subject: Change Buy and Sell dialogs to use ItemPopups --- src/gui/shoplistbox.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'src/gui/shoplistbox.cpp') diff --git a/src/gui/shoplistbox.cpp b/src/gui/shoplistbox.cpp index 6581a82d..fbdc22ce 100644 --- a/src/gui/shoplistbox.cpp +++ b/src/gui/shoplistbox.cpp @@ -19,9 +19,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "gui/widgets/shoplistbox.h" + +#include "gui/itempopup.h" #include "gui/palette.h" #include "gui/shop.h" -#include "gui/shoplistbox.h" +#include "gui/viewport.h" #include "configuration.h" #include "graphics.h" @@ -41,6 +44,8 @@ ShopListBox::ShopListBox(gcn::ListModel *listModel): { mRowHeight = getFont()->getHeight(); mPriceCheck = true; + + mItemPopup = new ItemPopup; } ShopListBox::ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel): @@ -50,6 +55,8 @@ ShopListBox::ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel): { mRowHeight = std::max(getFont()->getHeight(), ITEM_ICON_SIZE); mPriceCheck = true; + + mItemPopup = new ItemPopup; } void ShopListBox::setPlayersMoney(int money) @@ -128,3 +135,21 @@ void ShopListBox::setPriceCheck(bool check) { mPriceCheck = check; } + +void ShopListBox::mouseMoved(gcn::MouseEvent &event) +{ + if (!mShopItems) + return; + + Item *item = mShopItems->at(event.getY() / mRowHeight); + + if (item) + { + mItemPopup->setItem(item->getInfo()); + mItemPopup->view(viewport->getMouseX(), viewport->getMouseY()); + } + else + { + mItemPopup->setVisible(false); + } +} -- cgit v1.2.3-70-g09d2