summaryrefslogtreecommitdiffstats
path: root/MultiMC.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-12-22 04:31:30 +0100
committerPetr Mrázek <peterix@gmail.com>2013-12-22 04:31:30 +0100
commit74b5b5f535ec8d98ba93c629804c75fda9e32475 (patch)
treed24bf1a9219595db0b1e8356e78c8c34698a6a7c /MultiMC.cpp
parent82c87aa06f793b9f38e6cb42d284f00695f4bac5 (diff)
downloadMultiMC-74b5b5f535ec8d98ba93c629804c75fda9e32475.tar
MultiMC-74b5b5f535ec8d98ba93c629804c75fda9e32475.tar.gz
MultiMC-74b5b5f535ec8d98ba93c629804c75fda9e32475.tar.lz
MultiMC-74b5b5f535ec8d98ba93c629804c75fda9e32475.tar.xz
MultiMC-74b5b5f535ec8d98ba93c629804c75fda9e32475.zip
Make FTB instances behave better
* Do not re-create on every reload * Use the version.json/custom.json logic properly * Should be offline-friendly * FTB instances can be copied, turn into normal instances
Diffstat (limited to 'MultiMC.cpp')
-rw-r--r--MultiMC.cpp130
1 files changed, 69 insertions, 61 deletions
diff --git a/MultiMC.cpp b/MultiMC.cpp
index 8d188e96..110accc2 100644
--- a/MultiMC.cpp
+++ b/MultiMC.cpp
@@ -34,8 +34,9 @@
#include "config.h"
using namespace Util::Commandline;
-MultiMC::MultiMC(int &argc, char **argv, const QString &root) : QApplication(argc, argv),
- m_version{VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD, VERSION_CHANNEL, VERSION_BUILD_TYPE}
+MultiMC::MultiMC(int &argc, char **argv, const QString &root)
+ : QApplication(argc, argv), m_version{VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD,
+ VERSION_CHANNEL, VERSION_BUILD_TYPE}
{
setOrganizationName("MultiMC");
setApplicationName("MultiMC5");
@@ -135,9 +136,10 @@ MultiMC::MultiMC(int &argc, char **argv, const QString &root) : QApplication(arg
}
// change directory
- QDir::setCurrent(args["dir"].toString().isEmpty() ?
- (root.isEmpty() ? QDir::currentPath() : QDir::current().absoluteFilePath(root))
- : args["dir"].toString());
+ QDir::setCurrent(
+ args["dir"].toString().isEmpty()
+ ? (root.isEmpty() ? QDir::currentPath() : QDir::current().absoluteFilePath(root))
+ : args["dir"].toString());
// init the logger
initLogger();
@@ -174,42 +176,43 @@ MultiMC::MultiMC(int &argc, char **argv, const QString &root) : QApplication(arg
{
QLOG_INFO() << "No proxy found.";
}
- else for (auto proxy : proxies)
- {
- QString proxyDesc;
- if (proxy.type() == QNetworkProxy::NoProxy)
- {
- QLOG_INFO() << "Using no proxy is an option!";
- continue;
- }
- switch (proxy.type())
+ else
+ for (auto proxy : proxies)
{
- case QNetworkProxy::DefaultProxy:
- proxyDesc = "Default proxy: ";
- break;
- case QNetworkProxy::Socks5Proxy:
- proxyDesc = "Socks5 proxy: ";
- break;
- case QNetworkProxy::HttpProxy:
- proxyDesc = "HTTP proxy: ";
- break;
- case QNetworkProxy::HttpCachingProxy:
- proxyDesc = "HTTP caching: ";
- break;
- case QNetworkProxy::FtpCachingProxy:
- proxyDesc = "FTP caching: ";
- break;
- default:
- proxyDesc = "DERP proxy: ";
- break;
+ QString proxyDesc;
+ if (proxy.type() == QNetworkProxy::NoProxy)
+ {
+ QLOG_INFO() << "Using no proxy is an option!";
+ continue;
+ }
+ switch (proxy.type())
+ {
+ case QNetworkProxy::DefaultProxy:
+ proxyDesc = "Default proxy: ";
+ break;
+ case QNetworkProxy::Socks5Proxy:
+ proxyDesc = "Socks5 proxy: ";
+ break;
+ case QNetworkProxy::HttpProxy:
+ proxyDesc = "HTTP proxy: ";
+ break;
+ case QNetworkProxy::HttpCachingProxy:
+ proxyDesc = "HTTP caching: ";
+ break;
+ case QNetworkProxy::FtpCachingProxy:
+ proxyDesc = "FTP caching: ";
+ break;
+ default:
+ proxyDesc = "DERP proxy: ";
+ break;
+ }
+ proxyDesc += QString("%3@%1:%2 pass %4")
+ .arg(proxy.hostName())
+ .arg(proxy.port())
+ .arg(proxy.user())
+ .arg(proxy.password());
+ QLOG_INFO() << proxyDesc;
}
- proxyDesc += QString("%3@%1:%2 pass %4")
- .arg(proxy.hostName())
- .arg(proxy.port())
- .arg(proxy.user())
- .arg(proxy.password());
- QLOG_INFO() << proxyDesc;
- }
// create the global network manager
m_qnam.reset(new QNetworkAccessManager(this));
@@ -315,21 +318,23 @@ void MultiMC::initGlobalSettings()
// 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(
+ "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"));
+ QFile f(QDir(m_settings->get("FTBLauncherRoot").toString())
+ .absoluteFilePath("ftblaunch.cfg"));
QLOG_INFO() << "Attempting to read" << f.fileName();
if (f.open(QFile::ReadOnly))
{
@@ -398,7 +403,6 @@ void MultiMC::initGlobalSettings()
// The cat
m_settings->registerSetting(new Setting("TheCat", false));
-
m_settings->registerSetting(new Setting("InstSortMode", "Name"));
m_settings->registerSetting(new Setting("SelectedInstance", QString()));
@@ -486,17 +490,20 @@ std::shared_ptr<JavaVersionList> MultiMC::javalist()
#error Unsupported operating system.
#endif
-void MultiMC::installUpdates(const QString& updateFilesDir, bool restartOnFinish)
+void MultiMC::installUpdates(const QString &updateFilesDir, bool restartOnFinish)
{
QLOG_INFO() << "Installing updates.";
#if LINUX
- // On Linux, the MultiMC executable file is actually in the bin folder inside the installation directory.
+ // On Linux, the MultiMC executable file is actually in the bin folder inside the
+ // installation directory.
// This means that MultiMC's *actual* install path is the parent folder.
- // We need to tell the updater to run with this directory as the install path, rather than the bin folder where the executable is.
+ // We need to tell the updater to run with this directory as the install path, rather than
+ // the bin folder where the executable is.
// On other operating systems, we'll just use the path to the executable.
QString appDir = QFileInfo(MMC->applicationDirPath()).dir().path();
- // On Linux, we also need to set the finish command to the launch script, rather than the binary.
+ // On Linux, we also need to set the finish command to the launch script, rather than the
+ // binary.
QString finishCmd = PathCombine(appDir, "MultiMC");
#else
QString appDir = MMC->applicationDirPath();
@@ -504,18 +511,20 @@ void MultiMC::installUpdates(const QString& updateFilesDir, bool restartOnFinish
#endif
// Build the command we'll use to run the updater.
- // Note, the above comment about the app dir path on Linux is irrelevant here because the updater binary is always in the
+ // Note, the above comment about the app dir path on Linux is irrelevant here because the
+ // updater binary is always in the
// same folder as the main binary.
QString updaterBinary = PathCombine(MMC->applicationDirPath(), UPDATER_BIN);
QStringList args;
- // ./updater --install-dir $INSTALL_DIR --package-dir $UPDATEFILES_DIR --script $UPDATEFILES_DIR/file_list.xml --wait $PID --mode main
+ // ./updater --install-dir $INSTALL_DIR --package-dir $UPDATEFILES_DIR --script
+ // $UPDATEFILES_DIR/file_list.xml --wait $PID --mode main
args << "--install-dir" << appDir;
args << "--package-dir" << updateFilesDir;
- args << "--script" << PathCombine(updateFilesDir, "file_list.xml");
- args << "--wait" << QString::number(MMC->applicationPid());
+ args << "--script" << PathCombine(updateFilesDir, "file_list.xml");
+ args << "--wait" << QString::number(MMC->applicationPid());
if (restartOnFinish)
- args << "--finish-cmd" << finishCmd;
+ args << "--finish-cmd" << finishCmd;
QLOG_INFO() << "Running updater with command" << updaterBinary << args.join(" ");
@@ -525,7 +534,7 @@ void MultiMC::installUpdates(const QString& updateFilesDir, bool restartOnFinish
MMC->quit();
}
-void MultiMC::setUpdateOnExit(const QString& updateFilesDir)
+void MultiMC::setUpdateOnExit(const QString &updateFilesDir)
{
m_updateOnExitPath = updateFilesDir;
}
@@ -535,5 +544,4 @@ QString MultiMC::getExitUpdatePath() const
return m_updateOnExitPath;
}
-
#include "MultiMC.moc"