MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / changeModVersion

Method changeModVersion

launcher/ui/pages/instance/ModFolderPage.cpp:404–453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

402}
403
404void ModFolderPage::changeModVersion()
405{
406 if (m_instance->typeName() != "Minecraft")
407 return; // this is a null instance or a legacy instance
408
409 auto profile = static_cast<MinecraftInstance*>(m_instance)->getPackProfile();
410 if (!profile->getModLoaders().has_value()) {
411 QMessageBox::critical(this, tr("Error"), tr("Please install a mod loader first!"));
412 return;
413 }
414 if (APPLICATION->settings()->get("ModMetadataDisabled").toBool()) {
415 QMessageBox::critical(this, tr("Error"), tr("Mod updates are unavailable when metadata is disabled!"));
416 return;
417 }
418 auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
419 auto mods_list = m_model->selectedMods(selection);
420 if (mods_list.length() != 1 || mods_list[0]->metadata() == nullptr)
421 return;
422
423 ResourceDownload::ModDownloadDialog mdownload(this, m_model, m_instance);
424 mdownload.setModMetadata((*mods_list.begin())->metadata());
425 if (mdownload.exec()) {
426 auto tasks = new ConcurrentTask("Download Mods", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
427 connect(tasks, &Task::failed, [this, tasks](QString reason) {
428 CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
429 tasks->deleteLater();
430 });
431 connect(tasks, &Task::aborted, [this, tasks]() {
432 CustomMessageBox::selectable(this, tr("Aborted"), tr("Download stopped by user."), QMessageBox::Information)->show();
433 tasks->deleteLater();
434 });
435 connect(tasks, &Task::succeeded, [this, tasks]() {
436 QStringList warnings = tasks->warnings();
437 if (warnings.count())
438 CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show();
439
440 tasks->deleteLater();
441 });
442
443 for (auto& task : mdownload.getTasks()) {
444 tasks->addTask(task);
445 }
446
447 ProgressDialog loadDialog(this);
448 loadDialog.setSkipButton(true, tr("Abort"));
449 loadDialog.execWithTask(tasks);
450
451 m_model->update();
452 }
453}
454
455void ModFolderPage::exportModMetadata()
456{

Callers

nothing calls this directly

Calls 15

selectableFunction · 0.85
getPackProfileMethod · 0.80
getModLoadersMethod · 0.80
selectedModsMethod · 0.80
metadataMethod · 0.80
setModMetadataMethod · 0.80
showMethod · 0.80
addTaskMethod · 0.80
setSkipButtonMethod · 0.80
execWithTaskMethod · 0.80
typeNameMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected