X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=bigscreen%2Fgroupscreen.cpp;h=96afeecb3363cd47ac8bec5a210e5064b163f562;hb=095c175c9d289b584cf4cb6d337fd9c491c0a887;hp=2b4aa7d7369160b42ec0275c616451eb4caefb89;hpb=98628c92a0eaca1fdbcd4a35b60b7fb78616c82a;p=ccbs diff --git a/bigscreen/groupscreen.cpp b/bigscreen/groupscreen.cpp index 2b4aa7d..96afeec 100644 --- a/bigscreen/groupscreen.cpp +++ b/bigscreen/groupscreen.cpp @@ -6,6 +6,7 @@ #include "fetch_max_score_for_song.h" #include "fetch_max_score_for_player.h" #include "fetch_needs_update.h" +#include "fetch_highscore.h" #include "fonts.h" GroupScreen::GroupScreen(pqxx::connection &conn, unsigned tournament, unsigned round, unsigned parallel) @@ -63,8 +64,8 @@ void GroupScreen::draw(unsigned char *buf) // titles for chosen songs. unsigned width[16], num_scores; unsigned max_num_width = my_draw_text("8888", NULL, 22.0); - unsigned mode, sumwidth; - for (mode = 0; mode < 2; ++mode) { + unsigned sumwidth; + for (unsigned mode = 0; mode < 2; ++mode) { for (unsigned i = 0; i < 16; ++i) width[i] = 0; @@ -151,7 +152,13 @@ void GroupScreen::draw(unsigned char *buf) unsigned this_width = my_draw_text(text, NULL, 22.0); if (j->chosen) { my_draw_text_deferred(td, text, 22.0, x + max_num_width - this_width, y); - my_draw_text_deferred(td, (mode == 0) ? j->song.title : j->song.short_title, 12.0, x + max_num_width + 10, y); + + // draw the long name if we can, otherwise use the short one + if (my_draw_text(j->song.title, NULL, 12.0) > width[col]) { + my_draw_text_deferred(td, j->song.short_title, 12.0, x + max_num_width + 10, y); + } else { + my_draw_text_deferred(td, j->song.title, 12.0, x + max_num_width + 10, y); + } } else { my_draw_text_deferred(td, text, 22.0, x + width[col] / 2 - this_width / 2, y); } @@ -314,11 +321,15 @@ void GroupScreen::draw(unsigned char *buf) 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); - // fetch the high score later - text = widestring("High score: ") + widestring(pqxx::to_string(1234)) + - widestring(", by dufF in Challenge Cup 1, 2004"); - this_width = my_draw_text(text, NULL, 16.0); - my_draw_text(text, buf, 16.0, 400 - this_width/2, 487); + Highscore hs; + conn.perform(FetchHighscore(next_song->song.id, &hs)); + + if (hs.score != -1) { + 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); + } } // only show lead/win/qualify for the last song