fix: 'All' filter working and get around CF API capabilities
This commit is contained in:
parent
5cb0e75093
commit
76dfb7825a
@ -6,6 +6,8 @@ class FlameAPI : public NetworkModAPI {
|
|||||||
private:
|
private:
|
||||||
inline auto getModSearchURL(SearchArgs& args) const -> QString override
|
inline auto getModSearchURL(SearchArgs& args) const -> QString override
|
||||||
{
|
{
|
||||||
|
auto gameVersionStr = args.versions.size() != 0 ? QString("gameVersion=%1").arg(args.versions.front().toString()) : QString();
|
||||||
|
|
||||||
return QString(
|
return QString(
|
||||||
"https://addons-ecs.forgesvc.net/api/v2/addon/search?"
|
"https://addons-ecs.forgesvc.net/api/v2/addon/search?"
|
||||||
"gameId=432&"
|
"gameId=432&"
|
||||||
@ -17,12 +19,12 @@ class FlameAPI : public NetworkModAPI {
|
|||||||
"searchFilter=%2&"
|
"searchFilter=%2&"
|
||||||
"sort=%3&"
|
"sort=%3&"
|
||||||
"modLoaderType=%4&"
|
"modLoaderType=%4&"
|
||||||
"gameVersion=%5")
|
"%5")
|
||||||
.arg(args.offset)
|
.arg(args.offset)
|
||||||
.arg(args.search)
|
.arg(args.search)
|
||||||
.arg(args.sorting)
|
.arg(args.sorting)
|
||||||
.arg(args.mod_loader)
|
.arg(args.mod_loader)
|
||||||
.arg(getGameVersionsString(args.versions));
|
.arg(gameVersionStr);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline auto getVersionsURL(VersionSearchArgs& args) const -> QString override
|
inline auto getVersionsURL(VersionSearchArgs& args) const -> QString override
|
||||||
|
@ -22,7 +22,7 @@ class ModrinthAPI : public NetworkModAPI {
|
|||||||
"limit=25&"
|
"limit=25&"
|
||||||
"query=%2&"
|
"query=%2&"
|
||||||
"index=%3&"
|
"index=%3&"
|
||||||
"facets=[[\"categories:%4\"],[%5],[\"project_type:mod\"]]")
|
"facets=[[\"categories:%4\"],%5[\"project_type:mod\"]]")
|
||||||
.arg(args.offset)
|
.arg(args.offset)
|
||||||
.arg(args.search)
|
.arg(args.search)
|
||||||
.arg(args.sorting)
|
.arg(args.sorting)
|
||||||
@ -47,7 +47,7 @@ class ModrinthAPI : public NetworkModAPI {
|
|||||||
s += QString("\"versions:%1\",").arg(ver.toString());
|
s += QString("\"versions:%1\",").arg(ver.toString());
|
||||||
}
|
}
|
||||||
s.remove(s.length() - 1, 1); //remove last comma
|
s.remove(s.length() - 1, 1); //remove last comma
|
||||||
return s;
|
return s.isEmpty() ? QString() : QString("[%1],").arg(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static auto getModLoaderString(ModLoaderType type) -> const QString
|
static auto getModLoaderString(ModLoaderType type) -> const QString
|
||||||
|
@ -9,7 +9,7 @@ FilterModsDialog::FilterModsDialog(Version def, QWidget* parent)
|
|||||||
m_mcVersion_buttons.addButton(ui->strictVersionButton, VersionButtonID::Strict);
|
m_mcVersion_buttons.addButton(ui->strictVersionButton, VersionButtonID::Strict);
|
||||||
m_mcVersion_buttons.addButton(ui->majorVersionButton, VersionButtonID::Major);
|
m_mcVersion_buttons.addButton(ui->majorVersionButton, VersionButtonID::Major);
|
||||||
m_mcVersion_buttons.addButton(ui->allVersionsButton, VersionButtonID::All);
|
m_mcVersion_buttons.addButton(ui->allVersionsButton, VersionButtonID::All);
|
||||||
m_mcVersion_buttons.addButton(ui->betweenVersionsButton, VersionButtonID::Between);
|
//m_mcVersion_buttons.addButton(ui->betweenVersionsButton, VersionButtonID::Between);
|
||||||
|
|
||||||
connect(&m_mcVersion_buttons, SIGNAL(idClicked(int)), this, SLOT(onVersionFilterChanged(int)));
|
connect(&m_mcVersion_buttons, SIGNAL(idClicked(int)), this, SLOT(onVersionFilterChanged(int)));
|
||||||
|
|
||||||
@ -31,18 +31,38 @@ int FilterModsDialog::execWithInstance(MinecraftInstance* instance)
|
|||||||
tr("Major varsion match (= %1.%2.x)").arg(mcVersionSplit[0], mcVersionSplit[1]));
|
tr("Major varsion match (= %1.%2.x)").arg(mcVersionSplit[0], mcVersionSplit[1]));
|
||||||
ui->allVersionsButton->setText(
|
ui->allVersionsButton->setText(
|
||||||
tr("Any version match"));
|
tr("Any version match"));
|
||||||
ui->betweenVersionsButton->setText(
|
//ui->betweenVersionsButton->setText(
|
||||||
tr("Between two versions"));
|
// tr("Between two versions"));
|
||||||
|
|
||||||
int ret = QDialog::exec();
|
int ret = QDialog::exec();
|
||||||
m_instance = nullptr;
|
m_instance = nullptr;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FilterModsDialog::disableVersionButton(VersionButtonID id)
|
||||||
|
{
|
||||||
|
switch(id){
|
||||||
|
case(VersionButtonID::Strict):
|
||||||
|
ui->strictVersionButton->setEnabled(false);
|
||||||
|
break;
|
||||||
|
case(VersionButtonID::Major):
|
||||||
|
ui->majorVersionButton->setEnabled(false);
|
||||||
|
break;
|
||||||
|
case(VersionButtonID::All):
|
||||||
|
ui->allVersionsButton->setEnabled(false);
|
||||||
|
break;
|
||||||
|
case(VersionButtonID::Between):
|
||||||
|
// ui->betweenVersionsButton->setEnabled(false);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FilterModsDialog::onVersionFilterChanged(int id)
|
void FilterModsDialog::onVersionFilterChanged(int id)
|
||||||
{
|
{
|
||||||
ui->lowerVersionComboBox->setEnabled(id == VersionButtonID::Between);
|
//ui->lowerVersionComboBox->setEnabled(id == VersionButtonID::Between);
|
||||||
ui->upperVersionComboBox->setEnabled(id == VersionButtonID::Between);
|
//ui->upperVersionComboBox->setEnabled(id == VersionButtonID::Between);
|
||||||
|
|
||||||
auto versionSplit = mcVersionStr().split(".");
|
auto versionSplit = mcVersionStr().split(".");
|
||||||
int index = 0;
|
int index = 0;
|
||||||
@ -60,6 +80,7 @@ void FilterModsDialog::onVersionFilterChanged(int id)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case(VersionButtonID::All):
|
case(VersionButtonID::All):
|
||||||
|
// Empty list to avoid enumerating all versions :P
|
||||||
break;
|
break;
|
||||||
case(VersionButtonID::Between):
|
case(VersionButtonID::Between):
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -17,6 +17,13 @@ class FilterModsDialog : public QDialog
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
enum VersionButtonID {
|
||||||
|
Strict = 0,
|
||||||
|
Major = 1,
|
||||||
|
All = 2,
|
||||||
|
Between = 3
|
||||||
|
};
|
||||||
|
|
||||||
struct Filter {
|
struct Filter {
|
||||||
std::list<Version> versions;
|
std::list<Version> versions;
|
||||||
};
|
};
|
||||||
@ -29,16 +36,12 @@ public:
|
|||||||
|
|
||||||
int execWithInstance(MinecraftInstance* instance);
|
int execWithInstance(MinecraftInstance* instance);
|
||||||
|
|
||||||
|
/// By default all buttons are enabled
|
||||||
|
void disableVersionButton(VersionButtonID);
|
||||||
|
|
||||||
auto getFilter() -> std::shared_ptr<Filter> { return m_filter; }
|
auto getFilter() -> std::shared_ptr<Filter> { return m_filter; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum VersionButtonID {
|
|
||||||
Strict = 0,
|
|
||||||
Major = 1,
|
|
||||||
All = 2,
|
|
||||||
Between = 3
|
|
||||||
};
|
|
||||||
|
|
||||||
inline auto mcVersionStr() const -> QString { return m_instance ? m_instance->getPackProfile()->getComponentVersion("net.minecraft") : ""; }
|
inline auto mcVersionStr() const -> QString { return m_instance ? m_instance->getPackProfile()->getComponentVersion("net.minecraft") : ""; }
|
||||||
inline auto mcVersion() const -> Version { return { mcVersionStr() }; }
|
inline auto mcVersion() const -> Version { return { mcVersionStr() }; }
|
||||||
|
|
||||||
|
@ -10,15 +10,17 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>345</width>
|
<width>345</width>
|
||||||
<height>323</height>
|
<height>169</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="sizePolicy">
|
||||||
<string>Copy Instance</string>
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowIcon">
|
<property name="windowTitle">
|
||||||
<iconset>
|
<string>Filter options</string>
|
||||||
<normaloff>:/icons/toolbar/copy</normaloff>:/icons/toolbar/copy</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeGripEnabled">
|
<property name="sizeGripEnabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -78,59 +80,11 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
|
||||||
<item>
|
|
||||||
<layout class="QFormLayout" name="formLayout">
|
|
||||||
<item row="0" column="0" colspan="2">
|
|
||||||
<widget class="QRadioButton" name="betweenVersionsButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>BetweenVersions</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="fromLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>From</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QComboBox" name="lowerVersionComboBox"/>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QLabel" name="toLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>To</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QComboBox" name="upperVersionComboBox"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -64,7 +64,6 @@ void ModPage::filterMods()
|
|||||||
m_filter = filter_dialog.getFilter();
|
m_filter = filter_dialog.getFilter();
|
||||||
|
|
||||||
listModel->refresh();
|
listModel->refresh();
|
||||||
|
|
||||||
if(ui->versionSelectionBox->count() > 0){
|
if(ui->versionSelectionBox->count() > 0){
|
||||||
ui->versionSelectionBox->clear();
|
ui->versionSelectionBox->clear();
|
||||||
updateModVersions();
|
updateModVersions();
|
||||||
@ -164,14 +163,14 @@ void ModPage::updateModVersions()
|
|||||||
for (int i = 0; i < current.versions.size(); i++) {
|
for (int i = 0; i < current.versions.size(); i++) {
|
||||||
auto version = current.versions[i];
|
auto version = current.versions[i];
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
//NOTE: Flame doesn't care about loaderString, so passing it changes nothing.
|
|
||||||
for(auto& mcVer : m_filter->versions){
|
for(auto& mcVer : m_filter->versions){
|
||||||
|
//NOTE: Flame doesn't care about loaderString, so passing it changes nothing.
|
||||||
if (validateVersion(version, mcVer.toString(), loaderString)) {
|
if (validateVersion(version, mcVer.toString(), loaderString)) {
|
||||||
valid = true;
|
valid = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(valid)
|
if(valid || m_filter->versions.size() == 0)
|
||||||
ui->versionSelectionBox->addItem(version.version, QVariant(i));
|
ui->versionSelectionBox->addItem(version.version, QVariant(i));
|
||||||
}
|
}
|
||||||
if (ui->versionSelectionBox->count() == 0) { ui->versionSelectionBox->addItem(tr("No valid version found!"), QVariant(-1)); }
|
if (ui->versionSelectionBox->count() == 0) { ui->versionSelectionBox->addItem(tr("No valid version found!"), QVariant(-1)); }
|
||||||
|
@ -54,7 +54,7 @@ class ModPage : public QWidget, public BasePage {
|
|||||||
void updateSelectionButton();
|
void updateSelectionButton();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void filterMods();
|
virtual void filterMods();
|
||||||
void triggerSearch();
|
void triggerSearch();
|
||||||
void onSelectionChanged(QModelIndex first, QModelIndex second);
|
void onSelectionChanged(QModelIndex first, QModelIndex second);
|
||||||
void onVersionSelectionChanged(QString data);
|
void onVersionSelectionChanged(QString data);
|
||||||
|
@ -67,6 +67,25 @@ auto FlameModPage::validateVersion(ModPlatform::IndexedVersion& ver, QString min
|
|||||||
return ver.mcVersion.contains(mineVer);
|
return ver.mcVersion.contains(mineVer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We override this so that it refreshes correctly, otherwise it wouldn't show
|
||||||
|
// any mod on the mod list, because the CF API does not support it :(
|
||||||
|
void FlameModPage::filterMods()
|
||||||
|
{
|
||||||
|
filter_dialog.execWithInstance(static_cast<MinecraftInstance*>(m_instance));
|
||||||
|
|
||||||
|
int prev_size = m_filter->versions.size();
|
||||||
|
m_filter = filter_dialog.getFilter();
|
||||||
|
int new_size = m_filter->versions.size();
|
||||||
|
|
||||||
|
if(new_size <= 1 && new_size != prev_size)
|
||||||
|
listModel->refresh();
|
||||||
|
|
||||||
|
if(ui->versionSelectionBox->count() > 0){
|
||||||
|
ui->versionSelectionBox->clear();
|
||||||
|
updateModVersions();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// I don't know why, but doing this on the parent class makes it so that
|
// I don't know why, but doing this on the parent class makes it so that
|
||||||
// other mod providers start loading before being selected, at least with
|
// other mod providers start loading before being selected, at least with
|
||||||
// my Qt, so we need to implement this in every derived class...
|
// my Qt, so we need to implement this in every derived class...
|
||||||
|
@ -56,5 +56,7 @@ class FlameModPage : public ModPage {
|
|||||||
|
|
||||||
auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, QString loaderVer = "") const -> bool override;
|
auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, QString loaderVer = "") const -> bool override;
|
||||||
|
|
||||||
|
void filterMods() override;
|
||||||
|
|
||||||
auto shouldDisplay() const -> bool override;
|
auto shouldDisplay() const -> bool override;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user