summaryrefslogtreecommitdiff
path: root/src/gui/itempopup.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-25 22:50:59 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-03-25 22:50:59 +0100
commitcc79f0fe21e1a2ef73cbe987d54e848b9a47142d (patch)
treeedd316eb6094f0c02d6d014385865dcd88a2bc56 /src/gui/itempopup.cpp
parentb0df784f1be44a657ca8092069488602270629b7 (diff)
parent99e8a3fd77b63a029fe02dcf771b6af1aad252ed (diff)
downloadmana-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.gz
mana-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.bz2
mana-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.tar.xz
mana-cc79f0fe21e1a2ef73cbe987d54e848b9a47142d.zip
Merge branch 'eathena/master'
Conflicts: A lot of files.
Diffstat (limited to 'src/gui/itempopup.cpp')
-rw-r--r--src/gui/itempopup.cpp66
1 files changed, 39 insertions, 27 deletions
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index 25e6e78e..1b0a2bb2 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -26,11 +26,11 @@
#include "gui.h"
#include "itempopup.h"
+#include "palette.h"
#include "scrollarea.h"
#include "textbox.h"
-#include "windowcontainer.h"
-#include "widgets/layout.h"
+#include "../graphics.h"
#include "../units.h"
@@ -40,14 +40,12 @@
#include "../utils/stringutils.h"
ItemPopup::ItemPopup():
- Window()
+ Popup()
{
- setResizable(false);
- setShowTitle(false);
- setTitleBarHeight(0);
+ mItemType = "";
// Item Name
- mItemName = new gcn::Label("Label");
+ mItemName = new gcn::Label("");
mItemName->setFont(boldFont);
mItemName->setPosition(2, 2);
@@ -88,8 +86,6 @@ ItemPopup::ItemPopup():
add(mItemDescScroll);
add(mItemEffectScroll);
add(mItemWeightScroll);
-
- setLocationRelativeTo(getParent());
}
ItemPopup::~ItemPopup()
@@ -105,15 +101,18 @@ ItemPopup::~ItemPopup()
void ItemPopup::setItem(const ItemInfo &item)
{
+ if (item.getName() == mItemName->getCaption())
+ return;
+
mItemName->setCaption(item.getName());
-#ifdef EATHENA_SUPPORT
- mItemName->setForegroundColor(getColor(item.getType()));
-#endif
mItemName->setWidth(boldFont->getWidth(item.getName()));
mItemDesc->setTextWrapped(item.getDescription(), 196);
mItemEffect->setTextWrapped(item.getEffect(), 196);
mItemWeight->setTextWrapped(_("Weight: ") +
Units::formatWeight(item.getWeight()), 196);
+#ifdef EATHENA_SUPPORT
+ mItemType = item.getType();
+#endif
int minWidth = mItemName->getWidth();
@@ -166,40 +165,53 @@ void ItemPopup::setItem(const ItemInfo &item)
(2 * getFont()->getHeight()));
}
+void ItemPopup::updateColors()
+{
+#ifdef EATHENA_SUPPORT
+ mItemName->setForegroundColor(getColor(mItemType));
+#endif
+ graphics->setColor(guiPalette->getColor(Palette::TEXT));
+}
+
gcn::Color ItemPopup::getColor(const std::string& type)
{
gcn::Color color;
if (type.compare("generic") == 0)
- color = 0x21a5b1;
+ color = guiPalette->getColor(Palette::GENERIC);
else if (type.compare("equip-head") == 0)
- color = 0x527fa4;
+ color = guiPalette->getColor(Palette::HEAD);
else if (type.compare("usable") == 0)
- color = 0x268d24;
+ color = guiPalette->getColor(Palette::USABLE);
else if (type.compare("equip-torso") == 0)
- color = 0xd12aa4;
+ color = guiPalette->getColor(Palette::TORSO);
else if (type.compare("equip-1hand") == 0)
- color = 0xf42a2a;
+ color = guiPalette->getColor(Palette::ONEHAND);
else if (type.compare("equip-legs") == 0)
- color = 0x699900;
+ color = guiPalette->getColor(Palette::LEGS);
else if (type.compare("equip-feet") == 0)
- color = 0xaa1d48;
+ color = guiPalette->getColor(Palette::FEET);
else if (type.compare("equip-2hand") == 0)
- color = 0xf46d0e;
+ color = guiPalette->getColor(Palette::TWOHAND);
else if (type.compare("equip-shield") == 0)
- color = 0x9c2424;
+ color = guiPalette->getColor(Palette::SHIELD);
else if (type.compare("equip-ring") == 0)
- color = 0x0000ff;
+ color = guiPalette->getColor(Palette::RING);
else if (type.compare("equip-arms") == 0)
- color = 0x9c24e8;
+ color = guiPalette->getColor(Palette::ARMS);
else if (type.compare("equip-ammo") == 0)
- color = 0x8b6311;
+ color = guiPalette->getColor(Palette::AMMO);
else
- color = 0x000000;
+ color = guiPalette->getColor(Palette::UNKNOWN_ITEM);
return color;
}
+std::string ItemPopup::getItemName()
+{
+ return mItemName->getCaption();
+}
+
unsigned int ItemPopup::getNumRows()
{
return mItemDesc->getNumberOfRows() + mItemEffect->getNumberOfRows() +
@@ -208,8 +220,8 @@ unsigned int ItemPopup::getNumRows()
void ItemPopup::view(int x, int y)
{
- if (windowContainer->getWidth() < (x + getWidth() + 5))
- x = windowContainer->getWidth() - getWidth();
+ if (graphics->getWidth() < (x + getWidth() + 5))
+ x = graphics->getWidth() - getWidth();
if ((y - getHeight() - 10) < 0)
y = 0;
else