Skip to content

Commit

Permalink
Forgot this
Browse files Browse the repository at this point in the history
  • Loading branch information
Jpe230 committed Jun 22, 2018
1 parent d4d68e1 commit 3654272
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 25 deletions.
9 changes: 6 additions & 3 deletions source/MainMenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 1 addition & 3 deletions source/botw_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
52 changes: 34 additions & 18 deletions source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand All @@ -40,7 +63,15 @@ void initServices(){
currentState = 0;
currentItem = 0;
romfsInit();
startSDLServices();
if(mountSaveData() == 0){
currentState = -1;
errorScreen();
}
else{
startSDLServices();
}


}

void setPages(){
Expand Down Expand Up @@ -449,8 +480,10 @@ void MenuButtons(int x){

int main(int argc, char **argv){

appletSetScreenShotPermission(1);
initServices();


selectSlotMenu(slot);

while(appletMainLoop())
Expand Down Expand Up @@ -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();
Expand Down
10 changes: 9 additions & 1 deletion source/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void unmountSaveData(){
fsdevUnmountDevice("save");
}

void mountSaveData()
int mountSaveData()
{
int ret=0;
Result rc = 0;
Expand All @@ -27,6 +27,7 @@ void mountSaveData()

if (R_FAILED(rc)) {
printf("accountInitialize() failed: 0x%x\n", rc);
return 0;
}

if (R_SUCCEEDED(rc)) {
Expand All @@ -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;
}
}

Expand All @@ -50,16 +53,21 @@ 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)) {
ret = fsdevMountDevice("save", tmpfs);
if (ret==-1) {
printf("fsdevMountDevice() failed.\n");
rc = ret;
return 0;
}
}

return 1;

}

0 comments on commit 3654272

Please sign in to comment.