diff options
author | Teruaki Kawashima <teru@rockbox.org> | 2009-07-14 13:03:17 +0000 |
---|---|---|
committer | Teruaki Kawashima <teru@rockbox.org> | 2009-07-14 13:03:17 +0000 |
commit | c72b23ad2e1b3a507a36b6223c0a35be9b746f0a (patch) | |
tree | 2cf43da7cca0ff2caf8544a1f3c48ac5d961701c /apps/plugins/brickmania.c | |
parent | e37f9f16915a1a05059aee931723c127a53a68e0 (diff) | |
download | rockbox-c72b23ad2e1b3a507a36b6223c0a35be9b746f0a.tar.gz rockbox-c72b23ad2e1b3a507a36b6223c0a35be9b746f0a.zip |
use lib display text to display help messages (FS#10099).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21861 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/brickmania.c')
-rw-r--r-- | apps/plugins/brickmania.c | 284 |
1 files changed, 94 insertions, 190 deletions
diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c index 2f11cef24e..f0229b4f8b 100644 --- a/apps/plugins/brickmania.c +++ b/apps/plugins/brickmania.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include "plugin.h" | 22 | #include "plugin.h" |
23 | #include "lib/configfile.h" /* Part of libplugin */ | 23 | #include "lib/configfile.h" /* Part of libplugin */ |
24 | #include "lib/helper.h" | 24 | #include "lib/helper.h" |
25 | #include "lib/display_text.h" | ||
25 | 26 | ||
26 | PLUGIN_HEADER | 27 | PLUGIN_HEADER |
27 | 28 | ||
@@ -1130,154 +1131,84 @@ int game_menu(int when) | |||
1130 | } | 1131 | } |
1131 | } | 1132 | } |
1132 | 1133 | ||
1133 | int help(int when) | 1134 | int help(void) |
1134 | { | 1135 | { |
1135 | int w,h; | ||
1136 | int button; | 1136 | int button; |
1137 | int xoffset=0; | 1137 | #define WORDS (sizeof help_text / sizeof (char*)) |
1138 | int yoffset=0; | 1138 | static char* help_text[] = { |
1139 | /* set the maximum x and y in the helpscreen | 1139 | "BrickMania", "", "Aim", "", |
1140 | dont forget to update, if you change text */ | 1140 | "Destroy", "all", "the", "bricks", "by", "bouncing", |
1141 | int maxY=180; | 1141 | "the", "ball", "of", "them", "using", "the", "paddle.", "", "", |
1142 | int maxX=215; | 1142 | "Controls", "", |
1143 | 1143 | "< & >", "Move", "the", "paddle", "", | |
1144 | while(true) { | ||
1145 | #ifdef HAVE_LCD_COLOR | ||
1146 | rb->lcd_set_background(LCD_BLACK); | ||
1147 | rb->lcd_clear_display(); | ||
1148 | rb->lcd_set_background(LCD_BLACK); | ||
1149 | rb->lcd_set_foreground(LCD_WHITE); | ||
1150 | #else | ||
1151 | rb->lcd_clear_display(); | ||
1152 | #endif | ||
1153 | |||
1154 | rb->lcd_getstringsize("BrickMania", &w, &h); | ||
1155 | rb->lcd_putsxy(LCD_WIDTH/2-w/2+xoffset, 1+yoffset, "BrickMania"); | ||
1156 | |||
1157 | #ifdef HAVE_LCD_COLOR | ||
1158 | rb->lcd_set_foreground(LCD_RGBPACK(245,0,0)); | ||
1159 | rb->lcd_putsxy(1+xoffset, 1*(h+2)+yoffset,"Aim"); | ||
1160 | rb->lcd_set_foreground(LCD_WHITE); | ||
1161 | #else | ||
1162 | rb->lcd_putsxy(1+xoffset, 1*(h+2)+yoffset,"Aim"); | ||
1163 | #endif | ||
1164 | rb->lcd_putsxy(1+xoffset, 2*(h+2)+yoffset, | ||
1165 | "destroy all the bricks by bouncing"); | ||
1166 | rb->lcd_putsxy(1+xoffset, 3*(h+2)+yoffset, | ||
1167 | "the ball of them using the paddle."); | ||
1168 | #ifdef HAVE_LCD_COLOR | ||
1169 | rb->lcd_set_foreground(LCD_RGBPACK(245,0,0)); | ||
1170 | rb->lcd_putsxy(1+xoffset, 5*(h+2)+yoffset,"Controls"); | ||
1171 | rb->lcd_set_foreground(LCD_WHITE); | ||
1172 | #else | ||
1173 | rb->lcd_putsxy(1+xoffset, 5*(h+2)+yoffset,"Controls"); | ||
1174 | #endif | ||
1175 | rb->lcd_putsxy(1+xoffset, 6*(h+2)+yoffset,"< & > Move the paddle"); | ||
1176 | #if CONFIG_KEYPAD == ONDIO_PAD | 1144 | #if CONFIG_KEYPAD == ONDIO_PAD |
1177 | rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset, | 1145 | "MENU", |
1178 | "MENU Releases the ball/Fire!"); | ||
1179 | #elif (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IAUDIO_M3_PAD) | 1146 | #elif (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IAUDIO_M3_PAD) |
1180 | rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset, | 1147 | "PLAY", |
1181 | "PLAY Releases the ball/Fire!"); | ||
1182 | #elif CONFIG_KEYPAD == IRIVER_H300_PAD | 1148 | #elif CONFIG_KEYPAD == IRIVER_H300_PAD |
1183 | rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset, | 1149 | "NAVI", |
1184 | "NAVI Releases the ball/Fire!"); | ||
1185 | #else | 1150 | #else |
1186 | rb->lcd_putsxy(1+xoffset, 7*(h+2)+yoffset, | 1151 | "SELECT", |
1187 | "SELECT Releases the ball/Fire!"); | ||
1188 | #endif | 1152 | #endif |
1153 | "Releases", "the", "ball/", "Fire!", "", | ||
1189 | #if CONFIG_KEYPAD == IAUDIO_M3_PAD | 1154 | #if CONFIG_KEYPAD == IAUDIO_M3_PAD |
1190 | rb->lcd_putsxy(1+xoffset, 8*(h+2)+yoffset, "REC Opens menu/Quit"); | 1155 | "REC", |
1156 | #elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) || \ | ||
1157 | (CONFIG_KEYPAD == CREATIVEZVM_PAD) | ||
1158 | "BACK", | ||
1159 | #elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \ | ||
1160 | (CONFIG_KEYPAD == IPOD_3G_PAD) || \ | ||
1161 | (CONFIG_KEYPAD == IPOD_1G2G_PAD) | ||
1162 | "MENU", | ||
1163 | #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ | ||
1164 | (CONFIG_KEYPAD == IRIVER_H300_PAD) || \ | ||
1165 | (CONFIG_KEYPAD == ONDIO_PAD) || \ | ||
1166 | (CONFIG_KEYPAD == RECORDER_PAD) || \ | ||
1167 | (CONFIG_KEYPAD == ARCHOS_AV300_PAD) | ||
1168 | "STOP", | ||
1191 | #else | 1169 | #else |
1192 | rb->lcd_putsxy(1+xoffset, 8*(h+2)+yoffset, "STOP Opens menu/Quit"); | 1170 | "POWER", |
1193 | #endif | 1171 | #endif |
1172 | "Opens", "menu/", "Quit", "", "", | ||
1173 | "Specials", "", | ||
1174 | "N", "Normal:", "returns", "paddle", "to", "normal", "", | ||
1175 | "D", "DIE!:", "loses", "a", "life", "", | ||
1176 | "L", "Life:", "gains", "a", "life/", "power", "up", "", | ||
1177 | "F", "Fire:", "allows", "you", "to", "shoot", "bricks", "", | ||
1178 | "G", "Glue:", "ball", "sticks", "to", "paddle", "", | ||
1179 | "B", "Ball:", "generates", "another", "ball", "", | ||
1180 | "FL", "Flip:", "flips", "left /", "right", "movement", | ||
1181 | }; | ||
1182 | static struct style_text formation[]={ | ||
1183 | { 0, TEXT_CENTER|TEXT_UNDERLINE }, | ||
1184 | { 2, C_RED }, | ||
1185 | { 19, C_RED }, | ||
1186 | { 38, C_RED }, | ||
1187 | { 40, C_BLUE }, | ||
1188 | { 47, C_RED }, | ||
1189 | { 53, C_GREEN }, | ||
1190 | { 61, C_ORANGE }, | ||
1191 | { 69, C_GREEN }, | ||
1192 | { 76, C_YELLOW }, | ||
1193 | { 82, C_RED }, | ||
1194 | { -1, 0 } | ||
1195 | }; | ||
1196 | |||
1194 | #ifdef HAVE_LCD_COLOR | 1197 | #ifdef HAVE_LCD_COLOR |
1195 | rb->lcd_set_foreground(LCD_RGBPACK(245,0,0)); | 1198 | rb->lcd_set_background(LCD_BLACK); |
1196 | rb->lcd_putsxy(1+xoffset, 10*(h+2)+yoffset, "Specials"); | 1199 | rb->lcd_set_foreground(LCD_WHITE); |
1197 | rb->lcd_set_foreground(LCD_WHITE); | ||
1198 | #else | ||
1199 | rb->lcd_putsxy(1+xoffset, 10*(h+2)+yoffset, "Specials"); | ||
1200 | #endif | 1200 | #endif |
1201 | rb->lcd_putsxy(1+xoffset, 11*(h+2)+yoffset, | ||
1202 | "N Normal:returns paddle to normal"); | ||
1203 | rb->lcd_putsxy(1+xoffset, 12*(h+2)+yoffset, "D DIE!:loses a life"); | ||
1204 | rb->lcd_putsxy(1+xoffset, 13*(h+2)+yoffset, | ||
1205 | "L Life:gains a life/power up"); | ||
1206 | rb->lcd_putsxy(1+xoffset, 14*(h+2)+yoffset, | ||
1207 | "F Fire:allows you to shoot bricks"); | ||
1208 | rb->lcd_putsxy(1+xoffset, 15*(h+2)+yoffset, | ||
1209 | "G Glue:ball sticks to paddle"); | ||
1210 | rb->lcd_putsxy(1+xoffset, 16*(h+2)+yoffset, | ||
1211 | "B Ball:generates another ball"); | ||
1212 | rb->lcd_putsxy(1+xoffset, 17*(h+2)+yoffset, | ||
1213 | "FL Flip:flips left / right movement"); | ||
1214 | rb->lcd_update(); | ||
1215 | 1201 | ||
1216 | button=rb->button_get(true); | 1202 | rb->lcd_setfont(FONT_UI); |
1217 | switch (button) { | 1203 | if (display_text(WORDS, help_text, formation, NULL)) |
1218 | #ifdef RC_QUIT | 1204 | return 1; |
1219 | case RC_QUIT: | 1205 | do { |
1220 | #endif | 1206 | button = rb->button_get(true); |
1221 | #ifdef HAVE_TOUCHSCREEN | 1207 | if ( rb->default_event_handler( button ) == SYS_USB_CONNECTED ) |
1222 | case BUTTON_TOUCHSCREEN: | 1208 | return 1; |
1223 | #endif | 1209 | } while( ( button == BUTTON_NONE ) |
1224 | case QUIT: | 1210 | || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); |
1225 | switch (game_menu(when)) { | 1211 | rb->lcd_setfont(FONT_SYSFIXED); |
1226 | case 0: | ||
1227 | cur_level=0; | ||
1228 | life=2; | ||
1229 | int_game(1); | ||
1230 | break; | ||
1231 | case 1: | ||
1232 | con_game=1; | ||
1233 | break; | ||
1234 | case 2: | ||
1235 | if (help(when)==1) | ||
1236 | return 1; | ||
1237 | break; | ||
1238 | case 3: | ||
1239 | return 1; | ||
1240 | break; | ||
1241 | } | ||
1242 | return 0; | ||
1243 | break; | ||
1244 | case LEFT: | ||
1245 | case LEFT | BUTTON_REPEAT: | ||
1246 | #ifdef ALTLEFT | ||
1247 | case ALTLEFT: | ||
1248 | case ALTLEFT | BUTTON_REPEAT: | ||
1249 | #endif | ||
1250 | if( xoffset<0) | ||
1251 | xoffset+=2; | ||
1252 | break; | ||
1253 | case RIGHT: | ||
1254 | case RIGHT | BUTTON_REPEAT: | ||
1255 | #ifdef ALTRIGHT | ||
1256 | case ALTRIGHT: | ||
1257 | case ALTRIGHT | BUTTON_REPEAT: | ||
1258 | #endif | ||
1259 | if(xoffset+maxX > LCD_WIDTH) | ||
1260 | xoffset-=2; | ||
1261 | break; | ||
1262 | case UP: | ||
1263 | case UP | BUTTON_REPEAT: | ||
1264 | if(yoffset <0) | ||
1265 | yoffset+=2; | ||
1266 | break; | ||
1267 | case DOWN: | ||
1268 | case DOWN | BUTTON_REPEAT: | ||
1269 | if(yoffset+maxY > LCD_HEIGHT) | ||
1270 | yoffset-=2; | ||
1271 | break; | ||
1272 | |||
1273 | default: | ||
1274 | if(rb->default_event_handler(button) == SYS_USB_CONNECTED) | ||
1275 | return 1; | ||
1276 | break; | ||
1277 | } | ||
1278 | |||
1279 | rb->yield(); | ||
1280 | } | ||
1281 | return 0; | 1212 | return 0; |
1282 | } | 1213 | } |
1283 | 1214 | ||
@@ -1315,10 +1246,6 @@ int game_loop(void) | |||
1315 | int sec_count=0,num_count=10; | 1246 | int sec_count=0,num_count=10; |
1316 | int end; | 1247 | int end; |
1317 | 1248 | ||
1318 | rb->srand( *rb->current_tick ); | ||
1319 | |||
1320 | configfile_load(HIGH_SCORE,config,1,0); | ||
1321 | |||
1322 | switch(game_menu(0)) { | 1249 | switch(game_menu(0)) { |
1323 | case 0: | 1250 | case 0: |
1324 | cur_level = 0; | 1251 | cur_level = 0; |
@@ -1329,7 +1256,7 @@ int game_loop(void) | |||
1329 | con_game = 1; | 1256 | con_game = 1; |
1330 | break; | 1257 | break; |
1331 | case 2: | 1258 | case 2: |
1332 | if (help(0) == 1) return 1; | 1259 | return help(); |
1333 | break; | 1260 | break; |
1334 | case 3: | 1261 | case 3: |
1335 | return 1; | 1262 | return 1; |
@@ -1885,22 +1812,7 @@ int game_loop(void) | |||
1885 | sleep(3); | 1812 | sleep(3); |
1886 | } | 1813 | } |
1887 | 1814 | ||
1888 | switch(game_menu(0)) { | 1815 | return 0; |
1889 | case 0: | ||
1890 | life=2; | ||
1891 | cur_level=0; | ||
1892 | int_game(1); | ||
1893 | break; | ||
1894 | case 1: | ||
1895 | con_game=1; | ||
1896 | break; | ||
1897 | case 2: | ||
1898 | if (help(0)==1) return 1; | ||
1899 | break; | ||
1900 | case 3: | ||
1901 | return 1; | ||
1902 | break; | ||
1903 | } | ||
1904 | } | 1816 | } |
1905 | } | 1817 | } |
1906 | 1818 | ||
@@ -2029,24 +1941,28 @@ int game_loop(void) | |||
2029 | case RC_QUIT: | 1941 | case RC_QUIT: |
2030 | #endif | 1942 | #endif |
2031 | case QUIT: | 1943 | case QUIT: |
2032 | switch(game_menu(1)) { | 1944 | while(1) { |
2033 | case 0: | 1945 | switch(game_menu(1)) { |
2034 | life=2; | 1946 | case 0: |
2035 | cur_level=0; | 1947 | life=2; |
2036 | int_game(1); | 1948 | cur_level=0; |
2037 | break; | 1949 | int_game(1); |
2038 | case 1: | 1950 | break; |
2039 | for(k=0;k<used_balls;k++) | 1951 | case 1: |
2040 | if (ball[k].x!=0 && ball[k].y !=0) | 1952 | for(k=0;k<used_balls;k++) |
2041 | con_game=1; | 1953 | if (ball[k].x!=0 && ball[k].y !=0) |
2042 | break; | 1954 | con_game=1; |
2043 | case 2: | 1955 | break; |
2044 | if (help(1)==1) | 1956 | case 2: |
1957 | if (help()==1) | ||
1958 | return 1; | ||
1959 | continue; | ||
1960 | break; | ||
1961 | case 3: | ||
2045 | return 1; | 1962 | return 1; |
2046 | break; | 1963 | break; |
2047 | case 3: | 1964 | } |
2048 | return 1; | 1965 | break; |
2049 | break; | ||
2050 | } | 1966 | } |
2051 | 1967 | ||
2052 | for(k=0;k<used_balls;k++) { | 1968 | for(k=0;k<used_balls;k++) { |
@@ -2091,23 +2007,7 @@ int game_loop(void) | |||
2091 | ball[k].y=0; | 2007 | ball[k].y=0; |
2092 | } | 2008 | } |
2093 | 2009 | ||
2094 | switch(game_menu(0)) { | 2010 | return 0; |
2095 | case 0: | ||
2096 | cur_level=0; | ||
2097 | life=2; | ||
2098 | int_game(1); | ||
2099 | break; | ||
2100 | case 1: | ||
2101 | con_game=1; | ||
2102 | break; | ||
2103 | case 2: | ||
2104 | if (help(0)==1) | ||
2105 | return 1; | ||
2106 | break; | ||
2107 | case 3: | ||
2108 | return 1; | ||
2109 | break; | ||
2110 | } | ||
2111 | } | 2011 | } |
2112 | if (end > *rb->current_tick) | 2012 | if (end > *rb->current_tick) |
2113 | rb->sleep(end-*rb->current_tick); | 2013 | rb->sleep(end-*rb->current_tick); |
@@ -2128,6 +2028,10 @@ enum plugin_status plugin_start(const void* parameter) | |||
2128 | /* Turn off backlight timeout */ | 2028 | /* Turn off backlight timeout */ |
2129 | backlight_force_on(); /* backlight control in lib/helper.c */ | 2029 | backlight_force_on(); /* backlight control in lib/helper.c */ |
2130 | 2030 | ||
2031 | rb->srand( *rb->current_tick ); | ||
2032 | |||
2033 | configfile_load(HIGH_SCORE,config,1,0); | ||
2034 | |||
2131 | /* now go ahead and have fun! */ | 2035 | /* now go ahead and have fun! */ |
2132 | while (game_loop()!=1); | 2036 | while (game_loop()!=1); |
2133 | 2037 | ||