]> git.sesse.net Git - ccbs/commitdiff
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 aca82435744f11cee59cff18b48a0daec02ff992..b6697abcc51d45990516a7804026f919f25649ae 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
 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
 
 
 all: ccbs-bigscreen
 
index f50991212b4257bc323c01b3413b81f98ea2992f..aa94da2913d1d2508a446485262724de3b795eb0 100644 (file)
 #include "fetch_list_of_active_groups.h"
 #include "fetch_group.h"
 #include "fonts.h"
 #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;
 
 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)
 {
 
 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));
 
        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);
 
                        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");
 
        
        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);
 
        ptc_update(framebuf);
        sleep(1);
index c794f60465904d2070c2976f9b9fba95130379ae..2d0e81b608c68cc686208a26a912734bdf062fac 100644 (file)
@@ -1,18 +1,23 @@
 #ifndef _GROUPSCREEN_H
 #define _GROUPSCREEN_H 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 */
 #include "flagtrigger.h"
 #include "group.h"
 
 /* A screen class showing a group in the tournament */
-class GroupScreen : public Screen {
+class GroupScreen : public GenericScreen {
 private:
 private:
-       unsigned tournament;
+       unsigned tournament, round, parallel;
        FlagTrigger scores_changed;
        FlagTrigger scores_changed;
-       
+       pqxx::connection &conn;
+       bool valid;
 
 public:
 
 public:
-       Screen(unsigned tournament);
+       GroupScreen(pqxx::connection &conn, unsigned tournament, unsigned round, unsigned parallel);
+       virtual ~GroupScreen();
 
        bool check_invalidated();
        void draw(unsigned char *buf);
 
        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 098a7f08e7a2e93042dd75f1acd0d4a424952070..9b5d892c5606e817d4cac06a4f6cd934a8aa2f08 100644 (file)
@@ -1,9 +1,11 @@
 #ifndef _SCREEN_H
 #define _SCREEN_H 1
 
 #ifndef _SCREEN_H
 #define _SCREEN_H 1
 
-class Screen {
+// arf, Screen conflicts with X11
+class GenericScreen {
 protected:
 protected:
-       Screen();
+       GenericScreen();
+       virtual ~GenericScreen();
 
 public:
        virtual bool check_invalidated() = 0;
 
 public:
        virtual bool check_invalidated() = 0;