mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-25 02:26:54 +01:00
Fix game list ordering & Favorite checkbox (#163)
This commit is contained in:
parent
33167196d9
commit
f8297eeb44
@ -275,23 +275,27 @@ void wxGameList::UpdateItemColors(sint32 startIndex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int strongorder_to_int(const std::strong_ordering &wo)
|
||||||
|
{
|
||||||
|
/* No easy conversion seems to exists in C++20 */
|
||||||
|
if (wo < 0)
|
||||||
|
return -1;
|
||||||
|
else if (wo > 0)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int wxGameList::SortComparator(uint64 titleId1, uint64 titleId2, SortData* sortData)
|
int wxGameList::SortComparator(uint64 titleId1, uint64 titleId2, SortData* sortData)
|
||||||
{
|
{
|
||||||
//if(sortData->column == ColumnGameStarted)
|
const auto isFavoriteA = GetConfig().IsGameListFavorite(titleId1);
|
||||||
// return boost::ilexicographical_compare(name1, name2) ? 0 : 1;
|
const auto isFavoriteB = GetConfig().IsGameListFavorite(titleId2);
|
||||||
|
const auto& name1 = GetNameByTitleId(titleId1);
|
||||||
|
const auto& name2 = GetNameByTitleId(titleId2);
|
||||||
|
|
||||||
|
if(sortData->dir > 0)
|
||||||
bool isFavoriteA = GetConfig().IsGameListFavorite(titleId1);
|
return strongorder_to_int(std::tie(isFavoriteB, name1) <=> std::tie(isFavoriteA, name2));
|
||||||
bool isFavoriteB = GetConfig().IsGameListFavorite(titleId2);
|
else
|
||||||
if (isFavoriteA != isFavoriteB)
|
return strongorder_to_int(std::tie(isFavoriteB, name2) <=> std::tie(isFavoriteA, name1));
|
||||||
return isFavoriteB;
|
|
||||||
|
|
||||||
// default to name
|
|
||||||
std::string name1 = GetNameByTitleId(titleId1);
|
|
||||||
std::string name2 = GetNameByTitleId(titleId2);
|
|
||||||
if(sortData->dir)
|
|
||||||
return boost::ilexicographical_compare(name1, name2) ? 0 : 1;
|
|
||||||
return boost::ilexicographical_compare(name1, name2) ? 1 : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxGameList::SortFunction(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData)
|
int wxGameList::SortFunction(wxIntPtr item1, wxIntPtr item2, wxIntPtr sortData)
|
||||||
@ -469,7 +473,7 @@ void wxGameList::OnContextMenu(wxContextMenuEvent& event)
|
|||||||
|
|
||||||
menu.Append(kContextMenuStart, _("&Start"));
|
menu.Append(kContextMenuStart, _("&Start"));
|
||||||
|
|
||||||
bool isFavorite = false;
|
bool isFavorite = GetConfig().IsGameListFavorite(title_id);
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
|
|
||||||
menu.AppendSeparator();
|
menu.AppendSeparator();
|
||||||
@ -820,20 +824,13 @@ int wxGameList::FindInsertPosition(TitleId titleId)
|
|||||||
if (itemCount == 0)
|
if (itemCount == 0)
|
||||||
return 0;
|
return 0;
|
||||||
// todo - optimize this with binary search
|
// todo - optimize this with binary search
|
||||||
int linearScanIndex = 0;
|
|
||||||
if (SortComparator(titleId, (uint64)GetItemData(0), &data))
|
for (int i = 0; i < itemCount; i++)
|
||||||
{
|
{
|
||||||
linearScanIndex = itemCount;
|
if (SortComparator(titleId, (uint64)GetItemData(i), &data) <= 0)
|
||||||
for (int i = 1; i < itemCount - 1; i++)
|
return i;
|
||||||
{
|
|
||||||
if (!SortComparator(titleId, (uint64)GetItemData(i), &data))
|
|
||||||
{
|
|
||||||
linearScanIndex = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return linearScanIndex;
|
return itemCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGameList::OnGameEntryUpdatedByTitleId(wxTitleIdEvent& event)
|
void wxGameList::OnGameEntryUpdatedByTitleId(wxTitleIdEvent& event)
|
||||||
|
Loading…
Reference in New Issue
Block a user