A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

some changes to use of display_text. * add parameter, wait_key to display_text(). - set this true to wait button press after all words is displayed. * use ARRAYLEN macro instead of #define WORDS * add macro to indicate end of style array.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24846 a1c6a512-1295-4272-9138-f99709370657

+91 -166
+3 -12
apps/plugins/blackjack.c
··· 1135 1135 * blackjack_help() displays help text. 1136 1136 ******************************************************************************/ 1137 1137 static bool blackjack_help(void) { 1138 - #define WORDS (sizeof help_text / sizeof (char*)) 1139 1138 static char *help_text[] = { 1140 1139 "Blackjack", "", "Aim", "", 1141 1140 "Try", "to", "get", "as", "close", "to", "21", "without", "going", ··· 1151 1150 { 0, TEXT_CENTER|TEXT_UNDERLINE }, 1152 1151 { 2, C_RED }, 1153 1152 { 26, C_RED }, 1154 - { -1, 0 } 1153 + LAST_STYLE_ITEM 1155 1154 }; 1156 - int button; 1157 1155 1158 1156 rb->lcd_setfont(FONT_UI); 1159 1157 #ifdef HAVE_LCD_COLOR 1160 1158 rb->lcd_set_background(LCD_BLACK); 1161 1159 rb->lcd_set_foreground(LCD_WHITE); 1162 1160 #endif 1163 - 1164 - if (display_text(WORDS, help_text, formation, NULL)) 1161 + if (display_text(ARRAYLEN(help_text), help_text, formation, NULL, true)) 1165 1162 return true; 1166 - do { 1167 - button = rb->button_get(true); 1168 - if (rb->default_event_handler(button) == SYS_USB_CONNECTED) { 1169 - return true; 1170 - } 1171 - } while( ( button == BUTTON_NONE ) 1172 - || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); 1173 1163 rb->lcd_setfont(FONT_SYSFIXED); 1164 + 1174 1165 return false; 1175 1166 } 1176 1167
+3 -12
apps/plugins/brickmania.c
··· 1138 1138 1139 1139 static int brickmania_help(void) 1140 1140 { 1141 - #define WORDS (sizeof help_text / sizeof (char*)) 1142 1141 static char *help_text[] = { 1143 1142 "Brickmania", "", "Aim", "", 1144 1143 "Destroy", "all", "the", "bricks", "by", "bouncing", ··· 1205 1204 { 67, C_GREEN }, 1206 1205 { 74, C_YELLOW }, 1207 1206 { 80, C_RED }, 1208 - { -1, 0 } 1207 + LAST_STYLE_ITEM 1209 1208 }; 1210 - int button; 1211 1209 1212 1210 rb->lcd_setfont(FONT_UI); 1213 1211 #ifdef HAVE_LCD_COLOR 1214 1212 rb->lcd_set_background(LCD_BLACK); 1215 1213 rb->lcd_set_foreground(LCD_WHITE); 1216 1214 #endif 1217 - 1218 - if (display_text(WORDS, help_text, formation, NULL)) 1215 + if (display_text(ARRAYLEN(help_text), help_text, formation, NULL, true)) 1219 1216 return 1; 1220 - do { 1221 - button = rb->button_get(true); 1222 - if (rb->default_event_handler(button) == SYS_USB_CONNECTED) { 1223 - return 1; 1224 - } 1225 - } while( ( button == BUTTON_NONE ) 1226 - || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); 1227 1217 rb->lcd_setfont(FONT_SYSFIXED); 1218 + 1228 1219 return 0; 1229 1220 } 1230 1221
+6 -13
apps/plugins/clix.c
··· 435 435 } 436 436 437 437 rb->lcd_update(); 438 + rb->lcd_set_foreground(LCD_WHITE); 438 439 } 439 440 440 441 static void clix_move_cursor(struct clix_game_state_t* state, const bool left) ··· 467 468 } 468 469 } 469 470 } while ( y != state->y); 470 - 471 471 } 472 472 473 473 /* returns the color of the given position, if out of bounds return CC_BLACK */ ··· 581 581 582 582 static bool clix_help(void) 583 583 { 584 - #define WORDS (sizeof help_text / sizeof (char*)) 585 584 static char *help_text[] = { 586 585 "Clix", "", "Aim", "", 587 586 "Remove", "all", "blocks", "from", "the", "board", "to", "achieve", ··· 593 592 static struct style_text formation[]={ 594 593 { 0, TEXT_CENTER|TEXT_UNDERLINE }, 595 594 { 2, C_RED }, 596 - { -1, 0 } 595 + LAST_STYLE_ITEM 597 596 }; 598 - int button; 599 - 597 + 600 598 rb->lcd_setfont(FONT_UI); 601 599 rb->lcd_set_foreground(LCD_WHITE); 602 - if (display_text(WORDS, help_text, formation, NULL)) 600 + if (display_text(ARRAYLEN(help_text), help_text, formation, NULL, true)) 603 601 return true; 604 - do { 605 - button = rb->button_get(true); 606 - if ( rb->default_event_handler( button ) == SYS_USB_CONNECTED ) 607 - return true; 608 - } while( ( button == BUTTON_NONE ) 609 - || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); 610 602 rb->lcd_setfont(FONT_SYSFIXED); 611 - return 0; 603 + 604 + return false; 612 605 } 613 606 614 607 static bool _ingame;
+4 -16
apps/plugins/jewels.c
··· 1300 1300 1301 1301 static bool jewels_help(void) 1302 1302 { 1303 - rb->lcd_setfont(FONT_UI); 1304 - #define WORDS (sizeof help_text / sizeof (char*)) 1305 1303 static char *help_text[] = { 1306 1304 "Jewels", "", "Aim", "", 1307 1305 "Swap", "pairs", "of", "jewels", "to", "form", "connected", ··· 1323 1321 { 0, TEXT_CENTER|TEXT_UNDERLINE }, 1324 1322 { 2, C_RED }, 1325 1323 { 42, C_RED }, 1326 - { -1, 0 } 1324 + LAST_STYLE_ITEM 1327 1325 }; 1328 - #ifdef HAVE_LCD_COLOR 1329 - rb->lcd_set_background(LCD_BLACK); 1330 - rb->lcd_set_foreground(LCD_WHITE); 1331 - #endif 1332 - int button; 1333 - if (display_text(WORDS, help_text, formation, NULL)) 1326 + 1327 + rb->lcd_setfont(FONT_UI); 1328 + if (display_text(ARRAYLEN(help_text), help_text, formation, NULL, true)) 1334 1329 return true; 1335 - do { 1336 - button = rb->button_get(true); 1337 - if (rb->default_event_handler (button) == SYS_USB_CONNECTED) { 1338 - return true; 1339 - } 1340 - } while( ( button == BUTTON_NONE ) 1341 - || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); 1342 1330 rb->lcd_setfont(FONT_SYSFIXED); 1343 1331 1344 1332 return false;
+21 -9
apps/plugins/lib/display_text.c
··· 28 28 #define MARGIN 5 29 29 #endif 30 30 31 - bool display_text(short words, char** text, struct style_text* style, 32 - struct viewport* vp_text) 31 + static bool wait_key_press(void) 32 + { 33 + int button; 34 + do { 35 + button = rb->button_get(true); 36 + if ( rb->default_event_handler( button ) == SYS_USB_CONNECTED ) 37 + return true; 38 + } while( ( button == BUTTON_NONE ) 39 + || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); 40 + return false; 41 + } 42 + 43 + bool display_text(unsigned short words, char** text, struct style_text* style, 44 + struct viewport* vp_text, bool wait_key) 33 45 { 34 46 #ifdef HAVE_LCD_BITMAP 35 47 int prev_drawmode; ··· 41 53 unsigned short x , y; 42 54 unsigned short vp_width = LCD_WIDTH; 43 55 unsigned short vp_height = LCD_HEIGHT; 44 - int button; 45 56 unsigned short i = 0, style_index = 0; 46 57 if (vp_text != NULL) { 47 58 vp_width = vp_text->width; ··· 76 87 if (y + height > vp_height - MARGIN) { 77 88 y = MARGIN; 78 89 rb->screens[SCREEN_MAIN]->update_viewport(); 79 - do { 80 - button = rb->button_get(true); 81 - if ( rb->default_event_handler( button ) == SYS_USB_CONNECTED ) 82 - return true; 83 - } while( ( button == BUTTON_NONE ) 84 - || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); 90 + if (wait_key_press()) 91 + return true; 85 92 rb->screens[SCREEN_MAIN]->clear_viewport(); 86 93 } 87 94 /* no text formatting available */ ··· 134 141 #ifdef HAVE_LCD_BITMAP 135 142 rb->lcd_set_drawmode(prev_drawmode); 136 143 #endif 144 + if (wait_key) 145 + { 146 + if (wait_key_press()) 147 + return true; 148 + } 137 149 return false; 138 150 }
+20 -6
apps/plugins/lib/display_text.h
··· 19 19 * KIND, either express or implied. 20 20 * 21 21 ****************************************************************************/ 22 + #ifndef _DISPLAY_TEXT_H 23 + #define _DISPLAY_TEXT_H 24 + 22 25 #include "plugin.h" 26 + 23 27 /* 24 28 * basic usage: 25 - * #define WORDS (sizeof text / sizeof (char*)) 26 29 * char *text[] = {"normal", "centering", "red,underline"}; 27 30 * struct style_text formation[]={ 28 31 * { 1, TEXT_CENTER }, 29 32 * { 2, C_RED|TEXT_UNDERLINE }, 33 + * LAST_STYLE_ITEM 30 34 * }; 31 - * if (display_text(WORDS, text, formation, NULL)) 35 + * if (display_text(ARRAYLEN(text), text, formation, NULL, true)) 32 36 * return PLUGIN_USB_CONNECTED; 33 37 */ 34 38 ··· 36 40 #define TEXT_COLOR_MASK 0x00ff 37 41 #define TEXT_CENTER 0x0100 38 42 #define TEXT_UNDERLINE 0x0200 43 + #define LAST_STYLE_ITEM { -1, 0 } 39 44 40 45 struct style_text { 41 46 unsigned short index; 42 47 unsigned short flags; 43 48 }; 44 49 45 - /* style and vp_text are optional. 46 - * return true if usb is connected. */ 47 - bool display_text(short words, char** text, struct style_text* style, 48 - struct viewport* vp_text); 50 + /* 51 + * display text. 52 + * - words : number of words in text. 53 + * - text : array of word to be displayed. use empty string for newline. 54 + * - style : (optional) set style of each word. must be sorted by index. 55 + * - vp_text : (optional) viewport to display text. 56 + * - wait_key : set true to wait button press after all words is displayed. 57 + * return true if usb is connected, false otherwise. 58 + */ 59 + bool display_text(unsigned short words, char** text, struct style_text* style, 60 + struct viewport* vp_text, bool wait_key); 61 + 62 + #endif /* _DISPLAY_TEXT_H */
+3 -11
apps/plugins/pegbox.c
··· 970 970 ************************************************************************/ 971 971 static bool pegbox_help(void) 972 972 { 973 - int button; 974 - #define WORDS (sizeof help_text / sizeof (char*)) 975 973 static char* help_text[] = { 976 974 "Pegbox", "", "Aim", "", 977 975 "To", "beat", "each", "level,", "you", "must", "destroy", "all", "of", ··· 990 988 { 0, TEXT_CENTER|TEXT_UNDERLINE }, 991 989 { 2, C_RED }, 992 990 { 46, C_RED }, 993 - { -1, 0 } 991 + LAST_STYLE_ITEM 994 992 }; 995 993 996 994 rb->lcd_setfont(FONT_UI); 997 - 998 - if (display_text(WORDS, help_text, formation, NULL)) 995 + if (display_text(ARRAYLEN(help_text), help_text, formation, NULL, true)) 999 996 return true; 1000 - do { 1001 - button = rb->button_get(true); 1002 - if ( rb->default_event_handler( button ) == SYS_USB_CONNECTED ) 1003 - return true; 1004 - } while( ( button == BUTTON_NONE ) 1005 - || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); 1006 997 rb->lcd_setfont(FONT_SYSFIXED); 998 + 1007 999 return false; 1008 1000 } 1009 1001
+1 -2
apps/plugins/robotfindskitten.c
··· 863 863 864 864 static void instructions() 865 865 { 866 - #define WORDS (sizeof help_text / sizeof (char*)) 867 866 static char* help_text[] = { 868 867 #if 0 869 868 /* Not sure if we want to include this? */ ··· 879 878 "The", "game", "ends", "when", "robotfindskitten.", "", "", 880 879 "Press", "any", "key", "to", "start", 881 880 }; 882 - display_text(WORDS, help_text, NULL, NULL); 881 + display_text(ARRAYLEN(help_text), help_text, NULL, NULL, false); 883 882 pause(); 884 883 } 885 884
+11 -16
apps/plugins/rockblox.c
··· 1218 1218 1219 1219 static bool rockblox_help(void) 1220 1220 { 1221 - int button; 1222 - 1223 - #define WORDS (sizeof help_text / sizeof (char*)) 1224 - char *help_text[] = { 1225 - "Rockblox", "", "Aim", "", "Make", "the", "falling", "blocks", "of", "different", 1226 - "shapes", "form", "full", "rows.", "Whenever", "a", "row", "is", "completed,", "it", 1227 - "will", "be", "cleared", "away", "and", "you", "gain", "points." 1221 + static char *help_text[] = { 1222 + "Rockblox", "", "Aim", "", 1223 + "Make", "the", "falling", "blocks", "of", 1224 + "different", "shapes", "form", "full", "rows.", 1225 + "Whenever", "a", "row", "is", "completed,", 1226 + "it", "will", "be", "cleared", "away", 1227 + "and", "you", "gain", "points." 1228 1228 }; 1229 - 1230 1229 static struct style_text formation[]={ 1231 1230 { 0, TEXT_CENTER|TEXT_UNDERLINE }, 1232 1231 { 2, C_RED }, 1233 - { -1, 0 } 1232 + LAST_STYLE_ITEM 1234 1233 }; 1234 + 1235 1235 #ifdef HAVE_LCD_BITMAP 1236 1236 rb->lcd_setfont(FONT_UI); 1237 1237 #endif ··· 1239 1239 rb->lcd_set_background(LCD_BLACK); 1240 1240 rb->lcd_set_foreground(LCD_WHITE); 1241 1241 #endif 1242 - if (display_text(WORDS, help_text, formation, NULL)) 1242 + if (display_text(ARRAYLEN(help_text), help_text, formation, NULL, true)) 1243 1243 return true; 1244 - do { 1245 - button = rb->button_get(true); 1246 - if ( rb->default_event_handler( button ) == SYS_USB_CONNECTED ) 1247 - return true; 1248 - } while( ( button == BUTTON_NONE ) 1249 - || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); 1250 1244 #ifdef HAVE_LCD_BITMAP 1251 1245 rb->lcd_setfont(FONT_SYSFIXED); 1252 1246 #endif 1247 + 1253 1248 return false; 1254 1249 } 1255 1250
+2 -23
apps/plugins/solitaire.c
··· 686 686 /* Help */ 687 687 static bool solitaire_help( void ) 688 688 { 689 - 690 - #define WORDS (sizeof help_text / sizeof (char*)) 691 689 static char* help_text[] = { 692 690 "Solitaire", "", "Controls", "", 693 691 HK_LR ":", "Move", "the", "cursor", "to", "the", ··· 711 709 { 0, TEXT_CENTER|TEXT_UNDERLINE }, 712 710 { 2, C_RED }, 713 711 { 48, C_RED }, 714 - { -1, 0 } 712 + LAST_STYLE_ITEM 715 713 }; 716 - #if LCD_DEPTH > 1 717 - fb_data* backdrop = rb->lcd_get_backdrop(); 718 - rb->lcd_set_backdrop(NULL); 719 - #endif 720 - #ifdef HAVE_LCD_COLOR 721 - rb->lcd_set_background(LCD_BLACK); 722 - rb->lcd_set_foreground(LCD_WHITE); 723 - #endif 724 - int button; 725 - if (display_text(WORDS, help_text, formation, NULL)) 714 + if (display_text(ARRAYLEN(help_text), help_text, formation, NULL, true)) 726 715 return true; 727 - do { 728 - button = rb->button_get(true); 729 - if ( rb->default_event_handler( button ) == SYS_USB_CONNECTED ) 730 - return true; 731 - } while( ( button == BUTTON_NONE ) 732 - || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); 733 - 734 - #if LCD_DEPTH > 1 735 - rb->lcd_set_backdrop(backdrop); 736 - #endif 737 716 return false; 738 717 } 739 718
+8 -17
apps/plugins/spacerocks.c
··· 1745 1745 static bool spacerocks_help(void) 1746 1746 { 1747 1747 static char *help_text[] = { 1748 - "Spacerocks", "", "Aim", "", "The", "goal", "of", "the", "game", "is", 1749 - "to", "blow", "up", "the", "asteroids", "and", "avoid", "being", "hit", "by", 1750 - "them.", "Also", "you'd", "better", "watch", "out", "for", "the", "UFOs!" 1748 + "Spacerocks", "", "Aim", "", 1749 + "The", "goal", "of", "the", "game", "is", "to", "blow", "up", 1750 + "the", "asteroids", "and", "avoid", "being", "hit", "by", "them.", 1751 + "Also", "you'd", "better", "watch", "out", "for", "the", "UFOs!" 1751 1752 }; 1752 1753 static struct style_text formation[]={ 1753 1754 { 0, TEXT_CENTER|TEXT_UNDERLINE }, 1754 1755 { 2, C_RED }, 1755 - { -1, 0 } 1756 + LAST_STYLE_ITEM 1756 1757 }; 1757 - int button; 1758 1758 1759 1759 rb->lcd_setfont(FONT_UI); 1760 - #ifdef HAVE_LCD_COLOR 1761 - rb->lcd_set_background(LCD_BLACK); 1762 - rb->lcd_set_foreground(LCD_WHITE); 1763 - #endif 1764 - if (display_text(ARRAYLEN(help_text), help_text, formation, NULL) 1765 - == PLUGIN_USB_CONNECTED) 1760 + SET_BG(LCD_BLACK); 1761 + SET_FG(LCD_WHITE); 1762 + if (display_text(ARRAYLEN(help_text), help_text, formation, NULL, true)) 1766 1763 return true; 1767 - do { 1768 - button = rb->button_get(true); 1769 - if (button == SYS_USB_CONNECTED) 1770 - return true; 1771 - } while( ( button == BUTTON_NONE ) 1772 - || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); 1773 1764 rb->lcd_setfont(FONT_SYSFIXED); 1774 1765 1775 1766 return false;
+8 -20
apps/plugins/star.c
··· 1051 1051 */ 1052 1052 static bool star_help(void) 1053 1053 { 1054 - int button; 1055 - #define WORDS (sizeof help_text / sizeof (char*)) 1056 1054 static char* help_text[] = { 1057 1055 "Star", "", "Aim", "", 1058 1056 "Take", "all", "the", "stars", "to", "go", "to", "the", "next", "level.", ··· 1070 1068 { 0, TEXT_CENTER|TEXT_UNDERLINE }, 1071 1069 { 2, C_RED }, 1072 1070 { 35, C_RED }, 1073 - { -1, 0 } 1071 + LAST_STYLE_ITEM 1074 1072 }; 1075 - #if LCD_DEPTH > 1 1076 - #ifndef HAVE_LCD_COLOR 1077 - rb->lcd_set_background(LCD_WHITE ); 1078 - rb->lcd_set_foreground(LCD_BLACK ); 1079 - #endif 1073 + #if LCD_DEPTH > 1 && !defined(HAVE_LCD_COLOR) 1074 + rb->lcd_set_background(LCD_WHITE); 1075 + rb->lcd_set_foreground(LCD_BLACK); 1080 1076 #endif 1081 - if (display_text(WORDS, help_text, formation, NULL)) 1077 + if (display_text(ARRAYLEN(help_text), help_text, formation, NULL, true)) 1082 1078 return true; 1083 - do { 1084 - button = rb->button_get(true); 1085 - if ( rb->default_event_handler( button ) == SYS_USB_CONNECTED ) 1086 - return true; 1087 - } while( ( button == BUTTON_NONE ) 1088 - || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); 1089 - #if LCD_DEPTH > 1 1090 - #ifndef HAVE_LCD_COLOR 1091 - rb->lcd_set_background(LCD_BLACK ); 1092 - rb->lcd_set_foreground(LCD_WHITE ); 1093 - #endif 1079 + #if LCD_DEPTH > 1 && !defined(HAVE_LCD_COLOR) 1080 + rb->lcd_set_background(LCD_BLACK); 1081 + rb->lcd_set_foreground(LCD_WHITE); 1094 1082 #endif 1095 1083 return false; 1096 1084 }
+1 -9
apps/plugins/superdom.c
··· 566 566 } 567 567 568 568 static int superdom_help(void) { 569 - int button; 570 569 static char* help_text[] = { 571 570 "Super", "domination", "is", "a", "turn", "based", "strategy", "game,", 572 571 "where", "the", "aim", "is", "to", "overpower", "the", "computer", ··· 580 579 "and", "number", "of", "troops", "on", "them.", 581 580 }; 582 581 583 - if (display_text(ARRAYLEN(help_text), help_text, NULL, NULL)) 582 + if (display_text(ARRAYLEN(help_text), help_text, NULL, NULL, true)) 584 583 return RET_VAL_USB; 585 - do { 586 - button = rb->button_get(true); 587 - if ( rb->default_event_handler( button ) == SYS_USB_CONNECTED ) 588 - return RET_VAL_USB; 589 - } while( ( button == BUTTON_NONE ) 590 - || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); 591 - 592 584 return RET_VAL_OK; 593 585 } 594 586