]> git.sesse.net Git - ccbs/commitdiff
Try to make the column for the chosen songs as fixed-width as possible.
authorSteinar H. Gunderson <sesse@samfundet.no>
Sun, 20 Feb 2005 15:29:01 +0000 (15:29 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Sun, 20 Feb 2005 15:29:01 +0000 (15:29 +0000)
bigscreen/groupscreen.cpp

index 3628447512372f1c0b776c8c3bc69e1dea58a8b2..64bf7b9f44986072bf806a896dd3e5bfe00092ce 100644 (file)
@@ -63,7 +63,7 @@ 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;
+       unsigned mode, sumwidth;
        for (mode = 0; mode < 2; ++mode) {
                for (unsigned i = 0; i < 16; ++i)
                        width[i] = 0;
@@ -89,13 +89,33 @@ void GroupScreen::draw(unsigned char *buf)
                width[num_scores + 2] = my_draw_text("Rank", NULL, 12.0);
 
                // if we're at long titles and that works, don't try the short ones
-               if (mode == 0) {
-                       unsigned sumwidth = 0;
-                       for (unsigned i = 0; i <= num_scores + 2; ++i)
-                               sumwidth += width[i] + 20;
+               sumwidth = 0;
                        
-                       if (sumwidth < 800)
+               for (unsigned i = 0; i <= num_scores + 2; ++i)
+                       sumwidth += width[i] + 20;
+                       
+               if (sumwidth < 780)
+                       break;
+       }
+
+       /* 
+        * If we have space to go, distribute as much as we can to the chosen song column, so we won't have
+        * total and rank jumping around.
+        */
+       if (sumwidth < 780) {
+               int first_chosen_col = -1;
+               unsigned col = 1;
+
+               for (std::vector<Score>::const_iterator i = group.players[0].scores.begin(); i != group.players[0].scores.end(); ++i, ++col) {
+                       if (i->chosen) {
+                               first_chosen_col = col;
                                break;
+                       }
+               }
+
+               if (first_chosen_col != -1) {
+                       printf("first_chosen_col=%u\n", first_chosen_col);
+                       width[first_chosen_col] += 780 - sumwidth;
                }
        }