[Super-tux-commit] supertux/src title.cpp,1.51,1.52
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-04-20 11:43:51
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5891/src Modified Files: title.cpp Log Message: Recoded credits code, in order to respect fonts height. (if you think there should be more space between items, just change ITEMS_SPACE). Also fixed a mistake that was making SDL_QUIT signal to never be used. Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.51 retrieving revision 1.52 diff -u -d -r1.51 -r1.52 --- title.cpp 20 Apr 2004 11:21:53 -0000 1.51 +++ title.cpp 20 Apr 2004 11:43:43 -0000 1.52 @@ -58,7 +58,7 @@ static bool walking; static Timer random_timer; -static int frame, i; +static int frame; static unsigned int last_update_time; static unsigned int update_time; @@ -265,12 +265,9 @@ { Menu::current()->event(event); } - else - { - // FIXME: QUIT signal should be handled more generic, not locally - if (event.type == SDL_QUIT) - Menu::set_current(0); - } + // FIXME: QUIT signal should be handled more generic, not locally + if (event.type == SDL_QUIT) + Menu::set_current(0); } /* Draw the background: */ @@ -367,13 +364,14 @@ #define MAX_VEL 10 #define SPEED 1 #define SCROLL 60 +#define ITEMS_SPACE 4 void display_credits() { int done; int scroll, speed; + int y; Timer timer; - int n,d; int length; FILE* fi; char temp[1024]; @@ -406,8 +404,6 @@ speed = 2; done = 0; - n = d = 0; - length = names.num_items; SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); @@ -458,26 +454,33 @@ white_big_text->drawf("- Credits -", 0, screen->h-scroll, A_HMIDDLE, A_TOP, 2); - for(i = 0, n = 0, d = 0; i < length; i++,n++,d++) + y = 0; + for(int i = 0; i < length; i++) { - if(names.item[i] == "") - n--; - else - { - if(names.item[i][0] == ' ') - white_small_text->drawf(names.item[i], 0, 60+screen->h+(n*18)+(d*18)-scroll-10, A_HMIDDLE, A_TOP, 1); - else if(names.item[i][0] == ' ') - white_text->drawf(names.item[i], 0, 60+screen->h+(n*18)+(d*18)-scroll, A_HMIDDLE, A_TOP, 1); - else if(names.item[i+1][0] == '-' || names.item[i][0] == '-') - white_big_text->drawf(names.item[i], 0, 60+screen->h+(n*18)+(d*18)-scroll, A_HMIDDLE, A_TOP, 3); - else - blue_text->drawf(names.item[i], 0, 60+screen->h+(n*18)+(d*18)-scroll, A_HMIDDLE, A_TOP, 1); - } + switch(names.item[i][0]) + { + case ' ': + white_small_text->drawf(names.item[i], 0, 60+screen->h+y-scroll, A_HMIDDLE, A_TOP, 1); + y += white_small_text->h+ITEMS_SPACE; + break; + case ' ': + white_text->drawf(names.item[i], 0, 60+screen->h+y-scroll, A_HMIDDLE, A_TOP, 1); + y += white_text->h+ITEMS_SPACE; + break; + case '-': + white_big_text->drawf(names.item[i], 0, 60+screen->h+y-scroll, A_HMIDDLE, A_TOP, 3); + y += white_big_text->h+ITEMS_SPACE; + break; + default: + blue_text->drawf(names.item[i], 0, 60+screen->h+y-scroll, A_HMIDDLE, A_TOP, 1); + y += blue_text->h+ITEMS_SPACE; + break; + } } flipscreen(); - if(60+screen->h+(n*18)+(d*18)-scroll < 0 && 20+60+screen->h+(n*18)+(d*18)-scroll < 0) + if(60+screen->h+y-scroll < 0 && 20+60+screen->h+y-scroll < 0) done = 1; scroll += speed; |