summaryrefslogtreecommitdiffstats
path: root/logic
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-05-22 00:56:41 +0200
committerPetr Mrázek <peterix@gmail.com>2015-05-22 01:08:37 +0200
commitcfdfd0e8118fce8525a4618e0ee162f63504ed5b (patch)
tree0d996b477de12d19944a9f0489596233a1cbc831 /logic
parent81b37dae1839cd2daabbe18404a5dbe0c7292f35 (diff)
downloadMultiMC-cfdfd0e8118fce8525a4618e0ee162f63504ed5b.tar
MultiMC-cfdfd0e8118fce8525a4618e0ee162f63504ed5b.tar.gz
MultiMC-cfdfd0e8118fce8525a4618e0ee162f63504ed5b.tar.lz
MultiMC-cfdfd0e8118fce8525a4618e0ee162f63504ed5b.tar.xz
MultiMC-cfdfd0e8118fce8525a4618e0ee162f63504ed5b.zip
GH-977 possibly fix FTB on windows. Maybe. Partially. Now maybe for real.
Diffstat (limited to 'logic')
-rw-r--r--logic/ftb/FTBPlugin.cpp76
1 files changed, 40 insertions, 36 deletions
diff --git a/logic/ftb/FTBPlugin.cpp b/logic/ftb/FTBPlugin.cpp
index b30fc378..2f294b01 100644
--- a/logic/ftb/FTBPlugin.cpp
+++ b/logic/ftb/FTBPlugin.cpp
@@ -269,58 +269,62 @@ void FTBPlugin::loadInstances(SettingsObjectPtr globalSettings, QMap<QString, QS
static const int APPDATA_BUFFER_SIZE = 1024;
#endif
-void FTBPlugin::initialize(SettingsObjectPtr globalSettings)
+static QString getCacheStorageLocation()
{
- // FTB
- globalSettings->registerSetting("TrackFTBInstances", false);
- QString ftbDataDefault;
-#ifdef Q_OS_LINUX
- QString ftbDefault = ftbDataDefault = QDir::home().absoluteFilePath(".ftblauncher");
-#elif defined(Q_OS_WIN32)
+ QString ftbDefault;
+#ifdef 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))
- {
- if(!GetEnvironmentVariableW(L"USERPROFILE", newBuf, APPDATA_BUFFER_SIZE))
- {
- qCritical() << "Your LOCALAPPDATA folder is missing! If you are on windows, this means your system is broken.";
- }
- else
- {
- auto userHome = QString::fromWCharArray(newBuf);
- auto localAppData = PathCombine(QString::fromWCharArray(newBuf), "Local Settings", "Application Data");
- newFtbDefault = QDir(localAppData).absoluteFilePath("ftblauncher");
- }
- }
- else
+ if (GetEnvironmentVariableW(L"LOCALAPPDATA", buf, APPDATA_BUFFER_SIZE)) // local
{
- newFtbDefault = QDir(QString::fromWCharArray(newBuf)).absoluteFilePath("ftblauncher");
+ ftbDefault = QDir(QString::fromWCharArray(buf)).absoluteFilePath("ftblauncher");
}
- if (!GetEnvironmentVariableW(L"APPDATA", buf, APPDATA_BUFFER_SIZE))
+ else if (GetEnvironmentVariableW(L"APPDATA", buf, APPDATA_BUFFER_SIZE)) // roaming
{
- qCritical() << "Your APPDATA folder is missing! If you are on windows, this means your "
- "system is broken.";
+ ftbDefault = QDir(QString::fromWCharArray(buf)).absoluteFilePath("ftblauncher");
}
else
{
- oldFtbDefault = QDir(QString::fromWCharArray(buf)).absoluteFilePath("ftblauncher");
+ qCritical() << "Your LOCALAPPDATA and APPDATA folders are missing!"
+ " If you are on windows, this means your system is broken.";
}
- if (QFile::exists(QDir(newFtbDefault).absoluteFilePath("ftblaunch.cfg")))
+#elif defined(Q_OS_MAC)
+ ftbDefault = PathCombine(QDir::homePath(), "Library/Application Support/ftblauncher");
+#else
+ ftbDefault = QDir::home().absoluteFilePath(".ftblauncher");
+#endif
+ return ftbDefault;
+}
+
+
+static QString getDynamicStorageLocation()
+{
+ QString ftbDefault;
+#ifdef Q_OS_WIN32
+ wchar_t buf[APPDATA_BUFFER_SIZE];
+ QString cacheStorage;
+ if (GetEnvironmentVariableW(L"APPDATA", buf, APPDATA_BUFFER_SIZE))
{
- qDebug() << "Old FTB setup";
- ftbDefault = ftbDataDefault = oldFtbDefault;
+ ftbDefault = QDir(QString::fromWCharArray(buf)).absoluteFilePath("ftblauncher");
}
else
{
- qDebug() << "New FTB setup";
- ftbDefault = oldFtbDefault;
- ftbDataDefault = newFtbDefault;
+ qCritical() << "Your APPDATA folder is missing! If you are on windows, this means your system is broken.";
}
#elif defined(Q_OS_MAC)
- QString ftbDefault = ftbDataDefault =
- PathCombine(QDir::homePath(), "Library/Application Support/ftblauncher");
+ ftbDefault = PathCombine(QDir::homePath(), "Library/Application Support/ftblauncher");
+#else
+ ftbDefault = QDir::home().absoluteFilePath(".ftblauncher");
#endif
+ return ftbDefault;
+}
+
+void FTBPlugin::initialize(SettingsObjectPtr globalSettings)
+{
+ // FTB
+ globalSettings->registerSetting("TrackFTBInstances", false);
+ QString ftbDataDefault = getDynamicStorageLocation();
+ QString ftbDefault = getCacheStorageLocation();
+
globalSettings->registerSetting("FTBLauncherDataRoot", ftbDataDefault);
globalSettings->registerSetting("FTBLauncherRoot", ftbDefault);
qDebug() << "FTB Launcher paths:" << globalSettings->get("FTBLauncherDataRoot").toString()