Permalink
Browse files

SCRATCH partial broken rearranging of MinecraftProfile into multiple …

…things
  • Loading branch information...
peterix committed Sep 13, 2017
1 parent 5290b9d commit f29833ca01aaa459014ff80ee533f01f6086e393
View
@@ -253,6 +253,8 @@ set(MINECRAFT_SOURCES
minecraft/ParseUtils.h
minecraft/ProfileUtils.cpp
minecraft/ProfileUtils.h
minecraft/ResolvedProfile.cpp
minecraft/ResolvedProfile.h
minecraft/Library.cpp
minecraft/Library.h
minecraft/MojangDownloadInfo.h
@@ -35,7 +35,6 @@ MinecraftProfile::MinecraftProfile(MinecraftInstance * instance)
: QAbstractListModel()
{
m_instance = instance;
clear();
}
MinecraftProfile::~MinecraftProfile()
@@ -50,22 +49,6 @@ void MinecraftProfile::reload()
endResetModel();
}
void MinecraftProfile::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 MinecraftProfile::clearPatches()
{
beginResetModel();
@@ -363,6 +346,8 @@ void MinecraftProfile::resetOrder()
bool MinecraftProfile::reapplyPatches()
{
return false;
/*
try
{
clear();
@@ -379,267 +364,7 @@ bool MinecraftProfile::reapplyPatches()
return false;
}
return true;
}
static void applyString(const QString & from, QString & to)
{
if(from.isEmpty())
return;
to = from;
}
void MinecraftProfile::applyMinecraftVersion(const QString& id)
{
applyString(id, this->m_minecraftVersion);
}
void MinecraftProfile::applyAppletClass(const QString& appletClass)
{
applyString(appletClass, this->m_appletClass);
}
void MinecraftProfile::applyMainClass(const QString& mainClass)
{
applyString(mainClass, this->m_mainClass);
}
void MinecraftProfile::applyMinecraftArguments(const QString& minecraftArguments)
{
applyString(minecraftArguments, this->m_minecraftArguments);
}
void MinecraftProfile::applyMinecraftVersionType(const QString& type)
{
applyString(type, this->m_minecraftVersionType);
}
void MinecraftProfile::applyMinecraftAssets(MojangAssetIndexInfo::Ptr assets)
{
if(assets)
{
m_minecraftAssets = assets;
}
}
void MinecraftProfile::applyTraits(const QSet<QString>& traits)
{
this->m_traits.unite(traits);
}
void MinecraftProfile::applyTweakers(const QStringList& tweakers)
{
// FIXME: check for dupes?
// FIXME: does order matter?
for (auto tweaker : tweakers)
{
this->m_tweakers += tweaker;
}
}
void MinecraftProfile::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 MinecraftProfile::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 MinecraftProfile::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 MinecraftProfile::getMainJar() const
{
return m_mainJar;
}
void MinecraftProfile::applyMainJar(LibraryPtr jar)
{
if(jar)
{
m_mainJar = jar;
}
}
void MinecraftProfile::applyProblemSeverity(ProblemSeverity severity)
{
if (m_problemSeverity < severity)
{
m_problemSeverity = severity;
}
}
QString MinecraftProfile::getMinecraftVersion() const
{
return m_minecraftVersion;
}
QString MinecraftProfile::getAppletClass() const
{
return m_appletClass;
}
QString MinecraftProfile::getMainClass() const
{
return m_mainClass;
}
const QSet<QString> &MinecraftProfile::getTraits() const
{
return m_traits;
}
const QStringList & MinecraftProfile::getTweakers() const
{
return m_tweakers;
}
bool MinecraftProfile::hasTrait(const QString& trait) const
{
return m_traits.contains(trait);
}
ProblemSeverity MinecraftProfile::getProblemSeverity() const
{
return m_problemSeverity;
}
QString MinecraftProfile::getMinecraftVersionType() const
{
return m_minecraftVersionType;
}
std::shared_ptr<MojangAssetIndexInfo> MinecraftProfile::getMinecraftAssets() const
{
if(!m_minecraftAssets)
{
return std::make_shared<MojangAssetIndexInfo>("legacy");
}
return m_minecraftAssets;
}
QString MinecraftProfile::getMinecraftArguments() const
{
return m_minecraftArguments;
}
const QList<LibraryPtr> & MinecraftProfile::getJarMods() const
{
return m_jarMods;
}
const QList<LibraryPtr> & MinecraftProfile::getLibraries() const
{
return m_libraries;
}
const QList<LibraryPtr> & MinecraftProfile::getNativeLibraries() const
{
return m_nativeLibraries;
}
void MinecraftProfile::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 MinecraftProfile::installJarMods(QStringList selectedFiles)
Oops, something went wrong.

0 comments on commit f29833c

Please sign in to comment.