| 68 | } |
| 69 | |
| 70 | void SystemData::launchGame(Window* window, GameData* game) |
| 71 | { |
| 72 | LOG(LogInfo) << "Attempting to launch game..."; |
| 73 | |
| 74 | AudioManager::getInstance()->deinit(); |
| 75 | VolumeControl::getInstance()->deinit(); |
| 76 | window->deinit(); |
| 77 | |
| 78 | std::string command = mLaunchCommand; |
| 79 | |
| 80 | command = strreplace(command, "%ROM%", game->getBashPath()); |
| 81 | command = strreplace(command, "%BASENAME%", game->getBaseName()); |
| 82 | command = strreplace(command, "%ROM_RAW%", game->getPath()); |
| 83 | |
| 84 | LOG(LogInfo) << " " << command; |
| 85 | std::cout << "==============================================\n"; |
| 86 | int exitCode = system(command.c_str()); |
| 87 | std::cout << "==============================================\n"; |
| 88 | |
| 89 | if(exitCode != 0) |
| 90 | { |
| 91 | LOG(LogWarning) << "...launch terminated with nonzero exit code " << exitCode << "!"; |
| 92 | } |
| 93 | |
| 94 | window->init(); |
| 95 | VolumeControl::getInstance()->init(); |
| 96 | AudioManager::getInstance()->init(); |
| 97 | window->normalizeNextUpdate(); |
| 98 | |
| 99 | //update number of times the game has been launched and the time |
| 100 | game->setTimesPlayed(game->getTimesPlayed() + 1); |
| 101 | game->setLastPlayed(std::time(nullptr)); |
| 102 | } |
| 103 | |
| 104 | void SystemData::populateFolder(FolderData* folder) |
| 105 | { |
no test coverage detected