mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-09 08:21:29 +12:00
Attempt to make columns sortable for game list
This commit is contained in:
parent
360070bddb
commit
95f67080f8
2 changed files with 64 additions and 1 deletions
|
@ -11,6 +11,7 @@ GameViewer::GameViewer(wxWindow* parent) : wxListView(parent)
|
||||||
m_path = "/dev_hdd0/game/";
|
m_path = "/dev_hdd0/game/";
|
||||||
|
|
||||||
Bind(wxEVT_LIST_ITEM_ACTIVATED, &GameViewer::DClick, this);
|
Bind(wxEVT_LIST_ITEM_ACTIVATED, &GameViewer::DClick, this);
|
||||||
|
Bind(wxEVT_LIST_COL_CLICK, &GameViewer::OnColClick, this);
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
@ -25,6 +26,48 @@ void GameViewer::DoResize(wxSize size)
|
||||||
SetSize(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()
|
void GameViewer::LoadGames()
|
||||||
{
|
{
|
||||||
vfsDir dir(m_path);
|
vfsDir dir(m_path);
|
||||||
|
|
|
@ -216,6 +216,21 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ListSortInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ListSortInfo()
|
||||||
|
{
|
||||||
|
SortAscending = false;
|
||||||
|
Column = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SortAscending;
|
||||||
|
int Column;
|
||||||
|
class GameViewer *GameViewerCtrl;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
class GameViewer : public wxListView
|
class GameViewer : public wxListView
|
||||||
{
|
{
|
||||||
std::string m_path;
|
std::string m_path;
|
||||||
|
@ -223,7 +238,12 @@ class GameViewer : public wxListView
|
||||||
std::vector<GameInfo> m_game_data;
|
std::vector<GameInfo> m_game_data;
|
||||||
ColumnsArr m_columns;
|
ColumnsArr m_columns;
|
||||||
|
|
||||||
|
int n_lastItem;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
ListSortInfo SortInfo;
|
||||||
|
|
||||||
GameViewer(wxWindow* parent);
|
GameViewer(wxWindow* parent);
|
||||||
~GameViewer();
|
~GameViewer();
|
||||||
|
|
||||||
|
@ -237,7 +257,7 @@ public:
|
||||||
void LoadSettings();
|
void LoadSettings();
|
||||||
|
|
||||||
void Refresh();
|
void Refresh();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void DClick(wxListEvent& event);
|
virtual void DClick(wxListEvent& event);
|
||||||
|
void OnColClick(wxListEvent& event);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue