show item count on inventory

This commit is contained in:
Henrique Santiago 2012-01-05 17:28:32 -02:00
parent 0230540c07
commit b9e5a4e463
4 changed files with 18 additions and 1 deletions

View File

@ -132,3 +132,8 @@ bool Thing::ignoreLook()
{ {
return m_type->properties[ThingType::IgnoreLook]; return m_type->properties[ThingType::IgnoreLook];
} }
bool Thing::isStackable()
{
return m_type->properties[ThingType::IsStackable];
}

View File

@ -77,6 +77,7 @@ public:
bool isNotMoveable(); bool isNotMoveable();
bool isPickupable(); bool isPickupable();
bool ignoreLook(); bool ignoreLook();
bool isStackable();
protected: protected:
void internalDraw(const Point& p, int layer); void internalDraw(const Point& p, int layer);

View File

@ -23,10 +23,12 @@
#include "uiitem.h" #include "uiitem.h"
#include <framework/otml/otml.h> #include <framework/otml/otml.h>
#include <framework/graphics/graphics.h> #include <framework/graphics/graphics.h>
#include <framework/graphics/fontmanager.h>
UIItem::UIItem() UIItem::UIItem()
{ {
m_itemMargin = 0; m_itemMargin = 0;
m_font = g_fonts.getFont("verdana-11px-rounded");
} }
void UIItem::render() void UIItem::render()
@ -34,8 +36,16 @@ void UIItem::render()
renderSelf(); renderSelf();
if(m_item) { if(m_item) {
Point topLeft = m_rect.bottomRight() - Point(32, 32) + m_itemMargin;
g_painter.setColor(Fw::white); g_painter.setColor(Fw::white);
m_item->draw(m_rect.bottomRight() - Point(32, 32) + m_itemMargin, m_rect); m_item->draw(topLeft, m_rect);
if(m_font && m_item->isStackable() && m_item->getData() > 1) {
std::string count = Fw::tostring(m_item->getData());
m_font->renderText(count, Rect(m_rect.topLeft(), m_rect.bottomRight() - Point(3, 0)), Fw::AlignBottomRight, Color(231, 231, 231));
dump << m_rect;
}
} }
renderChildren(); renderChildren();

View File

@ -42,6 +42,7 @@ protected:
private: private:
ItemPtr m_item; ItemPtr m_item;
int m_itemMargin; int m_itemMargin;
FontPtr m_font;
}; };
#endif #endif