#ifndef LOGIC_BOX_CONTROLLER_HPP_
#define LOGIC_BOX_CONTROLLER_HPP_

#include <Controller/InventoryController/InventoryController.hpp>
#include <memory>
#include <Controller/Controller.hpp>
#include <Entity/PhysicsEntity/CameraEntity/Player/Player.hpp>
#include <Machine/MLogicBox/MLogicBox.hpp>

class LogicBoxController final : public InventoryController
{
private:
    std::shared_ptr<MLogicBox> logicBox;
    std::array<MLogicBox::Operation, 4> channelOps = {};

    Command<uint32_t, std::array<MLogicBox::Operation, 4>> updateLogicBoxState;
    Command<uint32_t, uint8_t, DataLink::Channel> setLeftInput;
    Command<uint32_t, uint8_t, DataLink::Channel> setRightInput;
    Command<uint32_t, uint8_t, MLogicBox::Operator> setOperator;

    Widget* makeChannelRow(Material &channelIcon, size_t channelNumber);

public:
    LogicBoxController(ControllerChannel &channel);

    void onConnect(std::shared_ptr<Machine> logicBox);

    virtual Widget* getRightPanel() override;
    virtual bool isBusy() override;
    virtual void update() override;
};

#endif