#ifndef GUIELEMENTS #define GUIELEMENTS #include "../../sdlpp/sdlpp.hpp" #include "../global_vars.hpp" #include "../objectids.hpp" class Button : public SDLPP::TextRenderer { public: Button() = delete; Button(double x, double y, double w, double h, std::shared_ptr &r, const std::string &text, const std::string &color, const std::string &outline_color, const std::string &background_color, std::function click_fun, void *input) : TextRenderer(x, y, w, h, r, g_text_config->getFont(), text, color, outline_color, 0.2), click_fun(click_fun), func_input(input) { setColor(background_color); setId(BUTTON_ID); addCollision(SDLPP::RectColider(0, 0, 1, 1)); } void setBackgroundColor(const std::string &color) { setColor(color); } void performFunction() const { click_fun(func_input); } // TODO highlight visit private: std::function click_fun; void *func_input; }; std::shared_ptr createButton(double x, double y, double w, double h, std::shared_ptr &r, const std::string &text, const std::string &color, const std::string &outline_color, const std::string &background_color, std::function click_fun, void *input); #endif