Skip to content

Commit

Permalink
UI|Client: Set profiles’ last played time
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Nov 3, 2018
1 parent b770352 commit de93b41
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
28 changes: 16 additions & 12 deletions doomsday/apps/client/src/dd_main.cpp
Expand Up @@ -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<GameProfile>();
auto &prof = DoomsdayApp::gameProfiles().find(games[param].title()).as<GameProfile>();
prof.setLastPlayedAt();
automaticProfile = prof;
}
else if (auto const *prof = DoomsdayApp::gameProfiles().tryFind(param))
else if (auto *prof = maybeAs<GameProfile>(DoomsdayApp::gameProfiles().tryFind(param)))
{
automaticProfile = prof->as<GameProfile>();
prof->setLastPlayedAt();
automaticProfile = *prof;
}

// Packages from the command line.
Expand Down Expand Up @@ -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<GameProfile>();
auto &gameProf = profile->as<GameProfile>();
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
Expand Down
1 change: 1 addition & 0 deletions doomsday/apps/client/src/ui/home/gamepanelbuttonwidget.cpp
Expand Up @@ -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)
Expand Down

0 comments on commit de93b41

Please sign in to comment.