std::string CGUIDialogSelectGameClient::ShowAndGetGameClient(const GameClientVector& candidates, const GameClientVector& installable) { std::string gameClient; CLog::Log(LOGDEBUG, "Select game client dialog: Found %lu candidates", candidates.size()); for (const auto& gameClient : candidates) CLog::Log(LOGDEBUG, "Adding %s as a candidate", gameClient->ID().c_str()); if (!installable.empty()) { CLog::Log(LOGDEBUG, "Select game client dialog: Found %lu installable clients", installable.size()); for (const auto& gameClient : installable) CLog::Log(LOGDEBUG, "Adding %s as an installable client", gameClient->ID().c_str()); } CContextButtons choiceButtons; // Add emulators int i = 0; for (const GameClientPtr& gameClient : candidates) choiceButtons.Add(i++, gameClient->Name()); // Add button to install emulators const int iInstallEmulator = i++; if (!installable.empty()) choiceButtons.Add(iInstallEmulator, 35253); // "Install emulator" // Add button to manage emulators const int iAddonMgr = i++; choiceButtons.Add(iAddonMgr, 35254); // "Manage emulators" // Do modal int result = CGUIDialogContextMenu::ShowAndGetChoice(choiceButtons); if (0 <= result && result < static_cast<int>(candidates.size())) { // Handle emulator gameClient = candidates[result]->ID(); } else if (result == iInstallEmulator) { // Install emulator gameClient = InstallGameClient(installable); } else if (result == iAddonMgr) { // Go to add-on manager to manage emulators ActivateAddonMgr(); } else { CLog::Log(LOGDEBUG, "Select game client dialog: User cancelled game client selection"); } return gameClient; }
bool CGameUtils::FillInGameClient(CFileItem &item, bool bPrompt) { using namespace ADDON; if (item.GetGameInfoTag()->GetGameClient().empty()) { // If the fileitem is an add-on, fall back to that if (item.HasAddonInfo() && item.GetAddonInfo()->Type() == ADDON::ADDON_GAMEDLL) { item.GetGameInfoTag()->SetGameClient(item.GetAddonInfo()->ID()); } else if (bPrompt) { // No game client specified, need to ask the user GameClientVector candidates; GameClientVector installable; bool bHasVfsGameClient; GetGameClients(item, candidates, installable, bHasVfsGameClient); if (candidates.empty() && installable.empty()) { int errorTextId = bHasVfsGameClient ? 35214 : // "This game can only be played directly from a hard drive or partition. Compressed files must be extracted." 35212; // "This game isn't compatible with any available emulators." // "Failed to play game" KODI::MESSAGING::HELPERS::ShowOKDialogText(CVariant{ 35210 }, CVariant{ errorTextId }); } else if (candidates.size() == 1 && installable.empty()) { // Only 1 option, avoid prompting the user item.GetGameInfoTag()->SetGameClient(candidates[0]->ID()); } else { std::string gameClient = CGUIDialogSelectGameClient::ShowAndGetGameClient(item.GetPath(), candidates, installable); if (!gameClient.empty()) item.GetGameInfoTag()->SetGameClient(gameClient); } } } return !item.GetGameInfoTag()->GetGameClient().empty(); }
void CGUIDialogSelectGameClient::LogGameClients(const GameClientVector& candidates, const GameClientVector& installable) { CLog::Log(LOGDEBUG, "Select game client dialog: Found %u candidates", static_cast<unsigned int>(candidates.size())); for (const auto& gameClient : candidates) CLog::Log(LOGDEBUG, "Adding %s as a candidate", gameClient->ID().c_str()); if (!installable.empty()) { CLog::Log(LOGDEBUG, "Select game client dialog: Found %u installable clients", static_cast<unsigned int>(installable.size())); for (const auto& gameClient : installable) CLog::Log(LOGDEBUG, "Adding %s as an installable client", gameClient->ID().c_str()); } }