#include <Widget/StaticItemSlot/RecipeInputView/RecipeInputView.hpp>
#include <Color/Color.hpp>
#include <Utilities/Utilities.hpp>

glm::vec4 RecipeInputView::getHighlight()
{
    if (inv.countItems(templStack) < templStack.getStackSize())
    {
        return Color::unavailableItem;
    }
    else
    {
        return Color::availableItem;
    }
}

void RecipeInputView::getExtraToolTipLines(ToolTip &tip)
{
    int numItems = inv.countItems(templStack);
    if (numItems < templStack.getStackSize())
    {
        tip.addLine(Color::unavailableItem, formatString("YOU HAVE $+/$+", numItems, templStack.getStackSize()));
    }
    else
    {
        tip.addLine(Color::availableItem, "YOU HAVE ENOUGH");
    }
}

RecipeInputView::RecipeInputView(IInventory &inv, ItemStack templStack) :
    StaticItemSlot([templStack]() { return templStack; }),
    inv(inv),
    templStack(templStack)
{}