From 1d0e6bf453bfee0d9201fabf1e979ab0aca90418 Mon Sep 17 00:00:00 2001 From: timoreo Date: Mon, 24 Jan 2022 07:23:01 +0100 Subject: [PATCH] Changed modrinth author data to not be a list --- .../modplatform/modrinth/ModrinthPackIndex.cpp | 8 ++++---- .../modplatform/modrinth/ModrinthPackIndex.h | 2 +- .../pages/modplatform/modrinth/ModrinthPage.cpp | 16 +--------------- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/launcher/modplatform/modrinth/ModrinthPackIndex.cpp b/launcher/modplatform/modrinth/ModrinthPackIndex.cpp index 8d47699b1..a546eb7c1 100644 --- a/launcher/modplatform/modrinth/ModrinthPackIndex.cpp +++ b/launcher/modplatform/modrinth/ModrinthPackIndex.cpp @@ -18,10 +18,10 @@ void Modrinth::loadIndexedPack(Modrinth::IndexedPack & pack, QJsonObject & obj) pack.logoUrl = Json::requireString(obj, "icon_url"); pack.logoName = pack.addonId; - Modrinth::ModpackAuthor packAuthor; - packAuthor.name = Json::requireString(obj, "author"); - packAuthor.url = Json::requireString(obj, "author_url"); - pack.authors.append(packAuthor); //TODO delete this ? only one author ever exists + Modrinth::ModpackAuthor modAuthor; + modAuthor.name = Json::requireString(obj, "author"); + modAuthor.url = Json::requireString(obj, "author_url"); + pack.author = modAuthor; } void Modrinth::loadIndexedPackVersions(Modrinth::IndexedPack & pack, QJsonArray & arr, const shared_qobject_ptr& network, BaseInstance * inst) diff --git a/launcher/modplatform/modrinth/ModrinthPackIndex.h b/launcher/modplatform/modrinth/ModrinthPackIndex.h index 01ae4b442..3a4cd2707 100644 --- a/launcher/modplatform/modrinth/ModrinthPackIndex.h +++ b/launcher/modplatform/modrinth/ModrinthPackIndex.h @@ -32,7 +32,7 @@ struct IndexedPack QString addonId; QString name; QString description; - QList authors; + ModpackAuthor author; QString logoName; QString logoUrl; QString websiteUrl; diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp index d03199842..61912cd75 100644 --- a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp +++ b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp @@ -90,21 +90,7 @@ void ModrinthPage::onSelectionChanged(QModelIndex first, QModelIndex second) text = name; else text = "" + name + ""; - if (!current.authors.empty()) { - auto authorToStr = [](Modrinth::ModpackAuthor & author) { - if(author.url.isEmpty()) { - return author.name; - } - return QString("%2").arg(author.url, author.name); - }; - QStringList authorStrs; - for(auto & author: current.authors) { - authorStrs.push_back(authorToStr(author)); - } - text += "
" + tr(" by ") + authorStrs.join(", "); - } - text += "

"; - + text += "
"+ tr(" by ") + ""+current.author.name+"

"; ui->packDescription->setHtml(text + current.description); if (!current.versionsLoaded)