From 11955605b506fc0af0bb0b267b4717d5b7f201d1 Mon Sep 17 00:00:00 2001 From: Haryaalcar Date: Tue, 10 Jun 2014 23:58:07 +0300 Subject: [PATCH] sorting by filename implemented for save and load screens --- client/CPreGame.cpp | 17 +++++++++++++---- client/CPreGame.h | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/client/CPreGame.cpp b/client/CPreGame.cpp index 3eb999988..6a85f3ea7 100644 --- a/client/CPreGame.cpp +++ b/client/CPreGame.cpp @@ -1247,7 +1247,7 @@ SelectionTab::SelectionTab(CMenuScreen::EState Type, const std::functiongeneraltexth->zelp[107+i].second, boost::bind(&SelectionTab::sortBy, this, i), xpos[i], 86, names[i]); + { + ESortBy criteria = (ESortBy)i; + + if(criteria == _name) + criteria = generalSortingBy; + + new CAdventureMapButton("", CGI->generaltexth->zelp[107+i].second, boost::bind(&SelectionTab::sortBy, this, criteria), xpos[i], 86, names[i]); + } } } else @@ -1327,8 +1334,8 @@ void SelectionTab::sortBy( int criteria ) void SelectionTab::sort() { - if(sortingBy != _name) - std::stable_sort(curItems.begin(), curItems.end(), mapSorter(_name)); + if(sortingBy != generalSortingBy) + std::stable_sort(curItems.begin(), curItems.end(), mapSorter(generalSortingBy)); std::stable_sort(curItems.begin(), curItems.end(), mapSorter(sortingBy)); if(!ascending) @@ -3013,6 +3020,8 @@ bool mapSorter::operator()(const CMapInfo *aaa, const CMapInfo *bbb) break; case _name: //by name return boost::ilexicographical_compare(a->name, b->name); + case _fileName: //by filename + return boost::ilexicographical_compare(aaa->fileURI, bbb->fileURI); default: return boost::ilexicographical_compare(a->name, b->name); } diff --git a/client/CPreGame.h b/client/CPreGame.h index 4f58d8603..6dfca80ab 100644 --- a/client/CPreGame.h +++ b/client/CPreGame.h @@ -35,7 +35,7 @@ struct PlayerInfo; namespace boost{ class thread; class recursive_mutex;} -enum ESortBy{_playerAm, _size, _format, _name, _viccon, _loscon, _numOfMaps}; //_numOfMaps is for campaigns +enum ESortBy{_playerAm, _size, _format, _name, _viccon, _loscon, _numOfMaps, _fileName}; //_numOfMaps is for campaigns /// Class which handles map sorting by different criteria class mapSorter @@ -160,6 +160,7 @@ public: std::function onSelect; ESortBy sortingBy; + ESortBy generalSortingBy; bool ascending; CTextInput *txt;