diff options
author | Teruaki Kawashima <teru@rockbox.org> | 2010-10-12 13:56:54 +0000 |
---|---|---|
committer | Teruaki Kawashima <teru@rockbox.org> | 2010-10-12 13:56:54 +0000 |
commit | 796ba3ed767a9a50bf183bc0aefb7220d4ca0460 (patch) | |
tree | 625ed0430777ee847d52a9c3d2d704663ce4aa8f /apps/plugins | |
parent | b2f5142601b73afc40c65cf0f78d3907861267a4 (diff) | |
download | rockbox-796ba3ed767a9a50bf183bc0aefb7220d4ca0460.tar.gz rockbox-796ba3ed767a9a50bf183bc0aefb7220d4ca0460.zip |
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
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/boomshine.lua | 32 |
1 files changed, 24 insertions, 8 deletions
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) | |||
313 | end | 313 | end |
314 | 314 | ||
315 | -- Helper function to display a message | 315 | -- Helper function to display a message |
316 | function display_message(...) | 316 | function display_message(to, ...) |
317 | local message = string.format(...) | 317 | local message = string.format(...) |
318 | local _, w, h = rb.font_getstringsize(message, rb.FONT_UI) | 318 | local _, w, h = rb.font_getstringsize(message, rb.FONT_UI) |
319 | local x, y = (rb.LCD_WIDTH - w) / 2, (rb.LCD_HEIGHT - h) / 2 | 319 | local x, y = (rb.LCD_WIDTH - w) / 2, (rb.LCD_HEIGHT - h) / 2 |
@@ -321,13 +321,29 @@ function display_message(...) | |||
321 | rb.lcd_clear_display() | 321 | rb.lcd_clear_display() |
322 | set_foreground(DEFAULT_FOREGROUND_COLOR) | 322 | set_foreground(DEFAULT_FOREGROUND_COLOR) |
323 | if w > rb.LCD_WIDTH then | 323 | if w > rb.LCD_WIDTH then |
324 | rb.lcd_puts_scroll(x/w, y/h, message) | 324 | rb.lcd_puts_scroll(0, y/h, message) |
325 | else | 325 | else |
326 | rb.lcd_putsxy(x, y, message) | 326 | rb.lcd_putsxy(x, y, message) |
327 | end | 327 | end |
328 | if to == -1 then | ||
329 | local msg = "Press button to exit" | ||
330 | w = rb.font_getstringsize(msg, rb.FONT_UI) | ||
331 | x = (rb.LCD_WIDTH - w) / 2 | ||
332 | if x < 0 then | ||
333 | rb.lcd_puts_scroll(0, y/h + 1, msg) | ||
334 | else | ||
335 | rb.lcd_putsxy(x, y + h, msg) | ||
336 | end | ||
337 | end | ||
328 | rb.lcd_update() | 338 | rb.lcd_update() |
329 | 339 | ||
330 | rb.sleep(rb.HZ * 2) | 340 | if to == -1 then |
341 | rb.sleep(rb.HZ/2) | ||
342 | rb.button_clear_queue() | ||
343 | rb.button_get(1) | ||
344 | else | ||
345 | rb.sleep(to) | ||
346 | end | ||
331 | 347 | ||
332 | rb.lcd_stop_scroll() -- Stop our scrolling message | 348 | rb.lcd_stop_scroll() -- Stop our scrolling message |
333 | end | 349 | end |
@@ -341,26 +357,26 @@ local idx, highscore = 1, 0 | |||
341 | while levels[idx] ~= nil do | 357 | while levels[idx] ~= nil do |
342 | local goal, nrBalls = levels[idx][1], levels[idx][2] | 358 | local goal, nrBalls = levels[idx][1], levels[idx][2] |
343 | 359 | ||
344 | display_message("Level %d: get %d out of %d balls", idx, goal, nrBalls) | 360 | display_message(rb.HZ*2, "Level %d: get %d out of %d balls", idx, goal, nrBalls) |
345 | 361 | ||
346 | local exit, score, nrExpandedBalls = start_round(idx, goal, nrBalls, highscore) | 362 | local exit, score, nrExpandedBalls = start_round(idx, goal, nrBalls, highscore) |
347 | if exit then | 363 | if exit then |
348 | break -- Exiting.. | 364 | break -- Exiting.. |
349 | else | 365 | else |
350 | if nrExpandedBalls >= goal then | 366 | if nrExpandedBalls >= goal then |
351 | display_message("You won!") | 367 | display_message(rb.HZ*2, "You won!") |
352 | idx = idx + 1 | 368 | idx = idx + 1 |
353 | highscore = highscore + score | 369 | highscore = highscore + score |
354 | else | 370 | else |
355 | display_message("You lost!") | 371 | display_message(rb.HZ*2, "You lost!") |
356 | end | 372 | end |
357 | end | 373 | end |
358 | end | 374 | end |
359 | 375 | ||
360 | if idx > #levels then | 376 | if idx > #levels then |
361 | display_message("You finished the game with %d points!", highscore) | 377 | display_message(-1, "You finished the game with %d points!", highscore) |
362 | else | 378 | else |
363 | display_message("You made it till level %d with %d points!", idx, highscore) | 379 | display_message(-1, "You made it till level %d with %d points!", idx, highscore) |
364 | end | 380 | end |
365 | 381 | ||
366 | -- Restore user backlight settings | 382 | -- Restore user backlight settings |