Make screen hierarchy compile.
authorSteinar H. Gunderson <sesse@samfundet.no>
Sat, 19 Feb 2005 16:18:29 +0000 (16:18 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Sat, 19 Feb 2005 16:18:29 +0000 (16:18 +0000)
bigscreen/Makefile
bigscreen/ccbs_bigscreen.cpp
bigscreen/groupscreen.h
bigscreen/screen.cpp [new file with mode: 0644]
bigscreen/screen.h

index aca8243..b6697ab 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
-CCBS_BIGSCREEN_OBJS=ccbs_bigscreen.o flagtrigger.o widestring.o fetch_current_tournament.o fetch_list_of_active_groups.o fetch_group.o fonts.o
+CCBS_BIGSCREEN_OBJS=ccbs_bigscreen.o flagtrigger.o widestring.o fetch_current_tournament.o fetch_list_of_active_groups.o fetch_group.o fonts.o groupscreen.o screen.o
 
 all: ccbs-bigscreen
 
index f509912..aa94da2 100644 (file)
 #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));
 
@@ -29,9 +36,7 @@ void init(pqxx::connection &conn)
                        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));
                }
        }
 }
@@ -48,15 +53,11 @@ void main_loop(pqxx::connection &conn)
        
        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);
index c794f60..2d0e81b 100644 (file)
@@ -1,18 +1,23 @@
 #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);
diff --git a/bigscreen/screen.cpp b/bigscreen/screen.cpp
new file mode 100644 (file)
index 0000000..850ca94
--- /dev/null
@@ -0,0 +1,5 @@
+#include "screen.h"
+
+GenericScreen::GenericScreen() {}
+GenericScreen::~GenericScreen() {}
+
index 098a7f0..9b5d892 100644 (file)
@@ -1,9 +1,11 @@
 #ifndef _SCREEN_H
 #define _SCREEN_H 1
 
-class Screen {
+// arf, Screen conflicts with X11
+class GenericScreen {
 protected:
-       Screen();
+       GenericScreen();
+       virtual ~GenericScreen();
 
 public:
        virtual bool check_invalidated() = 0;