summaryrefslogtreecommitdiff
path: root/src/gui/itempopup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/itempopup.cpp')
-rw-r--r--src/gui/itempopup.cpp57
1 files changed, 32 insertions, 25 deletions
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index efbee6b0..61cb18fb 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);
-
- center();
}
ItemPopup::~ItemPopup()
@@ -109,12 +105,12 @@ void ItemPopup::setItem(const ItemInfo &item)
return;
mItemName->setCaption(item.getName());
- mItemName->setForegroundColor(getColor(item.getType()));
mItemName->setWidth(boldFont->getWidth(item.getName()));
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();
@@ -167,40 +163,51 @@ void ItemPopup::setItem(const ItemInfo &item)
(2 * getFont()->getHeight()));
}
+void ItemPopup::updateColors()
+{
+ mItemName->setForegroundColor(getColor(mItemType));
+ 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() +
@@ -209,8 +216,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