Fixed icons
Also having a mod loader is now enforced
This commit is contained in:
parent
9e6fa8f29a
commit
1a8c972aef
@ -34,7 +34,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QUrl m_sourceUrl;
|
QUrl m_sourceUrl;
|
||||||
std::shared_ptr<NetJob> m_filesNetJob;
|
NetJob::Ptr m_filesNetJob;
|
||||||
const std::shared_ptr<ModFolderModel> mods;
|
const std::shared_ptr<ModFolderModel> mods;
|
||||||
const QString filename;
|
const QString filename;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ void Modrinth::loadIndexedPack(Modrinth::IndexedPack & pack, QJsonObject & obj)
|
|||||||
pack.description = Json::ensureString(obj, "description", "");
|
pack.description = Json::ensureString(obj, "description", "");
|
||||||
|
|
||||||
pack.logoUrl = Json::requireString(obj, "icon_url");
|
pack.logoUrl = Json::requireString(obj, "icon_url");
|
||||||
pack.logoName = "logoName";
|
pack.logoName = pack.addonId;
|
||||||
|
|
||||||
Modrinth::ModpackAuthor packAuthor;
|
Modrinth::ModpackAuthor packAuthor;
|
||||||
packAuthor.name = Json::requireString(obj, "author");
|
packAuthor.name = Json::requireString(obj, "author");
|
||||||
|
@ -31,8 +31,9 @@
|
|||||||
#include "ModDownloadTask.h"
|
#include "ModDownloadTask.h"
|
||||||
|
|
||||||
|
|
||||||
ModDownloadDialog::ModDownloadDialog(const std::shared_ptr<ModFolderModel>& mods, QWidget *parent)
|
ModDownloadDialog::ModDownloadDialog(const std::shared_ptr<ModFolderModel> &mods, QWidget *parent,
|
||||||
: QDialog(parent), mods(mods)
|
BaseInstance *instance)
|
||||||
|
: QDialog(parent), mods(mods), m_instance(instance)
|
||||||
{
|
{
|
||||||
setObjectName(QStringLiteral("ModDownloadDialog"));
|
setObjectName(QStringLiteral("ModDownloadDialog"));
|
||||||
resize(400, 347);
|
resize(400, 347);
|
||||||
@ -88,7 +89,7 @@ void ModDownloadDialog::accept()
|
|||||||
|
|
||||||
QList<BasePage *> ModDownloadDialog::getPages()
|
QList<BasePage *> ModDownloadDialog::getPages()
|
||||||
{
|
{
|
||||||
modrinthPage = new ModrinthPage(this);
|
modrinthPage = new ModrinthPage(this, m_instance);
|
||||||
return
|
return
|
||||||
{
|
{
|
||||||
modrinthPage
|
modrinthPage
|
||||||
|
@ -37,7 +37,7 @@ class ModDownloadDialog : public QDialog, public BasePageProvider
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ModDownloadDialog(const std::shared_ptr<ModFolderModel>& mods, QWidget *parent = nullptr);
|
explicit ModDownloadDialog(const std::shared_ptr<ModFolderModel> &mods, QWidget *parent, BaseInstance *instance);
|
||||||
~ModDownloadDialog();
|
~ModDownloadDialog();
|
||||||
|
|
||||||
QString dialogTitle() override;
|
QString dialogTitle() override;
|
||||||
@ -63,4 +63,5 @@ private:
|
|||||||
|
|
||||||
ModrinthPage *modrinthPage = nullptr;
|
ModrinthPage *modrinthPage = nullptr;
|
||||||
std::unique_ptr<ModDownloadTask> modTask;
|
std::unique_ptr<ModDownloadTask> modTask;
|
||||||
|
BaseInstance *m_instance;
|
||||||
};
|
};
|
||||||
|
@ -349,25 +349,34 @@ void ModFolderPage::on_actionInstall_mods_triggered()
|
|||||||
if(!m_controlsEnabled) {
|
if(!m_controlsEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ModDownloadDialog mdownload(m_mods, this);
|
if(m_inst->typeName() != "Minecraft"){
|
||||||
mdownload.exec();
|
return; //this is a null instance or a legacy instance
|
||||||
ModDownloadTask * task = mdownload.getTask();
|
}
|
||||||
if(task){
|
bool hasFabric = !((MinecraftInstance *)m_inst)->getPackProfile()->getComponentVersion("net.fabricmc.fabric-loader").isEmpty();
|
||||||
connect(task, &Task::failed, [this](QString reason)
|
bool hasForge = !((MinecraftInstance *)m_inst)->getPackProfile()->getComponentVersion("net.minecraftforge").isEmpty();
|
||||||
{
|
if (!hasFabric && !hasForge) {
|
||||||
|
QMessageBox::critical(this,tr("Error"),tr("Please install a mod loader first !"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ModDownloadDialog mdownload(m_mods, this, m_inst);
|
||||||
|
if(mdownload.exec()) {
|
||||||
|
ModDownloadTask *task = mdownload.getTask();
|
||||||
|
if (task) {
|
||||||
|
connect(task, &Task::failed, [this](QString reason) {
|
||||||
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
|
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
|
||||||
});
|
});
|
||||||
connect(task, &Task::succeeded, [this, task]()
|
connect(task, &Task::succeeded, [this, task]() {
|
||||||
{
|
|
||||||
QStringList warnings = task->warnings();
|
QStringList warnings = task->warnings();
|
||||||
if(warnings.count())
|
if (warnings.count()) {
|
||||||
{
|
CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'),
|
||||||
CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show();
|
QMessageBox::Warning)->show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ProgressDialog loadDialog(this);
|
ProgressDialog loadDialog(this);
|
||||||
loadDialog.setSkipButton(true, tr("Abort"));
|
loadDialog.setSkipButton(true, tr("Abort"));
|
||||||
loadDialog.execWithTask(task);
|
loadDialog.execWithTask(task);
|
||||||
|
m_mods->update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ void ListModel::requestLogo(QString logo, QString url)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("ModrinthPacks", QString("logos/%1").arg(logo.section(".", 0, 0)));
|
MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("ModrinthPacks", QString("logos/%1").arg(logo.section(".", 0, 0)));
|
||||||
NetJob *job = new NetJob(QString("Modrinth Icon Download %1").arg(logo), APPLICATION->network());
|
auto job = new NetJob(QString("Modrinth Icon Download %1").arg(logo), APPLICATION->network());
|
||||||
job->addNetAction(Net::Download::makeCached(QUrl(url), entry));
|
job->addNetAction(Net::Download::makeCached(QUrl(url), entry));
|
||||||
|
|
||||||
auto fullPath = entry->getFullPath();
|
auto fullPath = entry->getFullPath();
|
||||||
@ -119,7 +119,6 @@ void ListModel::requestLogo(QString logo, QString url)
|
|||||||
});
|
});
|
||||||
|
|
||||||
job->start();
|
job->start();
|
||||||
|
|
||||||
m_loadingLogos.append(logo);
|
m_loadingLogos.append(logo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,9 +9,11 @@
|
|||||||
#include "InstanceImportTask.h"
|
#include "InstanceImportTask.h"
|
||||||
#include "ModrinthModel.h"
|
#include "ModrinthModel.h"
|
||||||
#include "ModDownloadTask.h"
|
#include "ModDownloadTask.h"
|
||||||
|
#include "ui/pages/instance/ModFolderPage.h"
|
||||||
|
#include "minecraft/PackProfile.h"
|
||||||
|
|
||||||
ModrinthPage::ModrinthPage(ModDownloadDialog* dialog, QWidget *parent)
|
ModrinthPage::ModrinthPage(ModDownloadDialog *dialog, BaseInstance *instance)
|
||||||
: QWidget(parent), ui(new Ui::ModrinthPage), dialog(dialog)
|
: QWidget(dialog), ui(new Ui::ModrinthPage), dialog(dialog), m_instance(instance)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
connect(ui->searchButton, &QPushButton::clicked, this, &ModrinthPage::triggerSearch);
|
connect(ui->searchButton, &QPushButton::clicked, this, &ModrinthPage::triggerSearch);
|
||||||
|
@ -38,7 +38,7 @@ class ModrinthPage : public QWidget, public BasePage
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ModrinthPage(ModDownloadDialog* dialog, QWidget *parent = 0);
|
explicit ModrinthPage(ModDownloadDialog *dialog, BaseInstance *instance);
|
||||||
virtual ~ModrinthPage();
|
virtual ~ModrinthPage();
|
||||||
virtual QString displayName() const override
|
virtual QString displayName() const override
|
||||||
{
|
{
|
||||||
@ -77,4 +77,5 @@ private:
|
|||||||
Modrinth::IndexedPack current;
|
Modrinth::IndexedPack current;
|
||||||
|
|
||||||
QString selectedVersion;
|
QString selectedVersion;
|
||||||
|
BaseInstance *m_instance;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user