Launching a game inside a folder now also updates the folder's last played timestamp.

This commit is contained in:
Leon Styhre 2020-07-30 14:21:20 +02:00
parent 0985867d0f
commit 9f04458bbd
5 changed files with 17 additions and 7 deletions

View file

@ -720,6 +720,15 @@ void FileData::launchGame(Window* window)
// Update last played time. // Update last played time.
gameToUpdate->metadata.set("lastplayed", Utils::Time::DateTime(Utils::Time::now())); gameToUpdate->metadata.set("lastplayed", Utils::Time::DateTime(Utils::Time::now()));
// If the parent is a folder and it's not the root of the system, then update its lastplayed
// timestamp to the same time as the game that was just launched.
if (gameToUpdate->getParent()->getType() == FOLDER && gameToUpdate->getParent()->getName() !=
gameToUpdate->getSystem()->getFullName()) {
gameToUpdate->getParent()->metadata.set("lastplayed",
gameToUpdate->metadata.get("lastplayed"));
}
CollectionSystemManager::get()->refreshCollectionSystems(gameToUpdate); CollectionSystemManager::get()->refreshCollectionSystems(gameToUpdate);
gameToUpdate->mSystem->onMetaDataSavePoint(); gameToUpdate->mSystem->onMetaDataSavePoint();

View file

@ -45,7 +45,8 @@ MetaDataDecl folderDecls[] = {
{"publisher", MD_STRING, "unknown", false, "publisher", "enter game publisher", true}, {"publisher", MD_STRING, "unknown", false, "publisher", "enter game publisher", true},
{"genre", MD_STRING, "unknown", false, "genre", "enter game genre", true}, {"genre", MD_STRING, "unknown", false, "genre", "enter game genre", true},
{"players", MD_INT, "unknown", false, "players", "enter number of players", true}, {"players", MD_INT, "unknown", false, "players", "enter number of players", true},
{"hidden", MD_BOOL, "false", false, "hidden", "enter hidden off/on", false} {"hidden", MD_BOOL, "false", false, "hidden", "enter hidden off/on", false},
{"lastplayed", MD_TIME, "0", true, "last played", "enter last played date", false}
}; };
const std::vector<MetaDataDecl> folderMDD(folderDecls, folderDecls + const std::vector<MetaDataDecl> folderMDD(folderDecls, folderDecls +
sizeof(folderDecls) / sizeof(folderDecls[0])); sizeof(folderDecls) / sizeof(folderDecls[0]));

View file

@ -259,8 +259,8 @@ void DetailedGameListView::updateInfoPanel()
mLastPlayed.setValue(file->metadata.get("lastplayed")); mLastPlayed.setValue(file->metadata.get("lastplayed"));
mPlayCount.setValue(file->metadata.get("playcount")); mPlayCount.setValue(file->metadata.get("playcount"));
} }
else { else if (file->getType() == FOLDER) {
mLastPlayed.setValue(""); mLastPlayed.setValue(file->metadata.get("lastplayed"));
mPlayCount.setValue(""); mPlayCount.setValue("");
} }

View file

@ -387,8 +387,8 @@ void GridGameListView::updateInfoPanel()
mLastPlayed.setValue(file->metadata.get("lastplayed")); mLastPlayed.setValue(file->metadata.get("lastplayed"));
mPlayCount.setValue(file->metadata.get("playcount")); mPlayCount.setValue(file->metadata.get("playcount"));
} }
else { else if (file->getType() == FOLDER) {
mLastPlayed.setValue(""); mLastPlayed.setValue(file->metadata.get("lastplayed"));
mPlayCount.setValue(""); mPlayCount.setValue("");
} }

View file

@ -303,8 +303,8 @@ void VideoGameListView::updateInfoPanel()
mLastPlayed.setValue(file->metadata.get("lastplayed")); mLastPlayed.setValue(file->metadata.get("lastplayed"));
mPlayCount.setValue(file->metadata.get("playcount")); mPlayCount.setValue(file->metadata.get("playcount"));
} }
else { else if (file->getType() == FOLDER) {
mLastPlayed.setValue(""); mLastPlayed.setValue(file->metadata.get("lastplayed"));
mPlayCount.setValue(""); mPlayCount.setValue("");
} }