diff --git a/source/MainMenu.c b/source/MainMenu.c index e913492..4c055c4 100644 --- a/source/MainMenu.c +++ b/source/MainMenu.c @@ -10,12 +10,15 @@ void selectSlotMenu(int slotchar){ SDL_DrawRect(renderer,30,648,1220,2, WHITE_COLOR); SDL_DrawText(Arial, 110, 27, WHITE_TEXT_COLOR, "Breath of the Wild Editor"); - SDL_DrawRect(renderer,380,248,517,167, LEFTBAR_COLOR); - SDL_DrawText(Arial_S,554,300, WHITE_TEXT_COLOR, "Select File Slot:"); + SDL_DrawRect(renderer,380,148,517,400, LEFTBAR_COLOR); + SDL_DrawText(Arial_S,554,200, WHITE_TEXT_COLOR, "Select File Slot:"); char slotc[2]; snprintf(slotc, sizeof slotc, "%d", slotchar); - SDL_DrawText(Arial_S, 632, 330, WHITE_TEXT_COLOR, slotc); + SDL_DrawText(Arial_S, 632, 230, WHITE_TEXT_COLOR, slotc); + + SDL_DrawImage(renderer, saveFileImg[slotchar],512, 300, 256, 144); + SDL_RenderPresent(renderer); } diff --git a/source/botw_backend.c b/source/botw_backend.c index 2d1e79b..029ae33 100644 --- a/source/botw_backend.c +++ b/source/botw_backend.c @@ -170,9 +170,7 @@ int setFile(int intSlot){ numberOfItems = 0; rupeeValue = 0; rupees = 0; - - mountSaveData(); - + char file_name[75]; char header[] = "save:/"; char footer[] = "/game_data.sav"; diff --git a/source/main.c b/source/main.c index 759e2f4..9fbb867 100644 --- a/source/main.c +++ b/source/main.c @@ -31,6 +31,29 @@ void startSDLServices(){ SDL_LoadImage(renderer, &bbuttonp, "romfs:/bbutton_p.png"); SDL_LoadImage(renderer, &okbuttonp,"romfs:/okbutton_p.png" ); SDL_LoadImage(renderer, &check,"romfs:/check.png" ); + + for(int x = 0; x < 6; x++){ + char nameFile_S[22]; + snprintf(nameFile_S, sizeof nameFile_S, "save:/%d/caption.jpg", x); + + if(file_exist (nameFile_S)){ + SDL_LoadImage(renderer, &saveFileImg[x], nameFile_S); + } + else{ + SDL_LoadImage(renderer, &saveFileImg[x], "romfs:/missingSlot.png"); + } + } +} + +int file_exist (char *filename) +{ + FILE *file = fopen(filename, "r"); + if (file != NULL) + { + fclose(file); + return 1; + } + return 0; } void initServices(){ @@ -40,7 +63,15 @@ void initServices(){ currentState = 0; currentItem = 0; romfsInit(); - startSDLServices(); + if(mountSaveData() == 0){ + currentState = -1; + errorScreen(); + } + else{ + startSDLServices(); + } + + } void setPages(){ @@ -449,8 +480,10 @@ void MenuButtons(int x){ int main(int argc, char **argv){ + appletSetScreenShotPermission(1); initServices(); + selectSlotMenu(slot); while(appletMainLoop()) @@ -506,23 +539,6 @@ void RupeeKey(){ } } -void returnMainScreen(){ - - buttons = 0; - slot = 0; - currentPage = 1; - currentState = 0; - isopen = 0; - - fclose(fp); - unmountSaveData(); - fsdevUnmountDevice("save"); - selectSlotMenu(slot); - - - -} - void closeServices(){ fclose(fp); unmountSaveData(); diff --git a/source/mount.c b/source/mount.c index 0a62085..07e61fb 100644 --- a/source/mount.c +++ b/source/mount.c @@ -11,7 +11,7 @@ void unmountSaveData(){ fsdevUnmountDevice("save"); } -void mountSaveData() +int mountSaveData() { int ret=0; Result rc = 0; @@ -27,6 +27,7 @@ void mountSaveData() if (R_FAILED(rc)) { printf("accountInitialize() failed: 0x%x\n", rc); + return 0; } if (R_SUCCEEDED(rc)) { @@ -35,10 +36,12 @@ void mountSaveData() if (R_FAILED(rc)) { printf("accountGetActiveUser() failed: 0x%x\n", rc); + return 0; } else if(!account_selected) { printf("No user is currently selected.\n"); rc = -1; + return 0; } } @@ -50,7 +53,9 @@ void mountSaveData() rc = fsMount_SaveData(&tmpfs, titleID, userID); if (R_FAILED(rc)) { printf("fsMount_SaveData() failed: 0x%x\n", rc); + return 0; } + } if (R_SUCCEEDED(rc)) { @@ -58,8 +63,11 @@ void mountSaveData() if (ret==-1) { printf("fsdevMountDevice() failed.\n"); rc = ret; + return 0; } } + return 1; + }