void InternalLink::showPrompt(DesuraId id, Args args) { std::string prompt = args.getArgValue("prompt"); UserCore::Item::ItemInfoI* item = GetUserCore()->getItemManager()->findItemInfo( id ); if (prompt == "update") { std::vector<std::string> a; a.push_back("reminder=true"); showUpdateForm(id, Args(a)); } else if (prompt == "launch") { LaunchItemDialog* form = new LaunchItemDialog(m_pParent); regForm(id, form); form->setInfo(item); form->Show(true); form->Raise(); } else if (prompt == "eula") { showEULA(id); } else if (prompt == "preload") { showPreorderPrompt(id, true); } }
void InternalLink::showPrompt(DesuraId id, LinkArgs args) { std::string prompt = args.getArgValue("prompt"); gcRefPtr<UserCore::Item::ItemInfoI> item = GetUserCore()->getItemManager()->findItemInfo( id ); if (prompt == "update") { args.push_back("reminder=true"); showUpdateForm(id, args); } else if (prompt == "launch") { LaunchItemDialog* form = new LaunchItemDialog(m_pParent); regForm(id, form); form->setInfo(item); form->Show(true); form->Raise(); } else if (prompt == "eula") { showEULA(id); } else if (prompt == "preload") { showPreorderPrompt(id, true); } else if (prompt == "needtorunfirst") { std::string parentId = args.getArgValue("parentid"); DesuraId pid(parentId.c_str(), "games"); showNeedToRun(id, pid); } else { gcAssert(false); } }
void InternalLink::installItem(DesuraId id, LinkArgs args) { if (checkForPreorder(id)) { showPreorderPrompt(id, false); return; } std::string branch = args.getArgValue("branch"); std::string global = args.getArgValue("global"); MCFBranch iBranch; if (branch == "shortcut" || global == "shortcut") { iBranch = MCFBranch::BranchFromInt(-1); } else if (global.size() > 0) { iBranch = MCFBranch::BranchFromInt(Safe::atoi(global.c_str()), true); } else { iBranch = MCFBranch::BranchFromInt(Safe::atoi(branch.c_str())); } g_pMainApp->showPlay(); if (iBranch == 0 && !args.containsArg("skippreorder") && checkForPreorder(id)) return; UI::Forms::ItemForm* form = showItemForm(id, UI::Forms::INSTALL_ACTION::IA_INSTALL, iBranch); if (!form) Warning("Cant find item (or item not ready) for install [{0}].\n", id.toInt64()); }
void InternalLink::launchItem(DesuraId id, LinkArgs args) { bool cdKeyArg = args.containsArg("cdkey"); bool noUpdateArg = args.containsArg("noupdate"); bool exeNumArg = args.containsArg("exe"); std::string exe = args.getArgValue("exe"); if (exe == "") exeNumArg = false; g_pMainApp->showPlay(); if (checkForPreorder(id)) { showPreorderPrompt(id, false); return; } gcRefPtr<UserCore::Item::ItemInfoI> item = GetUserCore()->getItemManager()->findItemInfo(id); if (!item || !item->isLaunchable()) { installItem(id, LinkArgs()); return; } if (!item->hasAcceptedEula()) { showPrompt(id, FormatArgs("prompt=eula")); return; } if (!exeNumArg && item->getExeCount(true) > 1) { showExeSelect(id, cdKeyArg); return; } else if (exe.size() > 0) { item->setActiveExe(exe.c_str()); } bool hasCDKey = item->getCurrentBranch() && item->getCurrentBranch()->hasCDKey(); bool hasDLCDKey = item->getCurrentBranch() && item->getCurrentBranch()->isCDKeyValid(); if (!cdKeyArg && ((item->isFirstLaunch() && hasCDKey) || (hasCDKey && !hasDLCDKey))) { showCDKey(id, FormatArgs("launch=true", std::string("exe=") + exe)); return; } bool shouldShowGameDisk = false; if (args.containsArg("gamedisk") == false && HasAnyFlags(item->getOptions(), UserCore::Item::ItemInfoI::OPTION_DONTPROMPTGAMEDISK) == false) { size_t x=0; while (g_GameDiskList[x].isOk()) { if (item->getId() == g_GameDiskList[x] || item->getParentId() == g_GameDiskList[x]) { shouldShowGameDisk = true; break; } x++; } } if (shouldShowGameDisk) { showGameDisk(id, exe.c_str(), cdKeyArg); return; } if (noUpdateArg) item->addOFlag(UserCore::Item::ItemInfoI::OPTION_NOTREMINDUPDATE_ONETIME); UI::Forms::ItemForm* form = showItemForm(id, UI::Forms::INSTALL_ACTION::IA_LAUNCH, true, args); if (!form) Warning("Cant find item (or item not ready) for launch [{0}].\n", id.toInt64()); }