From: Steinar H. Gunderson Date: Mon, 28 Feb 2005 21:05:33 +0000 (+0000) Subject: Add the framework for a top 10 screen. X-Git-Url: https://git.sesse.net/?p=ccbs;a=commitdiff_plain;h=5a591d5e5db52bb78fd794342f090c7db66211dd Add the framework for a top 10 screen. --- diff --git a/bigscreen/Makefile b/bigscreen/Makefile index 2621456..6258a6b 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 -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 diff --git a/bigscreen/ccbs_bigscreen.cpp b/bigscreen/ccbs_bigscreen.cpp index 8180724..5c91b9e 100644 --- a/bigscreen/ccbs_bigscreen.cpp +++ b/bigscreen/ccbs_bigscreen.cpp @@ -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::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 index 0000000..58db329 --- /dev/null +++ b/bigscreen/top10scorescreen.cpp @@ -0,0 +1,36 @@ +#include + +#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 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 index 0000000..9e8f3c0 --- /dev/null +++ b/bigscreen/top10scorescreen.h @@ -0,0 +1,30 @@ +#ifndef _TOP10SCORESCREEN_H +#define _TOP10SCORESCREEN_H 1 + +#include +#include +#include +#include + +#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 last_text; + +public: + Top10ScoreScreen(pqxx::connection &conn, unsigned tournament); + virtual ~Top10ScoreScreen(); + + bool check_invalidated(); + void draw(unsigned char *buf); +}; + +#endif /* !defined(_TOP10SCORESCREEN_H) */