From f16a6b8abdcb9055f81a96f74df4fc809ca2f355 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 23 May 2020 23:11:03 -0700 Subject: [PATCH] MsgDialog: Show better error messages. I think the PSP really did just show error codes, but that's not a reason to keep that confusion going. For common save errors, let's show the messages. Some games, for example, simply show the no data found error when you play for the first time and trigger anything to check for data. --- Core/Dialog/PSPMsgDialog.cpp | 37 +++++++++++++++++++++++++++++++++++- Core/Dialog/PSPMsgDialog.h | 3 ++- Core/Dialog/SavedataParam.h | 1 + 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/Core/Dialog/PSPMsgDialog.cpp b/Core/Dialog/PSPMsgDialog.cpp index d90354f70f..7ddd1f8a73 100755 --- a/Core/Dialog/PSPMsgDialog.cpp +++ b/Core/Dialog/PSPMsgDialog.cpp @@ -17,6 +17,7 @@ #include #include "Core/Dialog/PSPMsgDialog.h" +#include "Core/Dialog/PSPSaveDialog.h" #include "Core/Util/PPGeDraw.h" #include "Core/HLE/sceCtrl.h" #include "Core/MemMapHelpers.h" @@ -133,7 +134,7 @@ int PSPMsgDialog::Init(unsigned int paramAddr) { } if (flag & DS_ERRORMSG) { - snprintf(msgText, 512, "Error code: %08x", messageDialog.errorNum); + FormatErrorCode(messageDialog.errorNum); } else { truncate_cpy(msgText, messageDialog.string); } @@ -145,6 +146,40 @@ int PSPMsgDialog::Init(unsigned int paramAddr) { return 0; } + +void PSPMsgDialog::FormatErrorCode(uint32_t code) { + auto di = GetI18NCategory("Dialog"); + + switch (code) { + case SCE_UTILITY_SAVEDATA_ERROR_LOAD_DATA_BROKEN: + snprintf(msgText, 512, "%s (%08x)", di->T("MsgErrorSavedataDataBroken", "Save data was corrupt."), code); + break; + + case SCE_UTILITY_SAVEDATA_ERROR_LOAD_NO_MS: + case SCE_UTILITY_SAVEDATA_ERROR_RW_NO_MEMSTICK: + case SCE_UTILITY_SAVEDATA_ERROR_SAVE_NO_MS: + case SCE_UTILITY_SAVEDATA_ERROR_DELETE_NO_MS: + case SCE_UTILITY_SAVEDATA_ERROR_SIZES_NO_MS: + snprintf(msgText, 512, "%s (%08x)", di->T("MsgErrorSavedataNoMS", "Memory stick not inserted."), code); + break; + + case SCE_UTILITY_SAVEDATA_ERROR_LOAD_NO_DATA: + case SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA: + case SCE_UTILITY_SAVEDATA_ERROR_DELETE_NO_DATA: + case SCE_UTILITY_SAVEDATA_ERROR_SIZES_NO_DATA: + snprintf(msgText, 512, "%s (%08x)", di->T("MsgErrorSavedataNoData", "Warning: no save data was found."), code); + break; + + case SCE_UTILITY_SAVEDATA_ERROR_RW_MEMSTICK_FULL: + case SCE_UTILITY_SAVEDATA_ERROR_SAVE_MS_NOSPACE: + snprintf(msgText, 512, "%s (%08x)", di->T("MsgErrorSavedataMSFull", "Memory stick full. Check your storage space."), code); + break; + + default: + snprintf(msgText, 512, "%s %08x", di->T("MsgErrorCode", "Error code:"), code); + } +} + void PSPMsgDialog::DisplayMessage(std::string text, bool hasYesNo, bool hasOK) { auto di = GetI18NCategory("Dialog"); diff --git a/Core/Dialog/PSPMsgDialog.h b/Core/Dialog/PSPMsgDialog.h index 64309f4659..78490393f8 100644 --- a/Core/Dialog/PSPMsgDialog.h +++ b/Core/Dialog/PSPMsgDialog.h @@ -74,7 +74,8 @@ protected: return false; } -private : +private: + void FormatErrorCode(uint32_t code); void DisplayMessage(std::string text, bool hasYesNo = false, bool hasOK = false); enum Flags diff --git a/Core/Dialog/SavedataParam.h b/Core/Dialog/SavedataParam.h index e509463712..857c69779b 100644 --- a/Core/Dialog/SavedataParam.h +++ b/Core/Dialog/SavedataParam.h @@ -17,6 +17,7 @@ #pragma once +#include #include "Common/CommonTypes.h" #include "Core/MemMap.h" #include "Core/HLE/sceRtc.h"