]> Chaos Git - corbenik/corbenik.git/commitdiff
Add a pager/less mode to menus v0.1.0
authorchaoskagami <chaos.kagami@gmail.com>
Fri, 17 Jun 2016 19:44:00 +0000 (15:44 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Fri, 17 Jun 2016 19:44:00 +0000 (15:44 -0400)
source/display.c
source/menu.c

index 7a3bace410b9ccf24e07771fb11ce5f8fd997c62..bb7b71590679c0d80bf664519eb4f3322f8f813a 100644 (file)
@@ -25,6 +25,7 @@ show_menu(struct options_s *options, uint8_t *toggles)
     int exit = 0;
     int window_size = (TOP_HEIGHT / font_h) - 3;
     int window_top = 0, window_bottom = window_size;
+    int less_mode = 0;
 
     clear_screen(TOP_SCREEN);
 
@@ -49,17 +50,28 @@ show_menu(struct options_s *options, uint8_t *toggles)
                 --cursor_max;
         }
 
+        if (cursor_max == 0)
+            less_mode = 1; // Behave as a pager
+
         // Figure out the min if unset.
         if (cursor_min == -1) {
-            cursor_min = 0;
-            while (options[cursor_min].allowed == not_option)
-                ++cursor_min;
-            cursor_y = cursor_min;
+            if (less_mode == 1) {
+                cursor_max = 0;
+                while (options[cursor_max].index != -1)
+                    ++cursor_max;
+
+                cursor_min = 0;
+            } else {
+                cursor_min = 0;
+                while (options[cursor_min].allowed == not_option)
+                    ++cursor_min;
+                cursor_y = cursor_min;
+            }
         }
 
-        if (cursor_max == cursor_y && cursor_max == 0)
-            header("B:Back");
-        else if (cursor_max == cursor_y)
+        if (less_mode)
+            header("B:Back DPAD:Scroll");
+        else if (cursor_max == cursor_min)
             header("A:Enter B:Back");
         else
             header("A:Enter B:Back DPAD:Nav Select:Info");
@@ -106,31 +118,34 @@ show_menu(struct options_s *options, uint8_t *toggles)
                 if (cursor_min == cursor_max)
                     break;
                 cursor_y -= 1;
-                while ((options[cursor_y].allowed == not_option || (options[cursor_y].allowed == boolean_val_n3ds && !is_n3ds)) && cursor_y >= cursor_min)
+                while ((options[cursor_y].allowed == not_option || (options[cursor_y].allowed == boolean_val_n3ds && !is_n3ds)) && cursor_y >= cursor_min && !less_mode)
                     cursor_y--;
                 break;
             case BUTTON_DOWN:
                 if (cursor_min == cursor_max)
                     break;
                 cursor_y += 1;
-                while ((options[cursor_y].allowed == not_option || (options[cursor_y].allowed == boolean_val_n3ds && !is_n3ds)) && cursor_y < cursor_max)
+                while ((options[cursor_y].allowed == not_option || (options[cursor_y].allowed == boolean_val_n3ds && !is_n3ds)) && cursor_y < cursor_max && !less_mode)
                     cursor_y++;
                 break;
             case BUTTON_LEFT:
                 if (cursor_min == cursor_max)
                     break;
                 cursor_y -= 5;
-                while ((options[cursor_y].allowed == not_option || (options[cursor_y].allowed == boolean_val_n3ds && !is_n3ds)) && cursor_y >= cursor_min)
+                while ((options[cursor_y].allowed == not_option || (options[cursor_y].allowed == boolean_val_n3ds && !is_n3ds)) && cursor_y >= cursor_min && !less_mode)
                     cursor_y--;
                 break;
             case BUTTON_RIGHT:
                 if (cursor_min == cursor_max)
                     break;
                 cursor_y += 5;
-                while ((options[cursor_y].allowed == not_option || (options[cursor_y].allowed == boolean_val_n3ds && !is_n3ds)) && cursor_y < cursor_max)
+                while ((options[cursor_y].allowed == not_option || (options[cursor_y].allowed == boolean_val_n3ds && !is_n3ds)) && cursor_y < cursor_max && !less_mode)
                     cursor_y++;
                 break;
             case BUTTON_A:
+                if (less_mode)
+                    break;
+
                 if (options[cursor_y].allowed == boolean_val || options[cursor_y].allowed == boolean_val_n3ds) {
                     toggles[options[cursor_y].index] = !toggles[options[cursor_y].index];
                 } else if (options[cursor_y].allowed == ranged_val) {
index 87e9994fe16b644b46a0691c75367dd665b66c02..06a6738a6705e4670dd9ae9a4daaf2229edba8a9 100644 (file)
@@ -222,8 +222,6 @@ static struct options_s info_d[] = {
        { 0, "  AGB FIRM:    ", "The version of AGB_FIRM in use. This is used to run GBA games.", not_option, 0, 0},
        { 0, "  TWL FIRM:    ", "The version of TWL_FIRM in use. This is used to run DS games and DSiware.", not_option, 0, 0},
        { 0, "  Corbenik:    " VERSION " (" REL ")", "Corbenik's version.", not_option, 0, 0},
-       { 0, "", "", not_option, 0, 0},
-       { 0, "[OK]", "", break_menu, 0, 0 }, // Temporary
        { -1, "", "", not_option, 0, 0 }
 };
 static int is_setup_info = 0;
@@ -263,10 +261,8 @@ static struct options_s help_d[] = {
        ln("  @mid-kid, @Wolfvak, @Reisyukaku, @AuroraWright"),
        ln("  @d0k3, @TuxSH, @Steveice10, @delebile,"),
        ln("  @Normmatt, @b1l1s, @dark-samus, @TiniVi, etc"),
-       ln(""),
+    ln(""),
        ln("  <https://github.com/chaoskagami/corbenik>"),
-       ln(""),
-       { 0, "[OK]", "", break_menu, 0, 0 }, // Temporary
        { -1, "", "", not_option, 0, 0 }
 };