X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bigscreen%2Ftheme.cpp;h=0b51fe2e8f795d23355af155cd6d1c3e10736dcb;hb=03c6f0c4b7f83e671b52f33b655c6218538afdb3;hp=fb6f7707b450de93bedf9bc97cc91ad905dc0e19;hpb=c9cf3358a292d988d5d50819bb2db4da3347284a;p=ccbs diff --git a/bigscreen/theme.cpp b/bigscreen/theme.cpp index fb6f770..0b51fe2 100644 --- a/bigscreen/theme.cpp +++ b/bigscreen/theme.cpp @@ -5,6 +5,8 @@ #include #include +#include "theme.h" + std::map config; void read_config(const char *filename) @@ -92,4 +94,30 @@ void fill_background(unsigned char *buf, const std::string &screen_name, unsigne *ptr++ = bg_r; *ptr++ = 0; } + + for (unsigned i = 0; i < 10; ++i) { + char rectkey[1024]; + snprintf(rectkey, sizeof(rectkey), "background.%s.rect%u", screen_name.c_str(), i); + if (get_theme_config(rectkey, "x0").empty()) { + continue; + } + + int x0 = std::max(atoi(get_theme_config(rectkey, "x0").c_str()) * width / LOGICAL_SCREEN_WIDTH, 0); + int y0 = std::max(atoi(get_theme_config(rectkey, "y0").c_str()) * height / LOGICAL_SCREEN_HEIGHT, 0); + int x1 = std::min(atoi(get_theme_config(rectkey, "x1").c_str()) * width / LOGICAL_SCREEN_WIDTH, width); + int y1 = std::min(atoi(get_theme_config(rectkey, "y1").c_str()) * height / LOGICAL_SCREEN_HEIGHT, height); + int r = atoi(get_theme_config(rectkey, "red").c_str()); + int g = atoi(get_theme_config(rectkey, "green").c_str()); + int b = atoi(get_theme_config(rectkey, "blue").c_str()); + + for (int y = y0; y < y1; ++y) { + unsigned char *ptr = buf + (y * width + x0) * 4; + for (int x = x0; x < x1; ++x) { + *ptr++ = b; + *ptr++ = g; + *ptr++ = r; + *ptr++ = 0; + } + } + } }