cellSaveDataEnableOverlay

This commit is contained in:
Megamouse 2021-03-17 08:48:07 +01:00 committed by Ivan
parent 83fdcff178
commit 43ac33c2b4
6 changed files with 36 additions and 17 deletions

View file

@ -95,9 +95,10 @@ namespace
vm::gvar<savedata_context> g_savedata_context; vm::gvar<savedata_context> g_savedata_context;
struct savedata_mutex struct savedata_manager
{ {
semaphore<> mutex; semaphore<> mutex;
atomic_t<bool> enable_overlay;
}; };
static std::vector<SaveDataEntry> get_save_entries(const std::string& base_dir, const std::string& prefix) static std::vector<SaveDataEntry> get_save_entries(const std::string& base_dir, const std::string& prefix)
@ -163,7 +164,7 @@ static std::vector<SaveDataEntry> get_save_entries(const std::string& base_dir,
static error_code select_and_delete(ppu_thread& ppu) static error_code select_and_delete(ppu_thread& ppu)
{ {
std::unique_lock lock(g_fxo->get<savedata_mutex>().mutex, std::try_to_lock); std::unique_lock lock(g_fxo->get<savedata_manager>().mutex, std::try_to_lock);
if (!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. // Display a blocking Save Data List asynchronously in the GUI thread.
if (auto save_dialog = Emu.GetCallbacks().get_save_dialog()) 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<savedata_manager>().enable_overlay);
} }
// Reschedule after a blocking dialog returns // 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)}; return {CELL_SAVEDATA_ERROR_PARAM, std::to_string(ecode)};
} }
std::unique_lock lock(g_fxo->get<savedata_mutex>().mutex, std::try_to_lock); std::unique_lock lock(g_fxo->get<savedata_manager>().mutex, std::try_to_lock);
if (!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. // Display a blocking Save Data List asynchronously in the GUI thread.
if (auto save_dialog = Emu.GetCallbacks().get_save_dialog()) 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<savedata_manager>().enable_overlay);
} }
else else
{ {
@ -2284,7 +2285,9 @@ error_code cellSaveDataUserFixedDelete(ppu_thread& ppu, u32 userId, PSetList set
void cellSaveDataEnableOverlay(s32 enable) void cellSaveDataEnableOverlay(s32 enable)
{ {
cellSaveData.todo("cellSaveDataEnableOverlay(enable=%d)", enable); cellSaveData.notice("cellSaveDataEnableOverlay(enable=%d)", enable);
auto& manager = g_fxo->get<savedata_manager>();
manager.enable_overlay = enable != 0;
} }

View file

@ -359,5 +359,5 @@ class SaveDialogBase
public: public:
virtual ~SaveDialogBase(); virtual ~SaveDialogBase();
virtual s32 ShowSaveDataList(std::vector<SaveDataEntry>& save_entries, s32 focused, u32 op, vm::ptr<CellSaveDataListSet> listSet) = 0; virtual s32 ShowSaveDataList(std::vector<SaveDataEntry>& save_entries, s32 focused, u32 op, vm::ptr<CellSaveDataListSet> listSet, bool enable_overlay) = 0;
}; };

View file

@ -99,7 +99,7 @@ namespace rsx
static_cast<label*>(m_description.get())->auto_resize(); static_cast<label*>(m_description.get())->auto_resize();
static_cast<label*>(m_time_thingy.get())->auto_resize(); static_cast<label*>(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_description->back_color.a = 0.f;
m_time_thingy->back_color.a = 0.f; m_time_thingy->back_color.a = 0.f;
@ -160,10 +160,19 @@ namespace rsx
return result; return result;
} }
s32 save_dialog::show(std::vector<SaveDataEntry>& save_entries, u32 focused, u32 op, vm::ptr<CellSaveDataListSet> listSet) s32 save_dialog::show(std::vector<SaveDataEntry>& save_entries, u32 focused, u32 op, vm::ptr<CellSaveDataListSet> listSet, bool enable_overlay)
{ {
visible = false; visible = false;
if (enable_overlay)
{
m_dim_background->back_color.a = 1.0f;
}
else
{
m_dim_background->back_color.a = 0.5f;
}
std::vector<u8> icon; std::vector<u8> icon;
std::vector<std::unique_ptr<overlay_element>> entries; std::vector<std::unique_ptr<overlay_element>> entries;
@ -260,10 +269,17 @@ namespace rsx
if (auto err = run_input_loop()) if (auto err = run_input_loop())
return err; return err;
if (return_code + 0u == entries.size() && !newpos_head) if (return_code >= 0)
return selection_code::new_save; {
if (return_code >= 0 && newpos_head) if (newpos_head)
{
return return_code - 1; return return_code - 1;
}
else if (static_cast<usz>(return_code) == entries.size())
{
return selection_code::new_save;
}
}
return return_code; return return_code;
} }

View file

@ -35,7 +35,7 @@ namespace rsx
compiled_resource get_compiled() override; compiled_resource get_compiled() override;
s32 show(std::vector<SaveDataEntry>& save_entries, u32 focused, u32 op, vm::ptr<CellSaveDataListSet> listSet); s32 show(std::vector<SaveDataEntry>& save_entries, u32 focused, u32 op, vm::ptr<CellSaveDataListSet> listSet, bool enable_overlay);
}; };
} }
} }

View file

@ -8,12 +8,12 @@
#include "Utilities/Thread.h" #include "Utilities/Thread.h"
s32 save_data_dialog::ShowSaveDataList(std::vector<SaveDataEntry>& save_entries, s32 focused, u32 op, vm::ptr<CellSaveDataListSet> listSet) s32 save_data_dialog::ShowSaveDataList(std::vector<SaveDataEntry>& save_entries, s32 focused, u32 op, vm::ptr<CellSaveDataListSet> listSet, bool enable_overlay)
{ {
// TODO: Install native shell as an Emu callback // TODO: Install native shell as an Emu callback
if (auto manager = g_fxo->try_get<rsx::overlays::display_manager>()) if (auto manager = g_fxo->try_get<rsx::overlays::display_manager>())
{ {
auto result = manager->create<rsx::overlays::save_dialog>()->show(save_entries, focused, op, listSet); auto result = manager->create<rsx::overlays::save_dialog>()->show(save_entries, focused, op, listSet, enable_overlay);
if (result != rsx::overlays::user_interface::selection_code::error) if (result != rsx::overlays::user_interface::selection_code::error)
return result; return result;
} }

View file

@ -9,5 +9,5 @@
class save_data_dialog : public SaveDialogBase class save_data_dialog : public SaveDialogBase
{ {
public: public:
virtual s32 ShowSaveDataList(std::vector<SaveDataEntry>& save_entries, s32 focused, u32 op, vm::ptr<CellSaveDataListSet> listSet) override; virtual s32 ShowSaveDataList(std::vector<SaveDataEntry>& save_entries, s32 focused, u32 op, vm::ptr<CellSaveDataListSet> listSet, bool enable_overlay) override;
}; };