aboutsummaryrefslogtreecommitdiff
path: root/launcher
diff options
context:
space:
mode:
Diffstat (limited to 'launcher')
-rw-r--r--launcher/Application.cpp119
-rw-r--r--launcher/Application.h1
-rw-r--r--launcher/CMakeLists.txt7
-rw-r--r--launcher/DataMigrationTask.cpp96
-rw-r--r--launcher/DataMigrationTask.h42
-rw-r--r--launcher/FileSystem.cpp12
-rw-r--r--launcher/FileSystem.h30
-rw-r--r--launcher/InstanceCopyTask.cpp6
-rw-r--r--launcher/main.cpp2
-rw-r--r--launcher/minecraft/MinecraftInstance.cpp35
-rw-r--r--launcher/minecraft/MinecraftInstance.h4
-rw-r--r--launcher/pathmatcher/SimplePrefixMatcher.h25
-rw-r--r--launcher/resources/breeze_dark/breeze_dark.qrc43
-rw-r--r--launcher/resources/breeze_dark/index.theme11
-rw-r--r--launcher/resources/breeze_dark/scalable/about.svg12
-rw-r--r--launcher/resources/breeze_dark/scalable/accounts.svg17
-rw-r--r--launcher/resources/breeze_dark/scalable/bug.svg13
-rw-r--r--launcher/resources/breeze_dark/scalable/centralmods.svg1
-rw-r--r--launcher/resources/breeze_dark/scalable/checkupdate.svg14
-rw-r--r--launcher/resources/breeze_dark/scalable/copy.svg11
-rw-r--r--launcher/resources/breeze_dark/scalable/coremods.svg1
-rw-r--r--launcher/resources/breeze_dark/scalable/custom-commands.svg13
-rw-r--r--launcher/resources/breeze_dark/scalable/delete.svg13
-rw-r--r--launcher/resources/breeze_dark/scalable/discord.svg1
-rw-r--r--launcher/resources/breeze_dark/scalable/export.svg11
-rw-r--r--launcher/resources/breeze_dark/scalable/externaltools.svg13
-rw-r--r--launcher/resources/breeze_dark/scalable/help.svg13
-rw-r--r--launcher/resources/breeze_dark/scalable/instance-settings.svg13
-rw-r--r--launcher/resources/breeze_dark/scalable/jarmods.svg1
-rw-r--r--launcher/resources/breeze_dark/scalable/java.svg10
-rw-r--r--launcher/resources/breeze_dark/scalable/language.svg13
-rw-r--r--launcher/resources/breeze_dark/scalable/launch.svg8
-rw-r--r--launcher/resources/breeze_dark/scalable/launcher.svg57
-rw-r--r--launcher/resources/breeze_dark/scalable/loadermods.svg13
-rw-r--r--launcher/resources/breeze_dark/scalable/log.svg13
-rw-r--r--launcher/resources/breeze_dark/scalable/matrix.svg9
-rw-r--r--launcher/resources/breeze_dark/scalable/minecraft.svg13
-rw-r--r--launcher/resources/breeze_dark/scalable/new.svg18
-rw-r--r--launcher/resources/breeze_dark/scalable/news.svg13
-rw-r--r--launcher/resources/breeze_dark/scalable/notes.svg13
-rw-r--r--launcher/resources/breeze_dark/scalable/patreon.svg3
-rw-r--r--launcher/resources/breeze_dark/scalable/proxy.svg14
-rw-r--r--launcher/resources/breeze_dark/scalable/reddit-alien.svg3
-rw-r--r--launcher/resources/breeze_dark/scalable/refresh.svg8
-rw-r--r--launcher/resources/breeze_dark/scalable/rename.svg13
-rw-r--r--launcher/resources/breeze_dark/scalable/resourcepacks.svg11
-rw-r--r--launcher/resources/breeze_dark/scalable/screenshots.svg13
-rw-r--r--launcher/resources/breeze_dark/scalable/settings.svg17
-rw-r--r--launcher/resources/breeze_dark/scalable/shaderpacks.svg13
-rw-r--r--launcher/resources/breeze_dark/scalable/status-bad.svg9
-rw-r--r--launcher/resources/breeze_dark/scalable/status-good.svg10
-rw-r--r--launcher/resources/breeze_dark/scalable/status-yellow.svg9
-rw-r--r--launcher/resources/breeze_dark/scalable/tag.svg17
-rw-r--r--launcher/resources/breeze_dark/scalable/viewfolder.svg13
-rw-r--r--launcher/resources/breeze_dark/scalable/worlds.svg16
-rw-r--r--launcher/resources/breeze_light/breeze_light.qrc43
-rw-r--r--launcher/resources/breeze_light/index.theme11
-rw-r--r--launcher/resources/breeze_light/scalable/about.svg12
-rw-r--r--launcher/resources/breeze_light/scalable/accounts.svg17
-rw-r--r--launcher/resources/breeze_light/scalable/bug.svg13
-rw-r--r--launcher/resources/breeze_light/scalable/centralmods.svg1
-rw-r--r--launcher/resources/breeze_light/scalable/checkupdate.svg14
-rw-r--r--launcher/resources/breeze_light/scalable/copy.svg11
-rw-r--r--launcher/resources/breeze_light/scalable/coremods.svg1
-rw-r--r--launcher/resources/breeze_light/scalable/custom-commands.svg13
-rw-r--r--launcher/resources/breeze_light/scalable/delete.svg13
-rw-r--r--launcher/resources/breeze_light/scalable/discord.svg1
-rw-r--r--launcher/resources/breeze_light/scalable/export.svg11
-rw-r--r--launcher/resources/breeze_light/scalable/externaltools.svg13
-rw-r--r--launcher/resources/breeze_light/scalable/help.svg13
-rw-r--r--launcher/resources/breeze_light/scalable/instance-settings.svg13
-rw-r--r--launcher/resources/breeze_light/scalable/jarmods.svg1
-rw-r--r--launcher/resources/breeze_light/scalable/java.svg10
-rw-r--r--launcher/resources/breeze_light/scalable/language.svg13
-rw-r--r--launcher/resources/breeze_light/scalable/launch.svg8
-rw-r--r--launcher/resources/breeze_light/scalable/loadermods.svg13
-rw-r--r--launcher/resources/breeze_light/scalable/log.svg13
-rw-r--r--launcher/resources/breeze_light/scalable/matrix.svg9
-rw-r--r--launcher/resources/breeze_light/scalable/minecraft.svg13
-rw-r--r--launcher/resources/breeze_light/scalable/new.svg18
-rw-r--r--launcher/resources/breeze_light/scalable/news.svg13
-rw-r--r--launcher/resources/breeze_light/scalable/notes.svg13
-rw-r--r--launcher/resources/breeze_light/scalable/patreon.svg3
-rw-r--r--launcher/resources/breeze_light/scalable/proxy.svg14
-rw-r--r--launcher/resources/breeze_light/scalable/reddit-alien.svg3
-rw-r--r--launcher/resources/breeze_light/scalable/refresh.svg8
-rw-r--r--launcher/resources/breeze_light/scalable/rename.svg13
-rw-r--r--launcher/resources/breeze_light/scalable/resourcepacks.svg11
-rw-r--r--launcher/resources/breeze_light/scalable/screenshots.svg13
-rw-r--r--launcher/resources/breeze_light/scalable/settings.svg17
-rw-r--r--launcher/resources/breeze_light/scalable/shaderpacks.svg13
-rw-r--r--launcher/resources/breeze_light/scalable/status-bad.svg9
-rw-r--r--launcher/resources/breeze_light/scalable/status-good.svg10
-rw-r--r--launcher/resources/breeze_light/scalable/status-yellow.svg9
-rw-r--r--launcher/resources/breeze_light/scalable/tag.svg17
-rw-r--r--launcher/resources/breeze_light/scalable/viewfolder.svg13
-rw-r--r--launcher/resources/breeze_light/scalable/worlds.svg16
-rw-r--r--launcher/translations/TranslationsModel.cpp3
-rw-r--r--launcher/ui/dialogs/ProgressDialog.cpp3
-rw-r--r--launcher/ui/pages/global/LauncherPage.cpp29
-rw-r--r--launcher/ui/pages/global/LauncherPage.ui10
101 files changed, 1411 insertions, 56 deletions
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index c5594b21..4ba9eb9b 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -1,4 +1,7 @@
-// SPDX-License-Identifier: GPL-3.0-only
+// SPDX-FileCopyrightText: 2022 Sefa Eyeoglu <contact@scrumplex.net>
+//
+// SPDX-License-Identifier: GPL-3.0-only AND Apache-2.0
+
/*
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
@@ -38,10 +41,14 @@
#include "Application.h"
#include "BuildConfig.h"
+#include "DataMigrationTask.h"
#include "net/PasteUpload.h"
+#include "pathmatcher/MultiMatcher.h"
+#include "pathmatcher/SimplePrefixMatcher.h"
#include "ui/MainWindow.h"
#include "ui/InstanceWindow.h"
+#include "ui/dialogs/ProgressDialog.h"
#include "ui/instanceview/AccessibleInstanceView.h"
#include "ui/pages/BasePageProvider.h"
@@ -301,22 +308,6 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
dataPath = foo.absolutePath();
adjustedBy = "Persistent data path";
- QDir polymcData(FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation), "PolyMC"));
- if (polymcData.exists()) {
- dataPath = polymcData.absolutePath();
- adjustedBy = "PolyMC data path";
- }
-
-#ifdef Q_OS_LINUX
- // TODO: this should be removed in a future version
- // TODO: provide a migration path similar to macOS migration
- QDir bar(FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation), "polymc"));
- if (bar.exists()) {
- dataPath = bar.absolutePath();
- adjustedBy = "Legacy data path";
- }
-#endif
-
#ifndef Q_OS_MACOS
if (QFile::exists(FS::PathCombine(m_rootPath, "portable.txt"))) {
dataPath = m_rootPath;
@@ -440,6 +431,15 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
}
{
+ bool migrated = false;
+
+ if (!migrated)
+ migrated = handleDataMigration(dataPath, FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), "../../PolyMC"), "PolyMC", "polymc.cfg");
+ if (!migrated)
+ migrated = handleDataMigration(dataPath, FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), "../../multimc"), "MultiMC", "multimc.cfg");
+ }
+
+ {
qDebug() << BuildConfig.LAUNCHER_DISPLAYNAME << ", (c) 2013-2021 " << BuildConfig.LAUNCHER_COPYRIGHT;
qDebug() << "Version : " << BuildConfig.printableVersionString();
@@ -1605,3 +1605,88 @@ int Application::suitableMaxMem()
return maxMemoryAlloc;
}
+
+bool Application::handleDataMigration(const QString& currentData,
+ const QString& oldData,
+ const QString& name,
+ const QString& configFile) const
+{
+ QString nomigratePath = FS::PathCombine(currentData, name + "_nomigrate.txt");
+ QStringList configPaths = { FS::PathCombine(oldData, configFile), FS::PathCombine(oldData, BuildConfig.LAUNCHER_CONFIGFILE) };
+
+ QLocale locale;
+
+ // Is there a valid config at the old location?
+ bool configExists = false;
+ for (QString configPath : configPaths) {
+ configExists |= QFileInfo::exists(configPath);
+ }
+
+ if (!configExists || QFileInfo::exists(nomigratePath)) {
+ qDebug() << "<> No migration needed from" << name;
+ return false;
+ }
+
+ QString message;
+ bool currentExists = QFileInfo::exists(FS::PathCombine(currentData, BuildConfig.LAUNCHER_CONFIGFILE));
+
+ if (currentExists) {
+ message = tr("Old data from %1 was found, but you already have existing data for %2. Sadly you will need to migrate yourself. Do "
+ "you want to be reminded of the pending data migration next time you start %2?")
+ .arg(name, BuildConfig.LAUNCHER_DISPLAYNAME);
+ } else {
+ message = tr("It looks like you used %1 before. Do you want to migrate your data to the new location of %2?")
+ .arg(name, BuildConfig.LAUNCHER_DISPLAYNAME);
+
+ QFileInfo logInfo(FS::PathCombine(oldData, name + "-0.log"));
+ if (logInfo.exists()) {
+ QString lastModified = logInfo.lastModified().toString(locale.dateFormat());
+ message = tr("It looks like you used %1 on %2 before. Do you want to migrate your data to the new location of %3?")
+ .arg(name, lastModified, BuildConfig.LAUNCHER_DISPLAYNAME);
+ }
+ }
+
+ QMessageBox::StandardButton askMoveDialogue =
+ QMessageBox::question(nullptr, BuildCo