1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

add sort for changedate

This commit is contained in:
Laserlicht
2024-01-07 20:17:44 +01:00
committed by GitHub
parent d6cf050b6b
commit 8b262e49a6
8 changed files with 27 additions and 7 deletions

View File

@@ -110,6 +110,8 @@ bool mapSorter::operator()(const std::shared_ptr<ElementInfo> aaa, const std::sh
return boost::ilexicographical_compare(a->name.toString(), b->name.toString());
case _fileName: //by filename
return boost::ilexicographical_compare(aaa->fileURI, bbb->fileURI);
case _changeDate: //by changedate
return aaa->lastWrite < bbb->lastWrite;
default:
return boost::ilexicographical_compare(a->name.toString(), b->name.toString());
}
@@ -149,9 +151,11 @@ SelectionTab::SelectionTab(ESelectionScreen Type)
: CIntObject(LCLICK | SHOW_POPUP | KEYBOARD | DOUBLECLICK), callOnSelect(nullptr), tabType(Type), selectionPos(0), sortModeAscending(true), inputNameRect{32, 539, 350, 20}, curFolder(""), currentMapSizeFilter(0), showRandom(false)
{
OBJ_CONSTRUCTION;
generalSortingBy = getSortBySelectionScreen(tabType);
bool enableUiEnhancements = settings["general"]["enableUiEnhancements"].Bool();
if(tabType != ESelectionScreen::campaignList)
{
sortingBy = _format;
@@ -208,6 +212,12 @@ SelectionTab::SelectionTab(ESelectionScreen Type)
break;
}
if(enableUiEnhancements)
{
buttonsSortBy.push_back(std::make_shared<CButton>(Point(371, 85), AnimationPath::builtin("lobby/selectionTabSortDate"), CButton::tooltip("", CGI->generaltexth->translate("vcmi.lobby.sortDate")), std::bind(&SelectionTab::sortBy, this, ESortBy::_changeDate)));
buttonsSortBy.back()->setAnimateLonelyFrame(true);
}
iconsMapFormats = GH.renderHandler().loadAnimation(AnimationPath::builtin("SCSELC.DEF"));
iconsVictoryCondition = GH.renderHandler().loadAnimation(AnimationPath::builtin("SCNRVICT.DEF"));
iconsLossCondition = GH.renderHandler().loadAnimation(AnimationPath::builtin("SCNRLOSS.DEF"));
@@ -215,7 +225,7 @@ SelectionTab::SelectionTab(ESelectionScreen Type)
listItems.push_back(std::make_shared<ListItem>(Point(30, 129 + i * 25), iconsMapFormats, iconsVictoryCondition, iconsLossCondition));
labelTabTitle = std::make_shared<CLabel>(205, 28, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, tabTitle);
slider = std::make_shared<CSlider>(Point(372, 86), tabType != ESelectionScreen::saveGame ? 480 : 430, std::bind(&SelectionTab::sliderMove, this, _1), positionsToShow, (int)curItems.size(), 0, Orientation::VERTICAL, CSlider::BLUE);
slider = std::make_shared<CSlider>(Point(372, 86 + (enableUiEnhancements ? 30 : 0)), (tabType != ESelectionScreen::saveGame ? 480 : 430) - (enableUiEnhancements ? 30 : 0), std::bind(&SelectionTab::sliderMove, this, _1), positionsToShow, (int)curItems.size(), 0, Orientation::VERTICAL, CSlider::BLUE);
slider->setPanningStep(24);
// create scroll bounds that encompass all area in this UI element to the left of slider (including area of slider itself)