std::vector<SkeletonGroup> active_groups;
std::vector<GenericScreen *> screens;
GenericScreen *mainscreen = NULL;
-unsigned char framebuf[800 * 600 * 4], screenbuf[800 * 600 * 4];
+unsigned char framebuf[SCREEN_WIDTH * SCREEN_HEIGHT * 4], screenbuf[SCREEN_WIDTH * SCREEN_HEIGHT * 4];
void init(pqxx::connection &conn)
{
}
}
- RotateScreen *aux_screen = new RotateScreen();
- screens.push_back(aux_screen);
-
- conn.perform(FetchAuxilliaryScreens(&aux_screens));
- for (std::vector<widestring>::const_iterator i = aux_screens.begin(); i != aux_screens.end(); ++i) {
- if (*i == widestring("top10scores")) {
- aux_screen->add_screen(new Top10ScoreScreen(conn, active_tournament.id));
- continue;
- }
- if (*i == widestring("top5chosen")) {
- aux_screen->add_screen(new Top5ChosenScreen(conn, active_tournament.id));
- continue;
+ // show auxilliary screens if we have zero, two or three other screens going
+ if (screens.size() < 4 && screens.size() != 1) {
+ RotateScreen *aux_screen = new RotateScreen();
+ screens.push_back(aux_screen);
+
+ conn.perform(FetchAuxilliaryScreens(&aux_screens));
+ for (std::vector<widestring>::const_iterator i = aux_screens.begin(); i != aux_screens.end(); ++i) {
+ if (*i == widestring("top10scores")) {
+ aux_screen->add_screen(new Top10ScoreScreen(conn, active_tournament.id));
+ continue;
+ }
+ if (*i == widestring("top5chosen")) {
+ aux_screen->add_screen(new Top5ChosenScreen(conn, active_tournament.id));
+ continue;
+ }
+ std::fprintf(stderr, "Foobarbaz?\n");
}
- std::fprintf(stderr, "Foobarbaz?\n");
- }
- // add all finished screens to the auxilliary screens
- std::vector<SkeletonGroup> finished_groups;
- conn.perform(FetchListOfFinishedGroups(active_tournament.id, &finished_groups));
-
- for (std::vector<SkeletonGroup>::const_iterator i = finished_groups.begin(); i != finished_groups.end(); ++i) {
- aux_screen->add_screen(new GroupScreen(conn, i->tournament, i->round, i->parallel, 0, 1));
+ /*
+ * If we still have room, make yet another rotational screen with
+ * results from previous groups -- otherwise tack them onto the end
+ * of the auxilliary screens.
+ */
+ RotateScreen *finished_groups_screen = aux_screen;
+ if (screens.size() < 4 && screens.size() != 1) {
+ finished_groups_screen = new RotateScreen();
+ screens.push_back(finished_groups_screen);
+ }
+
+ std::vector<SkeletonGroup> finished_groups;
+ conn.perform(FetchListOfFinishedGroups(active_tournament.id, &finished_groups));
+
+ for (std::vector<SkeletonGroup>::const_iterator i = finished_groups.begin(); i != finished_groups.end(); ++i) {
+ finished_groups_screen->add_screen(new GroupScreen(conn, i->tournament, i->round, i->parallel, 0, 1));
+ }
}
// hack
int main(int argc, char **argv)
{
- ptc_open("CCBS bigscreen", 800, 600);
+ ptc_open("CCBS bigscreen", SCREEN_WIDTH, SCREEN_HEIGHT);
try {
init_freetype();
#include <vector>
#include <stdexcept>
#include "fonts.h"
+#include "resolution.h"
std::vector<FT_Face> fonts;
for (y = 0; y < bm->rows; y++) {
int xx;
int dsty = ypos - slot->bitmap_top + y;
- if (dsty < 0 || dsty > 599) continue;
+ if (dsty < 0 || dsty > (SCREEN_HEIGHT-1)) continue;
- unsigned char *dst = buf + dsty * 800*4 + (x + xpos + slot->bitmap_left)*4;
+ unsigned char *dst = buf + dsty * SCREEN_WIDTH*4 + (x + xpos + slot->bitmap_left)*4;
unsigned char *src = bm->buffer + y * bm->width;
- int width = (x + xpos + slot->bitmap_left + bm->width >= 800) ? (799 - x - xpos - slot->bitmap_left) : bm->width;
+ int width = (x + xpos + slot->bitmap_left + bm->width >= SCREEN_WIDTH) ? ((SCREEN_WIDTH-1) - x - xpos - slot->bitmap_left) : bm->width;
for (xx = 0; xx < width; xx++) {
*dst = (*dst * (256-*src) + b * *src) >> 8;
*dst++;
#include <algorithm>
#include <map>
+#include "resolution.h"
#include "groupscreen.h"
#include "fetch_group.h"
#include "fetch_max_score_for_songs.h"
conn.perform(FetchGroup(tournament, round, parallel, &group));
gettimeofday(&last_updated, NULL);
- memset(buf, 0, 800 * 600 * 4);
+ memset(buf, 0, SCREEN_WIDTH * SCREEN_HEIGHT * 4);
// main heading
char heading[64];
{
unsigned width = my_draw_text(heading, NULL, 40.0);
- my_draw_text_deferred(td, heading, 40.0, 800/2 - width/2, 60);
+ my_draw_text_deferred(td, heading, 40.0, SCREEN_WIDTH/2 - width/2, 60);
}
// Find out how wide each column has to be. First try unlimited width (ie.
if (next_song != NULL) {
widestring text = widestring("Next player: ") + next_player->nick;
unsigned this_width = my_draw_text(text, NULL, 24.0);
- my_draw_text(text, buf, 24.0, 400 - this_width/2, 420);
+ my_draw_text(text, buf, 24.0, (SCREEN_WIDTH/2) - this_width/2, 420);
if (next_song->song.id != -1) {
this_width = my_draw_text(next_song->song.title, NULL, 20.0);
- my_draw_text(next_song->song.title, buf, 20.0, 400 - this_width/2, 457);
+ my_draw_text(next_song->song.title, buf, 20.0, (SCREEN_WIDTH/2) - this_width/2, 457);
Highscore hs;
conn.perform(FetchHighscore(next_song->song.id, &hs));
text = widestring("High score: ") + widestring(pqxx::to_string(hs.score)) +
widestring(", by ") + hs.nick + widestring(" in ") + hs.tournament_name;
this_width = my_draw_text(text, NULL, 16.0);
- my_draw_text(text, buf, 16.0, 400 - this_width/2, 487);
+ my_draw_text(text, buf, 16.0, (SCREEN_WIDTH/2) - this_width/2, 487);
}
}
if (lead_need > 0) {
text = widestring("Needs to lead: ") + widestring(pqxx::to_string(lead_need));
this_width = my_draw_text(text, NULL, 18.0);
- my_draw_text(text, buf, 18.0, 400 - this_width/2, y);
+ my_draw_text(text, buf, 18.0, (SCREEN_WIDTH/2) - this_width/2, y);
y += 30;
}
text = widestring("Needs to win: ") + widestring(pqxx::to_string(win_need));
this_width = my_draw_text(text, NULL, 18.0);
- my_draw_text(text, buf, 18.0, 400 - this_width/2, y);
+ my_draw_text(text, buf, 18.0, (SCREEN_WIDTH/2) - this_width/2, y);
y += 30;
}
}
this_width = my_draw_text(text, NULL, 18.0);
- my_draw_text(text, buf, 18.0, 400 - this_width/2, y);
+ my_draw_text(text, buf, 18.0, (SCREEN_WIDTH/2) - this_width/2, y);
y += 30;
}
--- /dev/null
+#ifndef _RESOLUTION_H
+#define _RESOLUTION_H 1
+
+#define SCREEN_WIDTH 800
+#define SCREEN_HEIGHT 600
+
+#endif /* !defined(_RESOLUTION_H) */
RotateScreen::RotateScreen()
: valid(false), current_screen(0), in_fade(false)
{
- fadefrom_buf = new unsigned char[800 * 600 * 4];
+ fadefrom_buf = new unsigned char[SCREEN_WIDTH * SCREEN_HEIGHT * 4];
}
RotateScreen::~RotateScreen()
// ugly hack here? :-)
subscreens[current_screen].screen->draw(subscreens[current_screen].buf);
- memcpy(buf, subscreens[current_screen].buf, 800 * 600 * 4);
+ memcpy(buf, subscreens[current_screen].buf, SCREEN_WIDTH * SCREEN_HEIGHT * 4);
} else {
// find the fade factors
int fr, fg, fb, fa;
if (fade_to_new_info && elapsed_fade >= 0.5) {
// fade G&B to be = R
- for (unsigned i = 0; i < 800 * 600; ++i) {
+ for (unsigned i = 0; i < SCREEN_WIDTH * SCREEN_HEIGHT; ++i) {
dptr[0] = sptr2[0] + (((int(sptr2[2]) - int(sptr2[0])) * fb) >> 8);
dptr[1] = sptr2[1] + (((int(sptr2[2]) - int(sptr2[1])) * fg) >> 8);
dptr[2] = sptr2[2];
sptr1 += 4, sptr2 += 4, dptr += 4;
}
} else {
- for (unsigned i = 0; i < 800 * 600; ++i) {
+ for (unsigned i = 0; i < SCREEN_WIDTH * SCREEN_HEIGHT; ++i) {
dptr[0] = sptr1[0] + (((int(sptr2[0]) - int(sptr1[0])) * fb) >> 8);
dptr[1] = sptr1[1] + (((int(sptr2[1]) - int(sptr1[1])) * fg) >> 8);
dptr[2] = sptr1[2] + (((int(sptr2[2]) - int(sptr1[2])) * fr) >> 8);
fade_found_start_time = false;
fade_to_new_info = force;
- memcpy(fadefrom_buf, subscreens[old_current_screen].buf, 800 * 600 * 4);
+ memcpy(fadefrom_buf, subscreens[old_current_screen].buf, SCREEN_WIDTH * SCREEN_HEIGHT * 4);
if (subscreens[current_screen].screen->check_invalidated())
subscreens[current_screen].screen->draw(subscreens[current_screen].buf);
void RotateScreen::add_screen(GenericScreen *screen)
{
Subscreen ss;
- ss.buf = new unsigned char[800 * 600 * 4];
+ ss.buf = new unsigned char[SCREEN_WIDTH * SCREEN_HEIGHT * 4];
ss.screen = screen;
screen->draw(ss.buf);
#ifndef _SCREEN_H
#define _SCREEN_H 1
+#include "resolution.h"
+
// arf, Screen conflicts with X11
class GenericScreen {
protected:
subscreens[2] = s3;
subscreens[3] = s4;
- memset(subbufs[0], 0, 800*600*4);
- memset(subbufs[1], 0, 800*600*4);
- memset(subbufs[2], 0, 800*600*4);
- memset(subbufs[3], 0, 800*600*4);
+ memset(subbufs[0], 0, SCREEN_WIDTH*SCREEN_HEIGHT*4);
+ memset(subbufs[1], 0, SCREEN_WIDTH*SCREEN_HEIGHT*4);
+ memset(subbufs[2], 0, SCREEN_WIDTH*SCREEN_HEIGHT*4);
+ memset(subbufs[3], 0, SCREEN_WIDTH*SCREEN_HEIGHT*4);
}
SplitScreen::~SplitScreen()
}
downscale_2x2(buf, subbufs[0]);
- downscale_2x2(buf + 400 * 4, subbufs[1]);
- downscale_2x2(buf + 800 * 300 * 4, subbufs[2]);
- downscale_2x2(buf + 800 * 300 * 4 + 400 * 4, subbufs[3]);
+ downscale_2x2(buf + (SCREEN_WIDTH/2) * 4, subbufs[1]);
+ downscale_2x2(buf + SCREEN_WIDTH * (SCREEN_HEIGHT/2) * 4, subbufs[2]);
+ downscale_2x2(buf + SCREEN_WIDTH * (SCREEN_HEIGHT/2) * 4 + (SCREEN_WIDTH/2) * 4, subbufs[3]);
// make divider lines
- unsigned char *ptr = buf + 300 * 800 * 4;
- for (unsigned x = 0; x < 800; ++x) {
+ unsigned char *ptr = buf + (SCREEN_HEIGHT/2) * SCREEN_WIDTH * 4;
+ for (unsigned x = 0; x < SCREEN_WIDTH; ++x) {
*ptr++ = 255;
*ptr++ = 255;
*ptr++ = 255;
*ptr++ = 0;
}
- ptr = buf + 400 * 4;
- for (unsigned y = 0; y < 600; ++y) {
+ ptr = buf + (SCREEN_WIDTH/2) * 4;
+ for (unsigned y = 0; y < SCREEN_HEIGHT; ++y) {
ptr[0] = 255;
ptr[1] = 255;
ptr[2] = 255;
ptr[3] = 0;
- ptr += 800 * 4;
+ ptr += SCREEN_WIDTH * 4;
}
valid = true;
// simple box filter (blah)
void SplitScreen::downscale_2x2(unsigned char *dst, unsigned char *src)
{
- for (unsigned y = 0; y < 300; ++y) {
- unsigned char *sptr1 = src + (y*2) * 800 * 4;
- unsigned char *sptr2 = src + (y*2+1) * 800 * 4;
- unsigned char *dptr = dst + y * 800 * 4;
+ for (unsigned y = 0; y < (SCREEN_HEIGHT/2); ++y) {
+ unsigned char *sptr1 = src + (y*2) * SCREEN_WIDTH * 4;
+ unsigned char *sptr2 = src + (y*2+1) * SCREEN_WIDTH * 4;
+ unsigned char *dptr = dst + y * SCREEN_WIDTH * 4;
- for (unsigned x = 0; x < 400; ++x) {
+ for (unsigned x = 0; x < (SCREEN_WIDTH/2); ++x) {
*dptr++ = (sptr1[0] + sptr1[4] + sptr2[0] + sptr2[4]) >> 2; // red
*dptr++ = (sptr1[1] + sptr1[5] + sptr2[1] + sptr2[5]) >> 2; // green
*dptr++ = (sptr1[2] + sptr1[6] + sptr2[2] + sptr2[6]) >> 2; // blue
/* A 4x4 split class */
class SplitScreen : public GenericScreen {
private:
- unsigned char subbufs[4][800 * 600 * 4];
+ unsigned char subbufs[4][SCREEN_WIDTH * SCREEN_HEIGHT * 4];
GenericScreen *subscreens[4];
bool valid;
#include <cstdio>
#include <algorithm>
+#include "resolution.h"
#include "top10scorescreen.h"
#include "fonts.h"
void Top10ScoreScreen::draw(unsigned char *buf)
{
scores_changed.reset_flag();
- memset(buf, 0, 800 * 600 * 4);
+ memset(buf, 0, SCREEN_WIDTH * SCREEN_HEIGHT * 4);
// fetch the top 10 scores
std::vector<TopScore> scores;
{
unsigned width = my_draw_text("Today's top 10 scores", NULL, 40.0);
- my_draw_text("Today's top 10 scores", buf, 40.0, 800/2 - width/2, 60);
+ my_draw_text("Today's top 10 scores", buf, 40.0, SCREEN_WIDTH/2 - width/2, 60);
}
// simple headings
#include <cstdio>
#include <algorithm>
+#include "resolution.h"
#include "top5chosenscreen.h"
#include "fonts.h"
void Top5ChosenScreen::draw(unsigned char *buf)
{
scores_changed.reset_flag();
- memset(buf, 0, 800 * 600 * 4);
+ memset(buf, 0, SCREEN_WIDTH * SCREEN_HEIGHT * 4);
// fetch the top 5 chosen songs
std::vector<TopChosen> scores;
{
unsigned width = my_draw_text("Today's top 5 chosen songs", NULL, 40.0);
- my_draw_text("Today's top 5 chosen songs", buf, 40.0, 800/2 - width/2, 60);
+ my_draw_text("Today's top 5 chosen songs", buf, 40.0, SCREEN_WIDTH/2 - width/2, 60);
}
// simple headings