diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/confirm_dialog.cpp | 5 | ||||
-rw-r--r-- | src/gui/confirm_dialog.h | 2 | ||||
-rw-r--r-- | src/gui/equipmentwindow.cpp | 4 | ||||
-rw-r--r-- | src/gui/itemcontainer.cpp | 4 | ||||
-rw-r--r-- | src/gui/itemlinkhandler.cpp | 10 | ||||
-rw-r--r-- | src/gui/itempopup.cpp | 24 | ||||
-rw-r--r-- | src/gui/itempopup.h | 18 | ||||
-rw-r--r-- | src/gui/itemshortcutcontainer.cpp | 5 | ||||
-rw-r--r-- | src/gui/ok_dialog.cpp | 5 | ||||
-rw-r--r-- | src/gui/ok_dialog.h | 2 | ||||
-rw-r--r-- | src/gui/speechbubble.cpp | 7 | ||||
-rw-r--r-- | src/gui/speechbubble.h | 7 |
12 files changed, 15 insertions, 78 deletions
diff --git a/src/gui/confirm_dialog.cpp b/src/gui/confirm_dialog.cpp index 41bf44ad..969000f3 100644 --- a/src/gui/confirm_dialog.cpp +++ b/src/gui/confirm_dialog.cpp @@ -85,11 +85,6 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg, yesButton->requestFocus(); } -unsigned int ConfirmDialog::getNumRows() -{ - return mTextBox->getNumberOfRows(); -} - void ConfirmDialog::action(const gcn::ActionEvent &event) { // Proxy button events to our listeners diff --git a/src/gui/confirm_dialog.h b/src/gui/confirm_dialog.h index 821131c6..dad79933 100644 --- a/src/gui/confirm_dialog.h +++ b/src/gui/confirm_dialog.h @@ -45,8 +45,6 @@ class ConfirmDialog : public Window, public gcn::ActionListener ConfirmDialog(const std::string &title, const std::string &msg, Window *parent = NULL); - unsigned int getNumRows(); - /** * Called when receiving actions from the widgets. */ diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 04b275e2..2ba55792 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -251,9 +251,7 @@ void EquipmentWindow::mouseMoved(gcn::MouseEvent &event) int mouseX, mouseY; SDL_GetMouseState(&mouseX, &mouseY); - if (item->getInfo().getName() != mItemPopup->getItemName()) - mItemPopup->setItem(item->getInfo()); - mItemPopup->updateColors(); + mItemPopup->setItem(item->getInfo()); mItemPopup->view(x + getX(), y + getY()); } else diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index 40f4ae28..a672f3b5 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -302,9 +302,7 @@ void ItemContainer::mouseMoved(gcn::MouseEvent &event) if (item) { - if (item->getInfo().getName() != mItemPopup->getItemName()) - mItemPopup->setItem(item->getInfo()); - mItemPopup->updateColors(); + mItemPopup->setItem(item->getInfo()); mItemPopup->view(viewport->getMouseX(), viewport->getMouseY()); } else diff --git a/src/gui/itemlinkhandler.cpp b/src/gui/itemlinkhandler.cpp index 29fa310d..6476ce60 100644 --- a/src/gui/itemlinkhandler.cpp +++ b/src/gui/itemlinkhandler.cpp @@ -32,7 +32,6 @@ ItemLinkHandler::ItemLinkHandler() { mItemPopup = new ItemPopup; - mItemPopup->setOpaque(false); } ItemLinkHandler::~ItemLinkHandler() @@ -46,21 +45,16 @@ void ItemLinkHandler::handleLink(const std::string &link) std::stringstream stream; stream << link; stream >> id; + if (id > 0) { const ItemInfo &iteminfo = ItemDB::get(id); - if (iteminfo.getName() != mItemPopup->getItemName()) - mItemPopup->setItem(iteminfo); + mItemPopup->setItem(iteminfo); if (mItemPopup->isVisible()) - { mItemPopup->setVisible(false); - } else - { - mItemPopup->updateColors(); mItemPopup->view(viewport->getMouseX(), viewport->getMouseY()); - } } } diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 6c994aca..a4229324 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -98,13 +98,16 @@ void ItemPopup::setItem(const ItemInfo &item) if (item.getName() == mItemName->getCaption()) return; + mItemType = item.getType(); + mItemName->setCaption(item.getName()); - mItemName->setWidth(boldFont->getWidth(item.getName())); + mItemName->adjustSize(); + mItemName->setForegroundColor(getColor(mItemType)); + mItemDesc->setTextWrapped(item.getDescription(), 196); mItemEffect->setTextWrapped(item.getEffect(), 196); mItemWeight->setTextWrapped(_("Weight: ") + Units::formatWeight(item.getWeight()), 196); - mItemType = item.getType(); int minWidth = mItemName->getWidth(); @@ -150,12 +153,6 @@ void ItemPopup::setItem(const ItemInfo &item) mItemEffectScroll->setPosition(2, (numRowsDesc + 2) * height); } -void ItemPopup::updateColors() -{ - mItemName->setForegroundColor(getColor(mItemType)); - graphics->setColor(guiPalette->getColor(Palette::TEXT)); -} - gcn::Color ItemPopup::getColor(ItemType type) { switch (type) @@ -191,17 +188,6 @@ gcn::Color ItemPopup::getColor(ItemType type) } } -std::string ItemPopup::getItemName() const -{ - return mItemName->getCaption(); -} - -unsigned int ItemPopup::getNumRows() const -{ - return mItemDesc->getNumberOfRows() + mItemEffect->getNumberOfRows() + - mItemWeight->getNumberOfRows(); -} - void ItemPopup::view(int x, int y) { const int distance = 20; diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h index c08b188a..687e664b 100644 --- a/src/gui/itempopup.h +++ b/src/gui/itempopup.h @@ -30,6 +30,9 @@ class ScrollArea; class TextBox; +/** + * A popup that displays information about an item. + */ class ItemPopup : public Popup { public: @@ -49,21 +52,6 @@ class ItemPopup : public Popup void setItem(const ItemInfo &item); /** - * Gets the number of rows that the item popup currently has. - */ - unsigned int getNumRows() const; - - /** - * Gets the name of the currently stored item in this popup. - */ - std::string getItemName() const; - - /** - * Updates the colors used within the item popup. - */ - void updateColors(); - - /** * Sets the location to display the item popup. */ void view(int x, int y); diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp index ce9013aa..e5d0d1b9 100644 --- a/src/gui/itemshortcutcontainer.cpp +++ b/src/gui/itemshortcutcontainer.cpp @@ -49,7 +49,6 @@ ItemShortcutContainer::ItemShortcutContainer(): addWidgetListener(this); mItemPopup = new ItemPopup; - mItemPopup->setOpaque(false); ResourceManager *resman = ResourceManager::getInstance(); @@ -239,9 +238,7 @@ void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event) if (item && inventoryWindow->isVisible()) { - if (item->getInfo().getName() != mItemPopup->getItemName()) - mItemPopup->setItem(item->getInfo()); - mItemPopup->updateColors(); + mItemPopup->setItem(item->getInfo()); mItemPopup->view(viewport->getMouseX(), viewport->getMouseY()); } else diff --git a/src/gui/ok_dialog.cpp b/src/gui/ok_dialog.cpp index 06217653..7ccb781e 100644 --- a/src/gui/ok_dialog.cpp +++ b/src/gui/ok_dialog.cpp @@ -75,11 +75,6 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg, okButton->requestFocus(); } -unsigned int OkDialog::getNumRows() -{ - return mTextBox->getNumberOfRows(); -} - void OkDialog::action(const gcn::ActionEvent &event) { // Proxy button events to our listeners diff --git a/src/gui/ok_dialog.h b/src/gui/ok_dialog.h index 30cfcdca..26e788f5 100644 --- a/src/gui/ok_dialog.h +++ b/src/gui/ok_dialog.h @@ -45,8 +45,6 @@ class OkDialog : public Window, public gcn::ActionListener OkDialog(const std::string &title, const std::string &msg, Window *parent = NULL); - unsigned int getNumRows(); - /** * Called when receiving actions from the widgets. */ diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index b7977d09..da472449 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -68,7 +68,7 @@ void SpeechBubble::setCaption(const std::string &name, const gcn::Color *color) mCaption->setForegroundColor(*color); } -void SpeechBubble::setText(std::string text, bool showName) +void SpeechBubble::setText(const std::string &text, bool showName) { if (text == mText && (mCaption->getWidth() <= mSpeechBox->getMinWidth())) return; @@ -98,8 +98,3 @@ void SpeechBubble::setText(std::string text, bool showName) mCaption->setPosition(xPos, getPadding()); mSpeechArea->setDimension(gcn::Rectangle(xPos, yPos, width, height)); } - -unsigned int SpeechBubble::getNumRows() const -{ - return mSpeechBox->getNumberOfRows(); -} diff --git a/src/gui/speechbubble.h b/src/gui/speechbubble.h index 4601a43e..8455a1b1 100644 --- a/src/gui/speechbubble.h +++ b/src/gui/speechbubble.h @@ -48,18 +48,13 @@ class SpeechBubble : public Popup /** * Sets the text to be displayed. */ - void setText(std::string text, bool showName = true); + void setText(const std::string &text, bool showName = true); /** * Sets the location in which the speech bubble will be displayed. */ void setLocation(int x, int y); - /** - * Gets the number of rows the speech bubble has. - */ - unsigned int getNumRows() const; - private: std::string mText; gcn::Label *mCaption; |