show item count on inventory
This commit is contained in:
parent
0230540c07
commit
b9e5a4e463
|
@ -132,3 +132,8 @@ bool Thing::ignoreLook()
|
|||
{
|
||||
return m_type->properties[ThingType::IgnoreLook];
|
||||
}
|
||||
|
||||
bool Thing::isStackable()
|
||||
{
|
||||
return m_type->properties[ThingType::IsStackable];
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ public:
|
|||
bool isNotMoveable();
|
||||
bool isPickupable();
|
||||
bool ignoreLook();
|
||||
bool isStackable();
|
||||
|
||||
protected:
|
||||
void internalDraw(const Point& p, int layer);
|
||||
|
|
|
@ -23,10 +23,12 @@
|
|||
#include "uiitem.h"
|
||||
#include <framework/otml/otml.h>
|
||||
#include <framework/graphics/graphics.h>
|
||||
#include <framework/graphics/fontmanager.h>
|
||||
|
||||
UIItem::UIItem()
|
||||
{
|
||||
m_itemMargin = 0;
|
||||
m_font = g_fonts.getFont("verdana-11px-rounded");
|
||||
}
|
||||
|
||||
void UIItem::render()
|
||||
|
@ -34,8 +36,16 @@ void UIItem::render()
|
|||
renderSelf();
|
||||
|
||||
if(m_item) {
|
||||
Point topLeft = m_rect.bottomRight() - Point(32, 32) + m_itemMargin;
|
||||
|
||||
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();
|
||||
|
|
|
@ -42,6 +42,7 @@ protected:
|
|||
private:
|
||||
ItemPtr m_item;
|
||||
int m_itemMargin;
|
||||
FontPtr m_font;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue