diff --git a/Mods/vcmi/Sprites/lobby/selectionTabSortDate.json b/Mods/vcmi/Sprites/lobby/selectionTabSortDate.json new file mode 100644 index 000000000..9022e4244 --- /dev/null +++ b/Mods/vcmi/Sprites/lobby/selectionTabSortDate.json @@ -0,0 +1,7 @@ +{ + "basepath" : "lobby/", + "images" : + [ + { "frame" : 0, "file" : "selectionTabSortDate.png"} + ] +} diff --git a/Mods/vcmi/Sprites/lobby/selectionTabSortDate.png b/Mods/vcmi/Sprites/lobby/selectionTabSortDate.png new file mode 100644 index 000000000..4e58b2838 Binary files /dev/null and b/Mods/vcmi/Sprites/lobby/selectionTabSortDate.png differ diff --git a/Mods/vcmi/config/vcmi/english.json b/Mods/vcmi/config/vcmi/english.json index b4537f306..b336c50e6 100644 --- a/Mods/vcmi/config/vcmi/english.json +++ b/Mods/vcmi/config/vcmi/english.json @@ -70,6 +70,7 @@ "vcmi.lobby.mapPreview" : "Map preview", "vcmi.lobby.noPreview" : "no preview", "vcmi.lobby.noUnderground" : "no underground", + "vcmi.lobby.sortDate" : "Sorts maps by change date", "vcmi.client.errors.missingCampaigns" : "{Missing data files}\n\nCampaigns data files were not found! You may be using incomplete or corrupted Heroes 3 data files. Please reinstall game data.", "vcmi.server.errors.existingProcess" : "Another VCMI server process is running. Please terminate it before starting a new game.", diff --git a/Mods/vcmi/config/vcmi/german.json b/Mods/vcmi/config/vcmi/german.json index 17c2614ab..fbb80eb8f 100644 --- a/Mods/vcmi/config/vcmi/german.json +++ b/Mods/vcmi/config/vcmi/german.json @@ -70,6 +70,7 @@ "vcmi.lobby.mapPreview" : "Kartenvorschau", "vcmi.lobby.noPreview" : "Keine Vorschau", "vcmi.lobby.noUnderground" : "Kein Untergrund", + "vcmi.lobby.sortDate" : "Ordnet Karten nach Änderungsdatum", "vcmi.server.errors.existingProcess" : "Es läuft ein weiterer vcmiserver-Prozess, bitte beendet diesen zuerst", "vcmi.server.errors.modsToEnable" : "{Erforderliche Mods um das Spiel zu laden}", diff --git a/client/lobby/SelectionTab.cpp b/client/lobby/SelectionTab.cpp index 8098715f2..4a90d6620 100644 --- a/client/lobby/SelectionTab.cpp +++ b/client/lobby/SelectionTab.cpp @@ -110,6 +110,8 @@ bool mapSorter::operator()(const std::shared_ptr 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(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(Point(30, 129 + i * 25), iconsMapFormats, iconsVictoryCondition, iconsLossCondition)); labelTabTitle = std::make_shared(205, 28, FONT_MEDIUM, ETextAlignment::CENTER, Colors::YELLOW, tabTitle); - slider = std::make_shared(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(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) diff --git a/client/lobby/SelectionTab.h b/client/lobby/SelectionTab.h index b457bcef8..529c2487f 100644 --- a/client/lobby/SelectionTab.h +++ b/client/lobby/SelectionTab.h @@ -23,7 +23,7 @@ class IImage; enum ESortBy { - _playerAm, _size, _format, _name, _viccon, _loscon, _numOfMaps, _fileName + _playerAm, _size, _format, _name, _viccon, _loscon, _numOfMaps, _fileName, _changeDate }; //_numOfMaps is for campaigns class ElementInfo : public CMapInfo diff --git a/lib/mapping/CMapInfo.cpp b/lib/mapping/CMapInfo.cpp index 0c6e03cff..39a0ee831 100644 --- a/lib/mapping/CMapInfo.cpp +++ b/lib/mapping/CMapInfo.cpp @@ -64,8 +64,8 @@ void CMapInfo::saveInit(const ResourcePath & file) originalFileURI = file.getOriginalName(); fullFileURI = boost::filesystem::canonical(*CResourceHandler::get()->getResourceName(file)).string(); countPlayers(); - std::time_t time = boost::filesystem::last_write_time(*CResourceHandler::get()->getResourceName(file)); - date = TextOperations::getFormattedDateTimeLocal(time); + lastWrite = boost::filesystem::last_write_time(*CResourceHandler::get()->getResourceName(file)); + date = TextOperations::getFormattedDateTimeLocal(lastWrite); // We absolutely not need this data for lobby and server will read it from save // FIXME: actually we don't want them in CMapHeader! diff --git a/lib/mapping/CMapInfo.h b/lib/mapping/CMapInfo.h index 512cff481..b086a38af 100644 --- a/lib/mapping/CMapInfo.h +++ b/lib/mapping/CMapInfo.h @@ -28,8 +28,9 @@ public: std::unique_ptr campaign; //may be nullptr if scenario StartInfo * scenarioOptionsOfSave; // Options with which scenario has been started (used only with saved games) std::string fileURI; - std::string originalFileURI; - std::string fullFileURI; + std::string originalFileURI; // no need to serialize + std::string fullFileURI; // no need to serialize + std::time_t lastWrite; // no need to serialize std::string date; int amountOfPlayersOnMap; int amountOfHumanControllablePlayers;