From: Steinar H. Gunderson Date: Sun, 19 Feb 2012 17:28:22 +0000 (+0100) Subject: Support different backgrounds per-screen. X-Git-Url: https://git.sesse.net/?p=ccbs;a=commitdiff_plain;h=c9cf3358a292d988d5d50819bb2db4da3347284a Support different backgrounds per-screen. --- diff --git a/bigscreen/groupscreen.cpp b/bigscreen/groupscreen.cpp index d417457..ab3ca54 100644 --- a/bigscreen/groupscreen.cpp +++ b/bigscreen/groupscreen.cpp @@ -615,7 +615,7 @@ void GroupScreen::draw(unsigned char *buf, unsigned width, unsigned height) conn.perform(FetchGroup(tournament, round, parallel, &group)); gettimeofday(&last_updated, NULL); - fill_background(buf, width, height); + fill_background(buf, "groupscreen", width, height); std::vector colwidth; diff --git a/bigscreen/theme.config b/bigscreen/theme.config index 2ac2167..fc03f3a 100644 --- a/bigscreen/theme.config +++ b/bigscreen/theme.config @@ -46,5 +46,5 @@ divider.red=127 divider.green=127 divider.blue=127 -# available elements: background, mainheading, (fresh)columnheading, randomsongname, nextsonginfo, need, divider +# available elements: background.groupscreen, background.top5chosenscreen, background.top10scorescreen, mainheading, (fresh)columnheading, randomsongname, nextsonginfo, need, divider # available elements that also have .odd and .even: rowheading, (fresh)score, (fresh)chosensongname, (fresh)totalscore, (fresh)rank diff --git a/bigscreen/theme.cpp b/bigscreen/theme.cpp index 542d2ad..fb6f770 100644 --- a/bigscreen/theme.cpp +++ b/bigscreen/theme.cpp @@ -78,11 +78,12 @@ std::string get_theme_config(const std::string &key, const std::string subkey) return config["default." + subkey]; } -void fill_background(unsigned char *buf, unsigned width, unsigned height) +void fill_background(unsigned char *buf, const std::string &screen_name, unsigned width, unsigned height) { - int bg_r = atoi(get_theme_config("background", "red").c_str()); - int bg_g = atoi(get_theme_config("background", "green").c_str()); - int bg_b = atoi(get_theme_config("background", "blue").c_str()); + std::string key = "background." + screen_name; + int bg_r = atoi(get_theme_config(key, "red").c_str()); + int bg_g = atoi(get_theme_config(key, "green").c_str()); + int bg_b = atoi(get_theme_config(key, "blue").c_str()); unsigned char *ptr = buf; for (unsigned i = 0; i < width * height; ++i) { diff --git a/bigscreen/theme.h b/bigscreen/theme.h index 2c87384..c87d9c3 100644 --- a/bigscreen/theme.h +++ b/bigscreen/theme.h @@ -5,7 +5,7 @@ void init_theme(); std::string get_theme_config(const std::string &key, const std::string subkey); -void fill_background(unsigned char *buf, unsigned width, unsigned height); +void fill_background(unsigned char *buf, const std::string &screen_name, unsigned width, unsigned height); #define LOGICAL_SCREEN_WIDTH (atoi(get_theme_config("screen", "logical_width").c_str())) #define LOGICAL_SCREEN_HEIGHT (atoi(get_theme_config("screen", "logical_height").c_str())) diff --git a/bigscreen/top10scorescreen.cpp b/bigscreen/top10scorescreen.cpp index 2a52568..a024e98 100644 --- a/bigscreen/top10scorescreen.cpp +++ b/bigscreen/top10scorescreen.cpp @@ -46,7 +46,7 @@ bool Top10ScoreScreen::check_invalidated() void Top10ScoreScreen::draw(unsigned char *buf, unsigned width, unsigned height) { scores_changed.reset_flag(); - fill_background(buf, width, height); + fill_background(buf, "top10scorescreen", width, height); set_screen_size(width, height); // fetch the top 10 scores diff --git a/bigscreen/top5chosenscreen.cpp b/bigscreen/top5chosenscreen.cpp index 57a54f0..d63b724 100644 --- a/bigscreen/top5chosenscreen.cpp +++ b/bigscreen/top5chosenscreen.cpp @@ -45,7 +45,7 @@ bool Top5ChosenScreen::check_invalidated() void Top5ChosenScreen::draw(unsigned char *buf, unsigned width, unsigned height) { scores_changed.reset_flag(); - fill_background(buf, width, height); + fill_background(buf, "top5chosenscreen", width, height); set_screen_size(width, height); // fetch the top 5 chosen songs