feat: Use version filter when searching mods
This commit is contained in:
parent
c2b97c3e3f
commit
c730fd6e5f
@ -3,6 +3,8 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
|
#include "Version.h"
|
||||||
|
|
||||||
namespace ModPlatform {
|
namespace ModPlatform {
|
||||||
class ListModel;
|
class ListModel;
|
||||||
}
|
}
|
||||||
@ -22,7 +24,7 @@ class ModAPI {
|
|||||||
QString search;
|
QString search;
|
||||||
QString sorting;
|
QString sorting;
|
||||||
ModLoaderType mod_loader;
|
ModLoaderType mod_loader;
|
||||||
QString version;
|
std::list<Version> versions;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void searchMods(CallerType* caller, SearchArgs&& args) const = 0;
|
virtual void searchMods(CallerType* caller, SearchArgs&& args) const = 0;
|
||||||
@ -30,7 +32,7 @@ class ModAPI {
|
|||||||
|
|
||||||
struct VersionSearchArgs {
|
struct VersionSearchArgs {
|
||||||
QString addonId;
|
QString addonId;
|
||||||
QList<QString> mcVersions;
|
std::list<Version> mcVersions;
|
||||||
ModLoaderType loader;
|
ModLoaderType loader;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -53,4 +55,16 @@ class ModAPI {
|
|||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
inline auto getGameVersionsString(std::list<Version> mcVersions) const -> QString
|
||||||
|
{
|
||||||
|
QString s;
|
||||||
|
for(auto& ver : mcVersions){
|
||||||
|
s += ver.toString();
|
||||||
|
if(ver != mcVersions.back())
|
||||||
|
s += ",";
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -22,7 +22,7 @@ class FlameAPI : public NetworkModAPI {
|
|||||||
.arg(args.search)
|
.arg(args.search)
|
||||||
.arg(args.sorting)
|
.arg(args.sorting)
|
||||||
.arg(args.mod_loader)
|
.arg(args.mod_loader)
|
||||||
.arg(args.version);
|
.arg(getGameVersionsString(args.versions));
|
||||||
};
|
};
|
||||||
|
|
||||||
inline auto getVersionsURL(VersionSearchArgs& args) const -> QString override
|
inline auto getVersionsURL(VersionSearchArgs& args) const -> QString override
|
||||||
|
@ -27,7 +27,7 @@ class ModrinthAPI : public NetworkModAPI {
|
|||||||
.arg(args.search)
|
.arg(args.search)
|
||||||
.arg(args.sorting)
|
.arg(args.sorting)
|
||||||
.arg(getModLoaderString(args.mod_loader))
|
.arg(getModLoaderString(args.mod_loader))
|
||||||
.arg(args.version);
|
.arg(getGameVersionsString(args.versions));
|
||||||
};
|
};
|
||||||
|
|
||||||
inline auto getVersionsURL(VersionSearchArgs& args) const -> QString override
|
inline auto getVersionsURL(VersionSearchArgs& args) const -> QString override
|
||||||
@ -40,17 +40,6 @@ class ModrinthAPI : public NetworkModAPI {
|
|||||||
.arg(getModLoaderString(args.loader));
|
.arg(getModLoaderString(args.loader));
|
||||||
};
|
};
|
||||||
|
|
||||||
inline auto getGameVersionsString(QList<QString> mcVersions) const -> QString
|
|
||||||
{
|
|
||||||
QString s;
|
|
||||||
for(int i = 0; i < mcVersions.count(); i++){
|
|
||||||
s += mcVersions.at(i);
|
|
||||||
if(i < mcVersions.count() - 1)
|
|
||||||
s += ",";
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
static auto getModLoaderString(ModLoaderType type) -> const QString
|
static auto getModLoaderString(ModLoaderType type) -> const QString
|
||||||
{
|
{
|
||||||
if (type == Unspecified)
|
if (type == Unspecified)
|
||||||
|
@ -72,7 +72,7 @@ void ListModel::performPaginatedSearch()
|
|||||||
auto profile = (dynamic_cast<MinecraftInstance*>((dynamic_cast<ModPage*>(parent()))->m_instance))->getPackProfile();
|
auto profile = (dynamic_cast<MinecraftInstance*>((dynamic_cast<ModPage*>(parent()))->m_instance))->getPackProfile();
|
||||||
|
|
||||||
m_parent->apiProvider()->searchMods(this,
|
m_parent->apiProvider()->searchMods(this,
|
||||||
{ nextSearchOffset, currentSearchTerm, getSorts()[currentSort], profile->getModLoader(), getMineVersions().at(0) });
|
{ nextSearchOffset, currentSearchTerm, getSorts()[currentSort], profile->getModLoader(), getMineVersions() });
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListModel::searchWithTerm(const QString& term, const int sort)
|
void ListModel::searchWithTerm(const QString& term, const int sort)
|
||||||
@ -223,9 +223,7 @@ void ListModel::versionRequestSucceeded(QJsonDocument doc, QString addonId)
|
|||||||
|
|
||||||
/******** Helpers ********/
|
/******** Helpers ********/
|
||||||
|
|
||||||
auto ModPlatform::ListModel::getMineVersions() const -> QList<QString>
|
auto ModPlatform::ListModel::getMineVersions() const -> std::list<Version>
|
||||||
{
|
{
|
||||||
return { (dynamic_cast<MinecraftInstance*>((dynamic_cast<ModPage*>(parent()))->m_instance))
|
return m_parent->getFilter()->versions;
|
||||||
->getPackProfile()
|
|
||||||
->getComponentVersion("net.minecraft") };
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "net/NetJob.h"
|
#include "net/NetJob.h"
|
||||||
|
|
||||||
class ModPage;
|
class ModPage;
|
||||||
|
class Version;
|
||||||
|
|
||||||
namespace ModPlatform {
|
namespace ModPlatform {
|
||||||
|
|
||||||
@ -62,7 +63,7 @@ class ListModel : public QAbstractListModel {
|
|||||||
|
|
||||||
void requestLogo(QString file, QString url);
|
void requestLogo(QString file, QString url);
|
||||||
|
|
||||||
inline auto getMineVersions() const -> QList<QString>;
|
inline auto getMineVersions() const -> std::list<Version>;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ModPage* m_parent;
|
ModPage* m_parent;
|
||||||
|
Loading…
Reference in New Issue
Block a user