Beispiel #1
0
void CModListView::selectMod(int index)
{
	if (index < 0)
	{
		disableModInfo();
	}
	else
	{
		enableModInfo();

		auto mod = modModel->getMod(modModel->modIndexToName(index));

		ui->textBrowser->setHtml(genModInfoText(mod));

		bool hasInvalidDeps = !findInvalidDependencies(modModel->modIndexToName(index)).empty();
		bool hasBlockingMods = !findBlockingMods(modModel->modIndexToName(index)).empty();
		bool hasDependentMods = !findDependentMods(modModel->modIndexToName(index), true).empty();

		ui->disableButton->setVisible(mod.isEnabled());
		ui->enableButton->setVisible(mod.isDisabled());
		ui->installButton->setVisible(mod.isAvailable());
		ui->uninstallButton->setVisible(mod.isInstalled());
		ui->updateButton->setVisible(mod.isUpdateable());

		// Block buttons if action is not allowed at this time
		// TODO: automate handling of some of these cases instead of forcing player
		// to resolve all conflicts manually.
		ui->disableButton->setEnabled(!hasDependentMods);
		ui->enableButton->setEnabled(!hasBlockingMods && !hasInvalidDeps);
		ui->installButton->setEnabled(!hasInvalidDeps);
		ui->uninstallButton->setEnabled(!hasDependentMods);
		ui->updateButton->setEnabled(!hasInvalidDeps && !hasDependentMods);
	}
}
Beispiel #2
0
QString CModListView::genModInfoText(CModEntry &mod)
{
    QString prefix = "<p><span style=\" font-weight:600;\">%1: </span>"; // shared prefix
    QString lineTemplate = prefix + "%2</p>";
    QString urlTemplate  = prefix + "<a href=\"%2\">%3</a></p>";
    QString textTemplate = prefix + "</p><p align=\"justify\">%2</p>";
    QString listTemplate = "<p align=\"justify\">%1: %2</p>";
    QString noteTemplate = "<p align=\"justify\">%1</p>";

    QString result;

    result += replaceIfNotEmpty(mod.getValue("name"), lineTemplate.arg(tr("Mod name")));
    result += replaceIfNotEmpty(mod.getValue("installedVersion"), lineTemplate.arg(tr("Installed version")));
    result += replaceIfNotEmpty(mod.getValue("latestVersion"), lineTemplate.arg(tr("Latest version")));

    if (mod.getValue("size").isValid())
        result += replaceIfNotEmpty(CModEntry::sizeToString(mod.getValue("size").toDouble()), lineTemplate.arg(tr("Download size")));
    result += replaceIfNotEmpty(mod.getValue("author"), lineTemplate.arg(tr("Authors")));

    if (mod.getValue("licenseURL").isValid())
        result += urlTemplate.arg(tr("License")).arg(mod.getValue("licenseURL").toString()).arg(mod.getValue("licenseName").toString());

    if (mod.getValue("contact").isValid())
        result += urlTemplate.arg(tr("Home")).arg(mod.getValue("contact").toString()).arg(mod.getValue("contact").toString());

    result += replaceIfNotEmpty(mod.getValue("depends"), lineTemplate.arg(tr("Required mods")));
    result += replaceIfNotEmpty(mod.getValue("conflicts"), lineTemplate.arg(tr("Conflicting mods")));
    result += replaceIfNotEmpty(mod.getValue("description"), textTemplate.arg(tr("Description")));

    result += "<p></p>"; // to get some empty space

    QString unknownDeps  = tr("This mod can not be installed or enabled because following dependencies are not present");
    QString blockingMods = tr("This mod can not be enabled because following mods are incompatible with this mod");
    QString hasActiveDependentMods = tr("This mod can not be disabled because it is required to run following mods");
    QString hasDependentMods = tr("This mod can not be uninstalled or updated because it is required to run following mods");
    QString thisIsSubmod = tr("This is submod and it can not be installed or uninstalled separately from parent mod");

    QString notes;

    notes += replaceIfNotEmpty(findInvalidDependencies(mod.getName()), listTemplate.arg(unknownDeps));
    notes += replaceIfNotEmpty(findBlockingMods(mod.getName()), listTemplate.arg(blockingMods));
    if (mod.isEnabled())
        notes += replaceIfNotEmpty(findDependentMods(mod.getName(), true), listTemplate.arg(hasActiveDependentMods));
    if (mod.isInstalled())
        notes += replaceIfNotEmpty(findDependentMods(mod.getName(), false), listTemplate.arg(hasDependentMods));

    if (mod.getName().contains('.'))
        notes += noteTemplate.arg(thisIsSubmod);

    if (notes.size())
        result += textTemplate.arg(tr("Notes")).arg(notes);

    return result;
}
Beispiel #3
0
void CModListView::on_enableButton_clicked()
{
    QString modName = ui->allModsView->currentIndex().data(ModRoles::ModNameRole).toString();

    assert(findBlockingMods(modName).empty());
    assert(findInvalidDependencies(modName).empty());

    for (auto & name : modModel->getRequirements(modName))
        if (modModel->getMod(name).isDisabled())
            manager->enableMod(name);
    checkManagerErrors();
}
Beispiel #4
0
void CModListView::on_enableButton_clicked()
{
	QString modName = modModel->modIndexToName(filterModel->mapToSource(ui->allModsView->currentIndex()).row());

	assert(findBlockingMods(modName).empty());
	assert(findInvalidDependencies(modName).empty());

	for (auto & name : modModel->getRequirements(modName))
		if (modModel->getMod(name).isDisabled())
			manager->enableMod(name);
	checkManagerErrors();
}
Beispiel #5
0
void CModListView::selectMod(const QModelIndex & index)
{
    if (!index.isValid())
    {
        disableModInfo();
    }
    else
    {
        auto mod = modModel->getMod(index.data(ModRoles::ModNameRole).toString());

        ui->modInfoBrowser->setHtml(genModInfoText(mod));
        ui->changelogBrowser->setHtml(genChangelogText(mod));

        bool hasInvalidDeps = !findInvalidDependencies(index.data(ModRoles::ModNameRole).toString()).empty();
        bool hasBlockingMods = !findBlockingMods(index.data(ModRoles::ModNameRole).toString()).empty();
        bool hasDependentMods = !findDependentMods(index.data(ModRoles::ModNameRole).toString(), true).empty();

        ui->hideModInfoButton->setEnabled(true);
        ui->showInfoButton->setVisible(!ui->modInfoWidget->isVisible());
        ui->disableButton->setVisible(mod.isEnabled());
        ui->enableButton->setVisible(mod.isDisabled());
        ui->installButton->setVisible(mod.isAvailable() && !mod.getName().contains('.'));
        ui->uninstallButton->setVisible(mod.isInstalled() && !mod.getName().contains('.'));
        ui->updateButton->setVisible(mod.isUpdateable());

        // Block buttons if action is not allowed at this time
        // TODO: automate handling of some of these cases instead of forcing player
        // to resolve all conflicts manually.
        ui->disableButton->setEnabled(!hasDependentMods);
        ui->enableButton->setEnabled(!hasBlockingMods && !hasInvalidDeps);
        ui->installButton->setEnabled(!hasInvalidDeps);
        ui->uninstallButton->setEnabled(!hasDependentMods);
        ui->updateButton->setEnabled(!hasInvalidDeps && !hasDependentMods);

        loadScreenshots();
    }
}