commit
4ff1306e0c
@ -249,6 +249,7 @@ void InstanceImportTask::processFlame()
|
||||
|
||||
QString forgeVersion;
|
||||
QString fabricVersion;
|
||||
// TODO: is Quilt relevant here?
|
||||
for(auto &loader: pack.minecraft.modLoaders)
|
||||
{
|
||||
auto id = loader.id;
|
||||
|
@ -591,7 +591,7 @@ void ComponentUpdateTask::resolveDependencies(bool checkOnly)
|
||||
{
|
||||
component->m_version = "3.1.2";
|
||||
}
|
||||
else if (add.uid == "net.fabricmc.intermediary")
|
||||
else if (add.uid == "net.fabricmc.intermediary" || add.uid == "org.quiltmc.hashed")
|
||||
{
|
||||
auto minecraft = std::find_if(components.begin(), components.end(), [](ComponentPtr & cmp){
|
||||
return cmp->getID() == "net.minecraft";
|
||||
|
@ -970,3 +970,20 @@ void PackProfile::disableInteraction(bool disable)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ModAPI::ModLoaderType PackProfile::getModLoader()
|
||||
{
|
||||
if (!getComponentVersion("net.minecraftforge").isEmpty())
|
||||
{
|
||||
return ModAPI::Forge;
|
||||
}
|
||||
else if (!getComponentVersion("net.fabricmc.fabric-loader").isEmpty())
|
||||
{
|
||||
return ModAPI::Fabric;
|
||||
}
|
||||
else if (!getComponentVersion("org.quiltmc.quilt-loader").isEmpty())
|
||||
{
|
||||
return ModAPI::Quilt;
|
||||
}
|
||||
return ModAPI::Unspecified;
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "BaseVersion.h"
|
||||
#include "MojangDownloadInfo.h"
|
||||
#include "net/Mode.h"
|
||||
#include "modplatform/ModAPI.h"
|
||||
|
||||
class MinecraftInstance;
|
||||
struct PackProfileData;
|
||||
@ -117,6 +118,8 @@ public:
|
||||
// todo(merged): is this the best approach
|
||||
void appendComponent(ComponentPtr component);
|
||||
|
||||
ModAPI::ModLoaderType getModLoader();
|
||||
|
||||
private:
|
||||
void scheduleSave();
|
||||
bool saveIsScheduled() const;
|
||||
|
@ -391,7 +391,7 @@ void LocalModParseTask::processAsZip()
|
||||
zip.close();
|
||||
return;
|
||||
}
|
||||
else if (zip.setCurrentFile("fabric.mod.json"))
|
||||
else if (zip.setCurrentFile("fabric.mod.json")) // TODO: Support quilt.mod.json
|
||||
{
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ class ModAPI {
|
||||
virtual ~ModAPI() = default;
|
||||
|
||||
// https://docs.curseforge.com/?http#tocS_ModLoaderType
|
||||
enum ModLoaderType { Any = 0, Forge = 1, Cauldron = 2, LiteLoader = 3, Fabric = 4 };
|
||||
enum ModLoaderType { Unspecified = 0, Forge = 1, Cauldron = 2, LiteLoader = 3, Fabric = 4, Quilt = 5 };
|
||||
|
||||
struct SearchArgs {
|
||||
int offset;
|
||||
@ -35,4 +35,22 @@ class ModAPI {
|
||||
};
|
||||
|
||||
virtual void getVersions(CallerType* caller, VersionSearchArgs&& args) const = 0;
|
||||
|
||||
static auto getModLoaderString(ModLoaderType type) -> const QString {
|
||||
switch (type) {
|
||||
case Unspecified:
|
||||
break;
|
||||
case Forge:
|
||||
return "forge";
|
||||
case Cauldron:
|
||||
return "cauldron";
|
||||
case LiteLoader:
|
||||
return "liteloader";
|
||||
case Fabric:
|
||||
return "fabric";
|
||||
case Quilt:
|
||||
return "quilt";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
@ -69,6 +69,7 @@ void FlameMod::loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
|
||||
for (auto m : modules) {
|
||||
auto fname = Json::requireString(m.toObject(), "foldername");
|
||||
// FIXME: This does not work properly when a mod supports more than one mod loader, since
|
||||
// FIXME: This also doesn't deal with Quilt mods at the moment
|
||||
// they bundle the meta files for all of them in the same arquive, even when that version
|
||||
// doesn't support the given mod loader.
|
||||
if (hasFabric) {
|
||||
|
@ -51,23 +51,16 @@ class ModrinthAPI : public NetworkModAPI {
|
||||
return s;
|
||||
}
|
||||
|
||||
inline auto getModLoaderString(ModLoaderType modLoader) const -> QString
|
||||
static auto getModLoaderString(ModLoaderType type) -> const QString
|
||||
{
|
||||
switch (modLoader) {
|
||||
case Any:
|
||||
return "fabric, forge";
|
||||
case Forge:
|
||||
return "forge";
|
||||
case Fabric:
|
||||
return "fabric";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
if (type == Unspecified)
|
||||
return "fabric, forge, quilt";
|
||||
return ModAPI::getModLoaderString(type);
|
||||
}
|
||||
|
||||
inline auto validateModLoader(ModLoaderType modLoader) const -> bool
|
||||
{
|
||||
return modLoader == Any || modLoader == Forge || modLoader == Fabric;
|
||||
return modLoader == Unspecified || modLoader == Forge || modLoader == Fabric || modLoader == Quilt;
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -56,6 +56,8 @@
|
||||
#include "minecraft/VersionFilterData.h"
|
||||
#include "minecraft/PackProfile.h"
|
||||
|
||||
#include "modplatform/ModAPI.h"
|
||||
|
||||
#include "Version.h"
|
||||
#include "ui/dialogs/ProgressDialog.h"
|
||||
#include "tasks/SequentialTask.h"
|
||||
@ -388,9 +390,8 @@ void ModFolderPage::on_actionInstall_mods_triggered()
|
||||
if(m_inst->typeName() != "Minecraft"){
|
||||
return; //this is a null instance or a legacy instance
|
||||
}
|
||||
bool hasFabric = !((MinecraftInstance *)m_inst)->getPackProfile()->getComponentVersion("net.fabricmc.fabric-loader").isEmpty();
|
||||
bool hasForge = !((MinecraftInstance *)m_inst)->getPackProfile()->getComponentVersion("net.minecraftforge").isEmpty();
|
||||
if (!hasFabric && !hasForge) {
|
||||
auto profile = ((MinecraftInstance *)m_inst)->getPackProfile();
|
||||
if (profile->getModLoader() == ModAPI::Unspecified) {
|
||||
QMessageBox::critical(this,tr("Error"),tr("Please install a mod loader first!"));
|
||||
return;
|
||||
}
|
||||
|
@ -243,6 +243,9 @@ void VersionPage::updateVersionControls()
|
||||
bool supportsFabric = minecraftVersion >= Version("1.14");
|
||||
ui->actionInstall_Fabric->setEnabled(controlsEnabled && supportsFabric);
|
||||
|
||||
bool supportsQuilt = minecraftVersion >= Version("1.14");
|
||||
ui->actionInstall_Quilt->setEnabled(controlsEnabled && supportsQuilt);
|
||||
|
||||
bool supportsLiteLoader = minecraftVersion <= Version("1.12.2");
|
||||
ui->actionInstall_LiteLoader->setEnabled(controlsEnabled && supportsLiteLoader);
|
||||
|
||||
@ -392,7 +395,7 @@ void VersionPage::on_actionChange_version_triggered()
|
||||
return;
|
||||
}
|
||||
VersionSelectDialog vselect(list.get(), tr("Change %1 version").arg(name), this);
|
||||
if (uid == "net.fabricmc.intermediary")
|
||||
if (uid == "net.fabricmc.intermediary" || uid == "org.quiltmc.hashed")
|
||||
{
|
||||
vselect.setEmptyString(tr("No intermediary mappings versions are currently available."));
|
||||
vselect.setEmptyErrorString(tr("Couldn't load or download the intermediary mappings version lists!"));
|
||||
@ -498,6 +501,33 @@ void VersionPage::on_actionInstall_Fabric_triggered()
|
||||
}
|
||||
}
|
||||
|
||||
void VersionPage::on_actionInstall_Quilt_triggered()
|
||||
{
|
||||
auto vlist = APPLICATION->metadataIndex()->get("org.quiltmc.quilt-loader");
|
||||
if(!vlist)
|
||||
{
|
||||
return;
|
||||
}
|
||||
VersionSelectDialog vselect(vlist.get(), tr("Select Quilt Loader version"), this);
|
||||
vselect.setEmptyString(tr("No Quilt Loader versions are currently available."));
|
||||
vselect.setEmptyErrorString(tr("Couldn't load or download the Quilt Loader version lists!"));
|
||||
|
||||
auto currentVersion = m_profile->getComponentVersion("org.quiltmc.quilt-loader");
|
||||
if(!currentVersion.isEmpty())
|
||||
{
|
||||
vselect.setCurrentVersion(currentVersion);
|
||||
}
|
||||
|
||||
if (vselect.exec() && vselect.selectedVersion())
|
||||
{
|
||||
auto vsn = vselect.selectedVersion();
|
||||
m_profile->setComponentVersion("org.quiltmc.quilt-loader", vsn->descriptor());
|
||||
m_profile->resolve(Net::Mode::Online);
|
||||
preselect(m_profile->rowCount(QModelIndex())-1);
|
||||
m_container->refreshContainer();
|
||||
}
|
||||
}
|
||||
|
||||
void VersionPage::on_actionAdd_Empty_triggered()
|
||||
{
|
||||
NewComponentDialog compdialog(QString(), QString(), this);
|
||||
|
@ -73,6 +73,7 @@ private slots:
|
||||
void on_actionChange_version_triggered();
|
||||
void on_actionInstall_Forge_triggered();
|
||||
void on_actionInstall_Fabric_triggered();
|
||||
void on_actionInstall_Quilt_triggered();
|
||||
void on_actionAdd_Empty_triggered();
|
||||
void on_actionInstall_LiteLoader_triggered();
|
||||
void on_actionReload_triggered();
|
||||
|
@ -107,6 +107,7 @@
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionInstall_Forge"/>
|
||||
<addaction name="actionInstall_Fabric"/>
|
||||
<addaction name="actionInstall_Quilt"/>
|
||||
<addaction name="actionInstall_LiteLoader"/>
|
||||
<addaction name="actionInstall_mods"/>
|
||||
<addaction name="separator"/>
|
||||
@ -192,6 +193,14 @@
|
||||
<string>Install the Fabric Loader package.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionInstall_Quilt">
|
||||
<property name="text">
|
||||
<string>Install Quilt</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Install the Quilt Loader package.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionInstall_LiteLoader">
|
||||
<property name="text">
|
||||
<string>Install LiteLoader</string>
|
||||
|
@ -61,14 +61,18 @@ auto ListModel::data(const QModelIndex& index, int role) const -> QVariant
|
||||
|
||||
void ListModel::requestModVersions(ModPlatform::IndexedPack const& current)
|
||||
{
|
||||
auto profile = (dynamic_cast<MinecraftInstance*>((dynamic_cast<ModPage*>(parent()))->m_instance))->getPackProfile();
|
||||
|
||||
m_parent->apiProvider()->getVersions(this,
|
||||
{ current.addonId.toString(), getMineVersions(), hasFabric() ? ModAPI::ModLoaderType::Fabric : ModAPI::ModLoaderType::Forge });
|
||||
{ current.addonId.toString(), getMineVersions(), profile->getModLoader() });
|
||||
}
|
||||
|
||||
void ListModel::performPaginatedSearch()
|
||||
{
|
||||
auto profile = (dynamic_cast<MinecraftInstance*>((dynamic_cast<ModPage*>(parent()))->m_instance))->getPackProfile();
|
||||
|
||||
m_parent->apiProvider()->searchMods(this,
|
||||
{ nextSearchOffset, currentSearchTerm, getSorts()[currentSort], hasFabric() ? ModAPI::Fabric : ModAPI::Forge, getMineVersions().at(0) });
|
||||
{ nextSearchOffset, currentSearchTerm, getSorts()[currentSort], profile->getModLoader(), getMineVersions().at(0) });
|
||||
}
|
||||
|
||||
void ListModel::searchWithTerm(const QString& term, const int sort)
|
||||
@ -218,13 +222,6 @@ void ListModel::versionRequestSucceeded(QJsonDocument doc, QString addonId)
|
||||
} // namespace ModPlatform
|
||||
|
||||
/******** Helpers ********/
|
||||
auto ModPlatform::ListModel::hasFabric() const -> bool
|
||||
{
|
||||
return !(dynamic_cast<MinecraftInstance*>((dynamic_cast<ModPage*>(parent()))->m_instance))
|
||||
->getPackProfile()
|
||||
->getComponentVersion("net.fabricmc.fabric-loader")
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
auto ModPlatform::ListModel::getMineVersions() const -> QList<QString>
|
||||
{
|
||||
|
@ -62,7 +62,6 @@ class ListModel : public QAbstractListModel {
|
||||
|
||||
void requestLogo(QString file, QString url);
|
||||
|
||||
inline auto hasFabric() const -> bool;
|
||||
inline auto getMineVersions() const -> QList<QString>;
|
||||
|
||||
protected:
|
||||
|
@ -68,7 +68,7 @@ void ModPage::onSelectionChanged(QModelIndex first, QModelIndex second)
|
||||
text = name;
|
||||
else
|
||||
text = "<a href=\"" + current.websiteUrl + "\">" + name + "</a>";
|
||||
|
||||
|
||||
if (!current.authors.empty()) {
|
||||
auto authorToStr = [](ModPlatform::ModpackAuthor& author) -> QString {
|
||||
if (author.url.isEmpty()) { return author.name; }
|
||||
@ -128,7 +128,7 @@ void ModPage::onModSelected()
|
||||
|
||||
void ModPage::retranslate()
|
||||
{
|
||||
ui->retranslateUi(this);
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
|
||||
void ModPage::updateModVersions()
|
||||
@ -136,13 +136,14 @@ void ModPage::updateModVersions()
|
||||
auto packProfile = (dynamic_cast<MinecraftInstance*>(m_instance))->getPackProfile();
|
||||
|
||||
QString mcVersion = packProfile->getComponentVersion("net.minecraft");
|
||||
QString loaderString = (packProfile->getComponentVersion("net.minecraftforge").isEmpty()) ? "fabric" : "forge";
|
||||
|
||||
QString loaderString = ModAPI::getModLoaderString(packProfile->getModLoader());
|
||||
|
||||
for (int i = 0; i < current.versions.size(); i++) {
|
||||
auto version = current.versions[i];
|
||||
//NOTE: Flame doesn't care about loaderString, so passing it changes nothing.
|
||||
if (!validateVersion(version, mcVersion, loaderString)) {
|
||||
continue;
|
||||
if (!validateVersion(version, mcVersion, loaderString)) {
|
||||
continue;
|
||||
}
|
||||
ui->versionSelectionBox->addItem(version.version, QVariant(i));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user