From de93b413eed50fcdbf83ad375ccffe0978c821cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= Date: Sat, 3 Nov 2018 21:35:47 +0200 Subject: [PATCH] =?UTF-8?q?UI|Client:=20Set=20profiles=E2=80=99=20last=20p?= =?UTF-8?q?layed=20time?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doomsday/apps/client/src/dd_main.cpp | 28 +++++++++++-------- .../src/ui/home/gamepanelbuttonwidget.cpp | 1 + 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/doomsday/apps/client/src/dd_main.cpp b/doomsday/apps/client/src/dd_main.cpp index d9ca7228b5..36f1c1aa85 100644 --- a/doomsday/apps/client/src/dd_main.cpp +++ b/doomsday/apps/client/src/dd_main.cpp @@ -941,12 +941,14 @@ static GameProfile const *autoselectGameProfile() // The argument can be a game ID or a profile name. if (games.contains(param)) { - Game &game = games[param]; - automaticProfile = DoomsdayApp::gameProfiles().find(game.title()).as(); + auto &prof = DoomsdayApp::gameProfiles().find(games[param].title()).as(); + prof.setLastPlayedAt(); + automaticProfile = prof; } - else if (auto const *prof = DoomsdayApp::gameProfiles().tryFind(param)) + else if (auto *prof = maybeAs(DoomsdayApp::gameProfiles().tryFind(param))) { - automaticProfile = prof->as(); + prof->setLastPlayedAt(); + automaticProfile = *prof; } // Packages from the command line. @@ -1975,28 +1977,30 @@ D_CMD(Load) << String::join(game.profile().unavailablePackages(), ", "); return true; } - if (!DoomsdayApp::app().changeGame(game.profile(), DD_ActivateGameWorker)) + if (DoomsdayApp::app().changeGame(game.profile(), DD_ActivateGameWorker)) { - return false; + game.profile().setLastPlayedAt(); + continue; } - continue; + return false; } // It could also be a game profile. - if (auto const *profile = DoomsdayApp::gameProfiles().tryFind(searchTerm)) + if (auto *profile = DoomsdayApp::gameProfiles().tryFind(searchTerm)) { - auto const &gameProf = profile->as(); + auto &gameProf = profile->as(); if (!gameProf.isPlayable()) { LOG_SCR_ERROR("Profile \"%s\" is missing one or more required packages: ") << String::join(gameProf.unavailablePackages(), ", "); return true; } - if (!DoomsdayApp::app().changeGame(gameProf, DD_ActivateGameWorker)) + if (DoomsdayApp::app().changeGame(gameProf, DD_ActivateGameWorker)) { - return false; + gameProf.setLastPlayedAt(); + continue; } - continue; + return false; } try diff --git a/doomsday/apps/client/src/ui/home/gamepanelbuttonwidget.cpp b/doomsday/apps/client/src/ui/home/gamepanelbuttonwidget.cpp index 79d77af994..b945d2cd10 100644 --- a/doomsday/apps/client/src/ui/home/gamepanelbuttonwidget.cpp +++ b/doomsday/apps/client/src/ui/home/gamepanelbuttonwidget.cpp @@ -203,6 +203,7 @@ DENG_GUI_PIMPL(GamePanelButtonWidget) // TODO: Emit a signal that hides the Home and closes the taskbar. // Switch the game. + gameProfile.setLastPlayedAt(); DoomsdayApp::app().changeGame(gameProfile, DD_ActivateGameWorker); if (saves->selectedPos() != ui::Data::InvalidPos)