diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/buy.cpp | 18 | ||||
-rw-r--r-- | src/gui/buy.h | 2 | ||||
-rw-r--r-- | src/gui/sell.cpp | 23 | ||||
-rw-r--r-- | src/gui/sell.h | 2 | ||||
-rw-r--r-- | src/gui/shoplistbox.cpp | 27 | ||||
-rw-r--r-- | src/gui/shoplistbox.h | 5 |
6 files changed, 38 insertions, 39 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index a2398472..c6ae56ff 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -26,7 +26,6 @@ #include "gui/widgets/layout.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/slider.h" - #include "gui/setup.h" #include "gui/shop.h" #include "gui/shoplistbox.h" @@ -76,8 +75,6 @@ BuyDialog::BuyDialog(): mBuyButton = new Button(_("Buy"), "buy", this); mQuitButton = new Button(_("Quit"), "quit", this); mAddMaxButton = new Button(_("Max"), "max", this); - mItemDescLabel = new Label(strprintf(_("Description: %s"), "")); - mItemEffectLabel = new Label(strprintf(_("Effect: %s"), "")); mDecreaseButton->adjustSize(); mDecreaseButton->setWidth(mIncreaseButton->getWidth()); @@ -101,10 +98,8 @@ BuyDialog::BuyDialog(): place(5, 5, mQuantityLabel, 2); place(7, 5, mAddMaxButton); place(0, 6, mMoneyLabel, 8); - place(0, 7, mItemEffectLabel, 8); - place(0, 8, mItemDescLabel, 8); - place(6, 9, mBuyButton); - place(7, 9, mQuitButton); + place(6, 7, mBuyButton); + place(7, 7, mQuitButton); Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); @@ -223,13 +218,6 @@ void BuyDialog::updateButtonsAndLabels() if (selectedItem > -1) { - const ItemInfo &info = mShopItems->at(selectedItem)->getInfo(); - - mItemDescLabel->setCaption - (strprintf(_("Description: %s"), info.getDescription().c_str())); - mItemEffectLabel->setCaption - (strprintf(_("Effect: %s"), info.getEffect().c_str())); - int itemPrice = mShopItems->at(selectedItem)->getPrice(); // Calculate how many the player can afford @@ -244,8 +232,6 @@ void BuyDialog::updateButtonsAndLabels() } else { - mItemDescLabel->setCaption(strprintf(_("Description: %s"), "")); - mItemEffectLabel->setCaption(strprintf(_("Effect: %s"), "")); mMaxItems = 0; mAmountItems = 0; } diff --git a/src/gui/buy.h b/src/gui/buy.h index 52d02d7b..7fddaf6c 100644 --- a/src/gui/buy.h +++ b/src/gui/buy.h @@ -117,8 +117,6 @@ class BuyDialog : public Window, public gcn::ActionListener, gcn::Button *mDecreaseButton; ShopListBox *mShopItemList; gcn::ScrollArea *mScrollArea; - gcn::Label *mItemDescLabel; - gcn::Label *mItemEffectLabel; gcn::Label *mMoneyLabel; gcn::Label *mQuantityLabel; gcn::Slider *mSlider; diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index 92ad1dbd..305eab97 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -21,15 +21,14 @@ #include "gui/sell.h" -#include "gui/setup.h" -#include "gui/shop.h" -#include "gui/shoplistbox.h" - #include "gui/widgets/button.h" #include "gui/widgets/label.h" #include "gui/widgets/layout.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/slider.h" +#include "gui/setup.h" +#include "gui/shop.h" +#include "gui/shoplistbox.h" #include "npc.h" #include "shopitem.h" @@ -74,8 +73,6 @@ SellDialog::SellDialog(): mSellButton = new Button(_("Sell"), "sell", this); mQuitButton = new Button(_("Quit"), "quit", this); mAddMaxButton = new Button(_("Max"), "max", this); - mItemDescLabel = new Label(strprintf(_("Description: %s"), "")); - mItemEffectLabel = new Label(strprintf(_("Effect: %s"), "")); mDecreaseButton->adjustSize(); mDecreaseButton->setWidth(mIncreaseButton->getWidth()); @@ -100,10 +97,8 @@ SellDialog::SellDialog(): place(5, 5, mQuantityLabel, 2); place(7, 5, mAddMaxButton); place(0, 6, mMoneyLabel, 8); - place(0, 7, mItemEffectLabel, 8); - place(0, 8, mItemDescLabel, 8); - place(6, 9, mSellButton); - place(7, 9, mQuitButton); + place(6, 7, mSellButton); + place(7, 7, mQuitButton); Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); @@ -248,12 +243,6 @@ void SellDialog::updateButtonsAndLabels() if (selectedItem > -1) { - const ItemInfo &info = mShopItems->at(selectedItem)->getInfo(); - mItemDescLabel->setCaption - (strprintf(_("Description: %s"), info.getDescription().c_str())); - mItemEffectLabel->setCaption - (strprintf(_("Effect: %s"), info.getEffect().c_str())); - mMaxItems = mShopItems->at(selectedItem)->getQuantity(); if (mAmountItems > mMaxItems) { @@ -264,8 +253,6 @@ void SellDialog::updateButtonsAndLabels() } else { - mItemDescLabel->setCaption(strprintf(_("Description: %s"), "")); - mItemEffectLabel->setCaption(strprintf(_("Effect: %s"), "")); mMaxItems = 0; mAmountItems = 0; } diff --git a/src/gui/sell.h b/src/gui/sell.h index 547e297b..c8b5092f 100644 --- a/src/gui/sell.h +++ b/src/gui/sell.h @@ -108,8 +108,6 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener ShopListBox *mShopItemList; gcn::ScrollArea *mScrollArea; gcn::Label *mMoneyLabel; - gcn::Label *mItemDescLabel; - gcn::Label *mItemEffectLabel; gcn::Label *mQuantityLabel; gcn::Slider *mSlider; 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); + } +} diff --git a/src/gui/shoplistbox.h b/src/gui/shoplistbox.h index 7b232ccb..99d3b9bd 100644 --- a/src/gui/shoplistbox.h +++ b/src/gui/shoplistbox.h @@ -25,6 +25,7 @@ #include "gui/widgets/listbox.h" class ShopItems; +class ItemPopup; /** * A list box, meant to be used inside a scroll area. Same as the Guichan list @@ -71,6 +72,8 @@ class ShopListBox : public ListBox * (Good for selling mode.) */ void setPriceCheck(bool check); + + void mouseMoved(gcn::MouseEvent &event); private: int mPlayerMoney; @@ -81,6 +84,8 @@ class ShopListBox : public ListBox */ ShopItems *mShopItems; + ItemPopup *mItemPopup; + unsigned int mRowHeight; /**< Row Height */ static float mAlpha; |