From 95f67080f8535da366692a8cfa338ab7914346a6 Mon Sep 17 00:00:00 2001 From: Blaypeg Date: Sun, 25 May 2014 19:45:44 +0100 Subject: [PATCH 1/4] Attempt to make columns sortable for game list --- rpcs3/Gui/GameViewer.cpp | 43 ++++++++++++++++++++++++++++++++++++++++ rpcs3/Gui/GameViewer.h | 22 +++++++++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/rpcs3/Gui/GameViewer.cpp b/rpcs3/Gui/GameViewer.cpp index eb3d41aa6e..c57efd12c8 100644 --- a/rpcs3/Gui/GameViewer.cpp +++ b/rpcs3/Gui/GameViewer.cpp @@ -11,6 +11,7 @@ GameViewer::GameViewer(wxWindow* parent) : wxListView(parent) m_path = "/dev_hdd0/game/"; Bind(wxEVT_LIST_ITEM_ACTIVATED, &GameViewer::DClick, this); + Bind(wxEVT_LIST_COL_CLICK, &GameViewer::OnColClick, this); Refresh(); } @@ -25,6 +26,48 @@ void GameViewer::DoResize(wxSize size) SetSize(size); } +int wxCALLBACK ListItemCompare(long item1, long item2, long sortinfo) +{ + ListSortInfo *SortInfo = (ListSortInfo *)sortinfo; + int Column = SortInfo->Column; + GameViewer *pGameViewer = SortInfo->GameViewerCtrl; + bool SortAscending = SortInfo->SortAscending; + long index1 = pGameViewer->FindItem(0, item1); + long index2 = pGameViewer->FindItem(0, item2); + wxString string1 = pGameViewer->GetItemText(index1, Column); + wxString string2 = pGameViewer->GetItemText(index2, Column); + + if (string1.Cmp(string2) < 0) + { + return SortAscending ? -1 : 1; + } + else + if (string1.Cmp(string2) > 0) + { + return SortAscending ? 1 : -1; + } + else + { + return 0; + } +} + +void GameViewer::OnColClick(wxListEvent& event) +{ + if (event.GetColumn() == SortInfo.Column) + { + SortInfo.SortAscending = SortInfo.SortAscending ? FALSE : TRUE; + } + else + { + SortInfo.SortAscending = TRUE; + } + SortInfo.Column = event.GetColumn(); + SortInfo.GameViewerCtrl = this; + SortItems(ListItemCompare, (long)&SortInfo); +} + + void GameViewer::LoadGames() { vfsDir dir(m_path); diff --git a/rpcs3/Gui/GameViewer.h b/rpcs3/Gui/GameViewer.h index d31fc241fc..e14d5b4f1e 100644 --- a/rpcs3/Gui/GameViewer.h +++ b/rpcs3/Gui/GameViewer.h @@ -216,6 +216,21 @@ public: } }; +class ListSortInfo +{ +public: + ListSortInfo() + { + SortAscending = false; + Column = -1; + } + + bool SortAscending; + int Column; + class GameViewer *GameViewerCtrl; + +}; + class GameViewer : public wxListView { std::string m_path; @@ -223,7 +238,12 @@ class GameViewer : public wxListView std::vector m_game_data; ColumnsArr m_columns; + int n_lastItem; + public: + + ListSortInfo SortInfo; + GameViewer(wxWindow* parent); ~GameViewer(); @@ -237,7 +257,7 @@ public: void LoadSettings(); void Refresh(); - private: virtual void DClick(wxListEvent& event); + void OnColClick(wxListEvent& event); }; From f1257f9e3f04161b370f1825fe4d2d5379eab051 Mon Sep 17 00:00:00 2001 From: Blaypeg Date: Sun, 25 May 2014 21:36:55 +0100 Subject: [PATCH 2/4] Change types to stop compiler warnings --- rpcs3/Gui/MemoryViewer.cpp | 4 ++-- rpcs3/Gui/VHDDManager.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rpcs3/Gui/MemoryViewer.cpp b/rpcs3/Gui/MemoryViewer.cpp index db9a10901b..0723e20230 100644 --- a/rpcs3/Gui/MemoryViewer.cpp +++ b/rpcs3/Gui/MemoryViewer.cpp @@ -191,9 +191,9 @@ void MemoryViewerPanel::ShowMemory() t_mem_addr_str += wxString::Format("%08x ", addr); } - for (int row = 0; row < m_rowcount; row++) + for (u32 row = 0; row < m_rowcount; row++) { - for (int col = 0; col < m_colcount; col++) + for (u32 col = 0; col < m_colcount; col++) { u32 addr = m_addr + row * m_colcount + col; diff --git a/rpcs3/Gui/VHDDManager.cpp b/rpcs3/Gui/VHDDManager.cpp index 57d7daca8b..c3c53cd00c 100644 --- a/rpcs3/Gui/VHDDManager.cpp +++ b/rpcs3/Gui/VHDDManager.cpp @@ -523,7 +523,7 @@ void VHDDManagerDialog::LoadPaths() { IniEntry path_count; path_count.Init("path_count", "HDDManager"); - int count = 0; + size_t count = 0; count = path_count.LoadValue(count); for(size_t i=0; i Date: Sun, 25 May 2014 21:59:26 +0100 Subject: [PATCH 3/4] Set Game List columns as sortable --- rpcs3/Gui/GameViewer.cpp | 7 ++++--- rpcs3/Gui/GameViewer.h | 7 ++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/rpcs3/Gui/GameViewer.cpp b/rpcs3/Gui/GameViewer.cpp index c57efd12c8..7f79afc6cf 100644 --- a/rpcs3/Gui/GameViewer.cpp +++ b/rpcs3/Gui/GameViewer.cpp @@ -26,14 +26,14 @@ void GameViewer::DoResize(wxSize size) SetSize(size); } -int wxCALLBACK ListItemCompare(long item1, long item2, long sortinfo) +int wxCALLBACK ListItemCompare(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortinfo) { ListSortInfo *SortInfo = (ListSortInfo *)sortinfo; int Column = SortInfo->Column; GameViewer *pGameViewer = SortInfo->GameViewerCtrl; bool SortAscending = SortInfo->SortAscending; - long index1 = pGameViewer->FindItem(0, item1); - long index2 = pGameViewer->FindItem(0, item2); + long index1 = pGameViewer->FindItem(-1, item1); + long index2 = pGameViewer->FindItem(-1, item2); wxString string1 = pGameViewer->GetItemText(index1, Column); wxString string2 = pGameViewer->GetItemText(index2, Column); @@ -65,6 +65,7 @@ void GameViewer::OnColClick(wxListEvent& event) SortInfo.Column = event.GetColumn(); SortInfo.GameViewerCtrl = this; SortItems(ListItemCompare, (long)&SortInfo); + } diff --git a/rpcs3/Gui/GameViewer.h b/rpcs3/Gui/GameViewer.h index e14d5b4f1e..85457bdc6b 100644 --- a/rpcs3/Gui/GameViewer.h +++ b/rpcs3/Gui/GameViewer.h @@ -140,8 +140,13 @@ public: for(u32 i=0; idata.size(); ++i) { - if(list->GetItemCount() <= (int)i) list->InsertItem(i, wxEmptyString); + if (list->GetItemCount() <= (int)i) + { + list->InsertItem(i, wxEmptyString); + list->SetItemData(i, i); + } list->SetItem(i, c, fmt::FromUTF8(col->data[i])); + } } } From 42e5000c2da79875213613296fe9a51a151012b7 Mon Sep 17 00:00:00 2001 From: Blaypeg Date: Sun, 25 May 2014 22:01:00 +0100 Subject: [PATCH 4/4] Remove Unused varible --- rpcs3/Gui/GameViewer.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/rpcs3/Gui/GameViewer.h b/rpcs3/Gui/GameViewer.h index 85457bdc6b..d78c241e0f 100644 --- a/rpcs3/Gui/GameViewer.h +++ b/rpcs3/Gui/GameViewer.h @@ -242,8 +242,6 @@ class GameViewer : public wxListView std::vector m_games; std::vector m_game_data; ColumnsArr m_columns; - - int n_lastItem; public: