]> git.sesse.net Git - ccbs/blob - bigscreen/groupscreen.cpp
Remove a debugging printf.
[ccbs] / bigscreen / groupscreen.cpp
1 #include "groupscreen.h"
2 #include "fetch_group.h"
3 #include "fonts.h"
4
5 GroupScreen::GroupScreen(pqxx::connection &conn, unsigned tournament, unsigned round, unsigned parallel)
6         : tournament(tournament), round(round), parallel(parallel), scores_changed(conn, "scores"), conn(conn), valid(false)
7 {
8 }
9
10 GroupScreen::~GroupScreen()
11 {
12 }
13
14 bool GroupScreen::check_invalidated()
15 {
16         // we might want to do this slightly more sophisticated later, but for now this will do
17         return !valid || scores_changed.get_flag();
18 }
19
20 void GroupScreen::draw(unsigned char *buf)
21 {
22         scores_changed.reset_flag();
23
24         Group group;
25         conn.perform(FetchGroup(tournament, round, parallel, &group));
26
27         memset(buf, 0, 800 * 600 * 4);
28         
29         // just as a test, show all the players and the scores (no headings)
30         unsigned y = 50;
31         for (std::vector<Player>::const_iterator i = group.players.begin(); i != group.players.end(); ++i) {
32                 my_draw_text(i->nick, buf, 20, y, true, 255, 255, 255);
33
34                 unsigned x = 90;
35                 for (std::vector<Score>::const_iterator j = i->scores.begin(); j != i->scores.end(); ++j) {
36                         if (j->score == -1) {
37                                 continue;
38                         }
39                         
40                         char text[16];
41                         sprintf(text, "%u", j->score);
42                         
43                         my_draw_text(text, buf, x, y, true, 255, 255, 255);
44                         x += 60;
45                 }
46
47                 y += 20;
48         }
49         
50         valid = true;
51 }
52