diff options
Diffstat (limited to 'MultiMC.cpp')
-rw-r--r-- | MultiMC.cpp | 74 |
1 files changed, 60 insertions, 14 deletions
diff --git a/MultiMC.cpp b/MultiMC.cpp index 358d15fb..bd72c139 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -12,13 +12,14 @@ #include <QDesktopServices> #include "gui/dialogs/VersionSelectDialog.h" -#include "logic/lists/InstanceList.h" +#include "logic/InstanceList.h" #include "logic/auth/MojangAccountList.h" #include "logic/icons/IconList.h" -#include "logic/lists/LwjglVersionList.h" -#include "logic/lists/MinecraftVersionList.h" -#include "logic/lists/ForgeVersionList.h" -#include "logic/lists/LiteLoaderVersionList.h" +#include "logic/LwjglVersionList.h" +#include "logic/minecraft/MinecraftVersionList.h" +#include "logic/liteloader/LiteLoaderVersionList.h" + +#include "logic/forge/ForgeVersionList.h" #include "logic/news/NewsChecker.h" @@ -28,7 +29,7 @@ #include "logic/net/HttpMetaCache.h" #include "logic/net/URLConstants.h" -#include "logic/JavaUtils.h" +#include "logic/java/JavaUtils.h" #include "logic/updater/UpdateChecker.h" #include "logic/updater/NotificationChecker.h" @@ -37,6 +38,8 @@ #include "logic/tools/JVisualVM.h" #include "logic/tools/MCEditTool.h" +#include "logic/URNResolver.h" + #include "pathutils.h" #include "cmdutils.h" #include <inisettingsobject.h> @@ -86,6 +89,7 @@ MultiMC::MultiMC(int &argc, char **argv, bool root_override) parser.addShortOpt("launch", 'l'); parser.addDocumentation("launch", "tries to launch the given instance", "<inst>"); */ + // parse the arguments try { @@ -335,13 +339,16 @@ void MultiMC::initLogger() QsLogging::Logger &logger = QsLogging::Logger::instance(); logger.setLoggingLevel(QsLogging::TraceLevel); m_fileDestination = QsLogging::DestinationFactory::MakeFileDestination(logBase.arg(0)); - m_debugDestination = QsLogging::DestinationFactory::MakeQDebugDestination(); + m_debugDestination = QsLogging::DestinationFactory::MakeDebugOutputDestination(); logger.addDestination(m_fileDestination.get()); logger.addDestination(m_debugDestination.get()); // log all the things logger.setLoggingLevel(QsLogging::TraceLevel); + loggerInitialized = true; } +bool loggerInitialized = false; + void MultiMC::initGlobalSettings() { m_settings.reset(new INISettingsObject("multimc.cfg", this)); @@ -355,31 +362,57 @@ void MultiMC::initGlobalSettings() // FTB m_settings->registerSetting("TrackFTBInstances", false); + QString ftbDataDefault; #ifdef Q_OS_LINUX - QString ftbDefault = QDir::home().absoluteFilePath(".ftblauncher"); + QString ftbDefault = ftbDataDefault = QDir::home().absoluteFilePath(".ftblauncher"); #elif defined(Q_OS_WIN32) wchar_t buf[APPDATA_BUFFER_SIZE]; - QString ftbDefault; - if(!GetEnvironmentVariableW(L"APPDATA", buf, APPDATA_BUFFER_SIZE)) + wchar_t newBuf[APPDATA_BUFFER_SIZE]; + QString ftbDefault, newFtbDefault, oldFtbDefault; + if (!GetEnvironmentVariableW(L"LOCALAPPDATA", newBuf, APPDATA_BUFFER_SIZE)) + { + QLOG_FATAL() << "Your LOCALAPPDATA folder is missing! If you are on windows, this means your system is broken. If you aren't on windows, how the **** are you running the windows build????"; + } + else + { + newFtbDefault = QDir(QString::fromWCharArray(newBuf)).absoluteFilePath("ftblauncher"); + } + if (!GetEnvironmentVariableW(L"APPDATA", buf, APPDATA_BUFFER_SIZE)) { QLOG_FATAL() << "Your APPDATA folder is missing! If you are on windows, this means your system is broken. If you aren't on windows, how the **** are you running the windows build????"; } else { - ftbDefault = PathCombine(QString::fromWCharArray(buf), "ftblauncher"); + oldFtbDefault = QDir(QString::fromWCharArray(buf)).absoluteFilePath("ftblauncher"); + } + if (QFile::exists(QDir(newFtbDefault).absoluteFilePath("ftblaunch.cfg"))) + { + QLOG_INFO() << "Old FTB setup"; + ftbDefault = ftbDataDefault = oldFtbDefault; + } + else + { + QLOG_INFO() << "New FTB setup"; + ftbDefault = oldFtbDefault; + ftbDataDefault = newFtbDefault; } #elif defined(Q_OS_MAC) - QString ftbDefault = - PathCombine(QDir::homePath(), "Library/Application Support/ftblauncher"); + QString ftbDefault = ftbDataDefault = + PathCombine(QDir::homePath(), "Library/Application Support/ftblauncher"); #endif + m_settings->registerSetting("FTBLauncherDataRoot", ftbDataDefault); m_settings->registerSetting("FTBLauncherRoot", ftbDefault); + QLOG_INFO() << "FTB Launcher paths:" + << m_settings->get("FTBLauncherDataRoot").toString() + << "and" + << m_settings->get("FTBLauncherRoot").toString(); m_settings->registerSetting("FTBRoot"); if (m_settings->get("FTBRoot").isNull()) { QString ftbRoot; QFile f(QDir(m_settings->get("FTBLauncherRoot").toString()) - .absoluteFilePath("ftblaunch.cfg")); + .absoluteFilePath("ftblaunch.cfg")); QLOG_INFO() << "Attempting to read" << f.fileName(); if (f.open(QFile::ReadOnly)) { @@ -455,6 +488,7 @@ void MultiMC::initGlobalSettings() // Java Settings m_settings->registerSetting("JavaPath", ""); m_settings->registerSetting("LastHostname", ""); + m_settings->registerSetting("JavaDetectionHack", ""); m_settings->registerSetting("JvmArgs", ""); // Custom Commands @@ -475,6 +509,8 @@ void MultiMC::initGlobalSettings() m_settings->registerSetting("ConsoleWindowGeometry", ""); m_settings->registerSetting("SettingsGeometry", ""); + + m_settings->registerSetting("PagedGeometry", ""); } void MultiMC::initHttpMetaCache() @@ -614,6 +650,16 @@ std::shared_ptr<JavaVersionList> MultiMC::javalist() return m_javalist; } +std::shared_ptr<URNResolver> MultiMC::resolver() +{ + if (!m_resolver) + { + m_resolver.reset(new URNResolver()); + } + return m_resolver; +} + + void MultiMC::installUpdates(const QString updateFilesDir, UpdateFlags flags) { // if we are going to update on exit, save the params now |