From 47da90736631198b5ee649c4c626dc72c4b1e062 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Fri, 27 Dec 2019 10:35:32 +0100 Subject: [PATCH] cellSaveData: add confirmation dialog for save data interactions --- rpcs3/Emu/Cell/Modules/cellSaveData.cpp | 56 +++++++++++++++++++++---- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp index 001dd50c84..5ba717f945 100644 --- a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp @@ -1,4 +1,4 @@ -#include "stdafx.h" +#include "stdafx.h" #include "Emu/System.h" #include "Emu/Cell/lv2/sys_sync.h" #include "Emu/Cell/lv2/sys_process.h" @@ -227,6 +227,24 @@ static error_code select_and_delete(ppu_thread& ppu) return CELL_CANCEL; } +static std::string get_confirmation_message(u32 operation) +{ + if (operation == SAVEDATA_OP_LIST_DELETE || operation == SAVEDATA_OP_FIXED_DELETE) + { + return "Delete this entry?"; + } + else if (operation == SAVEDATA_OP_LIST_LOAD || operation == SAVEDATA_OP_FIXED_LOAD) + { + return "Load this entry?"; + } + else if (operation == SAVEDATA_OP_LIST_SAVE || operation == SAVEDATA_OP_FIXED_SAVE) + { + return "Overwrite this entry?"; + } + + return ""; +} + static s32 savedata_check_args(u32 operation, u32 version, vm::cptr dirName, u32 errDialog, PSetList setList, PSetBuf setBuf, PFuncList funcList, PFuncFixed funcFixed, PFuncStat funcStat, PFuncFile funcFile, u32 container, u32 unk_op_flags, vm::ptr userdata, u32 userId, PFuncDone funcDone) @@ -759,19 +777,41 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v return 0; } - // UI returns -1 for new save games - if (selected == -1) - { - save_entry.dirName = listSet->newData->dirName.get_ptr(); - save_entry.escaped = vfs::escape(save_entry.dirName); - } - // Cancel selected in UI if (selected == -2) { return CELL_CANCEL; } + std::string message; + + // UI returns -1 for new save games + if (selected == -1) + { + message = "Create new Save Data?"; + save_entry.dirName = listSet->newData->dirName.get_ptr(); + save_entry.escaped = vfs::escape(save_entry.dirName); + } + else + { + // Get information from the selected entry + SaveDataEntry entry = save_entries[selected]; + message = get_confirmation_message(operation) + "\n\n" + entry.title + "\n" + entry.subtitle + "\n" + entry.details; + } + + // Get user confirmation + error_code res = open_msg_dialog(true, CELL_MSGDIALOG_TYPE_SE_TYPE_NORMAL | CELL_MSGDIALOG_TYPE_BUTTON_TYPE_YESNO, vm::make_str(message)); + + if (res != CELL_OK) + { + return CELL_SAVEDATA_ERROR_INTERNAL; + } + + if (g_last_user_response != CELL_MSGDIALOG_BUTTON_YES) + { + continue; + } + if (operation == SAVEDATA_OP_LIST_DELETE) { delete_save();