Support different backgrounds per-screen.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 19 Feb 2012 17:28:22 +0000 (18:28 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 19 Feb 2012 17:28:22 +0000 (18:28 +0100)
bigscreen/groupscreen.cpp
bigscreen/theme.config
bigscreen/theme.cpp
bigscreen/theme.h
bigscreen/top10scorescreen.cpp
bigscreen/top5chosenscreen.cpp

index d417457..ab3ca54 100644 (file)
@@ -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<unsigned> colwidth;
        
index 2ac2167..fc03f3a 100644 (file)
@@ -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
index 542d2ad..fb6f770 100644 (file)
@@ -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) {
index 2c87384..c87d9c3 100644 (file)
@@ -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()))
index 2a52568..a024e98 100644 (file)
@@ -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
index 57a54f0..d63b724 100644 (file)
@@ -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