From 8b4e22bbb88b289327c0614fa6df153533cdded3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 4 Apr 2015 15:46:15 +0200 Subject: NOISSUE Move FTB logic out of generic code --- MultiMC.cpp | 92 ++----------------------------------------------------------- 1 file changed, 2 insertions(+), 90 deletions(-) (limited to 'MultiMC.cpp') diff --git a/MultiMC.cpp b/MultiMC.cpp index b1b03ed9..6a967808 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -43,10 +43,7 @@ #include "logic/trans/TranslationDownloader.h" -#ifdef Q_OS_WIN32 -#include -static const int APPDATA_BUFFER_SIZE = 1024; -#endif +#include "logic/ftb/FTBPlugin.h" using namespace Util::Commandline; @@ -381,92 +378,7 @@ void MultiMC::initGlobalSettings(bool test_mode) } m_settings->registerSetting("ConsoleFontSize", defaultSize); - // FTB - m_settings->registerSetting("TrackFTBInstances", false); - QString ftbDataDefault; -#ifdef Q_OS_LINUX - QString ftbDefault = ftbDataDefault = QDir::home().absoluteFilePath(".ftblauncher"); -#elif defined(Q_OS_WIN32) - wchar_t 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 - { - 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 = 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")); - QLOG_INFO() << "Attempting to read" << f.fileName(); - if (f.open(QFile::ReadOnly)) - { - const QString data = QString::fromLatin1(f.readAll()); - QRegularExpression exp("installPath=(.*)"); - ftbRoot = QDir::cleanPath(exp.match(data).captured(1)); -#ifdef Q_OS_WIN32 - if (!ftbRoot.isEmpty()) - { - if (ftbRoot.at(0).isLetter() && ftbRoot.size() > 1 && ftbRoot.at(1) == '/') - { - ftbRoot.remove(1, 1); - } - } -#endif - if (ftbRoot.isEmpty()) - { - QLOG_INFO() << "Failed to get FTB root path"; - } - else - { - QLOG_INFO() << "FTB is installed at" << ftbRoot; - m_settings->set("FTBRoot", ftbRoot); - } - } - else - { - QLOG_WARN() << "Couldn't open" << f.fileName() << ":" << f.errorString(); - QLOG_WARN() << "This is perfectly normal if you don't have FTB installed"; - } - } + FTBPlugin::initialize(); // Folders m_settings->registerSetting("InstanceDir", "instances"); -- cgit v1.2.3