diff --git a/src/Base/Entry.cpp b/src/Base/Entry.cpp index 5a61364..3721ddb 100644 --- a/src/Base/Entry.cpp +++ b/src/Base/Entry.cpp @@ -32,6 +32,8 @@ int main(int argc, char **argv) { event.reply("Could not find that command :("); }); + bot.on_button_click([&bot](const dpp::button_click_t &event) {}); + bot.on_ready([&bot](const dpp::ready_t &event) { if (dpp::run_once()) { createCommands(event, bot); diff --git a/src/Commands/GenerativeCommands.cpp b/src/Commands/GenerativeCommands.cpp index 25f3985..9baa3e6 100644 --- a/src/Commands/GenerativeCommands.cpp +++ b/src/Commands/GenerativeCommands.cpp @@ -27,12 +27,12 @@ void commandGenerateReport(const dpp::slashcommand_t &event, .set_label(BUTTON_ACCEPT) .set_type(dpp::cot_button) .set_style(dpp::component_style::cos_success) - .set_id("stinky")) + .set_id("generate_report_confirm")) .add_component(dpp::component() .set_label(BUTTON_CANCEL) .set_type(dpp::cot_button) .set_style(dpp::component_style::cos_danger) - .set_id("stinkyyy"))); + .set_id("generate_report_deny"))); event.edit_response(confirmRequest); } else { event.edit_response( diff --git a/src/Utility/CairoGenerate.cpp b/src/Utility/CairoGenerate.cpp index 65117eb..3b94a0f 100644 --- a/src/Utility/CairoGenerate.cpp +++ b/src/Utility/CairoGenerate.cpp @@ -1,4 +1,5 @@ #include "CairoTools.hpp" +#include #include std::string GenerateReportImage(cairo_surface_t *background, @@ -7,14 +8,13 @@ std::string GenerateReportImage(cairo_surface_t *background, CAIRO_FORMAT_ARGB32, REPORT_WIDTH, REPORT_HEIGHT); cairo_t *ctx = cairo_create(surface); - cairo_set_source_rgb(ctx, 0, 0, 0); + cairo_set_source_rgb(ctx, CAIRO_BLACK); cairo_paint(ctx); - int imgW = 0, imgH = 0; // Background Image cairo_save(ctx); - imgW = cairo_image_surface_get_width(background); - imgH = cairo_image_surface_get_height(background); + int imgW = cairo_image_surface_get_width(background), + imgH = cairo_image_surface_get_height(background); cairo_scale(ctx, (double)REPORT_WIDTH / imgW, (double)(REPORT_HEIGHT - REPORT_HEIGHT_OFFSET) / imgH); @@ -25,15 +25,15 @@ std::string GenerateReportImage(cairo_surface_t *background, // Gradient cairo_pattern_t *gradient = cairo_pattern_create_linear(0, 0, 0, REPORT_HEIGHT); - cairo_pattern_add_color_stop_rgba(gradient, 0.85, 0, 0, 0, 1); - cairo_pattern_add_color_stop_rgba(gradient, 0, 0, 0, 0, 0); + cairo_pattern_add_color_stop_rgba(gradient, 0.85, CAIRO_BLACK, 1.0); + cairo_pattern_add_color_stop_rgba(gradient, 0.0, CAIRO_BLACK, 0.0); cairo_rectangle(ctx, 0, 0, REPORT_WIDTH, REPORT_HEIGHT); cairo_set_source(ctx, gradient); cairo_fill(ctx); // Bumper cairo_save(ctx); - cairo_surface_t *bumper = + static cairo_surface_t *bumper = cairo_image_surface_create_from_png(REPORT_RESOURCE_BUMPER_PATH); imgW = cairo_image_surface_get_width(bumper); @@ -71,11 +71,15 @@ std::string GenerateReportImage(cairo_surface_t *background, cairo_move_to(ctx, REPORT_TEXT_START_X, REPORT_HEIGHT - (REPORT_TEXT_JUMP_Y * (outputList.size() - lineCount++))); - cairo_set_source_rgb(ctx, CAIRO_TEXT_WHITE); + cairo_set_source_rgb(ctx, CAIRO_QUARTZ); cairo_show_text(ctx, line.c_str()); } std::string data; cairo_surface_write_to_png_stream(surface, cairoOutputAsPNGStream, &data); + + // Ugh cleanup + cairo_surface_destroy(surface); + cairo_destroy(ctx); return data; } diff --git a/src/Utility/CairoTools.hpp b/src/Utility/CairoTools.hpp index 9825553..882cf48 100644 --- a/src/Utility/CairoTools.hpp +++ b/src/Utility/CairoTools.hpp @@ -10,7 +10,8 @@ #define REPORT_TEXT_FONT_SIZE 120.0 #define REPORT_TEXT_LENGTH 26 #define REPORT_RESOURCE_BUMPER_PATH "./assets/report_bumper.png" -#define CAIRO_TEXT_WHITE 0.87, 0.87, 0.87 +#define CAIRO_QUARTZ 0.87, 0.87, 0.87 +#define CAIRO_BLACK 0.0, 0.0, 0.0 std::string GenerateReportImage(cairo_surface_t *background, std::string headline);