From 43ac33c2b46198c6e8bde9ed9e7fb2d72bb8dc57 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Wed, 17 Mar 2021 08:48:07 +0100 Subject: [PATCH] cellSaveDataEnableOverlay --- rpcs3/Emu/Cell/Modules/cellSaveData.cpp | 15 ++++++---- rpcs3/Emu/Cell/Modules/cellSaveData.h | 2 +- .../Emu/RSX/Overlays/overlay_save_dialog.cpp | 28 +++++++++++++++---- rpcs3/Emu/RSX/Overlays/overlay_save_dialog.h | 2 +- rpcs3/rpcs3qt/save_data_dialog.cpp | 4 +-- rpcs3/rpcs3qt/save_data_dialog.h | 2 +- 6 files changed, 36 insertions(+), 17 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp index 8f8c3448b7..92907e483a 100644 --- a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp @@ -95,9 +95,10 @@ namespace vm::gvar g_savedata_context; -struct savedata_mutex +struct savedata_manager { semaphore<> mutex; + atomic_t enable_overlay; }; static std::vector get_save_entries(const std::string& base_dir, const std::string& prefix) @@ -163,7 +164,7 @@ static std::vector get_save_entries(const std::string& base_dir, static error_code select_and_delete(ppu_thread& ppu) { - std::unique_lock lock(g_fxo->get().mutex, std::try_to_lock); + std::unique_lock lock(g_fxo->get().mutex, std::try_to_lock); if (!lock) { @@ -185,7 +186,7 @@ static error_code select_and_delete(ppu_thread& ppu) // Display a blocking Save Data List asynchronously in the GUI thread. if (auto save_dialog = Emu.GetCallbacks().get_save_dialog()) { - selected = save_dialog->ShowSaveDataList(save_entries, focused, SAVEDATA_OP_LIST_DELETE, vm::null); + selected = save_dialog->ShowSaveDataList(save_entries, focused, SAVEDATA_OP_LIST_DELETE, vm::null, g_fxo->get().enable_overlay); } // Reschedule after a blocking dialog returns @@ -558,7 +559,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v return {CELL_SAVEDATA_ERROR_PARAM, std::to_string(ecode)}; } - std::unique_lock lock(g_fxo->get().mutex, std::try_to_lock); + std::unique_lock lock(g_fxo->get().mutex, std::try_to_lock); if (!lock) { @@ -998,7 +999,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v // Display a blocking Save Data List asynchronously in the GUI thread. if (auto save_dialog = Emu.GetCallbacks().get_save_dialog()) { - selected = save_dialog->ShowSaveDataList(save_entries, focused, operation, listSet); + selected = save_dialog->ShowSaveDataList(save_entries, focused, operation, listSet, g_fxo->get().enable_overlay); } else { @@ -2284,7 +2285,9 @@ error_code cellSaveDataUserFixedDelete(ppu_thread& ppu, u32 userId, PSetList set void cellSaveDataEnableOverlay(s32 enable) { - cellSaveData.todo("cellSaveDataEnableOverlay(enable=%d)", enable); + cellSaveData.notice("cellSaveDataEnableOverlay(enable=%d)", enable); + auto& manager = g_fxo->get(); + manager.enable_overlay = enable != 0; } diff --git a/rpcs3/Emu/Cell/Modules/cellSaveData.h b/rpcs3/Emu/Cell/Modules/cellSaveData.h index 93938faadf..baa46bdea3 100644 --- a/rpcs3/Emu/Cell/Modules/cellSaveData.h +++ b/rpcs3/Emu/Cell/Modules/cellSaveData.h @@ -359,5 +359,5 @@ class SaveDialogBase public: virtual ~SaveDialogBase(); - virtual s32 ShowSaveDataList(std::vector& save_entries, s32 focused, u32 op, vm::ptr listSet) = 0; + virtual s32 ShowSaveDataList(std::vector& save_entries, s32 focused, u32 op, vm::ptr listSet, bool enable_overlay) = 0; }; diff --git a/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp b/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp index ecd9cffe3d..644aa274ad 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp @@ -99,7 +99,7 @@ namespace rsx static_cast(m_description.get())->auto_resize(); static_cast(m_time_thingy.get())->auto_resize(); - m_dim_background->back_color.a = 0.8f; + m_dim_background->back_color.a = 0.5f; m_description->back_color.a = 0.f; m_time_thingy->back_color.a = 0.f; @@ -160,10 +160,19 @@ namespace rsx return result; } - s32 save_dialog::show(std::vector& save_entries, u32 focused, u32 op, vm::ptr listSet) + s32 save_dialog::show(std::vector& save_entries, u32 focused, u32 op, vm::ptr listSet, bool enable_overlay) { visible = false; + if (enable_overlay) + { + m_dim_background->back_color.a = 1.0f; + } + else + { + m_dim_background->back_color.a = 0.5f; + } + std::vector icon; std::vector> entries; @@ -260,10 +269,17 @@ namespace rsx if (auto err = run_input_loop()) return err; - if (return_code + 0u == entries.size() && !newpos_head) - return selection_code::new_save; - if (return_code >= 0 && newpos_head) - return return_code - 1; + if (return_code >= 0) + { + if (newpos_head) + { + return return_code - 1; + } + else if (static_cast(return_code) == entries.size()) + { + return selection_code::new_save; + } + } return return_code; } diff --git a/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.h b/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.h index 3e30362376..ea3b1e349b 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.h @@ -35,7 +35,7 @@ namespace rsx compiled_resource get_compiled() override; - s32 show(std::vector& save_entries, u32 focused, u32 op, vm::ptr listSet); + s32 show(std::vector& save_entries, u32 focused, u32 op, vm::ptr listSet, bool enable_overlay); }; } } diff --git a/rpcs3/rpcs3qt/save_data_dialog.cpp b/rpcs3/rpcs3qt/save_data_dialog.cpp index d1ea7dc87d..167a4eb49b 100644 --- a/rpcs3/rpcs3qt/save_data_dialog.cpp +++ b/rpcs3/rpcs3qt/save_data_dialog.cpp @@ -8,12 +8,12 @@ #include "Utilities/Thread.h" -s32 save_data_dialog::ShowSaveDataList(std::vector& save_entries, s32 focused, u32 op, vm::ptr listSet) +s32 save_data_dialog::ShowSaveDataList(std::vector& save_entries, s32 focused, u32 op, vm::ptr listSet, bool enable_overlay) { // TODO: Install native shell as an Emu callback if (auto manager = g_fxo->try_get()) { - auto result = manager->create()->show(save_entries, focused, op, listSet); + auto result = manager->create()->show(save_entries, focused, op, listSet, enable_overlay); if (result != rsx::overlays::user_interface::selection_code::error) return result; } diff --git a/rpcs3/rpcs3qt/save_data_dialog.h b/rpcs3/rpcs3qt/save_data_dialog.h index e9c8c3c250..8cca7af6dd 100644 --- a/rpcs3/rpcs3qt/save_data_dialog.h +++ b/rpcs3/rpcs3qt/save_data_dialog.h @@ -9,5 +9,5 @@ class save_data_dialog : public SaveDialogBase { public: - virtual s32 ShowSaveDataList(std::vector& save_entries, s32 focused, u32 op, vm::ptr listSet) override; + virtual s32 ShowSaveDataList(std::vector& save_entries, s32 focused, u32 op, vm::ptr listSet, bool enable_overlay) override; };