#pragma once
#include <functional>

#include "CheckboxValue.h"
#include "ConfigValue.h"

#pragma pack(push, 1)
class ActionRowValue : public ConfigValue
{
public:
    ActionRowValue(const std::function<void ()>& action, const std::string& n,
                   const bool sameline = false) : ConfigValue(n)
    {
        this->action_ = action;
        this->sameline_ = sameline;
    }

    void draw() override
    {
        if (this->sameline_) ImGui::SameLine();
        if (disabled_) ImGui::BeginDisabled();
        if (ImGui::Button(this->get_imgui_title().c_str()))
        {
            if (!disabled_)
                this->action_();
        }
        if (disabled_) ImGui::EndDisabled();
        ImGui::SetCursorPosY(ImGui::GetCursorPosY() + ImGui::GetStyle().FramePadding.y * 3 * menu::get_scale_factor());
    }

    void set_disabled(const bool d)
    {
        disabled_ = d;
    }

    [[nodiscard]] bool is_disabled() const
    {
        return disabled_;
    }

    void set(const std::string& string) override
    {
    }

    std::string get() override
    {
        return "";
    }

    std::string get_default() override
    {
        return "";
    }

private:
    std::function<void ()> action_;
    bool sameline_ = false;
    bool disabled_ = false;
};
#pragma pack(pop)
