aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-07-23 21:29:03 +0200
committerPetr Mrázek <peterix@gmail.com>2017-09-09 18:30:22 +0200
commitb29382c748353856053f07b4756fa98f854244e1 (patch)
treef87f95bf99dd0a7251df2a8f8ada2244d402c244
parent4c01983f470e25dfd4c997201370057bba64832e (diff)
downloadPrismLauncher-b29382c748353856053f07b4756fa98f854244e1.tar.gz
PrismLauncher-b29382c748353856053f07b4756fa98f854244e1.tar.bz2
PrismLauncher-b29382c748353856053f07b4756fa98f854244e1.zip
NOISSUE Remove Legacy support
-rw-r--r--api/logic/CMakeLists.txt8
-rw-r--r--api/logic/Env.cpp10
-rw-r--r--api/logic/Env.h2
-rw-r--r--api/logic/FolderInstanceProvider.cpp5
-rw-r--r--api/logic/minecraft/ModList.h1
-rw-r--r--api/logic/minecraft/legacy/LegacyInstance.cpp521
-rw-r--r--api/logic/minecraft/legacy/LegacyInstance.h155
-rw-r--r--api/logic/minecraft/legacy/LegacyModList.cpp616
-rw-r--r--api/logic/minecraft/legacy/LegacyModList.h160
-rw-r--r--api/logic/minecraft/legacy/LegacyUpdate.cpp399
-rw-r--r--api/logic/minecraft/legacy/LegacyUpdate.h70
-rw-r--r--api/logic/minecraft/legacy/LwjglVersionList.cpp169
-rw-r--r--api/logic/minecraft/legacy/LwjglVersionList.h116
-rw-r--r--application/CMakeLists.txt6
-rw-r--r--application/InstancePageProvider.h18
-rw-r--r--application/MainWindow.cpp1
-rw-r--r--application/pages/LegacyJarModPage.cpp162
-rw-r--r--application/pages/LegacyJarModPage.h76
-rw-r--r--application/pages/LegacyJarModPage.ui162
-rw-r--r--application/pages/LegacyUpgradePage.cpp25
-rw-r--r--application/pages/LegacyUpgradePage.h60
-rw-r--r--application/pages/LegacyUpgradePage.ui51
22 files changed, 0 insertions, 2793 deletions
diff --git a/api/logic/CMakeLists.txt b/api/logic/CMakeLists.txt
index 46fcbf81..0fe42a1a 100644
--- a/api/logic/CMakeLists.txt
+++ b/api/logic/CMakeLists.txt
@@ -236,14 +236,6 @@ set(MINECRAFT_SOURCES
minecraft/launch/LauncherPartLaunch.h
minecraft/launch/PrintInstanceInfo.cpp
minecraft/launch/PrintInstanceInfo.h
- minecraft/legacy/LegacyModList.h
- minecraft/legacy/LegacyModList.cpp
- minecraft/legacy/LegacyUpdate.h
- minecraft/legacy/LegacyUpdate.cpp
- minecraft/legacy/LegacyInstance.h
- minecraft/legacy/LegacyInstance.cpp
- minecraft/legacy/LwjglVersionList.h
- minecraft/legacy/LwjglVersionList.cpp
minecraft/GradleSpecifier.h
minecraft/MinecraftProfile.cpp
minecraft/MinecraftProfile.h
diff --git a/api/logic/Env.cpp b/api/logic/Env.cpp
index 3a484703..17ee3fa8 100644
--- a/api/logic/Env.cpp
+++ b/api/logic/Env.cpp
@@ -10,7 +10,6 @@
#include "tasks/Task.h"
#include "meta/Index.h"
#include "FileSystem.h"
-#include "minecraft/legacy/LwjglVersionList.h"
#include <QDebug>
@@ -182,13 +181,4 @@ void Env::setJarsPath(const QString& path)
d->m_jarsPath = path;
}
-LWJGLVersionList *Env::getLegacyLWJGL()
-{
- if(!d->m_lwjgllist)
- {
- d->m_lwjgllist.reset(new LWJGLVersionList());
- }
- return d->m_lwjgllist.get();
-}
-
#include "Env.moc"
diff --git a/api/logic/Env.h b/api/logic/Env.h
index d42f13ce..3dadc58e 100644
--- a/api/logic/Env.h
+++ b/api/logic/Env.h
@@ -53,8 +53,6 @@ public:
shared_qobject_ptr<Meta::Index> metadataIndex();
- LWJGLVersionList *getLegacyLWJGL();
-
QString getJarsPath();
void setJarsPath(const QString & path);
protected:
diff --git a/api/logic/FolderInstanceProvider.cpp b/api/logic/FolderInstanceProvider.cpp
index e0b578e8..414cf479 100644
--- a/api/logic/FolderInstanceProvider.cpp
+++ b/api/logic/FolderInstanceProvider.cpp
@@ -2,7 +2,6 @@
#include "settings/INISettingsObject.h"
#include "FileSystem.h"
#include "minecraft/onesix/OneSixInstance.h"
-#include "minecraft/legacy/LegacyInstance.h"
#include "NullInstance.h"
#include <QDir>
@@ -91,10 +90,6 @@ InstancePtr FolderInstanceProvider::loadInstance(const InstanceId& id)
{
inst.reset(new OneSixInstance(m_globalSettings, instanceSettings, instanceRoot));
}
- else if (inst_type == "Legacy")
- {
- inst.reset(new LegacyInstance(m_globalSettings, instanceSettings, instanceRoot));
- }
else
{
inst.reset(new NullInstance(m_globalSettings, instanceSettings, instanceRoot));
diff --git a/api/logic/minecraft/ModList.h b/api/logic/minecraft/ModList.h
index 8cdd2d9a..f9b6b1c5 100644
--- a/api/logic/minecraft/ModList.h
+++ b/api/logic/minecraft/ModList.h
@@ -24,7 +24,6 @@
#include "multimc_logic_export.h"
-class LegacyInstance;
class BaseInstance;
class QFileSystemWatcher;
diff --git a/api/logic/minecraft/legacy/LegacyInstance.cpp b/api/logic/minecraft/legacy/LegacyInstance.cpp
deleted file mode 100644
index 9382ec21..00000000
--- a/api/logic/minecraft/legacy/LegacyInstance.cpp
+++ /dev/null
@@ -1,521 +0,0 @@
-/* Copyright 2013-2017 MultiMC Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <QFileInfo>
-#include <minecraft/launch/LauncherPartLaunch.h>
-#include <QDir>
-#include <settings/Setting.h>
-
-#include "LegacyInstance.h"
-
-#include "minecraft/legacy/LegacyUpdate.h"
-#include "minecraft/legacy/LegacyModList.h"
-#include "minecraft/ModList.h"
-#include "minecraft/WorldList.h"
-#include <MMCZip.h>
-#include <FileSystem.h>
-
-LegacyInstance::LegacyInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir)
- : MinecraftInstance(globalSettings, settings, rootDir)
-{
- m_lwjglFolderSetting = globalSettings->getSetting("LWJGLDir");
- settings->registerSetting("NeedsRebuild", true);
- settings->registerSetting("ShouldUpdate", false);
- settings->registerSetting("JarVersion", "Unknown");
- settings->registerSetting("LwjglVersion", "2.9.0");
- settings->registerSetting("IntendedJarVersion", "");
- /*
- * custom base jar has no default. it is determined in code... see the accessor methods for
- *it
- *
- * for instances that DO NOT have the CustomBaseJar setting (legacy instances),
- * [.]minecraft/bin/mcbackup.jar is the default base jar
- */
- settings->registerSetting("UseCustomBaseJar", true);
- settings->registerSetting("CustomBaseJar", "");
-}
-
-QString LegacyInstance::baseJar() const
-{
- bool customJar = m_settings->get("UseCustomBaseJar").toBool();
- if (customJar)
- {
- return customBaseJar();
- }
- else
- return defaultBaseJar();
-}
-
-QString LegacyInstance::customBaseJar() const
-{
- QString value = m_settings->get("CustomBaseJar").toString();
- if (value.isNull() || value.isEmpty())
- {
- return defaultCustomBaseJar();
- }
- return value;
-}
-
-void LegacyInstance::setCustomBaseJar(QString val)
-{
- if (val.isNull() || val.isEmpty() || val == defaultCustomBaseJar())
- m_settings->reset("CustomBaseJar");
- else
- m_settings->set("CustomBaseJar", val);
-}
-
-void LegacyInstance::setShouldUseCustomBaseJar(bool val)
-{
- m_settings->set("UseCustomBaseJar", val);
-}
-
-bool LegacyInstance::shouldUseCustomBaseJar() const
-{
- return m_settings->get("UseCustomBaseJar").toBool();
-}
-
-
-shared_qobject_ptr<Task> LegacyInstance::createUpdateTask()
-{
- // make sure the jar mods list is initialized by asking for it.
- auto list = jarModList();
- // create an update task
- return shared_qobject_ptr<Task>(new LegacyUpdate(this, this));
-}
-
-class LegacyJarModTask : public Task
-{
- Q_OBJECT
-public:
- explicit LegacyJarModTask(std::shared_ptr<LegacyInstance> inst) : Task(nullptr), m_inst(inst)
- {
- }
- virtual void executeTask()
- {
- if (!m_inst->shouldRebuild())
- {
- emitSucceeded();
- return;
- }
-
- // Get the mod list
- auto modList = m_inst->getJarMods();
-
- QFileInfo runnableJar(m_inst->runnableJar());
- QFileInfo baseJar(m_inst->baseJar());
- bool base_is_custom = m_inst->shouldUseCustomBaseJar();
-
- // Nothing to do if there are no jar mods to install, no backup and just the mc jar
- if (base_is_custom)
- {
- // yes, this can happen if the instance only has the runnable jar and not the base jar
- // it *could* be assumed that such an instance is vanilla, but that wouldn't be safe
- // because that's not something mmc4 guarantees
- if (runnableJar.isFile() && !baseJar.exists() && modList.empty())
- {
- m_inst->setShouldRebuild(false);
- emitSucceeded();
- return;
- }
-
- setStatus(tr("Installing mods: Backing up minecraft.jar ..."));
- if (!baseJar.exists() && !QFile::copy(runnableJar.filePath(), baseJar.filePath()))
- {
- emitFailed("It seems both the active and base jar are gone. A fresh base jar will "
- "be used on next run.");
- m_inst->setShouldRebuild(true);
- m_inst->setShouldUpdate(true);
- m_inst->setShouldUseCustomBaseJar(false);
- return;
- }
- }
-
- if (!baseJar.exists())
- {
- emitFailed("The base jar " + baseJar.filePath() + " does not exist");
- return;
- }
-
- if (runnableJar.exists() && !QFile::remove(runnableJar.filePath()))
- {
- emitFailed("Failed to delete old minecraft.jar");
- return;
- }
-
- setStatus(tr("Installing mods: Opening minecraft.jar ..."));
-
- QString outputJarPath = runnableJar.filePath();
- QString inputJarPath = baseJar.filePath();
-
- if(!MMCZip::createModdedJar(inputJarPath, outputJarPath, modList))
- {
- emitFailed(tr("Failed to create the custom Minecraft jar file."));
- return;
- }
- m_inst->setShouldRebuild(false);
- // inst->UpdateVersion(true);
- emitSucceeded();
- return;
-
- }
- std::shared_ptr<LegacyInstance> m_inst;
-};
-
-std::shared_ptr<Task> LegacyInstance::createJarModdingTask()
-{
- return std::make_shared<LegacyJarModTask>(std::dynamic_pointer_cast<LegacyInstance>(shared_from_this()));
-}
-
-QString LegacyInstance::createLaunchScript(AuthSessionPtr session)
-{
- QString launchScript;
-
- // window size
- QString windowParams;
- if (settings()->get("LaunchMaximized").toBool())
- {
- windowParams = "max";
- }
- else
- {
- windowParams = QString("%1x%2").arg(settings()->get("MinecraftWinWidth").toInt()).arg(settings()->get("MinecraftWinHeight").toInt());
- }
-
- QString lwjgl = QDir(m_lwjglFolderSetting->get().toString() + "/" + lwjglVersion()).absolutePath();
- launchScript += "userName " + session->player_name + "\n";
- launchScript += "sessionId " + session->session + "\n";
- launchScript += "windowTitle " + windowTitle() + "\n";
- launchScript += "windowParams " + windowParams + "\n";
- launchScript += "cp bin/minecraft.jar\n";
- launchScript += "cp " + lwjgl + "/lwjgl.jar\n";
- launchScript += "cp " + lwjgl + "/lwjgl_util.jar\n";
- launchScript += "cp " + lwjgl + "/jinput.jar\n";
- launchScript += "natives " + lwjgl + "/natives\n";
- launchScript += "traits legacyLaunch\n";
- launchScript += "launcher onesix\n";
- return launchScript;
-}
-
-std::shared_ptr<LaunchStep> LegacyInstance::createMainLaunchStep(LaunchTask * parent, AuthSessionPtr session)
-{
- auto step = std::make_shared<LauncherPartLaunch>(parent);
- step->setWorkingDirectory(minecraftRoot());
- step->setAuthSession(session);
- return step;
-}
-
-QString LegacyInstance::launchMethod()
-{
- return "Legacy";
-}
-
-QStringList LegacyInstance::validLaunchMethods()
-{
- return {"Legacy"};
-}
-
-std::shared_ptr<ModList> LegacyInstance::coreModList() const
-{
- if (!core_mod_list)
- {
- core_mod_list.reset(new ModList(coreModsDir()));
- }
- core_mod_list->update();
- return core_mod_list;
-}
-
-std::shared_ptr<LegacyModList> LegacyInstance::jarModList() const
-{
- if (!jar_mod_list)
- {
- auto list = new LegacyModList(jarModsDir(), modListFile());
- connect(list, SIGNAL(changed()), SLOT(jarModsChanged()));
- jar_mod_list.reset(list);
- }
- jar_mod_list->update();
- return jar_mod_list;
-}
-
-QList<Mod> LegacyInstance::getJarMods() const
-{
- return jarModList()->allMods();
-}
-
-void LegacyInstance::jarModsChanged()
-{
- qDebug() << "Jar mods of instance " << name() << " have changed. Jar will be rebuilt.";
- setShouldRebuild(true);
-}
-
-std::shared_ptr<ModList> LegacyInstance::loaderModList() const
-{
- if (!loader_mod_list)
- {
- loader_mod_list.reset(new ModList(loaderModsDir()));
- }
- loader_mod_list->update();
- return loader_mod_list;
-}
-
-std::shared_ptr<ModList> LegacyInstance::texturePackList() const
-{
- if (!texture_pack_list)
- {
- texture_pack_list.reset(new ModList(texturePacksDir()));
- }
- texture_pack_list->update();
- return texture_pack_list;
-}
-
-std::shared_ptr<WorldList> LegacyInstance::worldList() const
-{
- if (!m_world_list)
- {
- m_world_list.reset(new WorldList(savesDir()));
- }
- return m_world_list;
-}
-
-QString LegacyInstance::jarModsDir() const
-{
- return FS::PathCombine(instanceRoot(), "instMods");
-}
-
-QString LegacyInstance::libDir() const
-{
- return FS::PathCombine(minecraftRoot(), "lib");
-}
-
-QString LegacyInstance::savesDir() const
-{
- return FS::PathCombine(minecraftRoot(), "saves");
-}
-
-QString LegacyInstance::loaderModsDir() const
-{
- return FS::PathCombine(minecraftRoot(), "mods");
-}
-
-QString LegacyInstance::coreModsDir() const
-{
- return FS::PathCombine(minecraftRoot(), "coremods");
-}
-
-QString LegacyInstance::resourceDir() const
-{
- return FS::PathCombine(minecraftRoot(), "resources");
-}
-QString LegacyInstance::texturePacksDir() const
-{
- return FS::PathCombine(minecraftRoot(), "texturepacks");
-}
-
-QString LegacyInstance::runnableJar() const
-{
- return FS::PathCombine(binRoot(), "minecraft.jar");
-}
-
-QString LegacyInstance::modListFile() const
-{
- return FS::PathCombine(instanceRoot(), "modlist");
-}
-
-QString LegacyInstance::instanceConfigFolder() const
-{
- return FS::PathCombine(minecraftRoot(), "config");
-}
-
-bool LegacyInstance::shouldRebuild() const
-{
- return m_settings->get("NeedsRebuild").toBool();
-}
-
-void LegacyInstance::setShouldRebuild(bool val)
-{
- m_settings->set("NeedsRebuild", val);
-}
-
-QString LegacyInstance::currentVersionId() const
-{
- return m_settings->get("JarVersion").toString();
-}
-
-QString LegacyInstance::lwjglVersion() const
-{
- return m_settings->get("LwjglVersion").toString();
-}
-
-void LegacyInstance::setLWJGLVersion(QString val)
-{
- m_settings->set("LwjglVersion", val);
-}
-
-QString LegacyInstance::intendedVersionId() const
-{
- return m_settings->get("IntendedJarVersion").toString();
-}
-
-bool LegacyInstance::setIntendedVersionId(QString version)
-{
- settings()->set("IntendedJarVersion", version);
- setShouldUpdate(true);
- return true;
-}
-
-bool LegacyInstance::shouldUpdate() const
-{
- QVariant var = settings()->get("ShouldUpdate");
- if (!var.isValid() || var.toBool() == false)
- {
- return intendedVersionId() != currentVersionId();
- }
- return true;
-}
-
-void LegacyInstance::setShouldUpdate(bool val)
-{
- settings()->set("ShouldUpdate", val);
-}
-
-QString LegacyInstance::defaultBaseJar() const
-{
- return "versions/" + intendedVersionId() + "/" + intendedVersionId() + ".jar";
-}
-
-QString LegacyInstance::defaultCustomBaseJar() const
-{
- return FS::PathCombine(binRoot(), "mcbackup.jar");
-}
-
-QString LegacyInstance::lwjglFolder() const
-{
- return m_lwjglFolderSetting->get().toString();
-}
-
-QString LegacyInstance::typeName() const
-{
- return tr("Legacy");
-}
-
-QStringList LegacyInstance::verboseDescription(AuthSessionPtr session)
-{
- QStringList out;
-
- auto alltraits = traits();
- if(alltraits.size())
- {
- out << "Traits:";
- for (auto trait : alltraits)
- {
- out << " " + trait;
- }
- out << "";
- }
-
- if(loaderModList()->size())
- {
- out << "Mods:";
- for(auto & mod: loaderModList()->allMods())
- {
- if(!mod.enabled())
- continue;
- if(mod.type() == Mod::MOD_FOLDER)
- continue;
- // TODO: proper implementation would need to descend into folders.
-
- out << " " + mod.filename().completeBaseName();
- }
- out << "";
- }
-
- if(coreModList()->size())
- {
- out << "Core Mods:";
- for(auto & coremod: coreModList()->allMods())
- {
- if(!coremod.enabled())
- continue;
- if(coremod.type() == Mod::MOD_FOLDER)
- continue;
- // TODO: proper implementation would need to descend into folders.
-
- out << " " + coremod.filename().completeBaseName();
- }
- out << "";
- }
-
- if(jarModList()->size())
- {
- out << "Jar Mods:";
- for(auto & jarmod: jarModList()->allMods())
- {
- out << " " + jarmod.name() + " (" + jarmod.filename().filePath() + ")";
- }
- out << "";
- }
-
- QString windowParams;
- if (settings()->get("LaunchMaximized").toBool())
- {
- out << "Window size: max (if available)";
- }
- else
- {
- auto width = settings()->get("MinecraftWinWidth").toInt();
- auto height = settings()->get("MinecraftWinHeight").toInt();
- out << "Window size: " + QString::number(width) + " x " + QString::number(height);
- }
- out << "";
- return out;
-}
-
-QStringList LegacyInstance::getClassPath() const
-{
- QString launchScript;
- QString lwjgl = getNativePath();
- QStringList out =
- {
- "bin/minecraft.jar",
- lwjgl + "/lwjgl.jar",
- lwjgl + "/lwjgl_util.jar",
- lwjgl + "/jinput.jar"
- };
- return out;
-}
-
-QString LegacyInstance::getMainClass() const
-{
- return "net.minecraft.client.Minecraft";
-}
-
-QString LegacyInstance::getNativePath() const
-{
- return QDir(m_lwjglFolderSetting->get().toString() + "/" + lwjglVersion()).absolutePath();
-}
-
-QStringList LegacyInstance::getNativeJars() const
-{
- return {};
-}
-
-QStringList LegacyInstance::processMinecraftArgs(AuthSessionPtr account) const
-{
- QStringList out;
- out.append(account->player_name);
- out.append(account->session);
- return out;
-}
-
-#include "LegacyInstance.moc"
diff --git a/api/logic/minecraft/legacy/LegacyInstance.h b/api/logic/minecraft/legacy/LegacyInstance.h
deleted file mode 100644
index 15d1383f..00000000
--- a/api/logic/minecraft/legacy/LegacyInstance.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/* Copyright 2013-2017 MultiMC Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include "minecraft/MinecraftInstance.h"
-
-#include "multimc_logic_export.h"
-
-class ModList;
-class LegacyModList;
-class Task;
-
-class MULTIMC_LOGIC_EXPORT LegacyInstance : public MinecraftInstance
-{
- Q_OBJECT
-public:
-
- explicit LegacyInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir);
-
- virtual void init() override {};
-
- /// Path to the instance's minecraft.jar
- QString runnableJar() const;
-
- //! Path to the instance's modlist file.
- QString modListFile() const;
-
- /*
- ////// Edit Instance Dialog stuff //////
- virtual QList<BasePage *> getPages();
- virtual QString dialogTitle();
- */
-
- ////// Mod Lists //////
- std::shared_ptr<LegacyModList> jarModList() const ;
- virtual QList< Mod > getJarMods() const override;
- std::shared_ptr<ModList> coreModList() const;
- std::shared_ptr<ModList> loaderModList() const;
- std::shared_ptr<ModList> texturePackList() const override;
- std::shared_ptr<WorldList> worldList() const override;
-
- ////// Directories //////
- QString libDir() const;
- QString savesDir() const;
- QString texturePacksDir() const;
- QString jarModsDir() const;
- QString loaderModsDir() const;
- QString coreModsDir() const;
- QString resourceDir() const;
- virtual QString instanceConfigFolder() const override;
-
- /// Get the curent base jar of this instance. By default, it's the
- /// versions/$version/$version.jar
- QString baseJar() const;
-
- /// the default base jar of this instance
- QString defaultBaseJar() const;
- /// the default custom base jar of this instance
- QString defaultCustomBaseJar() const;
-
- /*!
- * Whether or not custom base jar is used
- */
- bool shouldUseCustomBaseJar() const;
- void setShouldUseCustomBaseJar(bool val);
-
- /*!
- * The value of the custom base jar
- */
- QString customBaseJar() const;
- void setCustomBaseJar(QString val);
-
- /*!
- * Whether or not the instance's minecraft.jar needs to be rebuilt.
- * If this is true, when the instance launches, its jar mods will be
- * re-added to a fresh minecraft.jar file.
- */
- bool shouldRebuild() const;
- void setShouldRebuild(bool val);
-
- virtual QString currentVersionId() const override;
-
- //! The version of LWJGL that this instance uses.
- QString lwjglVersion() const;
-
- //! Where the lwjgl versions foor this instance can be found... HACK HACK HACK
- QString lwjglFolder() const;
-
- /// st the version of LWJGL libs this instance will use
- void setLWJGLVersion(QString val);
-
- virtual QString intendedVersionId() const override;
- virtual bool setIntendedVersionId(QString version) override;
-
- virtual QSet<QString> traits() override
- {
- return {"legacy-instance", "texturepacks"};
- };
-
- virtual bool shouldUpdate() const override;
- virtual void setShouldUpdate(bool val) override;
- virtual shared_qobject_ptr<Task> createUpdateTask() override;
- virtual std::shared_ptr<Task> createJarModdingTask() override;
- virtual QString createLaunchScript(AuthSessionPtr session) override;
-
- virtual QString typeName() const override;
-
- bool canExport() const override
- {
- return true;
- }
-
- QStringList getClassPath() const override;
- QString getMainClass() const override;
-
- QStringList getNativeJars() const override;
- QString getNativePath() const override;
-
- QString getLocalLibraryPath() const override
- {
- return QString();
- }
-
- QStringList processMinecraftArgs(AuthSessionPtr account) const override;
- QStringList verboseDescription(AuthSessionPtr session) override;
-
-protected:
- std::shared_ptr<LaunchStep> createMainLaunchStep(LaunchTask *parent, AuthSessionPtr session) override;
- QStringList validLaunchMethods() override;
- QString launchMethod() override;
-
-protected:
- mutable std::shared_ptr<LegacyModList> jar_mod_list;
- mutable std::shared_ptr<ModList> core_mod_list;
- mutable std::shared_ptr<ModList> loader_mod_list;
- mutable std::shared_ptr<ModList> texture_pack_list;
- mutable std::shared_ptr<WorldList> m_world_list;
- std::shared_ptr<Setting> m_lwjglFolderSetting;
-protected
-slots:
- virtual void jarModsChanged();
-};
diff --git a/api/logic/minecraft/legacy/LegacyModList.cpp b/api/logic/minecraft/legacy/LegacyModList.cpp
deleted file mode 100644
index 052f75fd..00000000
--- a/api/logic/minecraft/legacy/LegacyModList.cpp
+++ /dev/null
@@ -1,616 +0,0 @@
-/* Copyright 2013-2017 MultiMC Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "LegacyModList.h"
-#include <FileSystem.h>
-#include <QMimeData>
-#include <QUrl>
-#include <QUuid>
-#include <QString>
-#include <QFileSystemWatcher>
-#include <QDebug>
-
-LegacyModList::LegacyModList(const QString &dir, const QString &list_file)
- : QAbstractListModel(), m_dir(dir), m_list_file(list_file)
-{
- FS::ensureFolderPathExists(m_dir.absolutePath());
- m_dir.setFilter(QDir::Readable | QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs |
- QDir::NoSymLinks);
- m_dir.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware);
- m_list_id = QUuid::createUuid().toString();
- m_watcher = new QFileSystemWatcher(this);
- is_watching = false;
- connect(m_watcher, SIGNAL(directoryChanged(QString)), this,
- SLOT(directoryChanged(QString)));
-}
-
-void LegacyModList::startWatching()
-{
- update();
- is_watching = m_watcher->addPath(m_dir.absolutePath());
- if (is_watching)
- {
- qDebug() << "Started watching " << m_dir.absolutePath();
- }
- else
- {
- qDebug() << "Failed to start watching " << m_dir.absolutePath();
- }
-}
-
-void LegacyModList::stopWatching()
-{
- is_watching = !m_watcher->removePath(m_dir.absolutePath());
- if (!is_watching)
- {
- qDebug() << "Stopped watching " << m_dir.absolutePath();
- }
- else
- {
- qDebug() << "Failed to stop watching " << m_dir.absolutePath();
- }
-}
-
-void LegacyModList::internalSort(QList<Mod> &what)
-{
- auto predicate = [](const Mod &left, const Mod &right)
- {
- if (left.name() == right.name())
- {
- return left.mmc_id().localeAwareCompare(right.mmc_id()) < 0;
- }
- return left.name().localeAwareCompare(right.name()) < 0;
- };
- std::sort(what.begin(), what.end(), predicate);
-}
-
-bool LegacyModList::update()
-{
- if (!isValid())
- return false;
-
- QList<Mod> orderedMods;
- QList<Mod> newMods;
- m_dir.refresh();
- auto folderContents = m_dir.entryInfoList();
- bool orderOrStateChanged = false;
-
- // first, process the ordered items (if any)
- OrderList listOrder = readListFile();
- for (auto item : listOrder)
- {
- QFileInfo infoEnabled(m_dir.filePath(item.id));
- QFileInfo infoDisabled(m_dir.filePath(item.id + ".disabled"));
- int idxEnabled = folderContents.indexOf(infoEnabled);
- int idxDisabled = folderContents.indexOf(infoDisabled);
- bool isEnabled;
- // if both enabled and disabled versions are present, it's a special case...
- if (idxEnabled >= 0 && idxDisabled >= 0)
- {
- // we only process the one we actually have in the order file.
- // and exactly as we have it.
- // THIS IS A CORNER CASE
- isEnabled = item.enabled;
- }
- else
- {
- // only one is present.
- // we pick the one that we found.
- // we assume the mod was enabled/disabled by external means
- isEnabled = idxEnabled >= 0;
- }
- int idx = isEnabled ? idxEnabled : idxDisabled;
- QFileInfo &info = isEnabled ? infoEnabled : infoDisabled;
- // if the file from the index file exists
- if (idx != -1)
- {
- // remove from the actual folder contents list
- folderContents.takeAt(idx);
- // append the new mod
- orderedMods.append(Mod(info));
- if (isEnabled != item.enabled)
- orderOrStateChanged = true;
- }
- else
- {
- orderOrStateChanged = true;
- }
- }
- // if there are any untracked files...
- if (folderContents.size())
- {
- // the order surely changed!
- for (auto entry : folderContents)
- {
- newMods.append(Mod(entry));
- }
- internalSort(newMods);
- orderedMods.append(newMods);
- orderOrStateChanged = true;
- }
- // otherwise, if we were already tracking some mods
- else if (mods.size())
- {
- // if the number doesn't match, order changed.
- if (mods.size() != orderedMods.size())
- orderOrStateChanged = true;
- // if it does match, compare the mods themselves
- else
- for (int i = 0; i < mods.size(); i++)
- {
- if (!mods[i].strongCompare(orderedMods[i]))
- {
- orderOrStateChanged = true;
- break;
- }
- }
- }
- beginResetModel();
- mods.swap(orderedMods);
- endResetModel();
- if (orderOrStateChanged && !m_list_file.isEmpty())
- {
- qDebug() << "Mod list " << m_list_file << " changed!";
- saveListFile();
- emit changed();
- }
- return true;
-}
-
-void LegacyModList::directoryChanged(QString path)
-{
- update();
-}
-
-LegacyModList::OrderList LegacyModList::readListFile()
-{
- OrderList itemList;
- if (m_list_file.isNull() || m_list_file.isEmpty())
- return itemList;
-
- QFile textFile(m_list_file);
- if (!textFile.open(QIODevice: