#include "fetch_list_of_active_groups.h"
#include "fetch_group.h"
#include "fonts.h"
+#include "groupscreen.h"
Tournament active_tournament;
std::vector<SkeletonGroup> active_groups;
-unsigned char framebuf[800 * 600 * 4];
+std::vector<GenericScreen *> screens;
+unsigned char framebuf[800 * 600 * 4], screenbuf[800 * 600 * 4];
void init(pqxx::connection &conn)
{
+ for (std::vector<GenericScreen *>::const_iterator i = screens.begin(); i != screens.end(); ++i) {
+ delete *i;
+ }
+ screens.erase(screens.begin(), screens.end());
+
conn.perform(FetchCurrentTournament(&active_tournament));
conn.perform(FetchListOfActiveGroups(&active_groups));
std::fprintf(stderr, "tourn: %u round: %u parallel: %u\n",
i->tournament, i->round, i->parallel);
- Group gr;
- conn.perform(FetchGroup(i->tournament, i->round, i->parallel, &gr));
- std::fprintf(stderr, "%u players in group\n", gr.players.size());
+ screens.push_back(new GroupScreen(conn, i->tournament, i->round, i->parallel));
}
}
}
pqxx::work t(conn, "trx");
- // fetch all songs
- pqxx::result res( t.exec("SELECT * FROM songs WHERE title LIKE 'M%'") );
- unsigned y = 0;
- for (pqxx::result::const_iterator i = res.begin(); i != res.end(); ++i) {
- my_draw_text(i["title"].as(widestring()), framebuf, 0, y, 1, 255, 255, 255);
- y += 20;
-// std::fprintf(stderr, "%s\n", i["title"].c_str());
+ if (screens[0]->check_invalidated()) {
+ screens[0]->draw(screenbuf);
}
- t.commit();
+
+ memcpy(framebuf, screenbuf, 800*600*4);
ptc_update(framebuf);
sleep(1);
#ifndef _GROUPSCREEN_H
#define _GROUPSCREEN_H 1
+#include <pqxx/connection>
+
+#include "screen.h"
#include "flagtrigger.h"
#include "group.h"
/* A screen class showing a group in the tournament */
-class GroupScreen : public Screen {
+class GroupScreen : public GenericScreen {
private:
- unsigned tournament;
+ unsigned tournament, round, parallel;
FlagTrigger scores_changed;
-
+ pqxx::connection &conn;
+ bool valid;
public:
- Screen(unsigned tournament);
+ GroupScreen(pqxx::connection &conn, unsigned tournament, unsigned round, unsigned parallel);
+ virtual ~GroupScreen();
bool check_invalidated();
void draw(unsigned char *buf);