From 26500d5e2162affa6bf27c7574fca72bfcc1871a Mon Sep 17 00:00:00 2001 From: fgl82 Date: Sat, 22 Feb 2020 02:29:45 -0300 Subject: [PATCH] Universal dev (#60) * Adding New Pocket Go * Fixing relative size * Pushing SDL_Color to graphics.c to keep the code generic * Unused joystick * Tidying stuff up * Zooming Images to screen size * setting height for 2devices that use 320x240 * Changing footer for full screen mode * transparent footer * Fixing resolution for console and managing smoothing * Updating resources * Fixing indentation * Fixing full screen footer, adding the chance of not scaling and also scaling logos correctly * Fixing foter * Adding better navigation in full screen mode using shoulder buttons * Replacing images for rectangles, making fullscreen menu more compact and making logos be shown when pressing shoulder buttons while in FS mode * Better indication of total items per page, smaller fullscreen text, darker fullsceen background and showing logo while roms load in the background in fullscreen mode or hotkey mode * List branch (#54) * Universal dev (#49) * Adding New Pocket Go * Fixing relative size * Pushing SDL_Color to graphics.c to keep the code generic * Unused joystick * Tidying stuff up * Zooming Images to screen size * setting height for 2devices that use 320x240 * Changing footer for full screen mode * transparent footer * Fixing resolution for console and managing smoothing * Updating resources * Fixing indentation * Fixing full screen footer, adding the chance of not scaling and also scaling logos correctly * Fixing foter * Adding better navigation in full screen mode using shoulder buttons * Replacing images for rectangles, making fullscreen menu more compact and making logos be shown when pressing shoulder buttons while in FS mode * first commit of the list branch * Fixing memory leak * Adding numbers in full screen mode and making it display 12 games instead of 10 * Fixing favorites * Restoring execution * Setting 12 games per page when coming back to full screen and altering full screen text view * Fixing 12 games per page when comming back to full screen and altering text alignment in that mode * Fixing relative distance of text in full screen mode and ignoring triggers in favorites in full screen mode * Fixing how much text you can see in full screen * Fixing bugs and tuning fullscreen mode letter box * Better * Changing alpha navigation in fullscren mode * Fixing bugs * Showing the logo before loading the games * Fixing delete functionality * Improving fullscreen menu appearance when deleting games * Improving menu behavior in fullscreen mode * more tweaks * Keeping the strip roms state between sessions * POC for only highlighting letters that exist in the current rom list * Graying out letters in alpha nav, fullscreen * Fixing seg fault when exiting if showing the menu * Fixing showing favorites in the right spot, bad, bad code, but works * List branch (#56) * Universal dev (#49) * Adding New Pocket Go * Fixing relative size * Pushing SDL_Color to graphics.c to keep the code generic * Unused joystick * Tidying stuff up * Zooming Images to screen size * setting height for 2devices that use 320x240 * Changing footer for full screen mode * transparent footer * Fixing resolution for console and managing smoothing * Updating resources * Fixing indentation * Fixing full screen footer, adding the chance of not scaling and also scaling logos correctly * Fixing foter * Adding better navigation in full screen mode using shoulder buttons * Replacing images for rectangles, making fullscreen menu more compact and making logos be shown when pressing shoulder buttons while in FS mode * first commit of the list branch * Fixing memory leak * Adding numbers in full screen mode and making it display 12 games instead of 10 * Fixing favorites * Restoring execution * Setting 12 games per page when coming back to full screen and altering full screen text view * Fixing 12 games per page when comming back to full screen and altering text alignment in that mode * Fixing relative distance of text in full screen mode and ignoring triggers in favorites in full screen mode * Fixing how much text you can see in full screen * Fixing bugs and tuning fullscreen mode letter box * Better * Changing alpha navigation in fullscren mode * Fixing bugs * Showing the logo before loading the games * Fixing delete functionality * Improving fullscreen menu appearance when deleting games * Improving menu behavior in fullscreen mode * more tweaks * Keeping the strip roms state between sessions * POC for only highlighting letters that exist in the current rom list * Graying out letters in alpha nav, fullscreen * Fixing seg fault when exiting if showing the menu * Fixing showing favorites in the right spot, bad, bad code, but works * Fixing favrites bug, adding logo and imporving full screen mode * no idea * Making it fullscreen * whatever * List branch (#59) * first commit of the list branch * Fixing memory leak * Adding numbers in full screen mode and making it display 12 games instead of 10 * Fixing favorites * Restoring execution * Setting 12 games per page when coming back to full screen and altering full screen text view * Fixing 12 games per page when comming back to full screen and altering text alignment in that mode * Fixing relative distance of text in full screen mode and ignoring triggers in favorites in full screen mode * Fixing how much text you can see in full screen * Fixing bugs and tuning fullscreen mode letter box * Better * Changing alpha navigation in fullscren mode * Fixing bugs * Showing the logo before loading the games * Fixing delete functionality * Improving fullscreen menu appearance when deleting games * Improving menu behavior in fullscreen mode * more tweaks * Keeping the strip roms state between sessions * POC for only highlighting letters that exist in the current rom list * Graying out letters in alpha nav, fullscreen * Fixing seg fault when exiting if showing the menu * Fixing showing favorites in the right spot, bad, bad code, but works * Fixing favrites bug, adding logo and imporving full screen mode * no idea * Making it fullscreen * whatever * tweaks * Improving speed with less calls to getNthElement * Fixing scroll down * Fixing scroll up and down plus advance section * More fixes when changing page and loading * Fixing section switching * Fixing favorites * Fixing switching between fullscreen and menu mode * Fixing random select * Removing printfs * Fixing coming in and out of favorites in different modes * Fixing section switching in fullscreen mode * Fixing reintroduced bug when switching sections in different modes * Fixing section switching in fullscreen * Fixing favorites * Fixing favorites deletion * Configurable media folder --- simplemenu/Makefile | 4 +- simplemenu/src/headers/control.h | 1 + simplemenu/src/headers/globals.h | 8 +- simplemenu/src/headers/screen.h | 2 +- simplemenu/src/logic/config.c | 12 +- simplemenu/src/logic/control.c | 217 +++++++++++-------------- simplemenu/src/logic/control_bittboy.c | 42 +++-- simplemenu/src/logic/control_rg300.c | 14 +- simplemenu/src/logic/control_rg350.c | 72 ++++---- simplemenu/src/logic/graphics.c | 11 +- simplemenu/src/logic/logic.c | 58 +++---- simplemenu/src/logic/screen.c | 44 ++--- simplemenu/src/logic/simplemenu.c | 19 +-- 13 files changed, 238 insertions(+), 266 deletions(-) diff --git a/simplemenu/Makefile b/simplemenu/Makefile index 0b0bc858..4d1cd046 100644 --- a/simplemenu/Makefile +++ b/simplemenu/Makefile @@ -3,8 +3,8 @@ TARGET = simplemenu #PLATFORM = BITTBOY #PLATFORM = RG-300 #PLATFORM = RG-350 -#PLATFORM = NPG -PLATFORM = PC +PLATFORM = NPG +#PLATFORM = PC # Compiler diff --git a/simplemenu/src/headers/control.h b/simplemenu/src/headers/control.h index a9f0bea2..57e577e4 100644 --- a/simplemenu/src/headers/control.h +++ b/simplemenu/src/headers/control.h @@ -9,6 +9,7 @@ void launchGame(); void launchEmulator(); void scrollUp(); void scrollDown(); +void scrollToGame(int gameNumber); void advancePage(); void rewindPage(); void showOrHideFavorites(); diff --git a/simplemenu/src/headers/globals.h b/simplemenu/src/headers/globals.h index c201e316..43b177ca 100644 --- a/simplemenu/src/headers/globals.h +++ b/simplemenu/src/headers/globals.h @@ -12,6 +12,8 @@ int running; +char mediaFolder[100]; + int itsStoppedBecauseOfAnError; char *errorMessage; int thereIsACriticalError; @@ -27,7 +29,7 @@ int menuSectionCounter; int gamesInPage; int currentCPU; -int pictureMode; +int fullscreenMode; int hotKeyPressed; int currentlySectionSwitching; int currentlyChoosingEmulator; @@ -84,6 +86,7 @@ struct MenuSection { int realCurrentGameNumber; int alphabeticalPaging; int totalPages; + int gameCount; int initialized; int onlyFileNamesNoExtension; int headerAndFooterBackgroundColor[3]; @@ -92,14 +95,15 @@ struct MenuSection { int bodyTextColor[3]; int bodySelectedTextBackgroundColor[3]; int bodySelectedTextTextColor[3]; + struct Node* currentGameNode; struct Node *head; + struct Node *tail; hashtable_t *aliasHashTable; int activeExecutable; int activeEmulatorDirectory; char category[100]; }; -//struct Rom* currentGame; struct MenuSection menuSections[50]; diff --git a/simplemenu/src/headers/screen.h b/simplemenu/src/headers/screen.h index cc443fc2..e2af48bf 100644 --- a/simplemenu/src/headers/screen.h +++ b/simplemenu/src/headers/screen.h @@ -1,6 +1,6 @@ #ifndef SCREEN_DEFINED #define SCREEN_DEFINED -void updateScreen(); +void updateScreen(struct Rom *rom); void drawHeader(); void drawGameList(); void drawFooter(); diff --git a/simplemenu/src/logic/config.c b/simplemenu/src/logic/config.c index 652f3ead..35d850c3 100644 --- a/simplemenu/src/logic/config.c +++ b/simplemenu/src/logic/config.c @@ -154,7 +154,7 @@ void saveLastState() { snprintf(pathToStatesFilePlusFileName,sizeof(pathToStatesFilePlusFileName),"%s/.simplemenu/last_state.cfg",getenv("HOME")); fp = fopen(pathToStatesFilePlusFileName, "w"); fprintf(fp, "%d;\n", stripGames); - fprintf(fp, "%d;\n", pictureMode); + fprintf(fp, "%d;\n", fullscreenMode); fprintf(fp, "%d;\n", currentSectionNumber); for (currentSectionNumber=0;currentSectionNumbernext!=NULL&&strlen(currentNode->next->data->name)>0) { - CURRENT_SECTION.currentGameInPage++; +void scrollUp() { + CURRENT_SECTION.currentGameNode=CURRENT_SECTION.currentGameNode->prev; + //if at the first item of the first page + if (CURRENT_SECTION.currentGameNode==NULL) { + //go to the last page + CURRENT_SECTION.currentPage=CURRENT_SECTION.totalPages; + //go to the last game whether on the same page or not + if (CURRENT_SECTION.totalPages==0) { + CURRENT_SECTION.currentGameInPage=CURRENT_SECTION.gameCount-1; } else { - CURRENT_SECTION.currentPage=0; - CURRENT_SECTION.currentGameInPage=0; + if (CURRENT_SECTION.gameCount%(ITEMS_PER_PAGE)!=0) { + CURRENT_SECTION.currentGameInPage=(CURRENT_SECTION.gameCount%ITEMS_PER_PAGE)-1; + } else { + CURRENT_SECTION.currentGameInPage=ITEMS_PER_PAGE-1; + } } + //point to the last node + CURRENT_SECTION.currentGameNode=CURRENT_SECTION.tail; } else { - if (CURRENT_SECTION.currentPage < CURRENT_SECTION.totalPages) { - CURRENT_SECTION.currentPage++; + //it's a full page and not the first item + if (CURRENT_SECTION.currentGameInPage > 0) { + //decrease selected game + CURRENT_SECTION.currentGameInPage--; } else { - CURRENT_SECTION.currentPage=0; + //decrease page + CURRENT_SECTION.currentPage--; + //go to the last ekement of the page + CURRENT_SECTION.currentGameInPage=ITEMS_PER_PAGE-1; } + } + //establish real game number + CURRENT_SECTION.realCurrentGameNumber=CURRENT_GAME_NUMBER; +} + +void scrollDown() { + CURRENT_SECTION.currentGameNode=CURRENT_SECTION.currentGameNode->next; + // if at the end end of the list + if (CURRENT_SECTION.currentGameNode==NULL) { + //restart pages + CURRENT_SECTION.currentGameNode=CURRENT_SECTION.head; + CURRENT_SECTION.currentPage=0; CURRENT_SECTION.currentGameInPage=0; + } else { + // it's a filled page and not the last item + if (CURRENT_SECTION.currentGameInPage < ITEMS_PER_PAGE-1) { + // increase selected game + CURRENT_SECTION.currentGameInPage++; + } else { + CURRENT_SECTION.currentPage++; + CURRENT_SECTION.currentGameInPage=0; + } } CURRENT_SECTION.realCurrentGameNumber=CURRENT_GAME_NUMBER; } +void scrollToGame(int gameNumber) { + int pages = CURRENT_SECTION.gameCount / ITEMS_PER_PAGE; + if (CURRENT_SECTION.gameCount%ITEMS_PER_PAGE==0) { + pages--; + } + CURRENT_SECTION.totalPages=pages; + CURRENT_SECTION.currentGameInPage=0; + CURRENT_SECTION.currentPage=0; + CURRENT_SECTION.currentGameNode=CURRENT_SECTION.head; + while (CURRENT_GAME_NUMBER0) { - CURRENT_SECTION.currentPage--; - } else { - CURRENT_SECTION.currentPage=CURRENT_SECTION.totalPages; - } - gamesInPage=countGamesInPage(); - if (gamesInPage>0) { - CURRENT_SECTION.currentGameInPage=gamesInPage-1; - } - return; - } - if (CURRENT_SECTION.currentGameInPage > 0) { - CURRENT_SECTION.currentGameInPage--; - } - CURRENT_SECTION.realCurrentGameNumber=CURRENT_GAME_NUMBER; -} - void advancePage(struct Rom *rom) { - struct Node* currentGameNode = getCurrentNode(); if(CURRENT_SECTION.currentPage<=CURRENT_SECTION.totalPages) { - if (rom==NULL||rom->name==NULL) { - return; - } if (CURRENT_SECTION.alphabeticalPaging) { - char *currentGame = getFileNameOrAlias(currentGameNode->data); + char *currentGame = getFileNameOrAlias(CURRENT_SECTION.currentGameNode->data); char currentLetter=tolower(currentGame[0]); - while((tolower(currentGame[0])==currentLetter||isdigit(currentGame[0]))) { - if (CURRENT_SECTION.currentPage==CURRENT_SECTION.totalPages&&CURRENT_SECTION.currentGameInPage==countGamesInPage()-1) { - scrollDown(); - break; - } + while((tolower(currentGame[0])==currentLetter||(isdigit(currentLetter)&&isdigit(currentGame[0])))) { scrollDown(); free(currentGame); - currentGameNode=getCurrentNode(); - currentGame = getFileNameOrAlias(currentGameNode->data); + currentGame = getFileNameOrAlias(CURRENT_SECTION.currentGameNode->data); } free(currentGame); } else { if(CURRENT_SECTION.currentPage!=CURRENT_SECTION.totalPages) { CURRENT_SECTION.currentPage++; + for (int i=CURRENT_SECTION.currentGameInPage;inext; + } } else { CURRENT_SECTION.currentPage=0; + CURRENT_SECTION.currentGameNode=CURRENT_SECTION.head; } CURRENT_SECTION.currentGameInPage=0; } } - gamesInPage=countGamesInPage(); +// gamesInPage=countGamesInPage(); CURRENT_SECTION.realCurrentGameNumber=CURRENT_GAME_NUMBER; } void rewindPage(struct Rom *rom) { - struct Node* currentGameNode = getCurrentNode(); +// struct Node* currentGameNode = getCurrentNode(); if (rom==NULL||rom->name==NULL) { return; } @@ -191,18 +188,17 @@ void rewindPage(struct Rom *rom) { char *previousGame; int hitStart = 0; while(!(CURRENT_SECTION.currentPage==0&&CURRENT_SECTION.currentGameInPage==0)) { - previousGame = getFileNameOrAlias(currentGameNode->prev->data); + previousGame = getFileNameOrAlias(CURRENT_SECTION.currentGameNode->prev->data); if(tolower(currentGame[0])==tolower(previousGame[0])) { if (CURRENT_SECTION.currentPage==0&&CURRENT_SECTION.currentGameInPage==0) { hitStart = 1; break; } else { scrollUp(); - currentGameNode = getCurrentNode(); } free(currentGame); free(previousGame); - currentGame = getFileNameOrAlias(currentGameNode->data); + currentGame = getFileNameOrAlias(CURRENT_SECTION.currentGameNode->data); } else { break; } @@ -210,13 +206,12 @@ void rewindPage(struct Rom *rom) { } if (!hitStart) { scrollUp(); - currentGameNode = getCurrentNode(); } hitStart=0; free(currentGame); - currentGame = getFileNameOrAlias(currentGameNode->data); + currentGame = getFileNameOrAlias(CURRENT_SECTION.currentGameNode->data); while(!(CURRENT_SECTION.currentPage==0&&CURRENT_SECTION.currentGameInPage==0)) { - previousGame = getFileNameOrAlias(currentGameNode->prev->data); + previousGame = getFileNameOrAlias(CURRENT_SECTION.currentGameNode->prev->data); if ( (tolower(currentGame[0])==tolower(previousGame[0])) || (isdigit(currentGame[0])&&isdigit(previousGame[0]))) { if (CURRENT_SECTION.currentPage==0&&CURRENT_SECTION.currentGameInPage==0) { @@ -224,66 +219,53 @@ void rewindPage(struct Rom *rom) { break; } else { scrollUp(); - currentGameNode = getCurrentNode(); } free(currentGame); free(previousGame); - currentGame = getFileNameOrAlias(currentGameNode->data); + currentGame = getFileNameOrAlias(CURRENT_SECTION.currentGameNode->data); } else { break; } } free(currentGame); } else if (CURRENT_SECTION.currentPage > 0) { - CURRENT_SECTION.currentPage--; - CURRENT_SECTION.currentGameInPage=0; + int tempCurrentPage = CURRENT_SECTION.currentPage; + while (!(CURRENT_SECTION.currentPage==(tempCurrentPage-1)&&CURRENT_SECTION.currentGameInPage==0)) { + scrollUp(); + } } else { - CURRENT_SECTION.currentPage=CURRENT_SECTION.totalPages; - CURRENT_SECTION.currentGameInPage=0; - + while (!(CURRENT_SECTION.currentPage==CURRENT_SECTION.totalPages&&CURRENT_SECTION.currentGameInPage==0)) { + scrollUp(); + } } - gamesInPage=countGamesInPage(); +// gamesInPage=countGamesInPage(); CURRENT_SECTION.realCurrentGameNumber=CURRENT_GAME_NUMBER; } void showOrHideFavorites() { - hideFullScreenModeMenu(); if (favoritesSectionSelected) { favoritesSectionSelected=0; currentSectionNumber=returnTo; if (returnTo==0) { - if (pictureMode) { + if (fullscreenMode) { currentlySectionSwitching=1; resetPicModeHideLogoTimer(); currentlySectionSwitching=1; displayBackgroundPicture(); showConsole(); -// refreshScreen(); } determineStartingScreen(menuSectionCounter); } else { - if (pictureMode) { + if (fullscreenMode) { currentlySectionSwitching=1; resetPicModeHideLogoTimer(); displayBackgroundPicture(); showConsole(); -// refreshScreen(); } loadGameList(0); - int number = CURRENT_SECTION.realCurrentGameNumber; - int gamesInSection=countGamesInSection(); - int pages = gamesInSection / ITEMS_PER_PAGE; - if (gamesInSection%ITEMS_PER_PAGE==0) { - pages--; - } - CURRENT_SECTION.totalPages=pages; - CURRENT_SECTION.currentGameInPage=0; - CURRENT_SECTION.currentPage=0; - while (CURRENT_GAME_NUMBER 0) { + if (CURRENT_GAME_NUMBER==favoritesSize) { + FAVORITES_SECTION.realCurrentGameNumber--; + } loadFavoritesSectionGameList(); - } - if(CURRENT_GAME_NUMBER==favoritesSize) { - scrollUp(); +// } } } diff --git a/simplemenu/src/logic/control_bittboy.c b/simplemenu/src/logic/control_bittboy.c index 2f1632bb..d94755fc 100644 --- a/simplemenu/src/logic/control_bittboy.c +++ b/simplemenu/src/logic/control_bittboy.c @@ -54,7 +54,7 @@ int performAction(struct Rom *rom) { if (keys[BTN_SELECT]&&!currentlySectionSwitching) { for(int i=0;i<100;i++) { selectRandomGame(); - updateScreen(); + updateScreen(rom); } saveFavorites(); launchGame(); @@ -64,7 +64,7 @@ int performAction(struct Rom *rom) { CURRENT_SECTION.alphabeticalPaging=1; advancePage(); // CURRENT_SECTION.alphabeticalPaging=0; - if(pictureMode) { + if(fullscreenMode) { resetPicModeHideMenuTimer(); } return 0; @@ -74,7 +74,7 @@ int performAction(struct Rom *rom) { CURRENT_SECTION.alphabeticalPaging=1; rewindPage(); // CURRENT_SECTION.alphabeticalPaging=0; - if(pictureMode) { + if(fullscreenMode) { resetPicModeHideMenuTimer(); } return 0; @@ -130,52 +130,62 @@ int performAction(struct Rom *rom) { if(keys[BTN_L1]) { hideFullScreenModeMenu(); hotKeyPressed=0; - if (pictureMode&&!favoritesSectionSelected) { + if (fullscreenMode&&!favoritesSectionSelected) { resetPicModeHideLogoTimer(); currentlySectionSwitching=1; } int rewinded = rewindSection(); if(rewinded) { + currentlySectionSwitching=1; + loadGameList(0); while(CURRENT_SECTION.hidden) { rewindSection(); + loadGameList(0); } } - if (!pictureMode) { + if (!fullscreenMode) { currentlySectionSwitching=0; } + scrollToGame(CURRENT_SECTION.realCurrentGameNumber); return 0; } + if(keys[BTN_R1]) { hideFullScreenModeMenu(); hotKeyPressed=0; - if (pictureMode&&!favoritesSectionSelected) { + if (fullscreenMode&&!favoritesSectionSelected) { resetPicModeHideLogoTimer(); currentlySectionSwitching=1; } int advanced = advanceSection(); if(advanced) { + currentlySectionSwitching=1; + loadGameList(0); while(CURRENT_SECTION.hidden) { advanceSection(); + loadGameList(0); } } - if (!pictureMode) { + if (!fullscreenMode) { currentlySectionSwitching=0; } + scrollToGame(CURRENT_SECTION.realCurrentGameNumber); return 0; } + if (!hotKeyPressed&&!currentlySectionSwitching&&!isUSBMode) { if (keys[BTN_X]) { if(!isPicModeMenuHidden) { resetPicModeHideMenuTimer(); } if (!favoritesSectionSelected) { - markAsFavorite(); + markAsFavorite(rom); } else { removeFavorite(); if(favoritesSize==0) { showOrHideFavorites(); - hideFullScreenModeMenu(); +// hideFullScreenModeMenu(); } } return 0; @@ -210,35 +220,35 @@ int performAction(struct Rom *rom) { return 0; } if (keys[BTN_Y]) { - if (pictureMode) { - pictureMode=0; + if (fullscreenMode) { + fullscreenMode=0; } else { - pictureMode=1; + fullscreenMode=1; } } if (keys[BTN_DOWN]) { - if(pictureMode) { + if(fullscreenMode) { resetPicModeHideMenuTimer(); } scrollDown(); return 1; } if(keys[BTN_UP]) { - if(pictureMode) { + if(fullscreenMode) { resetPicModeHideMenuTimer(); } scrollUp(); return 1; } if(keys[BTN_RIGHT]) { - if(pictureMode) { + if(fullscreenMode) { resetPicModeHideMenuTimer(); } advancePage(); return 1; } if(keys[BTN_LEFT]) { - if(pictureMode) { + if(fullscreenMode) { resetPicModeHideMenuTimer(); } rewindPage(); diff --git a/simplemenu/src/logic/control_rg300.c b/simplemenu/src/logic/control_rg300.c index 4bf18147..01746eeb 100644 --- a/simplemenu/src/logic/control_rg300.c +++ b/simplemenu/src/logic/control_rg300.c @@ -129,7 +129,7 @@ int performAction(struct Rom *rom) { if(keys[BTN_L1]) { hideFullScreenModeMenu(); hotKeyPressed=0; - if (pictureMode&&!favoritesSectionSelected) { + if (fullscreenMode&&!favoritesSectionSelected) { resetPicModeHideLogoTimer(); currentlySectionSwitching=1; } @@ -139,7 +139,7 @@ int performAction(struct Rom *rom) { rewindSection(); } } - if (!pictureMode) { + if (!fullscreenMode) { currentlySectionSwitching=0; } return 0; @@ -147,7 +147,7 @@ int performAction(struct Rom *rom) { if(keys[BTN_R1]) { hideFullScreenModeMenu(); hotKeyPressed=0; - if (pictureMode&&!favoritesSectionSelected) { + if (fullscreenMode&&!favoritesSectionSelected) { resetPicModeHideLogoTimer(); currentlySectionSwitching=1; } @@ -157,7 +157,7 @@ int performAction(struct Rom *rom) { advanceSection(); } } - if (!pictureMode) { + if (!fullscreenMode) { currentlySectionSwitching=0; } return 0; @@ -202,10 +202,10 @@ int performAction(struct Rom *rom) { return 0; } if (keys[BTN_Y]) { - if (pictureMode) { - pictureMode=0; + if (fullscreenMode) { + fullscreenMode=0; } else { - pictureMode=1; + fullscreenMode=1; } } if (keys[BTN_DOWN]) { diff --git a/simplemenu/src/logic/control_rg350.c b/simplemenu/src/logic/control_rg350.c index 43eeef3d..ed6ef3a7 100644 --- a/simplemenu/src/logic/control_rg350.c +++ b/simplemenu/src/logic/control_rg350.c @@ -62,19 +62,19 @@ int performAction(struct Rom *rom) { } } if (keys[BTN_SELECT]&&!currentlySectionSwitching) { - for(int i=0;i<100;i++) { + for(int i=0;i<25;i++) { selectRandomGame(); - updateScreen(); + updateScreen(CURRENT_SECTION.currentGameNode->data); } saveFavorites(); - launchGame(rom); + launchGame(CURRENT_SECTION.currentGameNode->data); } if (keys[BTN_DOWN]&&!currentlySectionSwitching) { hotKeyPressed=1; CURRENT_SECTION.alphabeticalPaging=1; advancePage(rom); // CURRENT_SECTION.alphabeticalPaging=0; - if(pictureMode) { + if(fullscreenMode) { resetPicModeHideMenuTimer(); } return 0; @@ -84,7 +84,7 @@ int performAction(struct Rom *rom) { CURRENT_SECTION.alphabeticalPaging=1; rewindPage(rom); // CURRENT_SECTION.alphabeticalPaging=0; - if(pictureMode) { + if(fullscreenMode) { resetPicModeHideMenuTimer(); } return 0; @@ -110,6 +110,7 @@ int performAction(struct Rom *rom) { loadGameList(0); } } + scrollToGame(CURRENT_SECTION.realCurrentGameNumber); return 0; } if(keys[BTN_LEFT]) { @@ -133,6 +134,7 @@ int performAction(struct Rom *rom) { loadGameList(0); } } + scrollToGame(CURRENT_SECTION.realCurrentGameNumber); return 0; } } @@ -140,37 +142,46 @@ int performAction(struct Rom *rom) { if(keys[BTN_L1]) { hideFullScreenModeMenu(); hotKeyPressed=0; - if (pictureMode&&!favoritesSectionSelected) { + if (fullscreenMode&&!favoritesSectionSelected) { resetPicModeHideLogoTimer(); currentlySectionSwitching=1; } int rewinded = rewindSection(); if(rewinded) { + currentlySectionSwitching=1; + loadGameList(0); while(CURRENT_SECTION.hidden) { rewindSection(); + loadGameList(0); } } - if (!pictureMode) { + if (!fullscreenMode) { currentlySectionSwitching=0; } + scrollToGame(CURRENT_SECTION.realCurrentGameNumber); return 0; } + if(keys[BTN_R1]) { hideFullScreenModeMenu(); hotKeyPressed=0; - if (pictureMode&&!favoritesSectionSelected) { + if (fullscreenMode&&!favoritesSectionSelected) { resetPicModeHideLogoTimer(); currentlySectionSwitching=1; } int advanced = advanceSection(); if(advanced) { + currentlySectionSwitching=1; + loadGameList(0); while(CURRENT_SECTION.hidden) { advanceSection(); + loadGameList(0); } } - if (!pictureMode) { + if (!fullscreenMode) { currentlySectionSwitching=0; } + scrollToGame(CURRENT_SECTION.realCurrentGameNumber); return 0; } @@ -186,7 +197,6 @@ int performAction(struct Rom *rom) { removeFavorite(); if(favoritesSize==0) { showOrHideFavorites(); - hideFullScreenModeMenu(); } } return 0; @@ -221,63 +231,39 @@ int performAction(struct Rom *rom) { return 0; } if (keys[BTN_Y]) { - if (pictureMode) { - pictureMode=0; - int number = CURRENT_GAME_NUMBER; + int number = CURRENT_GAME_NUMBER; + if (fullscreenMode) { + fullscreenMode=0; ITEMS_PER_PAGE=10; - int gamesInSection=countGamesInSection(); - int pages = gamesInSection / ITEMS_PER_PAGE; - if (gamesInSection%ITEMS_PER_PAGE==0) { - pages--; - } - CURRENT_SECTION.totalPages=pages; - CURRENT_SECTION.currentGameInPage=0; - CURRENT_SECTION.currentPage=0; - while (CURRENT_GAME_NUMBERw>width) { @@ -149,7 +149,7 @@ void drawBatteryOnFooter(char *text) { } void drawCurrentLetter(char *letter, int textColor[], int x, int y) { - if (!pictureMode) { + if (!fullscreenMode) { drawTextOnScreen(BIGFont, x, y, letter, textColor, VAlignMiddle | HAlignCenter); } else { drawTextOnScreen(miniFont, x, y, letter, textColor, VAlignMiddle | HAlignCenter); @@ -301,8 +301,11 @@ void initializeDisplay() { SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER); const SDL_VideoInfo* info = SDL_GetVideoInfo(); //<-- calls SDL_GetVideoInfo(); SCREEN_HEIGHT = info->current_h; - if (SCREEN_HEIGHT>600) { - SCREEN_HEIGHT = 600; + if (SCREEN_HEIGHT>768) { + SCREEN_HEIGHT = 768; + } + if (SCREEN_HEIGHT<240) { + SCREEN_HEIGHT = 240; } SDL_ShowCursor(0); screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 16, SDL_SWSURFACE | SDL_NOFRAME); diff --git a/simplemenu/src/logic/logic.c b/simplemenu/src/logic/logic.c index bf46f076..25978f38 100644 --- a/simplemenu/src/logic/logic.c +++ b/simplemenu/src/logic/logic.c @@ -279,7 +279,7 @@ void executeCommand (char *emulatorFolder, char *executable, char *fileToBeExecu char pSectionNumber[3]=""; char pPictureMode[2]=""; snprintf(pSectionNumber,sizeof(pSectionNumber),"%d",currentSectionNumber); - snprintf(pPictureMode,sizeof(pPictureMode),"%d",pictureMode); + snprintf(pPictureMode,sizeof(pPictureMode),"%d",fullscreenMode); saveLastState(); #ifndef TARGET_PC saveFavorites(); @@ -309,10 +309,11 @@ int isExtensionValid(char *extension, char *fileExtensions) { int countGamesInSection() { int gamesCounter=0; + struct Node* currentGameNode = CURRENT_SECTION.head; for (int i=0;i<=10000;i++) { - struct Rom* currentGame = GetNthElement(i); - if (currentGame!=NULL&&strlen(currentGame->name)>0) { + if (currentGameNode!=NULL&&strlen(currentGameNode->data->name)>0) { gamesCounter++; + currentGameNode = currentGameNode->next; } else { break; } @@ -402,15 +403,16 @@ struct Node *mergeSort(struct Node *head) { } void loadFavoritesSectionGameList() { - int game = 0; + int gameInPage = 0; int page = 0; FAVORITES_SECTION.totalPages=0; + FAVORITES_SECTION.gameCount=0; cleanListForSection(&FAVORITES_SECTION); for (int i=0;ialias, favorites[i].alias); strcpy(rom->name, favorites[i].name); InsertAtTailInSection(&FAVORITES_SECTION, rom); - game++; + gameInPage++; + FAVORITES_SECTION.gameCount++; + } + FAVORITES_SECTION.tail=GetNthNode(FAVORITES_SECTION.gameCount-1); + if (favoritesSize>0) { + scrollToGame(FAVORITES_SECTION.realCurrentGameNumber); } -// menuSections[favoritesSectionNumber].head = mergeSort(menuSections[favoritesSectionNumber].head); } int recursivelyScanDirectory (char *directory, char* files[], int i) { @@ -634,6 +640,7 @@ void loadGameList(int refresh) { strcpy(rom->alias,desktopFiles[desktopCounter].displayName); InsertAtTail(rom); game++; + CURRENT_SECTION.gameCount++; } desktopCounter++; } @@ -670,6 +677,7 @@ void loadGameList(int refresh) { rom->alias=NULL; } } + CURRENT_SECTION.gameCount++; if (game==ITEMS_PER_PAGE) { if(i!=realItemCount) { CURRENT_SECTION.totalPages++; @@ -694,7 +702,10 @@ void loadGameList(int refresh) { for (int i=0;idata->name!=NULL && strlen(node->data->name)>1) { @@ -731,13 +742,8 @@ int getFirstNonHiddenSection(int sectionCount) { } void selectRandomGame() { - int gamesInSection = countGamesInSection(); - if (gamesInSection%ITEMS_PER_PAGE==0) { - CURRENT_SECTION.currentPage = rand() % ((int)gamesInSection/ITEMS_PER_PAGE); - } else { - CURRENT_SECTION.currentPage = rand() % ((int)(gamesInSection/ITEMS_PER_PAGE) +1); - } - CURRENT_SECTION.currentGameInPage = rand() % countGamesInPage(); + int game = rand() % CURRENT_SECTION.gameCount; + scrollToGame(game); } void determineStartingScreen(int sectionCount) { @@ -748,19 +754,12 @@ void determineStartingScreen(int sectionCount) { if(sectionCount==0||currentSectionNumber==favoritesSectionNumber) { favoritesSectionSelected=1; loadFavoritesSectionGameList(); - int number = CURRENT_SECTION.realCurrentGameNumber; - int gamesInSection=countGamesInSection(); + int gamesInSection=CURRENT_SECTION.gameCount; int pages = gamesInSection / ITEMS_PER_PAGE; if (gamesInSection%ITEMS_PER_PAGE==0) { pages--; } CURRENT_SECTION.totalPages=pages; - CURRENT_SECTION.currentGameInPage=0; - CURRENT_SECTION.currentPage=0; - while (CURRENT_GAME_NUMBERdirectory); tempGameName=getGameName(rom->name); } - strcat(pictureWithFullPath,"media/"); + strcat(pictureWithFullPath,mediaFolder); + strcat(pictureWithFullPath,"/"); // tempGameName=getNameWithoutExtension(tempGameName); strcat(pictureWithFullPath,tempGameName); strcat(pictureWithFullPath,".png"); @@ -286,7 +287,7 @@ void drawHeader(struct Rom *rom) { char finalString [100]; // char timeString[150]; int rgbColor[] = {menuSections[currentSectionNumber].headerAndFooterBackgroundColor[0],menuSections[currentSectionNumber].headerAndFooterBackgroundColor[1],menuSections[currentSectionNumber].headerAndFooterBackgroundColor[2]}; - if (!pictureMode) { + if (!fullscreenMode) { drawRectangleOnScreen(SCREEN_WIDTH, calculateProportionalSizeOrDistance(22), 0, 0, rgbColor); } if (currentCPU==OC_UC) { @@ -329,21 +330,22 @@ void drawShutDownScreen() { void drawGameList() { int rgbColor[] = {menuSections[currentSectionNumber].bodyBackgroundColor[0],menuSections[currentSectionNumber].bodyBackgroundColor[1],menuSections[currentSectionNumber].bodyBackgroundColor[2]}; - if (!pictureMode) { + if (!fullscreenMode) { drawRectangleOnScreen(SCREEN_WIDTH, SCREEN_HEIGHT-calculateProportionalSizeOrDistance(43), 0, calculateProportionalSizeOrDistance(22), rgbColor); } gamesInPage=0; int nextLine = calculateProportionalSizeOrDistance(29); - if (pictureMode) { + if (fullscreenMode) { nextLine = calculateProportionalSizeOrDistance(12); } char *nameWithoutExtension; + struct Node* currentNode; + currentNode = GetNthNode(ITEMS_PER_PAGE*CURRENT_SECTION.currentPage); for (int i=0;idata; gamesInPage++; sprintf(buf,"%s", ""); if (rom->alias!=NULL && (strlen(rom->alias)>2)) { @@ -363,7 +365,7 @@ void drawGameList() { free(tempGame); } } - if (pictureMode) { + if (fullscreenMode) { // sprintf(buf,"%d. %s", i+ITEMS_PER_PAGE*CURRENT_SECTION.currentPage+1, nameWithoutExtension); sprintf(buf,"%s", nameWithoutExtension); } else { @@ -371,7 +373,7 @@ void drawGameList() { } if (i==menuSections[currentSectionNumber].currentGameInPage) { if(strlen(buf)>1) { - if(pictureMode) { + if(fullscreenMode) { if(!isPicModeMenuHidden) { // int white[3]={255, 255, 0}; // drawTransparentRectangleToScreen(320, 20, 0, nextLine-11, white, 200); @@ -383,7 +385,7 @@ void drawGameList() { } } else { if(strlen(buf)>1) { - if(pictureMode) { + if(fullscreenMode) { if(!isPicModeMenuHidden) { drawNonShadedGameNameOnScreenPicMode(buf, nextLine); } @@ -392,12 +394,13 @@ void drawGameList() { } } } - if (!pictureMode) { + if (!fullscreenMode) { nextLine+=calculateProportionalSizeOrDistance(19); } else { nextLine+=calculateProportionalSizeOrDistance(20); } free(nameWithoutExtension); + currentNode = currentNode->next; } } @@ -417,12 +420,13 @@ void setupDecorations(struct Rom *rom) { drawHeader(rom); } -void updateScreen() { - struct Rom* rom = GetNthElement(CURRENT_GAME_NUMBER); +void updateScreen(struct Rom *rom) { // pthread_mutex_lock(&lock); +// if(currentSectionNumber==favoritesSectionNumber) { +// } if (!currentlySectionSwitching&&!isUSBMode&&!itsStoppedBecauseOfAnError) { setupDecorations(rom); - if (pictureMode) { + if (fullscreenMode) { displayGamePicture(rom); } drawGameList(); @@ -461,7 +465,7 @@ uint32_t hideFullScreenModeMenu(uint32_t interval, void *param) { if(!hotKeyPressed) { clearPicModeHideMenuTimer(); isPicModeMenuHidden=1; - updateScreen(); + updateScreen(CURRENT_SECTION.currentGameNode->data); } return 0; } @@ -485,7 +489,7 @@ uint32_t hidePicModeLogo(uint32_t interval, void *param) { clearPicModeHideLogoTimer(); currentlySectionSwitching=0; hotKeyPressed=0; - updateScreen(); + updateScreen(CURRENT_SECTION.currentGameNode->data); return 0; } diff --git a/simplemenu/src/logic/simplemenu.c b/simplemenu/src/logic/simplemenu.c index 163bd6df..d4ca40ee 100644 --- a/simplemenu/src/logic/simplemenu.c +++ b/simplemenu/src/logic/simplemenu.c @@ -88,27 +88,26 @@ int main(int argc, char* argv[]) { setSectionsState(argv[1]); currentSectionNumber=atoi(argv[2]); returnTo=atoi(argv[3]); - pictureMode=atoi(argv[4]); + fullscreenMode=atoi(argv[4]); loadLastState(); } else { loadLastState(); } - if(pictureMode) { + if(fullscreenMode) { ITEMS_PER_PAGE=12; } #if defined(TARGET_BITTBOY) || defined(TARGET_RG300) || defined(TARGET_RG350) initSuspendTimer(); #endif determineStartingScreen(sectionCount); - updateScreen(); + updateScreen(CURRENT_SECTION.currentGameNode->data); enableKeyRepeat(); while (running) { while(pollEvent()){ - struct Rom *rom = GetNthElement(CURRENT_GAME_NUMBER); if(getEventType()==getKeyDown()){ if (!isSuspended) { if (!currentlyChoosingEmulator) { - performAction(rom); + performAction(CURRENT_SECTION.currentGameNode->data); } else { performChoosingAction(); } @@ -116,11 +115,11 @@ int main(int argc, char* argv[]) { #ifndef TARGET_PC resetScreenOffTimer(); #endif - updateScreen(); + updateScreen(CURRENT_SECTION.currentGameNode->data); } else if (getEventType()==getKeyUp()) { if(getPressedKey()==BTN_B) { hotKeyPressed=0; - if(pictureMode) { + if(fullscreenMode) { if(currentlySectionSwitching) { hideFullScreenModeMenu(); } else if (CURRENT_SECTION.alphabeticalPaging) { @@ -129,15 +128,15 @@ int main(int argc, char* argv[]) { } CURRENT_SECTION.alphabeticalPaging=0; currentlySectionSwitching=0; - updateScreen(); + updateScreen(CURRENT_SECTION.currentGameNode->data); } - if(getPressedKey()==BTN_SELECT) { + if(getPressedKey()==BTN_SELECT&&!hotKeyPressed) { if (stripGames) { stripGames=0; } else { stripGames=1; } - updateScreen(); + updateScreen(CURRENT_SECTION.currentGameNode->data); } } }