1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Merge pull request #3460 from Laserlicht/changedate_sort

add sort for changedate
This commit is contained in:
Ivan Savenko 2024-01-09 12:43:01 +02:00 committed by GitHub
commit eae3d806db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 27 additions and 7 deletions

View File

@ -0,0 +1,7 @@
{
"basepath" : "lobby/",
"images" :
[
{ "frame" : 0, "file" : "selectionTabSortDate.png"}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -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.",

View File

@ -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}",

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)

View File

@ -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

View File

@ -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!

View File

@ -28,8 +28,9 @@ public:
std::unique_ptr<Campaign> 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;