diff options
author | Jan Dalheimer <jan@dalheimer.de> | 2013-12-20 14:47:26 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-12-21 23:40:37 +0100 |
commit | 82c87aa06f793b9f38e6cb42d284f00695f4bac5 (patch) | |
tree | 21f893b0336a90d4e4b9f14cb5312f2c1ea04280 /MultiMC.cpp | |
parent | 34a3fedf7b115c84ff305bf72fbc9d568682d84a (diff) | |
download | MultiMC-82c87aa06f793b9f38e6cb42d284f00695f4bac5.tar MultiMC-82c87aa06f793b9f38e6cb42d284f00695f4bac5.tar.gz MultiMC-82c87aa06f793b9f38e6cb42d284f00695f4bac5.tar.lz MultiMC-82c87aa06f793b9f38e6cb42d284f00695f4bac5.tar.xz MultiMC-82c87aa06f793b9f38e6cb42d284f00695f4bac5.zip |
Initial FTB support. Allows "tracking" of FTB instances.
Diffstat (limited to 'MultiMC.cpp')
-rw-r--r-- | MultiMC.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/MultiMC.cpp b/MultiMC.cpp index 5d08af4c..8d188e96 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -313,6 +313,55 @@ void MultiMC::initGlobalSettings() m_settings->registerSetting(new Setting("UseDevBuilds", false)); m_settings->registerSetting(new Setting("AutoUpdate", true)); + // FTB + m_settings->registerSetting(new Setting("TrackFTBInstances", false)); + m_settings->registerSetting(new Setting("FTBLauncherRoot", + #ifdef Q_OS_LINUX + QDir::home().absoluteFilePath(".ftblauncher") + #elif defined(Q_OS_WIN32) + PathCombine(QDir::homePath(), "AppData/Roaming/ftblauncher") + #elif defined(Q_OS_MAC) + PathCombine(QDir::homePath(), "Library/Application Support/ftblauncher") + #endif + )); + + m_settings->registerSetting(new Setting("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"; + } + } + // Folders m_settings->registerSetting(new Setting("InstanceDir", "instances")); m_settings->registerSetting(new Setting("CentralModsDir", "mods")); |