#include <Widget/ItemView/ItemView.hpp>
#include <Entity/PhysicsEntity/CameraEntity/Player/Player.hpp>

ItemView::ItemView(Player *player, int slot) : m_player(player), m_slot(slot) {}

void ItemView::draw(GraphicsContext &context)
{
    if (m_slot == m_player->getSelectedSlot())
    {
        context.color = Color::selection;
    }
    else
    {
        context.color = Color::widgetBackground;
    }

    context.drawRect(4, 7, 12, 12);

    ItemStack stack = m_player->items.store("inventory").getStackInSlot(m_slot);
    stack.draw(context, 6, 9);
}

glm::ivec2 ItemView::getMinSize()
{
    return glm::ivec2(20, 21);
}