#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)
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, 450);
+ my_draw_text(text, buf, 24.0, 400 - 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, 487);
+ 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, 517);
+ 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
conn.perform(FetchMaxScoreForPlayer(tournament, next_player->id, round, &max_score_this_song));
}
- unsigned y = 540;
+ unsigned y = 520;
// see what score this player must beat to lead
unsigned lead_beat = 0, win_beat = 0;
y += 30;
}
- if (next_player->total + max_score_this_song > qualify_beat_worst_case) {
+ if (next_player->total + max_score_this_song > qualify_beat_worst_case && (qualify_beat_worst_case != win_beat)) {
int qual_need = std::max(qualify_beat_worst_case - next_player->total + 1, 0U);
if (qualify_beat_worst_case == qualify_beat_best_case) {