#ifndef STATIC_ITEM_SLOT_HPP_
#define STATIC_ITEM_SLOT_HPP_

#include <GraphicsContext/GraphicsContext.hpp>
#include <RuntimeStateCache/RuntimeStateCache.hpp>
#include <Utilities/StandardLerping.hpp>
#include <string>
#include <functional>
#include <Widget/Widget.hpp>
#include <ItemStack/ItemStack.hpp>

class InventoryController;

/**
 * @brief A widget which views and controls an item slot.
 */
class StaticItemSlot : public Widget
{
private:
    struct SharedState
    {
        StaticItemSlot *hoveredSlot = nullptr;
    };

    std::shared_ptr<SharedState> shared = RuntimeStateCache::get<SharedState>("/item-slot-shared");

    std::function<ItemStack()> m_getStack;
    std::string emptyToolTip;
    StandardLerping<glm::vec4> backgroundLerp;
    StandardLerping<glm::vec4> highlightLerp;
    glm::vec4 staticHighlight = glm::vec4(0.0f);

protected:
    /**
     * @brief Get the highlight color.
     */
    virtual glm::vec4 getHighlight();

    /**
     * @brief Add any additional lines desired to the item tooltip.
     * 
     * By default does not add any lines.
     * 
     * @param tip The tooltip.
     */
    virtual void getExtraToolTipLines(ToolTip &tip);

    /**
     * @brief Called if the mouse hovers over this slot while it's empty.
     * 
     * Does nothing by default. You could use it to create a tooltip.
     */
    virtual void onHoveringOverEmpty(GraphicsContext &context);

public:
    /**
     * @brief Construct the item slot.
     * 
     * @param getStack A function returning the stack to display.
     */
    StaticItemSlot(std::function<ItemStack()> getStack);

    virtual ~StaticItemSlot();

    /**
     * @brief Set the tooltip to display when hovering over this slot when empty.
     */
    StaticItemSlot* withEmptyToolTip(std::string tip);

    /**
     * @brief Set the static highlight.
     */
    StaticItemSlot* withStaticHighlight(glm::vec4 staticHighlight);

    virtual void draw(GraphicsContext &context) override;
    virtual glm::ivec2 getMinSize() override;
    virtual void onMouseMoved(glm::ivec2 pos) override;
};

#endif