diff --git a/include/gui.h b/include/gui.h index a1b00714f..c02f73939 100644 --- a/include/gui.h +++ b/include/gui.h @@ -57,6 +57,7 @@ extern int guiFrameId; #define GUI_SCREEN_MENU 1 #define GUI_SCREEN_INFO 2 #define GUI_SCREEN_GAME_MENU 3 +#define GUI_SCREEN_APP_MENU 4 void guiSwitchScreen(int target); diff --git a/include/lang.h b/include/lang.h index 9e137c585..29b99594a 100644 --- a/include/lang.h +++ b/include/lang.h @@ -269,7 +269,7 @@ enum _STR_IDS { _STR_CACHE_HDD_GAME_LIST, _STR_ENABLE_NOTIFICATIONS, _STR_NOTIFICATIONS, - _STR_GAME_MENU, + _STR_OPTIONS, _STR_GAME_SETTINGS_SAVED, _STR_GAME_SETTINGS_REMOVED, _STR_NET_UPDATE_HINT, diff --git a/include/menusys.h b/include/menusys.h index 2b5681851..83ac4a755 100644 --- a/include/menusys.h +++ b/include/menusys.h @@ -83,6 +83,7 @@ void menuInit(); void menuEnd(); void menuReinitMainMenu(void); void menuInitGameMenu(void); +void menuInitAppMenu(void); void menuAppendItem(menu_item_t *item); @@ -102,10 +103,12 @@ void menuRenderMain(); void menuRenderMenu(); void menuRenderInfo(); void menuRenderGameMenu(); +void menuRenderAppMenu(); void menuHandleInputMain(); void menuHandleInputMenu(); void menuHandleInputInfo(); void menuHandleInputGameMenu(); +void menuHandleInputAppMenu(); // Sets the selected item if it is found in the menu list void menuSetSelectedItem(menu_item_t *item); diff --git a/lng/lang_English.lng b/lng/lang_English.lng index eb41908eb..98b5e53f1 100644 --- a/lng/lang_English.lng +++ b/lng/lang_English.lng @@ -286,7 +286,7 @@ Confirm video mode change? Cache Game List (HDD) Enable Notifications %s loaded from %s -Game Menu +Options Game settings saved. %s settings removed. Overwrites existing game compatibility settings when enabled. diff --git a/src/gui.c b/src/gui.c index 3bff5848e..c97003c35 100644 --- a/src/gui.c +++ b/src/gui.c @@ -85,7 +85,8 @@ typedef struct static gui_screen_handler_t screenHandlers[] = {{&menuHandleInputMain, &menuRenderMain, 0}, {&menuHandleInputMenu, &menuRenderMenu, 1}, {&menuHandleInputInfo, &menuRenderInfo, 1}, - {&menuHandleInputGameMenu, &menuRenderGameMenu, 1}}; + {&menuHandleInputGameMenu, &menuRenderGameMenu, 1}, + {&menuHandleInputAppMenu, &menuRenderAppMenu, 1}}; // default screen handler (menu screen) static gui_screen_handler_t *screenHandler = &screenHandlers[GUI_SCREEN_MENU]; diff --git a/src/lang.c b/src/lang.c index 732860842..22b833990 100644 --- a/src/lang.c +++ b/src/lang.c @@ -272,7 +272,7 @@ static char *internalEnglish[LANG_STR_COUNT] = { "Cache Game List (HDD)", "Enable Notifications", "%s loaded from %s", - "Game Menu", + "Options", "Game settings saved.", "%s settings removed.", "Overwrites existing game compatibility settings when enabled.", diff --git a/src/menusys.c b/src/menusys.c index c6be68b13..d85eac385 100644 --- a/src/menusys.c +++ b/src/menusys.c @@ -68,10 +68,13 @@ static submenu_list_t *gameMenu; // active item in game settings static submenu_list_t *gameMenuCurrent; +static submenu_list_t *appMenu; +static submenu_list_t *appMenuCurrent; + static s32 menuSemaId; static ee_sema_t menuSema; -static void menuRenameGame(void) +static void menuRenameGame(submenu_list_t **submenu) { if (!selected_item->item->current) { return; @@ -91,7 +94,7 @@ static void menuRenameGame(void) strncpy(newName, selected_item->item->current->item.text, nameLength); if (guiShowKeyboard(newName, nameLength)) { guiSwitchScreen(GUI_SCREEN_MAIN); - submenuDestroy(&gameMenu); + submenuDestroy(submenu); support->itemRename(selected_item->item->current->item.id, newName); ioPutRequest(IO_MENU_UPDATE_DEFFERED, &support->mode); } @@ -101,7 +104,7 @@ static void menuRenameGame(void) guiMsgBox("NULL Support object. Please report", 0, NULL); } -static void menuDeleteGame(void) +static void menuDeleteGame(submenu_list_t **submenu) { if (!selected_item->item->current) return; @@ -116,7 +119,7 @@ static void menuDeleteGame(void) if (menuCheckParentalLock() == 0) { if (guiMsgBox(_l(_STR_DELETE_WARNING), 1, NULL)) { guiSwitchScreen(GUI_SCREEN_MAIN); - submenuDestroy(&gameMenu); + submenuDestroy(submenu); support->itemDelete(selected_item->item->current->item.id); ioPutRequest(IO_MENU_UPDATE_DEFFERED, &support->mode); } @@ -244,6 +247,18 @@ void menuInitGameMenu(void) gameMenuCurrent = gameMenu; } +void menuInitAppMenu(void) +{ + if (appMenu) + submenuDestroy(&appMenu); + + // initialize the menu + submenuAppendItem(&appMenu, -1, NULL, 0, _STR_RENAME); + submenuAppendItem(&appMenu, -1, NULL, 1, _STR_DELETE); + + appMenuCurrent = appMenu; +} + // ------------------------------------------------------------------------------------------- // ---------------------------------------- Menu manipulation -------------------------------- // ------------------------------------------------------------------------------------------- @@ -257,6 +272,8 @@ void menuInit() mainMenuCurrent = NULL; gameMenu = NULL; gameMenuCurrent = NULL; + appMenu = NULL; + appMenuCurrent = NULL; menuInitMainMenu(); menuSema.init_count = 1; @@ -284,6 +301,7 @@ void menuEnd() submenuDestroy(&mainMenu); submenuDestroy(&gameMenu); + submenuDestroy(&appMenu); if (itemConfig) { configFree(itemConfig); @@ -1060,9 +1078,88 @@ void menuHandleInputGameMenu() guiGameLoadConfig(selected_item->item->userdata, gameMenuLoadConfig(NULL)); } } else if (menuID == GAME_RENAME_GAME) { - menuRenameGame(); + menuRenameGame(&gameMenu); } else if (menuID == GAME_DELETE_GAME) { - menuDeleteGame(); + menuDeleteGame(&gameMenu); + } + // so the exit press wont propagate twice + readPads(); + } + + if (getKeyOn(KEY_START) || getKeyOn(gSelectButton == KEY_CIRCLE ? KEY_CROSS : KEY_CIRCLE)) { + guiSwitchScreen(GUI_SCREEN_MAIN); + } +} + +void menuRenderAppMenu() +{ + guiDrawBGPlasma(); + + if (!appMenu) + return; + + // draw the animated menu + if (!appMenuCurrent) + appMenuCurrent = appMenu; + + submenu_list_t *it = appMenu; + + // calculate the number of items + int count = 0; + int sitem = 0; + for (; it; count++, it = it->next) { + if (it == appMenuCurrent) + sitem = count; + } + + int spacing = 25; + int y = (gTheme->usedHeight >> 1) - (spacing * (count >> 1)); + int cp = 0; // current position + for (it = appMenu; it; it = it->next, cp++) { + // render, advance + fntRenderString(gTheme->fonts[0], 320, y, ALIGN_CENTER, 0, 0, submenuItemGetText(&it->item), (cp == sitem) ? gTheme->selTextColor : gTheme->textColor); + y += spacing; + } + + //hints + guiDrawSubMenuHints(); +} + +void menuHandleInputAppMenu() +{ + if (!appMenu) + return; + + if (!appMenuCurrent) + appMenuCurrent = appMenu; + + if (getKey(KEY_UP)) { + sfxPlay(SFX_CURSOR); + if (appMenuCurrent->prev) + appMenuCurrent = appMenuCurrent->prev; + else // rewind to the last item + while (appMenuCurrent->next) + appMenuCurrent = appMenuCurrent->next; + } + + if (getKey(KEY_DOWN)) { + sfxPlay(SFX_CURSOR); + if (appMenuCurrent->next) + appMenuCurrent = appMenuCurrent->next; + else + appMenuCurrent = appMenu; + } + + if (getKeyOn(gSelectButton)) { + // execute the item via looking at the id of it + int menuID = appMenuCurrent->item.id; + + sfxPlay(SFX_CONFIRM); + + if (menuID == 0) { + menuRenameGame(&appMenu); + } else if (menuID == 1) { + menuDeleteGame(&appMenu); } // so the exit press wont propagate twice readPads(); diff --git a/src/opl.c b/src/opl.c index 8ac771c5f..99c3b1066 100644 --- a/src/opl.c +++ b/src/opl.c @@ -215,8 +215,8 @@ void moduleUpdateMenu(int mode, int themeChanged, int langChanged) if (gTheme->infoElems.first) menuAddHint(&mod->menuItem, _STR_INFO, SQUARE_ICON); - if (!(mod->support->flags & MODE_FLAG_NO_COMPAT)) - menuAddHint(&mod->menuItem, _STR_GAME_MENU, TRIANGLE_ICON); + if (!(mod->support->flags & MODE_FLAG_NO_COMPAT) || gEnableWrite) + menuAddHint(&mod->menuItem, _STR_OPTIONS, TRIANGLE_ICON); menuAddHint(&mod->menuItem, _STR_REFRESH, SELECT_ICON); } @@ -292,6 +292,11 @@ static void itemExecTriangle(struct menu_item *curMenu) guiSwitchScreen(GUI_SCREEN_GAME_MENU); guiGameLoadConfig(support, gameMenuLoadConfig(NULL)); } + } else { + if (menuCheckParentalLock() == 0 && gEnableWrite) { + menuInitAppMenu(); + guiSwitchScreen(GUI_SCREEN_APP_MENU); + } } } else guiMsgBox("NULL Support object. Please report", 0, NULL);