Index: apps/plugins/brickmania.c =================================================================== --- apps/plugins/brickmania.c (Revision 20981) +++ apps/plugins/brickmania.c (Arbeitskopie) @@ -22,6 +22,7 @@ #include "plugin.h" #include "lib/configfile.h" /* Part of libplugin */ #include "lib/helper.h" +#include "lib/text.h" PLUGIN_HEADER @@ -1132,155 +1133,76 @@ int help(int when) { - int w,h; + static struct viewport vp_help = + { + .x = 10, + .y = 10, + .width = LCD_WIDTH-20, + .height = LCD_HEIGHT-20, + .font = FONT_UI, + #if LCD_DEPTH > 1 + .fg_pattern = LCD_WHITE, + .bg_pattern = LCD_BLACK, + #endif + }; + +#define WORDS (sizeof help_text / sizeof (char*)) + char *help_text[] = { + "Brickmania", "", "Aim", "", "Destroy", "all", "the", "bricks", "by", "bouncing", + "the", "ball", "of", "them", "using", "the", "paddle.", "", "", "Controls", "", + "< & >", "Move", "the", "paddle", "", HELP_SELECT, "Release", "the", "ball/fire!", "", "", + "Specials:", "", "N", "Normal:", "returns", "paddle", "to", "normal", "", "D", "DIE!:", + "loses", "a", "life", "", "L", "Life:", "gains", "a", "life", "up", "", "F", "Fire:", + "allows", "you", "to", "shoot", "bricks", "", "G", "Glue:", "ball", "sticks", "to", + "paddle", "", "B", "Ball:", "generate", "another", "ball", "", "FL", "Flip:", "flips", + "left/right", "movement", + }; + struct style_text formation[WORDS]={}; + formation[0].center=1; + formation[0].underline=1; + formation[2].color=C_RED; + formation[19].color=C_RED; + formation[32].color=C_RED; + formation[34].color=C_BLUE; + formation[41].color=C_RED; + formation[47].color=C_GREEN; + formation[54].color=C_ORANGE; + formation[62].color=C_GREEN; + formation[69].color=C_YELLOW; + formation[75].color=C_RED; + + if (display_text(WORDS, help_text, formation, &vp_help)==PLUGIN_USB_CONNECTED) + return 1; + rb->screens[SCREEN_MAIN]->set_viewport(NULL); int button; - int xoffset=0; - int yoffset=0; - /* set the maximum x and y in the helpscreen - dont forget to update, if you change text */ - int maxY=180; - int maxX=215; - - while(true) { -#ifdef HAVE_LCD_COLOR - rb->lcd_set_background(LCD_BLACK); - rb->lcd_clear_display(); - rb->lcd_set_background(LCD_BLACK); - rb->lcd_set_foreground(LCD_WHITE); -#else - rb->lcd_clear_display(); -#endif - - rb->lcd_getstringsize("BrickMania", &w, &h); - rb->lcd_putsxy(LCD_WIDTH/2-w/2+xoffset, 1+yoffset, "BrickMania"); - -#ifdef HAVE_LCD_COLOR - rb->lcd_set_foreground(LCD_RGBPACK(245,0,0)); - rb->lcd_putsxy(1+xoffset, 1*(h+2)+yoffset,"Aim"); - rb->lcd_set_foreground(LCD_WHITE); -#else - rb->lcd_putsxy(1+xoffset, 1*(h+2)+yoffset,"Aim"); -#endif - rb->lcd_putsxy(1+xoffset, 2*(h+2)+yoffset, - "destroy all the bricks by bouncing"); - rb->lcd_putsxy(1+xoffset, 3*(h+2)+yoffset, - "the ball of them using the paddle."); -#ifdef HAVE_LCD_COLOR - rb->lcd_set_foreground(LCD_RGBPACK(245,0,0)); - rb->lcd_putsxy(1+xoffset, 5*(h+2)+yoffset,"Controls"); - rb->lcd_set_foreground(LCD_WHITE); -#else - rb->lcd_putsxy(1+xoffset, 5*(h+2)+yoffset,"Controls"); -#endif - rb->lcd_putsxy(1+xoffset, 6*(h+2)+yoffset,"< & > Move the paddle"); -#if CONFIG_KEYPAD == ONDIO_PAD - rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset, - "MENU Releases the ball/Fire!"); -#elif (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IAUDIO_M3_PAD) - rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset, - "PLAY Releases the ball/Fire!"); -#elif CONFIG_KEYPAD == IRIVER_H300_PAD - rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset, - "NAVI Releases the ball/Fire!"); -#else - rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset, - "SELECT Releases the ball/Fire!"); -#endif -#if CONFIG_KEYPAD == IAUDIO_M3_PAD - rb->lcd_putsxy(1+xoffset, 8*(h+2)+yoffset, "REC Opens menu/Quit"); -#else - rb->lcd_putsxy(1+xoffset, 8*(h+2)+yoffset, "STOP Opens menu/Quit"); -#endif -#ifdef HAVE_LCD_COLOR - rb->lcd_set_foreground(LCD_RGBPACK(245,0,0)); - rb->lcd_putsxy(1+xoffset, 10*(h+2)+yoffset, "Specials"); - rb->lcd_set_foreground(LCD_WHITE); -#else - rb->lcd_putsxy(1+xoffset, 10*(h+2)+yoffset, "Specials"); -#endif - rb->lcd_putsxy(1+xoffset, 11*(h+2)+yoffset, - "N Normal:returns paddle to normal"); - rb->lcd_putsxy(1+xoffset, 12*(h+2)+yoffset, "D DIE!:loses a life"); - rb->lcd_putsxy(1+xoffset, 13*(h+2)+yoffset, - "L Life:gains a life/power up"); - rb->lcd_putsxy(1+xoffset, 14*(h+2)+yoffset, - "F Fire:allows you to shoot bricks"); - rb->lcd_putsxy(1+xoffset, 15*(h+2)+yoffset, - "G Glue:ball sticks to paddle"); - rb->lcd_putsxy(1+xoffset, 16*(h+2)+yoffset, - "B Ball:generates another ball"); - rb->lcd_putsxy(1+xoffset, 17*(h+2)+yoffset, - "FL Flip:flips left / right movement"); - rb->lcd_update(); - - button=rb->button_get(true); - switch (button) { -#ifdef RC_QUIT - case RC_QUIT: -#endif -#ifdef HAVE_TOUCHSCREEN - case BUTTON_TOUCHSCREEN: -#endif - case QUIT: - switch (game_menu(when)) { - case 0: - cur_level=0; - life=2; - int_game(1); - break; - case 1: - con_game=1; - break; - case 2: - if (help(when)==1) - return 1; - break; - case 3: - return 1; - break; - } - return 0; - break; - case LEFT: - case LEFT | BUTTON_REPEAT: -#ifdef ALTLEFT - case ALTLEFT: - case ALTLEFT | BUTTON_REPEAT: -#endif - if( xoffset<0) - xoffset+=2; - break; - case RIGHT: - case RIGHT | BUTTON_REPEAT: -#ifdef ALTRIGHT - case ALTRIGHT: - case ALTRIGHT | BUTTON_REPEAT: -#endif - if(xoffset+maxX > LCD_WIDTH) - xoffset-=2; - break; - case UP: - case UP | BUTTON_REPEAT: - if(yoffset <0) - yoffset+=2; - break; - case DOWN: - case DOWN | BUTTON_REPEAT: - if(yoffset+maxY > LCD_HEIGHT) - yoffset-=2; - break; - - default: - if(rb->default_event_handler(button) == SYS_USB_CONNECTED) - return 1; - break; + do { + button = rb->button_get(true); + if (button == SYS_USB_CONNECTED) { + return 1; } - - rb->yield(); + } while( ( button == BUTTON_NONE ) + || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); + switch (game_menu(when)) { + case 0: + cur_level=0; + life=2; + int_game(1); + break; + case 1: + con_game=1; + break; + case 2: + if (help(when)==1) + return 1; + break; + case 3: + return 1; + break; } return 0; } + int pad_check(int ballxc, int mode, int pon ,int ballnum) { /* pon: positive(1) or negative(0) */