From: Steinar H. Gunderson Date: Tue, 1 Mar 2005 02:14:09 +0000 (+0000) Subject: Make a "logical resolution" (yuck!) of 800x600 for all the screens, and make fonts... X-Git-Url: https://git.sesse.net/?p=ccbs;a=commitdiff_plain;h=1f0419e8b9ad6225c901fdc9b272727547c08165;ds=sidebyside Make a "logical resolution" (yuck!) of 800x600 for all the screens, and make fonts.cpp compensate for that. --- diff --git a/bigscreen/fonts.cpp b/bigscreen/fonts.cpp index af9a936..aa61303 100644 --- a/bigscreen/fonts.cpp +++ b/bigscreen/fonts.cpp @@ -38,10 +38,14 @@ unsigned my_draw_text(const widestring &str, unsigned char *buf, double size, in int x = 0; for (std::vector::const_iterator i = fonts.begin(); i != fonts.end(); ++i) { - if (FT_Set_Char_Size(*i, 0, unsigned(size * 64.0), 96, 96)) + if (FT_Set_Char_Size(*i, 0, unsigned(size * 64.0), 96 * SCREEN_WIDTH/LOGICAL_SCREEN_WIDTH, 96 * SCREEN_HEIGHT/LOGICAL_SCREEN_HEIGHT)) throw std::runtime_error("Couldn't set font size"); } + // whoop :-P + xpos = xpos * SCREEN_WIDTH / LOGICAL_SCREEN_WIDTH; + ypos = ypos * SCREEN_HEIGHT / LOGICAL_SCREEN_HEIGHT; + for (widestring::const_iterator i = str.begin(); i != str.end(); ++i) { int glyph_index; for (std::vector::const_iterator j = fonts.begin(); j != fonts.end(); ++j) { @@ -87,7 +91,7 @@ unsigned my_draw_text(const widestring &str, unsigned char *buf, double size, in x += slot->advance.x >> 6; } - return x; + return x * LOGICAL_SCREEN_WIDTH / SCREEN_WIDTH; } void my_draw_text_deferred(std::vector &td, const widestring &str, double size, int xpos, int ypos) diff --git a/bigscreen/groupscreen.cpp b/bigscreen/groupscreen.cpp index 222db23..9d3b9e7 100644 --- a/bigscreen/groupscreen.cpp +++ b/bigscreen/groupscreen.cpp @@ -74,7 +74,7 @@ void GroupScreen::draw(unsigned char *buf) { unsigned width = my_draw_text(heading, NULL, 40.0); - my_draw_text_deferred(td, heading, 40.0, SCREEN_WIDTH/2 - width/2, 60); + my_draw_text_deferred(td, heading, 40.0, LOGICAL_SCREEN_WIDTH/2 - width/2, 60); } // Find out how wide each column has to be. First try unlimited width (ie. @@ -347,11 +347,11 @@ void GroupScreen::draw(unsigned char *buf) 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, (SCREEN_WIDTH/2) - this_width/2, 420); + my_draw_text(text, buf, 24.0, (LOGICAL_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, (SCREEN_WIDTH/2) - this_width/2, 457); + my_draw_text(next_song->song.title, buf, 20.0, (LOGICAL_SCREEN_WIDTH/2) - this_width/2, 457); Highscore hs; conn.perform(FetchHighscore(next_song->song.id, &hs)); @@ -360,7 +360,7 @@ void GroupScreen::draw(unsigned char *buf) 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, (SCREEN_WIDTH/2) - this_width/2, 487); + my_draw_text(text, buf, 16.0, (LOGICAL_SCREEN_WIDTH/2) - this_width/2, 487); } } @@ -457,7 +457,7 @@ void GroupScreen::draw(unsigned char *buf) 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, (SCREEN_WIDTH/2) - this_width/2, y); + my_draw_text(text, buf, 18.0, (LOGICAL_SCREEN_WIDTH/2) - this_width/2, y); y += 30; } @@ -470,7 +470,7 @@ void GroupScreen::draw(unsigned char *buf) 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, (SCREEN_WIDTH/2) - this_width/2, y); + my_draw_text(text, buf, 18.0, (LOGICAL_SCREEN_WIDTH/2) - this_width/2, y); y += 30; } @@ -489,7 +489,7 @@ void GroupScreen::draw(unsigned char *buf) } this_width = my_draw_text(text, NULL, 18.0); - my_draw_text(text, buf, 18.0, (SCREEN_WIDTH/2) - this_width/2, y); + my_draw_text(text, buf, 18.0, (LOGICAL_SCREEN_WIDTH/2) - this_width/2, y); y += 30; } diff --git a/bigscreen/resolution.h b/bigscreen/resolution.h index 0bbddf3..ba9472a 100644 --- a/bigscreen/resolution.h +++ b/bigscreen/resolution.h @@ -4,4 +4,12 @@ #define SCREEN_WIDTH 800 #define SCREEN_HEIGHT 600 +/* + * This is used in the screens, mostly for historical reasons (they were + * first hard-coded to 800x600, and changing them to be resolution-independent + * is not a project for today). + */ +#define LOGICAL_SCREEN_WIDTH 800 +#define LOGICAL_SCREEN_HEIGHT 600 + #endif /* !defined(_RESOLUTION_H) */ diff --git a/bigscreen/top10scorescreen.cpp b/bigscreen/top10scorescreen.cpp index d4453d8..66306b4 100644 --- a/bigscreen/top10scorescreen.cpp +++ b/bigscreen/top10scorescreen.cpp @@ -45,7 +45,7 @@ void Top10ScoreScreen::draw(unsigned char *buf) { unsigned width = my_draw_text("Today's top 10 scores", NULL, 40.0); - my_draw_text("Today's top 10 scores", buf, 40.0, SCREEN_WIDTH/2 - width/2, 60); + my_draw_text("Today's top 10 scores", buf, 40.0, LOGICAL_SCREEN_WIDTH/2 - width/2, 60); } // simple headings diff --git a/bigscreen/top5chosenscreen.cpp b/bigscreen/top5chosenscreen.cpp index 321005c..84b54ea 100644 --- a/bigscreen/top5chosenscreen.cpp +++ b/bigscreen/top5chosenscreen.cpp @@ -45,7 +45,7 @@ void Top5ChosenScreen::draw(unsigned char *buf) { 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, SCREEN_WIDTH/2 - width/2, 60); + my_draw_text("Today's top 5 chosen songs", buf, 40.0, LOGICAL_SCREEN_WIDTH/2 - width/2, 60); } // simple headings