Skip to content

Commit

Permalink
remove saves option (#19)
Browse files Browse the repository at this point in the history
* delete vmc saves
* delete from memcard
* optimized png
  • Loading branch information
bucanero authored Dec 6, 2024
1 parent 00780a8 commit 5c8fb36
Show file tree
Hide file tree
Showing 64 changed files with 138 additions and 20 deletions.
Binary file modified data/buk_scr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/cat_about.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/cat_bup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/cat_cheats.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/cat_db.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/cat_empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/cat_hdd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/cat_opt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/cat_sav.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/cat_usb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/cat_warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/cheat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/circle_loading_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/circle_loading_seek.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/column_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/column_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/column_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/column_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/column_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/column_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/column_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/edit_shadow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/footer_ico_circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/footer_ico_cross.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/footer_ico_square.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/footer_ico_triangle.png
Binary file modified data/header_dot.png
Binary file modified data/header_line.png
Binary file modified data/help.png
Binary file modified data/jar_about.png
Binary file modified data/jar_about_hover.png
Binary file modified data/jar_bup.png
Binary file modified data/jar_bup_hover.png
Binary file modified data/jar_db.png
Binary file modified data/jar_db_hover.png
Binary file modified data/jar_empty.png
Binary file modified data/jar_hdd.png
Binary file modified data/jar_hdd_hover.png
Binary file modified data/jar_opt.png
Binary file modified data/jar_opt_hover.png
Binary file modified data/jar_usb.png
Binary file modified data/jar_usb_hover.png
Binary file modified data/logo.png
Binary file modified data/logo_text.png
Binary file modified data/mark_arrow.png
Binary file modified data/mark_line.png
Binary file modified data/opt_off.png
Binary file modified data/opt_on.png
Binary file modified data/scroll_bg.png
Binary file modified data/tag_apply.png
Binary file modified data/tag_net.png
Binary file modified data/tag_transfer.png
Binary file modified data/tag_vmc.png
Binary file modified data/tag_warning.png
Binary file modified data/tag_zip.png
Binary file modified data/trp_gold.png
Binary file modified data/trp_sync.png
2 changes: 1 addition & 1 deletion include/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ enum menu_screen_ids
MENU_MAIN_SCREEN, /* 0 - Main Menu */
MENU_PS2VMC_SAVES, /* 1 - PS2 VMC Menu */
MENU_USB_SAVES, /* 2 - USB Menu (User List) */
MENU_HDD_SAVES, /* 3 - HDD Menu (User List) */
MENU_MEMCARD_SAVES, /* 3 - MemCard Menu (User List) */
MENU_ONLINE_DB, /* 4 - Online Menu (Online List) */
MENU_USER_BACKUP, /* 5 - User Backup */
MENU_SETTINGS, /* 6 - Options Menu */
Expand Down
5 changes: 3 additions & 2 deletions include/saves.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ enum save_type_enum
FILE_TYPE_NULL,
FILE_TYPE_MENU,
FILE_TYPE_PS2,
FILE_TYPE_PS1,
FILE_TYPE_VMC,
FILE_TYPE_PSV,

// PS1 File Types
FILE_TYPE_PS1,
FILE_TYPE_PSV,
FILE_TYPE_MCS,
FILE_TYPE_PSX,

Expand Down Expand Up @@ -268,6 +268,7 @@ int exportPSV(const char *mc_save, const char* out_path);
int exportCBS(const char *mc_save, const char* out_path, const char* title);
int exportMCS(const char* path, const char* fname, const char* dstName);

int vmc_delete_save(const char* path);
int vmc_export_psv(const char* save, const char* out_path);
int vmc_export_psu(const char* path, const char* output);
int vmc_import_psv(const char *input);
Expand Down
48 changes: 48 additions & 0 deletions source/exec_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,47 @@ static void resignSave(save_entry_t* entry)
show_message("Save %s successfully modified!", entry->title_id);
}

static int deleteSave(const save_entry_t* save)
{
char path[256];
int ret = 0;

if (!show_dialog(DIALOG_TYPE_YESNO, "Do you want to delete %s?", save->dir_name))
return 0;

if (save->flags & SAVE_FLAG_VMC)
ret = (save->flags & SAVE_FLAG_PS1) ? formatSave(save->icon[0]) : vmc_delete_save(save->dir_name);

else if (save->flags & SAVE_FLAG_PACKED)
ret = (remove(save->path) == SUCCESS);

else if (save->flags & SAVE_FLAG_MEMCARD)
{
if (save->flags & SAVE_FLAG_PS1CARD)
{
snprintf(path, sizeof(path), "%s%s", save->path, save->dir_name);
ret = (remove(path) == SUCCESS);
}
else
{
clean_directory(save->path);
ret = (remove(save->path) == SUCCESS);
}
}
else if (save->flags & SAVE_FLAG_PS1|SAVE_FLAG_PS2)
{
clean_directory(save->path);
ret = (remove(save->path) == SUCCESS);
}

if (ret)
show_message("Save successfully deleted:\n%s", save->dir_name);
else
show_message("Error! Couldn't delete save:\n%s", save->dir_name);

return ret;
}

