Add the framework for a top 10 screen.
authorSteinar H. Gunderson <sesse@samfundet.no>
Mon, 28 Feb 2005 21:05:33 +0000 (21:05 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Mon, 28 Feb 2005 21:05:33 +0000 (21:05 +0000)
bigscreen/Makefile
bigscreen/ccbs_bigscreen.cpp
bigscreen/top10scorescreen.cpp [new file with mode: 0644]
bigscreen/top10scorescreen.h [new file with mode: 0644]

index 2621456..6258a6b 100644 (file)
@@ -4,7 +4,7 @@ CPPFLAGS=-I/usr/include/postgresql $(shell freetype-config --cflags) -Itinyptc/
 CXXFLAGS=-g -Wall
 LDFLAGS=-L/usr/X11R6/lib
 LIBS=$(shell freetype-config --libs) $(shell libpq3-config) -lpqxx tinyptc/libtinyptc.a -lX11 -lXext
-CCBS_BIGSCREEN_OBJS=ccbs_bigscreen.o flagtrigger.o widestring.o fetch_current_tournament.o fetch_list_of_active_groups.o fetch_max_score_for_songs.o fetch_max_score_for_players.o fetch_group.o fetch_needs_update.o fetch_highscore.o fetch_auxilliary_screens.o fonts.o groupscreen.o splitscreen.o rotatescreen.o screen.o
+CCBS_BIGSCREEN_OBJS=ccbs_bigscreen.o flagtrigger.o widestring.o fetch_current_tournament.o fetch_list_of_active_groups.o fetch_max_score_for_songs.o fetch_max_score_for_players.o fetch_group.o fetch_needs_update.o fetch_highscore.o fetch_auxilliary_screens.o fonts.o groupscreen.o top10scorescreen.o splitscreen.o rotatescreen.o screen.o
 
 all: ccbs-bigscreen
 
index 8180724..5c91b9e 100644 (file)
@@ -12,6 +12,7 @@
 #include "fetch_auxilliary_screens.h"
 #include "fonts.h"
 #include "groupscreen.h"
+#include "top10scorescreen.h"
 #include "splitscreen.h"
 #include "rotatescreen.h"
 
@@ -56,7 +57,11 @@ void init(pqxx::connection &conn)
 
        conn.perform(FetchAuxilliaryScreens(&aux_screens));
        for (std::vector<widestring>::const_iterator i = aux_screens.begin(); i != aux_screens.end(); ++i) {
-//             std::fprintf(stderr, "Auxilliary screen '%s'\n", i->c_str());
+               if (*i == widestring("top10scores")) {
+                       screens.push_back(new Top10ScoreScreen(conn, active_tournament.id));
+                       continue;
+               }
+               std::fprintf(stderr, "Foobarbaz?\n");
        }
        
        // hack
diff --git a/bigscreen/top10scorescreen.cpp b/bigscreen/top10scorescreen.cpp
new file mode 100644 (file)
index 0000000..58db329
--- /dev/null
@@ -0,0 +1,36 @@
+#include <cstdio>
+
+#include "top10scorescreen.h"
+
+Top10ScoreScreen::Top10ScoreScreen(pqxx::connection &conn, unsigned tournament)
+       : conn(conn), tournament(tournament), scores_changed(conn, "scores"), valid(false)
+{
+}
+
+Top10ScoreScreen::~Top10ScoreScreen()
+{
+}
+
+bool Top10ScoreScreen::check_invalidated()
+{
+       if (!valid)
+               return true;
+       if (!scores_changed.get_flag())
+               return false;
+
+       return true;
+}
+
+void Top10ScoreScreen::draw(unsigned char *buf)
+{
+       std::vector<TextDefer> td;
+       scores_changed.reset_flag();
+       memset(buf, 0, 800 * 600 * 4);
+
+       std::fprintf(stderr, "foo bar\n");
+       
+       valid = true;
+       draw_all_deferred_text(buf, td, last_text);
+       last_text = td;
+}
+
diff --git a/bigscreen/top10scorescreen.h b/bigscreen/top10scorescreen.h
new file mode 100644 (file)
index 0000000..9e8f3c0
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef _TOP10SCORESCREEN_H
+#define _TOP10SCORESCREEN_H 1
+
+#include <vector>
+#include <pqxx/connection>
+#include <time.h>
+#include <sys/time.h>
+
+#include "screen.h"
+#include "flagtrigger.h"
+#include "fonts.h"
+
+/* A screen class showing a group in the tournament */
+class Top10ScoreScreen : public GenericScreen {
+private:
+       pqxx::connection &conn;
+       unsigned tournament;
+       FlagTrigger scores_changed;
+       bool valid;
+       std::vector<TextDefer> last_text;
+       
+public:
+       Top10ScoreScreen(pqxx::connection &conn, unsigned tournament);
+       virtual ~Top10ScoreScreen();
+
+       bool check_invalidated();
+       void draw(unsigned char *buf);
+};
+
+#endif /* !defined(_TOP10SCORESCREEN_H) */