#include <BlockRegistry/BlockRegistry.hpp>
#include <Widget/ItemIcon/ItemIcon.hpp>
#include <Widget/Label/Label.hpp>
#include <Widget/Layout/Center/Center.hpp>
#include <Widget/Layout/CompoundWidget/Deck/Deck.hpp>
#include <Widget/Layout/CompoundWidget/DocMachineTag/DocMachineTag.hpp>
#include <Widget/Layout/Frame/Frame.hpp>
#include <Widget/Layout/Row/Row.hpp>
#include <Widget/Panel/Panel.hpp>

DocMachineTag::DocMachineTag(const std::vector<std::string> &args)
{
    if (args.size() != 2)
    {
        addChildren(new Label("<!!!>", Color::error));
        return;
    }

    ItemStack itemStack = blockRegistry.getBlockByName(args[1]).toItemStack();

    addChildren(
        (new Frame(
            new Deck<Row, Center>(
                new ItemIcon(itemStack),
                new Panel(glm::ivec2(1, 0)),
                new Label(itemStack.getDisplayName())
            )
        ))->withMargin(1)
    );
}