diff --git a/source/ui/section/action/action.h b/source/ui/section/action/action.h index 94b1fea..afcfc11 100644 --- a/source/ui/section/action/action.h +++ b/source/ui/section/action/action.h @@ -3,10 +3,11 @@ #include "../task/task.h" void action_browse_boss_ext_save_data(ext_save_data_info* info); - void action_browse_user_ext_save_data(ext_save_data_info* info); +void action_delete_ext_save_data(ext_save_data_info* info); void action_browse_system_save_data(system_save_data_info* info); +void action_delete_system_save_data(system_save_data_info* info); void action_install_cias_nand(file_info* info); void action_install_cias_sd(file_info* info); diff --git a/source/ui/section/action/deleteextsavedata.c b/source/ui/section/action/deleteextsavedata.c new file mode 100644 index 0000000..36afe86 --- /dev/null +++ b/source/ui/section/action/deleteextsavedata.c @@ -0,0 +1,43 @@ +#include <3ds.h> + +#include "action.h" +#include "../../error.h" +#include "../../progressbar.h" +#include "../../prompt.h" +#include "../task/task.h" + +static void action_delete_ext_save_data_success_onresponse(ui_view* view, void* data, bool response) { + prompt_destroy(view); +} + +static void action_delete_ext_save_data_update(ui_view* view, void* data, float* progress, char* progressText) { + ext_save_data_info* info = (ext_save_data_info*) data; + + FS_ExtSaveDataInfo extInfo = {.mediaType = info->mediaType, .saveId = info->extSaveDataId}; + Result res = FSUSER_DeleteExtSaveData(extInfo); + if(R_FAILED(res)) { + progressbar_destroy(view); + ui_pop(); + + error_display_res(info, ui_draw_ext_save_data_info, res, "Failed to delete ext save data."); + + return; + } + + progressbar_destroy(view); + ui_pop(); + + ui_push(prompt_create("Success", "Ext save data deleted.", 0xFF000000, false, info, NULL, ui_draw_ext_save_data_info, action_delete_ext_save_data_success_onresponse)); +} + +static void action_delete_ext_save_data_onresponse(ui_view* view, void* data, bool response) { + prompt_destroy(view); + + if(response) { + ui_push(progressbar_create("Deleting Ext Save Data", "", data, action_delete_ext_save_data_update, ui_draw_ext_save_data_info)); + } +} + +void action_delete_ext_save_data(ext_save_data_info* info) { + ui_push(prompt_create("Confirmation", "Delete the selected ext save data?", 0xFF000000, true, info, NULL, ui_draw_ext_save_data_info, action_delete_ext_save_data_onresponse)); +} \ No newline at end of file diff --git a/source/ui/section/action/deletesystemsavedata.c b/source/ui/section/action/deletesystemsavedata.c new file mode 100644 index 0000000..d227a09 --- /dev/null +++ b/source/ui/section/action/deletesystemsavedata.c @@ -0,0 +1,42 @@ +#include <3ds.h> + +#include "action.h" +#include "../../error.h" +#include "../../progressbar.h" +#include "../../prompt.h" + +static void action_delete_system_save_data_success_onresponse(ui_view* view, void* data, bool response) { + prompt_destroy(view); +} + +static void action_delete_system_save_data_update(ui_view* view, void* data, float* progress, char* progressText) { + system_save_data_info* info = (system_save_data_info*) data; + + FS_SystemSaveDataInfo sysInfo = *(FS_SystemSaveDataInfo*) &info->systemSaveDataId; + Result res = FSUSER_DeleteSystemSaveData(sysInfo); + if(R_FAILED(res)) { + progressbar_destroy(view); + ui_pop(); + + error_display_res(info, ui_draw_system_save_data_info, res, "Failed to delete system save data."); + + return; + } + + progressbar_destroy(view); + ui_pop(); + + ui_push(prompt_create("Success", "System save data deleted.", 0xFF000000, false, info, NULL, ui_draw_system_save_data_info, action_delete_system_save_data_success_onresponse)); +} + +static void action_delete_system_save_data_onresponse(ui_view* view, void* data, bool response) { + prompt_destroy(view); + + if(response) { + ui_push(progressbar_create("Deleting System Save Data", "", data, action_delete_system_save_data_update, ui_draw_system_save_data_info)); + } +} + +void action_delete_system_save_data(system_save_data_info* info) { + ui_push(prompt_create("Confirmation", "Delete the selected system save data?", 0xFF000000, true, info, NULL, ui_draw_system_save_data_info, action_delete_system_save_data_onresponse)); +} \ No newline at end of file diff --git a/source/ui/section/extsavedata.c b/source/ui/section/extsavedata.c index 119a2c5..cc5a57e 100644 --- a/source/ui/section/extsavedata.c +++ b/source/ui/section/extsavedata.c @@ -16,12 +16,13 @@ typedef struct { bool populated; } extsavedata_data; -#define EXTSAVEDATA_ACTION_COUNT 2 +#define EXTSAVEDATA_ACTION_COUNT 3 static u32 extsavedata_action_count = EXTSAVEDATA_ACTION_COUNT; static list_item extsavedata_action_items[EXTSAVEDATA_ACTION_COUNT] = { {"Browse User Save Data", 0xFF000000, action_browse_user_ext_save_data}, {"Browse SpotPass Save Data", 0xFF000000, action_browse_boss_ext_save_data}, + {"Delete Save Data", 0xFF000000, action_delete_ext_save_data}, }; static void extsavedata_action_draw_top(ui_view* view, void* data, float x1, float y1, float x2, float y2, list_item* selected) { diff --git a/source/ui/section/systemsavedata.c b/source/ui/section/systemsavedata.c index 765758e..59640b5 100644 --- a/source/ui/section/systemsavedata.c +++ b/source/ui/section/systemsavedata.c @@ -16,11 +16,12 @@ typedef struct { bool populated; } systemsavedata_data; -#define SYSTEMSAVEDATA_ACTION_COUNT 1 +#define SYSTEMSAVEDATA_ACTION_COUNT 2 static u32 systemsavedata_action_count = SYSTEMSAVEDATA_ACTION_COUNT; static list_item systemsavedata_action_items[SYSTEMSAVEDATA_ACTION_COUNT] = { {"Browse Save Data", 0xFF000000, action_browse_system_save_data}, + {"Delete Save Data", 0xFF000000, action_delete_system_save_data}, }; static void systemsavedata_action_draw_top(ui_view* view, void* data, float x1, float y1, float x2, float y2, list_item* selected) {