From 22ef1e003f53437829039885c5aedf20a22423d9 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 19 Feb 2005 16:18:29 +0000 Subject: [PATCH] Make screen hierarchy compile. --- bigscreen/Makefile | 2 +- bigscreen/ccbs_bigscreen.cpp | 25 +++++++++++++------------ bigscreen/groupscreen.h | 13 +++++++++---- bigscreen/screen.cpp | 5 +++++ bigscreen/screen.h | 6 ++++-- 5 files changed, 32 insertions(+), 19 deletions(-) create mode 100644 bigscreen/screen.cpp diff --git a/bigscreen/Makefile b/bigscreen/Makefile index aca8243..b6697ab 100644 --- a/bigscreen/Makefile +++ b/bigscreen/Makefile @@ -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 diff --git a/bigscreen/ccbs_bigscreen.cpp b/bigscreen/ccbs_bigscreen.cpp index f509912..aa94da2 100644 --- a/bigscreen/ccbs_bigscreen.cpp +++ b/bigscreen/ccbs_bigscreen.cpp @@ -10,13 +10,20 @@ #include "fetch_list_of_active_groups.h" #include "fetch_group.h" #include "fonts.h" +#include "groupscreen.h" Tournament active_tournament; std::vector active_groups; -unsigned char framebuf[800 * 600 * 4]; +std::vector screens; +unsigned char framebuf[800 * 600 * 4], screenbuf[800 * 600 * 4]; void init(pqxx::connection &conn) { + for (std::vector::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); diff --git a/bigscreen/groupscreen.h b/bigscreen/groupscreen.h index c794f60..2d0e81b 100644 --- a/bigscreen/groupscreen.h +++ b/bigscreen/groupscreen.h @@ -1,18 +1,23 @@ #ifndef _GROUPSCREEN_H #define _GROUPSCREEN_H 1 +#include + +#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 index 0000000..850ca94 --- /dev/null +++ b/bigscreen/screen.cpp @@ -0,0 +1,5 @@ +#include "screen.h" + +GenericScreen::GenericScreen() {} +GenericScreen::~GenericScreen() {} + diff --git a/bigscreen/screen.h b/bigscreen/screen.h index 098a7f0..9b5d892 100644 --- a/bigscreen/screen.h +++ b/bigscreen/screen.h @@ -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; -- 2.39.2