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