Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
bucanero committed Dec 6, 2024
1 parent 8a41d0c commit 205e86e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
4 changes: 2 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
8 changes: 8 additions & 0 deletions source/exec_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,9 @@ static int deleteSave(const save_entry_t* save)
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)
Expand All @@ -802,6 +805,11 @@ static int deleteSave(const save_entry_t* save)
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);
Expand Down
4 changes: 4 additions & 0 deletions source/menu_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ static void SetMenu(int id)
case MENU_MEMCARD_SAVES:
ReloadUserSaves(&hdd_saves);
break;

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

selected_entry->flags ^= SAVE_FLAG_UPDATED;
Expand Down
21 changes: 19 additions & 2 deletions source/saves.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,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 @@ -1065,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

0 comments on commit 205e86e

Please sign in to comment.