7 #include "flagtrigger.h"
8 #include "widestring.h"
9 #include "fetch_current_tournament.h"
12 Tournament active_tournament;
13 unsigned char framebuf[800 * 600 * 4];
15 void init(pqxx::connection &conn)
17 conn.perform(FetchCurrentTournament(&active_tournament));
19 if (active_tournament.id == -1) {
20 std::fprintf(stderr, "No active tournament\n");
22 std::fprintf(stderr, "Current tournament is %d (name: '%s')\n",
23 active_tournament.id, active_tournament.name.c_str());
27 void main_loop(pqxx::connection &conn)
29 if (active_tournament.id == -1) {
30 // No active tournament, sleep a second or so and exit
35 memset(framebuf, 0, 800*600*4);
37 pqxx::work t(conn, "trx");
40 pqxx::result res( t.exec("SELECT * FROM songs WHERE title LIKE 'M%'") );
42 for (pqxx::result::const_iterator i = res.begin(); i != res.end(); ++i) {
43 my_draw_text(i["title"].as(widestring()), framebuf, 0, y, 1, 255, 255, 255);
45 // std::fprintf(stderr, "%s\n", i["title"].c_str());
53 int main(int argc, char **argv)
55 ptc_open("CCBS bigscreen", 800, 600);
59 pqxx::connection conn("dbname=ccbs host=altersex.samfundet.no user=ccbs password=GeT|>>B_");
60 FlagTrigger tournament_changed(conn, "active_tournament");
61 FlagTrigger rounds_changed(conn, "active_groups");
63 // when active_tournament or active_rounds is changed, we destroy everything and start from scratch
64 // (at least currently)
66 tournament_changed.reset_flag();
67 rounds_changed.reset_flag();
72 } while (!tournament_changed.get_flag() && !rounds_changed.get_flag());
73 std::fprintf(stderr, "active_tournament or active_groups changed, resetting...\n");
75 } catch (const std::exception &e) {
76 std::fprintf(stderr, "Exception: %s\n", e.what());