diff options
author | flow <thiagodonato300@gmail.com> | 2022-03-02 18:35:59 -0300 |
---|---|---|
committer | flow <thiagodonato300@gmail.com> | 2022-03-02 18:49:19 -0300 |
commit | 881b2f2b385f19d9b64a149fca3c3741a803a172 (patch) | |
tree | ff13eabfeec171560c2b8b90aa00db6a48e92691 /launcher/ui | |
parent | ca211558b5a4ee8b0dec3471c92f952002216532 (diff) | |
download | PrismLauncher-881b2f2b385f19d9b64a149fca3c3741a803a172.tar.gz PrismLauncher-881b2f2b385f19d9b64a149fca3c3741a803a172.tar.bz2 PrismLauncher-881b2f2b385f19d9b64a149fca3c3741a803a172.zip |
refactor: Use a single indexed pack for mods
Since there's little difference between them, let's remove duplication
and merge them.
Diffstat (limited to 'launcher/ui')
8 files changed, 17 insertions, 17 deletions
diff --git a/launcher/ui/pages/modplatform/flame/FlameModModel.cpp b/launcher/ui/pages/modplatform/flame/FlameModModel.cpp index e8afba5a..052f30d1 100644 --- a/launcher/ui/pages/modplatform/flame/FlameModModel.cpp +++ b/launcher/ui/pages/modplatform/flame/FlameModModel.cpp @@ -39,7 +39,7 @@ QVariant ListModel::data(const QModelIndex &index, int role) const return QString("INVALID INDEX %1").arg(pos); } - IndexedPack pack = modpacks.at(pos); + ModPlatform::IndexedPack pack = modpacks.at(pos); if(role == Qt::DisplayRole) { return pack.name; @@ -225,12 +225,12 @@ void ListModel::searchRequestFinished() return; } - QList<FlameMod::IndexedPack> newList; + QList<ModPlatform::IndexedPack> newList; auto packs = doc.array(); for(auto packRaw : packs) { auto packObj = packRaw.toObject(); - FlameMod::IndexedPack pack; + ModPlatform::IndexedPack pack; try { FlameMod::loadIndexedPack(pack, packObj); diff --git a/launcher/ui/pages/modplatform/flame/FlameModModel.h b/launcher/ui/pages/modplatform/flame/FlameModModel.h index 0c1cb95e..ec19ab2f 100644 --- a/launcher/ui/pages/modplatform/flame/FlameModModel.h +++ b/launcher/ui/pages/modplatform/flame/FlameModModel.h @@ -57,7 +57,7 @@ private: void requestLogo(QString file, QString url); private: - QList<IndexedPack> modpacks; + QList<ModPlatform::IndexedPack> modpacks; QStringList m_failedLogos; QStringList m_loadingLogos; LogoMap m_logoMap; diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp index 114ac907..48d38b82 100644 --- a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp +++ b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp @@ -77,7 +77,7 @@ void FlameModPage::onSelectionChanged(QModelIndex first, QModelIndex second) { return; } - current = listModel->data(first, Qt::UserRole).value<FlameMod::IndexedPack>(); + current = listModel->data(first, Qt::UserRole).value<ModPlatform::IndexedPack>(); QString text = ""; QString name = current.name; @@ -86,7 +86,7 @@ void FlameModPage::onSelectionChanged(QModelIndex first, QModelIndex second) { else text = "<a href=\"" + current.websiteUrl + "\">" + name + "</a>"; if (!current.authors.empty()) { - auto authorToStr = [](FlameMod::ModpackAuthor &author) { + auto authorToStr = [](ModPlatform::ModpackAuthor &author) { if (author.url.isEmpty()) { return author.name; } @@ -112,7 +112,7 @@ void FlameModPage::onSelectionChanged(QModelIndex first, QModelIndex second) { new NetJob(QString("Flame::ModVersions(%1)").arg(current.name), APPLICATION->network()); auto response = new QByteArray(); - int addonId = current.addonId; + int addonId = current.addonId.toInt(); netJob->addNetAction(Net::Download::makeByteArray( QString("https://addons-ecs.forgesvc.net/api/v2/addon/%1/files") .arg(addonId), diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.h b/launcher/ui/pages/modplatform/flame/FlameModPage.h index b5b19a4f..24dfcbc7 100644 --- a/launcher/ui/pages/modplatform/flame/FlameModPage.h +++ b/launcher/ui/pages/modplatform/flame/FlameModPage.h @@ -62,7 +62,7 @@ private: Ui::FlameModPage *ui = nullptr; ModDownloadDialog* dialog = nullptr; FlameMod::ListModel* listModel = nullptr; - FlameMod::IndexedPack current; + ModPlatform::IndexedPack current; int selectedVersion = -1; }; diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp index 5a18830a..088ca411 100644 --- a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp +++ b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp @@ -41,7 +41,7 @@ QVariant ListModel::data(const QModelIndex &index, int role) const return QString("INVALID INDEX %1").arg(pos); } - IndexedPack pack = modpacks.at(pos); + ModPlatform::IndexedPack pack = modpacks.at(pos); if(role == Qt::DisplayRole) { return pack.name; @@ -222,12 +222,12 @@ void Modrinth::ListModel::searchRequestFinished() return; } - QList<Modrinth::IndexedPack> newList; + QList<ModPlatform::IndexedPack> newList; auto packs = doc.object().value("hits").toArray(); for(auto packRaw : packs) { auto packObj = packRaw.toObject(); - Modrinth::IndexedPack pack; + ModPlatform::IndexedPack pack; try { Modrinth::loadIndexedPack(pack, packObj); diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.h b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.h index 53f1f134..20661412 100644 --- a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.h +++ b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.h @@ -57,7 +57,7 @@ private: void requestLogo(QString file, QString url); private: - QList<IndexedPack> modpacks; + QList<ModPlatform::IndexedPack> modpacks; QStringList m_failedLogos; QStringList m_loadingLogos; LogoMap m_logoMap; diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp index 35cd743a..4dfc8504 100644 --- a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp +++ b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp @@ -76,7 +76,7 @@ void ModrinthPage::onSelectionChanged(QModelIndex first, QModelIndex second) { return; } - current = listModel->data(first, Qt::UserRole).value<Modrinth::IndexedPack>(); + current = listModel->data(first, Qt::UserRole).value<ModPlatform::IndexedPack>(); QString text = ""; QString name = current.name; @@ -84,8 +84,8 @@ void ModrinthPage::onSelectionChanged(QModelIndex first, QModelIndex second) { text = name; else text = "<a href=\"" + current.websiteUrl + "\">" + name + "</a>"; - text += "<br>" + tr(" by ") + "<a href=\"" + current.author.url + "\">" + - current.author.name + "</a><br><br>"; + text += "<br>" + tr(" by ") + "<a href=\"" + current.authors[0].url + "\">" + + current.authors[0].name + "</a><br><br>"; ui->packDescription->setHtml(text + current.description); if (!current.versionsLoaded) { @@ -98,7 +98,7 @@ void ModrinthPage::onSelectionChanged(QModelIndex first, QModelIndex second) { new NetJob(QString("Modrinth::ModVersions(%1)").arg(current.name), APPLICATION->network()); auto response = new QByteArray(); - QString addonId = current.addonId; + QString addonId = current.addonId.toString(); netJob->addNetAction(Net::Download::makeByteArray( QString("https://api.modrinth.com/v2/project/%1/version").arg(addonId), response)); diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h index 52b538e3..1d725d47 100644 --- a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h +++ b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h @@ -62,7 +62,7 @@ private: Ui::ModrinthPage *ui = nullptr; ModDownloadDialog* dialog = nullptr; Modrinth::ListModel* listModel = nullptr; - Modrinth::IndexedPack current; + ModPlatform::IndexedPack current; int selectedVersion = -1; }; |