MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / installMods

Method installMods

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

Source from the content-addressed store, hash-verified

152}
153
154void ModFolderPage::installMods()
155{
156 if (!m_controlsEnabled)
157 return;
158 if (m_instance->typeName() != "Minecraft")
159 return; // this is a null instance or a legacy instance
160
161 auto profile = static_cast<MinecraftInstance*>(m_instance)->getPackProfile();
162 if (profile->getModLoaders() == ModAPI::Unspecified) {
163 QMessageBox::critical(this, tr("Error"), tr("Please install a mod loader first!"));
164 return;
165 }
166
167 ModDownloadDialog mdownload(m_model, this, m_instance);
168 if (mdownload.exec()) {
169 ConcurrentTask* tasks = new ConcurrentTask(this);
170 connect(tasks, &Task::failed, [this, tasks](QString reason) {
171 CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
172 tasks->deleteLater();
173 });
174 connect(tasks, &Task::aborted, [this, tasks]() {
175 CustomMessageBox::selectable(this, tr("Aborted"), tr("Download stopped by user."), QMessageBox::Information)->show();
176 tasks->deleteLater();
177 });
178 connect(tasks, &Task::succeeded, [this, tasks]() {
179 QStringList warnings = tasks->warnings();
180 if (warnings.count())
181 CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show();
182
183 tasks->deleteLater();
184 });
185
186 for (auto& task : mdownload.getTasks()) {
187 tasks->addTask(task);
188 }
189
190 ProgressDialog loadDialog(this);
191 loadDialog.setSkipButton(true, tr("Abort"));
192 loadDialog.execWithTask(tasks);
193
194 m_model->update();
195 }
196}
197
198void ModFolderPage::updateMods()
199{

Callers

nothing calls this directly

Calls 13

selectableFunction · 0.85
getPackProfileMethod · 0.80
getModLoadersMethod · 0.80
showMethod · 0.80
addTaskMethod · 0.80
setSkipButtonMethod · 0.80
execWithTaskMethod · 0.80
typeNameMethod · 0.45
execMethod · 0.45
warningsMethod · 0.45
countMethod · 0.45
getTasksMethod · 0.45

Tested by

no test coverage detected