static void exportAllSaves(const save_entry_t* save, int dev, int all)
{
struct tm t;
Expand Down Expand Up @@ -1140,6 +1181,13 @@ void execCodeCommand(code_entry_t* code, const char* codecmd)
code->activated = 0;
break;

case CMD_DELETE_SAVE:
if (deleteSave(selected_entry))
selected_entry->flags |= SAVE_FLAG_UPDATED;
else
code->activated = 0;
break;

case CMD_COPY_SAVE_VMC:
copyVmcSave(selected_entry, codecmd[1] ? MC1_PATH : MC0_PATH);
code->activated = 0;
Expand Down
2 changes: 1 addition & 1 deletion source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static const char* get_menu_help(int id)
case MENU_PS1VMC_SAVES:
case MENU_PS2VMC_SAVES:
case MENU_USB_SAVES:
case MENU_HDD_SAVES:
case MENU_MEMCARD_SAVES:
case MENU_ONLINE_DB:
return "\x10 Select \x13 Back \x12 Details \x11 Refresh";

Expand Down
46 changes: 33 additions & 13 deletions source/menu_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static void SetMenu(int id)

case MENU_MAIN_SCREEN: //Main Menu
case MENU_USB_SAVES: //USB Saves Menu
case MENU_HDD_SAVES: //HHD Saves Menu
case MENU_MEMCARD_SAVES: //HHD Saves Menu
case MENU_ONLINE_DB: //Cheats Online Menu
case MENU_USER_BACKUP: //Backup Menu
menu_textures[icon_png_file_index].size = 0;
Expand All @@ -153,17 +153,30 @@ static void SetMenu(int id)
break;

case MENU_PATCHES: //Cheat Selection Menu
if (selected_entry->flags & SAVE_FLAG_UPDATED && id == MENU_PS2VMC_SAVES)
{
selected_entry->flags ^= SAVE_FLAG_UPDATED;
mcio_vmcFinish();
ReloadUserSaves(&vmc2_saves);
}
else if (selected_entry->flags & SAVE_FLAG_UPDATED && id == MENU_PS1VMC_SAVES)
if (selected_entry->flags & SAVE_FLAG_UPDATED)
{
switch (id)
{
case MENU_PS2VMC_SAVES:
mcio_vmcFinish();
ReloadUserSaves(&vmc2_saves);
break;

case MENU_PS1VMC_SAVES:
saveMemoryCard(vmc1_saves.path, 0, 0);
ReloadUserSaves(&vmc1_saves);
break;

case MENU_MEMCARD_SAVES:
ReloadUserSaves(&hdd_saves);
break;

case MENU_USB_SAVES:
ReloadUserSaves(&usb_saves);
break;
}

selected_entry->flags ^= SAVE_FLAG_UPDATED;
saveMemoryCard(vmc1_saves.path, 0, 0);
ReloadUserSaves(&vmc1_saves);
}
break;

Expand Down Expand Up @@ -226,7 +239,7 @@ static void SetMenu(int id)
Draw_UserCheatsMenu_Ani(&usb_saves);
break;

case MENU_HDD_SAVES: //HDD saves Menu
case MENU_MEMCARD_SAVES: //HDD saves Menu
if (!hdd_saves.list && !ReloadUserSaves(&hdd_saves))
return;

Expand Down Expand Up @@ -263,7 +276,7 @@ static void SetMenu(int id)

case MENU_PATCHES: //Cheat Selection Menu
//if entering from game list, don't keep index, otherwise keep
if (menu_id == MENU_USB_SAVES || menu_id == MENU_HDD_SAVES || menu_id == MENU_ONLINE_DB ||
if (menu_id == MENU_USB_SAVES || menu_id == MENU_MEMCARD_SAVES || menu_id == MENU_ONLINE_DB ||
menu_id == MENU_PS2VMC_SAVES || menu_id == MENU_PS1VMC_SAVES)
menu_old_sel[MENU_PATCHES] = 0;

Expand Down Expand Up @@ -780,6 +793,13 @@ static void doPatchMenu(void)
return;
}

if (selected_centry->codes[0] == CMD_DELETE_SAVE)
{
selected_centry->activated = 0;
SetMenu(last_menu_id[MENU_PATCHES]);
return;
}

if (selected_centry->codes[0] == CMD_VIEW_RAW_PATCH)
{
selected_centry->activated = 0;
Expand Down Expand Up @@ -833,7 +853,7 @@ void drawScene(void)
doSaveMenu(&usb_saves);
break;

case MENU_HDD_SAVES: //HDD Saves Menu
case MENU_MEMCARD_SAVES: //HDD Saves Menu
doSaveMenu(&hdd_saves);
break;

Expand Down
25 changes: 24 additions & 1 deletion source/psv_resign.c
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ int vmc_export_psu(const char* path, const char* output)
}
free(p);

entry.length = 1024 - (dirent.stat.size % 1024);
entry.length = (1024 - (dirent.stat.size % 1024)) % 1024;
while(entry.length--)
fputc(0xFF, fh);
}
Expand All @@ -1076,3 +1076,26 @@ int vmc_export_psu(const char* path, const char* output)

