From cfdfd0e8118fce8525a4618e0ee162f63504ed5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Fri, 22 May 2015 00:56:41 +0200 Subject: [PATCH] GH-977 possibly fix FTB on windows. Maybe. Partially. Now maybe for real. --- logic/ftb/FTBPlugin.cpp | 100 +++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 48 deletions(-) diff --git a/logic/ftb/FTBPlugin.cpp b/logic/ftb/FTBPlugin.cpp index b30fc378a..2f294b016 100644 --- a/logic/ftb/FTBPlugin.cpp +++ b/logic/ftb/FTBPlugin.cpp @@ -269,58 +269,62 @@ void FTBPlugin::loadInstances(SettingsObjectPtr globalSettings, QMapregisterSetting("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)) - { - 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 - { - newFtbDefault = QDir(QString::fromWCharArray(newBuf)).absoluteFilePath("ftblauncher"); - } - if (!GetEnvironmentVariableW(L"APPDATA", buf, APPDATA_BUFFER_SIZE)) - { - qCritical() << "Your APPDATA folder is missing! If you are on windows, this means your " - "system is broken."; - } - else - { - oldFtbDefault = QDir(QString::fromWCharArray(buf)).absoluteFilePath("ftblauncher"); - } - if (QFile::exists(QDir(newFtbDefault).absoluteFilePath("ftblaunch.cfg"))) - { - qDebug() << "Old FTB setup"; - ftbDefault = ftbDataDefault = oldFtbDefault; - } - else - { - qDebug() << "New FTB setup"; - ftbDefault = oldFtbDefault; - ftbDataDefault = newFtbDefault; - } -#elif defined(Q_OS_MAC) - QString ftbDefault = ftbDataDefault = - PathCombine(QDir::homePath(), "Library/Application Support/ftblauncher"); -#endif + QString ftbDataDefault = getDynamicStorageLocation(); + QString ftbDefault = getCacheStorageLocation(); + globalSettings->registerSetting("FTBLauncherDataRoot", ftbDataDefault); globalSettings->registerSetting("FTBLauncherRoot", ftbDefault); qDebug() << "FTB Launcher paths:" << globalSettings->get("FTBLauncherDataRoot").toString()