]> git.sesse.net Git - ccbs/commitdiff
Clamp number of players shown to nine. Squeeze players a bit more together when we...
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 20 Feb 2005 19:53:20 +0000 (19:53 +0000)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 20 Feb 2005 19:53:20 +0000 (19:53 +0000)
bigscreen/groupscreen.cpp

index 2b541203aa9d3dd02f57255905f89cab82c44f38..6d38c4cca58e45102a459ddb982a749d24c2deae 100644 (file)
@@ -135,8 +135,11 @@ void GroupScreen::draw(unsigned char *buf)
        my_draw_text_deferred(td, "Rank", 12.0, x + width[num_scores + 2] / 2 - my_draw_text("Rank", NULL, 12.0) / 2, 100);
        
        // show all the players and the scores
        my_draw_text_deferred(td, "Rank", 12.0, x + width[num_scores + 2] / 2 - my_draw_text("Rank", NULL, 12.0) / 2, 100);
        
        // show all the players and the scores
-       unsigned y = 140;
-       for (std::vector<Player>::const_iterator i = group.players.begin(); i != group.players.end(); ++i) {
+       unsigned show_players = std::min(group.players.size(), 9U);
+       unsigned y = (show_players <= 7) ? 140 : (140 - (show_players - 7) * 5);
+       
+       unsigned row = 0;
+       for (std::vector<Player>::const_iterator i = group.players.begin(); i != group.players.end() && row < 9; ++i, ++row) {
                my_draw_text_deferred(td, i->nick, 18.0, 20, y);
 
                unsigned x = 40 + width[0];
                my_draw_text_deferred(td, i->nick, 18.0, 20, y);
 
                unsigned x = 40 + width[0];
@@ -174,7 +177,10 @@ void GroupScreen::draw(unsigned char *buf)
                        x += width[num_scores + 1] + 20;
                }
 
                        x += width[num_scores + 1] + 20;
                }
 
-               y += 40;
+               if (show_players > 7)
+                       y += 40 - (show_players - 7) * 4;
+               else 
+                       y += 40;
        }
        
        /*
        }
        
        /*
@@ -224,8 +230,8 @@ void GroupScreen::draw(unsigned char *buf)
        }
 
        // now finally find min and max rank, and draw it all
        }
 
        // now finally find min and max rank, and draw it all
-       y = 140;
-       for (unsigned i = 0; i < group.players.size(); ++i) {
+       y = (show_players <= 7) ? 140 : (140 - (show_players - 7) * 5);
+       for (unsigned i = 0; i < show_players; ++i) {
                unsigned best_rank = 1, worst_rank = 1;
                for (unsigned j = 0; j < group.players.size(); ++j) {
                        if (i == j)
                unsigned best_rank = 1, worst_rank = 1;
                for (unsigned j = 0; j < group.players.size(); ++j) {
                        if (i == j)
@@ -246,7 +252,10 @@ void GroupScreen::draw(unsigned char *buf)
                unsigned this_width = my_draw_text(text, NULL, 22.0);
                my_draw_text_deferred(td, text, 22.0, x + width[num_scores + 2] / 2 - this_width / 2, y);
 
                unsigned this_width = my_draw_text(text, NULL, 22.0);
                my_draw_text_deferred(td, text, 22.0, x + width[num_scores + 2] / 2 - this_width / 2, y);
 
-               y += 40;
+               if (show_players > 7)
+                       y += 40 - (show_players - 7) * 4;
+               else 
+                       y += 40;
        }
                
        /*
        }
                
        /*