]> git.sesse.net Git - ccbs/blobdiff - bigscreen/groupscreen.cpp
Do some funky channel magic on fading between different versions of the same screen...
[ccbs] / bigscreen / groupscreen.cpp
index d8450f8679d370a8e16b97170433e5e75ae6855b..441117d45e29f95e58056748ab2add1635b5a93e 100644 (file)
@@ -1,9 +1,11 @@
+#include <cstdio>
 #include <algorithm>
 
 #include "groupscreen.h"
 #include "fetch_group.h"
 #include "fetch_max_score_for_song.h"
 #include "fetch_max_score_for_player.h"
+#include "fetch_needs_update.h"
 #include "fonts.h"
 
 GroupScreen::GroupScreen(pqxx::connection &conn, unsigned tournament, unsigned round, unsigned parallel)
@@ -17,8 +19,18 @@ GroupScreen::~GroupScreen()
 
 bool GroupScreen::check_invalidated()
 {
-       // we might want to do this slightly more sophisticated later, but for now this will do
-       return !valid || scores_changed.get_flag();
+       if (!valid)
+               return true;
+       if (!scores_changed.get_flag())
+               return false;
+
+       bool needs_update;
+       conn.perform(FetchNeedsUpdate(last_updated, tournament, round, parallel, &needs_update));
+
+       if (!needs_update)
+               scores_changed.reset_flag();
+       
+       return needs_update;
 }
 
 void GroupScreen::draw(unsigned char *buf)
@@ -27,6 +39,7 @@ void GroupScreen::draw(unsigned char *buf)
 
        Group group;
        conn.perform(FetchGroup(tournament, round, parallel, &group));
+       gettimeofday(&last_updated, NULL);
 
        memset(buf, 0, 800 * 600 * 4);