From 796ba3ed767a9a50bf183bc0aefb7220d4ca0460 Mon Sep 17 00:00:00 2001 From: Teruaki Kawashima Date: Tue, 12 Oct 2010 13:56:54 +0000 Subject: fix FS#11659. wait for user input before exiting the plugin. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28253 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/boomshine.lua | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'apps') diff --git a/apps/plugins/boomshine.lua b/apps/plugins/boomshine.lua index c160fddf0d..0d0f9c518a 100644 --- a/apps/plugins/boomshine.lua +++ b/apps/plugins/boomshine.lua @@ -313,7 +313,7 @@ function start_round(level, goal, nrBalls, total) end -- Helper function to display a message -function display_message(...) +function display_message(to, ...) local message = string.format(...) local _, w, h = rb.font_getstringsize(message, rb.FONT_UI) local x, y = (rb.LCD_WIDTH - w) / 2, (rb.LCD_HEIGHT - h) / 2 @@ -321,13 +321,29 @@ function display_message(...) rb.lcd_clear_display() set_foreground(DEFAULT_FOREGROUND_COLOR) if w > rb.LCD_WIDTH then - rb.lcd_puts_scroll(x/w, y/h, message) + rb.lcd_puts_scroll(0, y/h, message) else rb.lcd_putsxy(x, y, message) end + if to == -1 then + local msg = "Press button to exit" + w = rb.font_getstringsize(msg, rb.FONT_UI) + x = (rb.LCD_WIDTH - w) / 2 + if x < 0 then + rb.lcd_puts_scroll(0, y/h + 1, msg) + else + rb.lcd_putsxy(x, y + h, msg) + end + end rb.lcd_update() - rb.sleep(rb.HZ * 2) + if to == -1 then + rb.sleep(rb.HZ/2) + rb.button_clear_queue() + rb.button_get(1) + else + rb.sleep(to) + end rb.lcd_stop_scroll() -- Stop our scrolling message end @@ -341,26 +357,26 @@ local idx, highscore = 1, 0 while levels[idx] ~= nil do local goal, nrBalls = levels[idx][1], levels[idx][2] - display_message("Level %d: get %d out of %d balls", idx, goal, nrBalls) + display_message(rb.HZ*2, "Level %d: get %d out of %d balls", idx, goal, nrBalls) local exit, score, nrExpandedBalls = start_round(idx, goal, nrBalls, highscore) if exit then break -- Exiting.. else if nrExpandedBalls >= goal then - display_message("You won!") + display_message(rb.HZ*2, "You won!") idx = idx + 1 highscore = highscore + score else - display_message("You lost!") + display_message(rb.HZ*2, "You lost!") end end end if idx > #levels then - display_message("You finished the game with %d points!", highscore) + display_message(-1, "You finished the game with %d points!", highscore) else - display_message("You made it till level %d with %d points!", idx, highscore) + display_message(-1, "You made it till level %d with %d points!", idx, highscore) end -- Restore user backlight settings -- cgit v1.2.3