From a1d19e32e1206e406409ca68db6f344535e16519 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Mon, 26 Jan 2009 11:38:12 -0700 Subject: Modified item popups to show the weight of the item as well. TODO: modify itemdb to pull the item weight information from the server instead of the client, so as to always have the server and client in sync. Signed-off-by: Ira Rice --- src/gui/itempopup.cpp | 71 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 57 insertions(+), 14 deletions(-) (limited to 'src/gui/itempopup.cpp') diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index f9916a89..42ef88ae 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -20,6 +20,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #include #include "gui.h" @@ -34,6 +36,7 @@ #include "../utils/gettext.h" #include "../utils/strprintf.h" +#include "../utils/tostring.h" ItemPopup::ItemPopup(): Window() @@ -52,37 +55,50 @@ ItemPopup::ItemPopup(): mItemDesc = new TextBox(); mItemDesc->setEditable(false); mItemDesc->setMinWidth(186); + mItemDesc->setTextWrapped(""); mItemDescScroll = new ScrollArea(mItemDesc); mItemDescScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mItemDescScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); - mItemDescScroll->setDimension(gcn::Rectangle(0, 0, 196, 14)); + mItemDescScroll->setDimension(gcn::Rectangle(0, 0, 196, getFont()->getHeight())); mItemDescScroll->setOpaque(false); - mItemDescScroll->setPosition(2, 15); + mItemDescScroll->setPosition(2, getFont()->getHeight()); // Item Effect mItemEffect = new TextBox(); mItemEffect->setEditable(false); mItemEffect->setMinWidth(186); + mItemEffect->setTextWrapped(""); mItemEffectScroll = new ScrollArea(mItemEffect); mItemEffectScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mItemEffectScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); - mItemEffectScroll->setDimension(gcn::Rectangle(0, 0, 196, 14)); + mItemEffectScroll->setDimension(gcn::Rectangle(0, 0, 196, getFont()->getHeight())); mItemEffectScroll->setOpaque(false); - mItemEffectScroll->setPosition(2, 35); + mItemEffectScroll->setPosition(2, (2 * getFont()->getHeight()) + 5); + + // Item Weight + mItemWeight = new TextBox(); + mItemWeight->setEditable(false); + mItemWeight->setMinWidth(186); + mItemWeight->setTextWrapped(""); + mItemWeightScroll = new ScrollArea(mItemWeight); + + mItemWeightScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); + mItemWeightScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); + mItemWeightScroll->setDimension(gcn::Rectangle(0, 0, 196, getFont()->getHeight())); + mItemWeightScroll->setOpaque(false); + mItemWeightScroll->setPosition(2, (3 * getFont()->getHeight()) + 10); add(mItemName); add(mItemDescScroll); add(mItemEffectScroll); + add(mItemWeightScroll); setLocationRelativeTo(getParent()); // LEEOR / TODO: This causes an exception error. //moveToBottom(getParent()); - - mItemDesc->setTextWrapped( "" ); - mItemEffect->setTextWrapped( "" ); } void ItemPopup::setItem(const ItemInfo &item) @@ -92,30 +108,57 @@ void ItemPopup::setItem(const ItemInfo &item) mItemDesc->setMinWidth(width - 10); mItemEffect->setMinWidth(width - 10); + mItemWeight->setMinWidth(width - 10); mItemName->setCaption(item.getName()); mItemDesc->setTextWrapped(item.getDescription()); mItemEffect->setTextWrapped(item.getEffect()); + mItemWeight->setTextWrapped(_("Weight: ") + toString(item.getWeight()) + + _(" grams")); int numRowsDesc = mItemDesc->getNumberOfRows(); int numRowsEffect = mItemEffect->getNumberOfRows(); + int numRowsWeight = mItemWeight->getNumberOfRows(); + + mItemDescScroll->setDimension(gcn::Rectangle(2, 0, 196, + numRowsDesc * getFont()->getHeight())); + + mItemEffectScroll->setDimension(gcn::Rectangle(2, 0, 196, + numRowsEffect * getFont()->getHeight())); + + mItemWeightScroll->setDimension(gcn::Rectangle(2, 0, 196, + numRowsWeight * getFont()->getHeight())); if(item.getEffect() == "") - setContentSize(200, (numRowsDesc * 14) + 30); + { + setContentSize(200, (numRowsDesc * getFont()->getHeight() + + (3 * getFont()->getHeight()))); + + mItemWeightScroll->setPosition(2, + (numRowsDesc * getFont()->getHeight()) + + (2 * getFont()->getHeight())); + } else - setContentSize(200, (numRowsDesc * 14) + (numRowsEffect * 14) + 30); - - mItemDescScroll->setDimension(gcn::Rectangle(2, 0, 196, numRowsDesc * 14)); + { + setContentSize(200, (numRowsDesc * getFont()->getHeight()) + + (numRowsEffect * getFont()->getHeight()) + + (3 * getFont()->getHeight())); - mItemEffectScroll->setDimension(gcn::Rectangle(2, 0, 196, numRowsEffect * 14)); + mItemWeightScroll->setPosition(2, + (numRowsDesc * getFont()->getHeight()) + + (numRowsEffect * getFont()->getHeight()) + + (2 * getFont()->getHeight())); + } mItemDescScroll->setPosition(2, 20); - mItemEffectScroll->setPosition(2, (numRowsDesc * 15) + 25); + mItemEffectScroll->setPosition(2, (numRowsDesc * getFont()->getHeight()) + + (2 * getFont()->getHeight())); } unsigned int ItemPopup::getNumRows() { - return mItemDesc->getNumberOfRows(), mItemEffect->getNumberOfRows(); + return mItemDesc->getNumberOfRows() + mItemEffect->getNumberOfRows() + + mItemWeight->getNumberOfRows(); } void ItemPopup::view(int x, int y) -- cgit v1.2.3-60-g2f50