feat: add donate info to modrinth modpacks
This commit is contained in:
parent
ca3c6c5e8a
commit
22e0527502
@ -65,6 +65,19 @@ void loadIndexedInfo(Modpack& pack, QJsonObject& obj)
|
||||
pack.extra.sourceUrl = Json::ensureString(obj, "source_url");
|
||||
pack.extra.wikiUrl = Json::ensureString(obj, "wiki_url");
|
||||
|
||||
auto donate_arr = Json::ensureArray(obj, "donation_urls");
|
||||
for(auto d : donate_arr){
|
||||
auto d_obj = Json::requireObject(d);
|
||||
|
||||
DonationData donate;
|
||||
|
||||
donate.id = Json::ensureString(d_obj, "id");
|
||||
donate.platform = Json::ensureString(d_obj, "platform");
|
||||
donate.url = Json::ensureString(d_obj, "url");
|
||||
|
||||
pack.extra.donate.append(donate);
|
||||
}
|
||||
|
||||
pack.extraInfoLoaded = true;
|
||||
}
|
||||
|
||||
|
@ -58,12 +58,21 @@ struct File
|
||||
QUrl download;
|
||||
};
|
||||
|
||||
struct DonationData {
|
||||
QString id;
|
||||
QString platform;
|
||||
QString url;
|
||||
};
|
||||
|
||||
struct ModpackExtra {
|
||||
QString body;
|
||||
|
||||
QString projectUrl;
|
||||
QString sourceUrl;
|
||||
QString wikiUrl;
|
||||
|
||||
QList<DonationData> donate;
|
||||
|
||||
};
|
||||
|
||||
struct ModpackVersion {
|
||||
|
@ -224,6 +224,18 @@ void ModrinthPage::updateUI()
|
||||
// TODO: Implement multiple authors with links
|
||||
text += "<br>" + tr(" by ") + QString("<a href=%1>%2</a>").arg(std::get<1>(current.author).toString(), std::get<0>(current.author));
|
||||
|
||||
if(!current.extra.donate.isEmpty()) {
|
||||
text += "<br><br>Donation information:<br>";
|
||||
auto donateToStr = [](Modrinth::DonationData& donate) -> QString {
|
||||
return QString("<a href=\"%1\">%2</a>").arg(donate.url, donate.platform);
|
||||
};
|
||||
QStringList donates;
|
||||
for (auto& donate : current.extra.donate) {
|
||||
donates.append(donateToStr(donate));
|
||||
}
|
||||
text += donates.join(", ");
|
||||
}
|
||||
|
||||
text += "<br>";
|
||||
|
||||
HoeDown h;
|
||||
|
Loading…
Reference in New Issue
Block a user