From 2d29a33ea889b742469cb4dd837e88d92487e1ac Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 13 Jul 2019 21:43:02 +0200 Subject: [PATCH] cellSaveData/overlays: initialize with focused entry --- rpcs3/Emu/RSX/Overlays/overlay_controls.h | 3 ++- rpcs3/Emu/RSX/Overlays/overlay_list_view.cpp | 19 ++++++++++--------- .../Emu/RSX/Overlays/overlay_save_dialog.cpp | 6 ++++-- rpcs3/Emu/RSX/Overlays/overlays.h | 2 +- rpcs3/rpcs3qt/save_data_dialog.cpp | 2 +- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/rpcs3/Emu/RSX/Overlays/overlay_controls.h b/rpcs3/Emu/RSX/Overlays/overlay_controls.h index 8f819dd047..6b38caf67b 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_controls.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_controls.h @@ -1168,7 +1168,7 @@ namespace rsx std::unique_ptr m_highlight_box; u16 m_elements_height = 0; - s16 m_selected_entry = -1; + s32 m_selected_entry = -1; u16 m_elements_count = 0; bool m_cancel_only = false; @@ -1178,6 +1178,7 @@ namespace rsx void update_selection(); + void select_entry(s32 entry); void select_next(u16 count = 1); void select_previous(u16 count = 1); diff --git a/rpcs3/Emu/RSX/Overlays/overlay_list_view.cpp b/rpcs3/Emu/RSX/Overlays/overlay_list_view.cpp index 857e1eff7d..02d9d8392c 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_list_view.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_list_view.cpp @@ -91,24 +91,25 @@ namespace rsx refresh(); } - void list_view::select_next(u16 count) + void list_view::select_entry(s32 entry) { - const int max_entry = m_elements_count - 1; + const s32 max_entry = m_elements_count - 1; - if (m_selected_entry < max_entry) + if (m_selected_entry != entry) { - m_selected_entry = std::min(m_selected_entry + count, max_entry); + m_selected_entry = std::max(0, std::min(entry, max_entry)); update_selection(); } } + void list_view::select_next(u16 count) + { + select_entry(m_selected_entry + count); + } + void list_view::select_previous(u16 count) { - if (m_selected_entry > 0) - { - m_selected_entry = std::max(0, m_selected_entry - count); - update_selection(); - } + select_entry(m_selected_entry - count); } void list_view::add_entry(std::unique_ptr& entry) diff --git a/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp b/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp index 812da43fca..78e6e44604 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp @@ -1,4 +1,4 @@ -#include "stdafx.h" +#include "stdafx.h" #include "overlays.h" namespace rsx @@ -154,7 +154,7 @@ namespace rsx return result; } - s32 save_dialog::show(std::vector& save_entries, u32 op, vm::ptr listSet) + s32 save_dialog::show(std::vector& save_entries, u32 focused, u32 op, vm::ptr listSet) { std::vector icon; std::vector> entries; @@ -241,6 +241,8 @@ namespace rsx m_list->set_cancel_only(true); } + m_list->select_entry(focused); + static_cast(m_description.get())->auto_resize(); if (auto err = run_input_loop()) diff --git a/rpcs3/Emu/RSX/Overlays/overlays.h b/rpcs3/Emu/RSX/Overlays/overlays.h index 44a991b9ef..1336dbd03a 100644 --- a/rpcs3/Emu/RSX/Overlays/overlays.h +++ b/rpcs3/Emu/RSX/Overlays/overlays.h @@ -515,7 +515,7 @@ namespace rsx compiled_resource get_compiled() override; - s32 show(std::vector& save_entries, u32 op, vm::ptr listSet); + s32 show(std::vector& save_entries, u32 focused, u32 op, vm::ptr listSet); }; struct message_dialog : public user_interface diff --git a/rpcs3/rpcs3qt/save_data_dialog.cpp b/rpcs3/rpcs3qt/save_data_dialog.cpp index 42add41ca6..282e4f6467 100644 --- a/rpcs3/rpcs3qt/save_data_dialog.cpp +++ b/rpcs3/rpcs3qt/save_data_dialog.cpp @@ -9,7 +9,7 @@ s32 save_data_dialog::ShowSaveDataList(std::vector& save_entries, // TODO: Install native shell as an Emu callback if (auto manager = fxm::get()) { - auto result = manager->create()->show(save_entries, op, listSet); + auto result = manager->create()->show(save_entries, focused, op, listSet); if (result != rsx::overlays::user_interface::selection_code::error) return result; }