summaryrefslogtreecommitdiffstats
path: root/MultiMC.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-04-04 15:46:15 +0200
committerPetr Mrázek <peterix@gmail.com>2015-04-04 15:46:15 +0200
commit8b4e22bbb88b289327c0614fa6df153533cdded3 (patch)
treef813686f8780daca1948e1dd4fb77251ff1becf5 /MultiMC.cpp
parentc7b39fe1165956d07055e7917b22d5604fb5f768 (diff)
downloadMultiMC-8b4e22bbb88b289327c0614fa6df153533cdded3.tar
MultiMC-8b4e22bbb88b289327c0614fa6df153533cdded3.tar.gz
MultiMC-8b4e22bbb88b289327c0614fa6df153533cdded3.tar.lz
MultiMC-8b4e22bbb88b289327c0614fa6df153533cdded3.tar.xz
MultiMC-8b4e22bbb88b289327c0614fa6df153533cdded3.zip
NOISSUE Move FTB logic out of generic code
Diffstat (limited to 'MultiMC.cpp')
-rw-r--r--MultiMC.cpp92
1 files changed, 2 insertions, 90 deletions
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 <windows.h>
-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");