From abf454718f69f3718eb4ab5678dde4aaa5e5e494 Mon Sep 17 00:00:00 2001 From: NicknineTheEagle Date: Sat, 22 Jun 2024 14:40:48 +0300 Subject: [PATCH] cellSaveData: Add autosave indicator --- rpcs3/Emu/Cell/Modules/cellSaveData.cpp | 48 +++++++++++++++++++++++++ rpcs3/Emu/localized_string_id.h | 2 ++ rpcs3/rpcs3qt/localized_emu.h | 2 ++ 3 files changed, 52 insertions(+) diff --git a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp index dee57ac893..a431243327 100644 --- a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp @@ -10,6 +10,7 @@ #include "Emu/Cell/PPUModule.h" #include "Emu/Cell/Modules/cellSysutil.h" #include "Emu/Cell/Modules/cellUserInfo.h" +#include "Emu/RSX/Overlays/overlay_message.h" #include "cellSaveData.h" #include "cellMsgDialog.h" @@ -1750,6 +1751,48 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v fileGet->excSize = 0; + // show indicator for automatic save or auto load interactions if the game requests it (statSet->indicator) + const bool show_auto_indicator = operation <= SAVEDATA_OP_LIST_AUTO_LOAD && statSet && statSet->indicator; + + if (show_auto_indicator) + { + auto msg_text = localized_string_id::INVALID; + if (operation == SAVEDATA_OP_AUTO_SAVE || operation == SAVEDATA_OP_LIST_AUTO_SAVE) + { + msg_text = localized_string_id::CELL_SAVEDATA_AUTOSAVE; + } + else if (operation == SAVEDATA_OP_AUTO_LOAD || operation == SAVEDATA_OP_LIST_AUTO_LOAD) + { + msg_text = localized_string_id::CELL_SAVEDATA_AUTOLOAD; + } + + u32 indicator_pos = (statSet->indicator->dispPosition & 0x0F); + + auto msg_location = rsx::overlays::message_pin_location::top; + switch (indicator_pos) + { + case CELL_SAVEDATA_INDICATORPOS_UPPER_LEFT: + msg_location = rsx::overlays::message_pin_location::top; + break; + case CELL_SAVEDATA_INDICATORPOS_LOWER_LEFT: + msg_location = rsx::overlays::message_pin_location::bottom; + break; + case CELL_SAVEDATA_INDICATORPOS_UPPER_RIGHT: + msg_location = rsx::overlays::message_pin_location::top_right; + break; + case CELL_SAVEDATA_INDICATORPOS_LOWER_RIGHT: + msg_location = rsx::overlays::message_pin_location::bottom_right; + break; + } + + // TODO: Blinking variants + + // RPCS3 saves basically instantaneously so there's not much point in showing auto indicator + // WHILE saving is in progress. Instead we show the indicator for 3 seconds to let the user + // know when the game autosaves. + rsx::overlays::queue_message(msg_text, 3'000'000, {}, msg_location); + } + error_code savedata_result = CELL_OK; u64 delay_save_until = 0; @@ -2098,6 +2141,11 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v fs::remove_all(old_path); } + if (show_auto_indicator) + { + // auto indicator should be hidden here if save/load throttling is added + } + if (savedata_result + 0u == CELL_SAVEDATA_ERROR_CBRESULT) { return display_callback_result_error_message(ppu, *result, errDialog); diff --git a/rpcs3/Emu/localized_string_id.h b/rpcs3/Emu/localized_string_id.h index 6e2bb3c2dc..991f270961 100644 --- a/rpcs3/Emu/localized_string_id.h +++ b/rpcs3/Emu/localized_string_id.h @@ -132,6 +132,8 @@ enum class localized_string_id CELL_SAVEDATA_SAVE, CELL_SAVEDATA_LOAD, CELL_SAVEDATA_OVERWRITE, + CELL_SAVEDATA_AUTOSAVE, + CELL_SAVEDATA_AUTOLOAD, CELL_CROSS_CONTROLLER_MSG, CELL_CROSS_CONTROLLER_FW_MSG, diff --git a/rpcs3/rpcs3qt/localized_emu.h b/rpcs3/rpcs3qt/localized_emu.h index eff8602ff8..194f32e5a0 100644 --- a/rpcs3/rpcs3qt/localized_emu.h +++ b/rpcs3/rpcs3qt/localized_emu.h @@ -159,6 +159,8 @@ private: case localized_string_id::CELL_SAVEDATA_DELETE: return tr("Delete this data?\n\n%0", "Savedata entry info").arg(std::forward(args)...); case localized_string_id::CELL_SAVEDATA_LOAD: return tr("Load this data?\n\n%0", "Savedata entry info").arg(std::forward(args)...); case localized_string_id::CELL_SAVEDATA_OVERWRITE: return tr("Do you want to overwrite the saved data?\n\n%0", "Savedata entry info").arg(std::forward(args)...); + case localized_string_id::CELL_SAVEDATA_AUTOSAVE: return tr("Saving..."); + case localized_string_id::CELL_SAVEDATA_AUTOLOAD: return tr("Loading..."); case localized_string_id::CELL_CROSS_CONTROLLER_MSG: return tr("Start [%0] on the PS Vita system.\nIf you have not installed [%0], go to [Remote Play] on the PS Vita system and start [Cross-Controller] from the LiveArea™ screen.", "Cross-Controller message").arg(std::forward(args)...); case localized_string_id::CELL_CROSS_CONTROLLER_FW_MSG: return tr("If your system software version on the PS Vita system is earlier than 1.80, you must update the system software to the latest version.", "Cross-Controller firmware message"); case localized_string_id::CELL_NP_RECVMESSAGE_DIALOG_TITLE: return tr("Select Message", "RECVMESSAGE_DIALOG");