diff options
Diffstat (limited to 'apps/plugins/superdom.c')
-rw-r--r-- | apps/plugins/superdom.c | 53 |
1 files changed, 10 insertions, 43 deletions
diff --git a/apps/plugins/superdom.c b/apps/plugins/superdom.c index 80dd4f518b..1a44bad518 100644 --- a/apps/plugins/superdom.c +++ b/apps/plugins/superdom.c | |||
@@ -20,6 +20,7 @@ | |||
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include "plugin.h" | 21 | #include "plugin.h" |
22 | #include "lib/playback_control.h" | 22 | #include "lib/playback_control.h" |
23 | #include "lib/display_text.h" | ||
23 | PLUGIN_HEADER | 24 | PLUGIN_HEADER |
24 | 25 | ||
25 | extern const fb_data superdom_boarditems[]; | 26 | extern const fb_data superdom_boarditems[]; |
@@ -557,11 +558,9 @@ int settings_menu_function(void) { | |||
557 | 558 | ||
558 | static int do_help(void) { | 559 | static int do_help(void) { |
559 | int button; | 560 | int button; |
560 | int y = MARGIN, space_w, width, height; | 561 | #define WORDS (sizeof help_text / sizeof (char*)) |
561 | unsigned short x = MARGIN, i = 0; | 562 | static char* help_text[] = { |
562 | #define WORDS (sizeof instructions / sizeof (char*)) | 563 | "Super", "domination", "is", "a", "turn", "based", "strategy", "game,", |
563 | static char* instructions[] = { | ||
564 | "Super", "domination", "is", "a", "turn", "based", "strategy", "game,", | ||
565 | "where", "the", "aim", "is", "to", "overpower", "the", "computer", | 564 | "where", "the", "aim", "is", "to", "overpower", "the", "computer", |
566 | "player", "by", "taking", "their", "territory.", "", | 565 | "player", "by", "taking", "their", "territory.", "", |
567 | "Each", "year", "you", "are", "allocated", "an", "amount", "of", "cash", | 566 | "Each", "year", "you", "are", "allocated", "an", "amount", "of", "cash", |
@@ -572,49 +571,17 @@ static int do_help(void) { | |||
572 | "the", "ownership", "of", "adjacent", "tiles,", "and", "the", "type", | 571 | "the", "ownership", "of", "adjacent", "tiles,", "and", "the", "type", |
573 | "and", "number", "of", "troops", "on", "them.", | 572 | "and", "number", "of", "troops", "on", "them.", |
574 | }; | 573 | }; |
575 | rb->lcd_clear_display(); | ||
576 | rb->lcd_getstringsize(" ", &space_w, &height); | ||
577 | for (i = 0; i < WORDS; i++) { | ||
578 | rb->lcd_getstringsize(instructions[i], &width, NULL); | ||
579 | /* Skip to next line if the current one can't fit the word */ | ||
580 | if (x + width > LCD_WIDTH - MARGIN) { | ||
581 | x = MARGIN; | ||
582 | y += height; | ||
583 | } | ||
584 | /* .. or if the word is the empty string */ | ||
585 | if (rb->strcmp(instructions[i], "") == 0) { | ||
586 | x = MARGIN; | ||
587 | y += height; | ||
588 | continue; | ||
589 | } | ||
590 | /* We filled the screen */ | ||
591 | if (y + height > LCD_HEIGHT - MARGIN) { | ||
592 | y = MARGIN; | ||
593 | rb->lcd_update(); | ||
594 | do { | ||
595 | button = rb->button_get(true); | ||
596 | if (button == SYS_USB_CONNECTED) { | ||
597 | return PLUGIN_USB_CONNECTED; | ||
598 | } | ||
599 | } while( ( button == BUTTON_NONE ) | ||
600 | || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); | ||
601 | |||
602 | 574 | ||
603 | rb->lcd_clear_display(); | 575 | if (display_text(WORDS, help_text, NULL, NULL)) |
604 | } | 576 | return PLUGIN_USB_CONNECTED; |
605 | rb->lcd_putsxy(x, y, instructions[i]); | ||
606 | x += width + space_w; | ||
607 | } | ||
608 | rb->lcd_update(); | ||
609 | do { | 577 | do { |
610 | button = rb->button_get(true); | 578 | button = rb->button_get(true); |
611 | if (button == SYS_USB_CONNECTED) { | 579 | if ( rb->default_event_handler( button ) == SYS_USB_CONNECTED ) |
612 | return PLUGIN_USB_CONNECTED; | 580 | return PLUGIN_USB_CONNECTED; |
613 | } | ||
614 | } while( ( button == BUTTON_NONE ) | 581 | } while( ( button == BUTTON_NONE ) |
615 | || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); | 582 | || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); |
616 | 583 | ||
617 | return 0; | 584 | return PLUGIN_OK; |
618 | } | 585 | } |
619 | 586 | ||
620 | int menu(void) { | 587 | int menu(void) { |
@@ -661,7 +628,7 @@ int save_game(void) { | |||
661 | if(fd < 0) { | 628 | if(fd < 0) { |
662 | DEBUGF("Couldn't create/open file\n"); | 629 | DEBUGF("Couldn't create/open file\n"); |
663 | return -1; | 630 | return -1; |
664 | } | 631 | } |
665 | 632 | ||
666 | rb->write(fd, "SSGv3", 5); | 633 | rb->write(fd, "SSGv3", 5); |
667 | rb->write(fd, &gamestate, sizeof(gamestate)); | 634 | rb->write(fd, &gamestate, sizeof(gamestate)); |
@@ -1599,7 +1566,7 @@ int killmen(int colour) { | |||
1599 | } | 1566 | } |
1600 | } | 1567 | } |
1601 | } | 1568 | } |
1602 | 1569 | ||
1603 | if(human) | 1570 | if(human) |
1604 | humanres.men -= menkilled; | 1571 | humanres.men -= menkilled; |
1605 | else | 1572 | else |