Merge pull request #1796 from Trial97/dep_global_toggle

Added Global Dependenicies toggle
This commit is contained in:
Alexandru Ionut Tripon 2023-11-06 20:48:51 +00:00 committed by GitHub
commit 8eac0d34bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 7 deletions

View File

@ -644,6 +644,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
// Minecraft mods // Minecraft mods
m_settings->registerSetting("ModMetadataDisabled", false); m_settings->registerSetting("ModMetadataDisabled", false);
m_settings->registerSetting("ModDependenciesDisabled", false);
// Minecraft offline player name // Minecraft offline player name
m_settings->registerSetting("LastOfflinePlayerName", ""); m_settings->registerSetting("LastOfflinePlayerName", "");

View File

@ -186,7 +186,7 @@ void ModUpdateDialog::checkCandidates()
} }
} }
{ // dependencies if (!APPLICATION->settings()->get("ModDependenciesDisabled").toBool()) { // dependencies
auto depTask = makeShared<GetModDependenciesTask>(this, m_instance, m_mod_model.get(), selectedVers); auto depTask = makeShared<GetModDependenciesTask>(this, m_instance, m_mod_model.get(), selectedVers);
connect(depTask.get(), &Task::failed, this, connect(depTask.get(), &Task::failed, this,

View File

@ -270,6 +270,7 @@ QList<BasePage*> ModDownloadDialog::getPages()
GetModDependenciesTask::Ptr ModDownloadDialog::getModDependenciesTask() GetModDependenciesTask::Ptr ModDownloadDialog::getModDependenciesTask()
{ {
if (!APPLICATION->settings()->get("ModDependenciesDisabled").toBool()) { // dependencies
if (auto model = dynamic_cast<ModFolderModel*>(getBaseModel().get()); model) { if (auto model = dynamic_cast<ModFolderModel*>(getBaseModel().get()); model) {
QList<std::shared_ptr<GetModDependenciesTask::PackDependency>> selectedVers; QList<std::shared_ptr<GetModDependenciesTask::PackDependency>> selectedVers;
for (auto& selected : getTasks()) { for (auto& selected : getTasks()) {
@ -278,6 +279,7 @@ GetModDependenciesTask::Ptr ModDownloadDialog::getModDependenciesTask()
return makeShared<GetModDependenciesTask>(this, m_instance, model, selectedVers); return makeShared<GetModDependenciesTask>(this, m_instance, model, selectedVers);
} }
}
return nullptr; return nullptr;
} }

View File

@ -223,6 +223,7 @@ void LauncherPage::applySettings()
// Mods // Mods
s->set("ModMetadataDisabled", ui->metadataDisableBtn->isChecked()); s->set("ModMetadataDisabled", ui->metadataDisableBtn->isChecked());
s->set("ModDependenciesDisabled", ui->dependenciesDisableBtn->isChecked());
} }
void LauncherPage::loadSettings() void LauncherPage::loadSettings()
{ {
@ -278,6 +279,7 @@ void LauncherPage::loadSettings()
// Mods // Mods
ui->metadataDisableBtn->setChecked(s->get("ModMetadataDisabled").toBool()); ui->metadataDisableBtn->setChecked(s->get("ModMetadataDisabled").toBool());
ui->metadataWarningLabel->setHidden(!ui->metadataDisableBtn->isChecked()); ui->metadataWarningLabel->setHidden(!ui->metadataDisableBtn->isChecked());
ui->dependenciesDisableBtn->setChecked(s->get("ModDependenciesDisabled").toBool());
} }
void LauncherPage::refreshFontPreview() void LauncherPage::refreshFontPreview()

View File

@ -186,6 +186,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="dependenciesDisableBtn">
<property name="toolTip">
<string>Disable automatically checking and installation of mod dependencies.</string>
</property>
<property name="text">
<string>Do not install mod dependencies</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -214,6 +214,10 @@ void ModFolderPage::updateMods()
QMessageBox::critical(this, tr("Error"), tr("Please install a mod loader first!")); QMessageBox::critical(this, tr("Error"), tr("Please install a mod loader first!"));
return; return;
} }
if (APPLICATION->settings()->get("ModMetadataDisabled").toBool()) {
QMessageBox::critical(this, tr("Error"), tr("Mod updates are unavailable when metadata is disabled!"));
return;
}
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes(); auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
auto mods_list = m_model->selectedMods(selection); auto mods_list = m_model->selectedMods(selection);