summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2006-09-17 22:14:18 +0000
committerJens Arnold <amiconn@rockbox.org>2006-09-17 22:14:18 +0000
commit6b97c1793fd8a051eec1ae53641873e95aabd43c (patch)
treef71eb3237b1751f4c2e332cf53bfcf0365916252
parent0597826fbcb2b41975816e32815a42bb0915a0ed (diff)
downloadrockbox-6b97c1793fd8a051eec1ae53641873e95aabd43c.tar.gz
rockbox-6b97c1793fd8a051eec1ae53641873e95aabd43c.zip
Solitaire: * Button assignments: Better layout for ipods, allowing one-handed operation during the game. More logical shortcut buttons for Ondios. Slight changes for other targets, including working button repeat for up/down when there is no dual use. * Help text showing all possible buttons instead of forcing the user to try and find out. The text adapts to LCD resolution and selected font.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10984 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/solitaire.c266
1 files changed, 133 insertions, 133 deletions
diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c
index 129f5c5d3e..faaf504622 100644
--- a/apps/plugins/solitaire.c
+++ b/apps/plugins/solitaire.c
@@ -54,16 +54,16 @@ static struct plugin_api* rb;
54# define SOL_LEFT BUTTON_LEFT 54# define SOL_LEFT BUTTON_LEFT
55# define SOL_RIGHT BUTTON_RIGHT 55# define SOL_RIGHT BUTTON_RIGHT
56# define SOL_MOVE BUTTON_ON 56# define SOL_MOVE BUTTON_ON
57# define SOL_DRAW BUTTON_F2 57# define SOL_DRAW BUTTON_F1
58# define SOL_REM2CUR BUTTON_PLAY 58# define SOL_REM2CUR BUTTON_PLAY
59# define SOL_CUR2STACK BUTTON_F1 59# define SOL_CUR2STACK BUTTON_F2
60# define SOL_REM2STACK BUTTON_F3 60# define SOL_REM2STACK BUTTON_F3
61# define SOL_MENU_RUN BUTTON_RIGHT 61# define SOL_MENU_RUN BUTTON_RIGHT
62# define SOL_MENU_RUN2 BUTTON_PLAY 62# define SOL_MENU_RUN2 BUTTON_PLAY
63# define HK_MOVE "ON" 63# define HK_MOVE "ON"
64# define HK_DRAW "F2" 64# define HK_DRAW "F1"
65# define HK_REM2CUR "PLAY" 65# define HK_REM2CUR "PLAY"
66# define HK_CUR2STACK "F1" 66# define HK_CUR2STACK "F2"
67# define HK_REM2STACK "F3" 67# define HK_REM2STACK "F3"
68 68
69#elif CONFIG_KEYPAD == ONDIO_PAD 69#elif CONFIG_KEYPAD == ONDIO_PAD
@@ -80,18 +80,18 @@ static struct plugin_api* rb;
80# define SOL_MOVE (BUTTON_MENU | BUTTON_REL) 80# define SOL_MOVE (BUTTON_MENU | BUTTON_REL)
81# define SOL_DRAW_PRE BUTTON_MENU 81# define SOL_DRAW_PRE BUTTON_MENU
82# define SOL_DRAW (BUTTON_MENU | BUTTON_REPEAT) 82# define SOL_DRAW (BUTTON_MENU | BUTTON_REPEAT)
83# define SOL_REM2CUR_PRE BUTTON_LEFT 83# define SOL_REM2CUR_PRE BUTTON_DOWN
84# define SOL_REM2CUR (BUTTON_LEFT | BUTTON_REPEAT) 84# define SOL_REM2CUR (BUTTON_DOWN | BUTTON_REPEAT)
85# define SOL_CUR2STACK_PRE BUTTON_RIGHT 85# define SOL_CUR2STACK_PRE BUTTON_UP
86# define SOL_CUR2STACK (BUTTON_RIGHT | BUTTON_REPEAT) 86# define SOL_CUR2STACK (BUTTON_UP | BUTTON_REPEAT)
87# define SOL_REM2STACK_PRE BUTTON_UP 87# define SOL_REM2STACK_PRE BUTTON_RIGHT
88# define SOL_REM2STACK (BUTTON_UP | BUTTON_REPEAT) 88# define SOL_REM2STACK (BUTTON_RIGHT | BUTTON_REPEAT)
89# define SOL_MENU_RUN BUTTON_RIGHT 89# define SOL_MENU_RUN BUTTON_RIGHT
90# define HK_MOVE "MODE" 90# define HK_MOVE "MODE"
91# define HK_DRAW "MODE.." 91# define HK_DRAW "MODE.."
92# define HK_REM2CUR "LEFT.." 92# define HK_REM2CUR "DOWN.."
93# define HK_CUR2STACK "RIGHT.." 93# define HK_CUR2STACK "UP.."
94# define HK_REM2STACK "UP.." 94# define HK_REM2STACK "RIGHT.."
95 95
96#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ 96#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
97 (CONFIG_KEYPAD == IRIVER_H300_PAD) 97 (CONFIG_KEYPAD == IRIVER_H300_PAD)
@@ -114,26 +114,33 @@ static struct plugin_api* rb;
114# define HK_MOVE "NAVI" 114# define HK_MOVE "NAVI"
115# define HK_DRAW "A-B" 115# define HK_DRAW "A-B"
116# define HK_REM2CUR "PLAY+LEFT" 116# define HK_REM2CUR "PLAY+LEFT"
117# define HK_CUR2STACK "NAVI" 117# define HK_CUR2STACK "NAVI.."
118# define HK_REM2STACK "PLAY+RIGHT" 118# define HK_REM2STACK "PLAY+RIGHT"
119 119
120#elif (CONFIG_KEYPAD == IPOD_4G_PAD) ||(CONFIG_KEYPAD == IPOD_3G_PAD) 120#elif (CONFIG_KEYPAD == IPOD_4G_PAD) ||(CONFIG_KEYPAD == IPOD_3G_PAD)
121# define SOL_QUIT (BUTTON_SELECT | BUTTON_MENU) 121# define SOL_QUIT (BUTTON_SELECT | BUTTON_MENU)
122# define SOL_UP BUTTON_MENU 122# define SOL_UP BUTTON_SCROLL_BACK
123# define SOL_DOWN BUTTON_PLAY 123# define SOL_DOWN BUTTON_SCROLL_FWD
124# define SOL_LEFT BUTTON_LEFT 124# define SOL_LEFT_PRE BUTTON_LEFT
125# define SOL_RIGHT BUTTON_RIGHT 125# define SOL_LEFT (BUTTON_LEFT | BUTTON_REL)
126# define SOL_MOVE BUTTON_SELECT 126# define SOL_RIGHT_PRE BUTTON_RIGHT
127# define SOL_DRAW (BUTTON_SELECT | BUTTON_PLAY) 127# define SOL_RIGHT (BUTTON_RIGHT | BUTTON_REL)
128# define SOL_REM2CUR (BUTTON_SELECT | BUTTON_LEFT) 128# define SOL_MOVE_PRE BUTTON_SELECT
129# define SOL_CUR2STACK (BUTTON_SELECT | BUTTON_RIGHT) 129# define SOL_MOVE (BUTTON_SELECT | BUTTON_REL)
130# define SOL_REM2STACK (BUTTON_LEFT | BUTTON_RIGHT) 130# define SOL_DRAW_PRE BUTTON_MENU
131# define SOL_DRAW (BUTTON_MENU | BUTTON_REL)
132# define SOL_REM2CUR BUTTON_PLAY
133# define SOL_CUR2STACK_PRE BUTTON_MENU
134# define SOL_CUR2STACK (BUTTON_MENU | BUTTON_REPEAT)
135# define SOL_REM2STACK_PRE BUTTON_RIGHT
136# define SOL_REM2STACK (BUTTON_RIGHT | BUTTON_REPEAT)
131# define SOL_MENU_RUN BUTTON_SELECT 137# define SOL_MENU_RUN BUTTON_SELECT
138# define HK_UD "SROLL U/D"
132# define HK_MOVE "SELECT" 139# define HK_MOVE "SELECT"
133# define HK_DRAW "SELECT+PLAY" 140# define HK_DRAW "MENU"
134# define HK_REM2CUR "SELECT+LEFT" 141# define HK_REM2CUR "PLAY"
135# define HK_CUR2STACK "SELECT+RIGHT.." 142# define HK_CUR2STACK "MENU.."
136# define HK_REM2STACK "LEFT+RIGHT" 143# define HK_REM2STACK "RIGHT.."
137 144
138#elif (CONFIG_KEYPAD == IAUDIO_X5_PAD) 145#elif (CONFIG_KEYPAD == IAUDIO_X5_PAD)
139# define SOL_QUIT BUTTON_POWER 146# define SOL_QUIT BUTTON_POWER
@@ -147,10 +154,11 @@ static struct plugin_api* rb;
147# define SOL_CUR2STACK (BUTTON_REC | BUTTON_UP) 154# define SOL_CUR2STACK (BUTTON_REC | BUTTON_UP)
148# define SOL_REM2STACK (BUTTON_REC | BUTTON_DOWN) 155# define SOL_REM2STACK (BUTTON_REC | BUTTON_DOWN)
149# define SOL_MENU_RUN BUTTON_SELECT 156# define SOL_MENU_RUN BUTTON_SELECT
157# define SOL_MENU_RUN2 BUTTON_RIGHT
150# define HK_MOVE "MENU" 158# define HK_MOVE "MENU"
151# define HK_DRAW "PLAY" 159# define HK_DRAW "PLAY"
152# define HK_REM2CUR "REC+LEFT" 160# define HK_REM2CUR "REC+LEFT"
153# define HK_CUR2STACK "REC+UP.." 161# define HK_CUR2STACK "REC+UP"
154# define HK_REM2STACK "REC+DOWN" 162# define HK_REM2STACK "REC+DOWN"
155 163
156#elif (CONFIG_KEYPAD == GIGABEAT_PAD) 164#elif (CONFIG_KEYPAD == GIGABEAT_PAD)
@@ -196,25 +204,30 @@ static struct plugin_api* rb;
196# error "Unknown keypad" 204# error "Unknown keypad"
197#endif 205#endif
198 206
207#define HK_LR "LEFT/RIGHT"
208#ifndef HK_UD
209# define HK_UD "UP/DOWN"
210#endif
211
199/** 212/**
200 * Help strings 213 * Help strings
201 */ 214 */
202 215
203#define HELP_SOL_UP "UP: Move the cursor up in the column." 216static int helplines;
204#define HELP_SOL_DOWN "DOWN: Move the cursor down in the column." 217static int displaylines;
205#define HELP_SOL_LEFT "LEFT: Move the cursor to the previous column." 218
206#define HELP_SOL_RIGHT "RIGHT: Move the cursor to the next column." 219static char helptext[] =
207#define HELP_SOL_MOVE HK_MOVE \ 220 /* Use single spaces only! Close each line with one \0. */
208 ": Select cards, Move cards, reveal hidden cards ..." 221 "-- Navigation --\0"
209#define HELP_SOL_DRAW HK_DRAW \ 222 HK_LR ": Move the cursor to the previous/ next column.\0"
210 ": Un-select a card if it was selected. " \ 223 HK_UD ": Move the cursor up/ down in the column.\0"
211 "Else, draw new cards out of the remains' stack." 224 HK_MOVE ": Select cards, move cards, reveal hidden cards...\0"
212#define HELP_SOL_REM2CUR HK_REM2CUR \ 225 HK_DRAW ": Deselect a card if it was selected. Else draw new card(s) from the remains stack.\0"
213 ": Put the card on top of the remains' stack on top of the cursor." 226 "-- Shortcuts --\0"
214#define HELP_SOL_CUR2STACK HK_CUR2STACK \ 227 HK_REM2CUR ": Put the card on top of the remains stack on top of the cursor.\0"
215 ": Put the card under the cursor on one of the 4 final stacks." 228 HK_CUR2STACK ": Put the card under the cursor on one of the 4 final stacks.\0"
216#define HELP_SOL_REM2STACK HK_REM2STACK \ 229 HK_REM2STACK ": Put the card on top of the remains stack on one of the 4 final stacks.\0"
217 ": Put the card on top of the remains' stack on one of the 4 final stacks." 230;
218 231
219/** 232/**
220 * Misc constants, graphics and other defines 233 * Misc constants, graphics and other defines
@@ -445,53 +458,77 @@ static void draw_empty_stack( int s, int x, int y, bool cursor )
445 458
446/** 459/**
447 * Help 460 * Help
448 *
449 * TODO: the help menu should just list the key definitions. Asking the
450 * user to try all possible keys/key combos is just counter
451 * productive.
452 */ 461 */
453 462
463static void init_help(void)
464{
465 int lines = 0;
466 int w_space, w, h;
467 int para_len;
468 char *para = helptext;
469
470 rb->lcd_getstringsize(" ", &w_space, &h);
471 displaylines = LCD_HEIGHT / h;
472 para_len = rb->strlen(para);
473
474 while (para_len)
475 {
476 bool first = true;
477 int x = 0;
478 char *next, *store;
479
480 next = rb->strtok_r(para, " ", &store);
481 while (next)
482 {
483 rb->lcd_getstringsize(next, &w, NULL);
484 if (!first)
485 {
486 if (x + w > LCD_WIDTH)
487 {
488 lines++;
489 x = 0;
490 }
491 else
492 next[-1] = ' '; /* re-concatenate string */
493 }
494 else
495 first = false;
496
497 x += w + w_space;
498 next = rb->strtok_r(NULL, " ", &store);
499 }
500
501 lines++;
502 para += para_len + 1;
503 para_len = rb->strlen(para);
504 }
505 helplines = lines;
506}
507
454enum help { HELP_QUIT, HELP_USB }; 508enum help { HELP_QUIT, HELP_USB };
455 509
456/* help for the not so intuitive interface */ 510/* help for the not so intuitive interface */
457enum help solitaire_help( void ) 511enum help solitaire_help( void )
458{ 512{
459 513 int start = 0;
460 int button; 514 int button;
461 int lastbutton = BUTTON_NONE; 515 int lastbutton = BUTTON_NONE;
516 bool fixed = (displaylines >= helplines);
462 517
463 while( true ) 518 while( true )
464 { 519 {
465 rb->lcd_clear_display(); 520 char *text = helptext;
521 int line = fixed ? (displaylines - helplines) / 2 : 0;
522 int i;
466 523
467#if CONFIG_KEYPAD == RECORDER_PAD 524 rb->lcd_clear_display();
468 rb->lcd_putsxy(0, 0, "Press a key to see");
469 rb->lcd_putsxy(0, 7, "it's role.");
470 rb->lcd_putsxy(0, 21, "Press OFF to");
471 rb->lcd_putsxy(0, 28, "return to menu.");
472 rb->lcd_putsxy(0, 42, "All actions can");
473 rb->lcd_putsxy(0, 49, "be done using");
474 rb->lcd_putsxy(0, 56, "arrows, ON and F2.");
475#elif CONFIG_KEYPAD == ONDIO_PAD
476 rb->lcd_putsxy(0, 0, "Press a key short");
477 rb->lcd_putsxy(0, 7, "or long to see it's");
478 rb->lcd_putsxy(0, 21, "role. Press OFF to");
479 rb->lcd_putsxy(0, 28, "return to menu.");
480 rb->lcd_putsxy(0, 42, "All actions can be");
481 rb->lcd_putsxy(0, 49, "done using arrows,");
482 rb->lcd_putsxy(0, 56, "short & long MODE.");
483#elif CONFIG_KEYPAD == IRIVER_H100_PAD
484 rb->lcd_putsxy(20, 8, "Press a key or key");
485 rb->lcd_putsxy(20, 16, "combo to see it's");
486 rb->lcd_putsxy(20, 24, "role. Press STOP to");
487 rb->lcd_putsxy(20, 32, "return to menu.");
488 rb->lcd_putsxy(20, 48, "All actions can be");
489 rb->lcd_putsxy(20, 56, "done using the");
490 rb->lcd_putsxy(20, 64, "joystick and A-B.");
491#else
492//# warning "Add help strings for other keypads"
493#endif
494 525
526 for (i = 0; i < start + displaylines; i++)
527 {
528 if (i >= start)
529 rb->lcd_puts(0, line++, text);
530 text += rb->strlen(text) + 1;
531 }
495 rb->lcd_update(); 532 rb->lcd_update();
496 533
497 button = rb->button_get( true ); 534 button = rb->button_get( true );
@@ -501,73 +538,24 @@ enum help solitaire_help( void )
501#ifdef SOL_UP_PRE 538#ifdef SOL_UP_PRE
502 if( lastbutton != SOL_UP_PRE ) 539 if( lastbutton != SOL_UP_PRE )
503 break; 540 break;
541#else
542 case SOL_UP|BUTTON_REPEAT:
504#endif 543#endif
505 rb->splash( HZ*2, true, HELP_SOL_UP ); 544 if (!fixed && start > 0)
545 start--;
506 break; 546 break;
507 547
508 case SOL_DOWN: 548 case SOL_DOWN:
509#ifdef SOL_DOWN_PRE 549#ifdef SOL_DOWN_PRE
510 if( lastbutton != SOL_DOWN_PRE ) 550 if( lastbutton != SOL_DOWN_PRE )
511 break; 551 break;
552#else
553 case SOL_DOWN|BUTTON_REPEAT:
512#endif 554#endif
513 rb->splash( HZ*2, true, HELP_SOL_DOWN ); 555 if (!fixed && start < helplines - displaylines)
514 break; 556 start++;
515
516 case SOL_LEFT:
517#ifdef SOL_LEFT_PRE
518 if( lastbutton != SOL_LEFT_PRE )
519 break;
520#endif
521 rb->splash( HZ*2, true, HELP_SOL_LEFT );
522 break;
523
524 case SOL_RIGHT:
525#ifdef SOL_RIGHT_PRE
526 if( lastbutton != SOL_RIGHT_PRE )
527 break;
528#endif
529 rb->splash( HZ*2, true, HELP_SOL_RIGHT );
530 break;
531
532 case SOL_MOVE:
533#ifdef SOL_MOVE_PRE
534 if( lastbutton != SOL_MOVE_PRE )
535 break;
536#endif
537 rb->splash( HZ*2, true, HELP_SOL_MOVE );
538 break;
539
540 case SOL_DRAW:
541#ifdef SOL_DRAW_PRE
542 if( lastbutton != SOL_DRAW_PRE )
543 break;
544#endif
545 rb->splash( HZ*2, true, HELP_SOL_DRAW );
546 break;
547
548 case SOL_CUR2STACK:
549#ifdef SOL_CUR2STACK_PRE
550 if( lastbutton != SOL_CUR2STACK_PRE )
551 break;
552#endif
553 rb->splash( HZ*2, true, HELP_SOL_CUR2STACK );
554 break;
555
556 case SOL_REM2STACK:
557#ifdef SOL_REM2STACK_PRE
558 if( lastbutton != SOL_REM2STACK_PRE )
559 break;
560#endif
561 rb->splash( HZ*2, true, HELP_SOL_REM2STACK );
562 break; 557 break;
563 558
564 case SOL_REM2CUR:
565#ifdef SOL_REM2CUR_PRE
566 if( lastbutton != SOL_REM2CUR_PRE )
567 break;
568#endif
569 rb->splash( HZ*2, true, HELP_SOL_REM2CUR );
570 break;
571#ifdef SOL_RC_QUIT 559#ifdef SOL_RC_QUIT
572 case SOL_RC_QUIT: 560 case SOL_RC_QUIT:
573#endif 561#endif
@@ -675,10 +663,16 @@ int solitaire_menu( unsigned char context )
675 switch( button ) 663 switch( button )
676 { 664 {
677 case SOL_UP: 665 case SOL_UP:
666#ifndef SOL_UP_PRE
667 case SOL_UP|BUTTON_REPEAT:
668#endif
678 cursor = (cursor + MENU_LENGTH - 1)%MENU_LENGTH; 669 cursor = (cursor + MENU_LENGTH - 1)%MENU_LENGTH;
679 break; 670 break;
680 671
681 case SOL_DOWN: 672 case SOL_DOWN:
673#ifndef SOL_DOWN_PRE
674 case SOL_DOWN|BUTTON_REPEAT:
675#endif
682 cursor = (cursor + 1)%MENU_LENGTH; 676 cursor = (cursor + 1)%MENU_LENGTH;
683 break; 677 break;
684 678
@@ -1357,6 +1351,8 @@ int solitaire( void )
1357#ifdef SOL_DOWN_PRE 1351#ifdef SOL_DOWN_PRE
1358 if( lastbutton != SOL_DOWN_PRE ) 1352 if( lastbutton != SOL_DOWN_PRE )
1359 break; 1353 break;
1354#else
1355 case SOL_DOWN|BUTTON_REPEAT:
1360#endif 1356#endif
1361 if( cur_col >= COL_NUM ) 1357 if( cur_col >= COL_NUM )
1362 { 1358 {
@@ -1392,6 +1388,8 @@ int solitaire( void )
1392#ifdef SOL_UP_PRE 1388#ifdef SOL_UP_PRE
1393 if( lastbutton != SOL_UP_PRE ) 1389 if( lastbutton != SOL_UP_PRE )
1394 break; 1390 break;
1391#else
1392 case SOL_UP|BUTTON_REPEAT:
1395#endif 1393#endif
1396 if( cur_col >= COL_NUM ) 1394 if( cur_col >= COL_NUM )
1397 { 1395 {
@@ -1617,6 +1615,8 @@ enum plugin_status plugin_start( struct plugin_api* api, void* parameter )
1617 configfile_init(rb); 1615 configfile_init(rb);
1618 configfile_load(CONFIG_FILENAME, config, 1, 0); 1616 configfile_load(CONFIG_FILENAME, config, 1, 0);
1619 draw_type = draw_type_disk; 1617 draw_type = draw_type_disk;
1618
1619 init_help();
1620 1620
1621 /* play the game :) 1621 /* play the game :)
1622 * Keep playing if a game was won (that means display the menu after 1622 * Keep playing if a game was won (that means display the menu after