Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Save secondary list sorting.
Allow sorting by platform ascending.

Fixes issue 5774.
  • Loading branch information
rog9 committed Dec 17, 2012
1 parent 3519797 commit 4c7b63c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
4 changes: 3 additions & 1 deletion Source/Core/Core/Src/ConfigManager.cpp
Expand Up @@ -212,6 +212,7 @@ void SConfig::SaveSettings()
ini.Set("GameList", "ListTaiwan", m_ListTaiwan);
ini.Set("GameList", "ListUnknown", m_ListUnknown);
ini.Set("GameList", "ListSort", m_ListSort);
ini.Set("GameList", "ListSortSecondary", m_ListSort2);

// Core
ini.Set("Core", "HLE_BS2", m_LocalCoreStartupParameter.bHLE_BS2);
Expand Down Expand Up @@ -350,7 +351,8 @@ void SConfig::LoadSettings()
ini.Get("GameList", "ListKorea", &m_ListKorea, true);
ini.Get("GameList", "ListTaiwan", &m_ListTaiwan, true);
ini.Get("GameList", "ListUnknown", &m_ListUnknown, true);
ini.Get("GameList", "ListSort", &m_ListSort, 2);
ini.Get("GameList", "ListSort", &m_ListSort, 3);
ini.Get("GameList", "ListSortSecondary",&m_ListSort2, 0);

// Core
ini.Get("Core", "HLE_BS2", &m_LocalCoreStartupParameter.bHLE_BS2, false);
Expand Down
4 changes: 3 additions & 1 deletion Source/Core/Core/Src/ConfigManager.h
Expand Up @@ -62,7 +62,6 @@ struct SConfig : NonCopyable
bool m_InterfaceLogWindow;
bool m_InterfaceLogConfigWindow;
bool m_InterfaceConsole;
int m_ListSort;

bool m_ListDrives;
bool m_ListWad;
Expand All @@ -76,6 +75,9 @@ struct SConfig : NonCopyable
bool m_ListKorea;
bool m_ListTaiwan;
bool m_ListUnknown;
int m_ListSort;
int m_ListSort2;

std::string m_WirelessMac;
bool m_PauseMovie;
bool m_ShowLag;
Expand Down
26 changes: 19 additions & 7 deletions Source/Core/DolphinWX/Src/GameListCtrl.cpp
Expand Up @@ -51,6 +51,7 @@
size_t CGameListCtrl::m_currentItem = 0;
size_t CGameListCtrl::m_numberItem = 0;
std::string CGameListCtrl::m_currentFilename;
bool sorted = false;

static int CompareGameListItems(const GameListItem* iso1, const GameListItem* iso2,
long sortData = CGameListCtrl::COLUMN_TITLE)
Expand Down Expand Up @@ -284,6 +285,7 @@ void CGameListCtrl::Update()
InitBitmaps();

// add columns
InsertColumn(COLUMN_DUMMY,_T(""));
InsertColumn(COLUMN_PLATFORM, _T(""));
InsertColumn(COLUMN_BANNER, _("Banner"));
InsertColumn(COLUMN_TITLE, _("Title"));
Expand All @@ -303,6 +305,7 @@ void CGameListCtrl::Update()
#endif

// set initial sizes for columns
SetColumnWidth(COLUMN_DUMMY,0);
SetColumnWidth(COLUMN_PLATFORM, 35 + platform_padding);
SetColumnWidth(COLUMN_BANNER, 96 + platform_padding);
SetColumnWidth(COLUMN_TITLE, 200 + platform_padding);
Expand All @@ -320,9 +323,14 @@ void CGameListCtrl::Update()

// Sort items by Title
wxListEvent event;
event.m_col = SConfig::GetInstance().m_ListSort; last_column = 0;
event.m_col = SConfig::GetInstance().m_ListSort2;
last_column = 1;
OnColumnClick(event);

event.m_col = SConfig::GetInstance().m_ListSort;
OnColumnClick(event);
sorted = true;

SetColumnWidth(COLUMN_SIZE, wxLIST_AUTOSIZE);
}
else
Expand Down Expand Up @@ -414,9 +422,11 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
GameListItem& rISOFile = *m_ISOFiles[_Index];
m_gamePath.append(rISOFile.GetFileName() + '\n');

// Insert a first row with the platform image, that will be used as the Index
long ItemIndex = InsertItem(_Index, wxEmptyString,
m_PlatformImageIndex[rISOFile.GetPlatform()]);
// Insert a first row with nothing in it, that will be used as the Index
long ItemIndex = InsertItem(_Index, wxEmptyString);

// Insert the platform's image in the first (visible) column
SetItemColumnImage(_Index, COLUMN_PLATFORM, m_PlatformImageIndex[rISOFile.GetPlatform()]);

if (rISOFile.GetImage().IsOk())
ImageIndex = m_imageListSmall->Add(rISOFile.GetImage());
Expand Down Expand Up @@ -702,17 +712,19 @@ void CGameListCtrl::OnColumnClick(wxListEvent& event)
{
int current_column = event.GetColumn();

if(last_column == current_column)
if (last_column == current_column)
{
last_sort = -last_sort;
}
else
{
if (sorted)
SConfig::GetInstance().m_ListSort2 = last_sort;
last_column = current_column;
last_sort = current_column;
}

SConfig::GetInstance().m_ListSort = last_sort;
if (sorted)
SConfig::GetInstance().m_ListSort = last_sort;
caller = this;
SortItems(wxListCompare, last_sort);
}
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/DolphinWX/Src/GameListCtrl.h
Expand Up @@ -57,7 +57,8 @@ class CGameListCtrl : public wxListCtrl

enum
{
COLUMN_PLATFORM = 0,
COLUMN_DUMMY = 0,
COLUMN_PLATFORM,
COLUMN_BANNER,
COLUMN_TITLE,
COLUMN_NOTES,
Expand Down

0 comments on commit 4c7b63c

Please sign in to comment.