/* * do_user_menu - create the user menu on the screen. * * Returns USER_MENU_QUIT if the user selected "quit", otherwise * returns zero. * * Note: this is the only non-static function in this file at the * moment. In the future I may turn do_menu/etc into a proper API, in * which case they'll be exposed as well. * */ int do_user_menu(void) { int mi, ret, num_items; bool done = false; /* set defaults */ ret = 0; /* return value */ mi = 0; /* initial menu selection */ num_items = sizeof(main_menu) / sizeof(char*); /* loop until we should exit menu */ while (!done) { /* get item selection */ mi = do_menu(MAIN_MENU_TITLE, (char**) main_menu, num_items, mi); /* handle selected menu item */ switch (mi) { case MM_ITEM_QUIT: ret = USER_MENU_QUIT; case MENU_CANCEL: case MM_ITEM_BACK: done = true; break; case MM_ITEM_LOAD: do_slot_menu(true); break; case MM_ITEM_SAVE: do_slot_menu(false); break; case MM_ITEM_OPT: do_opt_menu(); break; } } /* return somethin' */ return ret; }
/* * do_user_menu - create the user menu on the screen. * * Returns USER_MENU_QUIT if the user selected "quit", otherwise * returns zero. */ int do_user_menu(void) { bool done=false; int selected=0, ret=0; int result; int time = 0; #if CONFIG_RTC time = rb->mktime(rb->get_time()); #endif #if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256) rb->lcd_set_mode(LCD_MODE_RGB565); #endif /* Clean out the button Queue */ while (rb->button_get(false) != BUTTON_NONE) rb->yield(); MENUITEM_STRINGLIST(menu, "Rockboy Menu", NULL, "Load Game", "Save Game", "Options", "Quit"); pcm_init(); while(!done) { result = rb->do_menu(&menu, &selected, NULL, false); switch (result) { case 0: /* Load Game */ do_slot_menu(true); break; case 1: /* Save Game */ do_slot_menu(false); break; case 2: /* Options */ do_opt_menu(); break; case 3: /* Quit */ ret = USER_MENU_QUIT; done=true; break; default: done=true; break; } } rb->lcd_setfont(0); /* Reset the font */ rb->lcd_clear_display(); /* Clear display for screen size changes */ /* Keep the RTC in sync */ #if CONFIG_RTC time = (rb->mktime(rb->get_time()) - time) * 60; #endif while (time-- > 0) rtc_tick(); #if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256) rb->lcd_set_mode(LCD_MODE_PAL256); #endif return ret; }