summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-11-04 22:55:25 +0100
committerPetr Mrázek <peterix@gmail.com>2017-11-17 15:44:13 +0100
commit17c8f31a09da6bdfc4aa7f67b2ca86b791f2ba96 (patch)
tree47330451b2a147ee54b2e63c5a1e614e4f88268b
parent3470158943acb9fc4439ea255fe3ea0fbc7dbc85 (diff)
downloadMultiMC-17c8f31a09da6bdfc4aa7f67b2ca86b791f2ba96.tar
MultiMC-17c8f31a09da6bdfc4aa7f67b2ca86b791f2ba96.tar.gz
MultiMC-17c8f31a09da6bdfc4aa7f67b2ca86b791f2ba96.tar.lz
MultiMC-17c8f31a09da6bdfc4aa7f67b2ca86b791f2ba96.tar.xz
MultiMC-17c8f31a09da6bdfc4aa7f67b2ca86b791f2ba96.zip
NOISSUE split out the LaunchProfile out of the ComponentList
-rw-r--r--api/logic/CMakeLists.txt2
-rw-r--r--api/logic/ProblemProvider.h9
-rw-r--r--api/logic/minecraft/ComponentList.cpp303
-rw-r--r--api/logic/minecraft/ComponentList.h88
-rw-r--r--api/logic/minecraft/LaunchProfile.cpp297
-rw-r--r--api/logic/minecraft/LaunchProfile.h99
-rw-r--r--api/logic/minecraft/MinecraftInstance.cpp64
-rw-r--r--api/logic/minecraft/MinecraftInstance.h10
-rw-r--r--api/logic/minecraft/ProfilePatch.cpp10
-rw-r--r--api/logic/minecraft/ProfilePatch.h11
-rw-r--r--api/logic/minecraft/VersionFile.cpp2
-rw-r--r--api/logic/minecraft/VersionFile.h3
-rw-r--r--api/logic/minecraft/launch/ModMinecraftJar.cpp3
-rw-r--r--api/logic/minecraft/update/AssetUpdateTask.cpp6
-rw-r--r--api/logic/minecraft/update/FMLLibrariesTask.cpp5
-rw-r--r--api/logic/minecraft/update/LibrariesTask.cpp3
16 files changed, 493 insertions, 422 deletions
diff --git a/api/logic/CMakeLists.txt b/api/logic/CMakeLists.txt
index e5047d38..42bea98c 100644
--- a/api/logic/CMakeLists.txt
+++ b/api/logic/CMakeLists.txt
@@ -237,6 +237,8 @@ set(MINECRAFT_SOURCES
minecraft/GradleSpecifier.h
minecraft/MinecraftInstance.cpp
minecraft/MinecraftInstance.h
+ minecraft/LaunchProfile.cpp
+ minecraft/LaunchProfile.h
minecraft/ComponentList.cpp
minecraft/ComponentList.h
minecraft/MinecraftUpdate.h
diff --git a/api/logic/ProblemProvider.h b/api/logic/ProblemProvider.h
index 7dedccd7..4040f4fa 100644
--- a/api/logic/ProblemProvider.h
+++ b/api/logic/ProblemProvider.h
@@ -16,18 +16,19 @@ struct PatchProblem
class ProblemProvider
{
public:
- virtual const QList<PatchProblem> getProblems() = 0;
- virtual ProblemSeverity getProblemSeverity() = 0;
+ virtual ~ProblemProvider() {};
+ virtual const QList<PatchProblem> getProblems() const = 0;
+ virtual ProblemSeverity getProblemSeverity() const = 0;
};
class ProblemContainer : public ProblemProvider
{
public:
- const QList<PatchProblem> getProblems() override
+ const QList<PatchProblem> getProblems() const override
{
return m_problems;
}
- ProblemSeverity getProblemSeverity() override
+ ProblemSeverity getProblemSeverity() const override
{
return m_problemSeverity;
}
diff --git a/api/logic/minecraft/ComponentList.cpp b/api/logic/minecraft/ComponentList.cpp
index 8ce1fded..34d3bc14 100644
--- a/api/logic/minecraft/ComponentList.cpp
+++ b/api/logic/minecraft/ComponentList.cpp
@@ -35,7 +35,6 @@ ComponentList::ComponentList(MinecraftInstance * instance)
: QAbstractListModel()
{
m_instance = instance;
- clear();
}
ComponentList::~ComponentList()
@@ -50,22 +49,6 @@ void ComponentList::reload()
endResetModel();
}
-void ComponentList::clear()
-{
- m_minecraftVersion.clear();
- m_minecraftVersionType.clear();
- m_minecraftAssets.reset();
- m_minecraftArguments.clear();
- m_tweakers.clear();
- m_mainClass.clear();
- m_appletClass.clear();
- m_libraries.clear();
- m_traits.clear();
- m_jarMods.clear();
- m_mainJar.reset();
- m_problemSeverity = ProblemSeverity::None;
-}
-
void ComponentList::clearPatches()
{
beginResetModel();
@@ -365,290 +348,22 @@ bool ComponentList::reapplyPatches()
{
try
{
- clear();
+ m_profile.reset(new LaunchProfile);
for(auto file: m_patches)
{
qDebug() << "Applying" << file->getID() << (file->getProblemSeverity() == ProblemSeverity::Error ? "ERROR" : "GOOD");
- file->applyTo(this);
+ file->applyTo(m_profile.get());
}
}
catch (Exception & error)
{
- clear();
+ m_profile.reset();
qWarning() << "Couldn't apply profile patches because: " << error.cause();
return false;
}
return true;
}
-static void applyString(const QString & from, QString & to)
-{
- if(from.isEmpty())
- return;
- to = from;
-}
-
-void ComponentList::applyMinecraftVersion(const QString& id)
-{
- applyString(id, this->m_minecraftVersion);
-}
-
-void ComponentList::applyAppletClass(const QString& appletClass)
-{
- applyString(appletClass, this->m_appletClass);
-}
-
-void ComponentList::applyMainClass(const QString& mainClass)
-{
- applyString(mainClass, this->m_mainClass);
-}
-
-void ComponentList::applyMinecraftArguments(const QString& minecraftArguments)
-{
- applyString(minecraftArguments, this->m_minecraftArguments);
-}
-
-void ComponentList::applyMinecraftVersionType(const QString& type)
-{
- applyString(type, this->m_minecraftVersionType);
-}
-
-void ComponentList::applyMinecraftAssets(MojangAssetIndexInfo::Ptr assets)
-{
- if(assets)
- {
- m_minecraftAssets = assets;
- }
-}
-
-void ComponentList::applyTraits(const QSet<QString>& traits)
-{
- this->m_traits.unite(traits);
-}
-
-void ComponentList::applyTweakers(const QStringList& tweakers)
-{
- // if the applied tweakers override an existing one, skip it. this effectively moves it later in the sequence
- QStringList newTweakers;
- for(auto & tweaker: m_tweakers)
- {
- if (tweakers.contains(tweaker))
- {
- continue;
- }
- newTweakers.append(tweaker);
- }
- // then just append the new tweakers (or moved original ones)
- newTweakers += tweakers;
- m_tweakers = newTweakers;
-}
-
-void ComponentList::applyJarMods(const QList<LibraryPtr>& jarMods)
-{
- this->m_jarMods.append(jarMods);
-}
-
-static int findLibraryByName(QList<LibraryPtr> *haystack, const GradleSpecifier &needle)
-{
- int retval = -1;
- for (int i = 0; i < haystack->size(); ++i)
- {
- if (haystack->at(i)->rawName().matchName(needle))
- {
- // only one is allowed.
- if (retval != -1)
- return -1;
- retval = i;
- }
- }
- return retval;
-}
-
-void ComponentList::applyMods(const QList<LibraryPtr>& mods)
-{
- QList<LibraryPtr> * list = &m_mods;
- for(auto & mod: mods)
- {
- auto modCopy = Library::limitedCopy(mod);
-
- // find the mod by name.
- const int index = findLibraryByName(list, mod->rawName());
- // mod not found? just add it.
- if (index < 0)
- {
- list->append(modCopy);
- return;
- }
-
- auto existingLibrary = list->at(index);
- // if we are higher it means we should update
- if (Version(mod->version()) > Version(existingLibrary->version()))
- {
- list->replace(index, modCopy);
- }
- }
-}
-
-void ComponentList::applyLibrary(LibraryPtr library)
-{
- if(!library->isActive())
- {
- return;
- }
-
- QList<LibraryPtr> * list = &m_libraries;
- if(library->isNative())
- {
- list = &m_nativeLibraries;
- }
-
- auto libraryCopy = Library::limitedCopy(library);
-
- // find the library by name.
- const int index = findLibraryByName(list, library->rawName());
- // library not found? just add it.
- if (index < 0)
- {
- list->append(libraryCopy);
- return;
- }
-
- auto existingLibrary = list->at(index);
- // if we are higher it means we should update
- if (Version(library->version()) > Version(existingLibrary->version()))
- {
- list->replace(index, libraryCopy);
- }
-}
-
-const LibraryPtr ComponentList::getMainJar() const
-{
- return m_mainJar;
-}
-
-void ComponentList::applyMainJar(LibraryPtr jar)
-{
- if(jar)
- {
- m_mainJar = jar;
- }
-}
-
-void ComponentList::applyProblemSeverity(ProblemSeverity severity)
-{
- if (m_problemSeverity < severity)
- {
- m_problemSeverity = severity;
- }
-}
-
-
-QString ComponentList::getMinecraftVersion() const
-{
- return m_minecraftVersion;
-}
-
-QString ComponentList::getAppletClass() const
-{
- return m_appletClass;
-}
-
-QString ComponentList::getMainClass() const
-{
- return m_mainClass;
-}
-
-const QSet<QString> &ComponentList::getTraits() const
-{
- return m_traits;
-}
-
-const QStringList & ComponentList::getTweakers() const
-{
- return m_tweakers;
-}
-
-bool ComponentList::hasTrait(const QString& trait) const
-{
- return m_traits.contains(trait);
-}
-
-ProblemSeverity ComponentList::getProblemSeverity() const
-{
- return m_problemSeverity;
-}
-
-QString ComponentList::getMinecraftVersionType() const
-{
- return m_minecraftVersionType;
-}
-
-std::shared_ptr<MojangAssetIndexInfo> ComponentList::getMinecraftAssets() const
-{
- if(!m_minecraftAssets)
- {
- return std::make_shared<MojangAssetIndexInfo>("legacy");
- }
- return m_minecraftAssets;
-}
-
-QString ComponentList::getMinecraftArguments() const
-{
- return m_minecraftArguments;
-}
-
-const QList<LibraryPtr> & ComponentList::getJarMods() const
-{
- return m_jarMods;
-}
-
-const QList<LibraryPtr> & ComponentList::getLibraries() const
-{
- return m_libraries;
-}
-
-const QList<LibraryPtr> & ComponentList::getNativeLibraries() const
-{
- return m_nativeLibraries;
-}
-
-void ComponentList::getLibraryFiles(const QString& architecture, QStringList& jars, QStringList& nativeJars, const QString& overridePath, const QString& tempPath) const
-{
- QStringList native32, native64;
- jars.clear();
- nativeJars.clear();
- for (auto lib : getLibraries())
- {
- lib->getApplicableFiles(currentSystem, jars, nativeJars, native32, native64, overridePath);
- }
- // NOTE: order is important here, add main jar last to the lists
- if(m_mainJar)
- {
- // FIXME: HACK!! jar modding is weird and unsystematic!
- if(m_jarMods.size())
- {
- QDir tempDir(tempPath);
- jars.append(tempDir.absoluteFilePath("minecraft.jar"));
- }
- else
- {
- m_mainJar->getApplicableFiles(currentSystem, jars, nativeJars, native32, native64, overridePath);
- }
- }
- for (auto lib : getNativeLibraries())
- {
- lib->getApplicableFiles(currentSystem, jars, nativeJars, native32, native64, overridePath);
- }
- if(architecture == "32")
- {
- nativeJars.append(native32);
- }
- else if(architecture == "64")
- {
- nativeJars.append(native64);
- }
-}
-
void ComponentList::installJarMods(QStringList selectedFiles)
{
installJarMods_internal(selectedFiles);
@@ -1122,4 +837,14 @@ bool ComponentList::installCustomJar_internal(QString filepath)
saveCurrentOrder();
reapplyPatches();
return true;
-} \ No newline at end of file
+}
+
+std::shared_ptr<LaunchProfile> ComponentList::getProfile() const
+{
+ return m_profile;
+}
+
+void ComponentList::clearProfile()
+{
+ m_profile.reset();
+}
diff --git a/api/logic/minecraft/ComponentList.h b/api/logic/minecraft/ComponentList.h
index a566d8f5..0811a829 100644
--- a/api/logic/minecraft/ComponentList.h
+++ b/api/logic/minecraft/ComponentList.h
@@ -22,11 +22,11 @@
#include <memory>
#include "Library.h"
+#include "LaunchProfile.h"
#include "ProfilePatch.h"
#include "ProfileUtils.h"
#include "BaseVersion.h"
#include "MojangDownloadInfo.h"
-
#include "multimc_logic_export.h"
class MinecraftInstance;
@@ -80,45 +80,11 @@ public:
/// reload all profile patches from storage, clear the profile and apply the patches
void reload();
- /// clear the profile
- void clear();
-
/// apply the patches. Catches all the errors and returns true/false for success/failure
bool reapplyPatches();
-public: /* application of profile variables from patches */
- void applyMinecraftVersion(const QString& id);
- void applyMainClass(const QString& mainClass);
- void applyAppletClass(const QString& appletClass);
- void applyMinecraftArguments(const QString& minecraftArguments);
- void applyMinecraftVersionType(const QString& type);
- void applyMinecraftAssets(MojangAssetIndexInfo::Ptr assets);
- void applyTraits(const QSet<QString> &traits);
- void applyTweakers(const QStringList &tweakers);
- void applyJarMods(const QList<LibraryPtr> &jarMods);
- void applyMods(const QList<LibraryPtr> &jarMods);
- void applyLibrary(LibraryPtr library);
- void applyMainJar(LibraryPtr jar);
- void applyProblemSeverity(ProblemSeverity severity);
-
-public: /* getters for profile variables */
- QString getMinecraftVersion() const;
- QString getMainClass() const;
- QString getAppletClass() const;
- QString getMinecraftVersionType() const;
- MojangAssetIndexInfo::Ptr getMinecraftAssets() const;
- QString getMinecraftArguments() const;
- const QSet<QString> & getTraits() const;
- const QStringList & getTweakers() const;
- const QList<LibraryPtr> & getJarMods() const;
- const QList<LibraryPtr> & getLibraries() const;
- const QList<LibraryPtr> & getNativeLibraries() const;
- const LibraryPtr getMainJar() const;
- void getLibraryFiles(const QString & architecture, QStringList & jars, QStringList & nativeJars, const QString & overridePath,
- const QString & tempPath) const;
- bool hasTrait(const QString & trait) const;
- ProblemSeverity getProblemSeverity() const;
-
+ std::shared_ptr<LaunchProfile> getProfile() const;
+ void clearProfile();
public:
/// get the profile patch by id
ProfilePatchPtr versionPatch(const QString &id);
@@ -149,55 +115,11 @@ private:
void upgradeDeprecatedFiles_internal();
private: /* data */
- /// the version of Minecraft - jar to use
- QString m_minecraftVersion;
-
- /// Release type - "release" or "snapshot"
- QString m_minecraftVersionType;
-
- /// Assets type - "legacy" or a version ID
- MojangAssetIndexInfo::Ptr m_minecraftAssets;
-
- /**
- * arguments that should be used for launching minecraft
- *
- * ex: "--username ${auth_player_name} --session ${auth_session}
- * --version ${version_name} --gameDir ${game_directory} --assetsDir ${game_assets}"
- */
- QString m_minecraftArguments;
-
- /// A list of all tweaker classes
- QStringList m_tweakers;
-
- /// The main class to load first
- QString m_mainClass;
-
- /// The applet class, for some very old minecraft releases
- QString m_appletClass;
-
- /// the list of libraries
- QList<LibraryPtr> m_libraries;
-
- /// the main jar
- LibraryPtr m_mainJar;
-
- /// the list of libraries
- QList<LibraryPtr> m_nativeLibraries;
-
- /// traits, collected from all the version files (version files can only add)
- QSet<QString> m_traits;
-
- /// A list of jar mods. version files can add those.
- QList<LibraryPtr> m_jarMods;
-
- /// the list of mods
- QList<LibraryPtr> m_mods;
-
- ProblemSeverity m_problemSeverity = ProblemSeverity::None;
-
/// list of attached profile patches
QList<ProfilePatchPtr> m_patches;
// the instance this belongs to
MinecraftInstance *m_instance;
+
+ std::shared_ptr<LaunchProfile> m_profile;
};
diff --git a/api/logic/minecraft/LaunchProfile.cpp b/api/logic/minecraft/LaunchProfile.cpp
new file mode 100644
index 00000000..436a39d9
--- /dev/null
+++ b/api/logic/minecraft/LaunchProfile.cpp
@@ -0,0 +1,297 @@
+#include "LaunchProfile.h"
+#include <Version.h>
+
+void LaunchProfile::clear()
+{
+ m_minecraftVersion.clear();
+ m_minecraftVersionType.clear();
+ m_minecraftAssets.reset();
+ m_minecraftArguments.clear();
+ m_tweakers.clear();
+ m_mainClass.clear();
+ m_appletClass.clear();
+ m_libraries.clear();
+ m_traits.clear();
+ m_jarMods.clear();
+ m_mainJar.reset();
+ m_problemSeverity = ProblemSeverity::None;
+}
+
+static void applyString(const QString & from, QString & to)
+{
+ if(from.isEmpty())
+ return;
+ to = from;
+}
+
+void LaunchProfile::applyMinecraftVersion(const QString& id)
+{
+ applyString(id, this->m_minecraftVersion);
+}
+
+void LaunchProfile::applyAppletClass(const QString& appletClass)
+{
+ applyString(appletClass, this->m_appletClass);
+}
+
+void LaunchProfile::applyMainClass(const QString& mainClass)
+{
+ applyString(mainClass, this->m_mainClass);
+}
+
+void LaunchProfile::applyMinecraftArguments(const QString& minecraftArguments)
+{
+ applyString(minecraftArguments, this->m_minecraftArguments);
+}
+
+void LaunchProfile::applyMinecraftVersionType(const QString& type)
+{
+ applyString(type, this->m_minecraftVersionType);
+}
+
+void LaunchProfile::applyMinecraftAssets(MojangAssetIndexInfo::Ptr assets)
+{
+ if(assets)
+ {
+ m_minecraftAssets = assets;
+ }
+}
+
+void LaunchProfile::applyTraits(const QSet<QString>& traits)
+{
+ this->m_traits.unite(traits);
+}
+
+void LaunchProfile::applyTweakers(const QStringList& tweakers)
+{
+ // if the applied tweakers override an existing one, skip it. this effectively moves it later in the sequence
+ QStringList newTweakers;
+ for(auto & tweaker: m_tweakers)
+ {
+ if (tweakers.contains(tweaker))
+ {
+ continue;
+ }
+ newTweakers.append(tweaker);
+ }
+ // then just append the new tweakers (or moved original ones)
+ newTweakers += tweakers;
+ m_tweakers = newTweakers;
+}
+
+void LaunchProfile::applyJarMods(const QList<LibraryPtr>& jarMods)
+{
+ this->m_jarMods.append(jarMods);
+}
+
+static int findLibraryByName(QList<LibraryPtr> *haystack, const GradleSpecifier &needle)
+{
+ int retval = -1;
+ for (int i = 0; i < haystack->size(); ++i)
+ {
+ if (haystack->at(i)->rawName().matchName(needle))
+ {
+ // only one is allowed.
+ if (retval != -1)
+ return -1;
+ retval = i;
+ }
+ }
+ return retval;
+}
+
+void LaunchProfile::applyMods(const QList<LibraryPtr>& mods)
+{
+ QList<LibraryPtr> * list = &m_mods;
+ for(auto & mod: mods)
+ {
+ auto modCopy = Library::limitedCopy(mod);
+
+ // find the mod by name.
+ const int index = findLibraryByName(list, mod->rawName());
+ // mod not found? just add it.
+ if (index < 0)
+ {
+ list->append(modCopy);
+ return;
+ }
+
+ auto existingLibrary = list->at(index);
+ // if we are higher it means we should update
+ if (Version(mod->version()) > Version(existingLibrary->version()))
+ {
+ list->replace(index, modCopy);
+ }
+ }
+}
+
+void LaunchProfile::applyLibrary(LibraryPtr library)
+{
+ if(!library->isActive())
+ {
+ return;
+ }
+
+ QList<LibraryPtr> * list = &m_libraries;
+ if(library->isNative())
+ {
+ list = &m_nativeLibraries;
+ }
+
+ auto libraryCopy = Library::limitedCopy(library);
+
+ // find the library by name.
+ const int index = findLibraryByName(list, library->rawName());
+ // library not found? just add it.
+ if (index < 0)
+ {
+ list->append(libraryCopy);
+ return;
+ }
+
+ auto existingLibrary = list->at(index);
+ // if we are higher it means we should update
+ if (Version(library->version()) > Version(existingLibrary->version()))
+ {
+ list->replace(index, libraryCopy);
+ }
+}
+
+const LibraryPtr LaunchProfile::getMainJar() const
+{
+ return m_mainJar;
+}
+
+void LaunchProfile::applyMainJar(LibraryPtr jar)
+{
+ if(jar)
+ {
+ m_mainJar = jar;
+ }
+}
+
+void LaunchProfile::applyProblemSeverity(ProblemSeverity severity)
+{
+ if (m_problemSeverity < severity)
+ {
+ m_problemSeverity = severity;
+ }
+}
+
+const QList<PatchProblem> LaunchProfile::getProblems() const
+{
+ // FIXME: implement something that actually makes sense here
+ return {};
+}
+
+QString LaunchProfile::getMinecraftVersion() const
+{
+ return m_minecraftVersion;
+}
+
+QString LaunchProfile::getAppletClass() const
+{
+ return m_appletClass;
+}
+
+QString LaunchProfile::getMainClass() const
+{
+ return m_mainClass;
+}
+
+const QSet<QString> &LaunchProfile::getTraits() const
+{
+ return m_traits;
+}
+
+const QStringList & LaunchProfile::getTweakers() const
+{
+ return m_tweakers;
+}
+
+bool LaunchProfile::hasTrait(const QString& trait) const
+{
+ return m_traits.contains(trait);
+}
+
+ProblemSeverity LaunchProfile::getProblemSeverity() const
+{
+ return m_problemSeverity;
+}
+
+QString LaunchProfile::getMinecraftVersionType() const
+{
+ return m_minecraftVersionType;
+}
+
+std::shared_ptr<MojangAssetIndexInfo> LaunchProfile::getMinecraftAssets() const
+{
+ if(!m_minecraftAssets)
+ {
+ return std::make_shared<MojangAssetIndexInfo>("legacy");
+ }
+ return m_minecraftAssets;
+}
+
+QString LaunchProfile::getMinecraftArguments() const
+{
+ return m_minecraftArguments;
+}
+
+const QList<LibraryPtr> & LaunchProfile::getJarMods() const
+{
+ return m_jarMods;
+}
+
+const QList<LibraryPtr> & LaunchProfile::getLibraries() const
+{
+ return m_libraries;
+}
+
+const QList<LibraryPtr> & LaunchProfile::getNativeLibraries() const
+{
+ return m_nativeLibraries;
+}
+
+void LaunchProfile::getLibraryFiles(
+ const QString& architecture,
+ QStringList& jars,
+ QStringList& nativeJars,
+ const QString& overridePath,
+ const QString& tempPath
+) const
+{
+ QStringList native32, native64;
+ jars.clear();
+ nativeJars.clear();
+ for (auto lib : getLibraries())
+ {
+ lib->getApplicableFiles(currentSystem, jars, nativeJars, native32, native64, overridePath);
+ }
+ // NOTE: order is important here, add main jar last to the lists
+ if(m_mainJar)
+ {
+ // FIXME: HACK!! jar modding is weird and unsystematic!
+ if(m_jarMods.size())
+ {
+ QDir tempDir(tempPath);
+ jars.append(tempDir.absoluteFilePath("minecraft.jar"));
+ }
+ else
+ {
+ m_mainJar->getApplicableFiles(currentSystem, jars, nativeJars, native32, native64, overridePath);
+ }
+ }
+ for (auto lib : getNativeLibraries())
+ {
+ lib->getApplicableFiles(currentSystem, jars, nativeJars, native32, native64, overridePath);
+ }
+ if(architecture == "32")
+ {
+ nativeJars.append(native32);
+ }
+ else if(architecture == "64")
+ {
+ nativeJars.append(native64);
+ }
+}
diff --git a/api/logic/minecraft/LaunchProfile.h b/api/logic/minecraft/LaunchProfile.h
new file mode 100644
index 00000000..e7f5f4af
--- /dev/null
+++ b/api/logic/minecraft/LaunchProfile.h
@@ -0,0 +1,99 @@
+#pragma once
+#include <QString>
+#include "Library.h"
+#include <ProblemProvider.h>
+
+class LaunchProfile: public ProblemProvider
+{
+public:
+ virtual ~LaunchProfile() {};
+
+public: /* application of profile variables from patches */
+ void applyMinecraftVersion(const QString& id);
+ void applyMainClass(const QString& mainClass);
+ void applyAppletClass(const QString& appletClass);
+ void applyMinecraftArguments(const QString& minecraftArguments);
+ void applyMinecraftVersionType(const QString& type);
+ void applyMinecraftAssets(MojangAssetIndexInfo::Ptr assets);
+ void applyTraits(const QSet<QString> &traits);
+ void applyTweakers(const QStringList &tweakers);
+ void applyJarMods(const QList<LibraryPtr> &jarMods);
+ void applyMods(const QList<LibraryPtr> &jarMods);
+ void applyLibrary(LibraryPtr library);
+ void applyMainJar(LibraryPtr jar);
+ void applyProblemSeverity(ProblemSeverity severity);
+ /// clear the profile
+ void clear();
+
+public: /* getters for profile variables */
+ QString getMinecraftVersion() const;
+ QString getMainClass() const;
+ QString getAppletClass() const;
+ QString getMinecraftVersionType() const;
+ MojangAssetIndexInfo::Ptr getMinecraftAssets() const;
+ QString getMinecraftArguments() const;
+ const QSet<QString> & getTraits() const;
+ const QStringList & getTweakers() const;
+ const QList<LibraryPtr> & getJarMods() const;
+ const QList<LibraryPtr> & getLibraries() const;
+ const QList<LibraryPtr> & getNativeLibraries() const;
+ const LibraryPtr getMainJar() const;
+ void getLibraryFiles(
+ const QString & architecture,
+ QStringList & jars,
+ QStringList & nativeJars,
+ const QString & overridePath,
+ const QString & tempPath
+ ) const;
+ bool hasTrait(const QString & trait) const;
+ ProblemSeverity getProblemSeverity() const override;
+ const QList<PatchProblem> getProblems() const override;
+
+private:
+ /// the version of Minecraft - jar to use
+ QString m_minecraftVersion;
+
+ /// Release type - "release" or "snapshot"
+ QString m_minecraftVersionType;
+
+ /// Assets type - "legacy" or a version ID
+ MojangAssetIndexInfo::Ptr m_minecraftAssets;
+
+ /**
+ * arguments that should be used for launching minecraft
+ *
+ * ex: "--username ${auth_player_name} --session ${auth_session}
+ * --version ${version_name} --gameDir ${game_directory} --assetsDir ${game_assets}"
+ */
+ QString m_minecraftArguments;
+
+ /// A list of all tweaker classes
+ QStringList m_tweakers;
+
+ /// The main class to load first
+ QString m_mainClass;
+
+ /// The applet class, for some very old minecraft releases
+ QString m_appletClass;
+
+ /// the list of libraries
+ QList<LibraryPtr> m_libraries;
+
+ /// the main jar
+ LibraryPtr m_mainJar;
+
+ /// the list of libraries
+ QList<LibraryPtr> m_nativeLibraries;
+
+ /// traits, collected from all the version files (version files can only add)
+ QSet<QString> m_traits;
+
+ /// A list of jar mods. version files can add those.
+ QList<LibraryPtr> m_jarMods;
+
+ /// the list of mods
+ QList<LibraryPtr> m_mods;
+
+ ProblemSeverity m_problemSeverity = ProblemSeverity::None;
+
+};
diff --git a/api/logic/minecraft/MinecraftInstance.cpp b/api/logic/minecraft/MinecraftInstance.cpp
index e01d2616..76e70e5b 100644
--- a/api/logic/minecraft/MinecraftInstance.cpp
+++ b/api/logic/minecraft/MinecraftInstance.cpp
@@ -133,38 +133,39 @@ bool MinecraftInstance::reload()
void MinecraftInstance::createProfile()
{
- m_profile.reset(new ComponentList(this));
+ m_components.reset(new ComponentList(this));
}
void MinecraftInstance::reloadProfile()
{
- m_profile->reload();
- setVersionBroken(m_profile->getProblemSeverity() == ProblemSeverity::Error);
+ m_components->reload();
emit versionReloaded();
}
void MinecraftInstance::clearProfile()
{
- m_profile->clear();
+ m_components->clearProfile();
emit versionReloaded();
}
std::shared_ptr<ComponentList> MinecraftInstance::getComponentList() const
{
- return m_profile;
+ return m_components;
}
QSet<QString> MinecraftInstance::traits() const
{
- auto version = getComponentList();
- if (!version)
+ auto components = getComponentList();
+ if (!components)
{
return {"version-incomplete"};
}
- else
+ auto profile = components->getProfile();
+ if (!profile)
{
- return version->getTraits();
+ return {"version-incomplete"};
}
+ return profile->getTraits();
}
QString MinecraftInstance::minecraftRoot() const
@@ -254,20 +255,23 @@ QStringList MinecraftInstance::getClassPath() const
{
QStringList jars, nativeJars;
auto javaArchitecture = settings()->get("JavaArchitecture").toString();
- m_profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
+ auto profile = m_components->getProfile();
+ profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
return jars;
}
QString MinecraftInstance::getMainClass() const
{
- return m_profile->getMainClass();
+ auto profile = m_components->getProfile();
+ return profile->getMainClass();
}
QStringList MinecraftInstance::getNativeJars() const
{
QStringList jars, nativeJars;
auto javaArchitecture = settings()->get("JavaArchitecture").toString();
- m_profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
+ auto profile = m_components->getProfile();
+ profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
return nativeJars;
}
@@ -298,11 +302,11 @@ QStringList MinecraftInstance::javaArguments() const
args << "-Xdock:icon=icon.png";
args << QString("-Xdock:name=\"%1\"").arg(windowTitle());
#endif
- auto traits = m_profile->getTraits();
+ auto traits_ = traits();
// HACK: fix issues on macOS with 1.13 snapshots
// NOTE: Oracle Java option. if there are alternate jvm implementations, this would be the place to customize this for them
#ifdef Q_OS_MAC
- if(traits.contains("FirstThreadOnMacOS"))
+ if(traits_.contains("FirstThreadOnMacOS"))
{
args << QString("-XstartOnFirstThread");
}
@@ -395,8 +399,9 @@ static QString replaceTokensIn(QString text, QMap<QString, QString> with)
QStringList MinecraftInstance::processMinecraftArgs(AuthSessionPtr session) const
{
- QString args_pattern = m_profile->getMinecraftArguments();
- for (auto tweaker : m_profile->getTweakers())
+ auto profile = m_components->getProfile();
+ QString args_pattern = profile->getMinecraftArguments();
+ for (auto tweaker : profile->getTweakers())
{
args_pattern += " --tweakClass " + tweaker;
}
@@ -416,9 +421,9 @@ QStringList MinecraftInstance::processMinecraftArgs(AuthSessionPtr session) cons
// blatant self-promotion.
token_mapping["profile_name"] = token_mapping["version_name"] = "MultiMC5";
- if(m_profile->isVanilla())
+ if(m_components->isVanilla())
{
- token_mapping["version_type"] = m_profile->getMinecraftVersionType();
+ token_mapping["version_type"] = profile->getMinecraftVersionType();
}
else
{
@@ -428,7 +433,7 @@ QStringList MinecraftInstance::processMinecraftArgs(AuthSessionPtr session) cons
QString absRootDir = QDir(minecraftRoot()).absolutePath();
token_mapping["game_directory"] = absRootDir;
QString absAssetsDir = QDir("assets/").absolutePath();
- auto assets = m_profile->getMinecraftAssets();
+ auto assets = profile->getMinecraftAssets();
// FIXME: this is wrong and should be run as an async task
token_mapping["game_assets"] = AssetsUtils::reconstructAssets(assets->id).absolutePath();
@@ -448,15 +453,18 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session)
{
QString launchScript;
- if (!m_profile)
- return nullptr;
+ if (!m_components)
+ return QString();
+ auto profile = m_components->getProfile();
+ if(!profile)
+ return QString();
auto mainClass = getMainClass();
if (!mainClass.isEmpty())
{
launchScript += "mainClass " + mainClass + "\n";
}
- auto appletClass = m_profile->getAppletClass();
+ auto appletClass = profile->getAppletClass();
if (!appletClass.isEmpty())
{
launchScript += "appletClass " + appletClass + "\n";
@@ -492,7 +500,7 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session)
{
QStringList jars, nativeJars;
auto javaArchitecture = settings()->get("JavaArchitecture").toString();
- m_profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
+ profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
for(auto file: jars)
{
launchScript += "cp " + file + "\n";
@@ -504,7 +512,7 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session)
launchScript += "natives " + getNativePath() + "\n";
}
- for (auto trait : m_profile->getTraits())
+ for (auto trait : profile->getTraits())
{
launchScript += "traits " + trait + "\n";
}
@@ -519,6 +527,7 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session)
out << "Main Class:" << " " + getMainClass() << "";
out << "Native path:" << " " + getNativePath() << "";
+ auto profile = m_components->getProfile();
auto alltraits = traits();
if(alltraits.size())
@@ -536,7 +545,7 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session)
out << "Libraries:";
QStringList jars, nativeJars;
auto javaArchitecture = settings()->get("JavaArchitecture").toString();
- m_profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
+ profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
auto printLibFile = [&](const QString & path)
{
QFileInfo info(path);
@@ -594,7 +603,7 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session)
out << "";
}
- auto & jarMods = m_profile->getJarMods();
+ auto & jarMods = profile->getJarMods();
if(jarMods.size())
{
out << "Jar Mods:";
@@ -989,8 +998,9 @@ std::shared_ptr<WorldList> MinecraftInstance::worldList() const
QList< Mod > MinecraftInstance::getJarMods() const
{
+ auto profile = m_components->getProfile();
QList<Mod> mods;
- for (auto jarmod : m_profile->getJarMods())
+ for (auto jarmod : profile->getJarMods())
{
QStringList jar, temp1, temp2, temp3;
jarmod->getApplicableFiles(currentSystem, jar, temp1, temp2, temp3, jarmodsPath().absolutePath());
diff --git a/api/logic/minecraft/MinecraftInstance.h b/api/logic/minecraft/MinecraftInstance.h
index 417098da..cea7c60a 100644
--- a/api/logic/minecraft/MinecraftInstance.h
+++ b/api/logic/minecraft/MinecraftInstance.h
@@ -19,7 +19,9 @@ public:
virtual ~MinecraftInstance() {};
virtual void init() override;
+ // FIXME: remove
QString typeName() const override;
+ // FIXME: remove
QSet<QString> traits() const override;
bool canEdit() const override
@@ -91,15 +93,21 @@ public:
QString getStatusbarDescription() override;
+ // FIXME: remove
virtual QStringList getClassPath() const;
+ // FIXME: remove
virtual QStringList getNativeJars() const;
+ // FIXME: remove
virtual QString getMainClass() const;
+ // FIXME: remove
virtual QStringList processMinecraftArgs(AuthSessionPtr account) const;
virtual JavaVersion getJavaVersion() const;
+ // FIXME: remove
QString getComponentVersion(const QString &uid) const;
+ // FIXME: remove
bool setComponentVersion(const QString &uid, const QString &version);
signals:
@@ -114,7 +122,7 @@ private:
QString prettifyTimeDuration(int64_t duration);
protected: // data
- std::shared_ptr<ComponentList> m_profile;
+ std::shared_ptr<ComponentList> m_components;
mutable std::shared_ptr<ModList> m_loader_mod_list;
mutable std::shared_ptr<ModList> m_core_mod_list;
mutable std::shared_ptr<ModList> m_resource_pack_list;
diff --git a/api/logic/minecraft/ProfilePatch.cpp b/api/logic/minecraft/ProfilePatch.cpp
index b8b5c240..b7a5a37a 100644
--- a/api/logic/minecraft/ProfilePatch.cpp
+++ b/api/logic/minecraft/ProfilePatch.cpp
@@ -22,7 +22,7 @@ std::shared_ptr<Meta::Version> ProfilePatch::getMeta()
return m_metaVersion;
}
-void ProfilePatch::applyTo(ComponentList* profile)
+void ProfilePatch::applyTo(LaunchProfile* profile)
{
auto vfile = getVersionFile();
if(vfile)
@@ -35,7 +35,7 @@ void ProfilePatch::applyTo(ComponentList* profile)
}
}
-std::shared_ptr<class VersionFile> ProfilePatch::getVersionFile()
+std::shared_ptr<class VersionFile> ProfilePatch::getVersionFile() const
{
if(m_metaVersion)
{
@@ -51,7 +51,7 @@ std::shared_ptr<class VersionFile> ProfilePatch::getVersionFile()
}
}
-std::shared_ptr<class Meta::VersionList> ProfilePatch::getVersionList()
+std::shared_ptr<class Meta::VersionList> ProfilePatch::getVersionList() const
{
if(m_metaVersion)
{
@@ -167,7 +167,7 @@ void ProfilePatch::setMovable (bool state)
m_isMovable = state;
}
-ProblemSeverity ProfilePatch::getProblemSeverity()
+ProblemSeverity ProfilePatch::getProblemSeverity() const
{
auto file = getVersionFile();
if(file)
@@ -177,7 +177,7 @@ ProblemSeverity ProfilePatch::getProblemSeverity()
return ProblemSeverity::Error;
}
-const QList<PatchProblem> ProfilePatch::getProblems()
+const QList<PatchProblem> ProfilePatch::getProblems() const
{
auto file = getVersionFile();
if(file)
diff --git a/api/logic/minecraft/ProfilePatch.h b/api/logic/minecraft/ProfilePatch.h
index af5e89a4..80825342 100644
--- a/api/logic/minecraft/ProfilePatch.h
+++ b/api/logic/minecraft/ProfilePatch.h
@@ -7,6 +7,7 @@
#include "ProblemProvider.h"
class ComponentList;
+class LaunchProfile;
namespace Meta
{
class Version;
@@ -21,7 +22,7 @@ public:
ProfilePatch(std::shared_ptr<VersionFile> file, const QString &filename = QString());
virtual ~ProfilePatch(){};
- virtual void applyTo(ComponentList *profile);
+ virtual void applyTo(LaunchProfile *profile);
virtual bool isMoveable();
virtual bool isCustomizable();
@@ -41,16 +42,16 @@ public:
virtual QString getFilename();
- virtual std::shared_ptr<class VersionFile> getVersionFile();
- virtual std::shared_ptr<class Meta::VersionList> getVersionList();
+ virtual std::shared_ptr<class VersionFile> getVersionFile() const;
+ virtual std::shared_ptr<class Meta::VersionList> getVersionList() const;
void setVanilla (bool state);
void setRemovable (bool state);
void setRevertible (bool state);
void setMovable (bool state);
- const QList<PatchProblem> getProblems() override;
- ProblemSeverity getProblemSeverity() override;
+ const QList<PatchProblem> getProblems() const override;
+ ProblemSeverity getProblemSeverity() const override;
protected:
// Properties for UI and version manipulation from UI in general
diff --git a/api/logic/minecraft/VersionFile.cpp b/api/logic/minecraft/VersionFile.cpp
index 65675873..9f485c55 100644
--- a/api/logic/minecraft/VersionFile.cpp
+++ b/api/logic/minecraft/VersionFile.cpp
@@ -15,7 +15,7 @@ static bool isMinecraftVersion(const QString &uid)
return uid == "net.minecraft";
}
-void VersionFile::applyTo(ComponentList *profile)
+void VersionFile::applyTo(LaunchProfile *profile)
{
// Only real Minecraft can set those. Don't let anything override them.
if (isMinecraftVersion(uid))
diff --git a/api/logic/minecraft/VersionFile.h b/api/logic/minecraft/VersionFile.h
index 001b696c..60acaad6 100644
--- a/api/logic/minecraft/VersionFile.h
+++ b/api/logic/minecraft/VersionFile.h
@@ -13,6 +13,7 @@
class ComponentList;
class VersionFile;
+class LaunchProfile;
struct MojangDownloadInfo;
struct MojangAssetIndexInfo;
@@ -22,7 +23,7 @@ class VersionFile : public ProblemContainer
friend class MojangVersionFormat;
friend class OneSixVersionFormat;
public: /* methods */
- void applyTo(ComponentList *profile);
+ void applyTo(LaunchProfile* profile);
public: /* data */
/// MultiMC: order hint for this version file if no explicit order is set
diff --git a/api/logic/minecraft/launch/ModMinecraftJar.cpp b/api/logic/minecraft/launch/ModMinecraftJar.cpp
index 14b00447..6407ade0 100644
--- a/api/logic/minecraft/launch/ModMinecraftJar.cpp
+++ b/api/logic/minecraft/launch/ModMinecraftJar.cpp
@@ -42,7 +42,8 @@ void ModMinecraftJar::executeTask()
}
// create temporary modded jar, if needed
- auto profile = m_inst->getComponentList();
+ auto components = m_inst->getComponentList();
+ auto profile = components->getProfile();
auto jarMods = m_inst->getJarMods();
if(jarMods.size())
{
diff --git a/api/logic/minecraft/update/AssetUpdateTask.cpp b/api/logic/minecraft/update/AssetUpdateTask.cpp
index 6919e0a6..2ad2b5b2 100644
--- a/api/logic/minecraft/update/AssetUpdateTask.cpp
+++ b/api/logic/minecraft/update/AssetUpdateTask.cpp
@@ -12,7 +12,8 @@ AssetUpdateTask::AssetUpdateTask(MinecraftInstance * inst)
void AssetUpdateTask::executeTask()
{
setStatus(tr("Updating assets index..."));
- auto profile = m_inst->getComponentList();
+ auto components = m_inst->getComponentList();
+ auto profile = components->getProfile();
auto assets = profile->getMinecraftAssets();
QUrl indexUrl = assets->url;
QString localPath = assets->id + ".json";
@@ -48,7 +49,8 @@ void AssetUpdateTask::assetIndexFinished()
AssetsIndex index;
qDebug() << m_inst->name() << ": Finished asset index download";
- auto profile = m_inst->getComponentList();
+ auto components = m_inst->getComponentList();
+ auto profile = components->getProfile();
auto assets = profile->getMinecraftAssets();
QString asset_fname = "assets/indexes/" + assets->id + ".json";
diff --git a/api/logic/minecraft/update/FMLLibrariesTask.cpp b/api/logic/minecraft/update/FMLLibrariesTask.cpp
index e64b7a82..56ecee43 100644
--- a/api/logic/minecraft/update/FMLLibrariesTask.cpp
+++ b/api/logic/minecraft/update/FMLLibrariesTask.cpp
@@ -13,7 +13,8 @@ void FMLLibrariesTask::executeTask()
{
// Get the mod list
MinecraftInstance *inst = (MinecraftInstance *)m_inst;
- std::shared_ptr<ComponentList> profile = inst->getComponentList();
+ auto components = inst->getComponentList();
+ auto profile = components->getProfile();
bool forge_present = false;
if (!profile->hasTrait("legacyFML"))
@@ -34,7 +35,7 @@ void FMLLibrariesTask::executeTask()
// determine if we need some libs for FML or forge
setStatus(tr("Checking for FML libraries..."));
- forge_present = (profile->versionPatch("net.minecraftforge") != nullptr);
+ forge_present = (components->versionPatch("net.minecraftforge") != nullptr);
// we don't...
if (!forge_present)
{
diff --git a/api/logic/minecraft/update/LibrariesTask.cpp b/api/logic/minecraft/update/LibrariesTask.cpp
index bbbd5f02..80d45d97 100644
--- a/api/logic/minecraft/update/LibrariesTask.cpp
+++ b/api/logic/minecraft/update/LibrariesTask.cpp
@@ -21,7 +21,8 @@ void LibrariesTask::executeTask()
}
// Build a list of URLs that will need to be downloaded.
- std::shared_ptr<ComponentList> profile = inst->getComponentList();
+ auto components = inst->getComponentList();
+ auto profile = components->getProfile();
auto job = new NetJob(tr("Libraries for instance %1").arg(inst->name()));
downloadJob.reset(job);