diff options
Diffstat (limited to 'apps/plugins/puzzles/rockbox.c')
-rw-r--r-- | apps/plugins/puzzles/rockbox.c | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/apps/plugins/puzzles/rockbox.c b/apps/plugins/puzzles/rockbox.c index 27005a447d..27060208fc 100644 --- a/apps/plugins/puzzles/rockbox.c +++ b/apps/plugins/puzzles/rockbox.c | |||
@@ -322,6 +322,7 @@ static struct viewport clip_rect; | |||
322 | static bool clipped = false, zoom_enabled = false, view_mode = true, mouse_mode = false; | 322 | static bool clipped = false, zoom_enabled = false, view_mode = true, mouse_mode = false; |
323 | 323 | ||
324 | static int mouse_x, mouse_y; | 324 | static int mouse_x, mouse_y; |
325 | static bool mouse_dragging = false; /* for sticky mode only */ | ||
325 | 326 | ||
326 | extern bool audiobuf_available; /* defined in rbmalloc.c */ | 327 | extern bool audiobuf_available; /* defined in rbmalloc.c */ |
327 | 328 | ||
@@ -346,6 +347,7 @@ static struct { | |||
346 | bool ignore_repeats; /* ignore repeated button events (currently in all games but Untangle) */ | 347 | bool ignore_repeats; /* ignore repeated button events (currently in all games but Untangle) */ |
347 | bool rclick_on_hold; /* if in mouse mode, send right-click on long-press of select */ | 348 | bool rclick_on_hold; /* if in mouse mode, send right-click on long-press of select */ |
348 | bool numerical_chooser; /* repurpose select to activate a numerical chooser */ | 349 | bool numerical_chooser; /* repurpose select to activate a numerical chooser */ |
350 | bool sticky_mouse; /* if mouse left button should be persistent and toggled on/off */ | ||
349 | } input_settings; | 351 | } input_settings; |
350 | 352 | ||
351 | static bool accept_input = true; | 353 | static bool accept_input = true; |
@@ -748,7 +750,8 @@ static void rb_color(int n) | |||
748 | fatal("bad color %d", n); | 750 | fatal("bad color %d", n); |
749 | return; | 751 | return; |
750 | } | 752 | } |
751 | rb->lcd_set_foreground(colors[n]); | 753 | if(colors) |
754 | rb->lcd_set_foreground(colors[n]); | ||
752 | } | 755 | } |
753 | 756 | ||
754 | /* clipping is implemented through viewports and offsetting | 757 | /* clipping is implemented through viewports and offsetting |
@@ -1284,7 +1287,8 @@ static void draw_title(bool clear_first) | |||
1284 | rb->lcd_setfont(cur_font = FONT_UI); | 1287 | rb->lcd_setfont(cur_font = FONT_UI); |
1285 | rb->lcd_getstringsize(str, &w, &h); | 1288 | rb->lcd_getstringsize(str, &w, &h); |
1286 | 1289 | ||
1287 | rb->lcd_set_foreground(BG_COLOR); | 1290 | |
1291 | rb->lcd_set_foreground(colors ? colors[0] : BG_COLOR); | ||
1288 | rb->lcd_fillrect(0, LCD_HEIGHT - h, clear_first ? LCD_WIDTH : w, h); | 1292 | rb->lcd_fillrect(0, LCD_HEIGHT - h, clear_first ? LCD_WIDTH : w, h); |
1289 | 1293 | ||
1290 | rb->lcd_set_drawmode(DRMODE_FG); | 1294 | rb->lcd_set_drawmode(DRMODE_FG); |
@@ -1682,9 +1686,17 @@ static int process_input(int tmo, bool do_pausemenu) | |||
1682 | LOGF("sending left click"); | 1686 | LOGF("sending left click"); |
1683 | send_click(LEFT_BUTTON, true); /* right-click is handled earlier */ | 1687 | send_click(LEFT_BUTTON, true); /* right-click is handled earlier */ |
1684 | } | 1688 | } |
1685 | } | 1689 | } else if(input_settings.sticky_mouse) { |
1686 | else | 1690 | if(pressed & BTN_FIRE) { |
1687 | { | 1691 | send_click(LEFT_BUTTON, false); |
1692 | accept_input = false; | ||
1693 | mouse_dragging = !mouse_dragging; | ||
1694 | } else if(mouse_dragging) { | ||
1695 | send_click(LEFT_DRAG, false); | ||
1696 | } else { | ||
1697 | send_click(LEFT_RELEASE, false); | ||
1698 | } | ||
1699 | } else { | ||
1688 | if(pressed & BTN_FIRE) { | 1700 | if(pressed & BTN_FIRE) { |
1689 | send_click(LEFT_BUTTON, false); | 1701 | send_click(LEFT_BUTTON, false); |
1690 | accept_input = false; | 1702 | accept_input = false; |
@@ -2482,6 +2494,7 @@ static bool presets_menu(void) | |||
2482 | 2494 | ||
2483 | static void quick_help(void) | 2495 | static void quick_help(void) |
2484 | { | 2496 | { |
2497 | #ifndef NO_HELP_TEXT | ||
2485 | #if defined(FOR_REAL) && defined(DEBUG_MENU) | 2498 | #if defined(FOR_REAL) && defined(DEBUG_MENU) |
2486 | if(++help_times >= 5) | 2499 | if(++help_times >= 5) |
2487 | { | 2500 | { |
@@ -2492,11 +2505,12 @@ static void quick_help(void) | |||
2492 | 2505 | ||
2493 | rb->splash(0, quick_help_text); | 2506 | rb->splash(0, quick_help_text); |
2494 | rb->button_get(true); | 2507 | rb->button_get(true); |
2495 | return; | 2508 | #endif |
2496 | } | 2509 | } |
2497 | 2510 | ||
2498 | static void full_help(const char *name) | 2511 | static void full_help(const char *name) |
2499 | { | 2512 | { |
2513 | #ifndef NO_HELP_TEXT | ||
2500 | unsigned old_bg = rb->lcd_get_background(); | 2514 | unsigned old_bg = rb->lcd_get_background(); |
2501 | 2515 | ||
2502 | bool orig_clipped = clipped; | 2516 | bool orig_clipped = clipped; |
@@ -2551,6 +2565,7 @@ static void full_help(const char *name) | |||
2551 | 2565 | ||
2552 | if(orig_clipped) | 2566 | if(orig_clipped) |
2553 | rb_clip(NULL, clip_rect.x, clip_rect.y, clip_rect.width, clip_rect.height); | 2567 | rb_clip(NULL, clip_rect.x, clip_rect.y, clip_rect.width, clip_rect.height); |
2568 | #endif | ||
2554 | } | 2569 | } |
2555 | 2570 | ||
2556 | static void init_default_settings(void) | 2571 | static void init_default_settings(void) |
@@ -2701,6 +2716,11 @@ static int pausemenu_cb(int action, | |||
2701 | if(!midend_which_game(me)->can_solve) | 2716 | if(!midend_which_game(me)->can_solve) |
2702 | return ACTION_EXIT_MENUITEM; | 2717 | return ACTION_EXIT_MENUITEM; |
2703 | break; | 2718 | break; |
2719 | case 7: | ||
2720 | case 8: | ||
2721 | if(!help_valid) | ||
2722 | return ACTION_EXIT_MENUITEM; | ||
2723 | break; | ||
2704 | case 9: | 2724 | case 9: |
2705 | if(audiobuf_available) | 2725 | if(audiobuf_available) |
2706 | break; | 2726 | break; |
@@ -2751,7 +2771,7 @@ static void reset_drawing(void) | |||
2751 | rb->lcd_set_viewport(NULL); | 2771 | rb->lcd_set_viewport(NULL); |
2752 | rb->lcd_set_backdrop(NULL); | 2772 | rb->lcd_set_backdrop(NULL); |
2753 | rb->lcd_set_foreground(LCD_BLACK); | 2773 | rb->lcd_set_foreground(LCD_BLACK); |
2754 | rb->lcd_set_background(BG_COLOR); | 2774 | rb->lcd_set_background(colors ? colors[0] : BG_COLOR); |
2755 | } | 2775 | } |
2756 | 2776 | ||
2757 | /* Make a new game, but tell the user through a splash so they don't | 2777 | /* Make a new game, but tell the user through a splash so they don't |
@@ -2876,7 +2896,7 @@ static int pause_menu(void) | |||
2876 | break; | 2896 | break; |
2877 | } | 2897 | } |
2878 | } | 2898 | } |
2879 | rb->lcd_set_background(BG_COLOR); | 2899 | rb->lcd_set_background(colors ? colors[0] : BG_COLOR); |
2880 | rb->lcd_clear_display(); | 2900 | rb->lcd_clear_display(); |
2881 | midend_force_redraw(me); | 2901 | midend_force_redraw(me); |
2882 | rb->lcd_update(); | 2902 | rb->lcd_update(); |
@@ -2923,6 +2943,7 @@ static void init_colors(void) | |||
2923 | float *floatcolors = midend_colors(me, &ncolors); | 2943 | float *floatcolors = midend_colors(me, &ncolors); |
2924 | 2944 | ||
2925 | /* convert them to packed RGB */ | 2945 | /* convert them to packed RGB */ |
2946 | sfree(colors); | ||
2926 | colors = smalloc(ncolors * sizeof(unsigned)); | 2947 | colors = smalloc(ncolors * sizeof(unsigned)); |
2927 | unsigned *ptr = colors; | 2948 | unsigned *ptr = colors; |
2928 | float *floatptr = floatcolors; | 2949 | float *floatptr = floatcolors; |
@@ -3007,6 +3028,7 @@ static void tune_input(const char *name) | |||
3007 | static const char *no_rclick_on_hold[] = { | 3028 | static const char *no_rclick_on_hold[] = { |
3008 | "Map", | 3029 | "Map", |
3009 | "Signpost", | 3030 | "Signpost", |
3031 | "Slide", | ||
3010 | "Untangle", | 3032 | "Untangle", |
3011 | NULL | 3033 | NULL |
3012 | }; | 3034 | }; |
@@ -3015,11 +3037,21 @@ static void tune_input(const char *name) | |||
3015 | 3037 | ||
3016 | static const char *mouse_games[] = { | 3038 | static const char *mouse_games[] = { |
3017 | "Loopy", | 3039 | "Loopy", |
3040 | "Slide", | ||
3018 | NULL | 3041 | NULL |
3019 | }; | 3042 | }; |
3020 | 3043 | ||
3021 | mouse_mode = string_in_list(name, mouse_games); | 3044 | mouse_mode = string_in_list(name, mouse_games); |
3022 | 3045 | ||
3046 | static const char *sticky_mouse_games[] = { | ||
3047 | "Map", | ||
3048 | "Signpost", | ||
3049 | "Slide", | ||
3050 | "Untangle", | ||
3051 | }; | ||
3052 | |||
3053 | input_settings.sticky_mouse = string_in_list(name, sticky_mouse_games); | ||
3054 | |||
3023 | static const char *number_chooser_games[] = { | 3055 | static const char *number_chooser_games[] = { |
3024 | "Filling", | 3056 | "Filling", |
3025 | "Keen", | 3057 | "Keen", |
@@ -3312,8 +3344,11 @@ static int mainmenu_cb(int action, | |||
3312 | if(!load_success) | 3344 | if(!load_success) |
3313 | return ACTION_EXIT_MENUITEM; | 3345 | return ACTION_EXIT_MENUITEM; |
3314 | break; | 3346 | break; |
3347 | case 2: | ||
3315 | case 3: | 3348 | case 3: |
3316 | break; | 3349 | if(!help_valid) |
3350 | return ACTION_EXIT_MENUITEM; | ||
3351 | break; | ||
3317 | case 4: | 3352 | case 4: |
3318 | if(audiobuf_available) | 3353 | if(audiobuf_available) |
3319 | break; | 3354 | break; |
@@ -3476,12 +3511,14 @@ static void puzzles_main(void) | |||
3476 | /* quit without saving */ | 3511 | /* quit without saving */ |
3477 | midend_free(me); | 3512 | midend_free(me); |
3478 | sfree(colors); | 3513 | sfree(colors); |
3514 | colors = NULL; | ||
3479 | return; | 3515 | return; |
3480 | case -3: | 3516 | case -3: |
3481 | /* save and quit */ | 3517 | /* save and quit */ |
3482 | save_game(); | 3518 | save_game(); |
3483 | midend_free(me); | 3519 | midend_free(me); |
3484 | sfree(colors); | 3520 | sfree(colors); |
3521 | colors = NULL; | ||
3485 | return; | 3522 | return; |
3486 | default: | 3523 | default: |
3487 | break; | 3524 | break; |
@@ -3511,6 +3548,7 @@ static void puzzles_main(void) | |||
3511 | rb->yield(); | 3548 | rb->yield(); |
3512 | } | 3549 | } |
3513 | sfree(colors); | 3550 | sfree(colors); |
3551 | colors = NULL; | ||
3514 | } | 3552 | } |
3515 | } | 3553 | } |
3516 | 3554 | ||