return (i > 0);
}

int vmc_delete_save(const char* path)
{
int r, dd;
struct io_dirent dirent;
char filepath[256];
LOG("Deleting '%s'...", path);
dd = mcio_mcDopen(path);
if (dd < 0)
return 0;
do {
r = mcio_mcDread(dd, &dirent);
if (r && (strcmp(dirent.name, ".")) && (strcmp(dirent.name, "..")))
{
snprintf(filepath, sizeof(filepath), "%s/%s", path, dirent.name);
LOG("Deleting '%s'", filepath);
mcio_mcRemove(filepath);
}
} while (r);
mcio_mcDclose(dd);
r = mcio_mcRmDir(path);
return (r == sceMcResSucceed);
}
30 changes: 28 additions & 2 deletions source/saves.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@ int ReadCodes(save_entry_t * save)
code = _createCmdCode(PATCH_COMMAND, CHAR_ICON_USER " View Save Details", CMD_VIEW_DETAILS);
list_append(save->codes, code);

code = _createCmdCode(PATCH_COMMAND, CHAR_ICON_WARN " Delete Save Game", CMD_DELETE_SAVE);
list_append(save->codes, code);

if (save->flags & SAVE_FLAG_PS1)
{
add_ps1_commands(save);
Expand Down Expand Up @@ -613,6 +616,9 @@ int ReadVmc2Codes(save_entry_t * save)
cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_USER " View Save Details", CMD_VIEW_DETAILS);
list_append(save->codes, cmd);

cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_WARN " Delete Save Game", CMD_DELETE_SAVE);
list_append(save->codes, cmd);

cmd = _createCmdCode(PATCH_NULL, "----- " UTF8_CHAR_STAR " Save Transfer " UTF8_CHAR_STAR " -----", CMD_CODE_NULL);
list_append(save->codes, cmd);

Expand Down Expand Up @@ -918,10 +924,24 @@ int sortSaveList_Compare(const void* a, const void* b)
return strcasecmp(((save_entry_t*) a)->name, ((save_entry_t*) b)->name);
}

static int parseTypeFlags(int flags)
{
if (flags & SAVE_FLAG_PACKED)
return ((flags & SAVE_FLAG_PS1) ? FILE_TYPE_PSX : FILE_TYPE_PSU);
else if (flags & SAVE_FLAG_VMC)
return ((flags & SAVE_FLAG_PS1) ? FILE_TYPE_VMC : FILE_TYPE_VMC+1);
else if (flags & SAVE_FLAG_PS1)
return FILE_TYPE_PS1;
else if (flags & SAVE_FLAG_PS2)
return FILE_TYPE_PS2;

return 0;
}

int sortSaveList_Compare_Type(const void* a, const void* b)
{
int ta = ((save_entry_t*) a)->type;
int tb = ((save_entry_t*) b)->type;
int ta = parseTypeFlags(((save_entry_t*) a)->flags);
int tb = parseTypeFlags(((save_entry_t*) b)->flags);

if (ta == tb)
return sortSaveList_Compare(a, b);
Expand Down Expand Up @@ -1059,6 +1079,9 @@ static int set_psx_import_codes(save_entry_t* item)
cmd->options = _createMcOptions(2, "Import to MemCard", CMD_IMP_SAVE_MC);
list_append(item->codes, cmd);

cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_WARN " Delete Save Game", CMD_DELETE_SAVE);
list_append(item->codes, cmd);

return list_count(item->codes);
}

Expand Down Expand Up @@ -1519,6 +1542,9 @@ list_t * ReadVmc1List(const char* userPath)
asprintf(&item->path, "%s\n%s", userPath, mcdata[i].saveName);
sjis2ascii(item->name);

if(strlen(item->title_id) == 10 && item->title_id[4] == '-')
memmove(&item->title_id[4], &item->title_id[5], 6);

LOG("[%s] F(%X) name '%s'", item->title_id, item->flags, item->name);
list_append(list, item);
}
Expand Down

0 comments on commit 5c8fb36

Please sign in to comment.