+
+ conn.perform(FetchAuxilliaryScreens(&aux_screens));
+ for (std::vector<widestring>::const_iterator i = aux_screens.begin(); i != aux_screens.end(); ++i) {
+ if (*i == widestring("top10scores")) {
+ screens.push_back(new Top10ScoreScreen(conn, active_tournament.id));
+ continue;
+ }
+ std::fprintf(stderr, "Foobarbaz?\n");
+ }
+
+ // hack
+ screens.push_back(NULL);
+ screens.push_back(NULL);
+ screens.push_back(NULL);
+ screens.push_back(NULL);
+
+ if (screens[1] == NULL) {
+ mainscreen = screens[0];
+ } else {
+ mainscreen = new SplitScreen(screens[0], screens[1], screens[2], screens[3]);
+ }
+}
+
+void main_loop(pqxx::connection &conn)
+{
+ if (active_tournament.id == -1) {
+ // No active tournament, sleep a second or so and exit
+ conn.await_notification(1, 0);
+ return;
+ }
+
+ if (mainscreen && mainscreen->check_invalidated()) {
+ mainscreen->draw(framebuf);
+ ptc_update(framebuf);
+ conn.await_notification(0, 10000);
+ } else {
+ ptc_update(framebuf);
+ conn.await_notification(0, 200000);
+ }
+}