From 5c4af45bf522267864755536fb3b7f72a10310b4 Mon Sep 17 00:00:00 2001 From: GhettoGirl Date: Tue, 5 Jul 2016 00:00:46 +0200 Subject: [PATCH 1/2] GUI: improve prx library selection Sorts the libraries in the settings dialog alphabetically, so they are easier to find. Sorts selected and unselected modules alphabetically seperatly. --- rpcs3/Gui/SettingsDialog.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/rpcs3/Gui/SettingsDialog.cpp b/rpcs3/Gui/SettingsDialog.cpp index 294b086415..eb9f8617b8 100644 --- a/rpcs3/Gui/SettingsDialog.cpp +++ b/rpcs3/Gui/SettingsDialog.cpp @@ -16,6 +16,7 @@ #include #include +#include // Node location using cfg_location = std::vector; @@ -313,7 +314,14 @@ SettingsDialog::SettingsDialog(wxWindow* parent) std::vector lle_module_list; { + // Sort string vector alphabetically + static const auto sort_string_vector = [](std::vector& vec) + { + std::sort(vec.begin(), vec.end(), [](const std::string &str1, const std::string &str2) { return str1 < str2; }); + }; + auto&& data = loaded["Core"]["Load libraries"].as, std::initializer_list>({}); + sort_string_vector(data); // List selected modules first for (const auto& unk : data) @@ -325,16 +333,26 @@ SettingsDialog::SettingsDialog(wxWindow* parent) const std::string& lle_dir = vfs::get("/dev_flash/sys/external/"); // TODO std::unordered_set set(data.begin(), data.end()); + std::vector lle_module_list_unselected; for (const auto& prxf : fs::dir(lle_dir)) { // List found unselected modules if (!prxf.is_directory && ppu_prx_loader(fs::file(lle_dir + prxf.name)) == elf_error::ok && !set.count(prxf.name)) { - chbox_list_core_lle->Check(chbox_list_core_lle->Append(prxf.name), false); - lle_module_list.push_back(prxf.name); + lle_module_list_unselected.push_back(prxf.name); } } + + sort_string_vector(lle_module_list_unselected); + + for (const auto& prxf : lle_module_list_unselected) + { + chbox_list_core_lle->Check(chbox_list_core_lle->Append(prxf), false); + lle_module_list.push_back(prxf); + } + + lle_module_list_unselected.clear(); } radiobox_pad_helper ppu_decoder_modes({ "Core", "PPU Decoder" }); @@ -364,7 +382,7 @@ SettingsDialog::SettingsDialog(wxWindow* parent) pads.emplace_back(std::make_unique(cfg_location{ "Video", "Debug output" }, chbox_gs_debug_output)); pads.emplace_back(std::make_unique(cfg_location{ "Video", "3D Monitor" }, chbox_gs_3dmonitor)); pads.emplace_back(std::make_unique(cfg_location{ "Video", "Debug overlay" }, chbox_gs_overlay)); - + pads.emplace_back(std::make_unique(cfg_location{ "Audio", "Renderer" }, cbox_audio_out)); pads.emplace_back(std::make_unique(cfg_location{ "Audio", "Dump to file" }, chbox_audio_dump)); pads.emplace_back(std::make_unique(cfg_location{ "Audio", "Convert to 16 bit" }, chbox_audio_conv)); @@ -493,7 +511,7 @@ SettingsDialog::SettingsDialog(wxWindow* parent) s_b_panel->Add(new wxButton(this, wxID_OK), wxSizerFlags().Border(wxALL, 5).Bottom()); s_b_panel->Add(new wxButton(this, wxID_CANCEL), wxSizerFlags().Border(wxALL, 5).Bottom()); - // Resize panels + // Resize panels SetSizerAndFit(s_subpanel_core, false); SetSizerAndFit(s_subpanel_graphics, false); SetSizerAndFit(s_subpanel_io, false); From 758897a929c2396837dcbe3bc8bf1131c3001844 Mon Sep 17 00:00:00 2001 From: GhettoGirl Date: Tue, 5 Jul 2016 04:24:16 +0200 Subject: [PATCH 2/2] GUI: add prx library search functionality in settings dialog Add the possibility too lookup specific libraries in the settings dialog. --- rpcs3/Gui/SettingsDialog.cpp | 67 ++++++++++++++++++++++++++++++++---- rpcs3/Gui/SettingsDialog.h | 7 ++++ 2 files changed, 67 insertions(+), 7 deletions(-) diff --git a/rpcs3/Gui/SettingsDialog.cpp b/rpcs3/Gui/SettingsDialog.cpp index eb9f8617b8..4cd47c323b 100644 --- a/rpcs3/Gui/SettingsDialog.cpp +++ b/rpcs3/Gui/SettingsDialog.cpp @@ -251,7 +251,10 @@ SettingsDialog::SettingsDialog(wxWindow* parent) // Core wxStaticBoxSizer* s_round_core_lle = new wxStaticBoxSizer(wxVERTICAL, p_core, "Load libraries"); - wxCheckListBox* chbox_list_core_lle = new wxCheckListBox(p_core, wxID_ANY, wxDefaultPosition, wxDefaultSize, {}, wxLB_EXTENDED); + chbox_list_core_lle = new wxCheckListBox(p_core, wxID_ANY, wxDefaultPosition, wxDefaultSize, {}, wxLB_EXTENDED); + chbox_list_core_lle->Bind(wxEVT_CHECKLISTBOX, &SettingsDialog::OnModuleListItemToggled, this); + wxTextCtrl* s_module_search_box = new wxTextCtrl(p_core, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, {}); + s_module_search_box->Bind(wxEVT_TEXT, &SettingsDialog::OnSearchBoxTextChanged, this); // Graphics wxStaticBoxSizer* s_round_gs_render = new wxStaticBoxSizer(wxVERTICAL, p_graphics, "Render"); @@ -312,7 +315,6 @@ SettingsDialog::SettingsDialog(wxWindow* parent) wxCheckBox* chbox_dbg_ap_systemcall = new wxCheckBox(p_misc, wxID_ANY, "Auto Pause at System Call"); wxCheckBox* chbox_dbg_ap_functioncall = new wxCheckBox(p_misc, wxID_ANY, "Auto Pause at Function Call"); - std::vector lle_module_list; { // Sort string vector alphabetically static const auto sort_string_vector = [](std::vector& vec) @@ -326,8 +328,8 @@ SettingsDialog::SettingsDialog(wxWindow* parent) // List selected modules first for (const auto& unk : data) { + lle_module_list.insert(lle_module_list.end(), std::pair(unk, true)); chbox_list_core_lle->Check(chbox_list_core_lle->Append(unk)); - lle_module_list.push_back(unk); } const std::string& lle_dir = vfs::get("/dev_flash/sys/external/"); // TODO @@ -348,8 +350,8 @@ SettingsDialog::SettingsDialog(wxWindow* parent) for (const auto& prxf : lle_module_list_unselected) { + lle_module_list.insert(lle_module_list.end(), std::pair(prxf, false)); chbox_list_core_lle->Check(chbox_list_core_lle->Append(prxf), false); - lle_module_list.push_back(prxf); } lle_module_list_unselected.clear(); @@ -426,6 +428,7 @@ SettingsDialog::SettingsDialog(wxWindow* parent) // Core s_round_core_lle->Add(chbox_list_core_lle, wxSizerFlags().Border(wxALL, 5).Expand()); + s_round_core_lle->Add(s_module_search_box, wxSizerFlags().Border(wxALL, 5).Expand()); // Rendering s_round_gs_render->Add(cbox_gs_render, wxSizerFlags().Border(wxALL, 5).Expand()); @@ -527,11 +530,11 @@ SettingsDialog::SettingsDialog(wxWindow* parent) { std::set lle_selected; - for (auto i = 0; i < lle_module_list.size(); i++) + for (auto& i : lle_module_list) { - if (chbox_list_core_lle->IsChecked(i)) + if (i.second) // selected { - lle_selected.emplace(lle_module_list[i]); + lle_selected.emplace(i.first); } } @@ -553,3 +556,53 @@ SettingsDialog::SettingsDialog(wxWindow* parent) config.write(out.c_str(), out.size()); } } + +void SettingsDialog::OnModuleListItemToggled(wxCommandEvent &event) +{ + lle_module_list[fmt::ToUTF8(event.GetString())] = chbox_list_core_lle->IsChecked(event.GetSelection()); +} + +void SettingsDialog::OnSearchBoxTextChanged(wxCommandEvent &event) +{ + // helper to preserve alphabetically order while inserting items + int item_index = 0; + + if (event.GetString().IsEmpty()) + { + for (auto& i : lle_module_list) + { + if (i.second) + { + chbox_list_core_lle->Check(chbox_list_core_lle->Insert(i.first, item_index)); + item_index++; + } + + else + { + chbox_list_core_lle->Check(chbox_list_core_lle->Insert(i.first, chbox_list_core_lle->GetCount()), false); + } + } + } + + chbox_list_core_lle->Clear(); + + wxString search_term = event.GetString().Lower(); + item_index = 0; + + for (auto& i : lle_module_list) + { + if (fmt::FromUTF8(i.first).Find(search_term) != wxString::npos) + { + if (i.second) + { + chbox_list_core_lle->Check(chbox_list_core_lle->Insert(i.first, item_index)); + item_index++; + } + + else + { + chbox_list_core_lle->Check(chbox_list_core_lle->Insert(i.first, chbox_list_core_lle->GetCount()), false); + } + } + } +} diff --git a/rpcs3/Gui/SettingsDialog.h b/rpcs3/Gui/SettingsDialog.h index fb64f7ee86..44cd6c792b 100644 --- a/rpcs3/Gui/SettingsDialog.h +++ b/rpcs3/Gui/SettingsDialog.h @@ -4,4 +4,11 @@ class SettingsDialog : public wxDialog { public: SettingsDialog(wxWindow* parent); + +private: + wxCheckListBox* chbox_list_core_lle; + + void OnModuleListItemToggled(wxCommandEvent& event); + void OnSearchBoxTextChanged(wxCommandEvent& event); + std::map lle_module_list; };