From 0ffbbaa33f633bccf3b2a49713eb1cb117ff8a5a Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 26 Feb 2009 08:24:01 -0700 Subject: Fixed an error in shoplistboxes as identified by Octalot. Signed-off-by: Ira Rice --- src/gui/buy.cpp | 2 +- src/gui/buy.h | 2 +- src/gui/listbox.cpp | 3 ++- src/gui/listbox.h | 10 +++++----- src/gui/sell.cpp | 2 +- src/gui/shop.cpp | 3 +-- src/gui/shoplistbox.cpp | 9 --------- src/gui/shoplistbox.h | 2 -- src/shopitem.cpp | 6 ++---- src/shopitem.h | 2 +- 10 files changed, 14 insertions(+), 27 deletions(-) diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index a2485ca1..5a57dcc6 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -118,7 +118,7 @@ void BuyDialog::reset() setMoney(0); } -void BuyDialog::addItem(short id, int price) +void BuyDialog::addItem(int id, int price) { mShopItems->addItem(id, price); mShopItemList->adjustSize(); diff --git a/src/gui/buy.h b/src/gui/buy.h index b05608c0..9029fe9d 100644 --- a/src/gui/buy.h +++ b/src/gui/buy.h @@ -69,7 +69,7 @@ class BuyDialog : public Window, public gcn::ActionListener, /** * Adds an item to the shop inventory. */ - void addItem(short id, int price); + void addItem(int id, int price); /** * Called when receiving actions from the widgets. diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp index 8ae68e09..45d14884 100644 --- a/src/gui/listbox.cpp +++ b/src/gui/listbox.cpp @@ -56,7 +56,7 @@ void ListBox::draw(gcn::Graphics *graphics) const int fontHeight = getFont()->getHeight(); - // Draw rectangle below the selected list element + // Draw filled rectangle around the selected list element if (mSelected >= 0) graphics->fillRectangle(gcn::Rectangle(0, fontHeight * mSelected, getWidth(), fontHeight)); @@ -97,6 +97,7 @@ void ListBox::setSelected(int selected) mSelected = selected; } } + gcn::ListBox::setSelected(mSelected); } // -- KeyListener notifications diff --git a/src/gui/listbox.h b/src/gui/listbox.h index a6392a94..09f00cdf 100644 --- a/src/gui/listbox.h +++ b/src/gui/listbox.h @@ -47,17 +47,17 @@ class ListBox : public gcn::ListBox */ void draw(gcn::Graphics *graphics); - void mouseDragged(gcn::MouseEvent &event); - // Inherited from KeyListener - virtual void keyPressed(gcn::KeyEvent& keyEvent); + void keyPressed(gcn::KeyEvent& keyEvent); // Inherited from MouseListener - virtual void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent); + void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent); - virtual void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent); + void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent); + + void mouseDragged(gcn::MouseEvent &event); /** * Sets the selected item. The selected item is represented by diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index f974f247..154d1a57 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -121,7 +121,7 @@ void SellDialog::addItem(const Item *item, int price) } mShopItems->addItem(item->getInvIndex(), item->getId(), - item->getQuantity(), price); + item->getQuantity(), price); mShopItemList->adjustSize(); } diff --git a/src/gui/shop.cpp b/src/gui/shop.cpp index da68cf28..bd676bc0 100644 --- a/src/gui/shop.cpp +++ b/src/gui/shop.cpp @@ -44,8 +44,7 @@ std::string ShopItems::getElementAt(int i) return mShopItems.at(i)->getDisplayName(); } -void ShopItems::addItem(int inventoryIndex, int id, int quantity, - int price) +void ShopItems::addItem(int inventoryIndex, int id, int quantity, int price) { ShopItem* item = 0; if (mMergeDuplicates) diff --git a/src/gui/shoplistbox.cpp b/src/gui/shoplistbox.cpp index 6d3d9464..6e70e022 100644 --- a/src/gui/shoplistbox.cpp +++ b/src/gui/shoplistbox.cpp @@ -108,15 +108,6 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) } } -void ShopListBox::mousePressed(gcn::MouseEvent &event) -{ - if (event.getButton() == gcn::MouseEvent::LEFT) - { - setSelected(event.getY() / mRowHeight); - distributeActionEvent(); - } -} - void ShopListBox::adjustSize() { if (mListModel) diff --git a/src/gui/shoplistbox.h b/src/gui/shoplistbox.h index 8542a7b8..bed9902b 100644 --- a/src/gui/shoplistbox.h +++ b/src/gui/shoplistbox.h @@ -57,8 +57,6 @@ class ShopListBox : public ListBox */ unsigned int getRowHeight() const { return mRowHeight; } - void mousePressed(gcn::MouseEvent &event); - /** * gives information about the current player's money */ diff --git a/src/shopitem.cpp b/src/shopitem.cpp index 5573eb37..00875a2d 100644 --- a/src/shopitem.cpp +++ b/src/shopitem.cpp @@ -24,8 +24,7 @@ #include "utils/stringutils.h" -ShopItem::ShopItem (int inventoryIndex, int id, - int quantity, int price) : +ShopItem::ShopItem (int inventoryIndex, int id, int quantity, int price) : Item (id, 0), mPrice(price) { mDisplayName = getInfo().getName() + " (" + toString(mPrice) + " GP)"; @@ -50,8 +49,7 @@ ShopItem::~ShopItem() } } -void ShopItem::addDuplicate(int inventoryIndex, - int quantity) +void ShopItem::addDuplicate(int inventoryIndex, int quantity) { DuplicateItem* di = new DuplicateItem; di->inventoryIndex = inventoryIndex; diff --git a/src/shopitem.h b/src/shopitem.h index d6226732..18608a94 100644 --- a/src/shopitem.h +++ b/src/shopitem.h @@ -89,7 +89,7 @@ class ShopItem : public Item */ int getCurrentInvIndex() { return mDuplicates.empty() ? mInvIndex : - mDuplicates.top()->inventoryIndex; + mDuplicates.top()->inventoryIndex; } /** -- cgit v1.2.3-70-g09d2