aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/pages/modplatform/flame
diff options
context:
space:
mode:
authorflow <thiagodonato300@gmail.com>2022-03-02 23:01:23 -0300
committerflow <thiagodonato300@gmail.com>2022-03-02 23:13:04 -0300
commit2d68308d4920be4c28a73d7646814765eee7b7a2 (patch)
treeac0c9abf5a1f33bc13b8f885070904e7e7bfe43d /launcher/ui/pages/modplatform/flame
parent0dd1c26cf3cd68cd83f5d9da6cf34d4aa3f30db2 (diff)
downloadPrismLauncher-2d68308d4920be4c28a73d7646814765eee7b7a2.tar.gz
PrismLauncher-2d68308d4920be4c28a73d7646814765eee7b7a2.tar.bz2
PrismLauncher-2d68308d4920be4c28a73d7646814765eee7b7a2.zip
refactor: move url creation for mods to modplatform/
Moves all things related to creating the URLs of the mod platforms that go to network tasks to a single place, so that: 1. Maintaining and fixing eventual issues is more straightforward. 2. Makes it possible to factor out more common code between the different modplatform pages
Diffstat (limited to 'launcher/ui/pages/modplatform/flame')
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModModel.cpp43
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModModel.h4
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModPage.h6
3 files changed, 16 insertions, 37 deletions
diff --git a/launcher/ui/pages/modplatform/flame/FlameModModel.cpp b/launcher/ui/pages/modplatform/flame/FlameModModel.cpp
index 5ab6672f..283f9ce7 100644
--- a/launcher/ui/pages/modplatform/flame/FlameModModel.cpp
+++ b/launcher/ui/pages/modplatform/flame/FlameModModel.cpp
@@ -1,6 +1,5 @@
#include "FlameModModel.h"
#include "FlameModPage.h"
-#include "minecraft/MinecraftInstance.h"
#include "minecraft/PackProfile.h"
#include <Json.h>
@@ -11,41 +10,6 @@ ListModel::ListModel(FlameModPage* parent) : ModPlatform::ListModel(parent) {}
ListModel::~ListModel() {}
-const char* sorts[6]{ "Featured", "Popularity", "LastUpdated", "Name", "Author", "TotalDownloads" };
-
-void ListModel::performPaginatedSearch()
-{
- QString mcVersion = ((MinecraftInstance*)((FlameModPage*)parent())->m_instance)->getPackProfile()->getComponentVersion("net.minecraft");
- bool hasFabric = !((MinecraftInstance*)((FlameModPage*)parent())->m_instance)
- ->getPackProfile()
- ->getComponentVersion("net.fabricmc.fabric-loader")
- .isEmpty();
- auto netJob = new NetJob("Flame::Search", APPLICATION->network());
- auto searchUrl = QString(
- "https://addons-ecs.forgesvc.net/api/v2/addon/search?"
- "gameId=432&"
- "categoryId=0&"
- "sectionId=6&"
-
- "index=%1&"
- "pageSize=25&"
- "searchFilter=%2&"
- "sort=%3&"
- "modLoaderType=%4&"
- "gameVersion=%5")
- .arg(nextSearchOffset)
- .arg(currentSearchTerm)
- .arg(sorts[currentSort])
- .arg(hasFabric ? 4 : 1) // Enum: https://docs.curseforge.com/?http#tocS_ModLoaderType
- .arg(mcVersion);
-
- netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
- jobPtr = netJob;
- jobPtr->start();
-
- QObject::connect(netJob, &NetJob::succeeded, this, &FlameMod::ListModel::searchRequestFinished);
- QObject::connect(netJob, &NetJob::failed, this, &ListModel::searchRequestFailed);
-}
void FlameMod::ListModel::searchRequestFinished()
{
@@ -87,4 +51,11 @@ void FlameMod::ListModel::searchRequestFinished()
endInsertRows();
}
+const char* sorts[6]{ "Featured", "Popularity", "LastUpdated", "Name", "Author", "TotalDownloads" };
+
+const char** FlameMod::ListModel::getSorts() const
+{
+ return sorts;
+}
+
} // namespace FlameMod
diff --git a/launcher/ui/pages/modplatform/flame/FlameModModel.h b/launcher/ui/pages/modplatform/flame/FlameModModel.h
index a585331d..ae919e63 100644
--- a/launcher/ui/pages/modplatform/flame/FlameModModel.h
+++ b/launcher/ui/pages/modplatform/flame/FlameModModel.h
@@ -30,8 +30,10 @@ class ListModel : public ModPlatform::ListModel {
virtual ~ListModel();
private slots:
- void performPaginatedSearch() override;
void searchRequestFinished() override;
+
+ private:
+ const char** getSorts() const override;
};
} // namespace Modrinth
diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.h b/launcher/ui/pages/modplatform/flame/FlameModPage.h
index 2daa155f..e7d98cb0 100644
--- a/launcher/ui/pages/modplatform/flame/FlameModPage.h
+++ b/launcher/ui/pages/modplatform/flame/FlameModPage.h
@@ -2,6 +2,8 @@
#include "ui/pages/modplatform/ModPage.h"
+#include "modplatform/flame/FlameAPI.h"
+
class FlameModPage : public ModPage {
Q_OBJECT
@@ -18,7 +20,11 @@ class FlameModPage : public ModPage {
inline QString metaEntryBase() const override { return "FlameMods"; };
bool shouldDisplay() const override;
+ const ModAPI* apiProvider() const override { return &api; };
private:
void onModVersionSucceed(ModPage*, QByteArray*, QString) override;
+
+ private:
+ FlameAPI api;
};